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 #ifdef RTE_LIBRTE_IXGBE_PMD
285 "set all queues drop (port_id) (on|off)\n"
286 " Set drop enable bit for all queues.\n\n"
288 "set vf split drop (port_id) (vf_id) (on|off)\n"
289 " Set split drop enable bit for a VF from the PF.\n\n"
292 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
293 " Set MAC antispoof for a VF from the PF.\n\n"
295 #ifdef RTE_LIBRTE_IXGBE_PMD
296 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
297 " Enable MACsec offload.\n\n"
299 "set macsec offload (port_id) off\n"
300 " Disable MACsec offload.\n\n"
302 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
303 " Configure MACsec secure connection (SC).\n\n"
305 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
306 " Configure MACsec secure association (SA).\n\n"
309 "set vf broadcast (port_id) (vf_id) (on|off)\n"
310 " Set VF broadcast for a VF from the PF.\n\n"
312 "vlan set strip (on|off) (port_id)\n"
313 " Set the VLAN strip on a port.\n\n"
315 "vlan set stripq (on|off) (port_id,queue_id)\n"
316 " Set the VLAN strip for a queue on a port.\n\n"
318 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
319 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
321 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
322 " Set VLAN insert for a VF from the PF.\n\n"
324 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
325 " Set VLAN antispoof for a VF from the PF.\n\n"
327 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
328 " Set VLAN tag for a VF from the PF.\n\n"
330 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
331 " Set a VF's max bandwidth(Mbps).\n\n"
333 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
334 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
336 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
337 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
339 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
340 " Set some TCs' strict link priority mode on a physical port.\n\n"
342 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
343 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
345 "vlan set filter (on|off) (port_id)\n"
346 " Set the VLAN filter on a port.\n\n"
348 "vlan set qinq (on|off) (port_id)\n"
349 " Set the VLAN QinQ (extended queue in queue)"
352 "vlan set (inner|outer) tpid (value) (port_id)\n"
353 " Set the VLAN TPID for Packet Filtering on"
356 "rx_vlan add (vlan_id|all) (port_id)\n"
357 " Add a vlan_id, or all identifiers, to the set"
358 " of VLAN identifiers filtered by port_id.\n\n"
360 "rx_vlan rm (vlan_id|all) (port_id)\n"
361 " Remove a vlan_id, or all identifiers, from the set"
362 " of VLAN identifiers filtered by port_id.\n\n"
364 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
365 " Add a vlan_id, to the set of VLAN identifiers"
366 "filtered for VF(s) from port_id.\n\n"
368 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
369 " Remove a vlan_id, to the set of VLAN identifiers"
370 "filtered for VF(s) from port_id.\n\n"
372 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
373 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
374 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
375 " add a tunnel filter of a port.\n\n"
377 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
378 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
379 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
380 " remove a tunnel filter of a port.\n\n"
382 "rx_vxlan_port add (udp_port) (port_id)\n"
383 " Add an UDP port for VXLAN packet filter on a port\n\n"
385 "rx_vxlan_port rm (udp_port) (port_id)\n"
386 " Remove an UDP port for VXLAN packet filter on a port\n\n"
388 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
389 " Set hardware insertion of VLAN IDs (single or double VLAN "
390 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
392 "tx_vlan set pvid port_id vlan_id (on|off)\n"
393 " Set port based TX VLAN insertion.\n\n"
395 "tx_vlan reset (port_id)\n"
396 " Disable hardware insertion of a VLAN header in"
397 " packets sent on a port.\n\n"
399 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
400 " Select hardware or software calculation of the"
401 " checksum when transmitting a packet using the"
402 " csum forward engine.\n"
403 " ip|udp|tcp|sctp always concern the inner layer.\n"
404 " outer-ip concerns the outer IP layer in"
405 " case the packet is recognized as a tunnel packet by"
406 " the forward engine (vxlan, gre and ipip are supported)\n"
407 " Please check the NIC datasheet for HW limits.\n\n"
409 "csum parse-tunnel (on|off) (tx_port_id)\n"
410 " If disabled, treat tunnel packets as non-tunneled"
411 " packets (treat inner headers as payload). The port\n"
412 " argument is the port used for TX in csum forward"
415 "csum show (port_id)\n"
416 " Display tx checksum offload configuration\n\n"
418 "tso set (segsize) (portid)\n"
419 " Enable TCP Segmentation Offload in csum forward"
421 " Please check the NIC datasheet for HW limits.\n\n"
424 " Display the status of TCP Segmentation Offload.\n\n"
427 " Set packet forwarding mode.\n\n"
429 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
430 " Add a MAC address on port_id.\n\n"
432 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
433 " Remove a MAC address from port_id.\n\n"
435 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
436 " Set the default MAC address for port_id.\n\n"
438 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
439 " Add a MAC address for a VF on the port.\n\n"
441 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
442 " Set the MAC address for a VF from the PF.\n\n"
444 "set port (port_id) uta (mac_address|all) (on|off)\n"
445 " Add/Remove a or all unicast hash filter(s)"
448 "set promisc (port_id|all) (on|off)\n"
449 " Set the promiscuous mode on port_id, or all.\n\n"
451 "set allmulti (port_id|all) (on|off)\n"
452 " Set the allmulti mode on port_id, or all.\n\n"
454 "set vf promisc (port_id) (vf_id) (on|off)\n"
455 " Set unicast promiscuous mode for a VF from the PF.\n\n"
457 "set vf allmulti (port_id) (vf_id) (on|off)\n"
458 " Set multicast promiscuous mode for a VF from the PF.\n\n"
460 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
461 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
462 " (on|off) autoneg (on|off) (port_id)\n"
463 "set flow_ctrl rx (on|off) (portid)\n"
464 "set flow_ctrl tx (on|off) (portid)\n"
465 "set flow_ctrl high_water (high_water) (portid)\n"
466 "set flow_ctrl low_water (low_water) (portid)\n"
467 "set flow_ctrl pause_time (pause_time) (portid)\n"
468 "set flow_ctrl send_xon (send_xon) (portid)\n"
469 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
470 "set flow_ctrl autoneg (on|off) (port_id)\n"
471 " Set the link flow control parameter on a port.\n\n"
473 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
474 " (low_water) (pause_time) (priority) (port_id)\n"
475 " Set the priority flow control parameter on a"
478 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
479 " Set statistics mapping (qmapping 0..15) for RX/TX"
481 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
482 " on port 0 to mapping 5.\n\n"
484 "set port (port_id) vf (vf_id) rx|tx on|off\n"
485 " Enable/Disable a VF receive/tranmit from a port\n\n"
487 "set port (port_id) vf (vf_id) (mac_addr)"
488 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
489 " Add/Remove unicast or multicast MAC addr filter"
492 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
494 " AUPE:accepts untagged VLAN;"
495 "ROPE:accept unicast hash\n\n"
496 " BAM:accepts broadcast packets;"
497 "MPE:accepts all multicast packets\n\n"
498 " Enable/Disable a VF receive mode of a port\n\n"
500 "set port (port_id) queue (queue_id) rate (rate_num)\n"
501 " Set rate limit for a queue of a port\n\n"
503 "set port (port_id) vf (vf_id) rate (rate_num) "
504 "queue_mask (queue_mask_value)\n"
505 " Set rate limit for queues in VF of a port\n\n"
507 "set port (port_id) mirror-rule (rule_id)"
508 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
509 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
510 " Set pool or vlan type mirror rule on a port.\n"
511 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
512 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
515 "set port (port_id) mirror-rule (rule_id)"
516 " (uplink-mirror|downlink-mirror) dst-pool"
517 " (pool_id) (on|off)\n"
518 " Set uplink or downlink type mirror rule on a port.\n"
519 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
520 " 0 on' enable mirror income traffic to pool 0.\n\n"
522 "reset port (port_id) mirror-rule (rule_id)\n"
523 " Reset a mirror rule.\n\n"
525 "set flush_rx (on|off)\n"
526 " Flush (default) or don't flush RX streams before"
527 " forwarding. Mainly used with PCAP drivers.\n\n"
529 "set bypass mode (normal|bypass|isolate) (port_id)\n"
530 " Set the bypass mode for the lowest port on bypass enabled"
533 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
534 "mode (normal|bypass|isolate) (port_id)\n"
535 " Set the event required to initiate specified bypass mode for"
536 " the lowest port on a bypass enabled NIC where:\n"
537 " timeout = enable bypass after watchdog timeout.\n"
538 " os_on = enable bypass when OS/board is powered on.\n"
539 " os_off = enable bypass when OS/board is powered off.\n"
540 " power_on = enable bypass when power supply is turned on.\n"
541 " power_off = enable bypass when power supply is turned off."
544 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
545 " Set the bypass watchdog timeout to 'n' seconds"
546 " where 0 = instant.\n\n"
548 "show bypass config (port_id)\n"
549 " Show the bypass configuration for a bypass enabled NIC"
550 " using the lowest port on the NIC.\n\n"
552 #ifdef RTE_LIBRTE_PMD_BOND
553 "create bonded device (mode) (socket)\n"
554 " Create a new bonded device with specific bonding mode and socket.\n\n"
556 "add bonding slave (slave_id) (port_id)\n"
557 " Add a slave device to a bonded device.\n\n"
559 "remove bonding slave (slave_id) (port_id)\n"
560 " Remove a slave device from a bonded device.\n\n"
562 "set bonding mode (value) (port_id)\n"
563 " Set the bonding mode on a bonded device.\n\n"
565 "set bonding primary (slave_id) (port_id)\n"
566 " Set the primary slave for a bonded device.\n\n"
568 "show bonding config (port_id)\n"
569 " Show the bonding config for port_id.\n\n"
571 "set bonding mac_addr (port_id) (address)\n"
572 " Set the MAC address of a bonded device.\n\n"
574 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
575 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
577 "set bonding mon_period (port_id) (value)\n"
578 " Set the bonding link status monitoring polling period in ms.\n\n"
580 "set link-up port (port_id)\n"
581 " Set link up for a port.\n\n"
583 "set link-down port (port_id)\n"
584 " Set link down for a port.\n\n"
586 "E-tag set insertion on port-tag-id (value)"
587 " port (port_id) vf (vf_id)\n"
588 " Enable E-tag insertion for a VF on a port\n\n"
590 "E-tag set insertion off port (port_id) vf (vf_id)\n"
591 " Disable E-tag insertion for a VF on a port\n\n"
593 "E-tag set stripping (on|off) port (port_id)\n"
594 " Enable/disable E-tag stripping on a port\n\n"
596 "E-tag set forwarding (on|off) port (port_id)\n"
597 " Enable/disable E-tag based forwarding"
600 "E-tag set filter add e-tag-id (value) dst-pool"
601 " (pool_id) port (port_id)\n"
602 " Add an E-tag forwarding filter on a port\n\n"
604 "E-tag set filter del e-tag-id (value) port (port_id)\n"
605 " Delete an E-tag forwarding filter on a port\n\n"
607 "ddp add (port_id) (profile_path)\n"
608 " Load a profile package on a port\n\n"
610 "ptype mapping get (port_id) (valid_only)\n"
611 " Get ptype mapping on a port\n\n"
613 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
614 " Replace target with the pkt_type in ptype mapping\n\n"
616 "ptype mapping reset (port_id)\n"
617 " Reset ptype mapping on a port\n\n"
619 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
620 " Update a ptype mapping item on a port\n\n"
622 , list_pkt_forwarding_modes()
626 if (show_all || !strcmp(res->section, "ports")) {
632 "----------------\n\n"
634 "port start (port_id|all)\n"
635 " Start all ports or port_id.\n\n"
637 "port stop (port_id|all)\n"
638 " Stop all ports or port_id.\n\n"
640 "port close (port_id|all)\n"
641 " Close all ports or port_id.\n\n"
643 "port attach (ident)\n"
644 " Attach physical or virtual dev by pci address or virtual device name\n\n"
646 "port detach (port_id)\n"
647 " Detach physical or virtual dev by port_id\n\n"
649 "port config (port_id|all)"
650 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
651 " duplex (half|full|auto)\n"
652 " Set speed and duplex for all ports or port_id\n\n"
654 "port config all (rxq|txq|rxd|txd) (value)\n"
655 " Set number for rxq/txq/rxd/txd.\n\n"
657 "port config all max-pkt-len (value)\n"
658 " Set the max packet length.\n\n"
660 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
661 "hw-vlan-strip|hw-vlan-extend|drop-en)"
663 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
666 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
667 " Set the RSS mode.\n\n"
669 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
670 " Set the RSS redirection table.\n\n"
672 "port config (port_id) dcb vt (on|off) (traffic_class)"
674 " Set the DCB mode.\n\n"
676 "port config all burst (value)\n"
677 " Set the number of packets per burst.\n\n"
679 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
681 " Set the ring prefetch/host/writeback threshold"
682 " for tx/rx queue.\n\n"
684 "port config all (txfreet|txrst|rxfreet) (value)\n"
685 " Set free threshold for rx/tx, or set"
686 " tx rs bit threshold.\n\n"
687 "port config mtu X value\n"
688 " Set the MTU of port X to a given value\n\n"
690 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
691 " Start/stop a rx/tx queue of port X. Only take effect"
692 " when port X is started\n\n"
694 "port config (port_id|all) l2-tunnel E-tag ether-type"
696 " Set the value of E-tag ether-type.\n\n"
698 "port config (port_id|all) l2-tunnel E-tag"
699 " (enable|disable)\n"
700 " Enable/disable the E-tag support.\n\n"
704 if (show_all || !strcmp(res->section, "registers")) {
712 "read reg (port_id) (address)\n"
713 " Display value of a port register.\n\n"
715 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
716 " Display a port register bit field.\n\n"
718 "read regbit (port_id) (address) (bit_x)\n"
719 " Display a single port register bit.\n\n"
721 "write reg (port_id) (address) (value)\n"
722 " Set value of a port register.\n\n"
724 "write regfield (port_id) (address) (bit_x) (bit_y)"
726 " Set bit field of a port register.\n\n"
728 "write regbit (port_id) (address) (bit_x) (value)\n"
729 " Set single bit value of a port register.\n\n"
732 if (show_all || !strcmp(res->section, "filters")) {
740 "ethertype_filter (port_id) (add|del)"
741 " (mac_addr|mac_ignr) (mac_address) ethertype"
742 " (ether_type) (drop|fwd) queue (queue_id)\n"
743 " Add/Del an ethertype filter.\n\n"
745 "2tuple_filter (port_id) (add|del)"
746 " dst_port (dst_port_value) protocol (protocol_value)"
747 " mask (mask_value) tcp_flags (tcp_flags_value)"
748 " priority (prio_value) queue (queue_id)\n"
749 " Add/Del a 2tuple filter.\n\n"
751 "5tuple_filter (port_id) (add|del)"
752 " dst_ip (dst_address) src_ip (src_address)"
753 " dst_port (dst_port_value) src_port (src_port_value)"
754 " protocol (protocol_value)"
755 " mask (mask_value) tcp_flags (tcp_flags_value)"
756 " priority (prio_value) queue (queue_id)\n"
757 " Add/Del a 5tuple filter.\n\n"
759 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
760 " Add/Del syn filter.\n\n"
762 "flex_filter (port_id) (add|del) len (len_value)"
763 " bytes (bytes_value) mask (mask_value)"
764 " priority (prio_value) queue (queue_id)\n"
765 " Add/Del a flex filter.\n\n"
767 "flow_director_filter (port_id) mode IP (add|del|update)"
768 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
769 " src (src_ip_address) dst (dst_ip_address)"
770 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
771 " vlan (vlan_value) flexbytes (flexbytes_value)"
772 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
773 " fd_id (fd_id_value)\n"
774 " Add/Del an IP type flow director filter.\n\n"
776 "flow_director_filter (port_id) mode IP (add|del|update)"
777 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
778 " src (src_ip_address) (src_port)"
779 " dst (dst_ip_address) (dst_port)"
780 " tos (tos_value) ttl (ttl_value)"
781 " vlan (vlan_value) flexbytes (flexbytes_value)"
782 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
783 " fd_id (fd_id_value)\n"
784 " Add/Del an UDP/TCP type flow director filter.\n\n"
786 "flow_director_filter (port_id) mode IP (add|del|update)"
787 " flow (ipv4-sctp|ipv6-sctp)"
788 " src (src_ip_address) (src_port)"
789 " dst (dst_ip_address) (dst_port)"
790 " tag (verification_tag) "
791 " tos (tos_value) ttl (ttl_value)"
793 " flexbytes (flexbytes_value) (drop|fwd)"
794 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
795 " Add/Del a SCTP type flow director filter.\n\n"
797 "flow_director_filter (port_id) mode IP (add|del|update)"
798 " flow l2_payload ether (ethertype)"
799 " flexbytes (flexbytes_value) (drop|fwd)"
800 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
801 " Add/Del a l2 payload type flow director filter.\n\n"
803 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
804 " mac (mac_address) vlan (vlan_value)"
805 " flexbytes (flexbytes_value) (drop|fwd)"
806 " queue (queue_id) fd_id (fd_id_value)\n"
807 " Add/Del a MAC-VLAN flow director filter.\n\n"
809 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
810 " mac (mac_address) vlan (vlan_value)"
811 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
812 " flexbytes (flexbytes_value) (drop|fwd)"
813 " queue (queue_id) fd_id (fd_id_value)\n"
814 " Add/Del a Tunnel flow director filter.\n\n"
816 "flush_flow_director (port_id)\n"
817 " Flush all flow director entries of a device.\n\n"
819 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
820 " src_mask (ipv4_src) (ipv6_src) (src_port)"
821 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
822 " Set flow director IP mask.\n\n"
824 "flow_director_mask (port_id) mode MAC-VLAN"
825 " vlan (vlan_value)\n"
826 " Set flow director MAC-VLAN mask.\n\n"
828 "flow_director_mask (port_id) mode Tunnel"
829 " vlan (vlan_value) mac (mac_value)"
830 " tunnel-type (tunnel_type_value)"
831 " tunnel-id (tunnel_id_value)\n"
832 " Set flow director Tunnel mask.\n\n"
834 "flow_director_flex_mask (port_id)"
835 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
836 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
838 " Configure mask of flex payload.\n\n"
840 "flow_director_flex_payload (port_id)"
841 " (raw|l2|l3|l4) (config)\n"
842 " Configure flex payload selection.\n\n"
844 "get_sym_hash_ena_per_port (port_id)\n"
845 " get symmetric hash enable configuration per port.\n\n"
847 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
848 " set symmetric hash enable configuration per port"
849 " to enable or disable.\n\n"
851 "get_hash_global_config (port_id)\n"
852 " Get the global configurations of hash filters.\n\n"
854 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
855 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
856 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
857 " (enable|disable)\n"
858 " Set the global configurations of hash filters.\n\n"
860 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
861 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
862 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
863 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
864 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
865 "ipv6-next-header|udp-src-port|udp-dst-port|"
866 "tcp-src-port|tcp-dst-port|sctp-src-port|"
867 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
868 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
869 "fld-8th|none) (select|add)\n"
870 " Set the input set for hash.\n\n"
872 "set_fdir_input_set (port_id) "
873 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
874 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
875 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
876 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
877 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
878 "udp-dst-port|tcp-src-port|tcp-dst-port|"
879 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
881 " Set the input set for FDir.\n\n"
883 "flow validate {port_id}"
884 " [group {group_id}] [priority {level}]"
885 " [ingress] [egress]"
886 " pattern {item} [/ {item} [...]] / end"
887 " actions {action} [/ {action} [...]] / end\n"
888 " Check whether a flow rule can be created.\n\n"
890 "flow create {port_id}"
891 " [group {group_id}] [priority {level}]"
892 " [ingress] [egress]"
893 " pattern {item} [/ {item} [...]] / end"
894 " actions {action} [/ {action} [...]] / end\n"
895 " Create a flow rule.\n\n"
897 "flow destroy {port_id} rule {rule_id} [...]\n"
898 " Destroy specific flow rules.\n\n"
900 "flow flush {port_id}\n"
901 " Destroy all flow rules.\n\n"
903 "flow query {port_id} {rule_id} {action}\n"
904 " Query an existing flow rule.\n\n"
906 "flow list {port_id} [group {group_id}] [...]\n"
907 " List existing flow rules sorted by priority,"
908 " filtered by group identifiers.\n\n"
910 "flow isolate {port_id} {boolean}\n"
911 " Restrict ingress traffic to the defined"
917 cmdline_parse_token_string_t cmd_help_long_help =
918 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
920 cmdline_parse_token_string_t cmd_help_long_section =
921 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
922 "all#control#display#config#"
923 "ports#registers#filters");
925 cmdline_parse_inst_t cmd_help_long = {
926 .f = cmd_help_long_parsed,
928 .help_str = "help all|control|display|config|ports|register|filters: "
931 (void *)&cmd_help_long_help,
932 (void *)&cmd_help_long_section,
938 /* *** start/stop/close all ports *** */
939 struct cmd_operate_port_result {
940 cmdline_fixed_string_t keyword;
941 cmdline_fixed_string_t name;
942 cmdline_fixed_string_t value;
945 static void cmd_operate_port_parsed(void *parsed_result,
946 __attribute__((unused)) struct cmdline *cl,
947 __attribute__((unused)) void *data)
949 struct cmd_operate_port_result *res = parsed_result;
951 if (!strcmp(res->name, "start"))
952 start_port(RTE_PORT_ALL);
953 else if (!strcmp(res->name, "stop"))
954 stop_port(RTE_PORT_ALL);
955 else if (!strcmp(res->name, "close"))
956 close_port(RTE_PORT_ALL);
958 printf("Unknown parameter\n");
961 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
962 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
964 cmdline_parse_token_string_t cmd_operate_port_all_port =
965 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
967 cmdline_parse_token_string_t cmd_operate_port_all_all =
968 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
970 cmdline_parse_inst_t cmd_operate_port = {
971 .f = cmd_operate_port_parsed,
973 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
975 (void *)&cmd_operate_port_all_cmd,
976 (void *)&cmd_operate_port_all_port,
977 (void *)&cmd_operate_port_all_all,
982 /* *** start/stop/close specific port *** */
983 struct cmd_operate_specific_port_result {
984 cmdline_fixed_string_t keyword;
985 cmdline_fixed_string_t name;
989 static void cmd_operate_specific_port_parsed(void *parsed_result,
990 __attribute__((unused)) struct cmdline *cl,
991 __attribute__((unused)) void *data)
993 struct cmd_operate_specific_port_result *res = parsed_result;
995 if (!strcmp(res->name, "start"))
996 start_port(res->value);
997 else if (!strcmp(res->name, "stop"))
998 stop_port(res->value);
999 else if (!strcmp(res->name, "close"))
1000 close_port(res->value);
1002 printf("Unknown parameter\n");
1005 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1006 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1008 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1009 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1010 name, "start#stop#close");
1011 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1012 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1015 cmdline_parse_inst_t cmd_operate_specific_port = {
1016 .f = cmd_operate_specific_port_parsed,
1018 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
1020 (void *)&cmd_operate_specific_port_cmd,
1021 (void *)&cmd_operate_specific_port_port,
1022 (void *)&cmd_operate_specific_port_id,
1027 /* *** attach a specified port *** */
1028 struct cmd_operate_attach_port_result {
1029 cmdline_fixed_string_t port;
1030 cmdline_fixed_string_t keyword;
1031 cmdline_fixed_string_t identifier;
1034 static void cmd_operate_attach_port_parsed(void *parsed_result,
1035 __attribute__((unused)) struct cmdline *cl,
1036 __attribute__((unused)) void *data)
1038 struct cmd_operate_attach_port_result *res = parsed_result;
1040 if (!strcmp(res->keyword, "attach"))
1041 attach_port(res->identifier);
1043 printf("Unknown parameter\n");
1046 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1047 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1049 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1050 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1052 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1053 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1056 cmdline_parse_inst_t cmd_operate_attach_port = {
1057 .f = cmd_operate_attach_port_parsed,
1059 .help_str = "port attach <identifier>: "
1060 "(identifier: pci address or virtual dev name)",
1062 (void *)&cmd_operate_attach_port_port,
1063 (void *)&cmd_operate_attach_port_keyword,
1064 (void *)&cmd_operate_attach_port_identifier,
1069 /* *** detach a specified port *** */
1070 struct cmd_operate_detach_port_result {
1071 cmdline_fixed_string_t port;
1072 cmdline_fixed_string_t keyword;
1076 static void cmd_operate_detach_port_parsed(void *parsed_result,
1077 __attribute__((unused)) struct cmdline *cl,
1078 __attribute__((unused)) void *data)
1080 struct cmd_operate_detach_port_result *res = parsed_result;
1082 if (!strcmp(res->keyword, "detach"))
1083 detach_port(res->port_id);
1085 printf("Unknown parameter\n");
1088 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1089 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1091 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1092 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1094 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1095 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1098 cmdline_parse_inst_t cmd_operate_detach_port = {
1099 .f = cmd_operate_detach_port_parsed,
1101 .help_str = "port detach <port_id>",
1103 (void *)&cmd_operate_detach_port_port,
1104 (void *)&cmd_operate_detach_port_keyword,
1105 (void *)&cmd_operate_detach_port_port_id,
1110 /* *** configure speed for all ports *** */
1111 struct cmd_config_speed_all {
1112 cmdline_fixed_string_t port;
1113 cmdline_fixed_string_t keyword;
1114 cmdline_fixed_string_t all;
1115 cmdline_fixed_string_t item1;
1116 cmdline_fixed_string_t item2;
1117 cmdline_fixed_string_t value1;
1118 cmdline_fixed_string_t value2;
1122 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1127 if (!strcmp(duplexstr, "half")) {
1128 duplex = ETH_LINK_HALF_DUPLEX;
1129 } else if (!strcmp(duplexstr, "full")) {
1130 duplex = ETH_LINK_FULL_DUPLEX;
1131 } else if (!strcmp(duplexstr, "auto")) {
1132 duplex = ETH_LINK_FULL_DUPLEX;
1134 printf("Unknown duplex parameter\n");
1138 if (!strcmp(speedstr, "10")) {
1139 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1140 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1141 } else if (!strcmp(speedstr, "100")) {
1142 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1143 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1145 if (duplex != ETH_LINK_FULL_DUPLEX) {
1146 printf("Invalid speed/duplex parameters\n");
1149 if (!strcmp(speedstr, "1000")) {
1150 *speed = ETH_LINK_SPEED_1G;
1151 } else if (!strcmp(speedstr, "10000")) {
1152 *speed = ETH_LINK_SPEED_10G;
1153 } else if (!strcmp(speedstr, "25000")) {
1154 *speed = ETH_LINK_SPEED_25G;
1155 } else if (!strcmp(speedstr, "40000")) {
1156 *speed = ETH_LINK_SPEED_40G;
1157 } else if (!strcmp(speedstr, "50000")) {
1158 *speed = ETH_LINK_SPEED_50G;
1159 } else if (!strcmp(speedstr, "100000")) {
1160 *speed = ETH_LINK_SPEED_100G;
1161 } else if (!strcmp(speedstr, "auto")) {
1162 *speed = ETH_LINK_SPEED_AUTONEG;
1164 printf("Unknown speed parameter\n");
1173 cmd_config_speed_all_parsed(void *parsed_result,
1174 __attribute__((unused)) struct cmdline *cl,
1175 __attribute__((unused)) void *data)
1177 struct cmd_config_speed_all *res = parsed_result;
1178 uint32_t link_speed;
1181 if (!all_ports_stopped()) {
1182 printf("Please stop all ports first\n");
1186 if (parse_and_check_speed_duplex(res->value1, res->value2,
1190 RTE_ETH_FOREACH_DEV(pid) {
1191 ports[pid].dev_conf.link_speeds = link_speed;
1194 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1197 cmdline_parse_token_string_t cmd_config_speed_all_port =
1198 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1199 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1200 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1202 cmdline_parse_token_string_t cmd_config_speed_all_all =
1203 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1204 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1205 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1206 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1207 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1208 "10#100#1000#10000#25000#40000#50000#100000#auto");
1209 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1210 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1211 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1212 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1215 cmdline_parse_inst_t cmd_config_speed_all = {
1216 .f = cmd_config_speed_all_parsed,
1218 .help_str = "port config all speed "
1219 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1222 (void *)&cmd_config_speed_all_port,
1223 (void *)&cmd_config_speed_all_keyword,
1224 (void *)&cmd_config_speed_all_all,
1225 (void *)&cmd_config_speed_all_item1,
1226 (void *)&cmd_config_speed_all_value1,
1227 (void *)&cmd_config_speed_all_item2,
1228 (void *)&cmd_config_speed_all_value2,
1233 /* *** configure speed for specific port *** */
1234 struct cmd_config_speed_specific {
1235 cmdline_fixed_string_t port;
1236 cmdline_fixed_string_t keyword;
1238 cmdline_fixed_string_t item1;
1239 cmdline_fixed_string_t item2;
1240 cmdline_fixed_string_t value1;
1241 cmdline_fixed_string_t value2;
1245 cmd_config_speed_specific_parsed(void *parsed_result,
1246 __attribute__((unused)) struct cmdline *cl,
1247 __attribute__((unused)) void *data)
1249 struct cmd_config_speed_specific *res = parsed_result;
1250 uint32_t link_speed;
1252 if (!all_ports_stopped()) {
1253 printf("Please stop all ports first\n");
1257 if (port_id_is_invalid(res->id, ENABLED_WARN))
1260 if (parse_and_check_speed_duplex(res->value1, res->value2,
1264 ports[res->id].dev_conf.link_speeds = link_speed;
1266 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1270 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1271 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1273 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1274 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1276 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1277 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1278 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1279 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1281 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1282 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1283 "10#100#1000#10000#25000#40000#50000#100000#auto");
1284 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1285 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1287 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1288 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1291 cmdline_parse_inst_t cmd_config_speed_specific = {
1292 .f = cmd_config_speed_specific_parsed,
1294 .help_str = "port config <port_id> speed "
1295 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1298 (void *)&cmd_config_speed_specific_port,
1299 (void *)&cmd_config_speed_specific_keyword,
1300 (void *)&cmd_config_speed_specific_id,
1301 (void *)&cmd_config_speed_specific_item1,
1302 (void *)&cmd_config_speed_specific_value1,
1303 (void *)&cmd_config_speed_specific_item2,
1304 (void *)&cmd_config_speed_specific_value2,
1309 /* *** configure txq/rxq, txd/rxd *** */
1310 struct cmd_config_rx_tx {
1311 cmdline_fixed_string_t port;
1312 cmdline_fixed_string_t keyword;
1313 cmdline_fixed_string_t all;
1314 cmdline_fixed_string_t name;
1319 cmd_config_rx_tx_parsed(void *parsed_result,
1320 __attribute__((unused)) struct cmdline *cl,
1321 __attribute__((unused)) void *data)
1323 struct cmd_config_rx_tx *res = parsed_result;
1325 if (!all_ports_stopped()) {
1326 printf("Please stop all ports first\n");
1329 if (!strcmp(res->name, "rxq")) {
1330 if (!res->value && !nb_txq) {
1331 printf("Warning: Either rx or tx queues should be non zero\n");
1334 nb_rxq = res->value;
1336 else if (!strcmp(res->name, "txq")) {
1337 if (!res->value && !nb_rxq) {
1338 printf("Warning: Either rx or tx queues should be non zero\n");
1341 nb_txq = res->value;
1343 else if (!strcmp(res->name, "rxd")) {
1344 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1345 printf("rxd %d invalid - must be > 0 && <= %d\n",
1346 res->value, RTE_TEST_RX_DESC_MAX);
1349 nb_rxd = res->value;
1350 } else if (!strcmp(res->name, "txd")) {
1351 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1352 printf("txd %d invalid - must be > 0 && <= %d\n",
1353 res->value, RTE_TEST_TX_DESC_MAX);
1356 nb_txd = res->value;
1358 printf("Unknown parameter\n");
1366 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1369 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1370 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1371 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1372 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1373 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1374 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1375 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1376 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1378 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1379 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1381 cmdline_parse_inst_t cmd_config_rx_tx = {
1382 .f = cmd_config_rx_tx_parsed,
1384 .help_str = "port config all rxq|txq|rxd|txd <value>",
1386 (void *)&cmd_config_rx_tx_port,
1387 (void *)&cmd_config_rx_tx_keyword,
1388 (void *)&cmd_config_rx_tx_all,
1389 (void *)&cmd_config_rx_tx_name,
1390 (void *)&cmd_config_rx_tx_value,
1395 /* *** config max packet length *** */
1396 struct cmd_config_max_pkt_len_result {
1397 cmdline_fixed_string_t port;
1398 cmdline_fixed_string_t keyword;
1399 cmdline_fixed_string_t all;
1400 cmdline_fixed_string_t name;
1405 cmd_config_max_pkt_len_parsed(void *parsed_result,
1406 __attribute__((unused)) struct cmdline *cl,
1407 __attribute__((unused)) void *data)
1409 struct cmd_config_max_pkt_len_result *res = parsed_result;
1411 if (!all_ports_stopped()) {
1412 printf("Please stop all ports first\n");
1416 if (!strcmp(res->name, "max-pkt-len")) {
1417 if (res->value < ETHER_MIN_LEN) {
1418 printf("max-pkt-len can not be less than %d\n",
1422 if (res->value == rx_mode.max_rx_pkt_len)
1425 rx_mode.max_rx_pkt_len = res->value;
1426 if (res->value > ETHER_MAX_LEN)
1427 rx_mode.jumbo_frame = 1;
1429 rx_mode.jumbo_frame = 0;
1431 printf("Unknown parameter\n");
1437 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1440 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1441 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1443 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1444 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1446 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1447 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1449 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1450 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1452 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1453 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1456 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1457 .f = cmd_config_max_pkt_len_parsed,
1459 .help_str = "port config all max-pkt-len <value>",
1461 (void *)&cmd_config_max_pkt_len_port,
1462 (void *)&cmd_config_max_pkt_len_keyword,
1463 (void *)&cmd_config_max_pkt_len_all,
1464 (void *)&cmd_config_max_pkt_len_name,
1465 (void *)&cmd_config_max_pkt_len_value,
1470 /* *** configure port MTU *** */
1471 struct cmd_config_mtu_result {
1472 cmdline_fixed_string_t port;
1473 cmdline_fixed_string_t keyword;
1474 cmdline_fixed_string_t mtu;
1480 cmd_config_mtu_parsed(void *parsed_result,
1481 __attribute__((unused)) struct cmdline *cl,
1482 __attribute__((unused)) void *data)
1484 struct cmd_config_mtu_result *res = parsed_result;
1486 if (res->value < ETHER_MIN_LEN) {
1487 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1490 port_mtu_set(res->port_id, res->value);
1493 cmdline_parse_token_string_t cmd_config_mtu_port =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1496 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1497 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1499 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1500 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1502 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1503 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1504 cmdline_parse_token_num_t cmd_config_mtu_value =
1505 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1507 cmdline_parse_inst_t cmd_config_mtu = {
1508 .f = cmd_config_mtu_parsed,
1510 .help_str = "port config mtu <port_id> <value>",
1512 (void *)&cmd_config_mtu_port,
1513 (void *)&cmd_config_mtu_keyword,
1514 (void *)&cmd_config_mtu_mtu,
1515 (void *)&cmd_config_mtu_port_id,
1516 (void *)&cmd_config_mtu_value,
1521 /* *** configure rx mode *** */
1522 struct cmd_config_rx_mode_flag {
1523 cmdline_fixed_string_t port;
1524 cmdline_fixed_string_t keyword;
1525 cmdline_fixed_string_t all;
1526 cmdline_fixed_string_t name;
1527 cmdline_fixed_string_t value;
1531 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1532 __attribute__((unused)) struct cmdline *cl,
1533 __attribute__((unused)) void *data)
1535 struct cmd_config_rx_mode_flag *res = parsed_result;
1537 if (!all_ports_stopped()) {
1538 printf("Please stop all ports first\n");
1542 if (!strcmp(res->name, "crc-strip")) {
1543 if (!strcmp(res->value, "on"))
1544 rx_mode.hw_strip_crc = 1;
1545 else if (!strcmp(res->value, "off"))
1546 rx_mode.hw_strip_crc = 0;
1548 printf("Unknown parameter\n");
1551 } else if (!strcmp(res->name, "scatter")) {
1552 if (!strcmp(res->value, "on"))
1553 rx_mode.enable_scatter = 1;
1554 else if (!strcmp(res->value, "off"))
1555 rx_mode.enable_scatter = 0;
1557 printf("Unknown parameter\n");
1560 } else if (!strcmp(res->name, "rx-cksum")) {
1561 if (!strcmp(res->value, "on"))
1562 rx_mode.hw_ip_checksum = 1;
1563 else if (!strcmp(res->value, "off"))
1564 rx_mode.hw_ip_checksum = 0;
1566 printf("Unknown parameter\n");
1569 } else if (!strcmp(res->name, "hw-vlan")) {
1570 if (!strcmp(res->value, "on")) {
1571 rx_mode.hw_vlan_filter = 1;
1572 rx_mode.hw_vlan_strip = 1;
1574 else if (!strcmp(res->value, "off")) {
1575 rx_mode.hw_vlan_filter = 0;
1576 rx_mode.hw_vlan_strip = 0;
1579 printf("Unknown parameter\n");
1582 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1583 if (!strcmp(res->value, "on"))
1584 rx_mode.hw_vlan_filter = 1;
1585 else if (!strcmp(res->value, "off"))
1586 rx_mode.hw_vlan_filter = 0;
1588 printf("Unknown parameter\n");
1591 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1592 if (!strcmp(res->value, "on"))
1593 rx_mode.hw_vlan_strip = 1;
1594 else if (!strcmp(res->value, "off"))
1595 rx_mode.hw_vlan_strip = 0;
1597 printf("Unknown parameter\n");
1600 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1601 if (!strcmp(res->value, "on"))
1602 rx_mode.hw_vlan_extend = 1;
1603 else if (!strcmp(res->value, "off"))
1604 rx_mode.hw_vlan_extend = 0;
1606 printf("Unknown parameter\n");
1609 } else if (!strcmp(res->name, "drop-en")) {
1610 if (!strcmp(res->value, "on"))
1612 else if (!strcmp(res->value, "off"))
1615 printf("Unknown parameter\n");
1619 printf("Unknown parameter\n");
1625 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1628 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1630 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1633 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1635 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1636 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1637 "crc-strip#scatter#rx-cksum#hw-vlan#"
1638 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1639 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1643 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1644 .f = cmd_config_rx_mode_flag_parsed,
1646 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1647 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1649 (void *)&cmd_config_rx_mode_flag_port,
1650 (void *)&cmd_config_rx_mode_flag_keyword,
1651 (void *)&cmd_config_rx_mode_flag_all,
1652 (void *)&cmd_config_rx_mode_flag_name,
1653 (void *)&cmd_config_rx_mode_flag_value,
1658 /* *** configure rss *** */
1659 struct cmd_config_rss {
1660 cmdline_fixed_string_t port;
1661 cmdline_fixed_string_t keyword;
1662 cmdline_fixed_string_t all;
1663 cmdline_fixed_string_t name;
1664 cmdline_fixed_string_t value;
1668 cmd_config_rss_parsed(void *parsed_result,
1669 __attribute__((unused)) struct cmdline *cl,
1670 __attribute__((unused)) void *data)
1672 struct cmd_config_rss *res = parsed_result;
1673 struct rte_eth_rss_conf rss_conf;
1677 if (!strcmp(res->value, "all"))
1678 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1679 ETH_RSS_UDP | ETH_RSS_SCTP |
1681 else if (!strcmp(res->value, "ip"))
1682 rss_conf.rss_hf = ETH_RSS_IP;
1683 else if (!strcmp(res->value, "udp"))
1684 rss_conf.rss_hf = ETH_RSS_UDP;
1685 else if (!strcmp(res->value, "tcp"))
1686 rss_conf.rss_hf = ETH_RSS_TCP;
1687 else if (!strcmp(res->value, "sctp"))
1688 rss_conf.rss_hf = ETH_RSS_SCTP;
1689 else if (!strcmp(res->value, "ether"))
1690 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1691 else if (!strcmp(res->value, "port"))
1692 rss_conf.rss_hf = ETH_RSS_PORT;
1693 else if (!strcmp(res->value, "vxlan"))
1694 rss_conf.rss_hf = ETH_RSS_VXLAN;
1695 else if (!strcmp(res->value, "geneve"))
1696 rss_conf.rss_hf = ETH_RSS_GENEVE;
1697 else if (!strcmp(res->value, "nvgre"))
1698 rss_conf.rss_hf = ETH_RSS_NVGRE;
1699 else if (!strcmp(res->value, "none"))
1700 rss_conf.rss_hf = 0;
1702 printf("Unknown parameter\n");
1705 rss_conf.rss_key = NULL;
1706 for (i = 0; i < rte_eth_dev_count(); i++) {
1707 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1709 printf("Configuration of RSS hash at ethernet port %d "
1710 "failed with error (%d): %s.\n",
1711 i, -diag, strerror(-diag));
1715 cmdline_parse_token_string_t cmd_config_rss_port =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1717 cmdline_parse_token_string_t cmd_config_rss_keyword =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1719 cmdline_parse_token_string_t cmd_config_rss_all =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1721 cmdline_parse_token_string_t cmd_config_rss_name =
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1723 cmdline_parse_token_string_t cmd_config_rss_value =
1724 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1725 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1727 cmdline_parse_inst_t cmd_config_rss = {
1728 .f = cmd_config_rss_parsed,
1730 .help_str = "port config all rss "
1731 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1733 (void *)&cmd_config_rss_port,
1734 (void *)&cmd_config_rss_keyword,
1735 (void *)&cmd_config_rss_all,
1736 (void *)&cmd_config_rss_name,
1737 (void *)&cmd_config_rss_value,
1742 /* *** configure rss hash key *** */
1743 struct cmd_config_rss_hash_key {
1744 cmdline_fixed_string_t port;
1745 cmdline_fixed_string_t config;
1747 cmdline_fixed_string_t rss_hash_key;
1748 cmdline_fixed_string_t rss_type;
1749 cmdline_fixed_string_t key;
1753 hexa_digit_to_value(char hexa_digit)
1755 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1756 return (uint8_t) (hexa_digit - '0');
1757 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1758 return (uint8_t) ((hexa_digit - 'a') + 10);
1759 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1760 return (uint8_t) ((hexa_digit - 'A') + 10);
1761 /* Invalid hexa digit */
1766 parse_and_check_key_hexa_digit(char *key, int idx)
1770 hexa_v = hexa_digit_to_value(key[idx]);
1772 printf("invalid key: character %c at position %d is not a "
1773 "valid hexa digit\n", key[idx], idx);
1778 cmd_config_rss_hash_key_parsed(void *parsed_result,
1779 __attribute__((unused)) struct cmdline *cl,
1780 __attribute__((unused)) void *data)
1782 struct cmd_config_rss_hash_key *res = parsed_result;
1783 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1787 struct rte_eth_dev_info dev_info;
1788 uint8_t hash_key_size;
1791 memset(&dev_info, 0, sizeof(dev_info));
1792 rte_eth_dev_info_get(res->port_id, &dev_info);
1793 if (dev_info.hash_key_size > 0 &&
1794 dev_info.hash_key_size <= sizeof(hash_key))
1795 hash_key_size = dev_info.hash_key_size;
1797 printf("dev_info did not provide a valid hash key size\n");
1800 /* Check the length of the RSS hash key */
1801 key_len = strlen(res->key);
1802 if (key_len != (hash_key_size * 2)) {
1803 printf("key length: %d invalid - key must be a string of %d"
1804 " hexa-decimal numbers\n",
1805 (int) key_len, hash_key_size * 2);
1808 /* Translate RSS hash key into binary representation */
1809 for (i = 0; i < hash_key_size; i++) {
1810 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1813 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1816 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1818 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1822 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1823 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1824 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1825 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1827 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1828 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1829 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1830 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1831 rss_hash_key, "rss-hash-key");
1832 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1833 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1834 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1835 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1836 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1837 "ipv6-tcp-ex#ipv6-udp-ex");
1838 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1839 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1841 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1842 .f = cmd_config_rss_hash_key_parsed,
1844 .help_str = "port config <port_id> rss-hash-key "
1845 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1846 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1847 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1848 "<string of hex digits (variable length, NIC dependent)>",
1850 (void *)&cmd_config_rss_hash_key_port,
1851 (void *)&cmd_config_rss_hash_key_config,
1852 (void *)&cmd_config_rss_hash_key_port_id,
1853 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1854 (void *)&cmd_config_rss_hash_key_rss_type,
1855 (void *)&cmd_config_rss_hash_key_value,
1860 /* *** configure port rxq/txq start/stop *** */
1861 struct cmd_config_rxtx_queue {
1862 cmdline_fixed_string_t port;
1864 cmdline_fixed_string_t rxtxq;
1866 cmdline_fixed_string_t opname;
1870 cmd_config_rxtx_queue_parsed(void *parsed_result,
1871 __attribute__((unused)) struct cmdline *cl,
1872 __attribute__((unused)) void *data)
1874 struct cmd_config_rxtx_queue *res = parsed_result;
1879 if (test_done == 0) {
1880 printf("Please stop forwarding first\n");
1884 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1887 if (port_is_started(res->portid) != 1) {
1888 printf("Please start port %u first\n", res->portid);
1892 if (!strcmp(res->rxtxq, "rxq"))
1894 else if (!strcmp(res->rxtxq, "txq"))
1897 printf("Unknown parameter\n");
1901 if (isrx && rx_queue_id_is_invalid(res->qid))
1903 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1906 if (!strcmp(res->opname, "start"))
1908 else if (!strcmp(res->opname, "stop"))
1911 printf("Unknown parameter\n");
1915 if (isstart && isrx)
1916 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1917 else if (!isstart && isrx)
1918 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1919 else if (isstart && !isrx)
1920 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1922 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1924 if (ret == -ENOTSUP)
1925 printf("Function not supported in PMD driver\n");
1928 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1929 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1930 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1931 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1932 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1933 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1934 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1935 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1936 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1937 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1940 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1941 .f = cmd_config_rxtx_queue_parsed,
1943 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1945 (void *)&cmd_config_speed_all_port,
1946 (void *)&cmd_config_rxtx_queue_portid,
1947 (void *)&cmd_config_rxtx_queue_rxtxq,
1948 (void *)&cmd_config_rxtx_queue_qid,
1949 (void *)&cmd_config_rxtx_queue_opname,
1954 /* *** Configure RSS RETA *** */
1955 struct cmd_config_rss_reta {
1956 cmdline_fixed_string_t port;
1957 cmdline_fixed_string_t keyword;
1959 cmdline_fixed_string_t name;
1960 cmdline_fixed_string_t list_name;
1961 cmdline_fixed_string_t list_of_items;
1965 parse_reta_config(const char *str,
1966 struct rte_eth_rss_reta_entry64 *reta_conf,
1967 uint16_t nb_entries)
1971 uint16_t hash_index, idx, shift;
1974 const char *p, *p0 = str;
1981 unsigned long int_fld[_NUM_FLD];
1982 char *str_fld[_NUM_FLD];
1984 while ((p = strchr(p0,'(')) != NULL) {
1986 if((p0 = strchr(p,')')) == NULL)
1990 if(size >= sizeof(s))
1993 snprintf(s, sizeof(s), "%.*s", size, p);
1994 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1996 for (i = 0; i < _NUM_FLD; i++) {
1998 int_fld[i] = strtoul(str_fld[i], &end, 0);
1999 if (errno != 0 || end == str_fld[i] ||
2004 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2005 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2007 if (hash_index >= nb_entries) {
2008 printf("Invalid RETA hash index=%d\n", hash_index);
2012 idx = hash_index / RTE_RETA_GROUP_SIZE;
2013 shift = hash_index % RTE_RETA_GROUP_SIZE;
2014 reta_conf[idx].mask |= (1ULL << shift);
2015 reta_conf[idx].reta[shift] = nb_queue;
2022 cmd_set_rss_reta_parsed(void *parsed_result,
2023 __attribute__((unused)) struct cmdline *cl,
2024 __attribute__((unused)) void *data)
2027 struct rte_eth_dev_info dev_info;
2028 struct rte_eth_rss_reta_entry64 reta_conf[8];
2029 struct cmd_config_rss_reta *res = parsed_result;
2031 memset(&dev_info, 0, sizeof(dev_info));
2032 rte_eth_dev_info_get(res->port_id, &dev_info);
2033 if (dev_info.reta_size == 0) {
2034 printf("Redirection table size is 0 which is "
2035 "invalid for RSS\n");
2038 printf("The reta size of port %d is %u\n",
2039 res->port_id, dev_info.reta_size);
2040 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2041 printf("Currently do not support more than %u entries of "
2042 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2046 memset(reta_conf, 0, sizeof(reta_conf));
2047 if (!strcmp(res->list_name, "reta")) {
2048 if (parse_reta_config(res->list_of_items, reta_conf,
2049 dev_info.reta_size)) {
2050 printf("Invalid RSS Redirection Table "
2051 "config entered\n");
2054 ret = rte_eth_dev_rss_reta_update(res->port_id,
2055 reta_conf, dev_info.reta_size);
2057 printf("Bad redirection table parameter, "
2058 "return code = %d \n", ret);
2062 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2063 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2064 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2066 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2067 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2068 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2069 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2070 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2071 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2072 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2073 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2075 cmdline_parse_inst_t cmd_config_rss_reta = {
2076 .f = cmd_set_rss_reta_parsed,
2078 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2080 (void *)&cmd_config_rss_reta_port,
2081 (void *)&cmd_config_rss_reta_keyword,
2082 (void *)&cmd_config_rss_reta_port_id,
2083 (void *)&cmd_config_rss_reta_name,
2084 (void *)&cmd_config_rss_reta_list_name,
2085 (void *)&cmd_config_rss_reta_list_of_items,
2090 /* *** SHOW PORT RETA INFO *** */
2091 struct cmd_showport_reta {
2092 cmdline_fixed_string_t show;
2093 cmdline_fixed_string_t port;
2095 cmdline_fixed_string_t rss;
2096 cmdline_fixed_string_t reta;
2098 cmdline_fixed_string_t list_of_items;
2102 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2103 uint16_t nb_entries,
2107 const char *p, *p0 = str;
2112 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2113 RTE_RETA_GROUP_SIZE;
2116 p = strchr(p0, '(');
2120 p0 = strchr(p, ')');
2124 if (size >= sizeof(s)) {
2125 printf("The string size exceeds the internal buffer size\n");
2128 snprintf(s, sizeof(s), "%.*s", size, p);
2129 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2130 if (ret <= 0 || ret != num) {
2131 printf("The bits of masks do not match the number of "
2132 "reta entries: %u\n", num);
2135 for (i = 0; i < ret; i++)
2136 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2142 cmd_showport_reta_parsed(void *parsed_result,
2143 __attribute__((unused)) struct cmdline *cl,
2144 __attribute__((unused)) void *data)
2146 struct cmd_showport_reta *res = parsed_result;
2147 struct rte_eth_rss_reta_entry64 reta_conf[8];
2148 struct rte_eth_dev_info dev_info;
2150 memset(&dev_info, 0, sizeof(dev_info));
2151 rte_eth_dev_info_get(res->port_id, &dev_info);
2152 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2153 res->size > ETH_RSS_RETA_SIZE_512) {
2154 printf("Invalid redirection table size: %u\n", res->size);
2158 memset(reta_conf, 0, sizeof(reta_conf));
2159 if (showport_parse_reta_config(reta_conf, res->size,
2160 res->list_of_items) < 0) {
2161 printf("Invalid string: %s for reta masks\n",
2162 res->list_of_items);
2165 port_rss_reta_info(res->port_id, reta_conf, res->size);
2168 cmdline_parse_token_string_t cmd_showport_reta_show =
2169 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2170 cmdline_parse_token_string_t cmd_showport_reta_port =
2171 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2172 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2173 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2174 cmdline_parse_token_string_t cmd_showport_reta_rss =
2175 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2176 cmdline_parse_token_string_t cmd_showport_reta_reta =
2177 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2178 cmdline_parse_token_num_t cmd_showport_reta_size =
2179 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2180 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2181 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2182 list_of_items, NULL);
2184 cmdline_parse_inst_t cmd_showport_reta = {
2185 .f = cmd_showport_reta_parsed,
2187 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2189 (void *)&cmd_showport_reta_show,
2190 (void *)&cmd_showport_reta_port,
2191 (void *)&cmd_showport_reta_port_id,
2192 (void *)&cmd_showport_reta_rss,
2193 (void *)&cmd_showport_reta_reta,
2194 (void *)&cmd_showport_reta_size,
2195 (void *)&cmd_showport_reta_list_of_items,
2200 /* *** Show RSS hash configuration *** */
2201 struct cmd_showport_rss_hash {
2202 cmdline_fixed_string_t show;
2203 cmdline_fixed_string_t port;
2205 cmdline_fixed_string_t rss_hash;
2206 cmdline_fixed_string_t rss_type;
2207 cmdline_fixed_string_t key; /* optional argument */
2210 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2211 __attribute__((unused)) struct cmdline *cl,
2214 struct cmd_showport_rss_hash *res = parsed_result;
2216 port_rss_hash_conf_show(res->port_id, res->rss_type,
2217 show_rss_key != NULL);
2220 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2221 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2222 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2223 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2224 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2225 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2226 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2227 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2229 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2230 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2231 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2232 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2233 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2234 "ipv6-tcp-ex#ipv6-udp-ex");
2235 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2236 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2238 cmdline_parse_inst_t cmd_showport_rss_hash = {
2239 .f = cmd_showport_rss_hash_parsed,
2241 .help_str = "show port <port_id> rss-hash "
2242 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2243 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2244 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2246 (void *)&cmd_showport_rss_hash_show,
2247 (void *)&cmd_showport_rss_hash_port,
2248 (void *)&cmd_showport_rss_hash_port_id,
2249 (void *)&cmd_showport_rss_hash_rss_hash,
2250 (void *)&cmd_showport_rss_hash_rss_hash_info,
2255 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2256 .f = cmd_showport_rss_hash_parsed,
2258 .help_str = "show port <port_id> rss-hash "
2259 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2260 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2261 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2263 (void *)&cmd_showport_rss_hash_show,
2264 (void *)&cmd_showport_rss_hash_port,
2265 (void *)&cmd_showport_rss_hash_port_id,
2266 (void *)&cmd_showport_rss_hash_rss_hash,
2267 (void *)&cmd_showport_rss_hash_rss_hash_info,
2268 (void *)&cmd_showport_rss_hash_rss_key,
2273 /* *** Configure DCB *** */
2274 struct cmd_config_dcb {
2275 cmdline_fixed_string_t port;
2276 cmdline_fixed_string_t config;
2278 cmdline_fixed_string_t dcb;
2279 cmdline_fixed_string_t vt;
2280 cmdline_fixed_string_t vt_en;
2282 cmdline_fixed_string_t pfc;
2283 cmdline_fixed_string_t pfc_en;
2287 cmd_config_dcb_parsed(void *parsed_result,
2288 __attribute__((unused)) struct cmdline *cl,
2289 __attribute__((unused)) void *data)
2291 struct cmd_config_dcb *res = parsed_result;
2292 portid_t port_id = res->port_id;
2293 struct rte_port *port;
2297 port = &ports[port_id];
2298 /** Check if the port is not started **/
2299 if (port->port_status != RTE_PORT_STOPPED) {
2300 printf("Please stop port %d first\n", port_id);
2304 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2305 printf("The invalid number of traffic class,"
2306 " only 4 or 8 allowed.\n");
2310 if (nb_fwd_lcores < res->num_tcs) {
2311 printf("nb_cores shouldn't be less than number of TCs.\n");
2314 if (!strncmp(res->pfc_en, "on", 2))
2319 /* DCB in VT mode */
2320 if (!strncmp(res->vt_en, "on", 2))
2321 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2322 (enum rte_eth_nb_tcs)res->num_tcs,
2325 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2326 (enum rte_eth_nb_tcs)res->num_tcs,
2331 printf("Cannot initialize network ports.\n");
2335 cmd_reconfig_device_queue(port_id, 1, 1);
2338 cmdline_parse_token_string_t cmd_config_dcb_port =
2339 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2340 cmdline_parse_token_string_t cmd_config_dcb_config =
2341 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2342 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2343 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2344 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2345 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2346 cmdline_parse_token_string_t cmd_config_dcb_vt =
2347 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2348 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2349 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2350 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2351 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2352 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2353 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2354 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2355 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2357 cmdline_parse_inst_t cmd_config_dcb = {
2358 .f = cmd_config_dcb_parsed,
2360 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2362 (void *)&cmd_config_dcb_port,
2363 (void *)&cmd_config_dcb_config,
2364 (void *)&cmd_config_dcb_port_id,
2365 (void *)&cmd_config_dcb_dcb,
2366 (void *)&cmd_config_dcb_vt,
2367 (void *)&cmd_config_dcb_vt_en,
2368 (void *)&cmd_config_dcb_num_tcs,
2369 (void *)&cmd_config_dcb_pfc,
2370 (void *)&cmd_config_dcb_pfc_en,
2375 /* *** configure number of packets per burst *** */
2376 struct cmd_config_burst {
2377 cmdline_fixed_string_t port;
2378 cmdline_fixed_string_t keyword;
2379 cmdline_fixed_string_t all;
2380 cmdline_fixed_string_t name;
2385 cmd_config_burst_parsed(void *parsed_result,
2386 __attribute__((unused)) struct cmdline *cl,
2387 __attribute__((unused)) void *data)
2389 struct cmd_config_burst *res = parsed_result;
2391 if (!all_ports_stopped()) {
2392 printf("Please stop all ports first\n");
2396 if (!strcmp(res->name, "burst")) {
2397 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2398 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2401 nb_pkt_per_burst = res->value;
2403 printf("Unknown parameter\n");
2409 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2412 cmdline_parse_token_string_t cmd_config_burst_port =
2413 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2414 cmdline_parse_token_string_t cmd_config_burst_keyword =
2415 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2416 cmdline_parse_token_string_t cmd_config_burst_all =
2417 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2418 cmdline_parse_token_string_t cmd_config_burst_name =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2420 cmdline_parse_token_num_t cmd_config_burst_value =
2421 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2423 cmdline_parse_inst_t cmd_config_burst = {
2424 .f = cmd_config_burst_parsed,
2426 .help_str = "port config all burst <value>",
2428 (void *)&cmd_config_burst_port,
2429 (void *)&cmd_config_burst_keyword,
2430 (void *)&cmd_config_burst_all,
2431 (void *)&cmd_config_burst_name,
2432 (void *)&cmd_config_burst_value,
2437 /* *** configure rx/tx queues *** */
2438 struct cmd_config_thresh {
2439 cmdline_fixed_string_t port;
2440 cmdline_fixed_string_t keyword;
2441 cmdline_fixed_string_t all;
2442 cmdline_fixed_string_t name;
2447 cmd_config_thresh_parsed(void *parsed_result,
2448 __attribute__((unused)) struct cmdline *cl,
2449 __attribute__((unused)) void *data)
2451 struct cmd_config_thresh *res = parsed_result;
2453 if (!all_ports_stopped()) {
2454 printf("Please stop all ports first\n");
2458 if (!strcmp(res->name, "txpt"))
2459 tx_pthresh = res->value;
2460 else if(!strcmp(res->name, "txht"))
2461 tx_hthresh = res->value;
2462 else if(!strcmp(res->name, "txwt"))
2463 tx_wthresh = res->value;
2464 else if(!strcmp(res->name, "rxpt"))
2465 rx_pthresh = res->value;
2466 else if(!strcmp(res->name, "rxht"))
2467 rx_hthresh = res->value;
2468 else if(!strcmp(res->name, "rxwt"))
2469 rx_wthresh = res->value;
2471 printf("Unknown parameter\n");
2477 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2480 cmdline_parse_token_string_t cmd_config_thresh_port =
2481 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2482 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2483 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2484 cmdline_parse_token_string_t cmd_config_thresh_all =
2485 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2486 cmdline_parse_token_string_t cmd_config_thresh_name =
2487 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2488 "txpt#txht#txwt#rxpt#rxht#rxwt");
2489 cmdline_parse_token_num_t cmd_config_thresh_value =
2490 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2492 cmdline_parse_inst_t cmd_config_thresh = {
2493 .f = cmd_config_thresh_parsed,
2495 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2497 (void *)&cmd_config_thresh_port,
2498 (void *)&cmd_config_thresh_keyword,
2499 (void *)&cmd_config_thresh_all,
2500 (void *)&cmd_config_thresh_name,
2501 (void *)&cmd_config_thresh_value,
2506 /* *** configure free/rs threshold *** */
2507 struct cmd_config_threshold {
2508 cmdline_fixed_string_t port;
2509 cmdline_fixed_string_t keyword;
2510 cmdline_fixed_string_t all;
2511 cmdline_fixed_string_t name;
2516 cmd_config_threshold_parsed(void *parsed_result,
2517 __attribute__((unused)) struct cmdline *cl,
2518 __attribute__((unused)) void *data)
2520 struct cmd_config_threshold *res = parsed_result;
2522 if (!all_ports_stopped()) {
2523 printf("Please stop all ports first\n");
2527 if (!strcmp(res->name, "txfreet"))
2528 tx_free_thresh = res->value;
2529 else if (!strcmp(res->name, "txrst"))
2530 tx_rs_thresh = res->value;
2531 else if (!strcmp(res->name, "rxfreet"))
2532 rx_free_thresh = res->value;
2534 printf("Unknown parameter\n");
2540 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2543 cmdline_parse_token_string_t cmd_config_threshold_port =
2544 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2545 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2546 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2548 cmdline_parse_token_string_t cmd_config_threshold_all =
2549 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2550 cmdline_parse_token_string_t cmd_config_threshold_name =
2551 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2552 "txfreet#txrst#rxfreet");
2553 cmdline_parse_token_num_t cmd_config_threshold_value =
2554 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2556 cmdline_parse_inst_t cmd_config_threshold = {
2557 .f = cmd_config_threshold_parsed,
2559 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2561 (void *)&cmd_config_threshold_port,
2562 (void *)&cmd_config_threshold_keyword,
2563 (void *)&cmd_config_threshold_all,
2564 (void *)&cmd_config_threshold_name,
2565 (void *)&cmd_config_threshold_value,
2571 struct cmd_stop_result {
2572 cmdline_fixed_string_t stop;
2575 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2576 __attribute__((unused)) struct cmdline *cl,
2577 __attribute__((unused)) void *data)
2579 stop_packet_forwarding();
2582 cmdline_parse_token_string_t cmd_stop_stop =
2583 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2585 cmdline_parse_inst_t cmd_stop = {
2586 .f = cmd_stop_parsed,
2588 .help_str = "stop: Stop packet forwarding",
2590 (void *)&cmd_stop_stop,
2595 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2598 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2599 unsigned int *parsed_items, int check_unique_values)
2601 unsigned int nb_item;
2609 * First parse all items in the list and store their value.
2614 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2616 if ((c >= '0') && (c <= '9')) {
2617 value = (unsigned int) (value * 10 + (c - '0'));
2622 printf("character %c is not a decimal digit\n", c);
2626 printf("No valid value before comma\n");
2629 if (nb_item < max_items) {
2630 parsed_items[nb_item] = value;
2636 if (nb_item >= max_items) {
2637 printf("Number of %s = %u > %u (maximum items)\n",
2638 item_name, nb_item + 1, max_items);
2641 parsed_items[nb_item++] = value;
2642 if (! check_unique_values)
2646 * Then, check that all values in the list are differents.
2647 * No optimization here...
2649 for (i = 0; i < nb_item; i++) {
2650 for (j = i + 1; j < nb_item; j++) {
2651 if (parsed_items[j] == parsed_items[i]) {
2652 printf("duplicated %s %u at index %u and %u\n",
2653 item_name, parsed_items[i], i, j);
2661 struct cmd_set_list_result {
2662 cmdline_fixed_string_t cmd_keyword;
2663 cmdline_fixed_string_t list_name;
2664 cmdline_fixed_string_t list_of_items;
2667 static void cmd_set_list_parsed(void *parsed_result,
2668 __attribute__((unused)) struct cmdline *cl,
2669 __attribute__((unused)) void *data)
2671 struct cmd_set_list_result *res;
2673 unsigned int lcorelist[RTE_MAX_LCORE];
2674 unsigned int portlist[RTE_MAX_ETHPORTS];
2676 unsigned int nb_item;
2678 if (test_done == 0) {
2679 printf("Please stop forwarding first\n");
2683 res = parsed_result;
2684 if (!strcmp(res->list_name, "corelist")) {
2685 nb_item = parse_item_list(res->list_of_items, "core",
2687 parsed_items.lcorelist, 1);
2689 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2694 if (!strcmp(res->list_name, "portlist")) {
2695 nb_item = parse_item_list(res->list_of_items, "port",
2697 parsed_items.portlist, 1);
2699 set_fwd_ports_list(parsed_items.portlist, nb_item);
2705 cmdline_parse_token_string_t cmd_set_list_keyword =
2706 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2708 cmdline_parse_token_string_t cmd_set_list_name =
2709 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2710 "corelist#portlist");
2711 cmdline_parse_token_string_t cmd_set_list_of_items =
2712 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2715 cmdline_parse_inst_t cmd_set_fwd_list = {
2716 .f = cmd_set_list_parsed,
2718 .help_str = "set corelist|portlist <list0[,list1]*>",
2720 (void *)&cmd_set_list_keyword,
2721 (void *)&cmd_set_list_name,
2722 (void *)&cmd_set_list_of_items,
2727 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2729 struct cmd_setmask_result {
2730 cmdline_fixed_string_t set;
2731 cmdline_fixed_string_t mask;
2735 static void cmd_set_mask_parsed(void *parsed_result,
2736 __attribute__((unused)) struct cmdline *cl,
2737 __attribute__((unused)) void *data)
2739 struct cmd_setmask_result *res = parsed_result;
2741 if (test_done == 0) {
2742 printf("Please stop forwarding first\n");
2745 if (!strcmp(res->mask, "coremask")) {
2746 set_fwd_lcores_mask(res->hexavalue);
2748 } else if (!strcmp(res->mask, "portmask")) {
2749 set_fwd_ports_mask(res->hexavalue);
2754 cmdline_parse_token_string_t cmd_setmask_set =
2755 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2756 cmdline_parse_token_string_t cmd_setmask_mask =
2757 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2758 "coremask#portmask");
2759 cmdline_parse_token_num_t cmd_setmask_value =
2760 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2762 cmdline_parse_inst_t cmd_set_fwd_mask = {
2763 .f = cmd_set_mask_parsed,
2765 .help_str = "set coremask|portmask <hexadecimal value>",
2767 (void *)&cmd_setmask_set,
2768 (void *)&cmd_setmask_mask,
2769 (void *)&cmd_setmask_value,
2775 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2777 struct cmd_set_result {
2778 cmdline_fixed_string_t set;
2779 cmdline_fixed_string_t what;
2783 static void cmd_set_parsed(void *parsed_result,
2784 __attribute__((unused)) struct cmdline *cl,
2785 __attribute__((unused)) void *data)
2787 struct cmd_set_result *res = parsed_result;
2788 if (!strcmp(res->what, "nbport")) {
2789 set_fwd_ports_number(res->value);
2791 } else if (!strcmp(res->what, "nbcore")) {
2792 set_fwd_lcores_number(res->value);
2794 } else if (!strcmp(res->what, "burst"))
2795 set_nb_pkt_per_burst(res->value);
2796 else if (!strcmp(res->what, "verbose"))
2797 set_verbose_level(res->value);
2800 cmdline_parse_token_string_t cmd_set_set =
2801 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2802 cmdline_parse_token_string_t cmd_set_what =
2803 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2804 "nbport#nbcore#burst#verbose");
2805 cmdline_parse_token_num_t cmd_set_value =
2806 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2808 cmdline_parse_inst_t cmd_set_numbers = {
2809 .f = cmd_set_parsed,
2811 .help_str = "set nbport|nbcore|burst|verbose <value>",
2813 (void *)&cmd_set_set,
2814 (void *)&cmd_set_what,
2815 (void *)&cmd_set_value,
2820 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2822 struct cmd_set_txpkts_result {
2823 cmdline_fixed_string_t cmd_keyword;
2824 cmdline_fixed_string_t txpkts;
2825 cmdline_fixed_string_t seg_lengths;
2829 cmd_set_txpkts_parsed(void *parsed_result,
2830 __attribute__((unused)) struct cmdline *cl,
2831 __attribute__((unused)) void *data)
2833 struct cmd_set_txpkts_result *res;
2834 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2835 unsigned int nb_segs;
2837 res = parsed_result;
2838 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2839 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2841 set_tx_pkt_segments(seg_lengths, nb_segs);
2844 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2845 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2846 cmd_keyword, "set");
2847 cmdline_parse_token_string_t cmd_set_txpkts_name =
2848 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2850 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2851 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2854 cmdline_parse_inst_t cmd_set_txpkts = {
2855 .f = cmd_set_txpkts_parsed,
2857 .help_str = "set txpkts <len0[,len1]*>",
2859 (void *)&cmd_set_txpkts_keyword,
2860 (void *)&cmd_set_txpkts_name,
2861 (void *)&cmd_set_txpkts_lengths,
2866 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2868 struct cmd_set_txsplit_result {
2869 cmdline_fixed_string_t cmd_keyword;
2870 cmdline_fixed_string_t txsplit;
2871 cmdline_fixed_string_t mode;
2875 cmd_set_txsplit_parsed(void *parsed_result,
2876 __attribute__((unused)) struct cmdline *cl,
2877 __attribute__((unused)) void *data)
2879 struct cmd_set_txsplit_result *res;
2881 res = parsed_result;
2882 set_tx_pkt_split(res->mode);
2885 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2886 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2887 cmd_keyword, "set");
2888 cmdline_parse_token_string_t cmd_set_txsplit_name =
2889 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2890 txsplit, "txsplit");
2891 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2892 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2895 cmdline_parse_inst_t cmd_set_txsplit = {
2896 .f = cmd_set_txsplit_parsed,
2898 .help_str = "set txsplit on|off|rand",
2900 (void *)&cmd_set_txsplit_keyword,
2901 (void *)&cmd_set_txsplit_name,
2902 (void *)&cmd_set_txsplit_mode,
2907 /* *** CONFIG TX QUEUE FLAGS *** */
2909 struct cmd_config_txqflags_result {
2910 cmdline_fixed_string_t port;
2911 cmdline_fixed_string_t config;
2912 cmdline_fixed_string_t all;
2913 cmdline_fixed_string_t what;
2917 static void cmd_config_txqflags_parsed(void *parsed_result,
2918 __attribute__((unused)) struct cmdline *cl,
2919 __attribute__((unused)) void *data)
2921 struct cmd_config_txqflags_result *res = parsed_result;
2923 if (!all_ports_stopped()) {
2924 printf("Please stop all ports first\n");
2928 if (strcmp(res->what, "txqflags")) {
2929 printf("Unknown parameter\n");
2933 if (res->hexvalue >= 0) {
2934 txq_flags = res->hexvalue;
2936 printf("txqflags must be >= 0\n");
2942 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2945 cmdline_parse_token_string_t cmd_config_txqflags_port =
2946 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2948 cmdline_parse_token_string_t cmd_config_txqflags_config =
2949 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2951 cmdline_parse_token_string_t cmd_config_txqflags_all =
2952 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2954 cmdline_parse_token_string_t cmd_config_txqflags_what =
2955 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2957 cmdline_parse_token_num_t cmd_config_txqflags_value =
2958 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2961 cmdline_parse_inst_t cmd_config_txqflags = {
2962 .f = cmd_config_txqflags_parsed,
2964 .help_str = "port config all txqflags <value>",
2966 (void *)&cmd_config_txqflags_port,
2967 (void *)&cmd_config_txqflags_config,
2968 (void *)&cmd_config_txqflags_all,
2969 (void *)&cmd_config_txqflags_what,
2970 (void *)&cmd_config_txqflags_value,
2975 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2976 struct cmd_rx_vlan_filter_all_result {
2977 cmdline_fixed_string_t rx_vlan;
2978 cmdline_fixed_string_t what;
2979 cmdline_fixed_string_t all;
2984 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2985 __attribute__((unused)) struct cmdline *cl,
2986 __attribute__((unused)) void *data)
2988 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2990 if (!strcmp(res->what, "add"))
2991 rx_vlan_all_filter_set(res->port_id, 1);
2993 rx_vlan_all_filter_set(res->port_id, 0);
2996 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2997 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2998 rx_vlan, "rx_vlan");
2999 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3000 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3002 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3003 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3005 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3006 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3009 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3010 .f = cmd_rx_vlan_filter_all_parsed,
3012 .help_str = "rx_vlan add|rm all <port_id>: "
3013 "Add/Remove all identifiers to/from the set of VLAN "
3014 "identifiers filtered by a port",
3016 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3017 (void *)&cmd_rx_vlan_filter_all_what,
3018 (void *)&cmd_rx_vlan_filter_all_all,
3019 (void *)&cmd_rx_vlan_filter_all_portid,
3024 /* *** VLAN OFFLOAD SET ON A PORT *** */
3025 struct cmd_vlan_offload_result {
3026 cmdline_fixed_string_t vlan;
3027 cmdline_fixed_string_t set;
3028 cmdline_fixed_string_t vlan_type;
3029 cmdline_fixed_string_t what;
3030 cmdline_fixed_string_t on;
3031 cmdline_fixed_string_t port_id;
3035 cmd_vlan_offload_parsed(void *parsed_result,
3036 __attribute__((unused)) struct cmdline *cl,
3037 __attribute__((unused)) void *data)
3040 struct cmd_vlan_offload_result *res = parsed_result;
3043 portid_t port_id = 0;
3047 len = strnlen(str, STR_TOKEN_SIZE);
3049 /* Get port_id first */
3057 tmp = strtoul(str, NULL, 0);
3058 /* If port_id greater that what portid_t can represent, return */
3059 if(tmp >= RTE_MAX_ETHPORTS)
3061 port_id = (portid_t)tmp;
3063 if (!strcmp(res->on, "on"))
3068 if (!strcmp(res->what, "strip"))
3069 rx_vlan_strip_set(port_id, on);
3070 else if(!strcmp(res->what, "stripq")){
3071 uint16_t queue_id = 0;
3073 /* No queue_id, return */
3075 printf("must specify (port,queue_id)\n");
3078 tmp = strtoul(str + i + 1, NULL, 0);
3079 /* If queue_id greater that what 16-bits can represent, return */
3083 queue_id = (uint16_t)tmp;
3084 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3086 else if (!strcmp(res->what, "filter"))
3087 rx_vlan_filter_set(port_id, on);
3089 vlan_extend_set(port_id, on);
3094 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3095 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3097 cmdline_parse_token_string_t cmd_vlan_offload_set =
3098 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3100 cmdline_parse_token_string_t cmd_vlan_offload_what =
3101 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3102 what, "strip#filter#qinq#stripq");
3103 cmdline_parse_token_string_t cmd_vlan_offload_on =
3104 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3106 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3107 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3110 cmdline_parse_inst_t cmd_vlan_offload = {
3111 .f = cmd_vlan_offload_parsed,
3113 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3114 "<port_id[,queue_id]>: "
3115 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3117 (void *)&cmd_vlan_offload_vlan,
3118 (void *)&cmd_vlan_offload_set,
3119 (void *)&cmd_vlan_offload_what,
3120 (void *)&cmd_vlan_offload_on,
3121 (void *)&cmd_vlan_offload_portid,
3126 /* *** VLAN TPID SET ON A PORT *** */
3127 struct cmd_vlan_tpid_result {
3128 cmdline_fixed_string_t vlan;
3129 cmdline_fixed_string_t set;
3130 cmdline_fixed_string_t vlan_type;
3131 cmdline_fixed_string_t what;
3137 cmd_vlan_tpid_parsed(void *parsed_result,
3138 __attribute__((unused)) struct cmdline *cl,
3139 __attribute__((unused)) void *data)
3141 struct cmd_vlan_tpid_result *res = parsed_result;
3142 enum rte_vlan_type vlan_type;
3144 if (!strcmp(res->vlan_type, "inner"))
3145 vlan_type = ETH_VLAN_TYPE_INNER;
3146 else if (!strcmp(res->vlan_type, "outer"))
3147 vlan_type = ETH_VLAN_TYPE_OUTER;
3149 printf("Unknown vlan type\n");
3152 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3155 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3156 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3158 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3159 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3161 cmdline_parse_token_string_t cmd_vlan_type =
3162 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3163 vlan_type, "inner#outer");
3164 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3165 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3167 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3168 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3170 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3171 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3174 cmdline_parse_inst_t cmd_vlan_tpid = {
3175 .f = cmd_vlan_tpid_parsed,
3177 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3178 "Set the VLAN Ether type",
3180 (void *)&cmd_vlan_tpid_vlan,
3181 (void *)&cmd_vlan_tpid_set,
3182 (void *)&cmd_vlan_type,
3183 (void *)&cmd_vlan_tpid_what,
3184 (void *)&cmd_vlan_tpid_tpid,
3185 (void *)&cmd_vlan_tpid_portid,
3190 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3191 struct cmd_rx_vlan_filter_result {
3192 cmdline_fixed_string_t rx_vlan;
3193 cmdline_fixed_string_t what;
3199 cmd_rx_vlan_filter_parsed(void *parsed_result,
3200 __attribute__((unused)) struct cmdline *cl,
3201 __attribute__((unused)) void *data)
3203 struct cmd_rx_vlan_filter_result *res = parsed_result;
3205 if (!strcmp(res->what, "add"))
3206 rx_vft_set(res->port_id, res->vlan_id, 1);
3208 rx_vft_set(res->port_id, res->vlan_id, 0);
3211 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3212 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3213 rx_vlan, "rx_vlan");
3214 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3215 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3217 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3218 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3220 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3221 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3224 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3225 .f = cmd_rx_vlan_filter_parsed,
3227 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3228 "Add/Remove a VLAN identifier to/from the set of VLAN "
3229 "identifiers filtered by a port",
3231 (void *)&cmd_rx_vlan_filter_rx_vlan,
3232 (void *)&cmd_rx_vlan_filter_what,
3233 (void *)&cmd_rx_vlan_filter_vlanid,
3234 (void *)&cmd_rx_vlan_filter_portid,
3239 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3240 struct cmd_tx_vlan_set_result {
3241 cmdline_fixed_string_t tx_vlan;
3242 cmdline_fixed_string_t set;
3248 cmd_tx_vlan_set_parsed(void *parsed_result,
3249 __attribute__((unused)) struct cmdline *cl,
3250 __attribute__((unused)) void *data)
3252 struct cmd_tx_vlan_set_result *res = parsed_result;
3254 tx_vlan_set(res->port_id, res->vlan_id);
3257 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3258 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3259 tx_vlan, "tx_vlan");
3260 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3261 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3263 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3264 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3266 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3267 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3270 cmdline_parse_inst_t cmd_tx_vlan_set = {
3271 .f = cmd_tx_vlan_set_parsed,
3273 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3274 "Enable hardware insertion of a single VLAN header "
3275 "with a given TAG Identifier in packets sent on a port",
3277 (void *)&cmd_tx_vlan_set_tx_vlan,
3278 (void *)&cmd_tx_vlan_set_set,
3279 (void *)&cmd_tx_vlan_set_portid,
3280 (void *)&cmd_tx_vlan_set_vlanid,
3285 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3286 struct cmd_tx_vlan_set_qinq_result {
3287 cmdline_fixed_string_t tx_vlan;
3288 cmdline_fixed_string_t set;
3291 uint16_t vlan_id_outer;
3295 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3296 __attribute__((unused)) struct cmdline *cl,
3297 __attribute__((unused)) void *data)
3299 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3301 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3304 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3305 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3306 tx_vlan, "tx_vlan");
3307 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3308 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3310 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3311 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3313 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3314 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3316 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3317 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3318 vlan_id_outer, UINT16);
3320 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3321 .f = cmd_tx_vlan_set_qinq_parsed,
3323 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3324 "Enable hardware insertion of double VLAN header "
3325 "with given TAG Identifiers in packets sent on a port",
3327 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3328 (void *)&cmd_tx_vlan_set_qinq_set,
3329 (void *)&cmd_tx_vlan_set_qinq_portid,
3330 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3331 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3336 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3337 struct cmd_tx_vlan_set_pvid_result {
3338 cmdline_fixed_string_t tx_vlan;
3339 cmdline_fixed_string_t set;
3340 cmdline_fixed_string_t pvid;
3343 cmdline_fixed_string_t mode;
3347 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3348 __attribute__((unused)) struct cmdline *cl,
3349 __attribute__((unused)) void *data)
3351 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3353 if (strcmp(res->mode, "on") == 0)
3354 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3356 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3359 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3360 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3361 tx_vlan, "tx_vlan");
3362 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3363 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3365 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3366 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3368 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3369 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3371 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3372 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3374 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3375 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3378 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3379 .f = cmd_tx_vlan_set_pvid_parsed,
3381 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3383 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3384 (void *)&cmd_tx_vlan_set_pvid_set,
3385 (void *)&cmd_tx_vlan_set_pvid_pvid,
3386 (void *)&cmd_tx_vlan_set_pvid_port_id,
3387 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3388 (void *)&cmd_tx_vlan_set_pvid_mode,
3393 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3394 struct cmd_tx_vlan_reset_result {
3395 cmdline_fixed_string_t tx_vlan;
3396 cmdline_fixed_string_t reset;
3401 cmd_tx_vlan_reset_parsed(void *parsed_result,
3402 __attribute__((unused)) struct cmdline *cl,
3403 __attribute__((unused)) void *data)
3405 struct cmd_tx_vlan_reset_result *res = parsed_result;
3407 tx_vlan_reset(res->port_id);
3410 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3411 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3412 tx_vlan, "tx_vlan");
3413 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3414 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3416 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3417 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3420 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3421 .f = cmd_tx_vlan_reset_parsed,
3423 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3424 "VLAN header in packets sent on a port",
3426 (void *)&cmd_tx_vlan_reset_tx_vlan,
3427 (void *)&cmd_tx_vlan_reset_reset,
3428 (void *)&cmd_tx_vlan_reset_portid,
3434 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3435 struct cmd_csum_result {
3436 cmdline_fixed_string_t csum;
3437 cmdline_fixed_string_t mode;
3438 cmdline_fixed_string_t proto;
3439 cmdline_fixed_string_t hwsw;
3444 csum_show(int port_id)
3446 struct rte_eth_dev_info dev_info;
3449 ol_flags = ports[port_id].tx_ol_flags;
3450 printf("Parse tunnel is %s\n",
3451 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3452 printf("IP checksum offload is %s\n",
3453 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3454 printf("UDP checksum offload is %s\n",
3455 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3456 printf("TCP checksum offload is %s\n",
3457 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3458 printf("SCTP checksum offload is %s\n",
3459 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3460 printf("Outer-Ip checksum offload is %s\n",
3461 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3463 /* display warnings if configuration is not supported by the NIC */
3464 rte_eth_dev_info_get(port_id, &dev_info);
3465 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3466 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3467 printf("Warning: hardware IP checksum enabled but not "
3468 "supported by port %d\n", port_id);
3470 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3471 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3472 printf("Warning: hardware UDP checksum enabled but not "
3473 "supported by port %d\n", port_id);
3475 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3476 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3477 printf("Warning: hardware TCP checksum enabled but not "
3478 "supported by port %d\n", port_id);
3480 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3481 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3482 printf("Warning: hardware SCTP checksum enabled but not "
3483 "supported by port %d\n", port_id);
3485 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3486 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3487 printf("Warning: hardware outer IP checksum enabled but not "
3488 "supported by port %d\n", port_id);
3493 cmd_csum_parsed(void *parsed_result,
3494 __attribute__((unused)) struct cmdline *cl,
3495 __attribute__((unused)) void *data)
3497 struct cmd_csum_result *res = parsed_result;
3501 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3502 printf("invalid port %d\n", res->port_id);
3506 if (!strcmp(res->mode, "set")) {
3508 if (!strcmp(res->hwsw, "hw"))
3511 if (!strcmp(res->proto, "ip")) {
3512 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3513 } else if (!strcmp(res->proto, "udp")) {
3514 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3515 } else if (!strcmp(res->proto, "tcp")) {
3516 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3517 } else if (!strcmp(res->proto, "sctp")) {
3518 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3519 } else if (!strcmp(res->proto, "outer-ip")) {
3520 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3524 ports[res->port_id].tx_ol_flags |= mask;
3526 ports[res->port_id].tx_ol_flags &= (~mask);
3528 csum_show(res->port_id);
3531 cmdline_parse_token_string_t cmd_csum_csum =
3532 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3534 cmdline_parse_token_string_t cmd_csum_mode =
3535 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3537 cmdline_parse_token_string_t cmd_csum_proto =
3538 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3539 proto, "ip#tcp#udp#sctp#outer-ip");
3540 cmdline_parse_token_string_t cmd_csum_hwsw =
3541 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3543 cmdline_parse_token_num_t cmd_csum_portid =
3544 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3547 cmdline_parse_inst_t cmd_csum_set = {
3548 .f = cmd_csum_parsed,
3550 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3551 "Enable/Disable hardware calculation of L3/L4 checksum when "
3552 "using csum forward engine",
3554 (void *)&cmd_csum_csum,
3555 (void *)&cmd_csum_mode,
3556 (void *)&cmd_csum_proto,
3557 (void *)&cmd_csum_hwsw,
3558 (void *)&cmd_csum_portid,
3563 cmdline_parse_token_string_t cmd_csum_mode_show =
3564 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3567 cmdline_parse_inst_t cmd_csum_show = {
3568 .f = cmd_csum_parsed,
3570 .help_str = "csum show <port_id>: Show checksum offload configuration",
3572 (void *)&cmd_csum_csum,
3573 (void *)&cmd_csum_mode_show,
3574 (void *)&cmd_csum_portid,
3579 /* Enable/disable tunnel parsing */
3580 struct cmd_csum_tunnel_result {
3581 cmdline_fixed_string_t csum;
3582 cmdline_fixed_string_t parse;
3583 cmdline_fixed_string_t onoff;
3588 cmd_csum_tunnel_parsed(void *parsed_result,
3589 __attribute__((unused)) struct cmdline *cl,
3590 __attribute__((unused)) void *data)
3592 struct cmd_csum_tunnel_result *res = parsed_result;
3594 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3597 if (!strcmp(res->onoff, "on"))
3598 ports[res->port_id].tx_ol_flags |=
3599 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3601 ports[res->port_id].tx_ol_flags &=
3602 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3604 csum_show(res->port_id);
3607 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3608 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3610 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3611 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3612 parse, "parse_tunnel");
3613 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3614 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3616 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3617 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3620 cmdline_parse_inst_t cmd_csum_tunnel = {
3621 .f = cmd_csum_tunnel_parsed,
3623 .help_str = "csum parse_tunnel on|off <port_id>: "
3624 "Enable/Disable parsing of tunnels for csum engine",
3626 (void *)&cmd_csum_tunnel_csum,
3627 (void *)&cmd_csum_tunnel_parse,
3628 (void *)&cmd_csum_tunnel_onoff,
3629 (void *)&cmd_csum_tunnel_portid,
3634 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3635 struct cmd_tso_set_result {
3636 cmdline_fixed_string_t tso;
3637 cmdline_fixed_string_t mode;
3643 cmd_tso_set_parsed(void *parsed_result,
3644 __attribute__((unused)) struct cmdline *cl,
3645 __attribute__((unused)) void *data)
3647 struct cmd_tso_set_result *res = parsed_result;
3648 struct rte_eth_dev_info dev_info;
3650 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3653 if (!strcmp(res->mode, "set"))
3654 ports[res->port_id].tso_segsz = res->tso_segsz;
3656 if (ports[res->port_id].tso_segsz == 0)
3657 printf("TSO for non-tunneled packets is disabled\n");
3659 printf("TSO segment size for non-tunneled packets is %d\n",
3660 ports[res->port_id].tso_segsz);
3662 /* display warnings if configuration is not supported by the NIC */
3663 rte_eth_dev_info_get(res->port_id, &dev_info);
3664 if ((ports[res->port_id].tso_segsz != 0) &&
3665 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3666 printf("Warning: TSO enabled but not "
3667 "supported by port %d\n", res->port_id);
3671 cmdline_parse_token_string_t cmd_tso_set_tso =
3672 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3674 cmdline_parse_token_string_t cmd_tso_set_mode =
3675 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3677 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3678 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3680 cmdline_parse_token_num_t cmd_tso_set_portid =
3681 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3684 cmdline_parse_inst_t cmd_tso_set = {
3685 .f = cmd_tso_set_parsed,
3687 .help_str = "tso set <tso_segsz> <port_id>: "
3688 "Set TSO segment size of non-tunneled packets for csum engine "
3691 (void *)&cmd_tso_set_tso,
3692 (void *)&cmd_tso_set_mode,
3693 (void *)&cmd_tso_set_tso_segsz,
3694 (void *)&cmd_tso_set_portid,
3699 cmdline_parse_token_string_t cmd_tso_show_mode =
3700 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3704 cmdline_parse_inst_t cmd_tso_show = {
3705 .f = cmd_tso_set_parsed,
3707 .help_str = "tso show <port_id>: "
3708 "Show TSO segment size of non-tunneled packets for csum engine",
3710 (void *)&cmd_tso_set_tso,
3711 (void *)&cmd_tso_show_mode,
3712 (void *)&cmd_tso_set_portid,
3717 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3718 struct cmd_tunnel_tso_set_result {
3719 cmdline_fixed_string_t tso;
3720 cmdline_fixed_string_t mode;
3726 check_tunnel_tso_nic_support(uint8_t port_id)
3728 struct rte_eth_dev_info dev_info;
3730 rte_eth_dev_info_get(port_id, &dev_info);
3731 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3732 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3733 "supported by port %d\n", port_id);
3734 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3735 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3736 "supported by port %d\n", port_id);
3737 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3738 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3739 "supported by port %d\n", port_id);
3740 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3741 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3742 "supported by port %d\n", port_id);
3746 cmd_tunnel_tso_set_parsed(void *parsed_result,
3747 __attribute__((unused)) struct cmdline *cl,
3748 __attribute__((unused)) void *data)
3750 struct cmd_tunnel_tso_set_result *res = parsed_result;
3752 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3755 if (!strcmp(res->mode, "set"))
3756 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3758 if (ports[res->port_id].tunnel_tso_segsz == 0)
3759 printf("TSO for tunneled packets is disabled\n");
3761 printf("TSO segment size for tunneled packets is %d\n",
3762 ports[res->port_id].tunnel_tso_segsz);
3764 /* Below conditions are needed to make it work:
3765 * (1) tunnel TSO is supported by the NIC;
3766 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3768 * (3) for tunneled pkts with outer L3 of IPv4,
3769 * "csum set outer-ip" must be set to hw, because after tso,
3770 * total_len of outer IP header is changed, and the checksum
3771 * of outer IP header calculated by sw should be wrong; that
3772 * is not necessary for IPv6 tunneled pkts because there's no
3773 * checksum in IP header anymore.
3775 check_tunnel_tso_nic_support(res->port_id);
3777 if (!(ports[res->port_id].tx_ol_flags &
3778 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3779 printf("Warning: csum parse_tunnel must be set "
3780 "so that tunneled packets are recognized\n");
3781 if (!(ports[res->port_id].tx_ol_flags &
3782 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3783 printf("Warning: csum set outer-ip must be set to hw "
3784 "if outer L3 is IPv4; not necessary for IPv6\n");
3788 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3789 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3791 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3792 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3794 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3795 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3797 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3798 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3801 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3802 .f = cmd_tunnel_tso_set_parsed,
3804 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3805 "Set TSO segment size of tunneled packets for csum engine "
3808 (void *)&cmd_tunnel_tso_set_tso,
3809 (void *)&cmd_tunnel_tso_set_mode,
3810 (void *)&cmd_tunnel_tso_set_tso_segsz,
3811 (void *)&cmd_tunnel_tso_set_portid,
3816 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3817 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3821 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3822 .f = cmd_tunnel_tso_set_parsed,
3824 .help_str = "tunnel_tso show <port_id> "
3825 "Show TSO segment size of tunneled packets for csum engine",
3827 (void *)&cmd_tunnel_tso_set_tso,
3828 (void *)&cmd_tunnel_tso_show_mode,
3829 (void *)&cmd_tunnel_tso_set_portid,
3834 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3835 struct cmd_set_flush_rx {
3836 cmdline_fixed_string_t set;
3837 cmdline_fixed_string_t flush_rx;
3838 cmdline_fixed_string_t mode;
3842 cmd_set_flush_rx_parsed(void *parsed_result,
3843 __attribute__((unused)) struct cmdline *cl,
3844 __attribute__((unused)) void *data)
3846 struct cmd_set_flush_rx *res = parsed_result;
3847 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3850 cmdline_parse_token_string_t cmd_setflushrx_set =
3851 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3853 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3854 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3855 flush_rx, "flush_rx");
3856 cmdline_parse_token_string_t cmd_setflushrx_mode =
3857 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3861 cmdline_parse_inst_t cmd_set_flush_rx = {
3862 .f = cmd_set_flush_rx_parsed,
3863 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3866 (void *)&cmd_setflushrx_set,
3867 (void *)&cmd_setflushrx_flush_rx,
3868 (void *)&cmd_setflushrx_mode,
3873 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3874 struct cmd_set_link_check {
3875 cmdline_fixed_string_t set;
3876 cmdline_fixed_string_t link_check;
3877 cmdline_fixed_string_t mode;
3881 cmd_set_link_check_parsed(void *parsed_result,
3882 __attribute__((unused)) struct cmdline *cl,
3883 __attribute__((unused)) void *data)
3885 struct cmd_set_link_check *res = parsed_result;
3886 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3889 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3890 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3892 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3893 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3894 link_check, "link_check");
3895 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3896 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3900 cmdline_parse_inst_t cmd_set_link_check = {
3901 .f = cmd_set_link_check_parsed,
3902 .help_str = "set link_check on|off: Enable/Disable link status check "
3903 "when starting/stopping a port",
3906 (void *)&cmd_setlinkcheck_set,
3907 (void *)&cmd_setlinkcheck_link_check,
3908 (void *)&cmd_setlinkcheck_mode,
3913 /* *** SET NIC BYPASS MODE *** */
3914 struct cmd_set_bypass_mode_result {
3915 cmdline_fixed_string_t set;
3916 cmdline_fixed_string_t bypass;
3917 cmdline_fixed_string_t mode;
3918 cmdline_fixed_string_t value;
3923 cmd_set_bypass_mode_parsed(void *parsed_result,
3924 __attribute__((unused)) struct cmdline *cl,
3925 __attribute__((unused)) void *data)
3927 struct cmd_set_bypass_mode_result *res = parsed_result;
3928 portid_t port_id = res->port_id;
3929 int32_t rc = -EINVAL;
3931 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
3932 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3934 if (!strcmp(res->value, "bypass"))
3935 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
3936 else if (!strcmp(res->value, "isolate"))
3937 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
3939 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3941 /* Set the bypass mode for the relevant port. */
3942 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
3945 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3948 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3949 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3951 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3952 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3954 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3955 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3957 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3958 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3959 value, "normal#bypass#isolate");
3960 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3961 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3964 cmdline_parse_inst_t cmd_set_bypass_mode = {
3965 .f = cmd_set_bypass_mode_parsed,
3966 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3967 "Set the NIC bypass mode for port_id",
3970 (void *)&cmd_setbypass_mode_set,
3971 (void *)&cmd_setbypass_mode_bypass,
3972 (void *)&cmd_setbypass_mode_mode,
3973 (void *)&cmd_setbypass_mode_value,
3974 (void *)&cmd_setbypass_mode_port,
3979 /* *** SET NIC BYPASS EVENT *** */
3980 struct cmd_set_bypass_event_result {
3981 cmdline_fixed_string_t set;
3982 cmdline_fixed_string_t bypass;
3983 cmdline_fixed_string_t event;
3984 cmdline_fixed_string_t event_value;
3985 cmdline_fixed_string_t mode;
3986 cmdline_fixed_string_t mode_value;
3991 cmd_set_bypass_event_parsed(void *parsed_result,
3992 __attribute__((unused)) struct cmdline *cl,
3993 __attribute__((unused)) void *data)
3995 int32_t rc = -EINVAL;
3996 struct cmd_set_bypass_event_result *res = parsed_result;
3997 portid_t port_id = res->port_id;
3999 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4000 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4001 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4003 if (!strcmp(res->event_value, "timeout"))
4004 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4005 else if (!strcmp(res->event_value, "os_on"))
4006 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4007 else if (!strcmp(res->event_value, "os_off"))
4008 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4009 else if (!strcmp(res->event_value, "power_on"))
4010 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4011 else if (!strcmp(res->event_value, "power_off"))
4012 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4014 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4016 if (!strcmp(res->mode_value, "bypass"))
4017 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4018 else if (!strcmp(res->mode_value, "isolate"))
4019 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4021 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4023 /* Set the watchdog timeout. */
4024 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4027 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4028 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4032 printf("Failed to set timeout value %u "
4033 "for port %d, errto code: %d.\n",
4034 bypass_timeout, port_id, rc);
4038 /* Set the bypass event to transition to bypass mode. */
4039 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4044 printf("\t Failed to set bypass event for port = %d.\n",
4048 cmdline_parse_token_string_t cmd_setbypass_event_set =
4049 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4051 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4052 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4054 cmdline_parse_token_string_t cmd_setbypass_event_event =
4055 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4057 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4058 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4059 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4060 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4061 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4063 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4064 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4065 mode_value, "normal#bypass#isolate");
4066 cmdline_parse_token_num_t cmd_setbypass_event_port =
4067 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4070 cmdline_parse_inst_t cmd_set_bypass_event = {
4071 .f = cmd_set_bypass_event_parsed,
4072 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4073 "power_off mode normal|bypass|isolate <port_id>: "
4074 "Set the NIC bypass event mode for port_id",
4077 (void *)&cmd_setbypass_event_set,
4078 (void *)&cmd_setbypass_event_bypass,
4079 (void *)&cmd_setbypass_event_event,
4080 (void *)&cmd_setbypass_event_event_value,
4081 (void *)&cmd_setbypass_event_mode,
4082 (void *)&cmd_setbypass_event_mode_value,
4083 (void *)&cmd_setbypass_event_port,
4089 /* *** SET NIC BYPASS TIMEOUT *** */
4090 struct cmd_set_bypass_timeout_result {
4091 cmdline_fixed_string_t set;
4092 cmdline_fixed_string_t bypass;
4093 cmdline_fixed_string_t timeout;
4094 cmdline_fixed_string_t value;
4098 cmd_set_bypass_timeout_parsed(void *parsed_result,
4099 __attribute__((unused)) struct cmdline *cl,
4100 __attribute__((unused)) void *data)
4102 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4104 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4105 if (!strcmp(res->value, "1.5"))
4106 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4107 else if (!strcmp(res->value, "2"))
4108 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4109 else if (!strcmp(res->value, "3"))
4110 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4111 else if (!strcmp(res->value, "4"))
4112 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4113 else if (!strcmp(res->value, "8"))
4114 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4115 else if (!strcmp(res->value, "16"))
4116 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4117 else if (!strcmp(res->value, "32"))
4118 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4120 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4124 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4125 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4127 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4128 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4130 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4131 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4132 timeout, "timeout");
4133 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4134 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4135 value, "0#1.5#2#3#4#8#16#32");
4137 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4138 .f = cmd_set_bypass_timeout_parsed,
4139 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4140 "Set the NIC bypass watchdog timeout in seconds",
4143 (void *)&cmd_setbypass_timeout_set,
4144 (void *)&cmd_setbypass_timeout_bypass,
4145 (void *)&cmd_setbypass_timeout_timeout,
4146 (void *)&cmd_setbypass_timeout_value,
4151 /* *** SHOW NIC BYPASS MODE *** */
4152 struct cmd_show_bypass_config_result {
4153 cmdline_fixed_string_t show;
4154 cmdline_fixed_string_t bypass;
4155 cmdline_fixed_string_t config;
4160 cmd_show_bypass_config_parsed(void *parsed_result,
4161 __attribute__((unused)) struct cmdline *cl,
4162 __attribute__((unused)) void *data)
4164 struct cmd_show_bypass_config_result *res = parsed_result;
4165 portid_t port_id = res->port_id;
4167 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4168 uint32_t event_mode;
4169 uint32_t bypass_mode;
4170 uint32_t timeout = bypass_timeout;
4173 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4174 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4175 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4176 {"UNKNOWN", "normal", "bypass", "isolate"};
4177 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4184 int num_events = (sizeof events) / (sizeof events[0]);
4186 /* Display the bypass mode.*/
4187 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4188 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4192 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4193 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4195 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4198 /* Display the bypass timeout.*/
4199 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4200 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4202 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4204 /* Display the bypass events and associated modes. */
4205 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4207 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4208 printf("\tFailed to get bypass mode for event = %s\n",
4211 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4212 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4214 printf("\tbypass event: %-16s = %s\n", events[i],
4220 printf("\tFailed to get bypass configuration for port = %d\n",
4224 cmdline_parse_token_string_t cmd_showbypass_config_show =
4225 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4227 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4228 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4230 cmdline_parse_token_string_t cmd_showbypass_config_config =
4231 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4233 cmdline_parse_token_num_t cmd_showbypass_config_port =
4234 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4237 cmdline_parse_inst_t cmd_show_bypass_config = {
4238 .f = cmd_show_bypass_config_parsed,
4239 .help_str = "show bypass config <port_id>: "
4240 "Show the NIC bypass config for port_id",
4243 (void *)&cmd_showbypass_config_show,
4244 (void *)&cmd_showbypass_config_bypass,
4245 (void *)&cmd_showbypass_config_config,
4246 (void *)&cmd_showbypass_config_port,
4251 #ifdef RTE_LIBRTE_PMD_BOND
4252 /* *** SET BONDING MODE *** */
4253 struct cmd_set_bonding_mode_result {
4254 cmdline_fixed_string_t set;
4255 cmdline_fixed_string_t bonding;
4256 cmdline_fixed_string_t mode;
4261 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4262 __attribute__((unused)) struct cmdline *cl,
4263 __attribute__((unused)) void *data)
4265 struct cmd_set_bonding_mode_result *res = parsed_result;
4266 portid_t port_id = res->port_id;
4268 /* Set the bonding mode for the relevant port. */
4269 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4270 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4273 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4274 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4276 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4277 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4278 bonding, "bonding");
4279 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4280 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4282 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4283 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4285 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4286 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4289 cmdline_parse_inst_t cmd_set_bonding_mode = {
4290 .f = cmd_set_bonding_mode_parsed,
4291 .help_str = "set bonding mode <mode_value> <port_id>: "
4292 "Set the bonding mode for port_id",
4295 (void *) &cmd_setbonding_mode_set,
4296 (void *) &cmd_setbonding_mode_bonding,
4297 (void *) &cmd_setbonding_mode_mode,
4298 (void *) &cmd_setbonding_mode_value,
4299 (void *) &cmd_setbonding_mode_port,
4304 /* *** SET BALANCE XMIT POLICY *** */
4305 struct cmd_set_bonding_balance_xmit_policy_result {
4306 cmdline_fixed_string_t set;
4307 cmdline_fixed_string_t bonding;
4308 cmdline_fixed_string_t balance_xmit_policy;
4310 cmdline_fixed_string_t policy;
4313 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4314 __attribute__((unused)) struct cmdline *cl,
4315 __attribute__((unused)) void *data)
4317 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4318 portid_t port_id = res->port_id;
4321 if (!strcmp(res->policy, "l2")) {
4322 policy = BALANCE_XMIT_POLICY_LAYER2;
4323 } else if (!strcmp(res->policy, "l23")) {
4324 policy = BALANCE_XMIT_POLICY_LAYER23;
4325 } else if (!strcmp(res->policy, "l34")) {
4326 policy = BALANCE_XMIT_POLICY_LAYER34;
4328 printf("\t Invalid xmit policy selection");
4332 /* Set the bonding mode for the relevant port. */
4333 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4334 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4339 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4340 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4342 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4343 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4344 bonding, "bonding");
4345 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4346 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4347 balance_xmit_policy, "balance_xmit_policy");
4348 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4349 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4351 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4352 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4353 policy, "l2#l23#l34");
4355 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4356 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4357 .help_str = "set bonding balance_xmit_policy <port_id> "
4359 "Set the bonding balance_xmit_policy for port_id",
4362 (void *)&cmd_setbonding_balance_xmit_policy_set,
4363 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4364 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4365 (void *)&cmd_setbonding_balance_xmit_policy_port,
4366 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4371 /* *** SHOW NIC BONDING CONFIGURATION *** */
4372 struct cmd_show_bonding_config_result {
4373 cmdline_fixed_string_t show;
4374 cmdline_fixed_string_t bonding;
4375 cmdline_fixed_string_t config;
4379 static void cmd_show_bonding_config_parsed(void *parsed_result,
4380 __attribute__((unused)) struct cmdline *cl,
4381 __attribute__((unused)) void *data)
4383 struct cmd_show_bonding_config_result *res = parsed_result;
4385 uint8_t slaves[RTE_MAX_ETHPORTS];
4386 int num_slaves, num_active_slaves;
4389 portid_t port_id = res->port_id;
4391 /* Display the bonding mode.*/
4392 bonding_mode = rte_eth_bond_mode_get(port_id);
4393 if (bonding_mode < 0) {
4394 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4397 printf("\tBonding mode: %d\n", bonding_mode);
4399 if (bonding_mode == BONDING_MODE_BALANCE) {
4400 int balance_xmit_policy;
4402 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4403 if (balance_xmit_policy < 0) {
4404 printf("\tFailed to get balance xmit policy for port = %d\n",
4408 printf("\tBalance Xmit Policy: ");
4410 switch (balance_xmit_policy) {
4411 case BALANCE_XMIT_POLICY_LAYER2:
4412 printf("BALANCE_XMIT_POLICY_LAYER2");
4414 case BALANCE_XMIT_POLICY_LAYER23:
4415 printf("BALANCE_XMIT_POLICY_LAYER23");
4417 case BALANCE_XMIT_POLICY_LAYER34:
4418 printf("BALANCE_XMIT_POLICY_LAYER34");
4425 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4427 if (num_slaves < 0) {
4428 printf("\tFailed to get slave list for port = %d\n", port_id);
4431 if (num_slaves > 0) {
4432 printf("\tSlaves (%d): [", num_slaves);
4433 for (i = 0; i < num_slaves - 1; i++)
4434 printf("%d ", slaves[i]);
4436 printf("%d]\n", slaves[num_slaves - 1]);
4438 printf("\tSlaves: []\n");
4442 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4445 if (num_active_slaves < 0) {
4446 printf("\tFailed to get active slave list for port = %d\n", port_id);
4449 if (num_active_slaves > 0) {
4450 printf("\tActive Slaves (%d): [", num_active_slaves);
4451 for (i = 0; i < num_active_slaves - 1; i++)
4452 printf("%d ", slaves[i]);
4454 printf("%d]\n", slaves[num_active_slaves - 1]);
4457 printf("\tActive Slaves: []\n");
4461 primary_id = rte_eth_bond_primary_get(port_id);
4462 if (primary_id < 0) {
4463 printf("\tFailed to get primary slave for port = %d\n", port_id);
4466 printf("\tPrimary: [%d]\n", primary_id);
4470 cmdline_parse_token_string_t cmd_showbonding_config_show =
4471 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4473 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4474 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4475 bonding, "bonding");
4476 cmdline_parse_token_string_t cmd_showbonding_config_config =
4477 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4479 cmdline_parse_token_num_t cmd_showbonding_config_port =
4480 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4483 cmdline_parse_inst_t cmd_show_bonding_config = {
4484 .f = cmd_show_bonding_config_parsed,
4485 .help_str = "show bonding config <port_id>: "
4486 "Show the bonding config for port_id",
4489 (void *)&cmd_showbonding_config_show,
4490 (void *)&cmd_showbonding_config_bonding,
4491 (void *)&cmd_showbonding_config_config,
4492 (void *)&cmd_showbonding_config_port,
4497 /* *** SET BONDING PRIMARY *** */
4498 struct cmd_set_bonding_primary_result {
4499 cmdline_fixed_string_t set;
4500 cmdline_fixed_string_t bonding;
4501 cmdline_fixed_string_t primary;
4506 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4507 __attribute__((unused)) struct cmdline *cl,
4508 __attribute__((unused)) void *data)
4510 struct cmd_set_bonding_primary_result *res = parsed_result;
4511 portid_t master_port_id = res->port_id;
4512 portid_t slave_port_id = res->slave_id;
4514 /* Set the primary slave for a bonded device. */
4515 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4516 printf("\t Failed to set primary slave for port = %d.\n",
4523 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4524 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4526 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4527 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4528 bonding, "bonding");
4529 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4530 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4531 primary, "primary");
4532 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4533 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4535 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4536 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4539 cmdline_parse_inst_t cmd_set_bonding_primary = {
4540 .f = cmd_set_bonding_primary_parsed,
4541 .help_str = "set bonding primary <slave_id> <port_id>: "
4542 "Set the primary slave for port_id",
4545 (void *)&cmd_setbonding_primary_set,
4546 (void *)&cmd_setbonding_primary_bonding,
4547 (void *)&cmd_setbonding_primary_primary,
4548 (void *)&cmd_setbonding_primary_slave,
4549 (void *)&cmd_setbonding_primary_port,
4554 /* *** ADD SLAVE *** */
4555 struct cmd_add_bonding_slave_result {
4556 cmdline_fixed_string_t add;
4557 cmdline_fixed_string_t bonding;
4558 cmdline_fixed_string_t slave;
4563 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4564 __attribute__((unused)) struct cmdline *cl,
4565 __attribute__((unused)) void *data)
4567 struct cmd_add_bonding_slave_result *res = parsed_result;
4568 portid_t master_port_id = res->port_id;
4569 portid_t slave_port_id = res->slave_id;
4571 /* Set the primary slave for a bonded device. */
4572 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4573 printf("\t Failed to add slave %d to master port = %d.\n",
4574 slave_port_id, master_port_id);
4578 set_port_slave_flag(slave_port_id);
4581 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4582 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4584 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4585 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4586 bonding, "bonding");
4587 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4588 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4590 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4591 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4593 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4594 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4597 cmdline_parse_inst_t cmd_add_bonding_slave = {
4598 .f = cmd_add_bonding_slave_parsed,
4599 .help_str = "add bonding slave <slave_id> <port_id>: "
4600 "Add a slave device to a bonded device",
4603 (void *)&cmd_addbonding_slave_add,
4604 (void *)&cmd_addbonding_slave_bonding,
4605 (void *)&cmd_addbonding_slave_slave,
4606 (void *)&cmd_addbonding_slave_slaveid,
4607 (void *)&cmd_addbonding_slave_port,
4612 /* *** REMOVE SLAVE *** */
4613 struct cmd_remove_bonding_slave_result {
4614 cmdline_fixed_string_t remove;
4615 cmdline_fixed_string_t bonding;
4616 cmdline_fixed_string_t slave;
4621 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4622 __attribute__((unused)) struct cmdline *cl,
4623 __attribute__((unused)) void *data)
4625 struct cmd_remove_bonding_slave_result *res = parsed_result;
4626 portid_t master_port_id = res->port_id;
4627 portid_t slave_port_id = res->slave_id;
4629 /* Set the primary slave for a bonded device. */
4630 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4631 printf("\t Failed to remove slave %d from master port = %d.\n",
4632 slave_port_id, master_port_id);
4636 clear_port_slave_flag(slave_port_id);
4639 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4640 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4642 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4643 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4644 bonding, "bonding");
4645 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4646 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4648 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4649 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4651 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4652 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4655 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4656 .f = cmd_remove_bonding_slave_parsed,
4657 .help_str = "remove bonding slave <slave_id> <port_id>: "
4658 "Remove a slave device from a bonded device",
4661 (void *)&cmd_removebonding_slave_remove,
4662 (void *)&cmd_removebonding_slave_bonding,
4663 (void *)&cmd_removebonding_slave_slave,
4664 (void *)&cmd_removebonding_slave_slaveid,
4665 (void *)&cmd_removebonding_slave_port,
4670 /* *** CREATE BONDED DEVICE *** */
4671 struct cmd_create_bonded_device_result {
4672 cmdline_fixed_string_t create;
4673 cmdline_fixed_string_t bonded;
4674 cmdline_fixed_string_t device;
4679 static int bond_dev_num = 0;
4681 static void cmd_create_bonded_device_parsed(void *parsed_result,
4682 __attribute__((unused)) struct cmdline *cl,
4683 __attribute__((unused)) void *data)
4685 struct cmd_create_bonded_device_result *res = parsed_result;
4686 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4689 if (test_done == 0) {
4690 printf("Please stop forwarding first\n");
4694 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4697 /* Create a new bonded device. */
4698 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4700 printf("\t Failed to create bonded device.\n");
4703 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4706 /* Update number of ports */
4707 nb_ports = rte_eth_dev_count();
4708 reconfig(port_id, res->socket);
4709 rte_eth_promiscuous_enable(port_id);
4714 cmdline_parse_token_string_t cmd_createbonded_device_create =
4715 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4717 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4718 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4720 cmdline_parse_token_string_t cmd_createbonded_device_device =
4721 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4723 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4724 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4726 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4727 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4730 cmdline_parse_inst_t cmd_create_bonded_device = {
4731 .f = cmd_create_bonded_device_parsed,
4732 .help_str = "create bonded device <mode> <socket>: "
4733 "Create a new bonded device with specific bonding mode and socket",
4736 (void *)&cmd_createbonded_device_create,
4737 (void *)&cmd_createbonded_device_bonded,
4738 (void *)&cmd_createbonded_device_device,
4739 (void *)&cmd_createbonded_device_mode,
4740 (void *)&cmd_createbonded_device_socket,
4745 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4746 struct cmd_set_bond_mac_addr_result {
4747 cmdline_fixed_string_t set;
4748 cmdline_fixed_string_t bonding;
4749 cmdline_fixed_string_t mac_addr;
4751 struct ether_addr address;
4754 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4755 __attribute__((unused)) struct cmdline *cl,
4756 __attribute__((unused)) void *data)
4758 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4761 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4764 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4766 /* check the return value and print it if is < 0 */
4768 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4771 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4772 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4773 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4774 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4776 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4777 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4779 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4780 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4781 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4782 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4784 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4785 .f = cmd_set_bond_mac_addr_parsed,
4787 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4789 (void *)&cmd_set_bond_mac_addr_set,
4790 (void *)&cmd_set_bond_mac_addr_bonding,
4791 (void *)&cmd_set_bond_mac_addr_mac,
4792 (void *)&cmd_set_bond_mac_addr_portnum,
4793 (void *)&cmd_set_bond_mac_addr_addr,
4799 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4800 struct cmd_set_bond_mon_period_result {
4801 cmdline_fixed_string_t set;
4802 cmdline_fixed_string_t bonding;
4803 cmdline_fixed_string_t mon_period;
4808 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4809 __attribute__((unused)) struct cmdline *cl,
4810 __attribute__((unused)) void *data)
4812 struct cmd_set_bond_mon_period_result *res = parsed_result;
4815 if (res->port_num >= nb_ports) {
4816 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4820 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4822 /* check the return value and print it if is < 0 */
4824 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4827 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4828 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4830 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4831 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4832 bonding, "bonding");
4833 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4834 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4835 mon_period, "mon_period");
4836 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4837 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4839 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4840 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4843 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4844 .f = cmd_set_bond_mon_period_parsed,
4846 .help_str = "set bonding mon_period <port_id> <period_ms>",
4848 (void *)&cmd_set_bond_mon_period_set,
4849 (void *)&cmd_set_bond_mon_period_bonding,
4850 (void *)&cmd_set_bond_mon_period_mon_period,
4851 (void *)&cmd_set_bond_mon_period_portnum,
4852 (void *)&cmd_set_bond_mon_period_period_ms,
4857 #endif /* RTE_LIBRTE_PMD_BOND */
4859 /* *** SET FORWARDING MODE *** */
4860 struct cmd_set_fwd_mode_result {
4861 cmdline_fixed_string_t set;
4862 cmdline_fixed_string_t fwd;
4863 cmdline_fixed_string_t mode;
4866 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4867 __attribute__((unused)) struct cmdline *cl,
4868 __attribute__((unused)) void *data)
4870 struct cmd_set_fwd_mode_result *res = parsed_result;
4873 set_pkt_forwarding_mode(res->mode);
4876 cmdline_parse_token_string_t cmd_setfwd_set =
4877 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4878 cmdline_parse_token_string_t cmd_setfwd_fwd =
4879 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4880 cmdline_parse_token_string_t cmd_setfwd_mode =
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4882 "" /* defined at init */);
4884 cmdline_parse_inst_t cmd_set_fwd_mode = {
4885 .f = cmd_set_fwd_mode_parsed,
4887 .help_str = NULL, /* defined at init */
4889 (void *)&cmd_setfwd_set,
4890 (void *)&cmd_setfwd_fwd,
4891 (void *)&cmd_setfwd_mode,
4896 static void cmd_set_fwd_mode_init(void)
4899 static char token[128];
4900 static char help[256];
4901 cmdline_parse_token_string_t *token_struct;
4903 modes = list_pkt_forwarding_modes();
4904 snprintf(help, sizeof(help), "set fwd %s: "
4905 "Set packet forwarding mode", modes);
4906 cmd_set_fwd_mode.help_str = help;
4908 /* string token separator is # */
4909 for (c = token; *modes != '\0'; modes++)
4914 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4915 token_struct->string_data.str = token;
4918 /* *** SET RETRY FORWARDING MODE *** */
4919 struct cmd_set_fwd_retry_mode_result {
4920 cmdline_fixed_string_t set;
4921 cmdline_fixed_string_t fwd;
4922 cmdline_fixed_string_t mode;
4923 cmdline_fixed_string_t retry;
4926 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4927 __attribute__((unused)) struct cmdline *cl,
4928 __attribute__((unused)) void *data)
4930 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4933 set_pkt_forwarding_mode(res->mode);
4936 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4937 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4939 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4940 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4942 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4943 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4945 "" /* defined at init */);
4946 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4947 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4950 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4951 .f = cmd_set_fwd_retry_mode_parsed,
4953 .help_str = NULL, /* defined at init */
4955 (void *)&cmd_setfwd_retry_set,
4956 (void *)&cmd_setfwd_retry_fwd,
4957 (void *)&cmd_setfwd_retry_mode,
4958 (void *)&cmd_setfwd_retry_retry,
4963 static void cmd_set_fwd_retry_mode_init(void)
4966 static char token[128];
4967 static char help[256];
4968 cmdline_parse_token_string_t *token_struct;
4970 modes = list_pkt_forwarding_retry_modes();
4971 snprintf(help, sizeof(help), "set fwd %s retry: "
4972 "Set packet forwarding mode with retry", modes);
4973 cmd_set_fwd_retry_mode.help_str = help;
4975 /* string token separator is # */
4976 for (c = token; *modes != '\0'; modes++)
4981 token_struct = (cmdline_parse_token_string_t *)
4982 cmd_set_fwd_retry_mode.tokens[2];
4983 token_struct->string_data.str = token;
4986 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4987 struct cmd_set_burst_tx_retry_result {
4988 cmdline_fixed_string_t set;
4989 cmdline_fixed_string_t burst;
4990 cmdline_fixed_string_t tx;
4991 cmdline_fixed_string_t delay;
4993 cmdline_fixed_string_t retry;
4997 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4998 __attribute__((unused)) struct cmdline *cl,
4999 __attribute__((unused)) void *data)
5001 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5003 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5004 && !strcmp(res->tx, "tx")) {
5005 if (!strcmp(res->delay, "delay"))
5006 burst_tx_delay_time = res->time;
5007 if (!strcmp(res->retry, "retry"))
5008 burst_tx_retry_num = res->retry_num;
5013 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5014 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5015 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5016 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5018 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5019 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5020 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5021 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5022 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5023 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5024 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5025 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5026 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5027 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5029 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5030 .f = cmd_set_burst_tx_retry_parsed,
5031 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5033 (void *)&cmd_set_burst_tx_retry_set,
5034 (void *)&cmd_set_burst_tx_retry_burst,
5035 (void *)&cmd_set_burst_tx_retry_tx,
5036 (void *)&cmd_set_burst_tx_retry_delay,
5037 (void *)&cmd_set_burst_tx_retry_time,
5038 (void *)&cmd_set_burst_tx_retry_retry,
5039 (void *)&cmd_set_burst_tx_retry_retry_num,
5044 /* *** SET PROMISC MODE *** */
5045 struct cmd_set_promisc_mode_result {
5046 cmdline_fixed_string_t set;
5047 cmdline_fixed_string_t promisc;
5048 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5049 uint8_t port_num; /* valid if "allports" argument == 0 */
5050 cmdline_fixed_string_t mode;
5053 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5054 __attribute__((unused)) struct cmdline *cl,
5057 struct cmd_set_promisc_mode_result *res = parsed_result;
5061 if (!strcmp(res->mode, "on"))
5068 RTE_ETH_FOREACH_DEV(i) {
5070 rte_eth_promiscuous_enable(i);
5072 rte_eth_promiscuous_disable(i);
5077 rte_eth_promiscuous_enable(res->port_num);
5079 rte_eth_promiscuous_disable(res->port_num);
5083 cmdline_parse_token_string_t cmd_setpromisc_set =
5084 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5085 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5086 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5088 cmdline_parse_token_string_t cmd_setpromisc_portall =
5089 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5091 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5092 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5094 cmdline_parse_token_string_t cmd_setpromisc_mode =
5095 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5098 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5099 .f = cmd_set_promisc_mode_parsed,
5101 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5103 (void *)&cmd_setpromisc_set,
5104 (void *)&cmd_setpromisc_promisc,
5105 (void *)&cmd_setpromisc_portall,
5106 (void *)&cmd_setpromisc_mode,
5111 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5112 .f = cmd_set_promisc_mode_parsed,
5114 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5116 (void *)&cmd_setpromisc_set,
5117 (void *)&cmd_setpromisc_promisc,
5118 (void *)&cmd_setpromisc_portnum,
5119 (void *)&cmd_setpromisc_mode,
5124 /* *** SET ALLMULTI MODE *** */
5125 struct cmd_set_allmulti_mode_result {
5126 cmdline_fixed_string_t set;
5127 cmdline_fixed_string_t allmulti;
5128 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5129 uint8_t port_num; /* valid if "allports" argument == 0 */
5130 cmdline_fixed_string_t mode;
5133 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5134 __attribute__((unused)) struct cmdline *cl,
5137 struct cmd_set_allmulti_mode_result *res = parsed_result;
5141 if (!strcmp(res->mode, "on"))
5148 RTE_ETH_FOREACH_DEV(i) {
5150 rte_eth_allmulticast_enable(i);
5152 rte_eth_allmulticast_disable(i);
5157 rte_eth_allmulticast_enable(res->port_num);
5159 rte_eth_allmulticast_disable(res->port_num);
5163 cmdline_parse_token_string_t cmd_setallmulti_set =
5164 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5165 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5166 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5168 cmdline_parse_token_string_t cmd_setallmulti_portall =
5169 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5171 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5172 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5174 cmdline_parse_token_string_t cmd_setallmulti_mode =
5175 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5178 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5179 .f = cmd_set_allmulti_mode_parsed,
5181 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5183 (void *)&cmd_setallmulti_set,
5184 (void *)&cmd_setallmulti_allmulti,
5185 (void *)&cmd_setallmulti_portall,
5186 (void *)&cmd_setallmulti_mode,
5191 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5192 .f = cmd_set_allmulti_mode_parsed,
5194 .help_str = "set allmulti <port_id> on|off: "
5195 "Set allmulti mode on port_id",
5197 (void *)&cmd_setallmulti_set,
5198 (void *)&cmd_setallmulti_allmulti,
5199 (void *)&cmd_setallmulti_portnum,
5200 (void *)&cmd_setallmulti_mode,
5205 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5206 struct cmd_link_flow_ctrl_set_result {
5207 cmdline_fixed_string_t set;
5208 cmdline_fixed_string_t flow_ctrl;
5209 cmdline_fixed_string_t rx;
5210 cmdline_fixed_string_t rx_lfc_mode;
5211 cmdline_fixed_string_t tx;
5212 cmdline_fixed_string_t tx_lfc_mode;
5213 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5214 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5215 cmdline_fixed_string_t autoneg_str;
5216 cmdline_fixed_string_t autoneg;
5217 cmdline_fixed_string_t hw_str;
5218 uint32_t high_water;
5219 cmdline_fixed_string_t lw_str;
5221 cmdline_fixed_string_t pt_str;
5222 uint16_t pause_time;
5223 cmdline_fixed_string_t xon_str;
5228 cmdline_parse_token_string_t cmd_lfc_set_set =
5229 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5231 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5232 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5233 flow_ctrl, "flow_ctrl");
5234 cmdline_parse_token_string_t cmd_lfc_set_rx =
5235 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5237 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5238 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5239 rx_lfc_mode, "on#off");
5240 cmdline_parse_token_string_t cmd_lfc_set_tx =
5241 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5243 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5244 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5245 tx_lfc_mode, "on#off");
5246 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5247 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5248 hw_str, "high_water");
5249 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5250 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5251 high_water, UINT32);
5252 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5253 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5254 lw_str, "low_water");
5255 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5256 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5258 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5259 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5260 pt_str, "pause_time");
5261 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5262 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5263 pause_time, UINT16);
5264 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5265 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5266 xon_str, "send_xon");
5267 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5268 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5270 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5271 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5272 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5273 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5274 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5275 mac_ctrl_frame_fwd_mode, "on#off");
5276 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5277 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5278 autoneg_str, "autoneg");
5279 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5280 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5282 cmdline_parse_token_num_t cmd_lfc_set_portid =
5283 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5286 /* forward declaration */
5288 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5291 cmdline_parse_inst_t cmd_link_flow_control_set = {
5292 .f = cmd_link_flow_ctrl_set_parsed,
5294 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5295 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5296 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5298 (void *)&cmd_lfc_set_set,
5299 (void *)&cmd_lfc_set_flow_ctrl,
5300 (void *)&cmd_lfc_set_rx,
5301 (void *)&cmd_lfc_set_rx_mode,
5302 (void *)&cmd_lfc_set_tx,
5303 (void *)&cmd_lfc_set_tx_mode,
5304 (void *)&cmd_lfc_set_high_water,
5305 (void *)&cmd_lfc_set_low_water,
5306 (void *)&cmd_lfc_set_pause_time,
5307 (void *)&cmd_lfc_set_send_xon,
5308 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5309 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5310 (void *)&cmd_lfc_set_autoneg_str,
5311 (void *)&cmd_lfc_set_autoneg,
5312 (void *)&cmd_lfc_set_portid,
5317 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5318 .f = cmd_link_flow_ctrl_set_parsed,
5319 .data = (void *)&cmd_link_flow_control_set_rx,
5320 .help_str = "set flow_ctrl rx on|off <port_id>: "
5321 "Change rx flow control parameter",
5323 (void *)&cmd_lfc_set_set,
5324 (void *)&cmd_lfc_set_flow_ctrl,
5325 (void *)&cmd_lfc_set_rx,
5326 (void *)&cmd_lfc_set_rx_mode,
5327 (void *)&cmd_lfc_set_portid,
5332 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5333 .f = cmd_link_flow_ctrl_set_parsed,
5334 .data = (void *)&cmd_link_flow_control_set_tx,
5335 .help_str = "set flow_ctrl tx on|off <port_id>: "
5336 "Change tx flow control parameter",
5338 (void *)&cmd_lfc_set_set,
5339 (void *)&cmd_lfc_set_flow_ctrl,
5340 (void *)&cmd_lfc_set_tx,
5341 (void *)&cmd_lfc_set_tx_mode,
5342 (void *)&cmd_lfc_set_portid,
5347 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5348 .f = cmd_link_flow_ctrl_set_parsed,
5349 .data = (void *)&cmd_link_flow_control_set_hw,
5350 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5351 "Change high water flow control parameter",
5353 (void *)&cmd_lfc_set_set,
5354 (void *)&cmd_lfc_set_flow_ctrl,
5355 (void *)&cmd_lfc_set_high_water_str,
5356 (void *)&cmd_lfc_set_high_water,
5357 (void *)&cmd_lfc_set_portid,
5362 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5363 .f = cmd_link_flow_ctrl_set_parsed,
5364 .data = (void *)&cmd_link_flow_control_set_lw,
5365 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5366 "Change low water flow control parameter",
5368 (void *)&cmd_lfc_set_set,
5369 (void *)&cmd_lfc_set_flow_ctrl,
5370 (void *)&cmd_lfc_set_low_water_str,
5371 (void *)&cmd_lfc_set_low_water,
5372 (void *)&cmd_lfc_set_portid,
5377 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5378 .f = cmd_link_flow_ctrl_set_parsed,
5379 .data = (void *)&cmd_link_flow_control_set_pt,
5380 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5381 "Change pause time flow control parameter",
5383 (void *)&cmd_lfc_set_set,
5384 (void *)&cmd_lfc_set_flow_ctrl,
5385 (void *)&cmd_lfc_set_pause_time_str,
5386 (void *)&cmd_lfc_set_pause_time,
5387 (void *)&cmd_lfc_set_portid,
5392 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5393 .f = cmd_link_flow_ctrl_set_parsed,
5394 .data = (void *)&cmd_link_flow_control_set_xon,
5395 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5396 "Change send_xon flow control parameter",
5398 (void *)&cmd_lfc_set_set,
5399 (void *)&cmd_lfc_set_flow_ctrl,
5400 (void *)&cmd_lfc_set_send_xon_str,
5401 (void *)&cmd_lfc_set_send_xon,
5402 (void *)&cmd_lfc_set_portid,
5407 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5408 .f = cmd_link_flow_ctrl_set_parsed,
5409 .data = (void *)&cmd_link_flow_control_set_macfwd,
5410 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5411 "Change mac ctrl fwd flow control parameter",
5413 (void *)&cmd_lfc_set_set,
5414 (void *)&cmd_lfc_set_flow_ctrl,
5415 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5416 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5417 (void *)&cmd_lfc_set_portid,
5422 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5423 .f = cmd_link_flow_ctrl_set_parsed,
5424 .data = (void *)&cmd_link_flow_control_set_autoneg,
5425 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5426 "Change autoneg flow control parameter",
5428 (void *)&cmd_lfc_set_set,
5429 (void *)&cmd_lfc_set_flow_ctrl,
5430 (void *)&cmd_lfc_set_autoneg_str,
5431 (void *)&cmd_lfc_set_autoneg,
5432 (void *)&cmd_lfc_set_portid,
5438 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5439 __attribute__((unused)) struct cmdline *cl,
5442 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5443 cmdline_parse_inst_t *cmd = data;
5444 struct rte_eth_fc_conf fc_conf;
5450 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5451 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5452 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5453 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5455 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5456 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5459 /* Partial command line, retrieve current configuration */
5461 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5463 printf("cannot get current flow ctrl parameters, return"
5464 "code = %d\n", ret);
5468 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5469 (fc_conf.mode == RTE_FC_FULL))
5471 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5472 (fc_conf.mode == RTE_FC_FULL))
5476 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5477 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5479 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5480 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5482 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5484 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5485 fc_conf.high_water = res->high_water;
5487 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5488 fc_conf.low_water = res->low_water;
5490 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5491 fc_conf.pause_time = res->pause_time;
5493 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5494 fc_conf.send_xon = res->send_xon;
5496 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5497 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5498 fc_conf.mac_ctrl_frame_fwd = 1;
5500 fc_conf.mac_ctrl_frame_fwd = 0;
5503 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5504 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5506 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5508 printf("bad flow contrl parameter, return code = %d \n", ret);
5511 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5512 struct cmd_priority_flow_ctrl_set_result {
5513 cmdline_fixed_string_t set;
5514 cmdline_fixed_string_t pfc_ctrl;
5515 cmdline_fixed_string_t rx;
5516 cmdline_fixed_string_t rx_pfc_mode;
5517 cmdline_fixed_string_t tx;
5518 cmdline_fixed_string_t tx_pfc_mode;
5519 uint32_t high_water;
5521 uint16_t pause_time;
5527 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5528 __attribute__((unused)) struct cmdline *cl,
5529 __attribute__((unused)) void *data)
5531 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5532 struct rte_eth_pfc_conf pfc_conf;
5533 int rx_fc_enable, tx_fc_enable;
5537 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5538 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5539 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5540 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5542 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5543 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5546 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5547 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5548 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5549 pfc_conf.fc.high_water = res->high_water;
5550 pfc_conf.fc.low_water = res->low_water;
5551 pfc_conf.fc.pause_time = res->pause_time;
5552 pfc_conf.priority = res->priority;
5554 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5556 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5559 cmdline_parse_token_string_t cmd_pfc_set_set =
5560 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5562 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5563 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5564 pfc_ctrl, "pfc_ctrl");
5565 cmdline_parse_token_string_t cmd_pfc_set_rx =
5566 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5568 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5569 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5570 rx_pfc_mode, "on#off");
5571 cmdline_parse_token_string_t cmd_pfc_set_tx =
5572 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5574 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5575 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5576 tx_pfc_mode, "on#off");
5577 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5578 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5579 high_water, UINT32);
5580 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5581 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5583 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5584 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5585 pause_time, UINT16);
5586 cmdline_parse_token_num_t cmd_pfc_set_priority =
5587 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5589 cmdline_parse_token_num_t cmd_pfc_set_portid =
5590 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5593 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5594 .f = cmd_priority_flow_ctrl_set_parsed,
5596 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5597 "<pause_time> <priority> <port_id>: "
5598 "Configure the Ethernet priority flow control",
5600 (void *)&cmd_pfc_set_set,
5601 (void *)&cmd_pfc_set_flow_ctrl,
5602 (void *)&cmd_pfc_set_rx,
5603 (void *)&cmd_pfc_set_rx_mode,
5604 (void *)&cmd_pfc_set_tx,
5605 (void *)&cmd_pfc_set_tx_mode,
5606 (void *)&cmd_pfc_set_high_water,
5607 (void *)&cmd_pfc_set_low_water,
5608 (void *)&cmd_pfc_set_pause_time,
5609 (void *)&cmd_pfc_set_priority,
5610 (void *)&cmd_pfc_set_portid,
5615 /* *** RESET CONFIGURATION *** */
5616 struct cmd_reset_result {
5617 cmdline_fixed_string_t reset;
5618 cmdline_fixed_string_t def;
5621 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5623 __attribute__((unused)) void *data)
5625 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5626 set_def_fwd_config();
5629 cmdline_parse_token_string_t cmd_reset_set =
5630 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5631 cmdline_parse_token_string_t cmd_reset_def =
5632 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5635 cmdline_parse_inst_t cmd_reset = {
5636 .f = cmd_reset_parsed,
5638 .help_str = "set default: Reset default forwarding configuration",
5640 (void *)&cmd_reset_set,
5641 (void *)&cmd_reset_def,
5646 /* *** START FORWARDING *** */
5647 struct cmd_start_result {
5648 cmdline_fixed_string_t start;
5651 cmdline_parse_token_string_t cmd_start_start =
5652 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5654 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5655 __attribute__((unused)) struct cmdline *cl,
5656 __attribute__((unused)) void *data)
5658 start_packet_forwarding(0);
5661 cmdline_parse_inst_t cmd_start = {
5662 .f = cmd_start_parsed,
5664 .help_str = "start: Start packet forwarding",
5666 (void *)&cmd_start_start,
5671 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5672 struct cmd_start_tx_first_result {
5673 cmdline_fixed_string_t start;
5674 cmdline_fixed_string_t tx_first;
5678 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5679 __attribute__((unused)) struct cmdline *cl,
5680 __attribute__((unused)) void *data)
5682 start_packet_forwarding(1);
5685 cmdline_parse_token_string_t cmd_start_tx_first_start =
5686 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5688 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5689 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5690 tx_first, "tx_first");
5692 cmdline_parse_inst_t cmd_start_tx_first = {
5693 .f = cmd_start_tx_first_parsed,
5695 .help_str = "start tx_first: Start packet forwarding, "
5696 "after sending 1 burst of packets",
5698 (void *)&cmd_start_tx_first_start,
5699 (void *)&cmd_start_tx_first_tx_first,
5704 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5705 struct cmd_start_tx_first_n_result {
5706 cmdline_fixed_string_t start;
5707 cmdline_fixed_string_t tx_first;
5712 cmd_start_tx_first_n_parsed(void *parsed_result,
5713 __attribute__((unused)) struct cmdline *cl,
5714 __attribute__((unused)) void *data)
5716 struct cmd_start_tx_first_n_result *res = parsed_result;
5718 start_packet_forwarding(res->tx_num);
5721 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5722 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5724 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5725 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5726 tx_first, "tx_first");
5727 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5728 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5731 cmdline_parse_inst_t cmd_start_tx_first_n = {
5732 .f = cmd_start_tx_first_n_parsed,
5734 .help_str = "start tx_first <num>: "
5735 "packet forwarding, after sending <num> bursts of packets",
5737 (void *)&cmd_start_tx_first_n_start,
5738 (void *)&cmd_start_tx_first_n_tx_first,
5739 (void *)&cmd_start_tx_first_n_tx_num,
5744 /* *** SET LINK UP *** */
5745 struct cmd_set_link_up_result {
5746 cmdline_fixed_string_t set;
5747 cmdline_fixed_string_t link_up;
5748 cmdline_fixed_string_t port;
5752 cmdline_parse_token_string_t cmd_set_link_up_set =
5753 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5754 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5755 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5757 cmdline_parse_token_string_t cmd_set_link_up_port =
5758 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5759 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5760 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5762 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5763 __attribute__((unused)) struct cmdline *cl,
5764 __attribute__((unused)) void *data)
5766 struct cmd_set_link_up_result *res = parsed_result;
5767 dev_set_link_up(res->port_id);
5770 cmdline_parse_inst_t cmd_set_link_up = {
5771 .f = cmd_set_link_up_parsed,
5773 .help_str = "set link-up port <port id>",
5775 (void *)&cmd_set_link_up_set,
5776 (void *)&cmd_set_link_up_link_up,
5777 (void *)&cmd_set_link_up_port,
5778 (void *)&cmd_set_link_up_port_id,
5783 /* *** SET LINK DOWN *** */
5784 struct cmd_set_link_down_result {
5785 cmdline_fixed_string_t set;
5786 cmdline_fixed_string_t link_down;
5787 cmdline_fixed_string_t port;
5791 cmdline_parse_token_string_t cmd_set_link_down_set =
5792 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5793 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5794 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5796 cmdline_parse_token_string_t cmd_set_link_down_port =
5797 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5798 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5799 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5801 static void cmd_set_link_down_parsed(
5802 __attribute__((unused)) void *parsed_result,
5803 __attribute__((unused)) struct cmdline *cl,
5804 __attribute__((unused)) void *data)
5806 struct cmd_set_link_down_result *res = parsed_result;
5807 dev_set_link_down(res->port_id);
5810 cmdline_parse_inst_t cmd_set_link_down = {
5811 .f = cmd_set_link_down_parsed,
5813 .help_str = "set link-down port <port id>",
5815 (void *)&cmd_set_link_down_set,
5816 (void *)&cmd_set_link_down_link_down,
5817 (void *)&cmd_set_link_down_port,
5818 (void *)&cmd_set_link_down_port_id,
5823 /* *** SHOW CFG *** */
5824 struct cmd_showcfg_result {
5825 cmdline_fixed_string_t show;
5826 cmdline_fixed_string_t cfg;
5827 cmdline_fixed_string_t what;
5830 static void cmd_showcfg_parsed(void *parsed_result,
5831 __attribute__((unused)) struct cmdline *cl,
5832 __attribute__((unused)) void *data)
5834 struct cmd_showcfg_result *res = parsed_result;
5835 if (!strcmp(res->what, "rxtx"))
5836 rxtx_config_display();
5837 else if (!strcmp(res->what, "cores"))
5838 fwd_lcores_config_display();
5839 else if (!strcmp(res->what, "fwd"))
5840 pkt_fwd_config_display(&cur_fwd_config);
5841 else if (!strcmp(res->what, "txpkts"))
5842 show_tx_pkt_segments();
5845 cmdline_parse_token_string_t cmd_showcfg_show =
5846 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5847 cmdline_parse_token_string_t cmd_showcfg_port =
5848 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5849 cmdline_parse_token_string_t cmd_showcfg_what =
5850 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5851 "rxtx#cores#fwd#txpkts");
5853 cmdline_parse_inst_t cmd_showcfg = {
5854 .f = cmd_showcfg_parsed,
5856 .help_str = "show config rxtx|cores|fwd|txpkts",
5858 (void *)&cmd_showcfg_show,
5859 (void *)&cmd_showcfg_port,
5860 (void *)&cmd_showcfg_what,
5865 /* *** SHOW ALL PORT INFO *** */
5866 struct cmd_showportall_result {
5867 cmdline_fixed_string_t show;
5868 cmdline_fixed_string_t port;
5869 cmdline_fixed_string_t what;
5870 cmdline_fixed_string_t all;
5873 static void cmd_showportall_parsed(void *parsed_result,
5874 __attribute__((unused)) struct cmdline *cl,
5875 __attribute__((unused)) void *data)
5879 struct cmd_showportall_result *res = parsed_result;
5880 if (!strcmp(res->show, "clear")) {
5881 if (!strcmp(res->what, "stats"))
5882 RTE_ETH_FOREACH_DEV(i)
5884 else if (!strcmp(res->what, "xstats"))
5885 RTE_ETH_FOREACH_DEV(i)
5886 nic_xstats_clear(i);
5887 } else if (!strcmp(res->what, "info"))
5888 RTE_ETH_FOREACH_DEV(i)
5889 port_infos_display(i);
5890 else if (!strcmp(res->what, "stats"))
5891 RTE_ETH_FOREACH_DEV(i)
5892 nic_stats_display(i);
5893 else if (!strcmp(res->what, "xstats"))
5894 RTE_ETH_FOREACH_DEV(i)
5895 nic_xstats_display(i);
5896 else if (!strcmp(res->what, "fdir"))
5897 RTE_ETH_FOREACH_DEV(i)
5899 else if (!strcmp(res->what, "stat_qmap"))
5900 RTE_ETH_FOREACH_DEV(i)
5901 nic_stats_mapping_display(i);
5902 else if (!strcmp(res->what, "dcb_tc"))
5903 RTE_ETH_FOREACH_DEV(i)
5904 port_dcb_info_display(i);
5905 else if (!strcmp(res->what, "cap"))
5906 RTE_ETH_FOREACH_DEV(i)
5907 port_offload_cap_display(i);
5910 cmdline_parse_token_string_t cmd_showportall_show =
5911 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5913 cmdline_parse_token_string_t cmd_showportall_port =
5914 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5915 cmdline_parse_token_string_t cmd_showportall_what =
5916 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5917 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5918 cmdline_parse_token_string_t cmd_showportall_all =
5919 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5920 cmdline_parse_inst_t cmd_showportall = {
5921 .f = cmd_showportall_parsed,
5923 .help_str = "show|clear port "
5924 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5926 (void *)&cmd_showportall_show,
5927 (void *)&cmd_showportall_port,
5928 (void *)&cmd_showportall_what,
5929 (void *)&cmd_showportall_all,
5934 /* *** SHOW PORT INFO *** */
5935 struct cmd_showport_result {
5936 cmdline_fixed_string_t show;
5937 cmdline_fixed_string_t port;
5938 cmdline_fixed_string_t what;
5942 static void cmd_showport_parsed(void *parsed_result,
5943 __attribute__((unused)) struct cmdline *cl,
5944 __attribute__((unused)) void *data)
5946 struct cmd_showport_result *res = parsed_result;
5947 if (!strcmp(res->show, "clear")) {
5948 if (!strcmp(res->what, "stats"))
5949 nic_stats_clear(res->portnum);
5950 else if (!strcmp(res->what, "xstats"))
5951 nic_xstats_clear(res->portnum);
5952 } else if (!strcmp(res->what, "info"))
5953 port_infos_display(res->portnum);
5954 else if (!strcmp(res->what, "stats"))
5955 nic_stats_display(res->portnum);
5956 else if (!strcmp(res->what, "xstats"))
5957 nic_xstats_display(res->portnum);
5958 else if (!strcmp(res->what, "fdir"))
5959 fdir_get_infos(res->portnum);
5960 else if (!strcmp(res->what, "stat_qmap"))
5961 nic_stats_mapping_display(res->portnum);
5962 else if (!strcmp(res->what, "dcb_tc"))
5963 port_dcb_info_display(res->portnum);
5964 else if (!strcmp(res->what, "cap"))
5965 port_offload_cap_display(res->portnum);
5968 cmdline_parse_token_string_t cmd_showport_show =
5969 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5971 cmdline_parse_token_string_t cmd_showport_port =
5972 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5973 cmdline_parse_token_string_t cmd_showport_what =
5974 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5975 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5976 cmdline_parse_token_num_t cmd_showport_portnum =
5977 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5979 cmdline_parse_inst_t cmd_showport = {
5980 .f = cmd_showport_parsed,
5982 .help_str = "show|clear port "
5983 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5986 (void *)&cmd_showport_show,
5987 (void *)&cmd_showport_port,
5988 (void *)&cmd_showport_what,
5989 (void *)&cmd_showport_portnum,
5994 /* *** SHOW QUEUE INFO *** */
5995 struct cmd_showqueue_result {
5996 cmdline_fixed_string_t show;
5997 cmdline_fixed_string_t type;
5998 cmdline_fixed_string_t what;
6004 cmd_showqueue_parsed(void *parsed_result,
6005 __attribute__((unused)) struct cmdline *cl,
6006 __attribute__((unused)) void *data)
6008 struct cmd_showqueue_result *res = parsed_result;
6010 if (!strcmp(res->type, "rxq"))
6011 rx_queue_infos_display(res->portnum, res->queuenum);
6012 else if (!strcmp(res->type, "txq"))
6013 tx_queue_infos_display(res->portnum, res->queuenum);
6016 cmdline_parse_token_string_t cmd_showqueue_show =
6017 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6018 cmdline_parse_token_string_t cmd_showqueue_type =
6019 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6020 cmdline_parse_token_string_t cmd_showqueue_what =
6021 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6022 cmdline_parse_token_num_t cmd_showqueue_portnum =
6023 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6024 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6025 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6027 cmdline_parse_inst_t cmd_showqueue = {
6028 .f = cmd_showqueue_parsed,
6030 .help_str = "show rxq|txq info <port_id> <queue_id>",
6032 (void *)&cmd_showqueue_show,
6033 (void *)&cmd_showqueue_type,
6034 (void *)&cmd_showqueue_what,
6035 (void *)&cmd_showqueue_portnum,
6036 (void *)&cmd_showqueue_queuenum,
6041 /* *** READ PORT REGISTER *** */
6042 struct cmd_read_reg_result {
6043 cmdline_fixed_string_t read;
6044 cmdline_fixed_string_t reg;
6050 cmd_read_reg_parsed(void *parsed_result,
6051 __attribute__((unused)) struct cmdline *cl,
6052 __attribute__((unused)) void *data)
6054 struct cmd_read_reg_result *res = parsed_result;
6055 port_reg_display(res->port_id, res->reg_off);
6058 cmdline_parse_token_string_t cmd_read_reg_read =
6059 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6060 cmdline_parse_token_string_t cmd_read_reg_reg =
6061 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6062 cmdline_parse_token_num_t cmd_read_reg_port_id =
6063 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6064 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6065 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6067 cmdline_parse_inst_t cmd_read_reg = {
6068 .f = cmd_read_reg_parsed,
6070 .help_str = "read reg <port_id> <reg_off>",
6072 (void *)&cmd_read_reg_read,
6073 (void *)&cmd_read_reg_reg,
6074 (void *)&cmd_read_reg_port_id,
6075 (void *)&cmd_read_reg_reg_off,
6080 /* *** READ PORT REGISTER BIT FIELD *** */
6081 struct cmd_read_reg_bit_field_result {
6082 cmdline_fixed_string_t read;
6083 cmdline_fixed_string_t regfield;
6091 cmd_read_reg_bit_field_parsed(void *parsed_result,
6092 __attribute__((unused)) struct cmdline *cl,
6093 __attribute__((unused)) void *data)
6095 struct cmd_read_reg_bit_field_result *res = parsed_result;
6096 port_reg_bit_field_display(res->port_id, res->reg_off,
6097 res->bit1_pos, res->bit2_pos);
6100 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6101 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6103 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6104 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6105 regfield, "regfield");
6106 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6107 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6109 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6110 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6112 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6113 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6115 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6116 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6119 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6120 .f = cmd_read_reg_bit_field_parsed,
6122 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6123 "Read register bit field between bit_x and bit_y included",
6125 (void *)&cmd_read_reg_bit_field_read,
6126 (void *)&cmd_read_reg_bit_field_regfield,
6127 (void *)&cmd_read_reg_bit_field_port_id,
6128 (void *)&cmd_read_reg_bit_field_reg_off,
6129 (void *)&cmd_read_reg_bit_field_bit1_pos,
6130 (void *)&cmd_read_reg_bit_field_bit2_pos,
6135 /* *** READ PORT REGISTER BIT *** */
6136 struct cmd_read_reg_bit_result {
6137 cmdline_fixed_string_t read;
6138 cmdline_fixed_string_t regbit;
6145 cmd_read_reg_bit_parsed(void *parsed_result,
6146 __attribute__((unused)) struct cmdline *cl,
6147 __attribute__((unused)) void *data)
6149 struct cmd_read_reg_bit_result *res = parsed_result;
6150 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6153 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6154 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6155 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6156 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6158 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6159 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6160 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6161 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6162 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6163 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6165 cmdline_parse_inst_t cmd_read_reg_bit = {
6166 .f = cmd_read_reg_bit_parsed,
6168 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6170 (void *)&cmd_read_reg_bit_read,
6171 (void *)&cmd_read_reg_bit_regbit,
6172 (void *)&cmd_read_reg_bit_port_id,
6173 (void *)&cmd_read_reg_bit_reg_off,
6174 (void *)&cmd_read_reg_bit_bit_pos,
6179 /* *** WRITE PORT REGISTER *** */
6180 struct cmd_write_reg_result {
6181 cmdline_fixed_string_t write;
6182 cmdline_fixed_string_t reg;
6189 cmd_write_reg_parsed(void *parsed_result,
6190 __attribute__((unused)) struct cmdline *cl,
6191 __attribute__((unused)) void *data)
6193 struct cmd_write_reg_result *res = parsed_result;
6194 port_reg_set(res->port_id, res->reg_off, res->value);
6197 cmdline_parse_token_string_t cmd_write_reg_write =
6198 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6199 cmdline_parse_token_string_t cmd_write_reg_reg =
6200 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6201 cmdline_parse_token_num_t cmd_write_reg_port_id =
6202 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6203 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6204 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6205 cmdline_parse_token_num_t cmd_write_reg_value =
6206 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6208 cmdline_parse_inst_t cmd_write_reg = {
6209 .f = cmd_write_reg_parsed,
6211 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6213 (void *)&cmd_write_reg_write,
6214 (void *)&cmd_write_reg_reg,
6215 (void *)&cmd_write_reg_port_id,
6216 (void *)&cmd_write_reg_reg_off,
6217 (void *)&cmd_write_reg_value,
6222 /* *** WRITE PORT REGISTER BIT FIELD *** */
6223 struct cmd_write_reg_bit_field_result {
6224 cmdline_fixed_string_t write;
6225 cmdline_fixed_string_t regfield;
6234 cmd_write_reg_bit_field_parsed(void *parsed_result,
6235 __attribute__((unused)) struct cmdline *cl,
6236 __attribute__((unused)) void *data)
6238 struct cmd_write_reg_bit_field_result *res = parsed_result;
6239 port_reg_bit_field_set(res->port_id, res->reg_off,
6240 res->bit1_pos, res->bit2_pos, res->value);
6243 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6244 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6246 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6247 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6248 regfield, "regfield");
6249 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6250 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6252 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6253 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6255 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6256 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6258 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6259 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6261 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6262 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6265 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6266 .f = cmd_write_reg_bit_field_parsed,
6268 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6270 "Set register bit field between bit_x and bit_y included",
6272 (void *)&cmd_write_reg_bit_field_write,
6273 (void *)&cmd_write_reg_bit_field_regfield,
6274 (void *)&cmd_write_reg_bit_field_port_id,
6275 (void *)&cmd_write_reg_bit_field_reg_off,
6276 (void *)&cmd_write_reg_bit_field_bit1_pos,
6277 (void *)&cmd_write_reg_bit_field_bit2_pos,
6278 (void *)&cmd_write_reg_bit_field_value,
6283 /* *** WRITE PORT REGISTER BIT *** */
6284 struct cmd_write_reg_bit_result {
6285 cmdline_fixed_string_t write;
6286 cmdline_fixed_string_t regbit;
6294 cmd_write_reg_bit_parsed(void *parsed_result,
6295 __attribute__((unused)) struct cmdline *cl,
6296 __attribute__((unused)) void *data)
6298 struct cmd_write_reg_bit_result *res = parsed_result;
6299 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6302 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6303 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6305 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6306 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6308 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6309 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6310 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6311 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6312 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6313 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6314 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6315 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6317 cmdline_parse_inst_t cmd_write_reg_bit = {
6318 .f = cmd_write_reg_bit_parsed,
6320 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6323 (void *)&cmd_write_reg_bit_write,
6324 (void *)&cmd_write_reg_bit_regbit,
6325 (void *)&cmd_write_reg_bit_port_id,
6326 (void *)&cmd_write_reg_bit_reg_off,
6327 (void *)&cmd_write_reg_bit_bit_pos,
6328 (void *)&cmd_write_reg_bit_value,
6333 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6334 struct cmd_read_rxd_txd_result {
6335 cmdline_fixed_string_t read;
6336 cmdline_fixed_string_t rxd_txd;
6343 cmd_read_rxd_txd_parsed(void *parsed_result,
6344 __attribute__((unused)) struct cmdline *cl,
6345 __attribute__((unused)) void *data)
6347 struct cmd_read_rxd_txd_result *res = parsed_result;
6349 if (!strcmp(res->rxd_txd, "rxd"))
6350 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6351 else if (!strcmp(res->rxd_txd, "txd"))
6352 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6355 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6356 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6357 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6358 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6360 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6361 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6362 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6363 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6364 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6365 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6367 cmdline_parse_inst_t cmd_read_rxd_txd = {
6368 .f = cmd_read_rxd_txd_parsed,
6370 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6372 (void *)&cmd_read_rxd_txd_read,
6373 (void *)&cmd_read_rxd_txd_rxd_txd,
6374 (void *)&cmd_read_rxd_txd_port_id,
6375 (void *)&cmd_read_rxd_txd_queue_id,
6376 (void *)&cmd_read_rxd_txd_desc_id,
6382 struct cmd_quit_result {
6383 cmdline_fixed_string_t quit;
6386 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6388 __attribute__((unused)) void *data)
6394 cmdline_parse_token_string_t cmd_quit_quit =
6395 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6397 cmdline_parse_inst_t cmd_quit = {
6398 .f = cmd_quit_parsed,
6400 .help_str = "quit: Exit application",
6402 (void *)&cmd_quit_quit,
6407 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6408 struct cmd_mac_addr_result {
6409 cmdline_fixed_string_t mac_addr_cmd;
6410 cmdline_fixed_string_t what;
6412 struct ether_addr address;
6415 static void cmd_mac_addr_parsed(void *parsed_result,
6416 __attribute__((unused)) struct cmdline *cl,
6417 __attribute__((unused)) void *data)
6419 struct cmd_mac_addr_result *res = parsed_result;
6422 if (strcmp(res->what, "add") == 0)
6423 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6424 else if (strcmp(res->what, "set") == 0)
6425 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6428 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6430 /* check the return value and print it if is < 0 */
6432 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6436 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6437 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6439 cmdline_parse_token_string_t cmd_mac_addr_what =
6440 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6442 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6443 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6444 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6445 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6447 cmdline_parse_inst_t cmd_mac_addr = {
6448 .f = cmd_mac_addr_parsed,
6450 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6451 "Add/Remove/Set MAC address on port_id",
6453 (void *)&cmd_mac_addr_cmd,
6454 (void *)&cmd_mac_addr_what,
6455 (void *)&cmd_mac_addr_portnum,
6456 (void *)&cmd_mac_addr_addr,
6462 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6463 struct cmd_set_qmap_result {
6464 cmdline_fixed_string_t set;
6465 cmdline_fixed_string_t qmap;
6466 cmdline_fixed_string_t what;
6473 cmd_set_qmap_parsed(void *parsed_result,
6474 __attribute__((unused)) struct cmdline *cl,
6475 __attribute__((unused)) void *data)
6477 struct cmd_set_qmap_result *res = parsed_result;
6478 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6480 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6483 cmdline_parse_token_string_t cmd_setqmap_set =
6484 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6486 cmdline_parse_token_string_t cmd_setqmap_qmap =
6487 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6489 cmdline_parse_token_string_t cmd_setqmap_what =
6490 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6492 cmdline_parse_token_num_t cmd_setqmap_portid =
6493 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6495 cmdline_parse_token_num_t cmd_setqmap_queueid =
6496 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6498 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6499 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6502 cmdline_parse_inst_t cmd_set_qmap = {
6503 .f = cmd_set_qmap_parsed,
6505 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6506 "Set statistics mapping value on tx|rx queue_id of port_id",
6508 (void *)&cmd_setqmap_set,
6509 (void *)&cmd_setqmap_qmap,
6510 (void *)&cmd_setqmap_what,
6511 (void *)&cmd_setqmap_portid,
6512 (void *)&cmd_setqmap_queueid,
6513 (void *)&cmd_setqmap_mapvalue,
6518 /* *** CONFIGURE UNICAST HASH TABLE *** */
6519 struct cmd_set_uc_hash_table {
6520 cmdline_fixed_string_t set;
6521 cmdline_fixed_string_t port;
6523 cmdline_fixed_string_t what;
6524 struct ether_addr address;
6525 cmdline_fixed_string_t mode;
6529 cmd_set_uc_hash_parsed(void *parsed_result,
6530 __attribute__((unused)) struct cmdline *cl,
6531 __attribute__((unused)) void *data)
6534 struct cmd_set_uc_hash_table *res = parsed_result;
6536 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6538 if (strcmp(res->what, "uta") == 0)
6539 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6540 &res->address,(uint8_t)is_on);
6542 printf("bad unicast hash table parameter, return code = %d \n", ret);
6546 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6547 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6549 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6550 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6552 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6553 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6555 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6556 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6558 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6559 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6561 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6562 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6565 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6566 .f = cmd_set_uc_hash_parsed,
6568 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6570 (void *)&cmd_set_uc_hash_set,
6571 (void *)&cmd_set_uc_hash_port,
6572 (void *)&cmd_set_uc_hash_portid,
6573 (void *)&cmd_set_uc_hash_what,
6574 (void *)&cmd_set_uc_hash_mac,
6575 (void *)&cmd_set_uc_hash_mode,
6580 struct cmd_set_uc_all_hash_table {
6581 cmdline_fixed_string_t set;
6582 cmdline_fixed_string_t port;
6584 cmdline_fixed_string_t what;
6585 cmdline_fixed_string_t value;
6586 cmdline_fixed_string_t mode;
6590 cmd_set_uc_all_hash_parsed(void *parsed_result,
6591 __attribute__((unused)) struct cmdline *cl,
6592 __attribute__((unused)) void *data)
6595 struct cmd_set_uc_all_hash_table *res = parsed_result;
6597 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6599 if ((strcmp(res->what, "uta") == 0) &&
6600 (strcmp(res->value, "all") == 0))
6601 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6603 printf("bad unicast hash table parameter,"
6604 "return code = %d \n", ret);
6607 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6608 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6610 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6611 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6613 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6614 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6616 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6617 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6619 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6620 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6622 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6623 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6626 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6627 .f = cmd_set_uc_all_hash_parsed,
6629 .help_str = "set port <port_id> uta all on|off",
6631 (void *)&cmd_set_uc_all_hash_set,
6632 (void *)&cmd_set_uc_all_hash_port,
6633 (void *)&cmd_set_uc_all_hash_portid,
6634 (void *)&cmd_set_uc_all_hash_what,
6635 (void *)&cmd_set_uc_all_hash_value,
6636 (void *)&cmd_set_uc_all_hash_mode,
6641 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6642 struct cmd_set_vf_macvlan_filter {
6643 cmdline_fixed_string_t set;
6644 cmdline_fixed_string_t port;
6646 cmdline_fixed_string_t vf;
6648 struct ether_addr address;
6649 cmdline_fixed_string_t filter_type;
6650 cmdline_fixed_string_t mode;
6654 cmd_set_vf_macvlan_parsed(void *parsed_result,
6655 __attribute__((unused)) struct cmdline *cl,
6656 __attribute__((unused)) void *data)
6659 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6660 struct rte_eth_mac_filter filter;
6662 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6664 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6666 /* set VF MAC filter */
6670 filter.dst_id = res->vf_id;
6672 if (!strcmp(res->filter_type, "exact-mac"))
6673 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6674 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6675 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6676 else if (!strcmp(res->filter_type, "hashmac"))
6677 filter.filter_type = RTE_MAC_HASH_MATCH;
6678 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6679 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6681 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6684 ret = rte_eth_dev_filter_ctrl(res->port_id,
6685 RTE_ETH_FILTER_MACVLAN,
6689 ret = rte_eth_dev_filter_ctrl(res->port_id,
6690 RTE_ETH_FILTER_MACVLAN,
6691 RTE_ETH_FILTER_DELETE,
6695 printf("bad set MAC hash parameter, return code = %d\n", ret);
6699 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6700 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6702 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6703 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6705 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6706 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6708 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6709 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6711 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6712 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6714 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6715 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6717 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6718 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6719 filter_type, "exact-mac#exact-mac-vlan"
6720 "#hashmac#hashmac-vlan");
6721 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6722 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6725 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6726 .f = cmd_set_vf_macvlan_parsed,
6728 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6729 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6730 "Exact match rule: exact match of MAC or MAC and VLAN; "
6731 "hash match rule: hash match of MAC and exact match of VLAN",
6733 (void *)&cmd_set_vf_macvlan_set,
6734 (void *)&cmd_set_vf_macvlan_port,
6735 (void *)&cmd_set_vf_macvlan_portid,
6736 (void *)&cmd_set_vf_macvlan_vf,
6737 (void *)&cmd_set_vf_macvlan_vf_id,
6738 (void *)&cmd_set_vf_macvlan_mac,
6739 (void *)&cmd_set_vf_macvlan_filter_type,
6740 (void *)&cmd_set_vf_macvlan_mode,
6745 #ifdef RTE_LIBRTE_IXGBE_PMD
6746 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6747 struct cmd_set_vf_traffic {
6748 cmdline_fixed_string_t set;
6749 cmdline_fixed_string_t port;
6751 cmdline_fixed_string_t vf;
6753 cmdline_fixed_string_t what;
6754 cmdline_fixed_string_t mode;
6758 cmd_set_vf_traffic_parsed(void *parsed_result,
6759 __attribute__((unused)) struct cmdline *cl,
6760 __attribute__((unused)) void *data)
6762 struct cmd_set_vf_traffic *res = parsed_result;
6763 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6764 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6766 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6769 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6770 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6772 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6773 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6775 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6776 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6778 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6779 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6781 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6782 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6784 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6785 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6787 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6788 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6791 cmdline_parse_inst_t cmd_set_vf_traffic = {
6792 .f = cmd_set_vf_traffic_parsed,
6794 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6796 (void *)&cmd_setvf_traffic_set,
6797 (void *)&cmd_setvf_traffic_port,
6798 (void *)&cmd_setvf_traffic_portid,
6799 (void *)&cmd_setvf_traffic_vf,
6800 (void *)&cmd_setvf_traffic_vfid,
6801 (void *)&cmd_setvf_traffic_what,
6802 (void *)&cmd_setvf_traffic_mode,
6806 #endif /* RTE_LIBRTE_IXGBE_PMD */
6808 /* *** CONFIGURE VF RECEIVE MODE *** */
6809 struct cmd_set_vf_rxmode {
6810 cmdline_fixed_string_t set;
6811 cmdline_fixed_string_t port;
6813 cmdline_fixed_string_t vf;
6815 cmdline_fixed_string_t what;
6816 cmdline_fixed_string_t mode;
6817 cmdline_fixed_string_t on;
6821 cmd_set_vf_rxmode_parsed(void *parsed_result,
6822 __attribute__((unused)) struct cmdline *cl,
6823 __attribute__((unused)) void *data)
6826 uint16_t rx_mode = 0;
6827 struct cmd_set_vf_rxmode *res = parsed_result;
6829 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6830 if (!strcmp(res->what,"rxmode")) {
6831 if (!strcmp(res->mode, "AUPE"))
6832 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6833 else if (!strcmp(res->mode, "ROPE"))
6834 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6835 else if (!strcmp(res->mode, "BAM"))
6836 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6837 else if (!strncmp(res->mode, "MPE",3))
6838 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6841 #ifdef RTE_LIBRTE_IXGBE_PMD
6842 if (ret == -ENOTSUP)
6843 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
6844 rx_mode, (uint8_t)is_on);
6846 #ifdef RTE_LIBRTE_BNXT_PMD
6847 if (ret == -ENOTSUP)
6848 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
6849 rx_mode, (uint8_t)is_on);
6852 printf("bad VF receive mode parameter, return code = %d \n",
6856 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6857 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6859 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6860 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6862 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6863 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6865 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6866 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6868 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6869 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6871 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6872 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6874 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6875 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6876 mode, "AUPE#ROPE#BAM#MPE");
6877 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6878 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6881 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6882 .f = cmd_set_vf_rxmode_parsed,
6884 .help_str = "set port <port_id> vf <vf_id> rxmode "
6885 "AUPE|ROPE|BAM|MPE on|off",
6887 (void *)&cmd_set_vf_rxmode_set,
6888 (void *)&cmd_set_vf_rxmode_port,
6889 (void *)&cmd_set_vf_rxmode_portid,
6890 (void *)&cmd_set_vf_rxmode_vf,
6891 (void *)&cmd_set_vf_rxmode_vfid,
6892 (void *)&cmd_set_vf_rxmode_what,
6893 (void *)&cmd_set_vf_rxmode_mode,
6894 (void *)&cmd_set_vf_rxmode_on,
6899 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6900 struct cmd_vf_mac_addr_result {
6901 cmdline_fixed_string_t mac_addr_cmd;
6902 cmdline_fixed_string_t what;
6903 cmdline_fixed_string_t port;
6905 cmdline_fixed_string_t vf;
6907 struct ether_addr address;
6910 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6911 __attribute__((unused)) struct cmdline *cl,
6912 __attribute__((unused)) void *data)
6914 struct cmd_vf_mac_addr_result *res = parsed_result;
6917 if (strcmp(res->what, "add") == 0)
6918 ret = rte_eth_dev_mac_addr_add(res->port_num,
6919 &res->address, res->vf_num);
6921 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6925 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6926 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6927 mac_addr_cmd,"mac_addr");
6928 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6929 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6931 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6932 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6934 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6935 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6937 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6938 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6940 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6941 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6943 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6944 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6947 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6948 .f = cmd_vf_mac_addr_parsed,
6950 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6951 "Add MAC address filtering for a VF on port_id",
6953 (void *)&cmd_vf_mac_addr_cmd,
6954 (void *)&cmd_vf_mac_addr_what,
6955 (void *)&cmd_vf_mac_addr_port,
6956 (void *)&cmd_vf_mac_addr_portnum,
6957 (void *)&cmd_vf_mac_addr_vf,
6958 (void *)&cmd_vf_mac_addr_vfnum,
6959 (void *)&cmd_vf_mac_addr_addr,
6964 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6965 struct cmd_vf_rx_vlan_filter {
6966 cmdline_fixed_string_t rx_vlan;
6967 cmdline_fixed_string_t what;
6969 cmdline_fixed_string_t port;
6971 cmdline_fixed_string_t vf;
6976 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6977 __attribute__((unused)) struct cmdline *cl,
6978 __attribute__((unused)) void *data)
6980 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6983 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6985 #ifdef RTE_LIBRTE_IXGBE_PMD
6986 if (ret == -ENOTSUP)
6987 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6988 res->vlan_id, res->vf_mask, is_add);
6990 #ifdef RTE_LIBRTE_I40E_PMD
6991 if (ret == -ENOTSUP)
6992 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6993 res->vlan_id, res->vf_mask, is_add);
6995 #ifdef RTE_LIBRTE_BNXT_PMD
6996 if (ret == -ENOTSUP)
6997 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
6998 res->vlan_id, res->vf_mask, is_add);
7005 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7006 res->vlan_id, res->vf_mask);
7009 printf("invalid port_id %d\n", res->port_id);
7012 printf("function not implemented or supported\n");
7015 printf("programming error: (%s)\n", strerror(-ret));
7019 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7020 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7021 rx_vlan, "rx_vlan");
7022 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7023 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7025 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7026 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7028 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7029 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7031 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7032 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7034 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7035 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7037 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7038 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7041 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7042 .f = cmd_vf_rx_vlan_filter_parsed,
7044 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7045 "(vf_mask = hexadecimal VF mask)",
7047 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7048 (void *)&cmd_vf_rx_vlan_filter_what,
7049 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7050 (void *)&cmd_vf_rx_vlan_filter_port,
7051 (void *)&cmd_vf_rx_vlan_filter_portid,
7052 (void *)&cmd_vf_rx_vlan_filter_vf,
7053 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7058 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7059 struct cmd_queue_rate_limit_result {
7060 cmdline_fixed_string_t set;
7061 cmdline_fixed_string_t port;
7063 cmdline_fixed_string_t queue;
7065 cmdline_fixed_string_t rate;
7069 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7070 __attribute__((unused)) struct cmdline *cl,
7071 __attribute__((unused)) void *data)
7073 struct cmd_queue_rate_limit_result *res = parsed_result;
7076 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7077 && (strcmp(res->queue, "queue") == 0)
7078 && (strcmp(res->rate, "rate") == 0))
7079 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7082 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7086 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7087 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7089 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7090 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7092 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7093 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7095 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7096 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7098 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7099 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7101 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7102 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7104 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7105 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7108 cmdline_parse_inst_t cmd_queue_rate_limit = {
7109 .f = cmd_queue_rate_limit_parsed,
7111 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7112 "Set rate limit for a queue on port_id",
7114 (void *)&cmd_queue_rate_limit_set,
7115 (void *)&cmd_queue_rate_limit_port,
7116 (void *)&cmd_queue_rate_limit_portnum,
7117 (void *)&cmd_queue_rate_limit_queue,
7118 (void *)&cmd_queue_rate_limit_queuenum,
7119 (void *)&cmd_queue_rate_limit_rate,
7120 (void *)&cmd_queue_rate_limit_ratenum,
7125 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7126 struct cmd_vf_rate_limit_result {
7127 cmdline_fixed_string_t set;
7128 cmdline_fixed_string_t port;
7130 cmdline_fixed_string_t vf;
7132 cmdline_fixed_string_t rate;
7134 cmdline_fixed_string_t q_msk;
7138 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7139 __attribute__((unused)) struct cmdline *cl,
7140 __attribute__((unused)) void *data)
7142 struct cmd_vf_rate_limit_result *res = parsed_result;
7145 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7146 && (strcmp(res->vf, "vf") == 0)
7147 && (strcmp(res->rate, "rate") == 0)
7148 && (strcmp(res->q_msk, "queue_mask") == 0))
7149 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7150 res->rate_num, res->q_msk_val);
7152 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7156 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7157 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7159 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7160 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7162 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7163 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7165 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7166 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7168 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7169 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7171 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7172 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7174 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7175 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7177 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7178 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7179 q_msk, "queue_mask");
7180 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7181 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7184 cmdline_parse_inst_t cmd_vf_rate_limit = {
7185 .f = cmd_vf_rate_limit_parsed,
7187 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7188 "queue_mask <queue_mask_value>: "
7189 "Set rate limit for queues of VF on port_id",
7191 (void *)&cmd_vf_rate_limit_set,
7192 (void *)&cmd_vf_rate_limit_port,
7193 (void *)&cmd_vf_rate_limit_portnum,
7194 (void *)&cmd_vf_rate_limit_vf,
7195 (void *)&cmd_vf_rate_limit_vfnum,
7196 (void *)&cmd_vf_rate_limit_rate,
7197 (void *)&cmd_vf_rate_limit_ratenum,
7198 (void *)&cmd_vf_rate_limit_q_msk,
7199 (void *)&cmd_vf_rate_limit_q_msk_val,
7204 /* *** ADD TUNNEL FILTER OF A PORT *** */
7205 struct cmd_tunnel_filter_result {
7206 cmdline_fixed_string_t cmd;
7207 cmdline_fixed_string_t what;
7209 struct ether_addr outer_mac;
7210 struct ether_addr inner_mac;
7211 cmdline_ipaddr_t ip_value;
7212 uint16_t inner_vlan;
7213 cmdline_fixed_string_t tunnel_type;
7214 cmdline_fixed_string_t filter_type;
7220 cmd_tunnel_filter_parsed(void *parsed_result,
7221 __attribute__((unused)) struct cmdline *cl,
7222 __attribute__((unused)) void *data)
7224 struct cmd_tunnel_filter_result *res = parsed_result;
7225 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7228 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7230 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7231 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7232 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7234 if (res->ip_value.family == AF_INET) {
7235 tunnel_filter_conf.ip_addr.ipv4_addr =
7236 res->ip_value.addr.ipv4.s_addr;
7237 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7239 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7240 &(res->ip_value.addr.ipv6),
7241 sizeof(struct in6_addr));
7242 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7245 if (!strcmp(res->filter_type, "imac-ivlan"))
7246 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7247 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7248 tunnel_filter_conf.filter_type =
7249 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7250 else if (!strcmp(res->filter_type, "imac-tenid"))
7251 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7252 else if (!strcmp(res->filter_type, "imac"))
7253 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7254 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7255 tunnel_filter_conf.filter_type =
7256 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7257 else if (!strcmp(res->filter_type, "oip"))
7258 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7259 else if (!strcmp(res->filter_type, "iip"))
7260 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7262 printf("The filter type is not supported");
7266 if (!strcmp(res->tunnel_type, "vxlan"))
7267 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7268 else if (!strcmp(res->tunnel_type, "nvgre"))
7269 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7270 else if (!strcmp(res->tunnel_type, "ipingre"))
7271 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7273 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7277 tunnel_filter_conf.tenant_id = res->tenant_id;
7278 tunnel_filter_conf.queue_id = res->queue_num;
7279 if (!strcmp(res->what, "add"))
7280 ret = rte_eth_dev_filter_ctrl(res->port_id,
7281 RTE_ETH_FILTER_TUNNEL,
7283 &tunnel_filter_conf);
7285 ret = rte_eth_dev_filter_ctrl(res->port_id,
7286 RTE_ETH_FILTER_TUNNEL,
7287 RTE_ETH_FILTER_DELETE,
7288 &tunnel_filter_conf);
7290 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7294 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7295 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7296 cmd, "tunnel_filter");
7297 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7298 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7300 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7301 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7303 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7304 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7306 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7307 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7309 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7310 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7311 inner_vlan, UINT16);
7312 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7313 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7315 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7316 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7317 tunnel_type, "vxlan#nvgre#ipingre");
7319 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7320 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7321 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7322 "imac#omac-imac-tenid");
7323 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7324 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7326 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7327 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7330 cmdline_parse_inst_t cmd_tunnel_filter = {
7331 .f = cmd_tunnel_filter_parsed,
7333 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7334 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7335 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7336 "<queue_id>: Add/Rm tunnel filter of a port",
7338 (void *)&cmd_tunnel_filter_cmd,
7339 (void *)&cmd_tunnel_filter_what,
7340 (void *)&cmd_tunnel_filter_port_id,
7341 (void *)&cmd_tunnel_filter_outer_mac,
7342 (void *)&cmd_tunnel_filter_inner_mac,
7343 (void *)&cmd_tunnel_filter_ip_value,
7344 (void *)&cmd_tunnel_filter_innner_vlan,
7345 (void *)&cmd_tunnel_filter_tunnel_type,
7346 (void *)&cmd_tunnel_filter_filter_type,
7347 (void *)&cmd_tunnel_filter_tenant_id,
7348 (void *)&cmd_tunnel_filter_queue_num,
7353 /* *** CONFIGURE TUNNEL UDP PORT *** */
7354 struct cmd_tunnel_udp_config {
7355 cmdline_fixed_string_t cmd;
7356 cmdline_fixed_string_t what;
7362 cmd_tunnel_udp_config_parsed(void *parsed_result,
7363 __attribute__((unused)) struct cmdline *cl,
7364 __attribute__((unused)) void *data)
7366 struct cmd_tunnel_udp_config *res = parsed_result;
7367 struct rte_eth_udp_tunnel tunnel_udp;
7370 tunnel_udp.udp_port = res->udp_port;
7372 if (!strcmp(res->cmd, "rx_vxlan_port"))
7373 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7375 if (!strcmp(res->what, "add"))
7376 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7379 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7383 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7386 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7387 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7388 cmd, "rx_vxlan_port");
7389 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7390 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7392 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7393 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7395 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7396 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7399 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7400 .f = cmd_tunnel_udp_config_parsed,
7402 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7403 "Add/Remove a tunneling UDP port filter",
7405 (void *)&cmd_tunnel_udp_config_cmd,
7406 (void *)&cmd_tunnel_udp_config_what,
7407 (void *)&cmd_tunnel_udp_config_udp_port,
7408 (void *)&cmd_tunnel_udp_config_port_id,
7413 /* *** GLOBAL CONFIG *** */
7414 struct cmd_global_config_result {
7415 cmdline_fixed_string_t cmd;
7417 cmdline_fixed_string_t cfg_type;
7422 cmd_global_config_parsed(void *parsed_result,
7423 __attribute__((unused)) struct cmdline *cl,
7424 __attribute__((unused)) void *data)
7426 struct cmd_global_config_result *res = parsed_result;
7427 struct rte_eth_global_cfg conf;
7430 memset(&conf, 0, sizeof(conf));
7431 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7432 conf.cfg.gre_key_len = res->len;
7433 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7434 RTE_ETH_FILTER_SET, &conf);
7436 printf("Global config error\n");
7439 cmdline_parse_token_string_t cmd_global_config_cmd =
7440 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7442 cmdline_parse_token_num_t cmd_global_config_port_id =
7443 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7444 cmdline_parse_token_string_t cmd_global_config_type =
7445 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7446 cfg_type, "gre-key-len");
7447 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7448 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7451 cmdline_parse_inst_t cmd_global_config = {
7452 .f = cmd_global_config_parsed,
7453 .data = (void *)NULL,
7454 .help_str = "global_config <port_id> gre-key-len <key_len>",
7456 (void *)&cmd_global_config_cmd,
7457 (void *)&cmd_global_config_port_id,
7458 (void *)&cmd_global_config_type,
7459 (void *)&cmd_global_config_gre_key_len,
7464 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7465 struct cmd_set_mirror_mask_result {
7466 cmdline_fixed_string_t set;
7467 cmdline_fixed_string_t port;
7469 cmdline_fixed_string_t mirror;
7471 cmdline_fixed_string_t what;
7472 cmdline_fixed_string_t value;
7473 cmdline_fixed_string_t dstpool;
7475 cmdline_fixed_string_t on;
7478 cmdline_parse_token_string_t cmd_mirror_mask_set =
7479 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7481 cmdline_parse_token_string_t cmd_mirror_mask_port =
7482 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7484 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7485 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7487 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7488 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7489 mirror, "mirror-rule");
7490 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7491 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7493 cmdline_parse_token_string_t cmd_mirror_mask_what =
7494 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7495 what, "pool-mirror-up#pool-mirror-down"
7497 cmdline_parse_token_string_t cmd_mirror_mask_value =
7498 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7500 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7501 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7502 dstpool, "dst-pool");
7503 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7504 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7506 cmdline_parse_token_string_t cmd_mirror_mask_on =
7507 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7511 cmd_set_mirror_mask_parsed(void *parsed_result,
7512 __attribute__((unused)) struct cmdline *cl,
7513 __attribute__((unused)) void *data)
7516 struct cmd_set_mirror_mask_result *res = parsed_result;
7517 struct rte_eth_mirror_conf mr_conf;
7519 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7521 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7523 mr_conf.dst_pool = res->dstpool_id;
7525 if (!strcmp(res->what, "pool-mirror-up")) {
7526 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7527 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7528 } else if (!strcmp(res->what, "pool-mirror-down")) {
7529 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7530 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7531 } else if (!strcmp(res->what, "vlan-mirror")) {
7532 mr_conf.rule_type = ETH_MIRROR_VLAN;
7533 nb_item = parse_item_list(res->value, "vlan",
7534 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7538 for (i = 0; i < nb_item; i++) {
7539 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7540 printf("Invalid vlan_id: must be < 4096\n");
7544 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7545 mr_conf.vlan.vlan_mask |= 1ULL << i;
7549 if (!strcmp(res->on, "on"))
7550 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7553 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7556 printf("mirror rule add error: (%s)\n", strerror(-ret));
7559 cmdline_parse_inst_t cmd_set_mirror_mask = {
7560 .f = cmd_set_mirror_mask_parsed,
7562 .help_str = "set port <port_id> mirror-rule <rule_id> "
7563 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7564 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7566 (void *)&cmd_mirror_mask_set,
7567 (void *)&cmd_mirror_mask_port,
7568 (void *)&cmd_mirror_mask_portid,
7569 (void *)&cmd_mirror_mask_mirror,
7570 (void *)&cmd_mirror_mask_ruleid,
7571 (void *)&cmd_mirror_mask_what,
7572 (void *)&cmd_mirror_mask_value,
7573 (void *)&cmd_mirror_mask_dstpool,
7574 (void *)&cmd_mirror_mask_poolid,
7575 (void *)&cmd_mirror_mask_on,
7580 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7581 struct cmd_set_mirror_link_result {
7582 cmdline_fixed_string_t set;
7583 cmdline_fixed_string_t port;
7585 cmdline_fixed_string_t mirror;
7587 cmdline_fixed_string_t what;
7588 cmdline_fixed_string_t dstpool;
7590 cmdline_fixed_string_t on;
7593 cmdline_parse_token_string_t cmd_mirror_link_set =
7594 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7596 cmdline_parse_token_string_t cmd_mirror_link_port =
7597 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7599 cmdline_parse_token_num_t cmd_mirror_link_portid =
7600 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7602 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7603 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7604 mirror, "mirror-rule");
7605 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7606 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7608 cmdline_parse_token_string_t cmd_mirror_link_what =
7609 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7610 what, "uplink-mirror#downlink-mirror");
7611 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7612 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7613 dstpool, "dst-pool");
7614 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7615 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7617 cmdline_parse_token_string_t cmd_mirror_link_on =
7618 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7622 cmd_set_mirror_link_parsed(void *parsed_result,
7623 __attribute__((unused)) struct cmdline *cl,
7624 __attribute__((unused)) void *data)
7627 struct cmd_set_mirror_link_result *res = parsed_result;
7628 struct rte_eth_mirror_conf mr_conf;
7630 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7631 if (!strcmp(res->what, "uplink-mirror"))
7632 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7634 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7636 mr_conf.dst_pool = res->dstpool_id;
7638 if (!strcmp(res->on, "on"))
7639 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7642 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7645 /* check the return value and print it if is < 0 */
7647 printf("mirror rule add error: (%s)\n", strerror(-ret));
7651 cmdline_parse_inst_t cmd_set_mirror_link = {
7652 .f = cmd_set_mirror_link_parsed,
7654 .help_str = "set port <port_id> mirror-rule <rule_id> "
7655 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7657 (void *)&cmd_mirror_link_set,
7658 (void *)&cmd_mirror_link_port,
7659 (void *)&cmd_mirror_link_portid,
7660 (void *)&cmd_mirror_link_mirror,
7661 (void *)&cmd_mirror_link_ruleid,
7662 (void *)&cmd_mirror_link_what,
7663 (void *)&cmd_mirror_link_dstpool,
7664 (void *)&cmd_mirror_link_poolid,
7665 (void *)&cmd_mirror_link_on,
7670 /* *** RESET VM MIRROR RULE *** */
7671 struct cmd_rm_mirror_rule_result {
7672 cmdline_fixed_string_t reset;
7673 cmdline_fixed_string_t port;
7675 cmdline_fixed_string_t mirror;
7679 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7680 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7682 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7683 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7685 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7686 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7688 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7689 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7690 mirror, "mirror-rule");
7691 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7692 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7696 cmd_reset_mirror_rule_parsed(void *parsed_result,
7697 __attribute__((unused)) struct cmdline *cl,
7698 __attribute__((unused)) void *data)
7701 struct cmd_set_mirror_link_result *res = parsed_result;
7703 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7705 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7708 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7709 .f = cmd_reset_mirror_rule_parsed,
7711 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7713 (void *)&cmd_rm_mirror_rule_reset,
7714 (void *)&cmd_rm_mirror_rule_port,
7715 (void *)&cmd_rm_mirror_rule_portid,
7716 (void *)&cmd_rm_mirror_rule_mirror,
7717 (void *)&cmd_rm_mirror_rule_ruleid,
7722 /* ******************************************************************************** */
7724 struct cmd_dump_result {
7725 cmdline_fixed_string_t dump;
7729 dump_struct_sizes(void)
7731 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7732 DUMP_SIZE(struct rte_mbuf);
7733 DUMP_SIZE(struct rte_mempool);
7734 DUMP_SIZE(struct rte_ring);
7738 static void cmd_dump_parsed(void *parsed_result,
7739 __attribute__((unused)) struct cmdline *cl,
7740 __attribute__((unused)) void *data)
7742 struct cmd_dump_result *res = parsed_result;
7744 if (!strcmp(res->dump, "dump_physmem"))
7745 rte_dump_physmem_layout(stdout);
7746 else if (!strcmp(res->dump, "dump_memzone"))
7747 rte_memzone_dump(stdout);
7748 else if (!strcmp(res->dump, "dump_struct_sizes"))
7749 dump_struct_sizes();
7750 else if (!strcmp(res->dump, "dump_ring"))
7751 rte_ring_list_dump(stdout);
7752 else if (!strcmp(res->dump, "dump_mempool"))
7753 rte_mempool_list_dump(stdout);
7754 else if (!strcmp(res->dump, "dump_devargs"))
7755 rte_eal_devargs_dump(stdout);
7756 else if (!strcmp(res->dump, "dump_log_types"))
7757 rte_log_dump(stdout);
7760 cmdline_parse_token_string_t cmd_dump_dump =
7761 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7764 "dump_struct_sizes#"
7770 cmdline_parse_inst_t cmd_dump = {
7771 .f = cmd_dump_parsed, /* function to call */
7772 .data = NULL, /* 2nd arg of func */
7773 .help_str = "Dump status",
7774 .tokens = { /* token list, NULL terminated */
7775 (void *)&cmd_dump_dump,
7780 /* ******************************************************************************** */
7782 struct cmd_dump_one_result {
7783 cmdline_fixed_string_t dump;
7784 cmdline_fixed_string_t name;
7787 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7788 __attribute__((unused)) void *data)
7790 struct cmd_dump_one_result *res = parsed_result;
7792 if (!strcmp(res->dump, "dump_ring")) {
7794 r = rte_ring_lookup(res->name);
7796 cmdline_printf(cl, "Cannot find ring\n");
7799 rte_ring_dump(stdout, r);
7800 } else if (!strcmp(res->dump, "dump_mempool")) {
7801 struct rte_mempool *mp;
7802 mp = rte_mempool_lookup(res->name);
7804 cmdline_printf(cl, "Cannot find mempool\n");
7807 rte_mempool_dump(stdout, mp);
7811 cmdline_parse_token_string_t cmd_dump_one_dump =
7812 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7813 "dump_ring#dump_mempool");
7815 cmdline_parse_token_string_t cmd_dump_one_name =
7816 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7818 cmdline_parse_inst_t cmd_dump_one = {
7819 .f = cmd_dump_one_parsed, /* function to call */
7820 .data = NULL, /* 2nd arg of func */
7821 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7822 .tokens = { /* token list, NULL terminated */
7823 (void *)&cmd_dump_one_dump,
7824 (void *)&cmd_dump_one_name,
7829 /* *** Add/Del syn filter *** */
7830 struct cmd_syn_filter_result {
7831 cmdline_fixed_string_t filter;
7833 cmdline_fixed_string_t ops;
7834 cmdline_fixed_string_t priority;
7835 cmdline_fixed_string_t high;
7836 cmdline_fixed_string_t queue;
7841 cmd_syn_filter_parsed(void *parsed_result,
7842 __attribute__((unused)) struct cmdline *cl,
7843 __attribute__((unused)) void *data)
7845 struct cmd_syn_filter_result *res = parsed_result;
7846 struct rte_eth_syn_filter syn_filter;
7849 ret = rte_eth_dev_filter_supported(res->port_id,
7850 RTE_ETH_FILTER_SYN);
7852 printf("syn filter is not supported on port %u.\n",
7857 memset(&syn_filter, 0, sizeof(syn_filter));
7859 if (!strcmp(res->ops, "add")) {
7860 if (!strcmp(res->high, "high"))
7861 syn_filter.hig_pri = 1;
7863 syn_filter.hig_pri = 0;
7865 syn_filter.queue = res->queue_id;
7866 ret = rte_eth_dev_filter_ctrl(res->port_id,
7871 ret = rte_eth_dev_filter_ctrl(res->port_id,
7873 RTE_ETH_FILTER_DELETE,
7877 printf("syn filter programming error: (%s)\n",
7881 cmdline_parse_token_string_t cmd_syn_filter_filter =
7882 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7883 filter, "syn_filter");
7884 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7885 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7887 cmdline_parse_token_string_t cmd_syn_filter_ops =
7888 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7890 cmdline_parse_token_string_t cmd_syn_filter_priority =
7891 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7892 priority, "priority");
7893 cmdline_parse_token_string_t cmd_syn_filter_high =
7894 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7896 cmdline_parse_token_string_t cmd_syn_filter_queue =
7897 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7899 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7900 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7903 cmdline_parse_inst_t cmd_syn_filter = {
7904 .f = cmd_syn_filter_parsed,
7906 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7907 "<queue_id>: Add/Delete syn filter",
7909 (void *)&cmd_syn_filter_filter,
7910 (void *)&cmd_syn_filter_port_id,
7911 (void *)&cmd_syn_filter_ops,
7912 (void *)&cmd_syn_filter_priority,
7913 (void *)&cmd_syn_filter_high,
7914 (void *)&cmd_syn_filter_queue,
7915 (void *)&cmd_syn_filter_queue_id,
7920 /* *** ADD/REMOVE A 2tuple FILTER *** */
7921 struct cmd_2tuple_filter_result {
7922 cmdline_fixed_string_t filter;
7924 cmdline_fixed_string_t ops;
7925 cmdline_fixed_string_t dst_port;
7926 uint16_t dst_port_value;
7927 cmdline_fixed_string_t protocol;
7928 uint8_t protocol_value;
7929 cmdline_fixed_string_t mask;
7931 cmdline_fixed_string_t tcp_flags;
7932 uint8_t tcp_flags_value;
7933 cmdline_fixed_string_t priority;
7934 uint8_t priority_value;
7935 cmdline_fixed_string_t queue;
7940 cmd_2tuple_filter_parsed(void *parsed_result,
7941 __attribute__((unused)) struct cmdline *cl,
7942 __attribute__((unused)) void *data)
7944 struct rte_eth_ntuple_filter filter;
7945 struct cmd_2tuple_filter_result *res = parsed_result;
7948 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7950 printf("ntuple filter is not supported on port %u.\n",
7955 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7957 filter.flags = RTE_2TUPLE_FLAGS;
7958 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7959 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7960 filter.proto = res->protocol_value;
7961 filter.priority = res->priority_value;
7962 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7963 printf("nonzero tcp_flags is only meaningful"
7964 " when protocol is TCP.\n");
7967 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7968 printf("invalid TCP flags.\n");
7972 if (res->tcp_flags_value != 0) {
7973 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7974 filter.tcp_flags = res->tcp_flags_value;
7977 /* need convert to big endian. */
7978 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7979 filter.queue = res->queue_id;
7981 if (!strcmp(res->ops, "add"))
7982 ret = rte_eth_dev_filter_ctrl(res->port_id,
7983 RTE_ETH_FILTER_NTUPLE,
7987 ret = rte_eth_dev_filter_ctrl(res->port_id,
7988 RTE_ETH_FILTER_NTUPLE,
7989 RTE_ETH_FILTER_DELETE,
7992 printf("2tuple filter programming error: (%s)\n",
7997 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7998 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7999 filter, "2tuple_filter");
8000 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8001 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8003 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8004 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8006 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8007 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8008 dst_port, "dst_port");
8009 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8010 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8011 dst_port_value, UINT16);
8012 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8013 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8014 protocol, "protocol");
8015 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8016 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8017 protocol_value, UINT8);
8018 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8019 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8021 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8022 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8024 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8025 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8026 tcp_flags, "tcp_flags");
8027 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8028 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8029 tcp_flags_value, UINT8);
8030 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8031 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8032 priority, "priority");
8033 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8034 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8035 priority_value, UINT8);
8036 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8037 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8039 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8040 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8043 cmdline_parse_inst_t cmd_2tuple_filter = {
8044 .f = cmd_2tuple_filter_parsed,
8046 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8047 "<value> mask <value> tcp_flags <value> priority <value> queue "
8048 "<queue_id>: Add a 2tuple filter",
8050 (void *)&cmd_2tuple_filter_filter,
8051 (void *)&cmd_2tuple_filter_port_id,
8052 (void *)&cmd_2tuple_filter_ops,
8053 (void *)&cmd_2tuple_filter_dst_port,
8054 (void *)&cmd_2tuple_filter_dst_port_value,
8055 (void *)&cmd_2tuple_filter_protocol,
8056 (void *)&cmd_2tuple_filter_protocol_value,
8057 (void *)&cmd_2tuple_filter_mask,
8058 (void *)&cmd_2tuple_filter_mask_value,
8059 (void *)&cmd_2tuple_filter_tcp_flags,
8060 (void *)&cmd_2tuple_filter_tcp_flags_value,
8061 (void *)&cmd_2tuple_filter_priority,
8062 (void *)&cmd_2tuple_filter_priority_value,
8063 (void *)&cmd_2tuple_filter_queue,
8064 (void *)&cmd_2tuple_filter_queue_id,
8069 /* *** ADD/REMOVE A 5tuple FILTER *** */
8070 struct cmd_5tuple_filter_result {
8071 cmdline_fixed_string_t filter;
8073 cmdline_fixed_string_t ops;
8074 cmdline_fixed_string_t dst_ip;
8075 cmdline_ipaddr_t dst_ip_value;
8076 cmdline_fixed_string_t src_ip;
8077 cmdline_ipaddr_t src_ip_value;
8078 cmdline_fixed_string_t dst_port;
8079 uint16_t dst_port_value;
8080 cmdline_fixed_string_t src_port;
8081 uint16_t src_port_value;
8082 cmdline_fixed_string_t protocol;
8083 uint8_t protocol_value;
8084 cmdline_fixed_string_t mask;
8086 cmdline_fixed_string_t tcp_flags;
8087 uint8_t tcp_flags_value;
8088 cmdline_fixed_string_t priority;
8089 uint8_t priority_value;
8090 cmdline_fixed_string_t queue;
8095 cmd_5tuple_filter_parsed(void *parsed_result,
8096 __attribute__((unused)) struct cmdline *cl,
8097 __attribute__((unused)) void *data)
8099 struct rte_eth_ntuple_filter filter;
8100 struct cmd_5tuple_filter_result *res = parsed_result;
8103 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8105 printf("ntuple filter is not supported on port %u.\n",
8110 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8112 filter.flags = RTE_5TUPLE_FLAGS;
8113 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8114 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8115 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8116 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8117 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8118 filter.proto = res->protocol_value;
8119 filter.priority = res->priority_value;
8120 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8121 printf("nonzero tcp_flags is only meaningful"
8122 " when protocol is TCP.\n");
8125 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8126 printf("invalid TCP flags.\n");
8130 if (res->tcp_flags_value != 0) {
8131 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8132 filter.tcp_flags = res->tcp_flags_value;
8135 if (res->dst_ip_value.family == AF_INET)
8136 /* no need to convert, already big endian. */
8137 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8139 if (filter.dst_ip_mask == 0) {
8140 printf("can not support ipv6 involved compare.\n");
8146 if (res->src_ip_value.family == AF_INET)
8147 /* no need to convert, already big endian. */
8148 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8150 if (filter.src_ip_mask == 0) {
8151 printf("can not support ipv6 involved compare.\n");
8156 /* need convert to big endian. */
8157 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8158 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8159 filter.queue = res->queue_id;
8161 if (!strcmp(res->ops, "add"))
8162 ret = rte_eth_dev_filter_ctrl(res->port_id,
8163 RTE_ETH_FILTER_NTUPLE,
8167 ret = rte_eth_dev_filter_ctrl(res->port_id,
8168 RTE_ETH_FILTER_NTUPLE,
8169 RTE_ETH_FILTER_DELETE,
8172 printf("5tuple filter programming error: (%s)\n",
8176 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8177 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8178 filter, "5tuple_filter");
8179 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8180 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8182 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8183 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8185 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8186 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8188 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8189 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8191 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8192 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8194 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8195 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8197 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8198 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8199 dst_port, "dst_port");
8200 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8201 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8202 dst_port_value, UINT16);
8203 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8204 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8205 src_port, "src_port");
8206 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8207 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8208 src_port_value, UINT16);
8209 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8210 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8211 protocol, "protocol");
8212 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8213 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8214 protocol_value, UINT8);
8215 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8216 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8218 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8219 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8221 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8222 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8223 tcp_flags, "tcp_flags");
8224 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8225 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8226 tcp_flags_value, UINT8);
8227 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8228 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8229 priority, "priority");
8230 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8231 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8232 priority_value, UINT8);
8233 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8234 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8236 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8237 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8240 cmdline_parse_inst_t cmd_5tuple_filter = {
8241 .f = cmd_5tuple_filter_parsed,
8243 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8244 "src_ip <value> dst_port <value> src_port <value> "
8245 "protocol <value> mask <value> tcp_flags <value> "
8246 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8248 (void *)&cmd_5tuple_filter_filter,
8249 (void *)&cmd_5tuple_filter_port_id,
8250 (void *)&cmd_5tuple_filter_ops,
8251 (void *)&cmd_5tuple_filter_dst_ip,
8252 (void *)&cmd_5tuple_filter_dst_ip_value,
8253 (void *)&cmd_5tuple_filter_src_ip,
8254 (void *)&cmd_5tuple_filter_src_ip_value,
8255 (void *)&cmd_5tuple_filter_dst_port,
8256 (void *)&cmd_5tuple_filter_dst_port_value,
8257 (void *)&cmd_5tuple_filter_src_port,
8258 (void *)&cmd_5tuple_filter_src_port_value,
8259 (void *)&cmd_5tuple_filter_protocol,
8260 (void *)&cmd_5tuple_filter_protocol_value,
8261 (void *)&cmd_5tuple_filter_mask,
8262 (void *)&cmd_5tuple_filter_mask_value,
8263 (void *)&cmd_5tuple_filter_tcp_flags,
8264 (void *)&cmd_5tuple_filter_tcp_flags_value,
8265 (void *)&cmd_5tuple_filter_priority,
8266 (void *)&cmd_5tuple_filter_priority_value,
8267 (void *)&cmd_5tuple_filter_queue,
8268 (void *)&cmd_5tuple_filter_queue_id,
8273 /* *** ADD/REMOVE A flex FILTER *** */
8274 struct cmd_flex_filter_result {
8275 cmdline_fixed_string_t filter;
8276 cmdline_fixed_string_t ops;
8278 cmdline_fixed_string_t len;
8280 cmdline_fixed_string_t bytes;
8281 cmdline_fixed_string_t bytes_value;
8282 cmdline_fixed_string_t mask;
8283 cmdline_fixed_string_t mask_value;
8284 cmdline_fixed_string_t priority;
8285 uint8_t priority_value;
8286 cmdline_fixed_string_t queue;
8290 static int xdigit2val(unsigned char c)
8295 else if (isupper(c))
8303 cmd_flex_filter_parsed(void *parsed_result,
8304 __attribute__((unused)) struct cmdline *cl,
8305 __attribute__((unused)) void *data)
8308 struct rte_eth_flex_filter filter;
8309 struct cmd_flex_filter_result *res = parsed_result;
8310 char *bytes_ptr, *mask_ptr;
8311 uint16_t len, i, j = 0;
8316 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8317 printf("the len exceed the max length 128\n");
8320 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8321 filter.len = res->len_value;
8322 filter.priority = res->priority_value;
8323 filter.queue = res->queue_id;
8324 bytes_ptr = res->bytes_value;
8325 mask_ptr = res->mask_value;
8327 /* translate bytes string to array. */
8328 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8329 (bytes_ptr[1] == 'X')))
8331 len = strnlen(bytes_ptr, res->len_value * 2);
8332 if (len == 0 || (len % 8 != 0)) {
8333 printf("please check len and bytes input\n");
8336 for (i = 0; i < len; i++) {
8338 if (isxdigit(c) == 0) {
8339 /* invalid characters. */
8340 printf("invalid input\n");
8343 val = xdigit2val(c);
8346 filter.bytes[j] = byte;
8347 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8354 /* translate mask string to uint8_t array. */
8355 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8356 (mask_ptr[1] == 'X')))
8358 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8360 printf("invalid input\n");
8365 for (i = 0; i < len; i++) {
8367 if (isxdigit(c) == 0) {
8368 /* invalid characters. */
8369 printf("invalid input\n");
8372 val = xdigit2val(c);
8375 filter.mask[j] = byte;
8376 printf("mask[%d]:%02x ", j, filter.mask[j]);
8384 if (!strcmp(res->ops, "add"))
8385 ret = rte_eth_dev_filter_ctrl(res->port_id,
8386 RTE_ETH_FILTER_FLEXIBLE,
8390 ret = rte_eth_dev_filter_ctrl(res->port_id,
8391 RTE_ETH_FILTER_FLEXIBLE,
8392 RTE_ETH_FILTER_DELETE,
8396 printf("flex filter setting error: (%s)\n", strerror(-ret));
8399 cmdline_parse_token_string_t cmd_flex_filter_filter =
8400 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8401 filter, "flex_filter");
8402 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8403 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8405 cmdline_parse_token_string_t cmd_flex_filter_ops =
8406 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8408 cmdline_parse_token_string_t cmd_flex_filter_len =
8409 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8411 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8412 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8414 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8415 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8417 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8418 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8420 cmdline_parse_token_string_t cmd_flex_filter_mask =
8421 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8423 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8424 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8426 cmdline_parse_token_string_t cmd_flex_filter_priority =
8427 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8428 priority, "priority");
8429 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8430 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8431 priority_value, UINT8);
8432 cmdline_parse_token_string_t cmd_flex_filter_queue =
8433 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8435 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8436 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8438 cmdline_parse_inst_t cmd_flex_filter = {
8439 .f = cmd_flex_filter_parsed,
8441 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8442 "<value> mask <value> priority <value> queue <queue_id>: "
8443 "Add/Del a flex filter",
8445 (void *)&cmd_flex_filter_filter,
8446 (void *)&cmd_flex_filter_port_id,
8447 (void *)&cmd_flex_filter_ops,
8448 (void *)&cmd_flex_filter_len,
8449 (void *)&cmd_flex_filter_len_value,
8450 (void *)&cmd_flex_filter_bytes,
8451 (void *)&cmd_flex_filter_bytes_value,
8452 (void *)&cmd_flex_filter_mask,
8453 (void *)&cmd_flex_filter_mask_value,
8454 (void *)&cmd_flex_filter_priority,
8455 (void *)&cmd_flex_filter_priority_value,
8456 (void *)&cmd_flex_filter_queue,
8457 (void *)&cmd_flex_filter_queue_id,
8462 /* *** Filters Control *** */
8464 /* *** deal with ethertype filter *** */
8465 struct cmd_ethertype_filter_result {
8466 cmdline_fixed_string_t filter;
8468 cmdline_fixed_string_t ops;
8469 cmdline_fixed_string_t mac;
8470 struct ether_addr mac_addr;
8471 cmdline_fixed_string_t ethertype;
8472 uint16_t ethertype_value;
8473 cmdline_fixed_string_t drop;
8474 cmdline_fixed_string_t queue;
8478 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8479 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8480 filter, "ethertype_filter");
8481 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8482 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8484 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8485 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8487 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8488 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8489 mac, "mac_addr#mac_ignr");
8490 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8491 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8493 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8494 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8495 ethertype, "ethertype");
8496 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8497 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8498 ethertype_value, UINT16);
8499 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8500 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8502 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8503 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8505 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8506 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8510 cmd_ethertype_filter_parsed(void *parsed_result,
8511 __attribute__((unused)) struct cmdline *cl,
8512 __attribute__((unused)) void *data)
8514 struct cmd_ethertype_filter_result *res = parsed_result;
8515 struct rte_eth_ethertype_filter filter;
8518 ret = rte_eth_dev_filter_supported(res->port_id,
8519 RTE_ETH_FILTER_ETHERTYPE);
8521 printf("ethertype filter is not supported on port %u.\n",
8526 memset(&filter, 0, sizeof(filter));
8527 if (!strcmp(res->mac, "mac_addr")) {
8528 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8529 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8530 sizeof(struct ether_addr));
8532 if (!strcmp(res->drop, "drop"))
8533 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8534 filter.ether_type = res->ethertype_value;
8535 filter.queue = res->queue_id;
8537 if (!strcmp(res->ops, "add"))
8538 ret = rte_eth_dev_filter_ctrl(res->port_id,
8539 RTE_ETH_FILTER_ETHERTYPE,
8543 ret = rte_eth_dev_filter_ctrl(res->port_id,
8544 RTE_ETH_FILTER_ETHERTYPE,
8545 RTE_ETH_FILTER_DELETE,
8548 printf("ethertype filter programming error: (%s)\n",
8552 cmdline_parse_inst_t cmd_ethertype_filter = {
8553 .f = cmd_ethertype_filter_parsed,
8555 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8556 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8557 "Add or delete an ethertype filter entry",
8559 (void *)&cmd_ethertype_filter_filter,
8560 (void *)&cmd_ethertype_filter_port_id,
8561 (void *)&cmd_ethertype_filter_ops,
8562 (void *)&cmd_ethertype_filter_mac,
8563 (void *)&cmd_ethertype_filter_mac_addr,
8564 (void *)&cmd_ethertype_filter_ethertype,
8565 (void *)&cmd_ethertype_filter_ethertype_value,
8566 (void *)&cmd_ethertype_filter_drop,
8567 (void *)&cmd_ethertype_filter_queue,
8568 (void *)&cmd_ethertype_filter_queue_id,
8573 /* *** deal with flow director filter *** */
8574 struct cmd_flow_director_result {
8575 cmdline_fixed_string_t flow_director_filter;
8577 cmdline_fixed_string_t mode;
8578 cmdline_fixed_string_t mode_value;
8579 cmdline_fixed_string_t ops;
8580 cmdline_fixed_string_t flow;
8581 cmdline_fixed_string_t flow_type;
8582 cmdline_fixed_string_t ether;
8583 uint16_t ether_type;
8584 cmdline_fixed_string_t src;
8585 cmdline_ipaddr_t ip_src;
8587 cmdline_fixed_string_t dst;
8588 cmdline_ipaddr_t ip_dst;
8590 cmdline_fixed_string_t verify_tag;
8591 uint32_t verify_tag_value;
8592 cmdline_ipaddr_t tos;
8594 cmdline_ipaddr_t proto;
8595 uint8_t proto_value;
8596 cmdline_ipaddr_t ttl;
8598 cmdline_fixed_string_t vlan;
8599 uint16_t vlan_value;
8600 cmdline_fixed_string_t flexbytes;
8601 cmdline_fixed_string_t flexbytes_value;
8602 cmdline_fixed_string_t pf_vf;
8603 cmdline_fixed_string_t drop;
8604 cmdline_fixed_string_t queue;
8606 cmdline_fixed_string_t fd_id;
8607 uint32_t fd_id_value;
8608 cmdline_fixed_string_t mac;
8609 struct ether_addr mac_addr;
8610 cmdline_fixed_string_t tunnel;
8611 cmdline_fixed_string_t tunnel_type;
8612 cmdline_fixed_string_t tunnel_id;
8613 uint32_t tunnel_id_value;
8617 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8620 const char *p, *p0 = q_arg;
8622 unsigned long int_fld;
8623 char *str_fld[max_num];
8628 p = strchr(p0, '(');
8632 p0 = strchr(p, ')');
8637 if (size >= sizeof(s))
8640 snprintf(s, sizeof(s), "%.*s", size, p);
8641 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8642 if (ret < 0 || ret > max_num)
8644 for (i = 0; i < ret; i++) {
8646 int_fld = strtoul(str_fld[i], &end, 0);
8647 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8649 flexbytes[i] = (uint8_t)int_fld;
8655 str2flowtype(char *string)
8658 static const struct {
8661 } flowtype_str[] = {
8662 {"raw", RTE_ETH_FLOW_RAW},
8663 {"ipv4", RTE_ETH_FLOW_IPV4},
8664 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8665 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8666 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8667 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8668 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8669 {"ipv6", RTE_ETH_FLOW_IPV6},
8670 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8671 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8672 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8673 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8674 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8675 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8678 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8679 if (!strcmp(flowtype_str[i].str, string))
8680 return flowtype_str[i].type;
8682 return RTE_ETH_FLOW_UNKNOWN;
8685 static enum rte_eth_fdir_tunnel_type
8686 str2fdir_tunneltype(char *string)
8690 static const struct {
8692 enum rte_eth_fdir_tunnel_type type;
8693 } tunneltype_str[] = {
8694 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8695 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8698 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8699 if (!strcmp(tunneltype_str[i].str, string))
8700 return tunneltype_str[i].type;
8702 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8705 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8707 if ((ip_addr).family == AF_INET) \
8708 (ip) = (ip_addr).addr.ipv4.s_addr; \
8710 printf("invalid parameter.\n"); \
8715 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8717 if ((ip_addr).family == AF_INET6) \
8718 (void)rte_memcpy(&(ip), \
8719 &((ip_addr).addr.ipv6), \
8720 sizeof(struct in6_addr)); \
8722 printf("invalid parameter.\n"); \
8728 cmd_flow_director_filter_parsed(void *parsed_result,
8729 __attribute__((unused)) struct cmdline *cl,
8730 __attribute__((unused)) void *data)
8732 struct cmd_flow_director_result *res = parsed_result;
8733 struct rte_eth_fdir_filter entry;
8734 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8736 unsigned long vf_id;
8739 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8741 printf("flow director is not supported on port %u.\n",
8745 memset(flexbytes, 0, sizeof(flexbytes));
8746 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8748 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8749 if (strcmp(res->mode_value, "MAC-VLAN")) {
8750 printf("Please set mode to MAC-VLAN.\n");
8753 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8754 if (strcmp(res->mode_value, "Tunnel")) {
8755 printf("Please set mode to Tunnel.\n");
8759 if (strcmp(res->mode_value, "IP")) {
8760 printf("Please set mode to IP.\n");
8763 entry.input.flow_type = str2flowtype(res->flow_type);
8766 ret = parse_flexbytes(res->flexbytes_value,
8768 RTE_ETH_FDIR_MAX_FLEXLEN);
8770 printf("error: Cannot parse flexbytes input.\n");
8774 switch (entry.input.flow_type) {
8775 case RTE_ETH_FLOW_FRAG_IPV4:
8776 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8777 entry.input.flow.ip4_flow.proto = res->proto_value;
8779 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8780 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8781 IPV4_ADDR_TO_UINT(res->ip_dst,
8782 entry.input.flow.ip4_flow.dst_ip);
8783 IPV4_ADDR_TO_UINT(res->ip_src,
8784 entry.input.flow.ip4_flow.src_ip);
8785 entry.input.flow.ip4_flow.tos = res->tos_value;
8786 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8787 /* need convert to big endian. */
8788 entry.input.flow.udp4_flow.dst_port =
8789 rte_cpu_to_be_16(res->port_dst);
8790 entry.input.flow.udp4_flow.src_port =
8791 rte_cpu_to_be_16(res->port_src);
8793 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8794 IPV4_ADDR_TO_UINT(res->ip_dst,
8795 entry.input.flow.sctp4_flow.ip.dst_ip);
8796 IPV4_ADDR_TO_UINT(res->ip_src,
8797 entry.input.flow.sctp4_flow.ip.src_ip);
8798 entry.input.flow.ip4_flow.tos = res->tos_value;
8799 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8800 /* need convert to big endian. */
8801 entry.input.flow.sctp4_flow.dst_port =
8802 rte_cpu_to_be_16(res->port_dst);
8803 entry.input.flow.sctp4_flow.src_port =
8804 rte_cpu_to_be_16(res->port_src);
8805 entry.input.flow.sctp4_flow.verify_tag =
8806 rte_cpu_to_be_32(res->verify_tag_value);
8808 case RTE_ETH_FLOW_FRAG_IPV6:
8809 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8810 entry.input.flow.ipv6_flow.proto = res->proto_value;
8812 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8813 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8814 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8815 entry.input.flow.ipv6_flow.dst_ip);
8816 IPV6_ADDR_TO_ARRAY(res->ip_src,
8817 entry.input.flow.ipv6_flow.src_ip);
8818 entry.input.flow.ipv6_flow.tc = res->tos_value;
8819 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8820 /* need convert to big endian. */
8821 entry.input.flow.udp6_flow.dst_port =
8822 rte_cpu_to_be_16(res->port_dst);
8823 entry.input.flow.udp6_flow.src_port =
8824 rte_cpu_to_be_16(res->port_src);
8826 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8827 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8828 entry.input.flow.sctp6_flow.ip.dst_ip);
8829 IPV6_ADDR_TO_ARRAY(res->ip_src,
8830 entry.input.flow.sctp6_flow.ip.src_ip);
8831 entry.input.flow.ipv6_flow.tc = res->tos_value;
8832 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8833 /* need convert to big endian. */
8834 entry.input.flow.sctp6_flow.dst_port =
8835 rte_cpu_to_be_16(res->port_dst);
8836 entry.input.flow.sctp6_flow.src_port =
8837 rte_cpu_to_be_16(res->port_src);
8838 entry.input.flow.sctp6_flow.verify_tag =
8839 rte_cpu_to_be_32(res->verify_tag_value);
8841 case RTE_ETH_FLOW_L2_PAYLOAD:
8842 entry.input.flow.l2_flow.ether_type =
8843 rte_cpu_to_be_16(res->ether_type);
8849 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8850 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8852 sizeof(struct ether_addr));
8854 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8855 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8857 sizeof(struct ether_addr));
8858 entry.input.flow.tunnel_flow.tunnel_type =
8859 str2fdir_tunneltype(res->tunnel_type);
8860 entry.input.flow.tunnel_flow.tunnel_id =
8861 rte_cpu_to_be_32(res->tunnel_id_value);
8864 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8866 RTE_ETH_FDIR_MAX_FLEXLEN);
8868 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8870 entry.action.flex_off = 0; /*use 0 by default */
8871 if (!strcmp(res->drop, "drop"))
8872 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8874 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8876 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8877 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8878 if (!strcmp(res->pf_vf, "pf"))
8879 entry.input.flow_ext.is_vf = 0;
8880 else if (!strncmp(res->pf_vf, "vf", 2)) {
8881 struct rte_eth_dev_info dev_info;
8883 memset(&dev_info, 0, sizeof(dev_info));
8884 rte_eth_dev_info_get(res->port_id, &dev_info);
8886 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8887 if (errno != 0 || *end != '\0' ||
8888 vf_id >= dev_info.max_vfs) {
8889 printf("invalid parameter %s.\n", res->pf_vf);
8892 entry.input.flow_ext.is_vf = 1;
8893 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8895 printf("invalid parameter %s.\n", res->pf_vf);
8900 /* set to report FD ID by default */
8901 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8902 entry.action.rx_queue = res->queue_id;
8903 entry.soft_id = res->fd_id_value;
8904 if (!strcmp(res->ops, "add"))
8905 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8906 RTE_ETH_FILTER_ADD, &entry);
8907 else if (!strcmp(res->ops, "del"))
8908 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8909 RTE_ETH_FILTER_DELETE, &entry);
8911 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8912 RTE_ETH_FILTER_UPDATE, &entry);
8914 printf("flow director programming error: (%s)\n",
8918 cmdline_parse_token_string_t cmd_flow_director_filter =
8919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8920 flow_director_filter, "flow_director_filter");
8921 cmdline_parse_token_num_t cmd_flow_director_port_id =
8922 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8924 cmdline_parse_token_string_t cmd_flow_director_ops =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8926 ops, "add#del#update");
8927 cmdline_parse_token_string_t cmd_flow_director_flow =
8928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8930 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8932 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8933 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8934 cmdline_parse_token_string_t cmd_flow_director_ether =
8935 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8937 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8938 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8939 ether_type, UINT16);
8940 cmdline_parse_token_string_t cmd_flow_director_src =
8941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8943 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8944 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8946 cmdline_parse_token_num_t cmd_flow_director_port_src =
8947 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8949 cmdline_parse_token_string_t cmd_flow_director_dst =
8950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8952 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8953 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8955 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8956 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8958 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8960 verify_tag, "verify_tag");
8961 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8962 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8963 verify_tag_value, UINT32);
8964 cmdline_parse_token_string_t cmd_flow_director_tos =
8965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8967 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8968 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8970 cmdline_parse_token_string_t cmd_flow_director_proto =
8971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8973 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8974 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8975 proto_value, UINT8);
8976 cmdline_parse_token_string_t cmd_flow_director_ttl =
8977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8979 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8980 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8982 cmdline_parse_token_string_t cmd_flow_director_vlan =
8983 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8985 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8986 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8987 vlan_value, UINT16);
8988 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8989 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8990 flexbytes, "flexbytes");
8991 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8992 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8993 flexbytes_value, NULL);
8994 cmdline_parse_token_string_t cmd_flow_director_drop =
8995 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8997 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8998 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9000 cmdline_parse_token_string_t cmd_flow_director_queue =
9001 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9003 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9004 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9006 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9009 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9010 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9011 fd_id_value, UINT32);
9013 cmdline_parse_token_string_t cmd_flow_director_mode =
9014 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9016 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9017 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9019 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9020 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9021 mode_value, "MAC-VLAN");
9022 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9023 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9024 mode_value, "Tunnel");
9025 cmdline_parse_token_string_t cmd_flow_director_mac =
9026 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9028 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9029 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9031 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9032 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9034 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9035 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9036 tunnel_type, "NVGRE#VxLAN");
9037 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9038 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9039 tunnel_id, "tunnel-id");
9040 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9041 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9042 tunnel_id_value, UINT32);
9044 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9045 .f = cmd_flow_director_filter_parsed,
9047 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9048 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9049 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9050 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9051 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9052 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9053 "fd_id <fd_id_value>: "
9054 "Add or delete an ip flow director entry on NIC",
9056 (void *)&cmd_flow_director_filter,
9057 (void *)&cmd_flow_director_port_id,
9058 (void *)&cmd_flow_director_mode,
9059 (void *)&cmd_flow_director_mode_ip,
9060 (void *)&cmd_flow_director_ops,
9061 (void *)&cmd_flow_director_flow,
9062 (void *)&cmd_flow_director_flow_type,
9063 (void *)&cmd_flow_director_src,
9064 (void *)&cmd_flow_director_ip_src,
9065 (void *)&cmd_flow_director_dst,
9066 (void *)&cmd_flow_director_ip_dst,
9067 (void *)&cmd_flow_director_tos,
9068 (void *)&cmd_flow_director_tos_value,
9069 (void *)&cmd_flow_director_proto,
9070 (void *)&cmd_flow_director_proto_value,
9071 (void *)&cmd_flow_director_ttl,
9072 (void *)&cmd_flow_director_ttl_value,
9073 (void *)&cmd_flow_director_vlan,
9074 (void *)&cmd_flow_director_vlan_value,
9075 (void *)&cmd_flow_director_flexbytes,
9076 (void *)&cmd_flow_director_flexbytes_value,
9077 (void *)&cmd_flow_director_drop,
9078 (void *)&cmd_flow_director_pf_vf,
9079 (void *)&cmd_flow_director_queue,
9080 (void *)&cmd_flow_director_queue_id,
9081 (void *)&cmd_flow_director_fd_id,
9082 (void *)&cmd_flow_director_fd_id_value,
9087 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9088 .f = cmd_flow_director_filter_parsed,
9090 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9091 "director entry on NIC",
9093 (void *)&cmd_flow_director_filter,
9094 (void *)&cmd_flow_director_port_id,
9095 (void *)&cmd_flow_director_mode,
9096 (void *)&cmd_flow_director_mode_ip,
9097 (void *)&cmd_flow_director_ops,
9098 (void *)&cmd_flow_director_flow,
9099 (void *)&cmd_flow_director_flow_type,
9100 (void *)&cmd_flow_director_src,
9101 (void *)&cmd_flow_director_ip_src,
9102 (void *)&cmd_flow_director_port_src,
9103 (void *)&cmd_flow_director_dst,
9104 (void *)&cmd_flow_director_ip_dst,
9105 (void *)&cmd_flow_director_port_dst,
9106 (void *)&cmd_flow_director_tos,
9107 (void *)&cmd_flow_director_tos_value,
9108 (void *)&cmd_flow_director_ttl,
9109 (void *)&cmd_flow_director_ttl_value,
9110 (void *)&cmd_flow_director_vlan,
9111 (void *)&cmd_flow_director_vlan_value,
9112 (void *)&cmd_flow_director_flexbytes,
9113 (void *)&cmd_flow_director_flexbytes_value,
9114 (void *)&cmd_flow_director_drop,
9115 (void *)&cmd_flow_director_pf_vf,
9116 (void *)&cmd_flow_director_queue,
9117 (void *)&cmd_flow_director_queue_id,
9118 (void *)&cmd_flow_director_fd_id,
9119 (void *)&cmd_flow_director_fd_id_value,
9124 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9125 .f = cmd_flow_director_filter_parsed,
9127 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9128 "director entry on NIC",
9130 (void *)&cmd_flow_director_filter,
9131 (void *)&cmd_flow_director_port_id,
9132 (void *)&cmd_flow_director_mode,
9133 (void *)&cmd_flow_director_mode_ip,
9134 (void *)&cmd_flow_director_ops,
9135 (void *)&cmd_flow_director_flow,
9136 (void *)&cmd_flow_director_flow_type,
9137 (void *)&cmd_flow_director_src,
9138 (void *)&cmd_flow_director_ip_src,
9139 (void *)&cmd_flow_director_port_dst,
9140 (void *)&cmd_flow_director_dst,
9141 (void *)&cmd_flow_director_ip_dst,
9142 (void *)&cmd_flow_director_port_dst,
9143 (void *)&cmd_flow_director_verify_tag,
9144 (void *)&cmd_flow_director_verify_tag_value,
9145 (void *)&cmd_flow_director_tos,
9146 (void *)&cmd_flow_director_tos_value,
9147 (void *)&cmd_flow_director_ttl,
9148 (void *)&cmd_flow_director_ttl_value,
9149 (void *)&cmd_flow_director_vlan,
9150 (void *)&cmd_flow_director_vlan_value,
9151 (void *)&cmd_flow_director_flexbytes,
9152 (void *)&cmd_flow_director_flexbytes_value,
9153 (void *)&cmd_flow_director_drop,
9154 (void *)&cmd_flow_director_pf_vf,
9155 (void *)&cmd_flow_director_queue,
9156 (void *)&cmd_flow_director_queue_id,
9157 (void *)&cmd_flow_director_fd_id,
9158 (void *)&cmd_flow_director_fd_id_value,
9163 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9164 .f = cmd_flow_director_filter_parsed,
9166 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9167 "director entry on NIC",
9169 (void *)&cmd_flow_director_filter,
9170 (void *)&cmd_flow_director_port_id,
9171 (void *)&cmd_flow_director_mode,
9172 (void *)&cmd_flow_director_mode_ip,
9173 (void *)&cmd_flow_director_ops,
9174 (void *)&cmd_flow_director_flow,
9175 (void *)&cmd_flow_director_flow_type,
9176 (void *)&cmd_flow_director_ether,
9177 (void *)&cmd_flow_director_ether_type,
9178 (void *)&cmd_flow_director_flexbytes,
9179 (void *)&cmd_flow_director_flexbytes_value,
9180 (void *)&cmd_flow_director_drop,
9181 (void *)&cmd_flow_director_pf_vf,
9182 (void *)&cmd_flow_director_queue,
9183 (void *)&cmd_flow_director_queue_id,
9184 (void *)&cmd_flow_director_fd_id,
9185 (void *)&cmd_flow_director_fd_id_value,
9190 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9191 .f = cmd_flow_director_filter_parsed,
9193 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9194 "director entry on NIC",
9196 (void *)&cmd_flow_director_filter,
9197 (void *)&cmd_flow_director_port_id,
9198 (void *)&cmd_flow_director_mode,
9199 (void *)&cmd_flow_director_mode_mac_vlan,
9200 (void *)&cmd_flow_director_ops,
9201 (void *)&cmd_flow_director_mac,
9202 (void *)&cmd_flow_director_mac_addr,
9203 (void *)&cmd_flow_director_vlan,
9204 (void *)&cmd_flow_director_vlan_value,
9205 (void *)&cmd_flow_director_flexbytes,
9206 (void *)&cmd_flow_director_flexbytes_value,
9207 (void *)&cmd_flow_director_drop,
9208 (void *)&cmd_flow_director_queue,
9209 (void *)&cmd_flow_director_queue_id,
9210 (void *)&cmd_flow_director_fd_id,
9211 (void *)&cmd_flow_director_fd_id_value,
9216 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9217 .f = cmd_flow_director_filter_parsed,
9219 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9220 "director entry on NIC",
9222 (void *)&cmd_flow_director_filter,
9223 (void *)&cmd_flow_director_port_id,
9224 (void *)&cmd_flow_director_mode,
9225 (void *)&cmd_flow_director_mode_tunnel,
9226 (void *)&cmd_flow_director_ops,
9227 (void *)&cmd_flow_director_mac,
9228 (void *)&cmd_flow_director_mac_addr,
9229 (void *)&cmd_flow_director_vlan,
9230 (void *)&cmd_flow_director_vlan_value,
9231 (void *)&cmd_flow_director_tunnel,
9232 (void *)&cmd_flow_director_tunnel_type,
9233 (void *)&cmd_flow_director_tunnel_id,
9234 (void *)&cmd_flow_director_tunnel_id_value,
9235 (void *)&cmd_flow_director_flexbytes,
9236 (void *)&cmd_flow_director_flexbytes_value,
9237 (void *)&cmd_flow_director_drop,
9238 (void *)&cmd_flow_director_queue,
9239 (void *)&cmd_flow_director_queue_id,
9240 (void *)&cmd_flow_director_fd_id,
9241 (void *)&cmd_flow_director_fd_id_value,
9246 struct cmd_flush_flow_director_result {
9247 cmdline_fixed_string_t flush_flow_director;
9251 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9252 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9253 flush_flow_director, "flush_flow_director");
9254 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9255 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9259 cmd_flush_flow_director_parsed(void *parsed_result,
9260 __attribute__((unused)) struct cmdline *cl,
9261 __attribute__((unused)) void *data)
9263 struct cmd_flow_director_result *res = parsed_result;
9266 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9268 printf("flow director is not supported on port %u.\n",
9273 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9274 RTE_ETH_FILTER_FLUSH, NULL);
9276 printf("flow director table flushing error: (%s)\n",
9280 cmdline_parse_inst_t cmd_flush_flow_director = {
9281 .f = cmd_flush_flow_director_parsed,
9283 .help_str = "flush_flow_director <port_id>: "
9284 "Flush all flow director entries of a device on NIC",
9286 (void *)&cmd_flush_flow_director_flush,
9287 (void *)&cmd_flush_flow_director_port_id,
9292 /* *** deal with flow director mask *** */
9293 struct cmd_flow_director_mask_result {
9294 cmdline_fixed_string_t flow_director_mask;
9296 cmdline_fixed_string_t mode;
9297 cmdline_fixed_string_t mode_value;
9298 cmdline_fixed_string_t vlan;
9300 cmdline_fixed_string_t src_mask;
9301 cmdline_ipaddr_t ipv4_src;
9302 cmdline_ipaddr_t ipv6_src;
9304 cmdline_fixed_string_t dst_mask;
9305 cmdline_ipaddr_t ipv4_dst;
9306 cmdline_ipaddr_t ipv6_dst;
9308 cmdline_fixed_string_t mac;
9309 uint8_t mac_addr_byte_mask;
9310 cmdline_fixed_string_t tunnel_id;
9311 uint32_t tunnel_id_mask;
9312 cmdline_fixed_string_t tunnel_type;
9313 uint8_t tunnel_type_mask;
9317 cmd_flow_director_mask_parsed(void *parsed_result,
9318 __attribute__((unused)) struct cmdline *cl,
9319 __attribute__((unused)) void *data)
9321 struct cmd_flow_director_mask_result *res = parsed_result;
9322 struct rte_eth_fdir_masks *mask;
9323 struct rte_port *port;
9325 if (res->port_id > nb_ports) {
9326 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9330 port = &ports[res->port_id];
9331 /** Check if the port is not started **/
9332 if (port->port_status != RTE_PORT_STOPPED) {
9333 printf("Please stop port %d first\n", res->port_id);
9337 mask = &port->dev_conf.fdir_conf.mask;
9339 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9340 if (strcmp(res->mode_value, "MAC-VLAN")) {
9341 printf("Please set mode to MAC-VLAN.\n");
9345 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9346 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9347 if (strcmp(res->mode_value, "Tunnel")) {
9348 printf("Please set mode to Tunnel.\n");
9352 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9353 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9354 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9355 mask->tunnel_type_mask = res->tunnel_type_mask;
9357 if (strcmp(res->mode_value, "IP")) {
9358 printf("Please set mode to IP.\n");
9362 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9363 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9364 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9365 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9366 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9367 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9368 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9371 cmd_reconfig_device_queue(res->port_id, 1, 1);
9374 cmdline_parse_token_string_t cmd_flow_director_mask =
9375 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9376 flow_director_mask, "flow_director_mask");
9377 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9378 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9380 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9383 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9384 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9386 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9387 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9388 src_mask, "src_mask");
9389 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9390 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9392 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9393 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9395 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9396 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9398 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9400 dst_mask, "dst_mask");
9401 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9402 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9404 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9405 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9407 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9408 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9411 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9412 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9414 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9417 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9418 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9419 mode_value, "MAC-VLAN");
9420 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9421 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9422 mode_value, "Tunnel");
9423 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9426 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9427 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9428 mac_addr_byte_mask, UINT8);
9429 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9431 tunnel_type, "tunnel-type");
9432 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9433 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9434 tunnel_type_mask, UINT8);
9435 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9437 tunnel_id, "tunnel-id");
9438 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9439 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9440 tunnel_id_mask, UINT32);
9442 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9443 .f = cmd_flow_director_mask_parsed,
9445 .help_str = "flow_director_mask ... : "
9446 "Set IP mode flow director's mask on NIC",
9448 (void *)&cmd_flow_director_mask,
9449 (void *)&cmd_flow_director_mask_port_id,
9450 (void *)&cmd_flow_director_mask_mode,
9451 (void *)&cmd_flow_director_mask_mode_ip,
9452 (void *)&cmd_flow_director_mask_vlan,
9453 (void *)&cmd_flow_director_mask_vlan_value,
9454 (void *)&cmd_flow_director_mask_src,
9455 (void *)&cmd_flow_director_mask_ipv4_src,
9456 (void *)&cmd_flow_director_mask_ipv6_src,
9457 (void *)&cmd_flow_director_mask_port_src,
9458 (void *)&cmd_flow_director_mask_dst,
9459 (void *)&cmd_flow_director_mask_ipv4_dst,
9460 (void *)&cmd_flow_director_mask_ipv6_dst,
9461 (void *)&cmd_flow_director_mask_port_dst,
9466 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9467 .f = cmd_flow_director_mask_parsed,
9469 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9470 "flow director's mask on NIC",
9472 (void *)&cmd_flow_director_mask,
9473 (void *)&cmd_flow_director_mask_port_id,
9474 (void *)&cmd_flow_director_mask_mode,
9475 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9476 (void *)&cmd_flow_director_mask_vlan,
9477 (void *)&cmd_flow_director_mask_vlan_value,
9482 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9483 .f = cmd_flow_director_mask_parsed,
9485 .help_str = "flow_director_mask ... : Set tunnel mode "
9486 "flow director's mask on NIC",
9488 (void *)&cmd_flow_director_mask,
9489 (void *)&cmd_flow_director_mask_port_id,
9490 (void *)&cmd_flow_director_mask_mode,
9491 (void *)&cmd_flow_director_mask_mode_tunnel,
9492 (void *)&cmd_flow_director_mask_vlan,
9493 (void *)&cmd_flow_director_mask_vlan_value,
9494 (void *)&cmd_flow_director_mask_mac,
9495 (void *)&cmd_flow_director_mask_mac_value,
9496 (void *)&cmd_flow_director_mask_tunnel_type,
9497 (void *)&cmd_flow_director_mask_tunnel_type_value,
9498 (void *)&cmd_flow_director_mask_tunnel_id,
9499 (void *)&cmd_flow_director_mask_tunnel_id_value,
9504 /* *** deal with flow director mask on flexible payload *** */
9505 struct cmd_flow_director_flex_mask_result {
9506 cmdline_fixed_string_t flow_director_flexmask;
9508 cmdline_fixed_string_t flow;
9509 cmdline_fixed_string_t flow_type;
9510 cmdline_fixed_string_t mask;
9514 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9515 __attribute__((unused)) struct cmdline *cl,
9516 __attribute__((unused)) void *data)
9518 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9519 struct rte_eth_fdir_info fdir_info;
9520 struct rte_eth_fdir_flex_mask flex_mask;
9521 struct rte_port *port;
9522 uint32_t flow_type_mask;
9526 if (res->port_id > nb_ports) {
9527 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9531 port = &ports[res->port_id];
9532 /** Check if the port is not started **/
9533 if (port->port_status != RTE_PORT_STOPPED) {
9534 printf("Please stop port %d first\n", res->port_id);
9538 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9539 ret = parse_flexbytes(res->mask,
9541 RTE_ETH_FDIR_MAX_FLEXLEN);
9543 printf("error: Cannot parse mask input.\n");
9547 memset(&fdir_info, 0, sizeof(fdir_info));
9548 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9549 RTE_ETH_FILTER_INFO, &fdir_info);
9551 printf("Cannot get FDir filter info\n");
9555 if (!strcmp(res->flow_type, "none")) {
9556 /* means don't specify the flow type */
9557 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9558 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9559 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9560 0, sizeof(struct rte_eth_fdir_flex_mask));
9561 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9562 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9564 sizeof(struct rte_eth_fdir_flex_mask));
9565 cmd_reconfig_device_queue(res->port_id, 1, 1);
9568 flow_type_mask = fdir_info.flow_types_mask[0];
9569 if (!strcmp(res->flow_type, "all")) {
9570 if (!flow_type_mask) {
9571 printf("No flow type supported\n");
9574 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9575 if (flow_type_mask & (1 << i)) {
9576 flex_mask.flow_type = i;
9577 fdir_set_flex_mask(res->port_id, &flex_mask);
9580 cmd_reconfig_device_queue(res->port_id, 1, 1);
9583 flex_mask.flow_type = str2flowtype(res->flow_type);
9584 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9585 printf("Flow type %s not supported on port %d\n",
9586 res->flow_type, res->port_id);
9589 fdir_set_flex_mask(res->port_id, &flex_mask);
9590 cmd_reconfig_device_queue(res->port_id, 1, 1);
9593 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9595 flow_director_flexmask,
9596 "flow_director_flex_mask");
9597 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9598 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9600 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9601 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9603 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9604 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9605 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9606 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9607 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9608 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9611 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9612 .f = cmd_flow_director_flex_mask_parsed,
9614 .help_str = "flow_director_flex_mask ... : "
9615 "Set flow director's flex mask on NIC",
9617 (void *)&cmd_flow_director_flexmask,
9618 (void *)&cmd_flow_director_flexmask_port_id,
9619 (void *)&cmd_flow_director_flexmask_flow,
9620 (void *)&cmd_flow_director_flexmask_flow_type,
9621 (void *)&cmd_flow_director_flexmask_mask,
9626 /* *** deal with flow director flexible payload configuration *** */
9627 struct cmd_flow_director_flexpayload_result {
9628 cmdline_fixed_string_t flow_director_flexpayload;
9630 cmdline_fixed_string_t payload_layer;
9631 cmdline_fixed_string_t payload_cfg;
9635 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9638 const char *p, *p0 = q_arg;
9640 unsigned long int_fld;
9641 char *str_fld[max_num];
9646 p = strchr(p0, '(');
9650 p0 = strchr(p, ')');
9655 if (size >= sizeof(s))
9658 snprintf(s, sizeof(s), "%.*s", size, p);
9659 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9660 if (ret < 0 || ret > max_num)
9662 for (i = 0; i < ret; i++) {
9664 int_fld = strtoul(str_fld[i], &end, 0);
9665 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9667 offsets[i] = (uint16_t)int_fld;
9673 cmd_flow_director_flxpld_parsed(void *parsed_result,
9674 __attribute__((unused)) struct cmdline *cl,
9675 __attribute__((unused)) void *data)
9677 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9678 struct rte_eth_flex_payload_cfg flex_cfg;
9679 struct rte_port *port;
9682 if (res->port_id > nb_ports) {
9683 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9687 port = &ports[res->port_id];
9688 /** Check if the port is not started **/
9689 if (port->port_status != RTE_PORT_STOPPED) {
9690 printf("Please stop port %d first\n", res->port_id);
9694 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9696 if (!strcmp(res->payload_layer, "raw"))
9697 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9698 else if (!strcmp(res->payload_layer, "l2"))
9699 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9700 else if (!strcmp(res->payload_layer, "l3"))
9701 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9702 else if (!strcmp(res->payload_layer, "l4"))
9703 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9705 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9706 RTE_ETH_FDIR_MAX_FLEXLEN);
9708 printf("error: Cannot parse flex payload input.\n");
9712 fdir_set_flex_payload(res->port_id, &flex_cfg);
9713 cmd_reconfig_device_queue(res->port_id, 1, 1);
9716 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9718 flow_director_flexpayload,
9719 "flow_director_flex_payload");
9720 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9721 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9723 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9724 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9725 payload_layer, "raw#l2#l3#l4");
9726 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9727 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9730 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9731 .f = cmd_flow_director_flxpld_parsed,
9733 .help_str = "flow_director_flexpayload ... : "
9734 "Set flow director's flex payload on NIC",
9736 (void *)&cmd_flow_director_flexpayload,
9737 (void *)&cmd_flow_director_flexpayload_port_id,
9738 (void *)&cmd_flow_director_flexpayload_payload_layer,
9739 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9744 /* Generic flow interface command. */
9745 extern cmdline_parse_inst_t cmd_flow;
9747 /* *** Classification Filters Control *** */
9748 /* *** Get symmetric hash enable per port *** */
9749 struct cmd_get_sym_hash_ena_per_port_result {
9750 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9755 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9756 __rte_unused struct cmdline *cl,
9757 __rte_unused void *data)
9759 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9760 struct rte_eth_hash_filter_info info;
9763 if (rte_eth_dev_filter_supported(res->port_id,
9764 RTE_ETH_FILTER_HASH) < 0) {
9765 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9770 memset(&info, 0, sizeof(info));
9771 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9772 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9773 RTE_ETH_FILTER_GET, &info);
9776 printf("Cannot get symmetric hash enable per port "
9777 "on port %u\n", res->port_id);
9781 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9782 "enabled" : "disabled", res->port_id);
9785 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9786 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9787 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9788 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9789 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9792 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9793 .f = cmd_get_sym_hash_per_port_parsed,
9795 .help_str = "get_sym_hash_ena_per_port <port_id>",
9797 (void *)&cmd_get_sym_hash_ena_per_port_all,
9798 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9803 /* *** Set symmetric hash enable per port *** */
9804 struct cmd_set_sym_hash_ena_per_port_result {
9805 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9806 cmdline_fixed_string_t enable;
9811 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9812 __rte_unused struct cmdline *cl,
9813 __rte_unused void *data)
9815 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9816 struct rte_eth_hash_filter_info info;
9819 if (rte_eth_dev_filter_supported(res->port_id,
9820 RTE_ETH_FILTER_HASH) < 0) {
9821 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9826 memset(&info, 0, sizeof(info));
9827 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9828 if (!strcmp(res->enable, "enable"))
9829 info.info.enable = 1;
9830 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9831 RTE_ETH_FILTER_SET, &info);
9833 printf("Cannot set symmetric hash enable per port on "
9834 "port %u\n", res->port_id);
9837 printf("Symmetric hash has been set to %s on port %u\n",
9838 res->enable, res->port_id);
9841 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9842 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9843 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9844 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9845 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9847 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9848 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9849 enable, "enable#disable");
9851 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9852 .f = cmd_set_sym_hash_per_port_parsed,
9854 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9856 (void *)&cmd_set_sym_hash_ena_per_port_all,
9857 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9858 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9863 /* Get global config of hash function */
9864 struct cmd_get_hash_global_config_result {
9865 cmdline_fixed_string_t get_hash_global_config;
9870 flowtype_to_str(uint16_t ftype)
9877 {"ipv4", RTE_ETH_FLOW_IPV4},
9878 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9879 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9880 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9881 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9882 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9883 {"ipv6", RTE_ETH_FLOW_IPV6},
9884 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9885 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9886 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9887 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9888 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9889 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9890 {"port", RTE_ETH_FLOW_PORT},
9891 {"vxlan", RTE_ETH_FLOW_VXLAN},
9892 {"geneve", RTE_ETH_FLOW_GENEVE},
9893 {"nvgre", RTE_ETH_FLOW_NVGRE},
9896 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9897 if (ftype_table[i].ftype == ftype)
9898 return ftype_table[i].str;
9905 cmd_get_hash_global_config_parsed(void *parsed_result,
9906 __rte_unused struct cmdline *cl,
9907 __rte_unused void *data)
9909 struct cmd_get_hash_global_config_result *res = parsed_result;
9910 struct rte_eth_hash_filter_info info;
9911 uint32_t idx, offset;
9916 if (rte_eth_dev_filter_supported(res->port_id,
9917 RTE_ETH_FILTER_HASH) < 0) {
9918 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9923 memset(&info, 0, sizeof(info));
9924 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9925 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9926 RTE_ETH_FILTER_GET, &info);
9928 printf("Cannot get hash global configurations by port %d\n",
9933 switch (info.info.global_conf.hash_func) {
9934 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9935 printf("Hash function is Toeplitz\n");
9937 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9938 printf("Hash function is Simple XOR\n");
9941 printf("Unknown hash function\n");
9945 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9946 idx = i / UINT32_BIT;
9947 offset = i % UINT32_BIT;
9948 if (!(info.info.global_conf.valid_bit_mask[idx] &
9951 str = flowtype_to_str(i);
9954 printf("Symmetric hash is %s globally for flow type %s "
9956 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9957 (1UL << offset)) ? "enabled" : "disabled"), str,
9962 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9963 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9964 get_hash_global_config, "get_hash_global_config");
9965 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9966 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9969 cmdline_parse_inst_t cmd_get_hash_global_config = {
9970 .f = cmd_get_hash_global_config_parsed,
9972 .help_str = "get_hash_global_config <port_id>",
9974 (void *)&cmd_get_hash_global_config_all,
9975 (void *)&cmd_get_hash_global_config_port_id,
9980 /* Set global config of hash function */
9981 struct cmd_set_hash_global_config_result {
9982 cmdline_fixed_string_t set_hash_global_config;
9984 cmdline_fixed_string_t hash_func;
9985 cmdline_fixed_string_t flow_type;
9986 cmdline_fixed_string_t enable;
9990 cmd_set_hash_global_config_parsed(void *parsed_result,
9991 __rte_unused struct cmdline *cl,
9992 __rte_unused void *data)
9994 struct cmd_set_hash_global_config_result *res = parsed_result;
9995 struct rte_eth_hash_filter_info info;
9996 uint32_t ftype, idx, offset;
9999 if (rte_eth_dev_filter_supported(res->port_id,
10000 RTE_ETH_FILTER_HASH) < 0) {
10001 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10005 memset(&info, 0, sizeof(info));
10006 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10007 if (!strcmp(res->hash_func, "toeplitz"))
10008 info.info.global_conf.hash_func =
10009 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10010 else if (!strcmp(res->hash_func, "simple_xor"))
10011 info.info.global_conf.hash_func =
10012 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10013 else if (!strcmp(res->hash_func, "default"))
10014 info.info.global_conf.hash_func =
10015 RTE_ETH_HASH_FUNCTION_DEFAULT;
10017 ftype = str2flowtype(res->flow_type);
10018 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10019 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10020 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10021 if (!strcmp(res->enable, "enable"))
10022 info.info.global_conf.sym_hash_enable_mask[idx] |=
10024 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10025 RTE_ETH_FILTER_SET, &info);
10027 printf("Cannot set global hash configurations by port %d\n",
10030 printf("Global hash configurations have been set "
10031 "succcessfully by port %d\n", res->port_id);
10034 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10035 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10036 set_hash_global_config, "set_hash_global_config");
10037 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10038 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10040 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10041 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10042 hash_func, "toeplitz#simple_xor#default");
10043 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10044 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10046 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10047 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10048 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10049 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10050 enable, "enable#disable");
10052 cmdline_parse_inst_t cmd_set_hash_global_config = {
10053 .f = cmd_set_hash_global_config_parsed,
10055 .help_str = "set_hash_global_config <port_id> "
10056 "toeplitz|simple_xor|default "
10057 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10058 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10059 "l2_payload enable|disable",
10061 (void *)&cmd_set_hash_global_config_all,
10062 (void *)&cmd_set_hash_global_config_port_id,
10063 (void *)&cmd_set_hash_global_config_hash_func,
10064 (void *)&cmd_set_hash_global_config_flow_type,
10065 (void *)&cmd_set_hash_global_config_enable,
10070 /* Set hash input set */
10071 struct cmd_set_hash_input_set_result {
10072 cmdline_fixed_string_t set_hash_input_set;
10074 cmdline_fixed_string_t flow_type;
10075 cmdline_fixed_string_t inset_field;
10076 cmdline_fixed_string_t select;
10079 static enum rte_eth_input_set_field
10080 str2inset(char *string)
10084 static const struct {
10086 enum rte_eth_input_set_field inset;
10087 } inset_table[] = {
10088 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10089 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10090 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10091 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10092 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10093 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10094 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10095 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10096 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10097 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10098 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10099 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10100 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10101 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10102 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10103 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10104 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10105 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10106 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10107 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10108 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10109 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10110 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10111 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10112 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10113 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10114 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10115 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10116 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10117 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10118 {"none", RTE_ETH_INPUT_SET_NONE},
10121 for (i = 0; i < RTE_DIM(inset_table); i++) {
10122 if (!strcmp(string, inset_table[i].str))
10123 return inset_table[i].inset;
10126 return RTE_ETH_INPUT_SET_UNKNOWN;
10130 cmd_set_hash_input_set_parsed(void *parsed_result,
10131 __rte_unused struct cmdline *cl,
10132 __rte_unused void *data)
10134 struct cmd_set_hash_input_set_result *res = parsed_result;
10135 struct rte_eth_hash_filter_info info;
10137 memset(&info, 0, sizeof(info));
10138 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10139 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10140 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10141 info.info.input_set_conf.inset_size = 1;
10142 if (!strcmp(res->select, "select"))
10143 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10144 else if (!strcmp(res->select, "add"))
10145 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10146 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10147 RTE_ETH_FILTER_SET, &info);
10150 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10151 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10152 set_hash_input_set, "set_hash_input_set");
10153 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10154 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10156 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10157 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10159 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10160 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10161 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10162 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10164 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10165 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10166 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10167 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10168 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10170 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10171 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10172 select, "select#add");
10174 cmdline_parse_inst_t cmd_set_hash_input_set = {
10175 .f = cmd_set_hash_input_set_parsed,
10177 .help_str = "set_hash_input_set <port_id> "
10178 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10179 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10180 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10181 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10182 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10183 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10184 "fld-7th|fld-8th|none select|add",
10186 (void *)&cmd_set_hash_input_set_cmd,
10187 (void *)&cmd_set_hash_input_set_port_id,
10188 (void *)&cmd_set_hash_input_set_flow_type,
10189 (void *)&cmd_set_hash_input_set_field,
10190 (void *)&cmd_set_hash_input_set_select,
10195 /* Set flow director input set */
10196 struct cmd_set_fdir_input_set_result {
10197 cmdline_fixed_string_t set_fdir_input_set;
10199 cmdline_fixed_string_t flow_type;
10200 cmdline_fixed_string_t inset_field;
10201 cmdline_fixed_string_t select;
10205 cmd_set_fdir_input_set_parsed(void *parsed_result,
10206 __rte_unused struct cmdline *cl,
10207 __rte_unused void *data)
10209 struct cmd_set_fdir_input_set_result *res = parsed_result;
10210 struct rte_eth_fdir_filter_info info;
10212 memset(&info, 0, sizeof(info));
10213 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10214 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10215 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10216 info.info.input_set_conf.inset_size = 1;
10217 if (!strcmp(res->select, "select"))
10218 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10219 else if (!strcmp(res->select, "add"))
10220 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10221 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10222 RTE_ETH_FILTER_SET, &info);
10225 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10226 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10227 set_fdir_input_set, "set_fdir_input_set");
10228 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10229 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10231 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10232 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10234 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10235 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10236 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10237 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10239 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10240 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10241 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10242 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10243 "sctp-veri-tag#none");
10244 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10245 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10246 select, "select#add");
10248 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10249 .f = cmd_set_fdir_input_set_parsed,
10251 .help_str = "set_fdir_input_set <port_id> "
10252 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10253 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10254 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10255 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10256 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10257 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10258 "sctp-veri-tag|none select|add",
10260 (void *)&cmd_set_fdir_input_set_cmd,
10261 (void *)&cmd_set_fdir_input_set_port_id,
10262 (void *)&cmd_set_fdir_input_set_flow_type,
10263 (void *)&cmd_set_fdir_input_set_field,
10264 (void *)&cmd_set_fdir_input_set_select,
10269 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10270 struct cmd_mcast_addr_result {
10271 cmdline_fixed_string_t mcast_addr_cmd;
10272 cmdline_fixed_string_t what;
10274 struct ether_addr mc_addr;
10277 static void cmd_mcast_addr_parsed(void *parsed_result,
10278 __attribute__((unused)) struct cmdline *cl,
10279 __attribute__((unused)) void *data)
10281 struct cmd_mcast_addr_result *res = parsed_result;
10283 if (!is_multicast_ether_addr(&res->mc_addr)) {
10284 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10285 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10286 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10287 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10290 if (strcmp(res->what, "add") == 0)
10291 mcast_addr_add(res->port_num, &res->mc_addr);
10293 mcast_addr_remove(res->port_num, &res->mc_addr);
10296 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10297 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10298 mcast_addr_cmd, "mcast_addr");
10299 cmdline_parse_token_string_t cmd_mcast_addr_what =
10300 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10302 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10303 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10304 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10305 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10307 cmdline_parse_inst_t cmd_mcast_addr = {
10308 .f = cmd_mcast_addr_parsed,
10310 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10311 "Add/Remove multicast MAC address on port_id",
10313 (void *)&cmd_mcast_addr_cmd,
10314 (void *)&cmd_mcast_addr_what,
10315 (void *)&cmd_mcast_addr_portnum,
10316 (void *)&cmd_mcast_addr_addr,
10321 /* l2 tunnel config
10322 * only support E-tag now.
10325 /* Ether type config */
10326 struct cmd_config_l2_tunnel_eth_type_result {
10327 cmdline_fixed_string_t port;
10328 cmdline_fixed_string_t config;
10329 cmdline_fixed_string_t all;
10331 cmdline_fixed_string_t l2_tunnel;
10332 cmdline_fixed_string_t l2_tunnel_type;
10333 cmdline_fixed_string_t eth_type;
10334 uint16_t eth_type_val;
10337 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10338 TOKEN_STRING_INITIALIZER
10339 (struct cmd_config_l2_tunnel_eth_type_result,
10341 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10342 TOKEN_STRING_INITIALIZER
10343 (struct cmd_config_l2_tunnel_eth_type_result,
10345 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10346 TOKEN_STRING_INITIALIZER
10347 (struct cmd_config_l2_tunnel_eth_type_result,
10349 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10350 TOKEN_NUM_INITIALIZER
10351 (struct cmd_config_l2_tunnel_eth_type_result,
10353 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10354 TOKEN_STRING_INITIALIZER
10355 (struct cmd_config_l2_tunnel_eth_type_result,
10356 l2_tunnel, "l2-tunnel");
10357 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10358 TOKEN_STRING_INITIALIZER
10359 (struct cmd_config_l2_tunnel_eth_type_result,
10360 l2_tunnel_type, "E-tag");
10361 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10362 TOKEN_STRING_INITIALIZER
10363 (struct cmd_config_l2_tunnel_eth_type_result,
10364 eth_type, "ether-type");
10365 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10366 TOKEN_NUM_INITIALIZER
10367 (struct cmd_config_l2_tunnel_eth_type_result,
10368 eth_type_val, UINT16);
10370 static enum rte_eth_tunnel_type
10371 str2fdir_l2_tunnel_type(char *string)
10375 static const struct {
10377 enum rte_eth_tunnel_type type;
10378 } l2_tunnel_type_str[] = {
10379 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10382 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10383 if (!strcmp(l2_tunnel_type_str[i].str, string))
10384 return l2_tunnel_type_str[i].type;
10386 return RTE_TUNNEL_TYPE_NONE;
10389 /* ether type config for all ports */
10391 cmd_config_l2_tunnel_eth_type_all_parsed
10392 (void *parsed_result,
10393 __attribute__((unused)) struct cmdline *cl,
10394 __attribute__((unused)) void *data)
10396 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10397 struct rte_eth_l2_tunnel_conf entry;
10400 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10401 entry.ether_type = res->eth_type_val;
10403 RTE_ETH_FOREACH_DEV(pid) {
10404 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10408 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10409 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10411 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10413 (void *)&cmd_config_l2_tunnel_eth_type_port,
10414 (void *)&cmd_config_l2_tunnel_eth_type_config,
10415 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10416 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10417 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10418 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10419 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10424 /* ether type config for a specific port */
10426 cmd_config_l2_tunnel_eth_type_specific_parsed(
10427 void *parsed_result,
10428 __attribute__((unused)) struct cmdline *cl,
10429 __attribute__((unused)) void *data)
10431 struct cmd_config_l2_tunnel_eth_type_result *res =
10433 struct rte_eth_l2_tunnel_conf entry;
10435 if (port_id_is_invalid(res->id, ENABLED_WARN))
10438 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10439 entry.ether_type = res->eth_type_val;
10441 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10444 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10445 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10447 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10449 (void *)&cmd_config_l2_tunnel_eth_type_port,
10450 (void *)&cmd_config_l2_tunnel_eth_type_config,
10451 (void *)&cmd_config_l2_tunnel_eth_type_id,
10452 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10453 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10454 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10455 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10460 /* Enable/disable l2 tunnel */
10461 struct cmd_config_l2_tunnel_en_dis_result {
10462 cmdline_fixed_string_t port;
10463 cmdline_fixed_string_t config;
10464 cmdline_fixed_string_t all;
10466 cmdline_fixed_string_t l2_tunnel;
10467 cmdline_fixed_string_t l2_tunnel_type;
10468 cmdline_fixed_string_t en_dis;
10471 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10472 TOKEN_STRING_INITIALIZER
10473 (struct cmd_config_l2_tunnel_en_dis_result,
10475 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10476 TOKEN_STRING_INITIALIZER
10477 (struct cmd_config_l2_tunnel_en_dis_result,
10479 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10480 TOKEN_STRING_INITIALIZER
10481 (struct cmd_config_l2_tunnel_en_dis_result,
10483 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10484 TOKEN_NUM_INITIALIZER
10485 (struct cmd_config_l2_tunnel_en_dis_result,
10487 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10488 TOKEN_STRING_INITIALIZER
10489 (struct cmd_config_l2_tunnel_en_dis_result,
10490 l2_tunnel, "l2-tunnel");
10491 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10492 TOKEN_STRING_INITIALIZER
10493 (struct cmd_config_l2_tunnel_en_dis_result,
10494 l2_tunnel_type, "E-tag");
10495 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10496 TOKEN_STRING_INITIALIZER
10497 (struct cmd_config_l2_tunnel_en_dis_result,
10498 en_dis, "enable#disable");
10500 /* enable/disable l2 tunnel for all ports */
10502 cmd_config_l2_tunnel_en_dis_all_parsed(
10503 void *parsed_result,
10504 __attribute__((unused)) struct cmdline *cl,
10505 __attribute__((unused)) void *data)
10507 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10508 struct rte_eth_l2_tunnel_conf entry;
10512 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10514 if (!strcmp("enable", res->en_dis))
10519 RTE_ETH_FOREACH_DEV(pid) {
10520 rte_eth_dev_l2_tunnel_offload_set(pid,
10522 ETH_L2_TUNNEL_ENABLE_MASK,
10527 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10528 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10530 .help_str = "port config all l2-tunnel E-tag enable|disable",
10532 (void *)&cmd_config_l2_tunnel_en_dis_port,
10533 (void *)&cmd_config_l2_tunnel_en_dis_config,
10534 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10535 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10536 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10537 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10542 /* enable/disable l2 tunnel for a port */
10544 cmd_config_l2_tunnel_en_dis_specific_parsed(
10545 void *parsed_result,
10546 __attribute__((unused)) struct cmdline *cl,
10547 __attribute__((unused)) void *data)
10549 struct cmd_config_l2_tunnel_en_dis_result *res =
10551 struct rte_eth_l2_tunnel_conf entry;
10553 if (port_id_is_invalid(res->id, ENABLED_WARN))
10556 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10558 if (!strcmp("enable", res->en_dis))
10559 rte_eth_dev_l2_tunnel_offload_set(res->id,
10561 ETH_L2_TUNNEL_ENABLE_MASK,
10564 rte_eth_dev_l2_tunnel_offload_set(res->id,
10566 ETH_L2_TUNNEL_ENABLE_MASK,
10570 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10571 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10573 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10575 (void *)&cmd_config_l2_tunnel_en_dis_port,
10576 (void *)&cmd_config_l2_tunnel_en_dis_config,
10577 (void *)&cmd_config_l2_tunnel_en_dis_id,
10578 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10579 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10580 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10585 /* E-tag configuration */
10587 /* Common result structure for all E-tag configuration */
10588 struct cmd_config_e_tag_result {
10589 cmdline_fixed_string_t e_tag;
10590 cmdline_fixed_string_t set;
10591 cmdline_fixed_string_t insertion;
10592 cmdline_fixed_string_t stripping;
10593 cmdline_fixed_string_t forwarding;
10594 cmdline_fixed_string_t filter;
10595 cmdline_fixed_string_t add;
10596 cmdline_fixed_string_t del;
10597 cmdline_fixed_string_t on;
10598 cmdline_fixed_string_t off;
10599 cmdline_fixed_string_t on_off;
10600 cmdline_fixed_string_t port_tag_id;
10601 uint32_t port_tag_id_val;
10602 cmdline_fixed_string_t e_tag_id;
10603 uint16_t e_tag_id_val;
10604 cmdline_fixed_string_t dst_pool;
10605 uint8_t dst_pool_val;
10606 cmdline_fixed_string_t port;
10608 cmdline_fixed_string_t vf;
10612 /* Common CLI fields for all E-tag configuration */
10613 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10614 TOKEN_STRING_INITIALIZER
10615 (struct cmd_config_e_tag_result,
10617 cmdline_parse_token_string_t cmd_config_e_tag_set =
10618 TOKEN_STRING_INITIALIZER
10619 (struct cmd_config_e_tag_result,
10621 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10622 TOKEN_STRING_INITIALIZER
10623 (struct cmd_config_e_tag_result,
10624 insertion, "insertion");
10625 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10626 TOKEN_STRING_INITIALIZER
10627 (struct cmd_config_e_tag_result,
10628 stripping, "stripping");
10629 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10630 TOKEN_STRING_INITIALIZER
10631 (struct cmd_config_e_tag_result,
10632 forwarding, "forwarding");
10633 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10634 TOKEN_STRING_INITIALIZER
10635 (struct cmd_config_e_tag_result,
10637 cmdline_parse_token_string_t cmd_config_e_tag_add =
10638 TOKEN_STRING_INITIALIZER
10639 (struct cmd_config_e_tag_result,
10641 cmdline_parse_token_string_t cmd_config_e_tag_del =
10642 TOKEN_STRING_INITIALIZER
10643 (struct cmd_config_e_tag_result,
10645 cmdline_parse_token_string_t cmd_config_e_tag_on =
10646 TOKEN_STRING_INITIALIZER
10647 (struct cmd_config_e_tag_result,
10649 cmdline_parse_token_string_t cmd_config_e_tag_off =
10650 TOKEN_STRING_INITIALIZER
10651 (struct cmd_config_e_tag_result,
10653 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10654 TOKEN_STRING_INITIALIZER
10655 (struct cmd_config_e_tag_result,
10657 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10658 TOKEN_STRING_INITIALIZER
10659 (struct cmd_config_e_tag_result,
10660 port_tag_id, "port-tag-id");
10661 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10662 TOKEN_NUM_INITIALIZER
10663 (struct cmd_config_e_tag_result,
10664 port_tag_id_val, UINT32);
10665 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10666 TOKEN_STRING_INITIALIZER
10667 (struct cmd_config_e_tag_result,
10668 e_tag_id, "e-tag-id");
10669 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10670 TOKEN_NUM_INITIALIZER
10671 (struct cmd_config_e_tag_result,
10672 e_tag_id_val, UINT16);
10673 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10674 TOKEN_STRING_INITIALIZER
10675 (struct cmd_config_e_tag_result,
10676 dst_pool, "dst-pool");
10677 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10678 TOKEN_NUM_INITIALIZER
10679 (struct cmd_config_e_tag_result,
10680 dst_pool_val, UINT8);
10681 cmdline_parse_token_string_t cmd_config_e_tag_port =
10682 TOKEN_STRING_INITIALIZER
10683 (struct cmd_config_e_tag_result,
10685 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10686 TOKEN_NUM_INITIALIZER
10687 (struct cmd_config_e_tag_result,
10689 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10690 TOKEN_STRING_INITIALIZER
10691 (struct cmd_config_e_tag_result,
10693 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10694 TOKEN_NUM_INITIALIZER
10695 (struct cmd_config_e_tag_result,
10698 /* E-tag insertion configuration */
10700 cmd_config_e_tag_insertion_en_parsed(
10701 void *parsed_result,
10702 __attribute__((unused)) struct cmdline *cl,
10703 __attribute__((unused)) void *data)
10705 struct cmd_config_e_tag_result *res =
10707 struct rte_eth_l2_tunnel_conf entry;
10709 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10712 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10713 entry.tunnel_id = res->port_tag_id_val;
10714 entry.vf_id = res->vf_id;
10715 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10717 ETH_L2_TUNNEL_INSERTION_MASK,
10722 cmd_config_e_tag_insertion_dis_parsed(
10723 void *parsed_result,
10724 __attribute__((unused)) struct cmdline *cl,
10725 __attribute__((unused)) void *data)
10727 struct cmd_config_e_tag_result *res =
10729 struct rte_eth_l2_tunnel_conf entry;
10731 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10734 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10735 entry.vf_id = res->vf_id;
10737 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10739 ETH_L2_TUNNEL_INSERTION_MASK,
10743 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10744 .f = cmd_config_e_tag_insertion_en_parsed,
10746 .help_str = "E-tag ... : E-tag insertion enable",
10748 (void *)&cmd_config_e_tag_e_tag,
10749 (void *)&cmd_config_e_tag_set,
10750 (void *)&cmd_config_e_tag_insertion,
10751 (void *)&cmd_config_e_tag_on,
10752 (void *)&cmd_config_e_tag_port_tag_id,
10753 (void *)&cmd_config_e_tag_port_tag_id_val,
10754 (void *)&cmd_config_e_tag_port,
10755 (void *)&cmd_config_e_tag_port_id,
10756 (void *)&cmd_config_e_tag_vf,
10757 (void *)&cmd_config_e_tag_vf_id,
10762 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10763 .f = cmd_config_e_tag_insertion_dis_parsed,
10765 .help_str = "E-tag ... : E-tag insertion disable",
10767 (void *)&cmd_config_e_tag_e_tag,
10768 (void *)&cmd_config_e_tag_set,
10769 (void *)&cmd_config_e_tag_insertion,
10770 (void *)&cmd_config_e_tag_off,
10771 (void *)&cmd_config_e_tag_port,
10772 (void *)&cmd_config_e_tag_port_id,
10773 (void *)&cmd_config_e_tag_vf,
10774 (void *)&cmd_config_e_tag_vf_id,
10779 /* E-tag stripping configuration */
10781 cmd_config_e_tag_stripping_parsed(
10782 void *parsed_result,
10783 __attribute__((unused)) struct cmdline *cl,
10784 __attribute__((unused)) void *data)
10786 struct cmd_config_e_tag_result *res =
10788 struct rte_eth_l2_tunnel_conf entry;
10790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10793 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10795 if (!strcmp(res->on_off, "on"))
10796 rte_eth_dev_l2_tunnel_offload_set
10799 ETH_L2_TUNNEL_STRIPPING_MASK,
10802 rte_eth_dev_l2_tunnel_offload_set
10805 ETH_L2_TUNNEL_STRIPPING_MASK,
10809 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10810 .f = cmd_config_e_tag_stripping_parsed,
10812 .help_str = "E-tag ... : E-tag stripping enable/disable",
10814 (void *)&cmd_config_e_tag_e_tag,
10815 (void *)&cmd_config_e_tag_set,
10816 (void *)&cmd_config_e_tag_stripping,
10817 (void *)&cmd_config_e_tag_on_off,
10818 (void *)&cmd_config_e_tag_port,
10819 (void *)&cmd_config_e_tag_port_id,
10824 /* E-tag forwarding configuration */
10826 cmd_config_e_tag_forwarding_parsed(
10827 void *parsed_result,
10828 __attribute__((unused)) struct cmdline *cl,
10829 __attribute__((unused)) void *data)
10831 struct cmd_config_e_tag_result *res = parsed_result;
10832 struct rte_eth_l2_tunnel_conf entry;
10834 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10837 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10839 if (!strcmp(res->on_off, "on"))
10840 rte_eth_dev_l2_tunnel_offload_set
10843 ETH_L2_TUNNEL_FORWARDING_MASK,
10846 rte_eth_dev_l2_tunnel_offload_set
10849 ETH_L2_TUNNEL_FORWARDING_MASK,
10853 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10854 .f = cmd_config_e_tag_forwarding_parsed,
10856 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10858 (void *)&cmd_config_e_tag_e_tag,
10859 (void *)&cmd_config_e_tag_set,
10860 (void *)&cmd_config_e_tag_forwarding,
10861 (void *)&cmd_config_e_tag_on_off,
10862 (void *)&cmd_config_e_tag_port,
10863 (void *)&cmd_config_e_tag_port_id,
10868 /* E-tag filter configuration */
10870 cmd_config_e_tag_filter_add_parsed(
10871 void *parsed_result,
10872 __attribute__((unused)) struct cmdline *cl,
10873 __attribute__((unused)) void *data)
10875 struct cmd_config_e_tag_result *res = parsed_result;
10876 struct rte_eth_l2_tunnel_conf entry;
10879 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10882 if (res->e_tag_id_val > 0x3fff) {
10883 printf("e-tag-id must be equal or less than 0x3fff.\n");
10887 ret = rte_eth_dev_filter_supported(res->port_id,
10888 RTE_ETH_FILTER_L2_TUNNEL);
10890 printf("E-tag filter is not supported on port %u.\n",
10895 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10896 entry.tunnel_id = res->e_tag_id_val;
10897 entry.pool = res->dst_pool_val;
10899 ret = rte_eth_dev_filter_ctrl(res->port_id,
10900 RTE_ETH_FILTER_L2_TUNNEL,
10901 RTE_ETH_FILTER_ADD,
10904 printf("E-tag filter programming error: (%s)\n",
10908 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10909 .f = cmd_config_e_tag_filter_add_parsed,
10911 .help_str = "E-tag ... : E-tag filter add",
10913 (void *)&cmd_config_e_tag_e_tag,
10914 (void *)&cmd_config_e_tag_set,
10915 (void *)&cmd_config_e_tag_filter,
10916 (void *)&cmd_config_e_tag_add,
10917 (void *)&cmd_config_e_tag_e_tag_id,
10918 (void *)&cmd_config_e_tag_e_tag_id_val,
10919 (void *)&cmd_config_e_tag_dst_pool,
10920 (void *)&cmd_config_e_tag_dst_pool_val,
10921 (void *)&cmd_config_e_tag_port,
10922 (void *)&cmd_config_e_tag_port_id,
10928 cmd_config_e_tag_filter_del_parsed(
10929 void *parsed_result,
10930 __attribute__((unused)) struct cmdline *cl,
10931 __attribute__((unused)) void *data)
10933 struct cmd_config_e_tag_result *res = parsed_result;
10934 struct rte_eth_l2_tunnel_conf entry;
10937 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10940 if (res->e_tag_id_val > 0x3fff) {
10941 printf("e-tag-id must be less than 0x3fff.\n");
10945 ret = rte_eth_dev_filter_supported(res->port_id,
10946 RTE_ETH_FILTER_L2_TUNNEL);
10948 printf("E-tag filter is not supported on port %u.\n",
10953 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10954 entry.tunnel_id = res->e_tag_id_val;
10956 ret = rte_eth_dev_filter_ctrl(res->port_id,
10957 RTE_ETH_FILTER_L2_TUNNEL,
10958 RTE_ETH_FILTER_DELETE,
10961 printf("E-tag filter programming error: (%s)\n",
10965 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10966 .f = cmd_config_e_tag_filter_del_parsed,
10968 .help_str = "E-tag ... : E-tag filter delete",
10970 (void *)&cmd_config_e_tag_e_tag,
10971 (void *)&cmd_config_e_tag_set,
10972 (void *)&cmd_config_e_tag_filter,
10973 (void *)&cmd_config_e_tag_del,
10974 (void *)&cmd_config_e_tag_e_tag_id,
10975 (void *)&cmd_config_e_tag_e_tag_id_val,
10976 (void *)&cmd_config_e_tag_port,
10977 (void *)&cmd_config_e_tag_port_id,
10982 /* vf vlan anti spoof configuration */
10984 /* Common result structure for vf vlan anti spoof */
10985 struct cmd_vf_vlan_anti_spoof_result {
10986 cmdline_fixed_string_t set;
10987 cmdline_fixed_string_t vf;
10988 cmdline_fixed_string_t vlan;
10989 cmdline_fixed_string_t antispoof;
10992 cmdline_fixed_string_t on_off;
10995 /* Common CLI fields for vf vlan anti spoof enable disable */
10996 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10997 TOKEN_STRING_INITIALIZER
10998 (struct cmd_vf_vlan_anti_spoof_result,
11000 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11001 TOKEN_STRING_INITIALIZER
11002 (struct cmd_vf_vlan_anti_spoof_result,
11004 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11005 TOKEN_STRING_INITIALIZER
11006 (struct cmd_vf_vlan_anti_spoof_result,
11008 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11009 TOKEN_STRING_INITIALIZER
11010 (struct cmd_vf_vlan_anti_spoof_result,
11011 antispoof, "antispoof");
11012 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11013 TOKEN_NUM_INITIALIZER
11014 (struct cmd_vf_vlan_anti_spoof_result,
11016 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11017 TOKEN_NUM_INITIALIZER
11018 (struct cmd_vf_vlan_anti_spoof_result,
11020 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11021 TOKEN_STRING_INITIALIZER
11022 (struct cmd_vf_vlan_anti_spoof_result,
11026 cmd_set_vf_vlan_anti_spoof_parsed(
11027 void *parsed_result,
11028 __attribute__((unused)) struct cmdline *cl,
11029 __attribute__((unused)) void *data)
11031 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11032 int ret = -ENOTSUP;
11034 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11036 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11039 #ifdef RTE_LIBRTE_IXGBE_PMD
11040 if (ret == -ENOTSUP)
11041 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11042 res->vf_id, is_on);
11044 #ifdef RTE_LIBRTE_I40E_PMD
11045 if (ret == -ENOTSUP)
11046 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11047 res->vf_id, is_on);
11049 #ifdef RTE_LIBRTE_BNXT_PMD
11050 if (ret == -ENOTSUP)
11051 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11052 res->vf_id, is_on);
11059 printf("invalid vf_id %d\n", res->vf_id);
11062 printf("invalid port_id %d\n", res->port_id);
11065 printf("function not implemented\n");
11068 printf("programming error: (%s)\n", strerror(-ret));
11072 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11073 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11075 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11077 (void *)&cmd_vf_vlan_anti_spoof_set,
11078 (void *)&cmd_vf_vlan_anti_spoof_vf,
11079 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11080 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11081 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11082 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11083 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11088 /* vf mac anti spoof configuration */
11090 /* Common result structure for vf mac anti spoof */
11091 struct cmd_vf_mac_anti_spoof_result {
11092 cmdline_fixed_string_t set;
11093 cmdline_fixed_string_t vf;
11094 cmdline_fixed_string_t mac;
11095 cmdline_fixed_string_t antispoof;
11098 cmdline_fixed_string_t on_off;
11101 /* Common CLI fields for vf mac anti spoof enable disable */
11102 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11103 TOKEN_STRING_INITIALIZER
11104 (struct cmd_vf_mac_anti_spoof_result,
11106 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11107 TOKEN_STRING_INITIALIZER
11108 (struct cmd_vf_mac_anti_spoof_result,
11110 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11111 TOKEN_STRING_INITIALIZER
11112 (struct cmd_vf_mac_anti_spoof_result,
11114 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11115 TOKEN_STRING_INITIALIZER
11116 (struct cmd_vf_mac_anti_spoof_result,
11117 antispoof, "antispoof");
11118 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11119 TOKEN_NUM_INITIALIZER
11120 (struct cmd_vf_mac_anti_spoof_result,
11122 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11123 TOKEN_NUM_INITIALIZER
11124 (struct cmd_vf_mac_anti_spoof_result,
11126 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11127 TOKEN_STRING_INITIALIZER
11128 (struct cmd_vf_mac_anti_spoof_result,
11132 cmd_set_vf_mac_anti_spoof_parsed(
11133 void *parsed_result,
11134 __attribute__((unused)) struct cmdline *cl,
11135 __attribute__((unused)) void *data)
11137 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11138 int ret = -ENOTSUP;
11140 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11142 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11145 #ifdef RTE_LIBRTE_IXGBE_PMD
11146 if (ret == -ENOTSUP)
11147 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11148 res->vf_id, is_on);
11150 #ifdef RTE_LIBRTE_I40E_PMD
11151 if (ret == -ENOTSUP)
11152 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11153 res->vf_id, is_on);
11155 #ifdef RTE_LIBRTE_BNXT_PMD
11156 if (ret == -ENOTSUP)
11157 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11158 res->vf_id, is_on);
11165 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11168 printf("invalid port_id %d\n", res->port_id);
11171 printf("function not implemented\n");
11174 printf("programming error: (%s)\n", strerror(-ret));
11178 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11179 .f = cmd_set_vf_mac_anti_spoof_parsed,
11181 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11183 (void *)&cmd_vf_mac_anti_spoof_set,
11184 (void *)&cmd_vf_mac_anti_spoof_vf,
11185 (void *)&cmd_vf_mac_anti_spoof_mac,
11186 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11187 (void *)&cmd_vf_mac_anti_spoof_port_id,
11188 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11189 (void *)&cmd_vf_mac_anti_spoof_on_off,
11194 /* vf vlan strip queue configuration */
11196 /* Common result structure for vf mac anti spoof */
11197 struct cmd_vf_vlan_stripq_result {
11198 cmdline_fixed_string_t set;
11199 cmdline_fixed_string_t vf;
11200 cmdline_fixed_string_t vlan;
11201 cmdline_fixed_string_t stripq;
11204 cmdline_fixed_string_t on_off;
11207 /* Common CLI fields for vf vlan strip enable disable */
11208 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11209 TOKEN_STRING_INITIALIZER
11210 (struct cmd_vf_vlan_stripq_result,
11212 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11213 TOKEN_STRING_INITIALIZER
11214 (struct cmd_vf_vlan_stripq_result,
11216 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11217 TOKEN_STRING_INITIALIZER
11218 (struct cmd_vf_vlan_stripq_result,
11220 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11221 TOKEN_STRING_INITIALIZER
11222 (struct cmd_vf_vlan_stripq_result,
11224 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11225 TOKEN_NUM_INITIALIZER
11226 (struct cmd_vf_vlan_stripq_result,
11228 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11229 TOKEN_NUM_INITIALIZER
11230 (struct cmd_vf_vlan_stripq_result,
11232 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11233 TOKEN_STRING_INITIALIZER
11234 (struct cmd_vf_vlan_stripq_result,
11238 cmd_set_vf_vlan_stripq_parsed(
11239 void *parsed_result,
11240 __attribute__((unused)) struct cmdline *cl,
11241 __attribute__((unused)) void *data)
11243 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11244 int ret = -ENOTSUP;
11246 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11248 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11251 #ifdef RTE_LIBRTE_IXGBE_PMD
11252 if (ret == -ENOTSUP)
11253 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11254 res->vf_id, is_on);
11256 #ifdef RTE_LIBRTE_I40E_PMD
11257 if (ret == -ENOTSUP)
11258 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11259 res->vf_id, is_on);
11261 #ifdef RTE_LIBRTE_BNXT_PMD
11262 if (ret == -ENOTSUP)
11263 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11264 res->vf_id, is_on);
11271 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11274 printf("invalid port_id %d\n", res->port_id);
11277 printf("function not implemented\n");
11280 printf("programming error: (%s)\n", strerror(-ret));
11284 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11285 .f = cmd_set_vf_vlan_stripq_parsed,
11287 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11289 (void *)&cmd_vf_vlan_stripq_set,
11290 (void *)&cmd_vf_vlan_stripq_vf,
11291 (void *)&cmd_vf_vlan_stripq_vlan,
11292 (void *)&cmd_vf_vlan_stripq_stripq,
11293 (void *)&cmd_vf_vlan_stripq_port_id,
11294 (void *)&cmd_vf_vlan_stripq_vf_id,
11295 (void *)&cmd_vf_vlan_stripq_on_off,
11300 /* vf vlan insert configuration */
11302 /* Common result structure for vf vlan insert */
11303 struct cmd_vf_vlan_insert_result {
11304 cmdline_fixed_string_t set;
11305 cmdline_fixed_string_t vf;
11306 cmdline_fixed_string_t vlan;
11307 cmdline_fixed_string_t insert;
11313 /* Common CLI fields for vf vlan insert enable disable */
11314 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11315 TOKEN_STRING_INITIALIZER
11316 (struct cmd_vf_vlan_insert_result,
11318 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11319 TOKEN_STRING_INITIALIZER
11320 (struct cmd_vf_vlan_insert_result,
11322 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11323 TOKEN_STRING_INITIALIZER
11324 (struct cmd_vf_vlan_insert_result,
11326 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11327 TOKEN_STRING_INITIALIZER
11328 (struct cmd_vf_vlan_insert_result,
11330 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11331 TOKEN_NUM_INITIALIZER
11332 (struct cmd_vf_vlan_insert_result,
11334 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11335 TOKEN_NUM_INITIALIZER
11336 (struct cmd_vf_vlan_insert_result,
11338 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11339 TOKEN_NUM_INITIALIZER
11340 (struct cmd_vf_vlan_insert_result,
11344 cmd_set_vf_vlan_insert_parsed(
11345 void *parsed_result,
11346 __attribute__((unused)) struct cmdline *cl,
11347 __attribute__((unused)) void *data)
11349 struct cmd_vf_vlan_insert_result *res = parsed_result;
11350 int ret = -ENOTSUP;
11352 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11355 #ifdef RTE_LIBRTE_IXGBE_PMD
11356 if (ret == -ENOTSUP)
11357 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11360 #ifdef RTE_LIBRTE_I40E_PMD
11361 if (ret == -ENOTSUP)
11362 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11365 #ifdef RTE_LIBRTE_BNXT_PMD
11366 if (ret == -ENOTSUP)
11367 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11375 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11378 printf("invalid port_id %d\n", res->port_id);
11381 printf("function not implemented\n");
11384 printf("programming error: (%s)\n", strerror(-ret));
11388 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11389 .f = cmd_set_vf_vlan_insert_parsed,
11391 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11393 (void *)&cmd_vf_vlan_insert_set,
11394 (void *)&cmd_vf_vlan_insert_vf,
11395 (void *)&cmd_vf_vlan_insert_vlan,
11396 (void *)&cmd_vf_vlan_insert_insert,
11397 (void *)&cmd_vf_vlan_insert_port_id,
11398 (void *)&cmd_vf_vlan_insert_vf_id,
11399 (void *)&cmd_vf_vlan_insert_vlan_id,
11404 /* tx loopback configuration */
11406 /* Common result structure for tx loopback */
11407 struct cmd_tx_loopback_result {
11408 cmdline_fixed_string_t set;
11409 cmdline_fixed_string_t tx;
11410 cmdline_fixed_string_t loopback;
11412 cmdline_fixed_string_t on_off;
11415 /* Common CLI fields for tx loopback enable disable */
11416 cmdline_parse_token_string_t cmd_tx_loopback_set =
11417 TOKEN_STRING_INITIALIZER
11418 (struct cmd_tx_loopback_result,
11420 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11421 TOKEN_STRING_INITIALIZER
11422 (struct cmd_tx_loopback_result,
11424 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11425 TOKEN_STRING_INITIALIZER
11426 (struct cmd_tx_loopback_result,
11427 loopback, "loopback");
11428 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11429 TOKEN_NUM_INITIALIZER
11430 (struct cmd_tx_loopback_result,
11432 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11433 TOKEN_STRING_INITIALIZER
11434 (struct cmd_tx_loopback_result,
11438 cmd_set_tx_loopback_parsed(
11439 void *parsed_result,
11440 __attribute__((unused)) struct cmdline *cl,
11441 __attribute__((unused)) void *data)
11443 struct cmd_tx_loopback_result *res = parsed_result;
11444 int ret = -ENOTSUP;
11446 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11448 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11451 #ifdef RTE_LIBRTE_IXGBE_PMD
11452 if (ret == -ENOTSUP)
11453 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11455 #ifdef RTE_LIBRTE_I40E_PMD
11456 if (ret == -ENOTSUP)
11457 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11459 #ifdef RTE_LIBRTE_BNXT_PMD
11460 if (ret == -ENOTSUP)
11461 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11468 printf("invalid is_on %d\n", is_on);
11471 printf("invalid port_id %d\n", res->port_id);
11474 printf("function not implemented\n");
11477 printf("programming error: (%s)\n", strerror(-ret));
11481 cmdline_parse_inst_t cmd_set_tx_loopback = {
11482 .f = cmd_set_tx_loopback_parsed,
11484 .help_str = "set tx loopback <port_id> on|off",
11486 (void *)&cmd_tx_loopback_set,
11487 (void *)&cmd_tx_loopback_tx,
11488 (void *)&cmd_tx_loopback_loopback,
11489 (void *)&cmd_tx_loopback_port_id,
11490 (void *)&cmd_tx_loopback_on_off,
11495 /* all queues drop enable configuration */
11497 /* Common result structure for all queues drop enable */
11498 struct cmd_all_queues_drop_en_result {
11499 cmdline_fixed_string_t set;
11500 cmdline_fixed_string_t all;
11501 cmdline_fixed_string_t queues;
11502 cmdline_fixed_string_t drop;
11504 cmdline_fixed_string_t on_off;
11507 /* Common CLI fields for tx loopback enable disable */
11508 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11509 TOKEN_STRING_INITIALIZER
11510 (struct cmd_all_queues_drop_en_result,
11512 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11513 TOKEN_STRING_INITIALIZER
11514 (struct cmd_all_queues_drop_en_result,
11516 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11517 TOKEN_STRING_INITIALIZER
11518 (struct cmd_all_queues_drop_en_result,
11520 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11521 TOKEN_STRING_INITIALIZER
11522 (struct cmd_all_queues_drop_en_result,
11524 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11525 TOKEN_NUM_INITIALIZER
11526 (struct cmd_all_queues_drop_en_result,
11528 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11529 TOKEN_STRING_INITIALIZER
11530 (struct cmd_all_queues_drop_en_result,
11534 cmd_set_all_queues_drop_en_parsed(
11535 void *parsed_result,
11536 __attribute__((unused)) struct cmdline *cl,
11537 __attribute__((unused)) void *data)
11539 struct cmd_all_queues_drop_en_result *res = parsed_result;
11540 int ret = -ENOTSUP;
11541 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11543 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11546 #ifdef RTE_LIBRTE_IXGBE_PMD
11547 if (ret == -ENOTSUP)
11548 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11550 #ifdef RTE_LIBRTE_BNXT_PMD
11551 if (ret == -ENOTSUP)
11552 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11558 printf("invalid is_on %d\n", is_on);
11561 printf("invalid port_id %d\n", res->port_id);
11564 printf("function not implemented\n");
11567 printf("programming error: (%s)\n", strerror(-ret));
11571 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11572 .f = cmd_set_all_queues_drop_en_parsed,
11574 .help_str = "set all queues drop <port_id> on|off",
11576 (void *)&cmd_all_queues_drop_en_set,
11577 (void *)&cmd_all_queues_drop_en_all,
11578 (void *)&cmd_all_queues_drop_en_queues,
11579 (void *)&cmd_all_queues_drop_en_drop,
11580 (void *)&cmd_all_queues_drop_en_port_id,
11581 (void *)&cmd_all_queues_drop_en_on_off,
11586 #ifdef RTE_LIBRTE_IXGBE_PMD
11587 /* vf split drop enable configuration */
11589 /* Common result structure for vf split drop enable */
11590 struct cmd_vf_split_drop_en_result {
11591 cmdline_fixed_string_t set;
11592 cmdline_fixed_string_t vf;
11593 cmdline_fixed_string_t split;
11594 cmdline_fixed_string_t drop;
11597 cmdline_fixed_string_t on_off;
11600 /* Common CLI fields for vf split drop enable disable */
11601 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11602 TOKEN_STRING_INITIALIZER
11603 (struct cmd_vf_split_drop_en_result,
11605 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11606 TOKEN_STRING_INITIALIZER
11607 (struct cmd_vf_split_drop_en_result,
11609 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11610 TOKEN_STRING_INITIALIZER
11611 (struct cmd_vf_split_drop_en_result,
11613 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11614 TOKEN_STRING_INITIALIZER
11615 (struct cmd_vf_split_drop_en_result,
11617 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11618 TOKEN_NUM_INITIALIZER
11619 (struct cmd_vf_split_drop_en_result,
11621 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11622 TOKEN_NUM_INITIALIZER
11623 (struct cmd_vf_split_drop_en_result,
11625 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11626 TOKEN_STRING_INITIALIZER
11627 (struct cmd_vf_split_drop_en_result,
11631 cmd_set_vf_split_drop_en_parsed(
11632 void *parsed_result,
11633 __attribute__((unused)) struct cmdline *cl,
11634 __attribute__((unused)) void *data)
11636 struct cmd_vf_split_drop_en_result *res = parsed_result;
11638 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11640 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11643 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11649 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11652 printf("invalid port_id %d\n", res->port_id);
11655 printf("programming error: (%s)\n", strerror(-ret));
11659 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11660 .f = cmd_set_vf_split_drop_en_parsed,
11662 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11664 (void *)&cmd_vf_split_drop_en_set,
11665 (void *)&cmd_vf_split_drop_en_vf,
11666 (void *)&cmd_vf_split_drop_en_split,
11667 (void *)&cmd_vf_split_drop_en_drop,
11668 (void *)&cmd_vf_split_drop_en_port_id,
11669 (void *)&cmd_vf_split_drop_en_vf_id,
11670 (void *)&cmd_vf_split_drop_en_on_off,
11676 /* vf mac address configuration */
11678 /* Common result structure for vf mac address */
11679 struct cmd_set_vf_mac_addr_result {
11680 cmdline_fixed_string_t set;
11681 cmdline_fixed_string_t vf;
11682 cmdline_fixed_string_t mac;
11683 cmdline_fixed_string_t addr;
11686 struct ether_addr mac_addr;
11690 /* Common CLI fields for vf split drop enable disable */
11691 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11692 TOKEN_STRING_INITIALIZER
11693 (struct cmd_set_vf_mac_addr_result,
11695 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11696 TOKEN_STRING_INITIALIZER
11697 (struct cmd_set_vf_mac_addr_result,
11699 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11700 TOKEN_STRING_INITIALIZER
11701 (struct cmd_set_vf_mac_addr_result,
11703 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11704 TOKEN_STRING_INITIALIZER
11705 (struct cmd_set_vf_mac_addr_result,
11707 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11708 TOKEN_NUM_INITIALIZER
11709 (struct cmd_set_vf_mac_addr_result,
11711 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11712 TOKEN_NUM_INITIALIZER
11713 (struct cmd_set_vf_mac_addr_result,
11715 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11716 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11720 cmd_set_vf_mac_addr_parsed(
11721 void *parsed_result,
11722 __attribute__((unused)) struct cmdline *cl,
11723 __attribute__((unused)) void *data)
11725 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11726 int ret = -ENOTSUP;
11728 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11731 #ifdef RTE_LIBRTE_IXGBE_PMD
11732 if (ret == -ENOTSUP)
11733 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11736 #ifdef RTE_LIBRTE_I40E_PMD
11737 if (ret == -ENOTSUP)
11738 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11741 #ifdef RTE_LIBRTE_BNXT_PMD
11742 if (ret == -ENOTSUP)
11743 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11751 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11754 printf("invalid port_id %d\n", res->port_id);
11757 printf("function not implemented\n");
11760 printf("programming error: (%s)\n", strerror(-ret));
11764 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11765 .f = cmd_set_vf_mac_addr_parsed,
11767 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11769 (void *)&cmd_set_vf_mac_addr_set,
11770 (void *)&cmd_set_vf_mac_addr_vf,
11771 (void *)&cmd_set_vf_mac_addr_mac,
11772 (void *)&cmd_set_vf_mac_addr_addr,
11773 (void *)&cmd_set_vf_mac_addr_port_id,
11774 (void *)&cmd_set_vf_mac_addr_vf_id,
11775 (void *)&cmd_set_vf_mac_addr_mac_addr,
11780 #ifdef RTE_LIBRTE_IXGBE_PMD
11781 /* MACsec configuration */
11783 /* Common result structure for MACsec offload enable */
11784 struct cmd_macsec_offload_on_result {
11785 cmdline_fixed_string_t set;
11786 cmdline_fixed_string_t macsec;
11787 cmdline_fixed_string_t offload;
11789 cmdline_fixed_string_t on;
11790 cmdline_fixed_string_t encrypt;
11791 cmdline_fixed_string_t en_on_off;
11792 cmdline_fixed_string_t replay_protect;
11793 cmdline_fixed_string_t rp_on_off;
11796 /* Common CLI fields for MACsec offload disable */
11797 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11798 TOKEN_STRING_INITIALIZER
11799 (struct cmd_macsec_offload_on_result,
11801 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11802 TOKEN_STRING_INITIALIZER
11803 (struct cmd_macsec_offload_on_result,
11805 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11806 TOKEN_STRING_INITIALIZER
11807 (struct cmd_macsec_offload_on_result,
11808 offload, "offload");
11809 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11810 TOKEN_NUM_INITIALIZER
11811 (struct cmd_macsec_offload_on_result,
11813 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11814 TOKEN_STRING_INITIALIZER
11815 (struct cmd_macsec_offload_on_result,
11817 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11818 TOKEN_STRING_INITIALIZER
11819 (struct cmd_macsec_offload_on_result,
11820 encrypt, "encrypt");
11821 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11822 TOKEN_STRING_INITIALIZER
11823 (struct cmd_macsec_offload_on_result,
11824 en_on_off, "on#off");
11825 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11826 TOKEN_STRING_INITIALIZER
11827 (struct cmd_macsec_offload_on_result,
11828 replay_protect, "replay-protect");
11829 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11830 TOKEN_STRING_INITIALIZER
11831 (struct cmd_macsec_offload_on_result,
11832 rp_on_off, "on#off");
11835 cmd_set_macsec_offload_on_parsed(
11836 void *parsed_result,
11837 __attribute__((unused)) struct cmdline *cl,
11838 __attribute__((unused)) void *data)
11840 struct cmd_macsec_offload_on_result *res = parsed_result;
11842 portid_t port_id = res->port_id;
11843 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11844 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11846 if (port_id_is_invalid(port_id, ENABLED_WARN))
11849 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11850 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11856 printf("invalid port_id %d\n", port_id);
11859 printf("programming error: (%s)\n", strerror(-ret));
11863 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11864 .f = cmd_set_macsec_offload_on_parsed,
11866 .help_str = "set macsec offload <port_id> on "
11867 "encrypt on|off replay-protect on|off",
11869 (void *)&cmd_macsec_offload_on_set,
11870 (void *)&cmd_macsec_offload_on_macsec,
11871 (void *)&cmd_macsec_offload_on_offload,
11872 (void *)&cmd_macsec_offload_on_port_id,
11873 (void *)&cmd_macsec_offload_on_on,
11874 (void *)&cmd_macsec_offload_on_encrypt,
11875 (void *)&cmd_macsec_offload_on_en_on_off,
11876 (void *)&cmd_macsec_offload_on_replay_protect,
11877 (void *)&cmd_macsec_offload_on_rp_on_off,
11882 /* Common result structure for MACsec offload disable */
11883 struct cmd_macsec_offload_off_result {
11884 cmdline_fixed_string_t set;
11885 cmdline_fixed_string_t macsec;
11886 cmdline_fixed_string_t offload;
11888 cmdline_fixed_string_t off;
11891 /* Common CLI fields for MACsec offload disable */
11892 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11893 TOKEN_STRING_INITIALIZER
11894 (struct cmd_macsec_offload_off_result,
11896 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11897 TOKEN_STRING_INITIALIZER
11898 (struct cmd_macsec_offload_off_result,
11900 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11901 TOKEN_STRING_INITIALIZER
11902 (struct cmd_macsec_offload_off_result,
11903 offload, "offload");
11904 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11905 TOKEN_NUM_INITIALIZER
11906 (struct cmd_macsec_offload_off_result,
11908 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11909 TOKEN_STRING_INITIALIZER
11910 (struct cmd_macsec_offload_off_result,
11914 cmd_set_macsec_offload_off_parsed(
11915 void *parsed_result,
11916 __attribute__((unused)) struct cmdline *cl,
11917 __attribute__((unused)) void *data)
11919 struct cmd_macsec_offload_off_result *res = parsed_result;
11921 portid_t port_id = res->port_id;
11923 if (port_id_is_invalid(port_id, ENABLED_WARN))
11926 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11927 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11933 printf("invalid port_id %d\n", port_id);
11936 printf("programming error: (%s)\n", strerror(-ret));
11940 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11941 .f = cmd_set_macsec_offload_off_parsed,
11943 .help_str = "set macsec offload <port_id> off",
11945 (void *)&cmd_macsec_offload_off_set,
11946 (void *)&cmd_macsec_offload_off_macsec,
11947 (void *)&cmd_macsec_offload_off_offload,
11948 (void *)&cmd_macsec_offload_off_port_id,
11949 (void *)&cmd_macsec_offload_off_off,
11954 /* Common result structure for MACsec secure connection configure */
11955 struct cmd_macsec_sc_result {
11956 cmdline_fixed_string_t set;
11957 cmdline_fixed_string_t macsec;
11958 cmdline_fixed_string_t sc;
11959 cmdline_fixed_string_t tx_rx;
11961 struct ether_addr mac;
11965 /* Common CLI fields for MACsec secure connection configure */
11966 cmdline_parse_token_string_t cmd_macsec_sc_set =
11967 TOKEN_STRING_INITIALIZER
11968 (struct cmd_macsec_sc_result,
11970 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11971 TOKEN_STRING_INITIALIZER
11972 (struct cmd_macsec_sc_result,
11974 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11975 TOKEN_STRING_INITIALIZER
11976 (struct cmd_macsec_sc_result,
11978 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11979 TOKEN_STRING_INITIALIZER
11980 (struct cmd_macsec_sc_result,
11982 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11983 TOKEN_NUM_INITIALIZER
11984 (struct cmd_macsec_sc_result,
11986 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11987 TOKEN_ETHERADDR_INITIALIZER
11988 (struct cmd_macsec_sc_result,
11990 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11991 TOKEN_NUM_INITIALIZER
11992 (struct cmd_macsec_sc_result,
11996 cmd_set_macsec_sc_parsed(
11997 void *parsed_result,
11998 __attribute__((unused)) struct cmdline *cl,
11999 __attribute__((unused)) void *data)
12001 struct cmd_macsec_sc_result *res = parsed_result;
12003 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12006 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12007 res->mac.addr_bytes) :
12008 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12009 res->mac.addr_bytes, res->pi);
12014 printf("invalid port_id %d\n", res->port_id);
12017 printf("programming error: (%s)\n", strerror(-ret));
12021 cmdline_parse_inst_t cmd_set_macsec_sc = {
12022 .f = cmd_set_macsec_sc_parsed,
12024 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12026 (void *)&cmd_macsec_sc_set,
12027 (void *)&cmd_macsec_sc_macsec,
12028 (void *)&cmd_macsec_sc_sc,
12029 (void *)&cmd_macsec_sc_tx_rx,
12030 (void *)&cmd_macsec_sc_port_id,
12031 (void *)&cmd_macsec_sc_mac,
12032 (void *)&cmd_macsec_sc_pi,
12037 /* Common result structure for MACsec secure connection configure */
12038 struct cmd_macsec_sa_result {
12039 cmdline_fixed_string_t set;
12040 cmdline_fixed_string_t macsec;
12041 cmdline_fixed_string_t sa;
12042 cmdline_fixed_string_t tx_rx;
12047 cmdline_fixed_string_t key;
12050 /* Common CLI fields for MACsec secure connection configure */
12051 cmdline_parse_token_string_t cmd_macsec_sa_set =
12052 TOKEN_STRING_INITIALIZER
12053 (struct cmd_macsec_sa_result,
12055 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12056 TOKEN_STRING_INITIALIZER
12057 (struct cmd_macsec_sa_result,
12059 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12060 TOKEN_STRING_INITIALIZER
12061 (struct cmd_macsec_sa_result,
12063 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12064 TOKEN_STRING_INITIALIZER
12065 (struct cmd_macsec_sa_result,
12067 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12068 TOKEN_NUM_INITIALIZER
12069 (struct cmd_macsec_sa_result,
12071 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12072 TOKEN_NUM_INITIALIZER
12073 (struct cmd_macsec_sa_result,
12075 cmdline_parse_token_num_t cmd_macsec_sa_an =
12076 TOKEN_NUM_INITIALIZER
12077 (struct cmd_macsec_sa_result,
12079 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12080 TOKEN_NUM_INITIALIZER
12081 (struct cmd_macsec_sa_result,
12083 cmdline_parse_token_string_t cmd_macsec_sa_key =
12084 TOKEN_STRING_INITIALIZER
12085 (struct cmd_macsec_sa_result,
12089 cmd_set_macsec_sa_parsed(
12090 void *parsed_result,
12091 __attribute__((unused)) struct cmdline *cl,
12092 __attribute__((unused)) void *data)
12094 struct cmd_macsec_sa_result *res = parsed_result;
12096 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12097 uint8_t key[16] = { 0 };
12103 key_len = strlen(res->key) / 2;
12107 for (i = 0; i < key_len; i++) {
12108 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12111 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12114 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12118 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12119 res->idx, res->an, res->pn, key) :
12120 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12121 res->idx, res->an, res->pn, key);
12126 printf("invalid idx %d or an %d\n", res->idx, res->an);
12129 printf("invalid port_id %d\n", res->port_id);
12132 printf("programming error: (%s)\n", strerror(-ret));
12136 cmdline_parse_inst_t cmd_set_macsec_sa = {
12137 .f = cmd_set_macsec_sa_parsed,
12139 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12141 (void *)&cmd_macsec_sa_set,
12142 (void *)&cmd_macsec_sa_macsec,
12143 (void *)&cmd_macsec_sa_sa,
12144 (void *)&cmd_macsec_sa_tx_rx,
12145 (void *)&cmd_macsec_sa_port_id,
12146 (void *)&cmd_macsec_sa_idx,
12147 (void *)&cmd_macsec_sa_an,
12148 (void *)&cmd_macsec_sa_pn,
12149 (void *)&cmd_macsec_sa_key,
12155 /* VF unicast promiscuous mode configuration */
12157 /* Common result structure for VF unicast promiscuous mode */
12158 struct cmd_vf_promisc_result {
12159 cmdline_fixed_string_t set;
12160 cmdline_fixed_string_t vf;
12161 cmdline_fixed_string_t promisc;
12164 cmdline_fixed_string_t on_off;
12167 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12168 cmdline_parse_token_string_t cmd_vf_promisc_set =
12169 TOKEN_STRING_INITIALIZER
12170 (struct cmd_vf_promisc_result,
12172 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12173 TOKEN_STRING_INITIALIZER
12174 (struct cmd_vf_promisc_result,
12176 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12177 TOKEN_STRING_INITIALIZER
12178 (struct cmd_vf_promisc_result,
12179 promisc, "promisc");
12180 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12181 TOKEN_NUM_INITIALIZER
12182 (struct cmd_vf_promisc_result,
12184 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12185 TOKEN_NUM_INITIALIZER
12186 (struct cmd_vf_promisc_result,
12188 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12189 TOKEN_STRING_INITIALIZER
12190 (struct cmd_vf_promisc_result,
12194 cmd_set_vf_promisc_parsed(
12195 void *parsed_result,
12196 __attribute__((unused)) struct cmdline *cl,
12197 __attribute__((unused)) void *data)
12199 struct cmd_vf_promisc_result *res = parsed_result;
12200 int ret = -ENOTSUP;
12202 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12204 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12207 #ifdef RTE_LIBRTE_I40E_PMD
12208 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12209 res->vf_id, is_on);
12216 printf("invalid vf_id %d\n", res->vf_id);
12219 printf("invalid port_id %d\n", res->port_id);
12222 printf("function not implemented\n");
12225 printf("programming error: (%s)\n", strerror(-ret));
12229 cmdline_parse_inst_t cmd_set_vf_promisc = {
12230 .f = cmd_set_vf_promisc_parsed,
12232 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12233 "Set unicast promiscuous mode for a VF from the PF",
12235 (void *)&cmd_vf_promisc_set,
12236 (void *)&cmd_vf_promisc_vf,
12237 (void *)&cmd_vf_promisc_promisc,
12238 (void *)&cmd_vf_promisc_port_id,
12239 (void *)&cmd_vf_promisc_vf_id,
12240 (void *)&cmd_vf_promisc_on_off,
12245 /* VF multicast promiscuous mode configuration */
12247 /* Common result structure for VF multicast promiscuous mode */
12248 struct cmd_vf_allmulti_result {
12249 cmdline_fixed_string_t set;
12250 cmdline_fixed_string_t vf;
12251 cmdline_fixed_string_t allmulti;
12254 cmdline_fixed_string_t on_off;
12257 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12258 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12259 TOKEN_STRING_INITIALIZER
12260 (struct cmd_vf_allmulti_result,
12262 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12263 TOKEN_STRING_INITIALIZER
12264 (struct cmd_vf_allmulti_result,
12266 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12267 TOKEN_STRING_INITIALIZER
12268 (struct cmd_vf_allmulti_result,
12269 allmulti, "allmulti");
12270 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12271 TOKEN_NUM_INITIALIZER
12272 (struct cmd_vf_allmulti_result,
12274 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12275 TOKEN_NUM_INITIALIZER
12276 (struct cmd_vf_allmulti_result,
12278 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12279 TOKEN_STRING_INITIALIZER
12280 (struct cmd_vf_allmulti_result,
12284 cmd_set_vf_allmulti_parsed(
12285 void *parsed_result,
12286 __attribute__((unused)) struct cmdline *cl,
12287 __attribute__((unused)) void *data)
12289 struct cmd_vf_allmulti_result *res = parsed_result;
12290 int ret = -ENOTSUP;
12292 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12294 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12297 #ifdef RTE_LIBRTE_I40E_PMD
12298 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12299 res->vf_id, is_on);
12306 printf("invalid vf_id %d\n", res->vf_id);
12309 printf("invalid port_id %d\n", res->port_id);
12312 printf("function not implemented\n");
12315 printf("programming error: (%s)\n", strerror(-ret));
12319 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12320 .f = cmd_set_vf_allmulti_parsed,
12322 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12323 "Set multicast promiscuous mode for a VF from the PF",
12325 (void *)&cmd_vf_allmulti_set,
12326 (void *)&cmd_vf_allmulti_vf,
12327 (void *)&cmd_vf_allmulti_allmulti,
12328 (void *)&cmd_vf_allmulti_port_id,
12329 (void *)&cmd_vf_allmulti_vf_id,
12330 (void *)&cmd_vf_allmulti_on_off,
12335 /* vf broadcast mode configuration */
12337 /* Common result structure for vf broadcast */
12338 struct cmd_set_vf_broadcast_result {
12339 cmdline_fixed_string_t set;
12340 cmdline_fixed_string_t vf;
12341 cmdline_fixed_string_t broadcast;
12344 cmdline_fixed_string_t on_off;
12347 /* Common CLI fields for vf broadcast enable disable */
12348 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12349 TOKEN_STRING_INITIALIZER
12350 (struct cmd_set_vf_broadcast_result,
12352 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12353 TOKEN_STRING_INITIALIZER
12354 (struct cmd_set_vf_broadcast_result,
12356 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12357 TOKEN_STRING_INITIALIZER
12358 (struct cmd_set_vf_broadcast_result,
12359 broadcast, "broadcast");
12360 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12361 TOKEN_NUM_INITIALIZER
12362 (struct cmd_set_vf_broadcast_result,
12364 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12365 TOKEN_NUM_INITIALIZER
12366 (struct cmd_set_vf_broadcast_result,
12368 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12369 TOKEN_STRING_INITIALIZER
12370 (struct cmd_set_vf_broadcast_result,
12374 cmd_set_vf_broadcast_parsed(
12375 void *parsed_result,
12376 __attribute__((unused)) struct cmdline *cl,
12377 __attribute__((unused)) void *data)
12379 struct cmd_set_vf_broadcast_result *res = parsed_result;
12380 int ret = -ENOTSUP;
12382 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12384 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12387 #ifdef RTE_LIBRTE_I40E_PMD
12388 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12389 res->vf_id, is_on);
12396 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12399 printf("invalid port_id %d\n", res->port_id);
12402 printf("function not implemented\n");
12405 printf("programming error: (%s)\n", strerror(-ret));
12409 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12410 .f = cmd_set_vf_broadcast_parsed,
12412 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12414 (void *)&cmd_set_vf_broadcast_set,
12415 (void *)&cmd_set_vf_broadcast_vf,
12416 (void *)&cmd_set_vf_broadcast_broadcast,
12417 (void *)&cmd_set_vf_broadcast_port_id,
12418 (void *)&cmd_set_vf_broadcast_vf_id,
12419 (void *)&cmd_set_vf_broadcast_on_off,
12424 /* vf vlan tag configuration */
12426 /* Common result structure for vf vlan tag */
12427 struct cmd_set_vf_vlan_tag_result {
12428 cmdline_fixed_string_t set;
12429 cmdline_fixed_string_t vf;
12430 cmdline_fixed_string_t vlan;
12431 cmdline_fixed_string_t tag;
12434 cmdline_fixed_string_t on_off;
12437 /* Common CLI fields for vf vlan tag enable disable */
12438 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12439 TOKEN_STRING_INITIALIZER
12440 (struct cmd_set_vf_vlan_tag_result,
12442 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12443 TOKEN_STRING_INITIALIZER
12444 (struct cmd_set_vf_vlan_tag_result,
12446 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12447 TOKEN_STRING_INITIALIZER
12448 (struct cmd_set_vf_vlan_tag_result,
12450 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12451 TOKEN_STRING_INITIALIZER
12452 (struct cmd_set_vf_vlan_tag_result,
12454 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12455 TOKEN_NUM_INITIALIZER
12456 (struct cmd_set_vf_vlan_tag_result,
12458 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12459 TOKEN_NUM_INITIALIZER
12460 (struct cmd_set_vf_vlan_tag_result,
12462 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12463 TOKEN_STRING_INITIALIZER
12464 (struct cmd_set_vf_vlan_tag_result,
12468 cmd_set_vf_vlan_tag_parsed(
12469 void *parsed_result,
12470 __attribute__((unused)) struct cmdline *cl,
12471 __attribute__((unused)) void *data)
12473 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12474 int ret = -ENOTSUP;
12476 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12478 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12481 #ifdef RTE_LIBRTE_I40E_PMD
12482 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12483 res->vf_id, is_on);
12490 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12493 printf("invalid port_id %d\n", res->port_id);
12496 printf("function not implemented\n");
12499 printf("programming error: (%s)\n", strerror(-ret));
12503 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12504 .f = cmd_set_vf_vlan_tag_parsed,
12506 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12508 (void *)&cmd_set_vf_vlan_tag_set,
12509 (void *)&cmd_set_vf_vlan_tag_vf,
12510 (void *)&cmd_set_vf_vlan_tag_vlan,
12511 (void *)&cmd_set_vf_vlan_tag_tag,
12512 (void *)&cmd_set_vf_vlan_tag_port_id,
12513 (void *)&cmd_set_vf_vlan_tag_vf_id,
12514 (void *)&cmd_set_vf_vlan_tag_on_off,
12519 /* Common definition of VF and TC TX bandwidth configuration */
12520 struct cmd_vf_tc_bw_result {
12521 cmdline_fixed_string_t set;
12522 cmdline_fixed_string_t vf;
12523 cmdline_fixed_string_t tc;
12524 cmdline_fixed_string_t tx;
12525 cmdline_fixed_string_t min_bw;
12526 cmdline_fixed_string_t max_bw;
12527 cmdline_fixed_string_t strict_link_prio;
12532 cmdline_fixed_string_t bw_list;
12536 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12537 TOKEN_STRING_INITIALIZER
12538 (struct cmd_vf_tc_bw_result,
12540 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12541 TOKEN_STRING_INITIALIZER
12542 (struct cmd_vf_tc_bw_result,
12544 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12545 TOKEN_STRING_INITIALIZER
12546 (struct cmd_vf_tc_bw_result,
12548 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12549 TOKEN_STRING_INITIALIZER
12550 (struct cmd_vf_tc_bw_result,
12552 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12553 TOKEN_STRING_INITIALIZER
12554 (struct cmd_vf_tc_bw_result,
12555 strict_link_prio, "strict-link-priority");
12556 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12557 TOKEN_STRING_INITIALIZER
12558 (struct cmd_vf_tc_bw_result,
12559 min_bw, "min-bandwidth");
12560 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12561 TOKEN_STRING_INITIALIZER
12562 (struct cmd_vf_tc_bw_result,
12563 max_bw, "max-bandwidth");
12564 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12565 TOKEN_NUM_INITIALIZER
12566 (struct cmd_vf_tc_bw_result,
12568 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12569 TOKEN_NUM_INITIALIZER
12570 (struct cmd_vf_tc_bw_result,
12572 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12573 TOKEN_NUM_INITIALIZER
12574 (struct cmd_vf_tc_bw_result,
12576 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12577 TOKEN_NUM_INITIALIZER
12578 (struct cmd_vf_tc_bw_result,
12580 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12581 TOKEN_STRING_INITIALIZER
12582 (struct cmd_vf_tc_bw_result,
12584 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12585 TOKEN_NUM_INITIALIZER
12586 (struct cmd_vf_tc_bw_result,
12589 /* VF max bandwidth setting */
12591 cmd_vf_max_bw_parsed(
12592 void *parsed_result,
12593 __attribute__((unused)) struct cmdline *cl,
12594 __attribute__((unused)) void *data)
12596 struct cmd_vf_tc_bw_result *res = parsed_result;
12597 int ret = -ENOTSUP;
12599 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12602 #ifdef RTE_LIBRTE_I40E_PMD
12603 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12604 res->vf_id, res->bw);
12611 printf("invalid vf_id %d or bandwidth %d\n",
12612 res->vf_id, res->bw);
12615 printf("invalid port_id %d\n", res->port_id);
12618 printf("function not implemented\n");
12621 printf("programming error: (%s)\n", strerror(-ret));
12625 cmdline_parse_inst_t cmd_vf_max_bw = {
12626 .f = cmd_vf_max_bw_parsed,
12628 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12630 (void *)&cmd_vf_tc_bw_set,
12631 (void *)&cmd_vf_tc_bw_vf,
12632 (void *)&cmd_vf_tc_bw_tx,
12633 (void *)&cmd_vf_tc_bw_max_bw,
12634 (void *)&cmd_vf_tc_bw_port_id,
12635 (void *)&cmd_vf_tc_bw_vf_id,
12636 (void *)&cmd_vf_tc_bw_bw,
12642 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12647 const char *p, *p0 = str;
12654 p = strchr(p0, '(');
12656 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12660 p0 = strchr(p, ')');
12662 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12666 if (size >= sizeof(s)) {
12667 printf("The string size exceeds the internal buffer size\n");
12670 snprintf(s, sizeof(s), "%.*s", size, p);
12671 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12673 printf("Failed to get the bandwidth list. ");
12677 for (i = 0; i < ret; i++)
12678 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12683 /* TC min bandwidth setting */
12685 cmd_vf_tc_min_bw_parsed(
12686 void *parsed_result,
12687 __attribute__((unused)) struct cmdline *cl,
12688 __attribute__((unused)) void *data)
12690 struct cmd_vf_tc_bw_result *res = parsed_result;
12693 int ret = -ENOTSUP;
12695 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12698 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12702 #ifdef RTE_LIBRTE_I40E_PMD
12703 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12711 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12714 printf("invalid port_id %d\n", res->port_id);
12717 printf("function not implemented\n");
12720 printf("programming error: (%s)\n", strerror(-ret));
12724 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12725 .f = cmd_vf_tc_min_bw_parsed,
12727 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12728 " <bw1, bw2, ...>",
12730 (void *)&cmd_vf_tc_bw_set,
12731 (void *)&cmd_vf_tc_bw_vf,
12732 (void *)&cmd_vf_tc_bw_tc,
12733 (void *)&cmd_vf_tc_bw_tx,
12734 (void *)&cmd_vf_tc_bw_min_bw,
12735 (void *)&cmd_vf_tc_bw_port_id,
12736 (void *)&cmd_vf_tc_bw_vf_id,
12737 (void *)&cmd_vf_tc_bw_bw_list,
12743 cmd_tc_min_bw_parsed(
12744 void *parsed_result,
12745 __attribute__((unused)) struct cmdline *cl,
12746 __attribute__((unused)) void *data)
12748 struct cmd_vf_tc_bw_result *res = parsed_result;
12749 struct rte_port *port;
12752 int ret = -ENOTSUP;
12754 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12757 port = &ports[res->port_id];
12758 /** Check if the port is not started **/
12759 if (port->port_status != RTE_PORT_STOPPED) {
12760 printf("Please stop port %d first\n", res->port_id);
12764 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12768 #ifdef RTE_LIBRTE_IXGBE_PMD
12769 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12776 printf("invalid bandwidth\n");
12779 printf("invalid port_id %d\n", res->port_id);
12782 printf("function not implemented\n");
12785 printf("programming error: (%s)\n", strerror(-ret));
12789 cmdline_parse_inst_t cmd_tc_min_bw = {
12790 .f = cmd_tc_min_bw_parsed,
12792 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12794 (void *)&cmd_vf_tc_bw_set,
12795 (void *)&cmd_vf_tc_bw_tc,
12796 (void *)&cmd_vf_tc_bw_tx,
12797 (void *)&cmd_vf_tc_bw_min_bw,
12798 (void *)&cmd_vf_tc_bw_port_id,
12799 (void *)&cmd_vf_tc_bw_bw_list,
12804 /* TC max bandwidth setting */
12806 cmd_vf_tc_max_bw_parsed(
12807 void *parsed_result,
12808 __attribute__((unused)) struct cmdline *cl,
12809 __attribute__((unused)) void *data)
12811 struct cmd_vf_tc_bw_result *res = parsed_result;
12812 int ret = -ENOTSUP;
12814 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12817 #ifdef RTE_LIBRTE_I40E_PMD
12818 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12819 res->tc_no, res->bw);
12826 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12827 res->vf_id, res->tc_no, res->bw);
12830 printf("invalid port_id %d\n", res->port_id);
12833 printf("function not implemented\n");
12836 printf("programming error: (%s)\n", strerror(-ret));
12840 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12841 .f = cmd_vf_tc_max_bw_parsed,
12843 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12846 (void *)&cmd_vf_tc_bw_set,
12847 (void *)&cmd_vf_tc_bw_vf,
12848 (void *)&cmd_vf_tc_bw_tc,
12849 (void *)&cmd_vf_tc_bw_tx,
12850 (void *)&cmd_vf_tc_bw_max_bw,
12851 (void *)&cmd_vf_tc_bw_port_id,
12852 (void *)&cmd_vf_tc_bw_vf_id,
12853 (void *)&cmd_vf_tc_bw_tc_no,
12854 (void *)&cmd_vf_tc_bw_bw,
12859 /* Strict link priority scheduling mode setting */
12861 cmd_strict_link_prio_parsed(
12862 void *parsed_result,
12863 __attribute__((unused)) struct cmdline *cl,
12864 __attribute__((unused)) void *data)
12866 struct cmd_vf_tc_bw_result *res = parsed_result;
12867 int ret = -ENOTSUP;
12869 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12872 #ifdef RTE_LIBRTE_I40E_PMD
12873 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12880 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12883 printf("invalid port_id %d\n", res->port_id);
12886 printf("function not implemented\n");
12889 printf("programming error: (%s)\n", strerror(-ret));
12893 cmdline_parse_inst_t cmd_strict_link_prio = {
12894 .f = cmd_strict_link_prio_parsed,
12896 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12898 (void *)&cmd_vf_tc_bw_set,
12899 (void *)&cmd_vf_tc_bw_tx,
12900 (void *)&cmd_vf_tc_bw_strict_link_prio,
12901 (void *)&cmd_vf_tc_bw_port_id,
12902 (void *)&cmd_vf_tc_bw_tc_map,
12907 /* Load dynamic device personalization*/
12908 struct cmd_ddp_add_result {
12909 cmdline_fixed_string_t ddp;
12910 cmdline_fixed_string_t add;
12915 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12916 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12917 cmdline_parse_token_string_t cmd_ddp_add_add =
12918 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12919 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12920 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12921 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12922 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12925 cmd_ddp_add_parsed(
12926 void *parsed_result,
12927 __attribute__((unused)) struct cmdline *cl,
12928 __attribute__((unused)) void *data)
12930 struct cmd_ddp_add_result *res = parsed_result;
12933 int ret = -ENOTSUP;
12935 if (res->port_id > nb_ports) {
12936 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12940 if (!all_ports_stopped()) {
12941 printf("Please stop all ports first\n");
12945 buff = open_ddp_package_file(res->filepath, &size);
12949 #ifdef RTE_LIBRTE_I40E_PMD
12950 if (ret == -ENOTSUP)
12951 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12953 RTE_PMD_I40E_PKG_OP_WR_ADD);
12957 printf("Failed to load profile.\n");
12959 printf("Profile has already existed.\n");
12961 close_ddp_package_file(buff);
12964 cmdline_parse_inst_t cmd_ddp_add = {
12965 .f = cmd_ddp_add_parsed,
12967 .help_str = "ddp add <port_id> <profile_path>",
12969 (void *)&cmd_ddp_add_ddp,
12970 (void *)&cmd_ddp_add_add,
12971 (void *)&cmd_ddp_add_port_id,
12972 (void *)&cmd_ddp_add_filepath,
12977 /* Get dynamic device personalization profile info list*/
12978 #define PROFILE_INFO_SIZE 48
12979 #define MAX_PROFILE_NUM 16
12981 struct cmd_ddp_get_list_result {
12982 cmdline_fixed_string_t ddp;
12983 cmdline_fixed_string_t get;
12984 cmdline_fixed_string_t list;
12988 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
12989 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
12990 cmdline_parse_token_string_t cmd_ddp_get_list_get =
12991 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
12992 cmdline_parse_token_string_t cmd_ddp_get_list_list =
12993 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
12994 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
12995 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
12998 cmd_ddp_get_list_parsed(
12999 void *parsed_result,
13000 __attribute__((unused)) struct cmdline *cl,
13001 __attribute__((unused)) void *data)
13003 struct cmd_ddp_get_list_result *res = parsed_result;
13004 #ifdef RTE_LIBRTE_I40E_PMD
13005 struct rte_pmd_i40e_profile_list *p_list;
13006 struct rte_pmd_i40e_profile_info *p_info;
13011 int ret = -ENOTSUP;
13013 if (res->port_id > nb_ports) {
13014 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13018 #ifdef RTE_LIBRTE_I40E_PMD
13019 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13020 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13022 printf("%s: Failed to malloc buffer\n", __func__);
13024 if (ret == -ENOTSUP)
13025 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13026 (uint8_t *)p_list, size);
13029 p_num = p_list->p_count;
13030 printf("Profile number is: %d\n\n", p_num);
13032 for (i = 0; i < p_num; i++) {
13033 p_info = &p_list->p_info[i];
13034 printf("Profile %d:\n", i);
13035 printf("Track id: 0x%x\n", p_info->track_id);
13036 printf("Version: %d.%d.%d.%d\n",
13037 p_info->version.major,
13038 p_info->version.minor,
13039 p_info->version.update,
13040 p_info->version.draft);
13041 printf("Profile name: %s\n\n", p_info->name);
13049 printf("Failed to get ddp list\n");
13052 cmdline_parse_inst_t cmd_ddp_get_list = {
13053 .f = cmd_ddp_get_list_parsed,
13055 .help_str = "ddp get list <port_id>",
13057 (void *)&cmd_ddp_get_list_ddp,
13058 (void *)&cmd_ddp_get_list_get,
13059 (void *)&cmd_ddp_get_list_list,
13060 (void *)&cmd_ddp_get_list_port_id,
13065 /* show vf stats */
13067 /* Common result structure for show vf stats */
13068 struct cmd_show_vf_stats_result {
13069 cmdline_fixed_string_t show;
13070 cmdline_fixed_string_t vf;
13071 cmdline_fixed_string_t stats;
13076 /* Common CLI fields show vf stats*/
13077 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13078 TOKEN_STRING_INITIALIZER
13079 (struct cmd_show_vf_stats_result,
13081 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13082 TOKEN_STRING_INITIALIZER
13083 (struct cmd_show_vf_stats_result,
13085 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13086 TOKEN_STRING_INITIALIZER
13087 (struct cmd_show_vf_stats_result,
13089 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13090 TOKEN_NUM_INITIALIZER
13091 (struct cmd_show_vf_stats_result,
13093 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13094 TOKEN_NUM_INITIALIZER
13095 (struct cmd_show_vf_stats_result,
13099 cmd_show_vf_stats_parsed(
13100 void *parsed_result,
13101 __attribute__((unused)) struct cmdline *cl,
13102 __attribute__((unused)) void *data)
13104 struct cmd_show_vf_stats_result *res = parsed_result;
13105 struct rte_eth_stats stats;
13106 int ret = -ENOTSUP;
13107 static const char *nic_stats_border = "########################";
13109 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13112 memset(&stats, 0, sizeof(stats));
13114 #ifdef RTE_LIBRTE_I40E_PMD
13115 if (ret == -ENOTSUP)
13116 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13120 #ifdef RTE_LIBRTE_BNXT_PMD
13121 if (ret == -ENOTSUP)
13122 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
13131 printf("invalid vf_id %d\n", res->vf_id);
13134 printf("invalid port_id %d\n", res->port_id);
13137 printf("function not implemented\n");
13140 printf("programming error: (%s)\n", strerror(-ret));
13143 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13144 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13146 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13148 stats.ipackets, stats.imissed, stats.ibytes);
13149 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13150 printf(" RX-nombuf: %-10"PRIu64"\n",
13152 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13154 stats.opackets, stats.oerrors, stats.obytes);
13156 printf(" %s############################%s\n",
13157 nic_stats_border, nic_stats_border);
13160 cmdline_parse_inst_t cmd_show_vf_stats = {
13161 .f = cmd_show_vf_stats_parsed,
13163 .help_str = "show vf stats <port_id> <vf_id>",
13165 (void *)&cmd_show_vf_stats_show,
13166 (void *)&cmd_show_vf_stats_vf,
13167 (void *)&cmd_show_vf_stats_stats,
13168 (void *)&cmd_show_vf_stats_port_id,
13169 (void *)&cmd_show_vf_stats_vf_id,
13174 /* clear vf stats */
13176 /* Common result structure for clear vf stats */
13177 struct cmd_clear_vf_stats_result {
13178 cmdline_fixed_string_t clear;
13179 cmdline_fixed_string_t vf;
13180 cmdline_fixed_string_t stats;
13185 /* Common CLI fields clear vf stats*/
13186 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13187 TOKEN_STRING_INITIALIZER
13188 (struct cmd_clear_vf_stats_result,
13190 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13191 TOKEN_STRING_INITIALIZER
13192 (struct cmd_clear_vf_stats_result,
13194 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13195 TOKEN_STRING_INITIALIZER
13196 (struct cmd_clear_vf_stats_result,
13198 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13199 TOKEN_NUM_INITIALIZER
13200 (struct cmd_clear_vf_stats_result,
13202 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13203 TOKEN_NUM_INITIALIZER
13204 (struct cmd_clear_vf_stats_result,
13208 cmd_clear_vf_stats_parsed(
13209 void *parsed_result,
13210 __attribute__((unused)) struct cmdline *cl,
13211 __attribute__((unused)) void *data)
13213 struct cmd_clear_vf_stats_result *res = parsed_result;
13214 int ret = -ENOTSUP;
13216 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13219 #ifdef RTE_LIBRTE_I40E_PMD
13220 if (ret == -ENOTSUP)
13221 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13224 #ifdef RTE_LIBRTE_BNXT_PMD
13225 if (ret == -ENOTSUP)
13226 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
13234 printf("invalid vf_id %d\n", res->vf_id);
13237 printf("invalid port_id %d\n", res->port_id);
13240 printf("function not implemented\n");
13243 printf("programming error: (%s)\n", strerror(-ret));
13247 cmdline_parse_inst_t cmd_clear_vf_stats = {
13248 .f = cmd_clear_vf_stats_parsed,
13250 .help_str = "clear vf stats <port_id> <vf_id>",
13252 (void *)&cmd_clear_vf_stats_clear,
13253 (void *)&cmd_clear_vf_stats_vf,
13254 (void *)&cmd_clear_vf_stats_stats,
13255 (void *)&cmd_clear_vf_stats_port_id,
13256 (void *)&cmd_clear_vf_stats_vf_id,
13261 /* ptype mapping get */
13263 /* Common result structure for ptype mapping get */
13264 struct cmd_ptype_mapping_get_result {
13265 cmdline_fixed_string_t ptype;
13266 cmdline_fixed_string_t mapping;
13267 cmdline_fixed_string_t get;
13269 uint8_t valid_only;
13272 /* Common CLI fields for ptype mapping get */
13273 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
13274 TOKEN_STRING_INITIALIZER
13275 (struct cmd_ptype_mapping_get_result,
13277 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
13278 TOKEN_STRING_INITIALIZER
13279 (struct cmd_ptype_mapping_get_result,
13280 mapping, "mapping");
13281 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
13282 TOKEN_STRING_INITIALIZER
13283 (struct cmd_ptype_mapping_get_result,
13285 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
13286 TOKEN_NUM_INITIALIZER
13287 (struct cmd_ptype_mapping_get_result,
13289 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
13290 TOKEN_NUM_INITIALIZER
13291 (struct cmd_ptype_mapping_get_result,
13292 valid_only, UINT8);
13295 cmd_ptype_mapping_get_parsed(
13296 void *parsed_result,
13297 __attribute__((unused)) struct cmdline *cl,
13298 __attribute__((unused)) void *data)
13300 struct cmd_ptype_mapping_get_result *res = parsed_result;
13301 int ret = -ENOTSUP;
13302 #ifdef RTE_LIBRTE_I40E_PMD
13303 int max_ptype_num = 256;
13304 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
13309 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13312 #ifdef RTE_LIBRTE_I40E_PMD
13313 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
13324 printf("invalid port_id %d\n", res->port_id);
13327 printf("function not implemented\n");
13330 printf("programming error: (%s)\n", strerror(-ret));
13333 #ifdef RTE_LIBRTE_I40E_PMD
13335 for (i = 0; i < count; i++)
13336 printf("%3d\t0x%08x\n",
13337 mapping[i].hw_ptype, mapping[i].sw_ptype);
13342 cmdline_parse_inst_t cmd_ptype_mapping_get = {
13343 .f = cmd_ptype_mapping_get_parsed,
13345 .help_str = "ptype mapping get <port_id> <valid_only>",
13347 (void *)&cmd_ptype_mapping_get_ptype,
13348 (void *)&cmd_ptype_mapping_get_mapping,
13349 (void *)&cmd_ptype_mapping_get_get,
13350 (void *)&cmd_ptype_mapping_get_port_id,
13351 (void *)&cmd_ptype_mapping_get_valid_only,
13356 /* ptype mapping replace */
13358 /* Common result structure for ptype mapping replace */
13359 struct cmd_ptype_mapping_replace_result {
13360 cmdline_fixed_string_t ptype;
13361 cmdline_fixed_string_t mapping;
13362 cmdline_fixed_string_t replace;
13369 /* Common CLI fields for ptype mapping replace */
13370 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
13371 TOKEN_STRING_INITIALIZER
13372 (struct cmd_ptype_mapping_replace_result,
13374 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
13375 TOKEN_STRING_INITIALIZER
13376 (struct cmd_ptype_mapping_replace_result,
13377 mapping, "mapping");
13378 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
13379 TOKEN_STRING_INITIALIZER
13380 (struct cmd_ptype_mapping_replace_result,
13381 replace, "replace");
13382 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
13383 TOKEN_NUM_INITIALIZER
13384 (struct cmd_ptype_mapping_replace_result,
13386 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
13387 TOKEN_NUM_INITIALIZER
13388 (struct cmd_ptype_mapping_replace_result,
13390 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
13391 TOKEN_NUM_INITIALIZER
13392 (struct cmd_ptype_mapping_replace_result,
13394 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
13395 TOKEN_NUM_INITIALIZER
13396 (struct cmd_ptype_mapping_replace_result,
13400 cmd_ptype_mapping_replace_parsed(
13401 void *parsed_result,
13402 __attribute__((unused)) struct cmdline *cl,
13403 __attribute__((unused)) void *data)
13405 struct cmd_ptype_mapping_replace_result *res = parsed_result;
13406 int ret = -ENOTSUP;
13408 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13411 #ifdef RTE_LIBRTE_I40E_PMD
13412 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
13422 printf("invalid ptype 0x%8x or 0x%8x\n",
13423 res->target, res->pkt_type);
13426 printf("invalid port_id %d\n", res->port_id);
13429 printf("function not implemented\n");
13432 printf("programming error: (%s)\n", strerror(-ret));
13436 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
13437 .f = cmd_ptype_mapping_replace_parsed,
13440 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
13442 (void *)&cmd_ptype_mapping_replace_ptype,
13443 (void *)&cmd_ptype_mapping_replace_mapping,
13444 (void *)&cmd_ptype_mapping_replace_replace,
13445 (void *)&cmd_ptype_mapping_replace_port_id,
13446 (void *)&cmd_ptype_mapping_replace_target,
13447 (void *)&cmd_ptype_mapping_replace_mask,
13448 (void *)&cmd_ptype_mapping_replace_pkt_type,
13453 /* ptype mapping reset */
13455 /* Common result structure for ptype mapping reset */
13456 struct cmd_ptype_mapping_reset_result {
13457 cmdline_fixed_string_t ptype;
13458 cmdline_fixed_string_t mapping;
13459 cmdline_fixed_string_t reset;
13463 /* Common CLI fields for ptype mapping reset*/
13464 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
13465 TOKEN_STRING_INITIALIZER
13466 (struct cmd_ptype_mapping_reset_result,
13468 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
13469 TOKEN_STRING_INITIALIZER
13470 (struct cmd_ptype_mapping_reset_result,
13471 mapping, "mapping");
13472 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
13473 TOKEN_STRING_INITIALIZER
13474 (struct cmd_ptype_mapping_reset_result,
13476 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
13477 TOKEN_NUM_INITIALIZER
13478 (struct cmd_ptype_mapping_reset_result,
13482 cmd_ptype_mapping_reset_parsed(
13483 void *parsed_result,
13484 __attribute__((unused)) struct cmdline *cl,
13485 __attribute__((unused)) void *data)
13487 struct cmd_ptype_mapping_reset_result *res = parsed_result;
13488 int ret = -ENOTSUP;
13490 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13493 #ifdef RTE_LIBRTE_I40E_PMD
13494 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
13501 printf("invalid port_id %d\n", res->port_id);
13504 printf("function not implemented\n");
13507 printf("programming error: (%s)\n", strerror(-ret));
13511 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
13512 .f = cmd_ptype_mapping_reset_parsed,
13514 .help_str = "ptype mapping reset <port_id>",
13516 (void *)&cmd_ptype_mapping_reset_ptype,
13517 (void *)&cmd_ptype_mapping_reset_mapping,
13518 (void *)&cmd_ptype_mapping_reset_reset,
13519 (void *)&cmd_ptype_mapping_reset_port_id,
13524 /* ptype mapping update */
13526 /* Common result structure for ptype mapping update */
13527 struct cmd_ptype_mapping_update_result {
13528 cmdline_fixed_string_t ptype;
13529 cmdline_fixed_string_t mapping;
13530 cmdline_fixed_string_t reset;
13536 /* Common CLI fields for ptype mapping update*/
13537 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
13538 TOKEN_STRING_INITIALIZER
13539 (struct cmd_ptype_mapping_update_result,
13541 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
13542 TOKEN_STRING_INITIALIZER
13543 (struct cmd_ptype_mapping_update_result,
13544 mapping, "mapping");
13545 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
13546 TOKEN_STRING_INITIALIZER
13547 (struct cmd_ptype_mapping_update_result,
13549 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
13550 TOKEN_NUM_INITIALIZER
13551 (struct cmd_ptype_mapping_update_result,
13553 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
13554 TOKEN_NUM_INITIALIZER
13555 (struct cmd_ptype_mapping_update_result,
13557 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
13558 TOKEN_NUM_INITIALIZER
13559 (struct cmd_ptype_mapping_update_result,
13563 cmd_ptype_mapping_update_parsed(
13564 void *parsed_result,
13565 __attribute__((unused)) struct cmdline *cl,
13566 __attribute__((unused)) void *data)
13568 struct cmd_ptype_mapping_update_result *res = parsed_result;
13569 int ret = -ENOTSUP;
13570 #ifdef RTE_LIBRTE_I40E_PMD
13571 struct rte_pmd_i40e_ptype_mapping mapping;
13573 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13576 #ifdef RTE_LIBRTE_I40E_PMD
13577 mapping.hw_ptype = res->hw_ptype;
13578 mapping.sw_ptype = res->sw_ptype;
13579 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
13589 printf("invalid ptype 0x%8x\n", res->sw_ptype);
13592 printf("invalid port_id %d\n", res->port_id);
13595 printf("function not implemented\n");
13598 printf("programming error: (%s)\n", strerror(-ret));
13602 cmdline_parse_inst_t cmd_ptype_mapping_update = {
13603 .f = cmd_ptype_mapping_update_parsed,
13605 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
13607 (void *)&cmd_ptype_mapping_update_ptype,
13608 (void *)&cmd_ptype_mapping_update_mapping,
13609 (void *)&cmd_ptype_mapping_update_update,
13610 (void *)&cmd_ptype_mapping_update_port_id,
13611 (void *)&cmd_ptype_mapping_update_hw_ptype,
13612 (void *)&cmd_ptype_mapping_update_sw_ptype,
13617 /* Common result structure for file commands */
13618 struct cmd_cmdfile_result {
13619 cmdline_fixed_string_t load;
13620 cmdline_fixed_string_t filename;
13623 /* Common CLI fields for file commands */
13624 cmdline_parse_token_string_t cmd_load_cmdfile =
13625 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
13626 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
13627 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
13630 cmd_load_from_file_parsed(
13631 void *parsed_result,
13632 __attribute__((unused)) struct cmdline *cl,
13633 __attribute__((unused)) void *data)
13635 struct cmd_cmdfile_result *res = parsed_result;
13637 cmdline_read_from_file(res->filename);
13640 cmdline_parse_inst_t cmd_load_from_file = {
13641 .f = cmd_load_from_file_parsed,
13643 .help_str = "load <filename>",
13645 (void *)&cmd_load_cmdfile,
13646 (void *)&cmd_load_cmdfile_filename,
13651 /* ******************************************************************************** */
13653 /* list of instructions */
13654 cmdline_parse_ctx_t main_ctx[] = {
13655 (cmdline_parse_inst_t *)&cmd_help_brief,
13656 (cmdline_parse_inst_t *)&cmd_help_long,
13657 (cmdline_parse_inst_t *)&cmd_quit,
13658 (cmdline_parse_inst_t *)&cmd_load_from_file,
13659 (cmdline_parse_inst_t *)&cmd_showport,
13660 (cmdline_parse_inst_t *)&cmd_showqueue,
13661 (cmdline_parse_inst_t *)&cmd_showportall,
13662 (cmdline_parse_inst_t *)&cmd_showcfg,
13663 (cmdline_parse_inst_t *)&cmd_start,
13664 (cmdline_parse_inst_t *)&cmd_start_tx_first,
13665 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13666 (cmdline_parse_inst_t *)&cmd_set_link_up,
13667 (cmdline_parse_inst_t *)&cmd_set_link_down,
13668 (cmdline_parse_inst_t *)&cmd_reset,
13669 (cmdline_parse_inst_t *)&cmd_set_numbers,
13670 (cmdline_parse_inst_t *)&cmd_set_txpkts,
13671 (cmdline_parse_inst_t *)&cmd_set_txsplit,
13672 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13673 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13674 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13675 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13676 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13677 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13678 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13679 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13680 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13681 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13682 (cmdline_parse_inst_t *)&cmd_set_link_check,
13683 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
13684 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
13685 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
13686 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
13687 #ifdef RTE_LIBRTE_PMD_BOND
13688 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
13689 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
13690 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
13691 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
13692 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
13693 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
13694 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
13695 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
13696 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
13698 (cmdline_parse_inst_t *)&cmd_vlan_offload,
13699 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13700 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13701 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13702 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13703 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13704 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13705 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13706 (cmdline_parse_inst_t *)&cmd_csum_set,
13707 (cmdline_parse_inst_t *)&cmd_csum_show,
13708 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13709 (cmdline_parse_inst_t *)&cmd_tso_set,
13710 (cmdline_parse_inst_t *)&cmd_tso_show,
13711 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13712 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13713 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13714 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13715 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13716 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13717 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13718 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13719 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13720 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13721 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13722 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13723 (cmdline_parse_inst_t *)&cmd_config_dcb,
13724 (cmdline_parse_inst_t *)&cmd_read_reg,
13725 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
13726 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
13727 (cmdline_parse_inst_t *)&cmd_write_reg,
13728 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
13729 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
13730 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13731 (cmdline_parse_inst_t *)&cmd_stop,
13732 (cmdline_parse_inst_t *)&cmd_mac_addr,
13733 (cmdline_parse_inst_t *)&cmd_set_qmap,
13734 (cmdline_parse_inst_t *)&cmd_operate_port,
13735 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13736 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13737 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13738 (cmdline_parse_inst_t *)&cmd_config_speed_all,
13739 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13740 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13741 (cmdline_parse_inst_t *)&cmd_config_mtu,
13742 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13743 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13744 (cmdline_parse_inst_t *)&cmd_config_rss,
13745 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13746 (cmdline_parse_inst_t *)&cmd_config_txqflags,
13747 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13748 (cmdline_parse_inst_t *)&cmd_showport_reta,
13749 (cmdline_parse_inst_t *)&cmd_config_burst,
13750 (cmdline_parse_inst_t *)&cmd_config_thresh,
13751 (cmdline_parse_inst_t *)&cmd_config_threshold,
13752 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13753 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13754 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13755 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
13756 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13757 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
13758 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13759 (cmdline_parse_inst_t *)&cmd_global_config,
13760 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
13761 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
13762 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
13763 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13764 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13765 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13766 (cmdline_parse_inst_t *)&cmd_dump,
13767 (cmdline_parse_inst_t *)&cmd_dump_one,
13768 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
13769 (cmdline_parse_inst_t *)&cmd_syn_filter,
13770 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
13771 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
13772 (cmdline_parse_inst_t *)&cmd_flex_filter,
13773 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
13774 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
13775 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
13776 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
13777 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
13778 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
13779 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
13780 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
13781 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
13782 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
13783 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
13784 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
13785 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
13786 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
13787 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
13788 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
13789 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
13790 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
13791 (cmdline_parse_inst_t *)&cmd_flow,
13792 (cmdline_parse_inst_t *)&cmd_mcast_addr,
13793 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
13794 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
13795 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
13796 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
13797 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
13798 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
13799 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
13800 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
13801 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
13802 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
13803 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13804 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13805 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13806 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13807 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13808 #ifdef RTE_LIBRTE_IXGBE_PMD
13809 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13810 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
13811 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
13812 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
13813 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
13814 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
13815 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13817 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13818 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13819 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13820 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13821 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
13822 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
13823 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
13824 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
13825 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
13826 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
13827 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
13828 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
13829 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
13830 (cmdline_parse_inst_t *)&cmd_ddp_add,
13831 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
13832 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
13833 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
13834 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
13835 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
13836 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
13837 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
13841 /* read cmdline commands from file */
13843 cmdline_read_from_file(const char *filename)
13845 struct cmdline *cl;
13847 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
13849 printf("Failed to create file based cmdline context: %s\n",
13854 cmdline_interact(cl);
13859 printf("Read CLI commands from %s\n", filename);
13862 /* prompt function, called from main on MASTER lcore */
13866 /* initialize non-constant commands */
13867 cmd_set_fwd_mode_init();
13868 cmd_set_fwd_retry_mode_init();
13870 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13871 if (testpmd_cl == NULL)
13873 cmdline_interact(testpmd_cl);
13874 cmdline_stdin_exit(testpmd_cl);
13880 if (testpmd_cl != NULL)
13881 cmdline_quit(testpmd_cl);
13885 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13887 if (id == (portid_t)RTE_PORT_ALL) {
13890 RTE_ETH_FOREACH_DEV(pid) {
13891 /* check if need_reconfig has been set to 1 */
13892 if (ports[pid].need_reconfig == 0)
13893 ports[pid].need_reconfig = dev;
13894 /* check if need_reconfig_queues has been set to 1 */
13895 if (ports[pid].need_reconfig_queues == 0)
13896 ports[pid].need_reconfig_queues = queue;
13898 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13899 /* check if need_reconfig has been set to 1 */
13900 if (ports[id].need_reconfig == 0)
13901 ports[id].need_reconfig = dev;
13902 /* check if need_reconfig_queues has been set to 1 */
13903 if (ports[id].need_reconfig_queues == 0)
13904 ports[id].need_reconfig_queues = queue;