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>
99 static struct cmdline *testpmd_cl;
101 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
103 /* *** Help command with introduction. *** */
104 struct cmd_help_brief_result {
105 cmdline_fixed_string_t help;
108 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
110 __attribute__((unused)) void *data)
115 "Help is available for the following sections:\n\n"
116 " help control : Start and stop forwarding.\n"
117 " help display : Displaying port, stats and config "
119 " help config : Configuration information.\n"
120 " help ports : Configuring ports.\n"
121 " help registers : Reading and setting port registers.\n"
122 " help filters : Filters configuration help.\n"
123 " help all : All of the above sections.\n\n"
128 cmdline_parse_token_string_t cmd_help_brief_help =
129 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
131 cmdline_parse_inst_t cmd_help_brief = {
132 .f = cmd_help_brief_parsed,
134 .help_str = "help: Show help",
136 (void *)&cmd_help_brief_help,
141 /* *** Help command with help sections. *** */
142 struct cmd_help_long_result {
143 cmdline_fixed_string_t help;
144 cmdline_fixed_string_t section;
147 static void cmd_help_long_parsed(void *parsed_result,
149 __attribute__((unused)) void *data)
152 struct cmd_help_long_result *res = parsed_result;
154 if (!strcmp(res->section, "all"))
157 if (show_all || !strcmp(res->section, "control")) {
162 "Control forwarding:\n"
163 "-------------------\n\n"
166 " Start packet forwarding with current configuration.\n\n"
169 " Start packet forwarding with current config"
170 " after sending one burst of packets.\n\n"
173 " Stop packet forwarding, and display accumulated"
177 " Quit to prompt.\n\n"
181 if (show_all || !strcmp(res->section, "display")) {
189 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
190 " Display information for port_id, or all.\n\n"
192 "show port X rss reta (size) (mask0,mask1,...)\n"
193 " Display the rss redirection table entry indicated"
194 " by masks on port X. size is used to indicate the"
195 " hardware supported reta size\n\n"
197 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
198 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
199 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
200 " Display the RSS hash functions and RSS hash key"
203 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
204 " Clear information for port_id, or all.\n\n"
206 "show (rxq|txq) info (port_id) (queue_id)\n"
207 " Display information for configured RX/TX queue.\n\n"
209 "show config (rxtx|cores|fwd|txpkts)\n"
210 " Display the given configuration.\n\n"
212 "read rxd (port_id) (queue_id) (rxd_id)\n"
213 " Display an RX descriptor of a port RX queue.\n\n"
215 "read txd (port_id) (queue_id) (txd_id)\n"
216 " Display a TX descriptor of a port TX queue.\n\n"
218 "ddp get list (port_id)\n"
219 " Get ddp profile info list\n\n"
221 "show vf stats (port_id) (vf_id)\n"
222 " Display a VF's statistics.\n\n"
224 "clear vf stats (port_id) (vf_id)\n"
225 " Reset a VF's statistics.\n\n"
229 if (show_all || !strcmp(res->section, "config")) {
235 "Configuration changes only become active when"
236 " forwarding is started/restarted.\n\n"
239 " Reset forwarding to the default configuration.\n\n"
241 "set verbose (level)\n"
242 " Set the debug verbosity level X.\n\n"
245 " Set number of ports.\n\n"
248 " Set number of cores.\n\n"
250 "set coremask (mask)\n"
251 " Set the forwarding cores hexadecimal mask.\n\n"
253 "set portmask (mask)\n"
254 " Set the forwarding ports hexadecimal mask.\n\n"
257 " Set number of packets per burst.\n\n"
259 "set burst tx delay (microseconds) retry (num)\n"
260 " Set the transmit delay time and number of retries,"
261 " effective when retry is enabled.\n\n"
263 "set txpkts (x[,y]*)\n"
264 " Set the length of each segment of TXONLY"
265 " and optionally CSUM packets.\n\n"
267 "set txsplit (off|on|rand)\n"
268 " Set the split policy for the TX packets."
269 " Right now only applicable for CSUM and TXONLY"
272 "set corelist (x[,y]*)\n"
273 " Set the list of forwarding cores.\n\n"
275 "set portlist (x[,y]*)\n"
276 " Set the list of forwarding ports.\n\n"
278 "set tx loopback (port_id) (on|off)\n"
279 " Enable or disable tx loopback.\n\n"
281 #ifdef RTE_LIBRTE_IXGBE_PMD
282 "set all queues drop (port_id) (on|off)\n"
283 " Set drop enable bit for all queues.\n\n"
285 "set vf split drop (port_id) (vf_id) (on|off)\n"
286 " Set split drop enable bit for a VF from the PF.\n\n"
289 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
290 " Set MAC antispoof for a VF from the PF.\n\n"
292 #ifdef RTE_LIBRTE_IXGBE_PMD
293 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
294 " Enable MACsec offload.\n\n"
296 "set macsec offload (port_id) off\n"
297 " Disable MACsec offload.\n\n"
299 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
300 " Configure MACsec secure connection (SC).\n\n"
302 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
303 " Configure MACsec secure association (SA).\n\n"
306 "set vf broadcast (port_id) (vf_id) (on|off)\n"
307 " Set VF broadcast for a VF from the PF.\n\n"
309 "vlan set strip (on|off) (port_id)\n"
310 " Set the VLAN strip on a port.\n\n"
312 "vlan set stripq (on|off) (port_id,queue_id)\n"
313 " Set the VLAN strip for a queue on a port.\n\n"
315 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
316 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
318 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
319 " Set VLAN insert for a VF from the PF.\n\n"
321 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
322 " Set VLAN antispoof for a VF from the PF.\n\n"
324 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
325 " Set VLAN tag for a VF from the PF.\n\n"
327 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
328 " Set a VF's max bandwidth(Mbps).\n\n"
330 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
331 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
333 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
334 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
336 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
337 " Set some TCs' strict link priority mode on a physical port.\n\n"
339 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
340 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
342 "vlan set filter (on|off) (port_id)\n"
343 " Set the VLAN filter on a port.\n\n"
345 "vlan set qinq (on|off) (port_id)\n"
346 " Set the VLAN QinQ (extended queue in queue)"
349 "vlan set (inner|outer) tpid (value) (port_id)\n"
350 " Set the VLAN TPID for Packet Filtering on"
353 "rx_vlan add (vlan_id|all) (port_id)\n"
354 " Add a vlan_id, or all identifiers, to the set"
355 " of VLAN identifiers filtered by port_id.\n\n"
357 "rx_vlan rm (vlan_id|all) (port_id)\n"
358 " Remove a vlan_id, or all identifiers, from the set"
359 " of VLAN identifiers filtered by port_id.\n\n"
361 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
362 " Add a vlan_id, to the set of VLAN identifiers"
363 "filtered for VF(s) from port_id.\n\n"
365 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
366 " Remove a vlan_id, to the set of VLAN identifiers"
367 "filtered for VF(s) from port_id.\n\n"
369 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
370 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
371 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
372 " add a tunnel filter of a port.\n\n"
374 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
375 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
376 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
377 " remove a tunnel filter of a port.\n\n"
379 "rx_vxlan_port add (udp_port) (port_id)\n"
380 " Add an UDP port for VXLAN packet filter on a port\n\n"
382 "rx_vxlan_port rm (udp_port) (port_id)\n"
383 " Remove an UDP port for VXLAN packet filter on a port\n\n"
385 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
386 " Set hardware insertion of VLAN IDs (single or double VLAN "
387 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
389 "tx_vlan set pvid port_id vlan_id (on|off)\n"
390 " Set port based TX VLAN insertion.\n\n"
392 "tx_vlan reset (port_id)\n"
393 " Disable hardware insertion of a VLAN header in"
394 " packets sent on a port.\n\n"
396 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
397 " Select hardware or software calculation of the"
398 " checksum when transmitting a packet using the"
399 " csum forward engine.\n"
400 " ip|udp|tcp|sctp always concern the inner layer.\n"
401 " outer-ip concerns the outer IP layer in"
402 " case the packet is recognized as a tunnel packet by"
403 " the forward engine (vxlan, gre and ipip are supported)\n"
404 " Please check the NIC datasheet for HW limits.\n\n"
406 "csum parse-tunnel (on|off) (tx_port_id)\n"
407 " If disabled, treat tunnel packets as non-tunneled"
408 " packets (treat inner headers as payload). The port\n"
409 " argument is the port used for TX in csum forward"
412 "csum show (port_id)\n"
413 " Display tx checksum offload configuration\n\n"
415 "tso set (segsize) (portid)\n"
416 " Enable TCP Segmentation Offload in csum forward"
418 " Please check the NIC datasheet for HW limits.\n\n"
421 " Display the status of TCP Segmentation Offload.\n\n"
424 " Set packet forwarding mode.\n\n"
426 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
427 " Add a MAC address on port_id.\n\n"
429 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
430 " Remove a MAC address from port_id.\n\n"
432 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
433 " Set the default MAC address for port_id.\n\n"
435 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
436 " Add a MAC address for a VF on the port.\n\n"
438 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
439 " Set the MAC address for a VF from the PF.\n\n"
441 "set port (port_id) uta (mac_address|all) (on|off)\n"
442 " Add/Remove a or all unicast hash filter(s)"
445 "set promisc (port_id|all) (on|off)\n"
446 " Set the promiscuous mode on port_id, or all.\n\n"
448 "set allmulti (port_id|all) (on|off)\n"
449 " Set the allmulti mode on port_id, or all.\n\n"
451 "set vf promisc (port_id) (vf_id) (on|off)\n"
452 " Set unicast promiscuous mode for a VF from the PF.\n\n"
454 "set vf allmulti (port_id) (vf_id) (on|off)\n"
455 " Set multicast promiscuous mode for a VF from the PF.\n\n"
457 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
458 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
459 " (on|off) autoneg (on|off) (port_id)\n"
460 "set flow_ctrl rx (on|off) (portid)\n"
461 "set flow_ctrl tx (on|off) (portid)\n"
462 "set flow_ctrl high_water (high_water) (portid)\n"
463 "set flow_ctrl low_water (low_water) (portid)\n"
464 "set flow_ctrl pause_time (pause_time) (portid)\n"
465 "set flow_ctrl send_xon (send_xon) (portid)\n"
466 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
467 "set flow_ctrl autoneg (on|off) (port_id)\n"
468 " Set the link flow control parameter on a port.\n\n"
470 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
471 " (low_water) (pause_time) (priority) (port_id)\n"
472 " Set the priority flow control parameter on a"
475 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
476 " Set statistics mapping (qmapping 0..15) for RX/TX"
478 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
479 " on port 0 to mapping 5.\n\n"
481 "set port (port_id) vf (vf_id) rx|tx on|off\n"
482 " Enable/Disable a VF receive/tranmit from a port\n\n"
484 "set port (port_id) vf (vf_id) (mac_addr)"
485 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
486 " Add/Remove unicast or multicast MAC addr filter"
489 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
491 " AUPE:accepts untagged VLAN;"
492 "ROPE:accept unicast hash\n\n"
493 " BAM:accepts broadcast packets;"
494 "MPE:accepts all multicast packets\n\n"
495 " Enable/Disable a VF receive mode of a port\n\n"
497 "set port (port_id) queue (queue_id) rate (rate_num)\n"
498 " Set rate limit for a queue of a port\n\n"
500 "set port (port_id) vf (vf_id) rate (rate_num) "
501 "queue_mask (queue_mask_value)\n"
502 " Set rate limit for queues in VF of a port\n\n"
504 "set port (port_id) mirror-rule (rule_id)"
505 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
506 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
507 " Set pool or vlan type mirror rule on a port.\n"
508 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
509 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
512 "set port (port_id) mirror-rule (rule_id)"
513 " (uplink-mirror|downlink-mirror) dst-pool"
514 " (pool_id) (on|off)\n"
515 " Set uplink or downlink type mirror rule on a port.\n"
516 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
517 " 0 on' enable mirror income traffic to pool 0.\n\n"
519 "reset port (port_id) mirror-rule (rule_id)\n"
520 " Reset a mirror rule.\n\n"
522 "set flush_rx (on|off)\n"
523 " Flush (default) or don't flush RX streams before"
524 " forwarding. Mainly used with PCAP drivers.\n\n"
526 "set bypass mode (normal|bypass|isolate) (port_id)\n"
527 " Set the bypass mode for the lowest port on bypass enabled"
530 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
531 "mode (normal|bypass|isolate) (port_id)\n"
532 " Set the event required to initiate specified bypass mode for"
533 " the lowest port on a bypass enabled NIC where:\n"
534 " timeout = enable bypass after watchdog timeout.\n"
535 " os_on = enable bypass when OS/board is powered on.\n"
536 " os_off = enable bypass when OS/board is powered off.\n"
537 " power_on = enable bypass when power supply is turned on.\n"
538 " power_off = enable bypass when power supply is turned off."
541 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
542 " Set the bypass watchdog timeout to 'n' seconds"
543 " where 0 = instant.\n\n"
545 "show bypass config (port_id)\n"
546 " Show the bypass configuration for a bypass enabled NIC"
547 " using the lowest port on the NIC.\n\n"
549 #ifdef RTE_LIBRTE_PMD_BOND
550 "create bonded device (mode) (socket)\n"
551 " Create a new bonded device with specific bonding mode and socket.\n\n"
553 "add bonding slave (slave_id) (port_id)\n"
554 " Add a slave device to a bonded device.\n\n"
556 "remove bonding slave (slave_id) (port_id)\n"
557 " Remove a slave device from a bonded device.\n\n"
559 "set bonding mode (value) (port_id)\n"
560 " Set the bonding mode on a bonded device.\n\n"
562 "set bonding primary (slave_id) (port_id)\n"
563 " Set the primary slave for a bonded device.\n\n"
565 "show bonding config (port_id)\n"
566 " Show the bonding config for port_id.\n\n"
568 "set bonding mac_addr (port_id) (address)\n"
569 " Set the MAC address of a bonded device.\n\n"
571 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
572 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
574 "set bonding mon_period (port_id) (value)\n"
575 " Set the bonding link status monitoring polling period in ms.\n\n"
577 "set link-up port (port_id)\n"
578 " Set link up for a port.\n\n"
580 "set link-down port (port_id)\n"
581 " Set link down for a port.\n\n"
583 "E-tag set insertion on port-tag-id (value)"
584 " port (port_id) vf (vf_id)\n"
585 " Enable E-tag insertion for a VF on a port\n\n"
587 "E-tag set insertion off port (port_id) vf (vf_id)\n"
588 " Disable E-tag insertion for a VF on a port\n\n"
590 "E-tag set stripping (on|off) port (port_id)\n"
591 " Enable/disable E-tag stripping on a port\n\n"
593 "E-tag set forwarding (on|off) port (port_id)\n"
594 " Enable/disable E-tag based forwarding"
597 "E-tag set filter add e-tag-id (value) dst-pool"
598 " (pool_id) port (port_id)\n"
599 " Add an E-tag forwarding filter on a port\n\n"
601 "E-tag set filter del e-tag-id (value) port (port_id)\n"
602 " Delete an E-tag forwarding filter on a port\n\n"
604 "ddp add (port_id) (profile_path)\n"
605 " Load a profile package on a port\n\n"
607 "ptype mapping get (port_id) (valid_only)\n"
608 " Get ptype mapping on a port\n\n"
610 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
611 " Replace target with the pkt_type in ptype mapping\n\n"
613 "ptype mapping reset (port_id)\n"
614 " Reset ptype mapping on a port\n\n"
616 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
617 " Update a ptype mapping item on a port\n\n"
619 , list_pkt_forwarding_modes()
623 if (show_all || !strcmp(res->section, "ports")) {
629 "----------------\n\n"
631 "port start (port_id|all)\n"
632 " Start all ports or port_id.\n\n"
634 "port stop (port_id|all)\n"
635 " Stop all ports or port_id.\n\n"
637 "port close (port_id|all)\n"
638 " Close all ports or port_id.\n\n"
640 "port attach (ident)\n"
641 " Attach physical or virtual dev by pci address or virtual device name\n\n"
643 "port detach (port_id)\n"
644 " Detach physical or virtual dev by port_id\n\n"
646 "port config (port_id|all)"
647 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
648 " duplex (half|full|auto)\n"
649 " Set speed and duplex for all ports or port_id\n\n"
651 "port config all (rxq|txq|rxd|txd) (value)\n"
652 " Set number for rxq/txq/rxd/txd.\n\n"
654 "port config all max-pkt-len (value)\n"
655 " Set the max packet length.\n\n"
657 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
658 "hw-vlan-strip|hw-vlan-extend|drop-en)"
660 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
663 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
664 " Set the RSS mode.\n\n"
666 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
667 " Set the RSS redirection table.\n\n"
669 "port config (port_id) dcb vt (on|off) (traffic_class)"
671 " Set the DCB mode.\n\n"
673 "port config all burst (value)\n"
674 " Set the number of packets per burst.\n\n"
676 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
678 " Set the ring prefetch/host/writeback threshold"
679 " for tx/rx queue.\n\n"
681 "port config all (txfreet|txrst|rxfreet) (value)\n"
682 " Set free threshold for rx/tx, or set"
683 " tx rs bit threshold.\n\n"
684 "port config mtu X value\n"
685 " Set the MTU of port X to a given value\n\n"
687 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
688 " Start/stop a rx/tx queue of port X. Only take effect"
689 " when port X is started\n\n"
691 "port config (port_id|all) l2-tunnel E-tag ether-type"
693 " Set the value of E-tag ether-type.\n\n"
695 "port config (port_id|all) l2-tunnel E-tag"
696 " (enable|disable)\n"
697 " Enable/disable the E-tag support.\n\n"
701 if (show_all || !strcmp(res->section, "registers")) {
709 "read reg (port_id) (address)\n"
710 " Display value of a port register.\n\n"
712 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
713 " Display a port register bit field.\n\n"
715 "read regbit (port_id) (address) (bit_x)\n"
716 " Display a single port register bit.\n\n"
718 "write reg (port_id) (address) (value)\n"
719 " Set value of a port register.\n\n"
721 "write regfield (port_id) (address) (bit_x) (bit_y)"
723 " Set bit field of a port register.\n\n"
725 "write regbit (port_id) (address) (bit_x) (value)\n"
726 " Set single bit value of a port register.\n\n"
729 if (show_all || !strcmp(res->section, "filters")) {
737 "ethertype_filter (port_id) (add|del)"
738 " (mac_addr|mac_ignr) (mac_address) ethertype"
739 " (ether_type) (drop|fwd) queue (queue_id)\n"
740 " Add/Del an ethertype filter.\n\n"
742 "2tuple_filter (port_id) (add|del)"
743 " dst_port (dst_port_value) protocol (protocol_value)"
744 " mask (mask_value) tcp_flags (tcp_flags_value)"
745 " priority (prio_value) queue (queue_id)\n"
746 " Add/Del a 2tuple filter.\n\n"
748 "5tuple_filter (port_id) (add|del)"
749 " dst_ip (dst_address) src_ip (src_address)"
750 " dst_port (dst_port_value) src_port (src_port_value)"
751 " protocol (protocol_value)"
752 " mask (mask_value) tcp_flags (tcp_flags_value)"
753 " priority (prio_value) queue (queue_id)\n"
754 " Add/Del a 5tuple filter.\n\n"
756 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
757 " Add/Del syn filter.\n\n"
759 "flex_filter (port_id) (add|del) len (len_value)"
760 " bytes (bytes_value) mask (mask_value)"
761 " priority (prio_value) queue (queue_id)\n"
762 " Add/Del a flex filter.\n\n"
764 "flow_director_filter (port_id) mode IP (add|del|update)"
765 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
766 " src (src_ip_address) dst (dst_ip_address)"
767 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
768 " vlan (vlan_value) flexbytes (flexbytes_value)"
769 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
770 " fd_id (fd_id_value)\n"
771 " Add/Del an IP type flow director filter.\n\n"
773 "flow_director_filter (port_id) mode IP (add|del|update)"
774 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
775 " src (src_ip_address) (src_port)"
776 " dst (dst_ip_address) (dst_port)"
777 " tos (tos_value) ttl (ttl_value)"
778 " vlan (vlan_value) flexbytes (flexbytes_value)"
779 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
780 " fd_id (fd_id_value)\n"
781 " Add/Del an UDP/TCP type flow director filter.\n\n"
783 "flow_director_filter (port_id) mode IP (add|del|update)"
784 " flow (ipv4-sctp|ipv6-sctp)"
785 " src (src_ip_address) (src_port)"
786 " dst (dst_ip_address) (dst_port)"
787 " tag (verification_tag) "
788 " tos (tos_value) ttl (ttl_value)"
790 " flexbytes (flexbytes_value) (drop|fwd)"
791 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
792 " Add/Del a SCTP type flow director filter.\n\n"
794 "flow_director_filter (port_id) mode IP (add|del|update)"
795 " flow l2_payload ether (ethertype)"
796 " flexbytes (flexbytes_value) (drop|fwd)"
797 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
798 " Add/Del a l2 payload type flow director filter.\n\n"
800 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
801 " mac (mac_address) vlan (vlan_value)"
802 " flexbytes (flexbytes_value) (drop|fwd)"
803 " queue (queue_id) fd_id (fd_id_value)\n"
804 " Add/Del a MAC-VLAN flow director filter.\n\n"
806 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
807 " mac (mac_address) vlan (vlan_value)"
808 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
809 " flexbytes (flexbytes_value) (drop|fwd)"
810 " queue (queue_id) fd_id (fd_id_value)\n"
811 " Add/Del a Tunnel flow director filter.\n\n"
813 "flush_flow_director (port_id)\n"
814 " Flush all flow director entries of a device.\n\n"
816 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
817 " src_mask (ipv4_src) (ipv6_src) (src_port)"
818 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
819 " Set flow director IP mask.\n\n"
821 "flow_director_mask (port_id) mode MAC-VLAN"
822 " vlan (vlan_value)\n"
823 " Set flow director MAC-VLAN mask.\n\n"
825 "flow_director_mask (port_id) mode Tunnel"
826 " vlan (vlan_value) mac (mac_value)"
827 " tunnel-type (tunnel_type_value)"
828 " tunnel-id (tunnel_id_value)\n"
829 " Set flow director Tunnel mask.\n\n"
831 "flow_director_flex_mask (port_id)"
832 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
833 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
835 " Configure mask of flex payload.\n\n"
837 "flow_director_flex_payload (port_id)"
838 " (raw|l2|l3|l4) (config)\n"
839 " Configure flex payload selection.\n\n"
841 "get_sym_hash_ena_per_port (port_id)\n"
842 " get symmetric hash enable configuration per port.\n\n"
844 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
845 " set symmetric hash enable configuration per port"
846 " to enable or disable.\n\n"
848 "get_hash_global_config (port_id)\n"
849 " Get the global configurations of hash filters.\n\n"
851 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
852 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
853 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
854 " (enable|disable)\n"
855 " Set the global configurations of hash filters.\n\n"
857 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
858 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
859 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
860 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
861 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
862 "ipv6-next-header|udp-src-port|udp-dst-port|"
863 "tcp-src-port|tcp-dst-port|sctp-src-port|"
864 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
865 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
866 "fld-8th|none) (select|add)\n"
867 " Set the input set for hash.\n\n"
869 "set_fdir_input_set (port_id) "
870 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
871 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
872 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
873 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
874 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
875 "udp-dst-port|tcp-src-port|tcp-dst-port|"
876 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
878 " Set the input set for FDir.\n\n"
880 "flow validate {port_id}"
881 " [group {group_id}] [priority {level}]"
882 " [ingress] [egress]"
883 " pattern {item} [/ {item} [...]] / end"
884 " actions {action} [/ {action} [...]] / end\n"
885 " Check whether a flow rule can be created.\n\n"
887 "flow create {port_id}"
888 " [group {group_id}] [priority {level}]"
889 " [ingress] [egress]"
890 " pattern {item} [/ {item} [...]] / end"
891 " actions {action} [/ {action} [...]] / end\n"
892 " Create a flow rule.\n\n"
894 "flow destroy {port_id} rule {rule_id} [...]\n"
895 " Destroy specific flow rules.\n\n"
897 "flow flush {port_id}\n"
898 " Destroy all flow rules.\n\n"
900 "flow query {port_id} {rule_id} {action}\n"
901 " Query an existing flow rule.\n\n"
903 "flow list {port_id} [group {group_id}] [...]\n"
904 " List existing flow rules sorted by priority,"
905 " filtered by group identifiers.\n\n"
910 cmdline_parse_token_string_t cmd_help_long_help =
911 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
913 cmdline_parse_token_string_t cmd_help_long_section =
914 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
915 "all#control#display#config#"
916 "ports#registers#filters");
918 cmdline_parse_inst_t cmd_help_long = {
919 .f = cmd_help_long_parsed,
921 .help_str = "help all|control|display|config|ports|register|filters: "
924 (void *)&cmd_help_long_help,
925 (void *)&cmd_help_long_section,
931 /* *** start/stop/close all ports *** */
932 struct cmd_operate_port_result {
933 cmdline_fixed_string_t keyword;
934 cmdline_fixed_string_t name;
935 cmdline_fixed_string_t value;
938 static void cmd_operate_port_parsed(void *parsed_result,
939 __attribute__((unused)) struct cmdline *cl,
940 __attribute__((unused)) void *data)
942 struct cmd_operate_port_result *res = parsed_result;
944 if (!strcmp(res->name, "start"))
945 start_port(RTE_PORT_ALL);
946 else if (!strcmp(res->name, "stop"))
947 stop_port(RTE_PORT_ALL);
948 else if (!strcmp(res->name, "close"))
949 close_port(RTE_PORT_ALL);
951 printf("Unknown parameter\n");
954 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
955 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
957 cmdline_parse_token_string_t cmd_operate_port_all_port =
958 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
960 cmdline_parse_token_string_t cmd_operate_port_all_all =
961 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
963 cmdline_parse_inst_t cmd_operate_port = {
964 .f = cmd_operate_port_parsed,
966 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
968 (void *)&cmd_operate_port_all_cmd,
969 (void *)&cmd_operate_port_all_port,
970 (void *)&cmd_operate_port_all_all,
975 /* *** start/stop/close specific port *** */
976 struct cmd_operate_specific_port_result {
977 cmdline_fixed_string_t keyword;
978 cmdline_fixed_string_t name;
982 static void cmd_operate_specific_port_parsed(void *parsed_result,
983 __attribute__((unused)) struct cmdline *cl,
984 __attribute__((unused)) void *data)
986 struct cmd_operate_specific_port_result *res = parsed_result;
988 if (!strcmp(res->name, "start"))
989 start_port(res->value);
990 else if (!strcmp(res->name, "stop"))
991 stop_port(res->value);
992 else if (!strcmp(res->name, "close"))
993 close_port(res->value);
995 printf("Unknown parameter\n");
998 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
999 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1001 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1002 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1003 name, "start#stop#close");
1004 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1005 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1008 cmdline_parse_inst_t cmd_operate_specific_port = {
1009 .f = cmd_operate_specific_port_parsed,
1011 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
1013 (void *)&cmd_operate_specific_port_cmd,
1014 (void *)&cmd_operate_specific_port_port,
1015 (void *)&cmd_operate_specific_port_id,
1020 /* *** attach a specified port *** */
1021 struct cmd_operate_attach_port_result {
1022 cmdline_fixed_string_t port;
1023 cmdline_fixed_string_t keyword;
1024 cmdline_fixed_string_t identifier;
1027 static void cmd_operate_attach_port_parsed(void *parsed_result,
1028 __attribute__((unused)) struct cmdline *cl,
1029 __attribute__((unused)) void *data)
1031 struct cmd_operate_attach_port_result *res = parsed_result;
1033 if (!strcmp(res->keyword, "attach"))
1034 attach_port(res->identifier);
1036 printf("Unknown parameter\n");
1039 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1040 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1042 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1043 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1045 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1046 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1049 cmdline_parse_inst_t cmd_operate_attach_port = {
1050 .f = cmd_operate_attach_port_parsed,
1052 .help_str = "port attach <identifier>: "
1053 "(identifier: pci address or virtual dev name)",
1055 (void *)&cmd_operate_attach_port_port,
1056 (void *)&cmd_operate_attach_port_keyword,
1057 (void *)&cmd_operate_attach_port_identifier,
1062 /* *** detach a specified port *** */
1063 struct cmd_operate_detach_port_result {
1064 cmdline_fixed_string_t port;
1065 cmdline_fixed_string_t keyword;
1069 static void cmd_operate_detach_port_parsed(void *parsed_result,
1070 __attribute__((unused)) struct cmdline *cl,
1071 __attribute__((unused)) void *data)
1073 struct cmd_operate_detach_port_result *res = parsed_result;
1075 if (!strcmp(res->keyword, "detach"))
1076 detach_port(res->port_id);
1078 printf("Unknown parameter\n");
1081 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1082 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1084 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1085 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1087 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1088 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1091 cmdline_parse_inst_t cmd_operate_detach_port = {
1092 .f = cmd_operate_detach_port_parsed,
1094 .help_str = "port detach <port_id>",
1096 (void *)&cmd_operate_detach_port_port,
1097 (void *)&cmd_operate_detach_port_keyword,
1098 (void *)&cmd_operate_detach_port_port_id,
1103 /* *** configure speed for all ports *** */
1104 struct cmd_config_speed_all {
1105 cmdline_fixed_string_t port;
1106 cmdline_fixed_string_t keyword;
1107 cmdline_fixed_string_t all;
1108 cmdline_fixed_string_t item1;
1109 cmdline_fixed_string_t item2;
1110 cmdline_fixed_string_t value1;
1111 cmdline_fixed_string_t value2;
1115 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1120 if (!strcmp(duplexstr, "half")) {
1121 duplex = ETH_LINK_HALF_DUPLEX;
1122 } else if (!strcmp(duplexstr, "full")) {
1123 duplex = ETH_LINK_FULL_DUPLEX;
1124 } else if (!strcmp(duplexstr, "auto")) {
1125 duplex = ETH_LINK_FULL_DUPLEX;
1127 printf("Unknown duplex parameter\n");
1131 if (!strcmp(speedstr, "10")) {
1132 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1133 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1134 } else if (!strcmp(speedstr, "100")) {
1135 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1136 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1138 if (duplex != ETH_LINK_FULL_DUPLEX) {
1139 printf("Invalid speed/duplex parameters\n");
1142 if (!strcmp(speedstr, "1000")) {
1143 *speed = ETH_LINK_SPEED_1G;
1144 } else if (!strcmp(speedstr, "10000")) {
1145 *speed = ETH_LINK_SPEED_10G;
1146 } else if (!strcmp(speedstr, "25000")) {
1147 *speed = ETH_LINK_SPEED_25G;
1148 } else if (!strcmp(speedstr, "40000")) {
1149 *speed = ETH_LINK_SPEED_40G;
1150 } else if (!strcmp(speedstr, "50000")) {
1151 *speed = ETH_LINK_SPEED_50G;
1152 } else if (!strcmp(speedstr, "100000")) {
1153 *speed = ETH_LINK_SPEED_100G;
1154 } else if (!strcmp(speedstr, "auto")) {
1155 *speed = ETH_LINK_SPEED_AUTONEG;
1157 printf("Unknown speed parameter\n");
1166 cmd_config_speed_all_parsed(void *parsed_result,
1167 __attribute__((unused)) struct cmdline *cl,
1168 __attribute__((unused)) void *data)
1170 struct cmd_config_speed_all *res = parsed_result;
1171 uint32_t link_speed;
1174 if (!all_ports_stopped()) {
1175 printf("Please stop all ports first\n");
1179 if (parse_and_check_speed_duplex(res->value1, res->value2,
1183 RTE_ETH_FOREACH_DEV(pid) {
1184 ports[pid].dev_conf.link_speeds = link_speed;
1187 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1190 cmdline_parse_token_string_t cmd_config_speed_all_port =
1191 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1192 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1193 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1195 cmdline_parse_token_string_t cmd_config_speed_all_all =
1196 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1197 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1198 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1199 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1200 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1201 "10#100#1000#10000#25000#40000#50000#100000#auto");
1202 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1203 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1204 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1205 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1208 cmdline_parse_inst_t cmd_config_speed_all = {
1209 .f = cmd_config_speed_all_parsed,
1211 .help_str = "port config all speed "
1212 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1215 (void *)&cmd_config_speed_all_port,
1216 (void *)&cmd_config_speed_all_keyword,
1217 (void *)&cmd_config_speed_all_all,
1218 (void *)&cmd_config_speed_all_item1,
1219 (void *)&cmd_config_speed_all_value1,
1220 (void *)&cmd_config_speed_all_item2,
1221 (void *)&cmd_config_speed_all_value2,
1226 /* *** configure speed for specific port *** */
1227 struct cmd_config_speed_specific {
1228 cmdline_fixed_string_t port;
1229 cmdline_fixed_string_t keyword;
1231 cmdline_fixed_string_t item1;
1232 cmdline_fixed_string_t item2;
1233 cmdline_fixed_string_t value1;
1234 cmdline_fixed_string_t value2;
1238 cmd_config_speed_specific_parsed(void *parsed_result,
1239 __attribute__((unused)) struct cmdline *cl,
1240 __attribute__((unused)) void *data)
1242 struct cmd_config_speed_specific *res = parsed_result;
1243 uint32_t link_speed;
1245 if (!all_ports_stopped()) {
1246 printf("Please stop all ports first\n");
1250 if (port_id_is_invalid(res->id, ENABLED_WARN))
1253 if (parse_and_check_speed_duplex(res->value1, res->value2,
1257 ports[res->id].dev_conf.link_speeds = link_speed;
1259 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1263 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1264 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1266 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1267 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1269 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1270 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1271 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1272 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1274 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1275 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1276 "10#100#1000#10000#25000#40000#50000#100000#auto");
1277 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1278 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1280 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1284 cmdline_parse_inst_t cmd_config_speed_specific = {
1285 .f = cmd_config_speed_specific_parsed,
1287 .help_str = "port config <port_id> speed "
1288 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1291 (void *)&cmd_config_speed_specific_port,
1292 (void *)&cmd_config_speed_specific_keyword,
1293 (void *)&cmd_config_speed_specific_id,
1294 (void *)&cmd_config_speed_specific_item1,
1295 (void *)&cmd_config_speed_specific_value1,
1296 (void *)&cmd_config_speed_specific_item2,
1297 (void *)&cmd_config_speed_specific_value2,
1302 /* *** configure txq/rxq, txd/rxd *** */
1303 struct cmd_config_rx_tx {
1304 cmdline_fixed_string_t port;
1305 cmdline_fixed_string_t keyword;
1306 cmdline_fixed_string_t all;
1307 cmdline_fixed_string_t name;
1312 cmd_config_rx_tx_parsed(void *parsed_result,
1313 __attribute__((unused)) struct cmdline *cl,
1314 __attribute__((unused)) void *data)
1316 struct cmd_config_rx_tx *res = parsed_result;
1318 if (!all_ports_stopped()) {
1319 printf("Please stop all ports first\n");
1322 if (!strcmp(res->name, "rxq")) {
1323 if (!res->value && !nb_txq) {
1324 printf("Warning: Either rx or tx queues should be non zero\n");
1327 nb_rxq = res->value;
1329 else if (!strcmp(res->name, "txq")) {
1330 if (!res->value && !nb_rxq) {
1331 printf("Warning: Either rx or tx queues should be non zero\n");
1334 nb_txq = res->value;
1336 else if (!strcmp(res->name, "rxd")) {
1337 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1338 printf("rxd %d invalid - must be > 0 && <= %d\n",
1339 res->value, RTE_TEST_RX_DESC_MAX);
1342 nb_rxd = res->value;
1343 } else if (!strcmp(res->name, "txd")) {
1344 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1345 printf("txd %d invalid - must be > 0 && <= %d\n",
1346 res->value, RTE_TEST_TX_DESC_MAX);
1349 nb_txd = res->value;
1351 printf("Unknown parameter\n");
1359 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1362 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1363 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1364 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1365 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1366 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1367 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1368 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1369 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1371 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1372 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1374 cmdline_parse_inst_t cmd_config_rx_tx = {
1375 .f = cmd_config_rx_tx_parsed,
1377 .help_str = "port config all rxq|txq|rxd|txd <value>",
1379 (void *)&cmd_config_rx_tx_port,
1380 (void *)&cmd_config_rx_tx_keyword,
1381 (void *)&cmd_config_rx_tx_all,
1382 (void *)&cmd_config_rx_tx_name,
1383 (void *)&cmd_config_rx_tx_value,
1388 /* *** config max packet length *** */
1389 struct cmd_config_max_pkt_len_result {
1390 cmdline_fixed_string_t port;
1391 cmdline_fixed_string_t keyword;
1392 cmdline_fixed_string_t all;
1393 cmdline_fixed_string_t name;
1398 cmd_config_max_pkt_len_parsed(void *parsed_result,
1399 __attribute__((unused)) struct cmdline *cl,
1400 __attribute__((unused)) void *data)
1402 struct cmd_config_max_pkt_len_result *res = parsed_result;
1404 if (!all_ports_stopped()) {
1405 printf("Please stop all ports first\n");
1409 if (!strcmp(res->name, "max-pkt-len")) {
1410 if (res->value < ETHER_MIN_LEN) {
1411 printf("max-pkt-len can not be less than %d\n",
1415 if (res->value == rx_mode.max_rx_pkt_len)
1418 rx_mode.max_rx_pkt_len = res->value;
1419 if (res->value > ETHER_MAX_LEN)
1420 rx_mode.jumbo_frame = 1;
1422 rx_mode.jumbo_frame = 0;
1424 printf("Unknown parameter\n");
1430 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1433 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1434 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1436 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1437 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1439 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1440 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1442 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1443 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1445 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1446 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1449 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1450 .f = cmd_config_max_pkt_len_parsed,
1452 .help_str = "port config all max-pkt-len <value>",
1454 (void *)&cmd_config_max_pkt_len_port,
1455 (void *)&cmd_config_max_pkt_len_keyword,
1456 (void *)&cmd_config_max_pkt_len_all,
1457 (void *)&cmd_config_max_pkt_len_name,
1458 (void *)&cmd_config_max_pkt_len_value,
1463 /* *** configure port MTU *** */
1464 struct cmd_config_mtu_result {
1465 cmdline_fixed_string_t port;
1466 cmdline_fixed_string_t keyword;
1467 cmdline_fixed_string_t mtu;
1473 cmd_config_mtu_parsed(void *parsed_result,
1474 __attribute__((unused)) struct cmdline *cl,
1475 __attribute__((unused)) void *data)
1477 struct cmd_config_mtu_result *res = parsed_result;
1479 if (res->value < ETHER_MIN_LEN) {
1480 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1483 port_mtu_set(res->port_id, res->value);
1486 cmdline_parse_token_string_t cmd_config_mtu_port =
1487 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1489 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1492 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1495 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1496 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1497 cmdline_parse_token_num_t cmd_config_mtu_value =
1498 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1500 cmdline_parse_inst_t cmd_config_mtu = {
1501 .f = cmd_config_mtu_parsed,
1503 .help_str = "port config mtu <port_id> <value>",
1505 (void *)&cmd_config_mtu_port,
1506 (void *)&cmd_config_mtu_keyword,
1507 (void *)&cmd_config_mtu_mtu,
1508 (void *)&cmd_config_mtu_port_id,
1509 (void *)&cmd_config_mtu_value,
1514 /* *** configure rx mode *** */
1515 struct cmd_config_rx_mode_flag {
1516 cmdline_fixed_string_t port;
1517 cmdline_fixed_string_t keyword;
1518 cmdline_fixed_string_t all;
1519 cmdline_fixed_string_t name;
1520 cmdline_fixed_string_t value;
1524 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1525 __attribute__((unused)) struct cmdline *cl,
1526 __attribute__((unused)) void *data)
1528 struct cmd_config_rx_mode_flag *res = parsed_result;
1530 if (!all_ports_stopped()) {
1531 printf("Please stop all ports first\n");
1535 if (!strcmp(res->name, "crc-strip")) {
1536 if (!strcmp(res->value, "on"))
1537 rx_mode.hw_strip_crc = 1;
1538 else if (!strcmp(res->value, "off"))
1539 rx_mode.hw_strip_crc = 0;
1541 printf("Unknown parameter\n");
1544 } else if (!strcmp(res->name, "scatter")) {
1545 if (!strcmp(res->value, "on"))
1546 rx_mode.enable_scatter = 1;
1547 else if (!strcmp(res->value, "off"))
1548 rx_mode.enable_scatter = 0;
1550 printf("Unknown parameter\n");
1553 } else if (!strcmp(res->name, "rx-cksum")) {
1554 if (!strcmp(res->value, "on"))
1555 rx_mode.hw_ip_checksum = 1;
1556 else if (!strcmp(res->value, "off"))
1557 rx_mode.hw_ip_checksum = 0;
1559 printf("Unknown parameter\n");
1562 } else if (!strcmp(res->name, "hw-vlan")) {
1563 if (!strcmp(res->value, "on")) {
1564 rx_mode.hw_vlan_filter = 1;
1565 rx_mode.hw_vlan_strip = 1;
1567 else if (!strcmp(res->value, "off")) {
1568 rx_mode.hw_vlan_filter = 0;
1569 rx_mode.hw_vlan_strip = 0;
1572 printf("Unknown parameter\n");
1575 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1576 if (!strcmp(res->value, "on"))
1577 rx_mode.hw_vlan_filter = 1;
1578 else if (!strcmp(res->value, "off"))
1579 rx_mode.hw_vlan_filter = 0;
1581 printf("Unknown parameter\n");
1584 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1585 if (!strcmp(res->value, "on"))
1586 rx_mode.hw_vlan_strip = 1;
1587 else if (!strcmp(res->value, "off"))
1588 rx_mode.hw_vlan_strip = 0;
1590 printf("Unknown parameter\n");
1593 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1594 if (!strcmp(res->value, "on"))
1595 rx_mode.hw_vlan_extend = 1;
1596 else if (!strcmp(res->value, "off"))
1597 rx_mode.hw_vlan_extend = 0;
1599 printf("Unknown parameter\n");
1602 } else if (!strcmp(res->name, "drop-en")) {
1603 if (!strcmp(res->value, "on"))
1605 else if (!strcmp(res->value, "off"))
1608 printf("Unknown parameter\n");
1612 printf("Unknown parameter\n");
1618 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1621 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1622 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1623 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1624 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1626 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1627 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1628 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1630 "crc-strip#scatter#rx-cksum#hw-vlan#"
1631 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1632 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1633 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1636 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1637 .f = cmd_config_rx_mode_flag_parsed,
1639 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1640 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1642 (void *)&cmd_config_rx_mode_flag_port,
1643 (void *)&cmd_config_rx_mode_flag_keyword,
1644 (void *)&cmd_config_rx_mode_flag_all,
1645 (void *)&cmd_config_rx_mode_flag_name,
1646 (void *)&cmd_config_rx_mode_flag_value,
1651 /* *** configure rss *** */
1652 struct cmd_config_rss {
1653 cmdline_fixed_string_t port;
1654 cmdline_fixed_string_t keyword;
1655 cmdline_fixed_string_t all;
1656 cmdline_fixed_string_t name;
1657 cmdline_fixed_string_t value;
1661 cmd_config_rss_parsed(void *parsed_result,
1662 __attribute__((unused)) struct cmdline *cl,
1663 __attribute__((unused)) void *data)
1665 struct cmd_config_rss *res = parsed_result;
1666 struct rte_eth_rss_conf rss_conf;
1670 if (!strcmp(res->value, "all"))
1671 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1672 ETH_RSS_UDP | ETH_RSS_SCTP |
1674 else if (!strcmp(res->value, "ip"))
1675 rss_conf.rss_hf = ETH_RSS_IP;
1676 else if (!strcmp(res->value, "udp"))
1677 rss_conf.rss_hf = ETH_RSS_UDP;
1678 else if (!strcmp(res->value, "tcp"))
1679 rss_conf.rss_hf = ETH_RSS_TCP;
1680 else if (!strcmp(res->value, "sctp"))
1681 rss_conf.rss_hf = ETH_RSS_SCTP;
1682 else if (!strcmp(res->value, "ether"))
1683 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1684 else if (!strcmp(res->value, "port"))
1685 rss_conf.rss_hf = ETH_RSS_PORT;
1686 else if (!strcmp(res->value, "vxlan"))
1687 rss_conf.rss_hf = ETH_RSS_VXLAN;
1688 else if (!strcmp(res->value, "geneve"))
1689 rss_conf.rss_hf = ETH_RSS_GENEVE;
1690 else if (!strcmp(res->value, "nvgre"))
1691 rss_conf.rss_hf = ETH_RSS_NVGRE;
1692 else if (!strcmp(res->value, "none"))
1693 rss_conf.rss_hf = 0;
1695 printf("Unknown parameter\n");
1698 rss_conf.rss_key = NULL;
1699 for (i = 0; i < rte_eth_dev_count(); i++) {
1700 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1702 printf("Configuration of RSS hash at ethernet port %d "
1703 "failed with error (%d): %s.\n",
1704 i, -diag, strerror(-diag));
1708 cmdline_parse_token_string_t cmd_config_rss_port =
1709 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1710 cmdline_parse_token_string_t cmd_config_rss_keyword =
1711 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1712 cmdline_parse_token_string_t cmd_config_rss_all =
1713 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1714 cmdline_parse_token_string_t cmd_config_rss_name =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1716 cmdline_parse_token_string_t cmd_config_rss_value =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1718 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1720 cmdline_parse_inst_t cmd_config_rss = {
1721 .f = cmd_config_rss_parsed,
1723 .help_str = "port config all rss "
1724 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1726 (void *)&cmd_config_rss_port,
1727 (void *)&cmd_config_rss_keyword,
1728 (void *)&cmd_config_rss_all,
1729 (void *)&cmd_config_rss_name,
1730 (void *)&cmd_config_rss_value,
1735 /* *** configure rss hash key *** */
1736 struct cmd_config_rss_hash_key {
1737 cmdline_fixed_string_t port;
1738 cmdline_fixed_string_t config;
1740 cmdline_fixed_string_t rss_hash_key;
1741 cmdline_fixed_string_t rss_type;
1742 cmdline_fixed_string_t key;
1746 hexa_digit_to_value(char hexa_digit)
1748 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1749 return (uint8_t) (hexa_digit - '0');
1750 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1751 return (uint8_t) ((hexa_digit - 'a') + 10);
1752 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1753 return (uint8_t) ((hexa_digit - 'A') + 10);
1754 /* Invalid hexa digit */
1759 parse_and_check_key_hexa_digit(char *key, int idx)
1763 hexa_v = hexa_digit_to_value(key[idx]);
1765 printf("invalid key: character %c at position %d is not a "
1766 "valid hexa digit\n", key[idx], idx);
1771 cmd_config_rss_hash_key_parsed(void *parsed_result,
1772 __attribute__((unused)) struct cmdline *cl,
1773 __attribute__((unused)) void *data)
1775 struct cmd_config_rss_hash_key *res = parsed_result;
1776 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1780 struct rte_eth_dev_info dev_info;
1781 uint8_t hash_key_size;
1784 memset(&dev_info, 0, sizeof(dev_info));
1785 rte_eth_dev_info_get(res->port_id, &dev_info);
1786 if (dev_info.hash_key_size > 0 &&
1787 dev_info.hash_key_size <= sizeof(hash_key))
1788 hash_key_size = dev_info.hash_key_size;
1790 printf("dev_info did not provide a valid hash key size\n");
1793 /* Check the length of the RSS hash key */
1794 key_len = strlen(res->key);
1795 if (key_len != (hash_key_size * 2)) {
1796 printf("key length: %d invalid - key must be a string of %d"
1797 " hexa-decimal numbers\n",
1798 (int) key_len, hash_key_size * 2);
1801 /* Translate RSS hash key into binary representation */
1802 for (i = 0; i < hash_key_size; i++) {
1803 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1806 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1809 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1811 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1815 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1816 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1817 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1818 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1820 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1821 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1822 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1823 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1824 rss_hash_key, "rss-hash-key");
1825 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1826 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1827 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1828 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1829 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1830 "ipv6-tcp-ex#ipv6-udp-ex");
1831 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1834 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1835 .f = cmd_config_rss_hash_key_parsed,
1837 .help_str = "port config <port_id> rss-hash-key "
1838 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1839 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1840 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1841 "<string of hex digits (variable length, NIC dependent)>",
1843 (void *)&cmd_config_rss_hash_key_port,
1844 (void *)&cmd_config_rss_hash_key_config,
1845 (void *)&cmd_config_rss_hash_key_port_id,
1846 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1847 (void *)&cmd_config_rss_hash_key_rss_type,
1848 (void *)&cmd_config_rss_hash_key_value,
1853 /* *** configure port rxq/txq start/stop *** */
1854 struct cmd_config_rxtx_queue {
1855 cmdline_fixed_string_t port;
1857 cmdline_fixed_string_t rxtxq;
1859 cmdline_fixed_string_t opname;
1863 cmd_config_rxtx_queue_parsed(void *parsed_result,
1864 __attribute__((unused)) struct cmdline *cl,
1865 __attribute__((unused)) void *data)
1867 struct cmd_config_rxtx_queue *res = parsed_result;
1872 if (test_done == 0) {
1873 printf("Please stop forwarding first\n");
1877 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1880 if (port_is_started(res->portid) != 1) {
1881 printf("Please start port %u first\n", res->portid);
1885 if (!strcmp(res->rxtxq, "rxq"))
1887 else if (!strcmp(res->rxtxq, "txq"))
1890 printf("Unknown parameter\n");
1894 if (isrx && rx_queue_id_is_invalid(res->qid))
1896 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1899 if (!strcmp(res->opname, "start"))
1901 else if (!strcmp(res->opname, "stop"))
1904 printf("Unknown parameter\n");
1908 if (isstart && isrx)
1909 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1910 else if (!isstart && isrx)
1911 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1912 else if (isstart && !isrx)
1913 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1915 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1917 if (ret == -ENOTSUP)
1918 printf("Function not supported in PMD driver\n");
1921 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1922 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1923 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1924 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1925 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1926 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1927 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1928 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1929 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1930 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1933 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1934 .f = cmd_config_rxtx_queue_parsed,
1936 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1938 (void *)&cmd_config_speed_all_port,
1939 (void *)&cmd_config_rxtx_queue_portid,
1940 (void *)&cmd_config_rxtx_queue_rxtxq,
1941 (void *)&cmd_config_rxtx_queue_qid,
1942 (void *)&cmd_config_rxtx_queue_opname,
1947 /* *** Configure RSS RETA *** */
1948 struct cmd_config_rss_reta {
1949 cmdline_fixed_string_t port;
1950 cmdline_fixed_string_t keyword;
1952 cmdline_fixed_string_t name;
1953 cmdline_fixed_string_t list_name;
1954 cmdline_fixed_string_t list_of_items;
1958 parse_reta_config(const char *str,
1959 struct rte_eth_rss_reta_entry64 *reta_conf,
1960 uint16_t nb_entries)
1964 uint16_t hash_index, idx, shift;
1967 const char *p, *p0 = str;
1974 unsigned long int_fld[_NUM_FLD];
1975 char *str_fld[_NUM_FLD];
1977 while ((p = strchr(p0,'(')) != NULL) {
1979 if((p0 = strchr(p,')')) == NULL)
1983 if(size >= sizeof(s))
1986 snprintf(s, sizeof(s), "%.*s", size, p);
1987 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1989 for (i = 0; i < _NUM_FLD; i++) {
1991 int_fld[i] = strtoul(str_fld[i], &end, 0);
1992 if (errno != 0 || end == str_fld[i] ||
1997 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1998 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2000 if (hash_index >= nb_entries) {
2001 printf("Invalid RETA hash index=%d\n", hash_index);
2005 idx = hash_index / RTE_RETA_GROUP_SIZE;
2006 shift = hash_index % RTE_RETA_GROUP_SIZE;
2007 reta_conf[idx].mask |= (1ULL << shift);
2008 reta_conf[idx].reta[shift] = nb_queue;
2015 cmd_set_rss_reta_parsed(void *parsed_result,
2016 __attribute__((unused)) struct cmdline *cl,
2017 __attribute__((unused)) void *data)
2020 struct rte_eth_dev_info dev_info;
2021 struct rte_eth_rss_reta_entry64 reta_conf[8];
2022 struct cmd_config_rss_reta *res = parsed_result;
2024 memset(&dev_info, 0, sizeof(dev_info));
2025 rte_eth_dev_info_get(res->port_id, &dev_info);
2026 if (dev_info.reta_size == 0) {
2027 printf("Redirection table size is 0 which is "
2028 "invalid for RSS\n");
2031 printf("The reta size of port %d is %u\n",
2032 res->port_id, dev_info.reta_size);
2033 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2034 printf("Currently do not support more than %u entries of "
2035 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2039 memset(reta_conf, 0, sizeof(reta_conf));
2040 if (!strcmp(res->list_name, "reta")) {
2041 if (parse_reta_config(res->list_of_items, reta_conf,
2042 dev_info.reta_size)) {
2043 printf("Invalid RSS Redirection Table "
2044 "config entered\n");
2047 ret = rte_eth_dev_rss_reta_update(res->port_id,
2048 reta_conf, dev_info.reta_size);
2050 printf("Bad redirection table parameter, "
2051 "return code = %d \n", ret);
2055 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2056 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2057 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2058 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2059 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2060 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2061 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2062 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2063 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2065 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2066 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2068 cmdline_parse_inst_t cmd_config_rss_reta = {
2069 .f = cmd_set_rss_reta_parsed,
2071 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2073 (void *)&cmd_config_rss_reta_port,
2074 (void *)&cmd_config_rss_reta_keyword,
2075 (void *)&cmd_config_rss_reta_port_id,
2076 (void *)&cmd_config_rss_reta_name,
2077 (void *)&cmd_config_rss_reta_list_name,
2078 (void *)&cmd_config_rss_reta_list_of_items,
2083 /* *** SHOW PORT RETA INFO *** */
2084 struct cmd_showport_reta {
2085 cmdline_fixed_string_t show;
2086 cmdline_fixed_string_t port;
2088 cmdline_fixed_string_t rss;
2089 cmdline_fixed_string_t reta;
2091 cmdline_fixed_string_t list_of_items;
2095 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2096 uint16_t nb_entries,
2100 const char *p, *p0 = str;
2105 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2106 RTE_RETA_GROUP_SIZE;
2109 p = strchr(p0, '(');
2113 p0 = strchr(p, ')');
2117 if (size >= sizeof(s)) {
2118 printf("The string size exceeds the internal buffer size\n");
2121 snprintf(s, sizeof(s), "%.*s", size, p);
2122 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2123 if (ret <= 0 || ret != num) {
2124 printf("The bits of masks do not match the number of "
2125 "reta entries: %u\n", num);
2128 for (i = 0; i < ret; i++)
2129 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2135 cmd_showport_reta_parsed(void *parsed_result,
2136 __attribute__((unused)) struct cmdline *cl,
2137 __attribute__((unused)) void *data)
2139 struct cmd_showport_reta *res = parsed_result;
2140 struct rte_eth_rss_reta_entry64 reta_conf[8];
2141 struct rte_eth_dev_info dev_info;
2143 memset(&dev_info, 0, sizeof(dev_info));
2144 rte_eth_dev_info_get(res->port_id, &dev_info);
2145 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2146 res->size > ETH_RSS_RETA_SIZE_512) {
2147 printf("Invalid redirection table size: %u\n", res->size);
2151 memset(reta_conf, 0, sizeof(reta_conf));
2152 if (showport_parse_reta_config(reta_conf, res->size,
2153 res->list_of_items) < 0) {
2154 printf("Invalid string: %s for reta masks\n",
2155 res->list_of_items);
2158 port_rss_reta_info(res->port_id, reta_conf, res->size);
2161 cmdline_parse_token_string_t cmd_showport_reta_show =
2162 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2163 cmdline_parse_token_string_t cmd_showport_reta_port =
2164 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2165 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2166 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2167 cmdline_parse_token_string_t cmd_showport_reta_rss =
2168 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2169 cmdline_parse_token_string_t cmd_showport_reta_reta =
2170 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2171 cmdline_parse_token_num_t cmd_showport_reta_size =
2172 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2173 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2174 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2175 list_of_items, NULL);
2177 cmdline_parse_inst_t cmd_showport_reta = {
2178 .f = cmd_showport_reta_parsed,
2180 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2182 (void *)&cmd_showport_reta_show,
2183 (void *)&cmd_showport_reta_port,
2184 (void *)&cmd_showport_reta_port_id,
2185 (void *)&cmd_showport_reta_rss,
2186 (void *)&cmd_showport_reta_reta,
2187 (void *)&cmd_showport_reta_size,
2188 (void *)&cmd_showport_reta_list_of_items,
2193 /* *** Show RSS hash configuration *** */
2194 struct cmd_showport_rss_hash {
2195 cmdline_fixed_string_t show;
2196 cmdline_fixed_string_t port;
2198 cmdline_fixed_string_t rss_hash;
2199 cmdline_fixed_string_t rss_type;
2200 cmdline_fixed_string_t key; /* optional argument */
2203 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2204 __attribute__((unused)) struct cmdline *cl,
2207 struct cmd_showport_rss_hash *res = parsed_result;
2209 port_rss_hash_conf_show(res->port_id, res->rss_type,
2210 show_rss_key != NULL);
2213 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2214 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2215 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2216 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2217 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2218 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2219 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2220 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2222 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2223 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2224 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2225 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2226 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2227 "ipv6-tcp-ex#ipv6-udp-ex");
2228 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2229 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2231 cmdline_parse_inst_t cmd_showport_rss_hash = {
2232 .f = cmd_showport_rss_hash_parsed,
2234 .help_str = "show port <port_id> rss-hash "
2235 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2236 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2237 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2239 (void *)&cmd_showport_rss_hash_show,
2240 (void *)&cmd_showport_rss_hash_port,
2241 (void *)&cmd_showport_rss_hash_port_id,
2242 (void *)&cmd_showport_rss_hash_rss_hash,
2243 (void *)&cmd_showport_rss_hash_rss_hash_info,
2248 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2249 .f = cmd_showport_rss_hash_parsed,
2251 .help_str = "show port <port_id> rss-hash "
2252 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2253 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2254 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2256 (void *)&cmd_showport_rss_hash_show,
2257 (void *)&cmd_showport_rss_hash_port,
2258 (void *)&cmd_showport_rss_hash_port_id,
2259 (void *)&cmd_showport_rss_hash_rss_hash,
2260 (void *)&cmd_showport_rss_hash_rss_hash_info,
2261 (void *)&cmd_showport_rss_hash_rss_key,
2266 /* *** Configure DCB *** */
2267 struct cmd_config_dcb {
2268 cmdline_fixed_string_t port;
2269 cmdline_fixed_string_t config;
2271 cmdline_fixed_string_t dcb;
2272 cmdline_fixed_string_t vt;
2273 cmdline_fixed_string_t vt_en;
2275 cmdline_fixed_string_t pfc;
2276 cmdline_fixed_string_t pfc_en;
2280 cmd_config_dcb_parsed(void *parsed_result,
2281 __attribute__((unused)) struct cmdline *cl,
2282 __attribute__((unused)) void *data)
2284 struct cmd_config_dcb *res = parsed_result;
2285 portid_t port_id = res->port_id;
2286 struct rte_port *port;
2290 port = &ports[port_id];
2291 /** Check if the port is not started **/
2292 if (port->port_status != RTE_PORT_STOPPED) {
2293 printf("Please stop port %d first\n", port_id);
2297 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2298 printf("The invalid number of traffic class,"
2299 " only 4 or 8 allowed.\n");
2303 if (nb_fwd_lcores < res->num_tcs) {
2304 printf("nb_cores shouldn't be less than number of TCs.\n");
2307 if (!strncmp(res->pfc_en, "on", 2))
2312 /* DCB in VT mode */
2313 if (!strncmp(res->vt_en, "on", 2))
2314 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2315 (enum rte_eth_nb_tcs)res->num_tcs,
2318 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2319 (enum rte_eth_nb_tcs)res->num_tcs,
2324 printf("Cannot initialize network ports.\n");
2328 cmd_reconfig_device_queue(port_id, 1, 1);
2331 cmdline_parse_token_string_t cmd_config_dcb_port =
2332 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2333 cmdline_parse_token_string_t cmd_config_dcb_config =
2334 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2335 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2336 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2337 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2338 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2339 cmdline_parse_token_string_t cmd_config_dcb_vt =
2340 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2341 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2342 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2343 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2344 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2345 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2346 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2347 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2348 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2350 cmdline_parse_inst_t cmd_config_dcb = {
2351 .f = cmd_config_dcb_parsed,
2353 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2355 (void *)&cmd_config_dcb_port,
2356 (void *)&cmd_config_dcb_config,
2357 (void *)&cmd_config_dcb_port_id,
2358 (void *)&cmd_config_dcb_dcb,
2359 (void *)&cmd_config_dcb_vt,
2360 (void *)&cmd_config_dcb_vt_en,
2361 (void *)&cmd_config_dcb_num_tcs,
2362 (void *)&cmd_config_dcb_pfc,
2363 (void *)&cmd_config_dcb_pfc_en,
2368 /* *** configure number of packets per burst *** */
2369 struct cmd_config_burst {
2370 cmdline_fixed_string_t port;
2371 cmdline_fixed_string_t keyword;
2372 cmdline_fixed_string_t all;
2373 cmdline_fixed_string_t name;
2378 cmd_config_burst_parsed(void *parsed_result,
2379 __attribute__((unused)) struct cmdline *cl,
2380 __attribute__((unused)) void *data)
2382 struct cmd_config_burst *res = parsed_result;
2384 if (!all_ports_stopped()) {
2385 printf("Please stop all ports first\n");
2389 if (!strcmp(res->name, "burst")) {
2390 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2391 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2394 nb_pkt_per_burst = res->value;
2396 printf("Unknown parameter\n");
2402 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2405 cmdline_parse_token_string_t cmd_config_burst_port =
2406 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2407 cmdline_parse_token_string_t cmd_config_burst_keyword =
2408 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2409 cmdline_parse_token_string_t cmd_config_burst_all =
2410 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2411 cmdline_parse_token_string_t cmd_config_burst_name =
2412 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2413 cmdline_parse_token_num_t cmd_config_burst_value =
2414 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2416 cmdline_parse_inst_t cmd_config_burst = {
2417 .f = cmd_config_burst_parsed,
2419 .help_str = "port config all burst <value>",
2421 (void *)&cmd_config_burst_port,
2422 (void *)&cmd_config_burst_keyword,
2423 (void *)&cmd_config_burst_all,
2424 (void *)&cmd_config_burst_name,
2425 (void *)&cmd_config_burst_value,
2430 /* *** configure rx/tx queues *** */
2431 struct cmd_config_thresh {
2432 cmdline_fixed_string_t port;
2433 cmdline_fixed_string_t keyword;
2434 cmdline_fixed_string_t all;
2435 cmdline_fixed_string_t name;
2440 cmd_config_thresh_parsed(void *parsed_result,
2441 __attribute__((unused)) struct cmdline *cl,
2442 __attribute__((unused)) void *data)
2444 struct cmd_config_thresh *res = parsed_result;
2446 if (!all_ports_stopped()) {
2447 printf("Please stop all ports first\n");
2451 if (!strcmp(res->name, "txpt"))
2452 tx_pthresh = res->value;
2453 else if(!strcmp(res->name, "txht"))
2454 tx_hthresh = res->value;
2455 else if(!strcmp(res->name, "txwt"))
2456 tx_wthresh = res->value;
2457 else if(!strcmp(res->name, "rxpt"))
2458 rx_pthresh = res->value;
2459 else if(!strcmp(res->name, "rxht"))
2460 rx_hthresh = res->value;
2461 else if(!strcmp(res->name, "rxwt"))
2462 rx_wthresh = res->value;
2464 printf("Unknown parameter\n");
2470 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2473 cmdline_parse_token_string_t cmd_config_thresh_port =
2474 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2475 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2476 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2477 cmdline_parse_token_string_t cmd_config_thresh_all =
2478 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2479 cmdline_parse_token_string_t cmd_config_thresh_name =
2480 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2481 "txpt#txht#txwt#rxpt#rxht#rxwt");
2482 cmdline_parse_token_num_t cmd_config_thresh_value =
2483 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2485 cmdline_parse_inst_t cmd_config_thresh = {
2486 .f = cmd_config_thresh_parsed,
2488 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2490 (void *)&cmd_config_thresh_port,
2491 (void *)&cmd_config_thresh_keyword,
2492 (void *)&cmd_config_thresh_all,
2493 (void *)&cmd_config_thresh_name,
2494 (void *)&cmd_config_thresh_value,
2499 /* *** configure free/rs threshold *** */
2500 struct cmd_config_threshold {
2501 cmdline_fixed_string_t port;
2502 cmdline_fixed_string_t keyword;
2503 cmdline_fixed_string_t all;
2504 cmdline_fixed_string_t name;
2509 cmd_config_threshold_parsed(void *parsed_result,
2510 __attribute__((unused)) struct cmdline *cl,
2511 __attribute__((unused)) void *data)
2513 struct cmd_config_threshold *res = parsed_result;
2515 if (!all_ports_stopped()) {
2516 printf("Please stop all ports first\n");
2520 if (!strcmp(res->name, "txfreet"))
2521 tx_free_thresh = res->value;
2522 else if (!strcmp(res->name, "txrst"))
2523 tx_rs_thresh = res->value;
2524 else if (!strcmp(res->name, "rxfreet"))
2525 rx_free_thresh = res->value;
2527 printf("Unknown parameter\n");
2533 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2536 cmdline_parse_token_string_t cmd_config_threshold_port =
2537 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2538 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2539 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2541 cmdline_parse_token_string_t cmd_config_threshold_all =
2542 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2543 cmdline_parse_token_string_t cmd_config_threshold_name =
2544 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2545 "txfreet#txrst#rxfreet");
2546 cmdline_parse_token_num_t cmd_config_threshold_value =
2547 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2549 cmdline_parse_inst_t cmd_config_threshold = {
2550 .f = cmd_config_threshold_parsed,
2552 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2554 (void *)&cmd_config_threshold_port,
2555 (void *)&cmd_config_threshold_keyword,
2556 (void *)&cmd_config_threshold_all,
2557 (void *)&cmd_config_threshold_name,
2558 (void *)&cmd_config_threshold_value,
2564 struct cmd_stop_result {
2565 cmdline_fixed_string_t stop;
2568 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2569 __attribute__((unused)) struct cmdline *cl,
2570 __attribute__((unused)) void *data)
2572 stop_packet_forwarding();
2575 cmdline_parse_token_string_t cmd_stop_stop =
2576 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2578 cmdline_parse_inst_t cmd_stop = {
2579 .f = cmd_stop_parsed,
2581 .help_str = "stop: Stop packet forwarding",
2583 (void *)&cmd_stop_stop,
2588 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2591 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2592 unsigned int *parsed_items, int check_unique_values)
2594 unsigned int nb_item;
2602 * First parse all items in the list and store their value.
2607 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2609 if ((c >= '0') && (c <= '9')) {
2610 value = (unsigned int) (value * 10 + (c - '0'));
2615 printf("character %c is not a decimal digit\n", c);
2619 printf("No valid value before comma\n");
2622 if (nb_item < max_items) {
2623 parsed_items[nb_item] = value;
2629 if (nb_item >= max_items) {
2630 printf("Number of %s = %u > %u (maximum items)\n",
2631 item_name, nb_item + 1, max_items);
2634 parsed_items[nb_item++] = value;
2635 if (! check_unique_values)
2639 * Then, check that all values in the list are differents.
2640 * No optimization here...
2642 for (i = 0; i < nb_item; i++) {
2643 for (j = i + 1; j < nb_item; j++) {
2644 if (parsed_items[j] == parsed_items[i]) {
2645 printf("duplicated %s %u at index %u and %u\n",
2646 item_name, parsed_items[i], i, j);
2654 struct cmd_set_list_result {
2655 cmdline_fixed_string_t cmd_keyword;
2656 cmdline_fixed_string_t list_name;
2657 cmdline_fixed_string_t list_of_items;
2660 static void cmd_set_list_parsed(void *parsed_result,
2661 __attribute__((unused)) struct cmdline *cl,
2662 __attribute__((unused)) void *data)
2664 struct cmd_set_list_result *res;
2666 unsigned int lcorelist[RTE_MAX_LCORE];
2667 unsigned int portlist[RTE_MAX_ETHPORTS];
2669 unsigned int nb_item;
2671 if (test_done == 0) {
2672 printf("Please stop forwarding first\n");
2676 res = parsed_result;
2677 if (!strcmp(res->list_name, "corelist")) {
2678 nb_item = parse_item_list(res->list_of_items, "core",
2680 parsed_items.lcorelist, 1);
2682 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2687 if (!strcmp(res->list_name, "portlist")) {
2688 nb_item = parse_item_list(res->list_of_items, "port",
2690 parsed_items.portlist, 1);
2692 set_fwd_ports_list(parsed_items.portlist, nb_item);
2698 cmdline_parse_token_string_t cmd_set_list_keyword =
2699 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2701 cmdline_parse_token_string_t cmd_set_list_name =
2702 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2703 "corelist#portlist");
2704 cmdline_parse_token_string_t cmd_set_list_of_items =
2705 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2708 cmdline_parse_inst_t cmd_set_fwd_list = {
2709 .f = cmd_set_list_parsed,
2711 .help_str = "set corelist|portlist <list0[,list1]*>",
2713 (void *)&cmd_set_list_keyword,
2714 (void *)&cmd_set_list_name,
2715 (void *)&cmd_set_list_of_items,
2720 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2722 struct cmd_setmask_result {
2723 cmdline_fixed_string_t set;
2724 cmdline_fixed_string_t mask;
2728 static void cmd_set_mask_parsed(void *parsed_result,
2729 __attribute__((unused)) struct cmdline *cl,
2730 __attribute__((unused)) void *data)
2732 struct cmd_setmask_result *res = parsed_result;
2734 if (test_done == 0) {
2735 printf("Please stop forwarding first\n");
2738 if (!strcmp(res->mask, "coremask")) {
2739 set_fwd_lcores_mask(res->hexavalue);
2741 } else if (!strcmp(res->mask, "portmask")) {
2742 set_fwd_ports_mask(res->hexavalue);
2747 cmdline_parse_token_string_t cmd_setmask_set =
2748 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2749 cmdline_parse_token_string_t cmd_setmask_mask =
2750 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2751 "coremask#portmask");
2752 cmdline_parse_token_num_t cmd_setmask_value =
2753 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2755 cmdline_parse_inst_t cmd_set_fwd_mask = {
2756 .f = cmd_set_mask_parsed,
2758 .help_str = "set coremask|portmask <hexadecimal value>",
2760 (void *)&cmd_setmask_set,
2761 (void *)&cmd_setmask_mask,
2762 (void *)&cmd_setmask_value,
2768 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2770 struct cmd_set_result {
2771 cmdline_fixed_string_t set;
2772 cmdline_fixed_string_t what;
2776 static void cmd_set_parsed(void *parsed_result,
2777 __attribute__((unused)) struct cmdline *cl,
2778 __attribute__((unused)) void *data)
2780 struct cmd_set_result *res = parsed_result;
2781 if (!strcmp(res->what, "nbport")) {
2782 set_fwd_ports_number(res->value);
2784 } else if (!strcmp(res->what, "nbcore")) {
2785 set_fwd_lcores_number(res->value);
2787 } else if (!strcmp(res->what, "burst"))
2788 set_nb_pkt_per_burst(res->value);
2789 else if (!strcmp(res->what, "verbose"))
2790 set_verbose_level(res->value);
2793 cmdline_parse_token_string_t cmd_set_set =
2794 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2795 cmdline_parse_token_string_t cmd_set_what =
2796 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2797 "nbport#nbcore#burst#verbose");
2798 cmdline_parse_token_num_t cmd_set_value =
2799 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2801 cmdline_parse_inst_t cmd_set_numbers = {
2802 .f = cmd_set_parsed,
2804 .help_str = "set nbport|nbcore|burst|verbose <value>",
2806 (void *)&cmd_set_set,
2807 (void *)&cmd_set_what,
2808 (void *)&cmd_set_value,
2813 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2815 struct cmd_set_txpkts_result {
2816 cmdline_fixed_string_t cmd_keyword;
2817 cmdline_fixed_string_t txpkts;
2818 cmdline_fixed_string_t seg_lengths;
2822 cmd_set_txpkts_parsed(void *parsed_result,
2823 __attribute__((unused)) struct cmdline *cl,
2824 __attribute__((unused)) void *data)
2826 struct cmd_set_txpkts_result *res;
2827 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2828 unsigned int nb_segs;
2830 res = parsed_result;
2831 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2832 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2834 set_tx_pkt_segments(seg_lengths, nb_segs);
2837 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2838 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2839 cmd_keyword, "set");
2840 cmdline_parse_token_string_t cmd_set_txpkts_name =
2841 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2843 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2844 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2847 cmdline_parse_inst_t cmd_set_txpkts = {
2848 .f = cmd_set_txpkts_parsed,
2850 .help_str = "set txpkts <len0[,len1]*>",
2852 (void *)&cmd_set_txpkts_keyword,
2853 (void *)&cmd_set_txpkts_name,
2854 (void *)&cmd_set_txpkts_lengths,
2859 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2861 struct cmd_set_txsplit_result {
2862 cmdline_fixed_string_t cmd_keyword;
2863 cmdline_fixed_string_t txsplit;
2864 cmdline_fixed_string_t mode;
2868 cmd_set_txsplit_parsed(void *parsed_result,
2869 __attribute__((unused)) struct cmdline *cl,
2870 __attribute__((unused)) void *data)
2872 struct cmd_set_txsplit_result *res;
2874 res = parsed_result;
2875 set_tx_pkt_split(res->mode);
2878 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2879 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2880 cmd_keyword, "set");
2881 cmdline_parse_token_string_t cmd_set_txsplit_name =
2882 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2883 txsplit, "txsplit");
2884 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2885 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2888 cmdline_parse_inst_t cmd_set_txsplit = {
2889 .f = cmd_set_txsplit_parsed,
2891 .help_str = "set txsplit on|off|rand",
2893 (void *)&cmd_set_txsplit_keyword,
2894 (void *)&cmd_set_txsplit_name,
2895 (void *)&cmd_set_txsplit_mode,
2900 /* *** CONFIG TX QUEUE FLAGS *** */
2902 struct cmd_config_txqflags_result {
2903 cmdline_fixed_string_t port;
2904 cmdline_fixed_string_t config;
2905 cmdline_fixed_string_t all;
2906 cmdline_fixed_string_t what;
2910 static void cmd_config_txqflags_parsed(void *parsed_result,
2911 __attribute__((unused)) struct cmdline *cl,
2912 __attribute__((unused)) void *data)
2914 struct cmd_config_txqflags_result *res = parsed_result;
2916 if (!all_ports_stopped()) {
2917 printf("Please stop all ports first\n");
2921 if (strcmp(res->what, "txqflags")) {
2922 printf("Unknown parameter\n");
2926 if (res->hexvalue >= 0) {
2927 txq_flags = res->hexvalue;
2929 printf("txqflags must be >= 0\n");
2935 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2938 cmdline_parse_token_string_t cmd_config_txqflags_port =
2939 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2941 cmdline_parse_token_string_t cmd_config_txqflags_config =
2942 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2944 cmdline_parse_token_string_t cmd_config_txqflags_all =
2945 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2947 cmdline_parse_token_string_t cmd_config_txqflags_what =
2948 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2950 cmdline_parse_token_num_t cmd_config_txqflags_value =
2951 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2954 cmdline_parse_inst_t cmd_config_txqflags = {
2955 .f = cmd_config_txqflags_parsed,
2957 .help_str = "port config all txqflags <value>",
2959 (void *)&cmd_config_txqflags_port,
2960 (void *)&cmd_config_txqflags_config,
2961 (void *)&cmd_config_txqflags_all,
2962 (void *)&cmd_config_txqflags_what,
2963 (void *)&cmd_config_txqflags_value,
2968 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2969 struct cmd_rx_vlan_filter_all_result {
2970 cmdline_fixed_string_t rx_vlan;
2971 cmdline_fixed_string_t what;
2972 cmdline_fixed_string_t all;
2977 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2978 __attribute__((unused)) struct cmdline *cl,
2979 __attribute__((unused)) void *data)
2981 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2983 if (!strcmp(res->what, "add"))
2984 rx_vlan_all_filter_set(res->port_id, 1);
2986 rx_vlan_all_filter_set(res->port_id, 0);
2989 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2990 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2991 rx_vlan, "rx_vlan");
2992 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2993 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2995 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2996 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2998 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2999 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3002 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3003 .f = cmd_rx_vlan_filter_all_parsed,
3005 .help_str = "rx_vlan add|rm all <port_id>: "
3006 "Add/Remove all identifiers to/from the set of VLAN "
3007 "identifiers filtered by a port",
3009 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3010 (void *)&cmd_rx_vlan_filter_all_what,
3011 (void *)&cmd_rx_vlan_filter_all_all,
3012 (void *)&cmd_rx_vlan_filter_all_portid,
3017 /* *** VLAN OFFLOAD SET ON A PORT *** */
3018 struct cmd_vlan_offload_result {
3019 cmdline_fixed_string_t vlan;
3020 cmdline_fixed_string_t set;
3021 cmdline_fixed_string_t vlan_type;
3022 cmdline_fixed_string_t what;
3023 cmdline_fixed_string_t on;
3024 cmdline_fixed_string_t port_id;
3028 cmd_vlan_offload_parsed(void *parsed_result,
3029 __attribute__((unused)) struct cmdline *cl,
3030 __attribute__((unused)) void *data)
3033 struct cmd_vlan_offload_result *res = parsed_result;
3036 portid_t port_id = 0;
3040 len = strnlen(str, STR_TOKEN_SIZE);
3042 /* Get port_id first */
3050 tmp = strtoul(str, NULL, 0);
3051 /* If port_id greater that what portid_t can represent, return */
3052 if(tmp >= RTE_MAX_ETHPORTS)
3054 port_id = (portid_t)tmp;
3056 if (!strcmp(res->on, "on"))
3061 if (!strcmp(res->what, "strip"))
3062 rx_vlan_strip_set(port_id, on);
3063 else if(!strcmp(res->what, "stripq")){
3064 uint16_t queue_id = 0;
3066 /* No queue_id, return */
3068 printf("must specify (port,queue_id)\n");
3071 tmp = strtoul(str + i + 1, NULL, 0);
3072 /* If queue_id greater that what 16-bits can represent, return */
3076 queue_id = (uint16_t)tmp;
3077 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3079 else if (!strcmp(res->what, "filter"))
3080 rx_vlan_filter_set(port_id, on);
3082 vlan_extend_set(port_id, on);
3087 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3088 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3090 cmdline_parse_token_string_t cmd_vlan_offload_set =
3091 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3093 cmdline_parse_token_string_t cmd_vlan_offload_what =
3094 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3095 what, "strip#filter#qinq#stripq");
3096 cmdline_parse_token_string_t cmd_vlan_offload_on =
3097 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3099 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3100 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3103 cmdline_parse_inst_t cmd_vlan_offload = {
3104 .f = cmd_vlan_offload_parsed,
3106 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3107 "<port_id[,queue_id]>: "
3108 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3110 (void *)&cmd_vlan_offload_vlan,
3111 (void *)&cmd_vlan_offload_set,
3112 (void *)&cmd_vlan_offload_what,
3113 (void *)&cmd_vlan_offload_on,
3114 (void *)&cmd_vlan_offload_portid,
3119 /* *** VLAN TPID SET ON A PORT *** */
3120 struct cmd_vlan_tpid_result {
3121 cmdline_fixed_string_t vlan;
3122 cmdline_fixed_string_t set;
3123 cmdline_fixed_string_t vlan_type;
3124 cmdline_fixed_string_t what;
3130 cmd_vlan_tpid_parsed(void *parsed_result,
3131 __attribute__((unused)) struct cmdline *cl,
3132 __attribute__((unused)) void *data)
3134 struct cmd_vlan_tpid_result *res = parsed_result;
3135 enum rte_vlan_type vlan_type;
3137 if (!strcmp(res->vlan_type, "inner"))
3138 vlan_type = ETH_VLAN_TYPE_INNER;
3139 else if (!strcmp(res->vlan_type, "outer"))
3140 vlan_type = ETH_VLAN_TYPE_OUTER;
3142 printf("Unknown vlan type\n");
3145 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3148 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3149 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3151 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3152 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3154 cmdline_parse_token_string_t cmd_vlan_type =
3155 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3156 vlan_type, "inner#outer");
3157 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3158 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3160 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3161 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3163 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3164 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3167 cmdline_parse_inst_t cmd_vlan_tpid = {
3168 .f = cmd_vlan_tpid_parsed,
3170 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3171 "Set the VLAN Ether type",
3173 (void *)&cmd_vlan_tpid_vlan,
3174 (void *)&cmd_vlan_tpid_set,
3175 (void *)&cmd_vlan_type,
3176 (void *)&cmd_vlan_tpid_what,
3177 (void *)&cmd_vlan_tpid_tpid,
3178 (void *)&cmd_vlan_tpid_portid,
3183 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3184 struct cmd_rx_vlan_filter_result {
3185 cmdline_fixed_string_t rx_vlan;
3186 cmdline_fixed_string_t what;
3192 cmd_rx_vlan_filter_parsed(void *parsed_result,
3193 __attribute__((unused)) struct cmdline *cl,
3194 __attribute__((unused)) void *data)
3196 struct cmd_rx_vlan_filter_result *res = parsed_result;
3198 if (!strcmp(res->what, "add"))
3199 rx_vft_set(res->port_id, res->vlan_id, 1);
3201 rx_vft_set(res->port_id, res->vlan_id, 0);
3204 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3205 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3206 rx_vlan, "rx_vlan");
3207 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3208 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3210 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3211 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3213 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3214 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3217 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3218 .f = cmd_rx_vlan_filter_parsed,
3220 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3221 "Add/Remove a VLAN identifier to/from the set of VLAN "
3222 "identifiers filtered by a port",
3224 (void *)&cmd_rx_vlan_filter_rx_vlan,
3225 (void *)&cmd_rx_vlan_filter_what,
3226 (void *)&cmd_rx_vlan_filter_vlanid,
3227 (void *)&cmd_rx_vlan_filter_portid,
3232 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3233 struct cmd_tx_vlan_set_result {
3234 cmdline_fixed_string_t tx_vlan;
3235 cmdline_fixed_string_t set;
3241 cmd_tx_vlan_set_parsed(void *parsed_result,
3242 __attribute__((unused)) struct cmdline *cl,
3243 __attribute__((unused)) void *data)
3245 struct cmd_tx_vlan_set_result *res = parsed_result;
3247 tx_vlan_set(res->port_id, res->vlan_id);
3250 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3251 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3252 tx_vlan, "tx_vlan");
3253 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3254 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3256 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3257 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3259 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3260 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3263 cmdline_parse_inst_t cmd_tx_vlan_set = {
3264 .f = cmd_tx_vlan_set_parsed,
3266 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3267 "Enable hardware insertion of a single VLAN header "
3268 "with a given TAG Identifier in packets sent on a port",
3270 (void *)&cmd_tx_vlan_set_tx_vlan,
3271 (void *)&cmd_tx_vlan_set_set,
3272 (void *)&cmd_tx_vlan_set_portid,
3273 (void *)&cmd_tx_vlan_set_vlanid,
3278 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3279 struct cmd_tx_vlan_set_qinq_result {
3280 cmdline_fixed_string_t tx_vlan;
3281 cmdline_fixed_string_t set;
3284 uint16_t vlan_id_outer;
3288 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3289 __attribute__((unused)) struct cmdline *cl,
3290 __attribute__((unused)) void *data)
3292 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3294 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3297 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3298 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3299 tx_vlan, "tx_vlan");
3300 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3301 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3303 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3304 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3306 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3307 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3309 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3310 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3311 vlan_id_outer, UINT16);
3313 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3314 .f = cmd_tx_vlan_set_qinq_parsed,
3316 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3317 "Enable hardware insertion of double VLAN header "
3318 "with given TAG Identifiers in packets sent on a port",
3320 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3321 (void *)&cmd_tx_vlan_set_qinq_set,
3322 (void *)&cmd_tx_vlan_set_qinq_portid,
3323 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3324 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3329 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3330 struct cmd_tx_vlan_set_pvid_result {
3331 cmdline_fixed_string_t tx_vlan;
3332 cmdline_fixed_string_t set;
3333 cmdline_fixed_string_t pvid;
3336 cmdline_fixed_string_t mode;
3340 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3341 __attribute__((unused)) struct cmdline *cl,
3342 __attribute__((unused)) void *data)
3344 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3346 if (strcmp(res->mode, "on") == 0)
3347 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3349 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3352 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3353 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3354 tx_vlan, "tx_vlan");
3355 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3356 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3358 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3359 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3361 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3362 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3364 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3365 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3367 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3368 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3371 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3372 .f = cmd_tx_vlan_set_pvid_parsed,
3374 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3376 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3377 (void *)&cmd_tx_vlan_set_pvid_set,
3378 (void *)&cmd_tx_vlan_set_pvid_pvid,
3379 (void *)&cmd_tx_vlan_set_pvid_port_id,
3380 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3381 (void *)&cmd_tx_vlan_set_pvid_mode,
3386 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3387 struct cmd_tx_vlan_reset_result {
3388 cmdline_fixed_string_t tx_vlan;
3389 cmdline_fixed_string_t reset;
3394 cmd_tx_vlan_reset_parsed(void *parsed_result,
3395 __attribute__((unused)) struct cmdline *cl,
3396 __attribute__((unused)) void *data)
3398 struct cmd_tx_vlan_reset_result *res = parsed_result;
3400 tx_vlan_reset(res->port_id);
3403 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3404 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3405 tx_vlan, "tx_vlan");
3406 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3407 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3409 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3410 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3413 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3414 .f = cmd_tx_vlan_reset_parsed,
3416 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3417 "VLAN header in packets sent on a port",
3419 (void *)&cmd_tx_vlan_reset_tx_vlan,
3420 (void *)&cmd_tx_vlan_reset_reset,
3421 (void *)&cmd_tx_vlan_reset_portid,
3427 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3428 struct cmd_csum_result {
3429 cmdline_fixed_string_t csum;
3430 cmdline_fixed_string_t mode;
3431 cmdline_fixed_string_t proto;
3432 cmdline_fixed_string_t hwsw;
3437 csum_show(int port_id)
3439 struct rte_eth_dev_info dev_info;
3442 ol_flags = ports[port_id].tx_ol_flags;
3443 printf("Parse tunnel is %s\n",
3444 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3445 printf("IP checksum offload is %s\n",
3446 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3447 printf("UDP checksum offload is %s\n",
3448 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3449 printf("TCP checksum offload is %s\n",
3450 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3451 printf("SCTP checksum offload is %s\n",
3452 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3453 printf("Outer-Ip checksum offload is %s\n",
3454 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3456 /* display warnings if configuration is not supported by the NIC */
3457 rte_eth_dev_info_get(port_id, &dev_info);
3458 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3459 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3460 printf("Warning: hardware IP checksum enabled but not "
3461 "supported by port %d\n", port_id);
3463 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3464 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3465 printf("Warning: hardware UDP checksum enabled but not "
3466 "supported by port %d\n", port_id);
3468 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3469 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3470 printf("Warning: hardware TCP checksum enabled but not "
3471 "supported by port %d\n", port_id);
3473 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3474 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3475 printf("Warning: hardware SCTP checksum enabled but not "
3476 "supported by port %d\n", port_id);
3478 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3479 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3480 printf("Warning: hardware outer IP checksum enabled but not "
3481 "supported by port %d\n", port_id);
3486 cmd_csum_parsed(void *parsed_result,
3487 __attribute__((unused)) struct cmdline *cl,
3488 __attribute__((unused)) void *data)
3490 struct cmd_csum_result *res = parsed_result;
3494 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3495 printf("invalid port %d\n", res->port_id);
3499 if (!strcmp(res->mode, "set")) {
3501 if (!strcmp(res->hwsw, "hw"))
3504 if (!strcmp(res->proto, "ip")) {
3505 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3506 } else if (!strcmp(res->proto, "udp")) {
3507 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3508 } else if (!strcmp(res->proto, "tcp")) {
3509 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3510 } else if (!strcmp(res->proto, "sctp")) {
3511 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3512 } else if (!strcmp(res->proto, "outer-ip")) {
3513 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3517 ports[res->port_id].tx_ol_flags |= mask;
3519 ports[res->port_id].tx_ol_flags &= (~mask);
3521 csum_show(res->port_id);
3524 cmdline_parse_token_string_t cmd_csum_csum =
3525 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3527 cmdline_parse_token_string_t cmd_csum_mode =
3528 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3530 cmdline_parse_token_string_t cmd_csum_proto =
3531 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3532 proto, "ip#tcp#udp#sctp#outer-ip");
3533 cmdline_parse_token_string_t cmd_csum_hwsw =
3534 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3536 cmdline_parse_token_num_t cmd_csum_portid =
3537 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3540 cmdline_parse_inst_t cmd_csum_set = {
3541 .f = cmd_csum_parsed,
3543 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3544 "Enable/Disable hardware calculation of L3/L4 checksum when "
3545 "using csum forward engine",
3547 (void *)&cmd_csum_csum,
3548 (void *)&cmd_csum_mode,
3549 (void *)&cmd_csum_proto,
3550 (void *)&cmd_csum_hwsw,
3551 (void *)&cmd_csum_portid,
3556 cmdline_parse_token_string_t cmd_csum_mode_show =
3557 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3560 cmdline_parse_inst_t cmd_csum_show = {
3561 .f = cmd_csum_parsed,
3563 .help_str = "csum show <port_id>: Show checksum offload configuration",
3565 (void *)&cmd_csum_csum,
3566 (void *)&cmd_csum_mode_show,
3567 (void *)&cmd_csum_portid,
3572 /* Enable/disable tunnel parsing */
3573 struct cmd_csum_tunnel_result {
3574 cmdline_fixed_string_t csum;
3575 cmdline_fixed_string_t parse;
3576 cmdline_fixed_string_t onoff;
3581 cmd_csum_tunnel_parsed(void *parsed_result,
3582 __attribute__((unused)) struct cmdline *cl,
3583 __attribute__((unused)) void *data)
3585 struct cmd_csum_tunnel_result *res = parsed_result;
3587 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3590 if (!strcmp(res->onoff, "on"))
3591 ports[res->port_id].tx_ol_flags |=
3592 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3594 ports[res->port_id].tx_ol_flags &=
3595 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3597 csum_show(res->port_id);
3600 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3601 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3603 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3604 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3605 parse, "parse_tunnel");
3606 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3607 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3609 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3610 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3613 cmdline_parse_inst_t cmd_csum_tunnel = {
3614 .f = cmd_csum_tunnel_parsed,
3616 .help_str = "csum parse_tunnel on|off <port_id>: "
3617 "Enable/Disable parsing of tunnels for csum engine",
3619 (void *)&cmd_csum_tunnel_csum,
3620 (void *)&cmd_csum_tunnel_parse,
3621 (void *)&cmd_csum_tunnel_onoff,
3622 (void *)&cmd_csum_tunnel_portid,
3627 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3628 struct cmd_tso_set_result {
3629 cmdline_fixed_string_t tso;
3630 cmdline_fixed_string_t mode;
3636 cmd_tso_set_parsed(void *parsed_result,
3637 __attribute__((unused)) struct cmdline *cl,
3638 __attribute__((unused)) void *data)
3640 struct cmd_tso_set_result *res = parsed_result;
3641 struct rte_eth_dev_info dev_info;
3643 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3646 if (!strcmp(res->mode, "set"))
3647 ports[res->port_id].tso_segsz = res->tso_segsz;
3649 if (ports[res->port_id].tso_segsz == 0)
3650 printf("TSO for non-tunneled packets is disabled\n");
3652 printf("TSO segment size for non-tunneled packets is %d\n",
3653 ports[res->port_id].tso_segsz);
3655 /* display warnings if configuration is not supported by the NIC */
3656 rte_eth_dev_info_get(res->port_id, &dev_info);
3657 if ((ports[res->port_id].tso_segsz != 0) &&
3658 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3659 printf("Warning: TSO enabled but not "
3660 "supported by port %d\n", res->port_id);
3664 cmdline_parse_token_string_t cmd_tso_set_tso =
3665 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3667 cmdline_parse_token_string_t cmd_tso_set_mode =
3668 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3670 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3671 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3673 cmdline_parse_token_num_t cmd_tso_set_portid =
3674 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3677 cmdline_parse_inst_t cmd_tso_set = {
3678 .f = cmd_tso_set_parsed,
3680 .help_str = "tso set <tso_segsz> <port_id>: "
3681 "Set TSO segment size of non-tunneled packets for csum engine "
3684 (void *)&cmd_tso_set_tso,
3685 (void *)&cmd_tso_set_mode,
3686 (void *)&cmd_tso_set_tso_segsz,
3687 (void *)&cmd_tso_set_portid,
3692 cmdline_parse_token_string_t cmd_tso_show_mode =
3693 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3697 cmdline_parse_inst_t cmd_tso_show = {
3698 .f = cmd_tso_set_parsed,
3700 .help_str = "tso show <port_id>: "
3701 "Show TSO segment size of non-tunneled packets for csum engine",
3703 (void *)&cmd_tso_set_tso,
3704 (void *)&cmd_tso_show_mode,
3705 (void *)&cmd_tso_set_portid,
3710 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3711 struct cmd_tunnel_tso_set_result {
3712 cmdline_fixed_string_t tso;
3713 cmdline_fixed_string_t mode;
3719 check_tunnel_tso_nic_support(uint8_t port_id)
3721 struct rte_eth_dev_info dev_info;
3723 rte_eth_dev_info_get(port_id, &dev_info);
3724 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3725 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3726 "supported by port %d\n", port_id);
3727 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3728 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3729 "supported by port %d\n", port_id);
3730 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3731 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3732 "supported by port %d\n", port_id);
3733 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3734 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3735 "supported by port %d\n", port_id);
3739 cmd_tunnel_tso_set_parsed(void *parsed_result,
3740 __attribute__((unused)) struct cmdline *cl,
3741 __attribute__((unused)) void *data)
3743 struct cmd_tunnel_tso_set_result *res = parsed_result;
3745 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3748 if (!strcmp(res->mode, "set"))
3749 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3751 if (ports[res->port_id].tunnel_tso_segsz == 0)
3752 printf("TSO for tunneled packets is disabled\n");
3754 printf("TSO segment size for tunneled packets is %d\n",
3755 ports[res->port_id].tunnel_tso_segsz);
3757 /* Below conditions are needed to make it work:
3758 * (1) tunnel TSO is supported by the NIC;
3759 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3761 * (3) for tunneled pkts with outer L3 of IPv4,
3762 * "csum set outer-ip" must be set to hw, because after tso,
3763 * total_len of outer IP header is changed, and the checksum
3764 * of outer IP header calculated by sw should be wrong; that
3765 * is not necessary for IPv6 tunneled pkts because there's no
3766 * checksum in IP header anymore.
3768 check_tunnel_tso_nic_support(res->port_id);
3770 if (!(ports[res->port_id].tx_ol_flags &
3771 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3772 printf("Warning: csum parse_tunnel must be set "
3773 "so that tunneled packets are recognized\n");
3774 if (!(ports[res->port_id].tx_ol_flags &
3775 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3776 printf("Warning: csum set outer-ip must be set to hw "
3777 "if outer L3 is IPv4; not necessary for IPv6\n");
3781 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3782 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3784 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3785 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3787 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3788 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3790 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3791 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3794 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3795 .f = cmd_tunnel_tso_set_parsed,
3797 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3798 "Set TSO segment size of tunneled packets for csum engine "
3801 (void *)&cmd_tunnel_tso_set_tso,
3802 (void *)&cmd_tunnel_tso_set_mode,
3803 (void *)&cmd_tunnel_tso_set_tso_segsz,
3804 (void *)&cmd_tunnel_tso_set_portid,
3809 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3810 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3814 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3815 .f = cmd_tunnel_tso_set_parsed,
3817 .help_str = "tunnel_tso show <port_id> "
3818 "Show TSO segment size of tunneled packets for csum engine",
3820 (void *)&cmd_tunnel_tso_set_tso,
3821 (void *)&cmd_tunnel_tso_show_mode,
3822 (void *)&cmd_tunnel_tso_set_portid,
3827 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3828 struct cmd_set_flush_rx {
3829 cmdline_fixed_string_t set;
3830 cmdline_fixed_string_t flush_rx;
3831 cmdline_fixed_string_t mode;
3835 cmd_set_flush_rx_parsed(void *parsed_result,
3836 __attribute__((unused)) struct cmdline *cl,
3837 __attribute__((unused)) void *data)
3839 struct cmd_set_flush_rx *res = parsed_result;
3840 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3843 cmdline_parse_token_string_t cmd_setflushrx_set =
3844 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3846 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3847 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3848 flush_rx, "flush_rx");
3849 cmdline_parse_token_string_t cmd_setflushrx_mode =
3850 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3854 cmdline_parse_inst_t cmd_set_flush_rx = {
3855 .f = cmd_set_flush_rx_parsed,
3856 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3859 (void *)&cmd_setflushrx_set,
3860 (void *)&cmd_setflushrx_flush_rx,
3861 (void *)&cmd_setflushrx_mode,
3866 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3867 struct cmd_set_link_check {
3868 cmdline_fixed_string_t set;
3869 cmdline_fixed_string_t link_check;
3870 cmdline_fixed_string_t mode;
3874 cmd_set_link_check_parsed(void *parsed_result,
3875 __attribute__((unused)) struct cmdline *cl,
3876 __attribute__((unused)) void *data)
3878 struct cmd_set_link_check *res = parsed_result;
3879 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3882 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3883 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3885 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3886 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3887 link_check, "link_check");
3888 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3889 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3893 cmdline_parse_inst_t cmd_set_link_check = {
3894 .f = cmd_set_link_check_parsed,
3895 .help_str = "set link_check on|off: Enable/Disable link status check "
3896 "when starting/stopping a port",
3899 (void *)&cmd_setlinkcheck_set,
3900 (void *)&cmd_setlinkcheck_link_check,
3901 (void *)&cmd_setlinkcheck_mode,
3906 /* *** SET NIC BYPASS MODE *** */
3907 struct cmd_set_bypass_mode_result {
3908 cmdline_fixed_string_t set;
3909 cmdline_fixed_string_t bypass;
3910 cmdline_fixed_string_t mode;
3911 cmdline_fixed_string_t value;
3916 cmd_set_bypass_mode_parsed(void *parsed_result,
3917 __attribute__((unused)) struct cmdline *cl,
3918 __attribute__((unused)) void *data)
3920 struct cmd_set_bypass_mode_result *res = parsed_result;
3921 portid_t port_id = res->port_id;
3922 int32_t rc = -EINVAL;
3924 #ifdef RTE_LIBRTE_IXGBE_BYPASS
3925 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3927 if (!strcmp(res->value, "bypass"))
3928 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
3929 else if (!strcmp(res->value, "isolate"))
3930 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
3932 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3934 /* Set the bypass mode for the relevant port. */
3935 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
3938 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3941 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3942 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3944 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3945 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3947 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3950 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3952 value, "normal#bypass#isolate");
3953 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3954 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3957 cmdline_parse_inst_t cmd_set_bypass_mode = {
3958 .f = cmd_set_bypass_mode_parsed,
3959 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3960 "Set the NIC bypass mode for port_id",
3963 (void *)&cmd_setbypass_mode_set,
3964 (void *)&cmd_setbypass_mode_bypass,
3965 (void *)&cmd_setbypass_mode_mode,
3966 (void *)&cmd_setbypass_mode_value,
3967 (void *)&cmd_setbypass_mode_port,
3972 /* *** SET NIC BYPASS EVENT *** */
3973 struct cmd_set_bypass_event_result {
3974 cmdline_fixed_string_t set;
3975 cmdline_fixed_string_t bypass;
3976 cmdline_fixed_string_t event;
3977 cmdline_fixed_string_t event_value;
3978 cmdline_fixed_string_t mode;
3979 cmdline_fixed_string_t mode_value;
3984 cmd_set_bypass_event_parsed(void *parsed_result,
3985 __attribute__((unused)) struct cmdline *cl,
3986 __attribute__((unused)) void *data)
3988 int32_t rc = -EINVAL;
3989 struct cmd_set_bypass_event_result *res = parsed_result;
3990 portid_t port_id = res->port_id;
3992 #ifdef RTE_LIBRTE_IXGBE_BYPASS
3993 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
3994 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3996 if (!strcmp(res->event_value, "timeout"))
3997 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
3998 else if (!strcmp(res->event_value, "os_on"))
3999 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4000 else if (!strcmp(res->event_value, "os_off"))
4001 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4002 else if (!strcmp(res->event_value, "power_on"))
4003 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4004 else if (!strcmp(res->event_value, "power_off"))
4005 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4007 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4009 if (!strcmp(res->mode_value, "bypass"))
4010 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4011 else if (!strcmp(res->mode_value, "isolate"))
4012 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4014 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4016 /* Set the watchdog timeout. */
4017 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4020 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4021 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4025 printf("Failed to set timeout value %u "
4026 "for port %d, errto code: %d.\n",
4027 bypass_timeout, port_id, rc);
4031 /* Set the bypass event to transition to bypass mode. */
4032 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4037 printf("\t Failed to set bypass event for port = %d.\n",
4041 cmdline_parse_token_string_t cmd_setbypass_event_set =
4042 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4044 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4045 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4047 cmdline_parse_token_string_t cmd_setbypass_event_event =
4048 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4050 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4051 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4052 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4053 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4054 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4056 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4057 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4058 mode_value, "normal#bypass#isolate");
4059 cmdline_parse_token_num_t cmd_setbypass_event_port =
4060 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4063 cmdline_parse_inst_t cmd_set_bypass_event = {
4064 .f = cmd_set_bypass_event_parsed,
4065 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4066 "power_off mode normal|bypass|isolate <port_id>: "
4067 "Set the NIC bypass event mode for port_id",
4070 (void *)&cmd_setbypass_event_set,
4071 (void *)&cmd_setbypass_event_bypass,
4072 (void *)&cmd_setbypass_event_event,
4073 (void *)&cmd_setbypass_event_event_value,
4074 (void *)&cmd_setbypass_event_mode,
4075 (void *)&cmd_setbypass_event_mode_value,
4076 (void *)&cmd_setbypass_event_port,
4082 /* *** SET NIC BYPASS TIMEOUT *** */
4083 struct cmd_set_bypass_timeout_result {
4084 cmdline_fixed_string_t set;
4085 cmdline_fixed_string_t bypass;
4086 cmdline_fixed_string_t timeout;
4087 cmdline_fixed_string_t value;
4091 cmd_set_bypass_timeout_parsed(void *parsed_result,
4092 __attribute__((unused)) struct cmdline *cl,
4093 __attribute__((unused)) void *data)
4095 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4097 #ifdef RTE_LIBRTE_IXGBE_BYPASS
4098 if (!strcmp(res->value, "1.5"))
4099 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4100 else if (!strcmp(res->value, "2"))
4101 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4102 else if (!strcmp(res->value, "3"))
4103 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4104 else if (!strcmp(res->value, "4"))
4105 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4106 else if (!strcmp(res->value, "8"))
4107 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4108 else if (!strcmp(res->value, "16"))
4109 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4110 else if (!strcmp(res->value, "32"))
4111 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4113 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4117 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4118 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4120 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4121 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4123 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4124 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4125 timeout, "timeout");
4126 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4127 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4128 value, "0#1.5#2#3#4#8#16#32");
4130 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4131 .f = cmd_set_bypass_timeout_parsed,
4132 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4133 "Set the NIC bypass watchdog timeout in seconds",
4136 (void *)&cmd_setbypass_timeout_set,
4137 (void *)&cmd_setbypass_timeout_bypass,
4138 (void *)&cmd_setbypass_timeout_timeout,
4139 (void *)&cmd_setbypass_timeout_value,
4144 /* *** SHOW NIC BYPASS MODE *** */
4145 struct cmd_show_bypass_config_result {
4146 cmdline_fixed_string_t show;
4147 cmdline_fixed_string_t bypass;
4148 cmdline_fixed_string_t config;
4153 cmd_show_bypass_config_parsed(void *parsed_result,
4154 __attribute__((unused)) struct cmdline *cl,
4155 __attribute__((unused)) void *data)
4157 struct cmd_show_bypass_config_result *res = parsed_result;
4158 portid_t port_id = res->port_id;
4160 #ifdef RTE_LIBRTE_IXGBE_BYPASS
4161 uint32_t event_mode;
4162 uint32_t bypass_mode;
4163 uint32_t timeout = bypass_timeout;
4166 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4167 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4168 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4169 {"UNKNOWN", "normal", "bypass", "isolate"};
4170 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4177 int num_events = (sizeof events) / (sizeof events[0]);
4179 /* Display the bypass mode.*/
4180 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4181 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4185 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4186 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4188 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4191 /* Display the bypass timeout.*/
4192 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4193 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4195 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4197 /* Display the bypass events and associated modes. */
4198 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4200 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4201 printf("\tFailed to get bypass mode for event = %s\n",
4204 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4205 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4207 printf("\tbypass event: %-16s = %s\n", events[i],
4213 printf("\tFailed to get bypass configuration for port = %d\n",
4217 cmdline_parse_token_string_t cmd_showbypass_config_show =
4218 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4220 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4221 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4223 cmdline_parse_token_string_t cmd_showbypass_config_config =
4224 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4226 cmdline_parse_token_num_t cmd_showbypass_config_port =
4227 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4230 cmdline_parse_inst_t cmd_show_bypass_config = {
4231 .f = cmd_show_bypass_config_parsed,
4232 .help_str = "show bypass config <port_id>: "
4233 "Show the NIC bypass config for port_id",
4236 (void *)&cmd_showbypass_config_show,
4237 (void *)&cmd_showbypass_config_bypass,
4238 (void *)&cmd_showbypass_config_config,
4239 (void *)&cmd_showbypass_config_port,
4244 #ifdef RTE_LIBRTE_PMD_BOND
4245 /* *** SET BONDING MODE *** */
4246 struct cmd_set_bonding_mode_result {
4247 cmdline_fixed_string_t set;
4248 cmdline_fixed_string_t bonding;
4249 cmdline_fixed_string_t mode;
4254 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4255 __attribute__((unused)) struct cmdline *cl,
4256 __attribute__((unused)) void *data)
4258 struct cmd_set_bonding_mode_result *res = parsed_result;
4259 portid_t port_id = res->port_id;
4261 /* Set the bonding mode for the relevant port. */
4262 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4263 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4266 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4267 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4269 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4270 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4271 bonding, "bonding");
4272 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4273 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4275 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4276 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4278 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4279 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4282 cmdline_parse_inst_t cmd_set_bonding_mode = {
4283 .f = cmd_set_bonding_mode_parsed,
4284 .help_str = "set bonding mode <mode_value> <port_id>: "
4285 "Set the bonding mode for port_id",
4288 (void *) &cmd_setbonding_mode_set,
4289 (void *) &cmd_setbonding_mode_bonding,
4290 (void *) &cmd_setbonding_mode_mode,
4291 (void *) &cmd_setbonding_mode_value,
4292 (void *) &cmd_setbonding_mode_port,
4297 /* *** SET BALANCE XMIT POLICY *** */
4298 struct cmd_set_bonding_balance_xmit_policy_result {
4299 cmdline_fixed_string_t set;
4300 cmdline_fixed_string_t bonding;
4301 cmdline_fixed_string_t balance_xmit_policy;
4303 cmdline_fixed_string_t policy;
4306 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4307 __attribute__((unused)) struct cmdline *cl,
4308 __attribute__((unused)) void *data)
4310 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4311 portid_t port_id = res->port_id;
4314 if (!strcmp(res->policy, "l2")) {
4315 policy = BALANCE_XMIT_POLICY_LAYER2;
4316 } else if (!strcmp(res->policy, "l23")) {
4317 policy = BALANCE_XMIT_POLICY_LAYER23;
4318 } else if (!strcmp(res->policy, "l34")) {
4319 policy = BALANCE_XMIT_POLICY_LAYER34;
4321 printf("\t Invalid xmit policy selection");
4325 /* Set the bonding mode for the relevant port. */
4326 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4327 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4332 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4333 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4335 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4336 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4337 bonding, "bonding");
4338 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4339 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4340 balance_xmit_policy, "balance_xmit_policy");
4341 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4342 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4344 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4345 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4346 policy, "l2#l23#l34");
4348 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4349 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4350 .help_str = "set bonding balance_xmit_policy <port_id> "
4352 "Set the bonding balance_xmit_policy for port_id",
4355 (void *)&cmd_setbonding_balance_xmit_policy_set,
4356 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4357 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4358 (void *)&cmd_setbonding_balance_xmit_policy_port,
4359 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4364 /* *** SHOW NIC BONDING CONFIGURATION *** */
4365 struct cmd_show_bonding_config_result {
4366 cmdline_fixed_string_t show;
4367 cmdline_fixed_string_t bonding;
4368 cmdline_fixed_string_t config;
4372 static void cmd_show_bonding_config_parsed(void *parsed_result,
4373 __attribute__((unused)) struct cmdline *cl,
4374 __attribute__((unused)) void *data)
4376 struct cmd_show_bonding_config_result *res = parsed_result;
4378 uint8_t slaves[RTE_MAX_ETHPORTS];
4379 int num_slaves, num_active_slaves;
4382 portid_t port_id = res->port_id;
4384 /* Display the bonding mode.*/
4385 bonding_mode = rte_eth_bond_mode_get(port_id);
4386 if (bonding_mode < 0) {
4387 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4390 printf("\tBonding mode: %d\n", bonding_mode);
4392 if (bonding_mode == BONDING_MODE_BALANCE) {
4393 int balance_xmit_policy;
4395 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4396 if (balance_xmit_policy < 0) {
4397 printf("\tFailed to get balance xmit policy for port = %d\n",
4401 printf("\tBalance Xmit Policy: ");
4403 switch (balance_xmit_policy) {
4404 case BALANCE_XMIT_POLICY_LAYER2:
4405 printf("BALANCE_XMIT_POLICY_LAYER2");
4407 case BALANCE_XMIT_POLICY_LAYER23:
4408 printf("BALANCE_XMIT_POLICY_LAYER23");
4410 case BALANCE_XMIT_POLICY_LAYER34:
4411 printf("BALANCE_XMIT_POLICY_LAYER34");
4418 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4420 if (num_slaves < 0) {
4421 printf("\tFailed to get slave list for port = %d\n", port_id);
4424 if (num_slaves > 0) {
4425 printf("\tSlaves (%d): [", num_slaves);
4426 for (i = 0; i < num_slaves - 1; i++)
4427 printf("%d ", slaves[i]);
4429 printf("%d]\n", slaves[num_slaves - 1]);
4431 printf("\tSlaves: []\n");
4435 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4438 if (num_active_slaves < 0) {
4439 printf("\tFailed to get active slave list for port = %d\n", port_id);
4442 if (num_active_slaves > 0) {
4443 printf("\tActive Slaves (%d): [", num_active_slaves);
4444 for (i = 0; i < num_active_slaves - 1; i++)
4445 printf("%d ", slaves[i]);
4447 printf("%d]\n", slaves[num_active_slaves - 1]);
4450 printf("\tActive Slaves: []\n");
4454 primary_id = rte_eth_bond_primary_get(port_id);
4455 if (primary_id < 0) {
4456 printf("\tFailed to get primary slave for port = %d\n", port_id);
4459 printf("\tPrimary: [%d]\n", primary_id);
4463 cmdline_parse_token_string_t cmd_showbonding_config_show =
4464 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4466 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4467 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4468 bonding, "bonding");
4469 cmdline_parse_token_string_t cmd_showbonding_config_config =
4470 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4472 cmdline_parse_token_num_t cmd_showbonding_config_port =
4473 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4476 cmdline_parse_inst_t cmd_show_bonding_config = {
4477 .f = cmd_show_bonding_config_parsed,
4478 .help_str = "show bonding config <port_id>: "
4479 "Show the bonding config for port_id",
4482 (void *)&cmd_showbonding_config_show,
4483 (void *)&cmd_showbonding_config_bonding,
4484 (void *)&cmd_showbonding_config_config,
4485 (void *)&cmd_showbonding_config_port,
4490 /* *** SET BONDING PRIMARY *** */
4491 struct cmd_set_bonding_primary_result {
4492 cmdline_fixed_string_t set;
4493 cmdline_fixed_string_t bonding;
4494 cmdline_fixed_string_t primary;
4499 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4500 __attribute__((unused)) struct cmdline *cl,
4501 __attribute__((unused)) void *data)
4503 struct cmd_set_bonding_primary_result *res = parsed_result;
4504 portid_t master_port_id = res->port_id;
4505 portid_t slave_port_id = res->slave_id;
4507 /* Set the primary slave for a bonded device. */
4508 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4509 printf("\t Failed to set primary slave for port = %d.\n",
4516 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4517 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4519 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4520 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4521 bonding, "bonding");
4522 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4523 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4524 primary, "primary");
4525 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4526 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4528 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4529 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4532 cmdline_parse_inst_t cmd_set_bonding_primary = {
4533 .f = cmd_set_bonding_primary_parsed,
4534 .help_str = "set bonding primary <slave_id> <port_id>: "
4535 "Set the primary slave for port_id",
4538 (void *)&cmd_setbonding_primary_set,
4539 (void *)&cmd_setbonding_primary_bonding,
4540 (void *)&cmd_setbonding_primary_primary,
4541 (void *)&cmd_setbonding_primary_slave,
4542 (void *)&cmd_setbonding_primary_port,
4547 /* *** ADD SLAVE *** */
4548 struct cmd_add_bonding_slave_result {
4549 cmdline_fixed_string_t add;
4550 cmdline_fixed_string_t bonding;
4551 cmdline_fixed_string_t slave;
4556 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4557 __attribute__((unused)) struct cmdline *cl,
4558 __attribute__((unused)) void *data)
4560 struct cmd_add_bonding_slave_result *res = parsed_result;
4561 portid_t master_port_id = res->port_id;
4562 portid_t slave_port_id = res->slave_id;
4564 /* Set the primary slave for a bonded device. */
4565 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4566 printf("\t Failed to add slave %d to master port = %d.\n",
4567 slave_port_id, master_port_id);
4571 set_port_slave_flag(slave_port_id);
4574 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4575 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4577 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4578 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4579 bonding, "bonding");
4580 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4581 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4583 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4584 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4586 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4587 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4590 cmdline_parse_inst_t cmd_add_bonding_slave = {
4591 .f = cmd_add_bonding_slave_parsed,
4592 .help_str = "add bonding slave <slave_id> <port_id>: "
4593 "Add a slave device to a bonded device",
4596 (void *)&cmd_addbonding_slave_add,
4597 (void *)&cmd_addbonding_slave_bonding,
4598 (void *)&cmd_addbonding_slave_slave,
4599 (void *)&cmd_addbonding_slave_slaveid,
4600 (void *)&cmd_addbonding_slave_port,
4605 /* *** REMOVE SLAVE *** */
4606 struct cmd_remove_bonding_slave_result {
4607 cmdline_fixed_string_t remove;
4608 cmdline_fixed_string_t bonding;
4609 cmdline_fixed_string_t slave;
4614 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4615 __attribute__((unused)) struct cmdline *cl,
4616 __attribute__((unused)) void *data)
4618 struct cmd_remove_bonding_slave_result *res = parsed_result;
4619 portid_t master_port_id = res->port_id;
4620 portid_t slave_port_id = res->slave_id;
4622 /* Set the primary slave for a bonded device. */
4623 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4624 printf("\t Failed to remove slave %d from master port = %d.\n",
4625 slave_port_id, master_port_id);
4629 clear_port_slave_flag(slave_port_id);
4632 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4633 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4635 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4636 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4637 bonding, "bonding");
4638 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4639 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4641 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4642 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4644 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4645 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4648 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4649 .f = cmd_remove_bonding_slave_parsed,
4650 .help_str = "remove bonding slave <slave_id> <port_id>: "
4651 "Remove a slave device from a bonded device",
4654 (void *)&cmd_removebonding_slave_remove,
4655 (void *)&cmd_removebonding_slave_bonding,
4656 (void *)&cmd_removebonding_slave_slave,
4657 (void *)&cmd_removebonding_slave_slaveid,
4658 (void *)&cmd_removebonding_slave_port,
4663 /* *** CREATE BONDED DEVICE *** */
4664 struct cmd_create_bonded_device_result {
4665 cmdline_fixed_string_t create;
4666 cmdline_fixed_string_t bonded;
4667 cmdline_fixed_string_t device;
4672 static int bond_dev_num = 0;
4674 static void cmd_create_bonded_device_parsed(void *parsed_result,
4675 __attribute__((unused)) struct cmdline *cl,
4676 __attribute__((unused)) void *data)
4678 struct cmd_create_bonded_device_result *res = parsed_result;
4679 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4682 if (test_done == 0) {
4683 printf("Please stop forwarding first\n");
4687 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4690 /* Create a new bonded device. */
4691 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4693 printf("\t Failed to create bonded device.\n");
4696 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4699 /* Update number of ports */
4700 nb_ports = rte_eth_dev_count();
4701 reconfig(port_id, res->socket);
4702 rte_eth_promiscuous_enable(port_id);
4707 cmdline_parse_token_string_t cmd_createbonded_device_create =
4708 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4710 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4711 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4713 cmdline_parse_token_string_t cmd_createbonded_device_device =
4714 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4716 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4717 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4719 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4720 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4723 cmdline_parse_inst_t cmd_create_bonded_device = {
4724 .f = cmd_create_bonded_device_parsed,
4725 .help_str = "create bonded device <mode> <socket>: "
4726 "Create a new bonded device with specific bonding mode and socket",
4729 (void *)&cmd_createbonded_device_create,
4730 (void *)&cmd_createbonded_device_bonded,
4731 (void *)&cmd_createbonded_device_device,
4732 (void *)&cmd_createbonded_device_mode,
4733 (void *)&cmd_createbonded_device_socket,
4738 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4739 struct cmd_set_bond_mac_addr_result {
4740 cmdline_fixed_string_t set;
4741 cmdline_fixed_string_t bonding;
4742 cmdline_fixed_string_t mac_addr;
4744 struct ether_addr address;
4747 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4748 __attribute__((unused)) struct cmdline *cl,
4749 __attribute__((unused)) void *data)
4751 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4754 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4757 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4759 /* check the return value and print it if is < 0 */
4761 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4764 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4765 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4766 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4767 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4769 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4770 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4772 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4773 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4774 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4775 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4777 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4778 .f = cmd_set_bond_mac_addr_parsed,
4780 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4782 (void *)&cmd_set_bond_mac_addr_set,
4783 (void *)&cmd_set_bond_mac_addr_bonding,
4784 (void *)&cmd_set_bond_mac_addr_mac,
4785 (void *)&cmd_set_bond_mac_addr_portnum,
4786 (void *)&cmd_set_bond_mac_addr_addr,
4792 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4793 struct cmd_set_bond_mon_period_result {
4794 cmdline_fixed_string_t set;
4795 cmdline_fixed_string_t bonding;
4796 cmdline_fixed_string_t mon_period;
4801 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4802 __attribute__((unused)) struct cmdline *cl,
4803 __attribute__((unused)) void *data)
4805 struct cmd_set_bond_mon_period_result *res = parsed_result;
4808 if (res->port_num >= nb_ports) {
4809 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4813 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4815 /* check the return value and print it if is < 0 */
4817 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4820 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4821 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4823 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4824 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4825 bonding, "bonding");
4826 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4827 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4828 mon_period, "mon_period");
4829 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4830 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4832 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4833 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4836 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4837 .f = cmd_set_bond_mon_period_parsed,
4839 .help_str = "set bonding mon_period <port_id> <period_ms>",
4841 (void *)&cmd_set_bond_mon_period_set,
4842 (void *)&cmd_set_bond_mon_period_bonding,
4843 (void *)&cmd_set_bond_mon_period_mon_period,
4844 (void *)&cmd_set_bond_mon_period_portnum,
4845 (void *)&cmd_set_bond_mon_period_period_ms,
4850 #endif /* RTE_LIBRTE_PMD_BOND */
4852 /* *** SET FORWARDING MODE *** */
4853 struct cmd_set_fwd_mode_result {
4854 cmdline_fixed_string_t set;
4855 cmdline_fixed_string_t fwd;
4856 cmdline_fixed_string_t mode;
4859 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4860 __attribute__((unused)) struct cmdline *cl,
4861 __attribute__((unused)) void *data)
4863 struct cmd_set_fwd_mode_result *res = parsed_result;
4866 set_pkt_forwarding_mode(res->mode);
4869 cmdline_parse_token_string_t cmd_setfwd_set =
4870 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4871 cmdline_parse_token_string_t cmd_setfwd_fwd =
4872 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4873 cmdline_parse_token_string_t cmd_setfwd_mode =
4874 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4875 "" /* defined at init */);
4877 cmdline_parse_inst_t cmd_set_fwd_mode = {
4878 .f = cmd_set_fwd_mode_parsed,
4880 .help_str = NULL, /* defined at init */
4882 (void *)&cmd_setfwd_set,
4883 (void *)&cmd_setfwd_fwd,
4884 (void *)&cmd_setfwd_mode,
4889 static void cmd_set_fwd_mode_init(void)
4892 static char token[128];
4893 static char help[256];
4894 cmdline_parse_token_string_t *token_struct;
4896 modes = list_pkt_forwarding_modes();
4897 snprintf(help, sizeof(help), "set fwd %s: "
4898 "Set packet forwarding mode", modes);
4899 cmd_set_fwd_mode.help_str = help;
4901 /* string token separator is # */
4902 for (c = token; *modes != '\0'; modes++)
4907 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4908 token_struct->string_data.str = token;
4911 /* *** SET RETRY FORWARDING MODE *** */
4912 struct cmd_set_fwd_retry_mode_result {
4913 cmdline_fixed_string_t set;
4914 cmdline_fixed_string_t fwd;
4915 cmdline_fixed_string_t mode;
4916 cmdline_fixed_string_t retry;
4919 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4920 __attribute__((unused)) struct cmdline *cl,
4921 __attribute__((unused)) void *data)
4923 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4926 set_pkt_forwarding_mode(res->mode);
4929 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4930 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4932 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4933 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4935 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4936 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4938 "" /* defined at init */);
4939 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4940 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4943 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4944 .f = cmd_set_fwd_retry_mode_parsed,
4946 .help_str = NULL, /* defined at init */
4948 (void *)&cmd_setfwd_retry_set,
4949 (void *)&cmd_setfwd_retry_fwd,
4950 (void *)&cmd_setfwd_retry_mode,
4951 (void *)&cmd_setfwd_retry_retry,
4956 static void cmd_set_fwd_retry_mode_init(void)
4959 static char token[128];
4960 static char help[256];
4961 cmdline_parse_token_string_t *token_struct;
4963 modes = list_pkt_forwarding_retry_modes();
4964 snprintf(help, sizeof(help), "set fwd %s retry: "
4965 "Set packet forwarding mode with retry", modes);
4966 cmd_set_fwd_retry_mode.help_str = help;
4968 /* string token separator is # */
4969 for (c = token; *modes != '\0'; modes++)
4974 token_struct = (cmdline_parse_token_string_t *)
4975 cmd_set_fwd_retry_mode.tokens[2];
4976 token_struct->string_data.str = token;
4979 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4980 struct cmd_set_burst_tx_retry_result {
4981 cmdline_fixed_string_t set;
4982 cmdline_fixed_string_t burst;
4983 cmdline_fixed_string_t tx;
4984 cmdline_fixed_string_t delay;
4986 cmdline_fixed_string_t retry;
4990 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4991 __attribute__((unused)) struct cmdline *cl,
4992 __attribute__((unused)) void *data)
4994 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4996 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4997 && !strcmp(res->tx, "tx")) {
4998 if (!strcmp(res->delay, "delay"))
4999 burst_tx_delay_time = res->time;
5000 if (!strcmp(res->retry, "retry"))
5001 burst_tx_retry_num = res->retry_num;
5006 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5007 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5008 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5009 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5011 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5012 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5013 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5014 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5015 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5016 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5017 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5018 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5019 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5020 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5022 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5023 .f = cmd_set_burst_tx_retry_parsed,
5024 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5026 (void *)&cmd_set_burst_tx_retry_set,
5027 (void *)&cmd_set_burst_tx_retry_burst,
5028 (void *)&cmd_set_burst_tx_retry_tx,
5029 (void *)&cmd_set_burst_tx_retry_delay,
5030 (void *)&cmd_set_burst_tx_retry_time,
5031 (void *)&cmd_set_burst_tx_retry_retry,
5032 (void *)&cmd_set_burst_tx_retry_retry_num,
5037 /* *** SET PROMISC MODE *** */
5038 struct cmd_set_promisc_mode_result {
5039 cmdline_fixed_string_t set;
5040 cmdline_fixed_string_t promisc;
5041 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5042 uint8_t port_num; /* valid if "allports" argument == 0 */
5043 cmdline_fixed_string_t mode;
5046 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5047 __attribute__((unused)) struct cmdline *cl,
5050 struct cmd_set_promisc_mode_result *res = parsed_result;
5054 if (!strcmp(res->mode, "on"))
5061 RTE_ETH_FOREACH_DEV(i) {
5063 rte_eth_promiscuous_enable(i);
5065 rte_eth_promiscuous_disable(i);
5070 rte_eth_promiscuous_enable(res->port_num);
5072 rte_eth_promiscuous_disable(res->port_num);
5076 cmdline_parse_token_string_t cmd_setpromisc_set =
5077 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5078 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5079 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5081 cmdline_parse_token_string_t cmd_setpromisc_portall =
5082 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5084 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5085 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5087 cmdline_parse_token_string_t cmd_setpromisc_mode =
5088 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5091 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5092 .f = cmd_set_promisc_mode_parsed,
5094 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5096 (void *)&cmd_setpromisc_set,
5097 (void *)&cmd_setpromisc_promisc,
5098 (void *)&cmd_setpromisc_portall,
5099 (void *)&cmd_setpromisc_mode,
5104 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5105 .f = cmd_set_promisc_mode_parsed,
5107 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5109 (void *)&cmd_setpromisc_set,
5110 (void *)&cmd_setpromisc_promisc,
5111 (void *)&cmd_setpromisc_portnum,
5112 (void *)&cmd_setpromisc_mode,
5117 /* *** SET ALLMULTI MODE *** */
5118 struct cmd_set_allmulti_mode_result {
5119 cmdline_fixed_string_t set;
5120 cmdline_fixed_string_t allmulti;
5121 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5122 uint8_t port_num; /* valid if "allports" argument == 0 */
5123 cmdline_fixed_string_t mode;
5126 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5127 __attribute__((unused)) struct cmdline *cl,
5130 struct cmd_set_allmulti_mode_result *res = parsed_result;
5134 if (!strcmp(res->mode, "on"))
5141 RTE_ETH_FOREACH_DEV(i) {
5143 rte_eth_allmulticast_enable(i);
5145 rte_eth_allmulticast_disable(i);
5150 rte_eth_allmulticast_enable(res->port_num);
5152 rte_eth_allmulticast_disable(res->port_num);
5156 cmdline_parse_token_string_t cmd_setallmulti_set =
5157 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5158 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5159 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5161 cmdline_parse_token_string_t cmd_setallmulti_portall =
5162 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5164 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5165 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5167 cmdline_parse_token_string_t cmd_setallmulti_mode =
5168 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5171 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5172 .f = cmd_set_allmulti_mode_parsed,
5174 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5176 (void *)&cmd_setallmulti_set,
5177 (void *)&cmd_setallmulti_allmulti,
5178 (void *)&cmd_setallmulti_portall,
5179 (void *)&cmd_setallmulti_mode,
5184 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5185 .f = cmd_set_allmulti_mode_parsed,
5187 .help_str = "set allmulti <port_id> on|off: "
5188 "Set allmulti mode on port_id",
5190 (void *)&cmd_setallmulti_set,
5191 (void *)&cmd_setallmulti_allmulti,
5192 (void *)&cmd_setallmulti_portnum,
5193 (void *)&cmd_setallmulti_mode,
5198 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5199 struct cmd_link_flow_ctrl_set_result {
5200 cmdline_fixed_string_t set;
5201 cmdline_fixed_string_t flow_ctrl;
5202 cmdline_fixed_string_t rx;
5203 cmdline_fixed_string_t rx_lfc_mode;
5204 cmdline_fixed_string_t tx;
5205 cmdline_fixed_string_t tx_lfc_mode;
5206 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5207 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5208 cmdline_fixed_string_t autoneg_str;
5209 cmdline_fixed_string_t autoneg;
5210 cmdline_fixed_string_t hw_str;
5211 uint32_t high_water;
5212 cmdline_fixed_string_t lw_str;
5214 cmdline_fixed_string_t pt_str;
5215 uint16_t pause_time;
5216 cmdline_fixed_string_t xon_str;
5221 cmdline_parse_token_string_t cmd_lfc_set_set =
5222 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5224 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5225 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5226 flow_ctrl, "flow_ctrl");
5227 cmdline_parse_token_string_t cmd_lfc_set_rx =
5228 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5230 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5231 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5232 rx_lfc_mode, "on#off");
5233 cmdline_parse_token_string_t cmd_lfc_set_tx =
5234 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5236 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5237 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5238 tx_lfc_mode, "on#off");
5239 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5240 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5241 hw_str, "high_water");
5242 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5243 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5244 high_water, UINT32);
5245 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5246 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5247 lw_str, "low_water");
5248 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5249 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5251 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5252 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5253 pt_str, "pause_time");
5254 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5255 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5256 pause_time, UINT16);
5257 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5258 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5259 xon_str, "send_xon");
5260 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5261 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5263 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5264 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5265 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5266 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5267 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5268 mac_ctrl_frame_fwd_mode, "on#off");
5269 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5270 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5271 autoneg_str, "autoneg");
5272 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5273 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5275 cmdline_parse_token_num_t cmd_lfc_set_portid =
5276 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5279 /* forward declaration */
5281 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5284 cmdline_parse_inst_t cmd_link_flow_control_set = {
5285 .f = cmd_link_flow_ctrl_set_parsed,
5287 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5288 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5289 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5291 (void *)&cmd_lfc_set_set,
5292 (void *)&cmd_lfc_set_flow_ctrl,
5293 (void *)&cmd_lfc_set_rx,
5294 (void *)&cmd_lfc_set_rx_mode,
5295 (void *)&cmd_lfc_set_tx,
5296 (void *)&cmd_lfc_set_tx_mode,
5297 (void *)&cmd_lfc_set_high_water,
5298 (void *)&cmd_lfc_set_low_water,
5299 (void *)&cmd_lfc_set_pause_time,
5300 (void *)&cmd_lfc_set_send_xon,
5301 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5302 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5303 (void *)&cmd_lfc_set_autoneg_str,
5304 (void *)&cmd_lfc_set_autoneg,
5305 (void *)&cmd_lfc_set_portid,
5310 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5311 .f = cmd_link_flow_ctrl_set_parsed,
5312 .data = (void *)&cmd_link_flow_control_set_rx,
5313 .help_str = "set flow_ctrl rx on|off <port_id>: "
5314 "Change rx flow control parameter",
5316 (void *)&cmd_lfc_set_set,
5317 (void *)&cmd_lfc_set_flow_ctrl,
5318 (void *)&cmd_lfc_set_rx,
5319 (void *)&cmd_lfc_set_rx_mode,
5320 (void *)&cmd_lfc_set_portid,
5325 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5326 .f = cmd_link_flow_ctrl_set_parsed,
5327 .data = (void *)&cmd_link_flow_control_set_tx,
5328 .help_str = "set flow_ctrl tx on|off <port_id>: "
5329 "Change tx flow control parameter",
5331 (void *)&cmd_lfc_set_set,
5332 (void *)&cmd_lfc_set_flow_ctrl,
5333 (void *)&cmd_lfc_set_tx,
5334 (void *)&cmd_lfc_set_tx_mode,
5335 (void *)&cmd_lfc_set_portid,
5340 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5341 .f = cmd_link_flow_ctrl_set_parsed,
5342 .data = (void *)&cmd_link_flow_control_set_hw,
5343 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5344 "Change high water flow control parameter",
5346 (void *)&cmd_lfc_set_set,
5347 (void *)&cmd_lfc_set_flow_ctrl,
5348 (void *)&cmd_lfc_set_high_water_str,
5349 (void *)&cmd_lfc_set_high_water,
5350 (void *)&cmd_lfc_set_portid,
5355 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5356 .f = cmd_link_flow_ctrl_set_parsed,
5357 .data = (void *)&cmd_link_flow_control_set_lw,
5358 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5359 "Change low water flow control parameter",
5361 (void *)&cmd_lfc_set_set,
5362 (void *)&cmd_lfc_set_flow_ctrl,
5363 (void *)&cmd_lfc_set_low_water_str,
5364 (void *)&cmd_lfc_set_low_water,
5365 (void *)&cmd_lfc_set_portid,
5370 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5371 .f = cmd_link_flow_ctrl_set_parsed,
5372 .data = (void *)&cmd_link_flow_control_set_pt,
5373 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5374 "Change pause time flow control parameter",
5376 (void *)&cmd_lfc_set_set,
5377 (void *)&cmd_lfc_set_flow_ctrl,
5378 (void *)&cmd_lfc_set_pause_time_str,
5379 (void *)&cmd_lfc_set_pause_time,
5380 (void *)&cmd_lfc_set_portid,
5385 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5386 .f = cmd_link_flow_ctrl_set_parsed,
5387 .data = (void *)&cmd_link_flow_control_set_xon,
5388 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5389 "Change send_xon flow control parameter",
5391 (void *)&cmd_lfc_set_set,
5392 (void *)&cmd_lfc_set_flow_ctrl,
5393 (void *)&cmd_lfc_set_send_xon_str,
5394 (void *)&cmd_lfc_set_send_xon,
5395 (void *)&cmd_lfc_set_portid,
5400 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5401 .f = cmd_link_flow_ctrl_set_parsed,
5402 .data = (void *)&cmd_link_flow_control_set_macfwd,
5403 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5404 "Change mac ctrl fwd flow control parameter",
5406 (void *)&cmd_lfc_set_set,
5407 (void *)&cmd_lfc_set_flow_ctrl,
5408 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5409 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5410 (void *)&cmd_lfc_set_portid,
5415 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5416 .f = cmd_link_flow_ctrl_set_parsed,
5417 .data = (void *)&cmd_link_flow_control_set_autoneg,
5418 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5419 "Change autoneg flow control parameter",
5421 (void *)&cmd_lfc_set_set,
5422 (void *)&cmd_lfc_set_flow_ctrl,
5423 (void *)&cmd_lfc_set_autoneg_str,
5424 (void *)&cmd_lfc_set_autoneg,
5425 (void *)&cmd_lfc_set_portid,
5431 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5432 __attribute__((unused)) struct cmdline *cl,
5435 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5436 cmdline_parse_inst_t *cmd = data;
5437 struct rte_eth_fc_conf fc_conf;
5443 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5444 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5445 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5446 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5448 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5449 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5452 /* Partial command line, retrieve current configuration */
5454 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5456 printf("cannot get current flow ctrl parameters, return"
5457 "code = %d\n", ret);
5461 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5462 (fc_conf.mode == RTE_FC_FULL))
5464 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5465 (fc_conf.mode == RTE_FC_FULL))
5469 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5470 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5472 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5473 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5475 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5477 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5478 fc_conf.high_water = res->high_water;
5480 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5481 fc_conf.low_water = res->low_water;
5483 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5484 fc_conf.pause_time = res->pause_time;
5486 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5487 fc_conf.send_xon = res->send_xon;
5489 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5490 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5491 fc_conf.mac_ctrl_frame_fwd = 1;
5493 fc_conf.mac_ctrl_frame_fwd = 0;
5496 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5497 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5499 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5501 printf("bad flow contrl parameter, return code = %d \n", ret);
5504 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5505 struct cmd_priority_flow_ctrl_set_result {
5506 cmdline_fixed_string_t set;
5507 cmdline_fixed_string_t pfc_ctrl;
5508 cmdline_fixed_string_t rx;
5509 cmdline_fixed_string_t rx_pfc_mode;
5510 cmdline_fixed_string_t tx;
5511 cmdline_fixed_string_t tx_pfc_mode;
5512 uint32_t high_water;
5514 uint16_t pause_time;
5520 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5521 __attribute__((unused)) struct cmdline *cl,
5522 __attribute__((unused)) void *data)
5524 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5525 struct rte_eth_pfc_conf pfc_conf;
5526 int rx_fc_enable, tx_fc_enable;
5530 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5531 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5532 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5533 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5535 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5536 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5539 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5540 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5541 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5542 pfc_conf.fc.high_water = res->high_water;
5543 pfc_conf.fc.low_water = res->low_water;
5544 pfc_conf.fc.pause_time = res->pause_time;
5545 pfc_conf.priority = res->priority;
5547 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5549 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5552 cmdline_parse_token_string_t cmd_pfc_set_set =
5553 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5555 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5556 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5557 pfc_ctrl, "pfc_ctrl");
5558 cmdline_parse_token_string_t cmd_pfc_set_rx =
5559 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5561 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5562 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5563 rx_pfc_mode, "on#off");
5564 cmdline_parse_token_string_t cmd_pfc_set_tx =
5565 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5567 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5568 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5569 tx_pfc_mode, "on#off");
5570 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5571 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5572 high_water, UINT32);
5573 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5574 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5576 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5577 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5578 pause_time, UINT16);
5579 cmdline_parse_token_num_t cmd_pfc_set_priority =
5580 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5582 cmdline_parse_token_num_t cmd_pfc_set_portid =
5583 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5586 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5587 .f = cmd_priority_flow_ctrl_set_parsed,
5589 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5590 "<pause_time> <priority> <port_id>: "
5591 "Configure the Ethernet priority flow control",
5593 (void *)&cmd_pfc_set_set,
5594 (void *)&cmd_pfc_set_flow_ctrl,
5595 (void *)&cmd_pfc_set_rx,
5596 (void *)&cmd_pfc_set_rx_mode,
5597 (void *)&cmd_pfc_set_tx,
5598 (void *)&cmd_pfc_set_tx_mode,
5599 (void *)&cmd_pfc_set_high_water,
5600 (void *)&cmd_pfc_set_low_water,
5601 (void *)&cmd_pfc_set_pause_time,
5602 (void *)&cmd_pfc_set_priority,
5603 (void *)&cmd_pfc_set_portid,
5608 /* *** RESET CONFIGURATION *** */
5609 struct cmd_reset_result {
5610 cmdline_fixed_string_t reset;
5611 cmdline_fixed_string_t def;
5614 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5616 __attribute__((unused)) void *data)
5618 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5619 set_def_fwd_config();
5622 cmdline_parse_token_string_t cmd_reset_set =
5623 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5624 cmdline_parse_token_string_t cmd_reset_def =
5625 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5628 cmdline_parse_inst_t cmd_reset = {
5629 .f = cmd_reset_parsed,
5631 .help_str = "set default: Reset default forwarding configuration",
5633 (void *)&cmd_reset_set,
5634 (void *)&cmd_reset_def,
5639 /* *** START FORWARDING *** */
5640 struct cmd_start_result {
5641 cmdline_fixed_string_t start;
5644 cmdline_parse_token_string_t cmd_start_start =
5645 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5647 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5648 __attribute__((unused)) struct cmdline *cl,
5649 __attribute__((unused)) void *data)
5651 start_packet_forwarding(0);
5654 cmdline_parse_inst_t cmd_start = {
5655 .f = cmd_start_parsed,
5657 .help_str = "start: Start packet forwarding",
5659 (void *)&cmd_start_start,
5664 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5665 struct cmd_start_tx_first_result {
5666 cmdline_fixed_string_t start;
5667 cmdline_fixed_string_t tx_first;
5671 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5672 __attribute__((unused)) struct cmdline *cl,
5673 __attribute__((unused)) void *data)
5675 start_packet_forwarding(1);
5678 cmdline_parse_token_string_t cmd_start_tx_first_start =
5679 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5681 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5682 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5683 tx_first, "tx_first");
5685 cmdline_parse_inst_t cmd_start_tx_first = {
5686 .f = cmd_start_tx_first_parsed,
5688 .help_str = "start tx_first: Start packet forwarding, "
5689 "after sending 1 burst of packets",
5691 (void *)&cmd_start_tx_first_start,
5692 (void *)&cmd_start_tx_first_tx_first,
5697 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5698 struct cmd_start_tx_first_n_result {
5699 cmdline_fixed_string_t start;
5700 cmdline_fixed_string_t tx_first;
5705 cmd_start_tx_first_n_parsed(void *parsed_result,
5706 __attribute__((unused)) struct cmdline *cl,
5707 __attribute__((unused)) void *data)
5709 struct cmd_start_tx_first_n_result *res = parsed_result;
5711 start_packet_forwarding(res->tx_num);
5714 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5715 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5717 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5718 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5719 tx_first, "tx_first");
5720 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5721 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5724 cmdline_parse_inst_t cmd_start_tx_first_n = {
5725 .f = cmd_start_tx_first_n_parsed,
5727 .help_str = "start tx_first <num>: "
5728 "packet forwarding, after sending <num> bursts of packets",
5730 (void *)&cmd_start_tx_first_n_start,
5731 (void *)&cmd_start_tx_first_n_tx_first,
5732 (void *)&cmd_start_tx_first_n_tx_num,
5737 /* *** SET LINK UP *** */
5738 struct cmd_set_link_up_result {
5739 cmdline_fixed_string_t set;
5740 cmdline_fixed_string_t link_up;
5741 cmdline_fixed_string_t port;
5745 cmdline_parse_token_string_t cmd_set_link_up_set =
5746 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5747 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5748 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5750 cmdline_parse_token_string_t cmd_set_link_up_port =
5751 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5752 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5753 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5755 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5756 __attribute__((unused)) struct cmdline *cl,
5757 __attribute__((unused)) void *data)
5759 struct cmd_set_link_up_result *res = parsed_result;
5760 dev_set_link_up(res->port_id);
5763 cmdline_parse_inst_t cmd_set_link_up = {
5764 .f = cmd_set_link_up_parsed,
5766 .help_str = "set link-up port <port id>",
5768 (void *)&cmd_set_link_up_set,
5769 (void *)&cmd_set_link_up_link_up,
5770 (void *)&cmd_set_link_up_port,
5771 (void *)&cmd_set_link_up_port_id,
5776 /* *** SET LINK DOWN *** */
5777 struct cmd_set_link_down_result {
5778 cmdline_fixed_string_t set;
5779 cmdline_fixed_string_t link_down;
5780 cmdline_fixed_string_t port;
5784 cmdline_parse_token_string_t cmd_set_link_down_set =
5785 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5786 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5787 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5789 cmdline_parse_token_string_t cmd_set_link_down_port =
5790 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5791 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5792 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5794 static void cmd_set_link_down_parsed(
5795 __attribute__((unused)) void *parsed_result,
5796 __attribute__((unused)) struct cmdline *cl,
5797 __attribute__((unused)) void *data)
5799 struct cmd_set_link_down_result *res = parsed_result;
5800 dev_set_link_down(res->port_id);
5803 cmdline_parse_inst_t cmd_set_link_down = {
5804 .f = cmd_set_link_down_parsed,
5806 .help_str = "set link-down port <port id>",
5808 (void *)&cmd_set_link_down_set,
5809 (void *)&cmd_set_link_down_link_down,
5810 (void *)&cmd_set_link_down_port,
5811 (void *)&cmd_set_link_down_port_id,
5816 /* *** SHOW CFG *** */
5817 struct cmd_showcfg_result {
5818 cmdline_fixed_string_t show;
5819 cmdline_fixed_string_t cfg;
5820 cmdline_fixed_string_t what;
5823 static void cmd_showcfg_parsed(void *parsed_result,
5824 __attribute__((unused)) struct cmdline *cl,
5825 __attribute__((unused)) void *data)
5827 struct cmd_showcfg_result *res = parsed_result;
5828 if (!strcmp(res->what, "rxtx"))
5829 rxtx_config_display();
5830 else if (!strcmp(res->what, "cores"))
5831 fwd_lcores_config_display();
5832 else if (!strcmp(res->what, "fwd"))
5833 pkt_fwd_config_display(&cur_fwd_config);
5834 else if (!strcmp(res->what, "txpkts"))
5835 show_tx_pkt_segments();
5838 cmdline_parse_token_string_t cmd_showcfg_show =
5839 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5840 cmdline_parse_token_string_t cmd_showcfg_port =
5841 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5842 cmdline_parse_token_string_t cmd_showcfg_what =
5843 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5844 "rxtx#cores#fwd#txpkts");
5846 cmdline_parse_inst_t cmd_showcfg = {
5847 .f = cmd_showcfg_parsed,
5849 .help_str = "show config rxtx|cores|fwd|txpkts",
5851 (void *)&cmd_showcfg_show,
5852 (void *)&cmd_showcfg_port,
5853 (void *)&cmd_showcfg_what,
5858 /* *** SHOW ALL PORT INFO *** */
5859 struct cmd_showportall_result {
5860 cmdline_fixed_string_t show;
5861 cmdline_fixed_string_t port;
5862 cmdline_fixed_string_t what;
5863 cmdline_fixed_string_t all;
5866 static void cmd_showportall_parsed(void *parsed_result,
5867 __attribute__((unused)) struct cmdline *cl,
5868 __attribute__((unused)) void *data)
5872 struct cmd_showportall_result *res = parsed_result;
5873 if (!strcmp(res->show, "clear")) {
5874 if (!strcmp(res->what, "stats"))
5875 RTE_ETH_FOREACH_DEV(i)
5877 else if (!strcmp(res->what, "xstats"))
5878 RTE_ETH_FOREACH_DEV(i)
5879 nic_xstats_clear(i);
5880 } else if (!strcmp(res->what, "info"))
5881 RTE_ETH_FOREACH_DEV(i)
5882 port_infos_display(i);
5883 else if (!strcmp(res->what, "stats"))
5884 RTE_ETH_FOREACH_DEV(i)
5885 nic_stats_display(i);
5886 else if (!strcmp(res->what, "xstats"))
5887 RTE_ETH_FOREACH_DEV(i)
5888 nic_xstats_display(i);
5889 else if (!strcmp(res->what, "fdir"))
5890 RTE_ETH_FOREACH_DEV(i)
5892 else if (!strcmp(res->what, "stat_qmap"))
5893 RTE_ETH_FOREACH_DEV(i)
5894 nic_stats_mapping_display(i);
5895 else if (!strcmp(res->what, "dcb_tc"))
5896 RTE_ETH_FOREACH_DEV(i)
5897 port_dcb_info_display(i);
5898 else if (!strcmp(res->what, "cap"))
5899 RTE_ETH_FOREACH_DEV(i)
5900 port_offload_cap_display(i);
5903 cmdline_parse_token_string_t cmd_showportall_show =
5904 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5906 cmdline_parse_token_string_t cmd_showportall_port =
5907 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5908 cmdline_parse_token_string_t cmd_showportall_what =
5909 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5910 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5911 cmdline_parse_token_string_t cmd_showportall_all =
5912 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5913 cmdline_parse_inst_t cmd_showportall = {
5914 .f = cmd_showportall_parsed,
5916 .help_str = "show|clear port "
5917 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5919 (void *)&cmd_showportall_show,
5920 (void *)&cmd_showportall_port,
5921 (void *)&cmd_showportall_what,
5922 (void *)&cmd_showportall_all,
5927 /* *** SHOW PORT INFO *** */
5928 struct cmd_showport_result {
5929 cmdline_fixed_string_t show;
5930 cmdline_fixed_string_t port;
5931 cmdline_fixed_string_t what;
5935 static void cmd_showport_parsed(void *parsed_result,
5936 __attribute__((unused)) struct cmdline *cl,
5937 __attribute__((unused)) void *data)
5939 struct cmd_showport_result *res = parsed_result;
5940 if (!strcmp(res->show, "clear")) {
5941 if (!strcmp(res->what, "stats"))
5942 nic_stats_clear(res->portnum);
5943 else if (!strcmp(res->what, "xstats"))
5944 nic_xstats_clear(res->portnum);
5945 } else if (!strcmp(res->what, "info"))
5946 port_infos_display(res->portnum);
5947 else if (!strcmp(res->what, "stats"))
5948 nic_stats_display(res->portnum);
5949 else if (!strcmp(res->what, "xstats"))
5950 nic_xstats_display(res->portnum);
5951 else if (!strcmp(res->what, "fdir"))
5952 fdir_get_infos(res->portnum);
5953 else if (!strcmp(res->what, "stat_qmap"))
5954 nic_stats_mapping_display(res->portnum);
5955 else if (!strcmp(res->what, "dcb_tc"))
5956 port_dcb_info_display(res->portnum);
5957 else if (!strcmp(res->what, "cap"))
5958 port_offload_cap_display(res->portnum);
5961 cmdline_parse_token_string_t cmd_showport_show =
5962 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5964 cmdline_parse_token_string_t cmd_showport_port =
5965 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5966 cmdline_parse_token_string_t cmd_showport_what =
5967 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5968 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5969 cmdline_parse_token_num_t cmd_showport_portnum =
5970 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5972 cmdline_parse_inst_t cmd_showport = {
5973 .f = cmd_showport_parsed,
5975 .help_str = "show|clear port "
5976 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5979 (void *)&cmd_showport_show,
5980 (void *)&cmd_showport_port,
5981 (void *)&cmd_showport_what,
5982 (void *)&cmd_showport_portnum,
5987 /* *** SHOW QUEUE INFO *** */
5988 struct cmd_showqueue_result {
5989 cmdline_fixed_string_t show;
5990 cmdline_fixed_string_t type;
5991 cmdline_fixed_string_t what;
5997 cmd_showqueue_parsed(void *parsed_result,
5998 __attribute__((unused)) struct cmdline *cl,
5999 __attribute__((unused)) void *data)
6001 struct cmd_showqueue_result *res = parsed_result;
6003 if (!strcmp(res->type, "rxq"))
6004 rx_queue_infos_display(res->portnum, res->queuenum);
6005 else if (!strcmp(res->type, "txq"))
6006 tx_queue_infos_display(res->portnum, res->queuenum);
6009 cmdline_parse_token_string_t cmd_showqueue_show =
6010 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6011 cmdline_parse_token_string_t cmd_showqueue_type =
6012 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6013 cmdline_parse_token_string_t cmd_showqueue_what =
6014 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6015 cmdline_parse_token_num_t cmd_showqueue_portnum =
6016 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6017 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6018 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6020 cmdline_parse_inst_t cmd_showqueue = {
6021 .f = cmd_showqueue_parsed,
6023 .help_str = "show rxq|txq info <port_id> <queue_id>",
6025 (void *)&cmd_showqueue_show,
6026 (void *)&cmd_showqueue_type,
6027 (void *)&cmd_showqueue_what,
6028 (void *)&cmd_showqueue_portnum,
6029 (void *)&cmd_showqueue_queuenum,
6034 /* *** READ PORT REGISTER *** */
6035 struct cmd_read_reg_result {
6036 cmdline_fixed_string_t read;
6037 cmdline_fixed_string_t reg;
6043 cmd_read_reg_parsed(void *parsed_result,
6044 __attribute__((unused)) struct cmdline *cl,
6045 __attribute__((unused)) void *data)
6047 struct cmd_read_reg_result *res = parsed_result;
6048 port_reg_display(res->port_id, res->reg_off);
6051 cmdline_parse_token_string_t cmd_read_reg_read =
6052 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6053 cmdline_parse_token_string_t cmd_read_reg_reg =
6054 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6055 cmdline_parse_token_num_t cmd_read_reg_port_id =
6056 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6057 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6058 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6060 cmdline_parse_inst_t cmd_read_reg = {
6061 .f = cmd_read_reg_parsed,
6063 .help_str = "read reg <port_id> <reg_off>",
6065 (void *)&cmd_read_reg_read,
6066 (void *)&cmd_read_reg_reg,
6067 (void *)&cmd_read_reg_port_id,
6068 (void *)&cmd_read_reg_reg_off,
6073 /* *** READ PORT REGISTER BIT FIELD *** */
6074 struct cmd_read_reg_bit_field_result {
6075 cmdline_fixed_string_t read;
6076 cmdline_fixed_string_t regfield;
6084 cmd_read_reg_bit_field_parsed(void *parsed_result,
6085 __attribute__((unused)) struct cmdline *cl,
6086 __attribute__((unused)) void *data)
6088 struct cmd_read_reg_bit_field_result *res = parsed_result;
6089 port_reg_bit_field_display(res->port_id, res->reg_off,
6090 res->bit1_pos, res->bit2_pos);
6093 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6094 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6096 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6097 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6098 regfield, "regfield");
6099 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6100 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6102 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6103 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6105 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6106 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6108 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6109 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6112 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6113 .f = cmd_read_reg_bit_field_parsed,
6115 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6116 "Read register bit field between bit_x and bit_y included",
6118 (void *)&cmd_read_reg_bit_field_read,
6119 (void *)&cmd_read_reg_bit_field_regfield,
6120 (void *)&cmd_read_reg_bit_field_port_id,
6121 (void *)&cmd_read_reg_bit_field_reg_off,
6122 (void *)&cmd_read_reg_bit_field_bit1_pos,
6123 (void *)&cmd_read_reg_bit_field_bit2_pos,
6128 /* *** READ PORT REGISTER BIT *** */
6129 struct cmd_read_reg_bit_result {
6130 cmdline_fixed_string_t read;
6131 cmdline_fixed_string_t regbit;
6138 cmd_read_reg_bit_parsed(void *parsed_result,
6139 __attribute__((unused)) struct cmdline *cl,
6140 __attribute__((unused)) void *data)
6142 struct cmd_read_reg_bit_result *res = parsed_result;
6143 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6146 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6147 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6148 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6149 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6151 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6152 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6153 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6154 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6155 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6156 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6158 cmdline_parse_inst_t cmd_read_reg_bit = {
6159 .f = cmd_read_reg_bit_parsed,
6161 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6163 (void *)&cmd_read_reg_bit_read,
6164 (void *)&cmd_read_reg_bit_regbit,
6165 (void *)&cmd_read_reg_bit_port_id,
6166 (void *)&cmd_read_reg_bit_reg_off,
6167 (void *)&cmd_read_reg_bit_bit_pos,
6172 /* *** WRITE PORT REGISTER *** */
6173 struct cmd_write_reg_result {
6174 cmdline_fixed_string_t write;
6175 cmdline_fixed_string_t reg;
6182 cmd_write_reg_parsed(void *parsed_result,
6183 __attribute__((unused)) struct cmdline *cl,
6184 __attribute__((unused)) void *data)
6186 struct cmd_write_reg_result *res = parsed_result;
6187 port_reg_set(res->port_id, res->reg_off, res->value);
6190 cmdline_parse_token_string_t cmd_write_reg_write =
6191 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6192 cmdline_parse_token_string_t cmd_write_reg_reg =
6193 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6194 cmdline_parse_token_num_t cmd_write_reg_port_id =
6195 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6196 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6197 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6198 cmdline_parse_token_num_t cmd_write_reg_value =
6199 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6201 cmdline_parse_inst_t cmd_write_reg = {
6202 .f = cmd_write_reg_parsed,
6204 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6206 (void *)&cmd_write_reg_write,
6207 (void *)&cmd_write_reg_reg,
6208 (void *)&cmd_write_reg_port_id,
6209 (void *)&cmd_write_reg_reg_off,
6210 (void *)&cmd_write_reg_value,
6215 /* *** WRITE PORT REGISTER BIT FIELD *** */
6216 struct cmd_write_reg_bit_field_result {
6217 cmdline_fixed_string_t write;
6218 cmdline_fixed_string_t regfield;
6227 cmd_write_reg_bit_field_parsed(void *parsed_result,
6228 __attribute__((unused)) struct cmdline *cl,
6229 __attribute__((unused)) void *data)
6231 struct cmd_write_reg_bit_field_result *res = parsed_result;
6232 port_reg_bit_field_set(res->port_id, res->reg_off,
6233 res->bit1_pos, res->bit2_pos, res->value);
6236 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6237 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6239 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6240 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6241 regfield, "regfield");
6242 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6243 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6245 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6246 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6248 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6249 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6251 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6252 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6254 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6255 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6258 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6259 .f = cmd_write_reg_bit_field_parsed,
6261 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6263 "Set register bit field between bit_x and bit_y included",
6265 (void *)&cmd_write_reg_bit_field_write,
6266 (void *)&cmd_write_reg_bit_field_regfield,
6267 (void *)&cmd_write_reg_bit_field_port_id,
6268 (void *)&cmd_write_reg_bit_field_reg_off,
6269 (void *)&cmd_write_reg_bit_field_bit1_pos,
6270 (void *)&cmd_write_reg_bit_field_bit2_pos,
6271 (void *)&cmd_write_reg_bit_field_value,
6276 /* *** WRITE PORT REGISTER BIT *** */
6277 struct cmd_write_reg_bit_result {
6278 cmdline_fixed_string_t write;
6279 cmdline_fixed_string_t regbit;
6287 cmd_write_reg_bit_parsed(void *parsed_result,
6288 __attribute__((unused)) struct cmdline *cl,
6289 __attribute__((unused)) void *data)
6291 struct cmd_write_reg_bit_result *res = parsed_result;
6292 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6295 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6296 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6298 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6299 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6301 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6302 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6303 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6304 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6305 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6306 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6307 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6308 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6310 cmdline_parse_inst_t cmd_write_reg_bit = {
6311 .f = cmd_write_reg_bit_parsed,
6313 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6316 (void *)&cmd_write_reg_bit_write,
6317 (void *)&cmd_write_reg_bit_regbit,
6318 (void *)&cmd_write_reg_bit_port_id,
6319 (void *)&cmd_write_reg_bit_reg_off,
6320 (void *)&cmd_write_reg_bit_bit_pos,
6321 (void *)&cmd_write_reg_bit_value,
6326 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6327 struct cmd_read_rxd_txd_result {
6328 cmdline_fixed_string_t read;
6329 cmdline_fixed_string_t rxd_txd;
6336 cmd_read_rxd_txd_parsed(void *parsed_result,
6337 __attribute__((unused)) struct cmdline *cl,
6338 __attribute__((unused)) void *data)
6340 struct cmd_read_rxd_txd_result *res = parsed_result;
6342 if (!strcmp(res->rxd_txd, "rxd"))
6343 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6344 else if (!strcmp(res->rxd_txd, "txd"))
6345 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6348 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6349 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6350 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6351 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6353 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6354 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6355 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6356 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6357 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6358 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6360 cmdline_parse_inst_t cmd_read_rxd_txd = {
6361 .f = cmd_read_rxd_txd_parsed,
6363 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6365 (void *)&cmd_read_rxd_txd_read,
6366 (void *)&cmd_read_rxd_txd_rxd_txd,
6367 (void *)&cmd_read_rxd_txd_port_id,
6368 (void *)&cmd_read_rxd_txd_queue_id,
6369 (void *)&cmd_read_rxd_txd_desc_id,
6375 struct cmd_quit_result {
6376 cmdline_fixed_string_t quit;
6379 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6381 __attribute__((unused)) void *data)
6387 cmdline_parse_token_string_t cmd_quit_quit =
6388 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6390 cmdline_parse_inst_t cmd_quit = {
6391 .f = cmd_quit_parsed,
6393 .help_str = "quit: Exit application",
6395 (void *)&cmd_quit_quit,
6400 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6401 struct cmd_mac_addr_result {
6402 cmdline_fixed_string_t mac_addr_cmd;
6403 cmdline_fixed_string_t what;
6405 struct ether_addr address;
6408 static void cmd_mac_addr_parsed(void *parsed_result,
6409 __attribute__((unused)) struct cmdline *cl,
6410 __attribute__((unused)) void *data)
6412 struct cmd_mac_addr_result *res = parsed_result;
6415 if (strcmp(res->what, "add") == 0)
6416 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6417 else if (strcmp(res->what, "set") == 0)
6418 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6421 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6423 /* check the return value and print it if is < 0 */
6425 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6429 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6430 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6432 cmdline_parse_token_string_t cmd_mac_addr_what =
6433 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6435 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6436 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6437 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6438 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6440 cmdline_parse_inst_t cmd_mac_addr = {
6441 .f = cmd_mac_addr_parsed,
6443 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6444 "Add/Remove/Set MAC address on port_id",
6446 (void *)&cmd_mac_addr_cmd,
6447 (void *)&cmd_mac_addr_what,
6448 (void *)&cmd_mac_addr_portnum,
6449 (void *)&cmd_mac_addr_addr,
6455 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6456 struct cmd_set_qmap_result {
6457 cmdline_fixed_string_t set;
6458 cmdline_fixed_string_t qmap;
6459 cmdline_fixed_string_t what;
6466 cmd_set_qmap_parsed(void *parsed_result,
6467 __attribute__((unused)) struct cmdline *cl,
6468 __attribute__((unused)) void *data)
6470 struct cmd_set_qmap_result *res = parsed_result;
6471 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6473 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6476 cmdline_parse_token_string_t cmd_setqmap_set =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6479 cmdline_parse_token_string_t cmd_setqmap_qmap =
6480 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6482 cmdline_parse_token_string_t cmd_setqmap_what =
6483 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6485 cmdline_parse_token_num_t cmd_setqmap_portid =
6486 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6488 cmdline_parse_token_num_t cmd_setqmap_queueid =
6489 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6491 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6492 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6495 cmdline_parse_inst_t cmd_set_qmap = {
6496 .f = cmd_set_qmap_parsed,
6498 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6499 "Set statistics mapping value on tx|rx queue_id of port_id",
6501 (void *)&cmd_setqmap_set,
6502 (void *)&cmd_setqmap_qmap,
6503 (void *)&cmd_setqmap_what,
6504 (void *)&cmd_setqmap_portid,
6505 (void *)&cmd_setqmap_queueid,
6506 (void *)&cmd_setqmap_mapvalue,
6511 /* *** CONFIGURE UNICAST HASH TABLE *** */
6512 struct cmd_set_uc_hash_table {
6513 cmdline_fixed_string_t set;
6514 cmdline_fixed_string_t port;
6516 cmdline_fixed_string_t what;
6517 struct ether_addr address;
6518 cmdline_fixed_string_t mode;
6522 cmd_set_uc_hash_parsed(void *parsed_result,
6523 __attribute__((unused)) struct cmdline *cl,
6524 __attribute__((unused)) void *data)
6527 struct cmd_set_uc_hash_table *res = parsed_result;
6529 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6531 if (strcmp(res->what, "uta") == 0)
6532 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6533 &res->address,(uint8_t)is_on);
6535 printf("bad unicast hash table parameter, return code = %d \n", ret);
6539 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6540 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6542 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6543 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6545 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6546 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6548 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6549 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6551 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6552 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6554 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6555 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6558 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6559 .f = cmd_set_uc_hash_parsed,
6561 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6563 (void *)&cmd_set_uc_hash_set,
6564 (void *)&cmd_set_uc_hash_port,
6565 (void *)&cmd_set_uc_hash_portid,
6566 (void *)&cmd_set_uc_hash_what,
6567 (void *)&cmd_set_uc_hash_mac,
6568 (void *)&cmd_set_uc_hash_mode,
6573 struct cmd_set_uc_all_hash_table {
6574 cmdline_fixed_string_t set;
6575 cmdline_fixed_string_t port;
6577 cmdline_fixed_string_t what;
6578 cmdline_fixed_string_t value;
6579 cmdline_fixed_string_t mode;
6583 cmd_set_uc_all_hash_parsed(void *parsed_result,
6584 __attribute__((unused)) struct cmdline *cl,
6585 __attribute__((unused)) void *data)
6588 struct cmd_set_uc_all_hash_table *res = parsed_result;
6590 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6592 if ((strcmp(res->what, "uta") == 0) &&
6593 (strcmp(res->value, "all") == 0))
6594 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6596 printf("bad unicast hash table parameter,"
6597 "return code = %d \n", ret);
6600 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6601 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6603 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6604 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6606 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6607 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6609 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6610 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6612 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6613 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6615 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6616 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6619 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6620 .f = cmd_set_uc_all_hash_parsed,
6622 .help_str = "set port <port_id> uta all on|off",
6624 (void *)&cmd_set_uc_all_hash_set,
6625 (void *)&cmd_set_uc_all_hash_port,
6626 (void *)&cmd_set_uc_all_hash_portid,
6627 (void *)&cmd_set_uc_all_hash_what,
6628 (void *)&cmd_set_uc_all_hash_value,
6629 (void *)&cmd_set_uc_all_hash_mode,
6634 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6635 struct cmd_set_vf_macvlan_filter {
6636 cmdline_fixed_string_t set;
6637 cmdline_fixed_string_t port;
6639 cmdline_fixed_string_t vf;
6641 struct ether_addr address;
6642 cmdline_fixed_string_t filter_type;
6643 cmdline_fixed_string_t mode;
6647 cmd_set_vf_macvlan_parsed(void *parsed_result,
6648 __attribute__((unused)) struct cmdline *cl,
6649 __attribute__((unused)) void *data)
6652 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6653 struct rte_eth_mac_filter filter;
6655 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6657 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6659 /* set VF MAC filter */
6663 filter.dst_id = res->vf_id;
6665 if (!strcmp(res->filter_type, "exact-mac"))
6666 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6667 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6668 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6669 else if (!strcmp(res->filter_type, "hashmac"))
6670 filter.filter_type = RTE_MAC_HASH_MATCH;
6671 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6672 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6674 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6677 ret = rte_eth_dev_filter_ctrl(res->port_id,
6678 RTE_ETH_FILTER_MACVLAN,
6682 ret = rte_eth_dev_filter_ctrl(res->port_id,
6683 RTE_ETH_FILTER_MACVLAN,
6684 RTE_ETH_FILTER_DELETE,
6688 printf("bad set MAC hash parameter, return code = %d\n", ret);
6692 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6693 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6695 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6696 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6698 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6699 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6701 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6702 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6704 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6705 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6707 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6708 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6710 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6711 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6712 filter_type, "exact-mac#exact-mac-vlan"
6713 "#hashmac#hashmac-vlan");
6714 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6715 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6718 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6719 .f = cmd_set_vf_macvlan_parsed,
6721 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6722 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6723 "Exact match rule: exact match of MAC or MAC and VLAN; "
6724 "hash match rule: hash match of MAC and exact match of VLAN",
6726 (void *)&cmd_set_vf_macvlan_set,
6727 (void *)&cmd_set_vf_macvlan_port,
6728 (void *)&cmd_set_vf_macvlan_portid,
6729 (void *)&cmd_set_vf_macvlan_vf,
6730 (void *)&cmd_set_vf_macvlan_vf_id,
6731 (void *)&cmd_set_vf_macvlan_mac,
6732 (void *)&cmd_set_vf_macvlan_filter_type,
6733 (void *)&cmd_set_vf_macvlan_mode,
6738 #ifdef RTE_LIBRTE_IXGBE_PMD
6739 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6740 struct cmd_set_vf_traffic {
6741 cmdline_fixed_string_t set;
6742 cmdline_fixed_string_t port;
6744 cmdline_fixed_string_t vf;
6746 cmdline_fixed_string_t what;
6747 cmdline_fixed_string_t mode;
6751 cmd_set_vf_traffic_parsed(void *parsed_result,
6752 __attribute__((unused)) struct cmdline *cl,
6753 __attribute__((unused)) void *data)
6755 struct cmd_set_vf_traffic *res = parsed_result;
6756 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6757 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6759 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6762 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6763 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6765 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6766 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6768 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6769 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6771 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6772 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6774 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6775 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6777 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6778 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6780 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6781 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6784 cmdline_parse_inst_t cmd_set_vf_traffic = {
6785 .f = cmd_set_vf_traffic_parsed,
6787 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6789 (void *)&cmd_setvf_traffic_set,
6790 (void *)&cmd_setvf_traffic_port,
6791 (void *)&cmd_setvf_traffic_portid,
6792 (void *)&cmd_setvf_traffic_vf,
6793 (void *)&cmd_setvf_traffic_vfid,
6794 (void *)&cmd_setvf_traffic_what,
6795 (void *)&cmd_setvf_traffic_mode,
6800 /* *** CONFIGURE VF RECEIVE MODE *** */
6801 struct cmd_set_vf_rxmode {
6802 cmdline_fixed_string_t set;
6803 cmdline_fixed_string_t port;
6805 cmdline_fixed_string_t vf;
6807 cmdline_fixed_string_t what;
6808 cmdline_fixed_string_t mode;
6809 cmdline_fixed_string_t on;
6813 cmd_set_vf_rxmode_parsed(void *parsed_result,
6814 __attribute__((unused)) struct cmdline *cl,
6815 __attribute__((unused)) void *data)
6818 uint16_t rx_mode = 0;
6819 struct cmd_set_vf_rxmode *res = parsed_result;
6821 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6822 if (!strcmp(res->what,"rxmode")) {
6823 if (!strcmp(res->mode, "AUPE"))
6824 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6825 else if (!strcmp(res->mode, "ROPE"))
6826 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6827 else if (!strcmp(res->mode, "BAM"))
6828 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6829 else if (!strncmp(res->mode, "MPE",3))
6830 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6833 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6835 printf("bad VF receive mode parameter, return code = %d \n",
6839 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6840 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6842 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6843 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6845 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6846 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6848 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6849 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6851 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6852 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6854 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6855 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6857 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6858 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6859 mode, "AUPE#ROPE#BAM#MPE");
6860 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6861 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6864 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6865 .f = cmd_set_vf_rxmode_parsed,
6867 .help_str = "set port <port_id> vf <vf_id> rxmode "
6868 "AUPE|ROPE|BAM|MPE on|off",
6870 (void *)&cmd_set_vf_rxmode_set,
6871 (void *)&cmd_set_vf_rxmode_port,
6872 (void *)&cmd_set_vf_rxmode_portid,
6873 (void *)&cmd_set_vf_rxmode_vf,
6874 (void *)&cmd_set_vf_rxmode_vfid,
6875 (void *)&cmd_set_vf_rxmode_what,
6876 (void *)&cmd_set_vf_rxmode_mode,
6877 (void *)&cmd_set_vf_rxmode_on,
6883 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6884 struct cmd_vf_mac_addr_result {
6885 cmdline_fixed_string_t mac_addr_cmd;
6886 cmdline_fixed_string_t what;
6887 cmdline_fixed_string_t port;
6889 cmdline_fixed_string_t vf;
6891 struct ether_addr address;
6894 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6895 __attribute__((unused)) struct cmdline *cl,
6896 __attribute__((unused)) void *data)
6898 struct cmd_vf_mac_addr_result *res = parsed_result;
6901 if (strcmp(res->what, "add") == 0)
6902 ret = rte_eth_dev_mac_addr_add(res->port_num,
6903 &res->address, res->vf_num);
6905 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6909 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6910 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6911 mac_addr_cmd,"mac_addr");
6912 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6913 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6915 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6916 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6918 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6919 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6921 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6922 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6924 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6925 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6927 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6928 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6931 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6932 .f = cmd_vf_mac_addr_parsed,
6934 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6935 "Add MAC address filtering for a VF on port_id",
6937 (void *)&cmd_vf_mac_addr_cmd,
6938 (void *)&cmd_vf_mac_addr_what,
6939 (void *)&cmd_vf_mac_addr_port,
6940 (void *)&cmd_vf_mac_addr_portnum,
6941 (void *)&cmd_vf_mac_addr_vf,
6942 (void *)&cmd_vf_mac_addr_vfnum,
6943 (void *)&cmd_vf_mac_addr_addr,
6948 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6949 struct cmd_vf_rx_vlan_filter {
6950 cmdline_fixed_string_t rx_vlan;
6951 cmdline_fixed_string_t what;
6953 cmdline_fixed_string_t port;
6955 cmdline_fixed_string_t vf;
6960 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6961 __attribute__((unused)) struct cmdline *cl,
6962 __attribute__((unused)) void *data)
6964 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6967 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6969 #ifdef RTE_LIBRTE_IXGBE_PMD
6970 if (ret == -ENOTSUP)
6971 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6972 res->vlan_id, res->vf_mask, is_add);
6974 #ifdef RTE_LIBRTE_I40E_PMD
6975 if (ret == -ENOTSUP)
6976 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6977 res->vlan_id, res->vf_mask, is_add);
6984 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6985 res->vlan_id, res->vf_mask);
6988 printf("invalid port_id %d\n", res->port_id);
6991 printf("function not implemented or supported\n");
6994 printf("programming error: (%s)\n", strerror(-ret));
6998 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6999 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7000 rx_vlan, "rx_vlan");
7001 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7002 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7004 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7005 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7007 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7008 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7010 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7011 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7013 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7014 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7016 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7017 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7020 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7021 .f = cmd_vf_rx_vlan_filter_parsed,
7023 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7024 "(vf_mask = hexadecimal VF mask)",
7026 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7027 (void *)&cmd_vf_rx_vlan_filter_what,
7028 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7029 (void *)&cmd_vf_rx_vlan_filter_port,
7030 (void *)&cmd_vf_rx_vlan_filter_portid,
7031 (void *)&cmd_vf_rx_vlan_filter_vf,
7032 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7037 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7038 struct cmd_queue_rate_limit_result {
7039 cmdline_fixed_string_t set;
7040 cmdline_fixed_string_t port;
7042 cmdline_fixed_string_t queue;
7044 cmdline_fixed_string_t rate;
7048 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7049 __attribute__((unused)) struct cmdline *cl,
7050 __attribute__((unused)) void *data)
7052 struct cmd_queue_rate_limit_result *res = parsed_result;
7055 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7056 && (strcmp(res->queue, "queue") == 0)
7057 && (strcmp(res->rate, "rate") == 0))
7058 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7061 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7065 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7066 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7068 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7069 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7071 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7072 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7074 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7075 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7077 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7078 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7080 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7081 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7083 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7084 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7087 cmdline_parse_inst_t cmd_queue_rate_limit = {
7088 .f = cmd_queue_rate_limit_parsed,
7090 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7091 "Set rate limit for a queue on port_id",
7093 (void *)&cmd_queue_rate_limit_set,
7094 (void *)&cmd_queue_rate_limit_port,
7095 (void *)&cmd_queue_rate_limit_portnum,
7096 (void *)&cmd_queue_rate_limit_queue,
7097 (void *)&cmd_queue_rate_limit_queuenum,
7098 (void *)&cmd_queue_rate_limit_rate,
7099 (void *)&cmd_queue_rate_limit_ratenum,
7104 #ifdef RTE_LIBRTE_IXGBE_PMD
7105 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7106 struct cmd_vf_rate_limit_result {
7107 cmdline_fixed_string_t set;
7108 cmdline_fixed_string_t port;
7110 cmdline_fixed_string_t vf;
7112 cmdline_fixed_string_t rate;
7114 cmdline_fixed_string_t q_msk;
7118 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7119 __attribute__((unused)) struct cmdline *cl,
7120 __attribute__((unused)) void *data)
7122 struct cmd_vf_rate_limit_result *res = parsed_result;
7125 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7126 && (strcmp(res->vf, "vf") == 0)
7127 && (strcmp(res->rate, "rate") == 0)
7128 && (strcmp(res->q_msk, "queue_mask") == 0))
7129 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7130 res->rate_num, res->q_msk_val);
7132 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7136 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7137 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7139 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7140 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7142 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7143 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7145 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7146 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7148 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7149 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7151 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7152 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7154 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7155 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7157 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7158 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7159 q_msk, "queue_mask");
7160 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7161 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7164 cmdline_parse_inst_t cmd_vf_rate_limit = {
7165 .f = cmd_vf_rate_limit_parsed,
7167 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7168 "queue_mask <queue_mask_value>: "
7169 "Set rate limit for queues of VF on port_id",
7171 (void *)&cmd_vf_rate_limit_set,
7172 (void *)&cmd_vf_rate_limit_port,
7173 (void *)&cmd_vf_rate_limit_portnum,
7174 (void *)&cmd_vf_rate_limit_vf,
7175 (void *)&cmd_vf_rate_limit_vfnum,
7176 (void *)&cmd_vf_rate_limit_rate,
7177 (void *)&cmd_vf_rate_limit_ratenum,
7178 (void *)&cmd_vf_rate_limit_q_msk,
7179 (void *)&cmd_vf_rate_limit_q_msk_val,
7185 /* *** ADD TUNNEL FILTER OF A PORT *** */
7186 struct cmd_tunnel_filter_result {
7187 cmdline_fixed_string_t cmd;
7188 cmdline_fixed_string_t what;
7190 struct ether_addr outer_mac;
7191 struct ether_addr inner_mac;
7192 cmdline_ipaddr_t ip_value;
7193 uint16_t inner_vlan;
7194 cmdline_fixed_string_t tunnel_type;
7195 cmdline_fixed_string_t filter_type;
7201 cmd_tunnel_filter_parsed(void *parsed_result,
7202 __attribute__((unused)) struct cmdline *cl,
7203 __attribute__((unused)) void *data)
7205 struct cmd_tunnel_filter_result *res = parsed_result;
7206 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7209 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7211 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7212 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7213 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7215 if (res->ip_value.family == AF_INET) {
7216 tunnel_filter_conf.ip_addr.ipv4_addr =
7217 res->ip_value.addr.ipv4.s_addr;
7218 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7220 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7221 &(res->ip_value.addr.ipv6),
7222 sizeof(struct in6_addr));
7223 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7226 if (!strcmp(res->filter_type, "imac-ivlan"))
7227 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7228 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7229 tunnel_filter_conf.filter_type =
7230 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7231 else if (!strcmp(res->filter_type, "imac-tenid"))
7232 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7233 else if (!strcmp(res->filter_type, "imac"))
7234 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7235 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7236 tunnel_filter_conf.filter_type =
7237 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7238 else if (!strcmp(res->filter_type, "oip"))
7239 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7240 else if (!strcmp(res->filter_type, "iip"))
7241 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7243 printf("The filter type is not supported");
7247 if (!strcmp(res->tunnel_type, "vxlan"))
7248 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7249 else if (!strcmp(res->tunnel_type, "nvgre"))
7250 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7251 else if (!strcmp(res->tunnel_type, "ipingre"))
7252 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7254 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7258 tunnel_filter_conf.tenant_id = res->tenant_id;
7259 tunnel_filter_conf.queue_id = res->queue_num;
7260 if (!strcmp(res->what, "add"))
7261 ret = rte_eth_dev_filter_ctrl(res->port_id,
7262 RTE_ETH_FILTER_TUNNEL,
7264 &tunnel_filter_conf);
7266 ret = rte_eth_dev_filter_ctrl(res->port_id,
7267 RTE_ETH_FILTER_TUNNEL,
7268 RTE_ETH_FILTER_DELETE,
7269 &tunnel_filter_conf);
7271 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7275 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7276 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7277 cmd, "tunnel_filter");
7278 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7279 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7281 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7282 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7284 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7285 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7287 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7288 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7290 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7291 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7292 inner_vlan, UINT16);
7293 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7294 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7296 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7297 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7298 tunnel_type, "vxlan#nvgre#ipingre");
7300 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7301 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7302 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7303 "imac#omac-imac-tenid");
7304 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7305 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7307 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7308 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7311 cmdline_parse_inst_t cmd_tunnel_filter = {
7312 .f = cmd_tunnel_filter_parsed,
7314 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7315 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7316 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7317 "<queue_id>: Add/Rm tunnel filter of a port",
7319 (void *)&cmd_tunnel_filter_cmd,
7320 (void *)&cmd_tunnel_filter_what,
7321 (void *)&cmd_tunnel_filter_port_id,
7322 (void *)&cmd_tunnel_filter_outer_mac,
7323 (void *)&cmd_tunnel_filter_inner_mac,
7324 (void *)&cmd_tunnel_filter_ip_value,
7325 (void *)&cmd_tunnel_filter_innner_vlan,
7326 (void *)&cmd_tunnel_filter_tunnel_type,
7327 (void *)&cmd_tunnel_filter_filter_type,
7328 (void *)&cmd_tunnel_filter_tenant_id,
7329 (void *)&cmd_tunnel_filter_queue_num,
7334 /* *** CONFIGURE TUNNEL UDP PORT *** */
7335 struct cmd_tunnel_udp_config {
7336 cmdline_fixed_string_t cmd;
7337 cmdline_fixed_string_t what;
7343 cmd_tunnel_udp_config_parsed(void *parsed_result,
7344 __attribute__((unused)) struct cmdline *cl,
7345 __attribute__((unused)) void *data)
7347 struct cmd_tunnel_udp_config *res = parsed_result;
7348 struct rte_eth_udp_tunnel tunnel_udp;
7351 tunnel_udp.udp_port = res->udp_port;
7353 if (!strcmp(res->cmd, "rx_vxlan_port"))
7354 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7356 if (!strcmp(res->what, "add"))
7357 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7360 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7364 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7367 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7368 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7369 cmd, "rx_vxlan_port");
7370 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7371 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7373 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7374 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7376 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7377 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7380 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7381 .f = cmd_tunnel_udp_config_parsed,
7383 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7384 "Add/Remove a tunneling UDP port filter",
7386 (void *)&cmd_tunnel_udp_config_cmd,
7387 (void *)&cmd_tunnel_udp_config_what,
7388 (void *)&cmd_tunnel_udp_config_udp_port,
7389 (void *)&cmd_tunnel_udp_config_port_id,
7394 /* *** GLOBAL CONFIG *** */
7395 struct cmd_global_config_result {
7396 cmdline_fixed_string_t cmd;
7398 cmdline_fixed_string_t cfg_type;
7403 cmd_global_config_parsed(void *parsed_result,
7404 __attribute__((unused)) struct cmdline *cl,
7405 __attribute__((unused)) void *data)
7407 struct cmd_global_config_result *res = parsed_result;
7408 struct rte_eth_global_cfg conf;
7411 memset(&conf, 0, sizeof(conf));
7412 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7413 conf.cfg.gre_key_len = res->len;
7414 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7415 RTE_ETH_FILTER_SET, &conf);
7417 printf("Global config error\n");
7420 cmdline_parse_token_string_t cmd_global_config_cmd =
7421 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7423 cmdline_parse_token_num_t cmd_global_config_port_id =
7424 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7425 cmdline_parse_token_string_t cmd_global_config_type =
7426 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7427 cfg_type, "gre-key-len");
7428 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7429 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7432 cmdline_parse_inst_t cmd_global_config = {
7433 .f = cmd_global_config_parsed,
7434 .data = (void *)NULL,
7435 .help_str = "global_config <port_id> gre-key-len <key_len>",
7437 (void *)&cmd_global_config_cmd,
7438 (void *)&cmd_global_config_port_id,
7439 (void *)&cmd_global_config_type,
7440 (void *)&cmd_global_config_gre_key_len,
7445 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7446 struct cmd_set_mirror_mask_result {
7447 cmdline_fixed_string_t set;
7448 cmdline_fixed_string_t port;
7450 cmdline_fixed_string_t mirror;
7452 cmdline_fixed_string_t what;
7453 cmdline_fixed_string_t value;
7454 cmdline_fixed_string_t dstpool;
7456 cmdline_fixed_string_t on;
7459 cmdline_parse_token_string_t cmd_mirror_mask_set =
7460 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7462 cmdline_parse_token_string_t cmd_mirror_mask_port =
7463 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7465 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7466 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7468 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7469 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7470 mirror, "mirror-rule");
7471 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7472 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7474 cmdline_parse_token_string_t cmd_mirror_mask_what =
7475 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7476 what, "pool-mirror-up#pool-mirror-down"
7478 cmdline_parse_token_string_t cmd_mirror_mask_value =
7479 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7481 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7482 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7483 dstpool, "dst-pool");
7484 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7485 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7487 cmdline_parse_token_string_t cmd_mirror_mask_on =
7488 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7492 cmd_set_mirror_mask_parsed(void *parsed_result,
7493 __attribute__((unused)) struct cmdline *cl,
7494 __attribute__((unused)) void *data)
7497 struct cmd_set_mirror_mask_result *res = parsed_result;
7498 struct rte_eth_mirror_conf mr_conf;
7500 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7502 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7504 mr_conf.dst_pool = res->dstpool_id;
7506 if (!strcmp(res->what, "pool-mirror-up")) {
7507 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7508 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7509 } else if (!strcmp(res->what, "pool-mirror-down")) {
7510 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7511 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7512 } else if (!strcmp(res->what, "vlan-mirror")) {
7513 mr_conf.rule_type = ETH_MIRROR_VLAN;
7514 nb_item = parse_item_list(res->value, "vlan",
7515 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7519 for (i = 0; i < nb_item; i++) {
7520 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7521 printf("Invalid vlan_id: must be < 4096\n");
7525 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7526 mr_conf.vlan.vlan_mask |= 1ULL << i;
7530 if (!strcmp(res->on, "on"))
7531 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7534 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7537 printf("mirror rule add error: (%s)\n", strerror(-ret));
7540 cmdline_parse_inst_t cmd_set_mirror_mask = {
7541 .f = cmd_set_mirror_mask_parsed,
7543 .help_str = "set port <port_id> mirror-rule <rule_id> "
7544 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7545 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7547 (void *)&cmd_mirror_mask_set,
7548 (void *)&cmd_mirror_mask_port,
7549 (void *)&cmd_mirror_mask_portid,
7550 (void *)&cmd_mirror_mask_mirror,
7551 (void *)&cmd_mirror_mask_ruleid,
7552 (void *)&cmd_mirror_mask_what,
7553 (void *)&cmd_mirror_mask_value,
7554 (void *)&cmd_mirror_mask_dstpool,
7555 (void *)&cmd_mirror_mask_poolid,
7556 (void *)&cmd_mirror_mask_on,
7561 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7562 struct cmd_set_mirror_link_result {
7563 cmdline_fixed_string_t set;
7564 cmdline_fixed_string_t port;
7566 cmdline_fixed_string_t mirror;
7568 cmdline_fixed_string_t what;
7569 cmdline_fixed_string_t dstpool;
7571 cmdline_fixed_string_t on;
7574 cmdline_parse_token_string_t cmd_mirror_link_set =
7575 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7577 cmdline_parse_token_string_t cmd_mirror_link_port =
7578 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7580 cmdline_parse_token_num_t cmd_mirror_link_portid =
7581 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7583 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7584 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7585 mirror, "mirror-rule");
7586 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7587 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7589 cmdline_parse_token_string_t cmd_mirror_link_what =
7590 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7591 what, "uplink-mirror#downlink-mirror");
7592 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7593 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7594 dstpool, "dst-pool");
7595 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7596 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7598 cmdline_parse_token_string_t cmd_mirror_link_on =
7599 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7603 cmd_set_mirror_link_parsed(void *parsed_result,
7604 __attribute__((unused)) struct cmdline *cl,
7605 __attribute__((unused)) void *data)
7608 struct cmd_set_mirror_link_result *res = parsed_result;
7609 struct rte_eth_mirror_conf mr_conf;
7611 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7612 if (!strcmp(res->what, "uplink-mirror"))
7613 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7615 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7617 mr_conf.dst_pool = res->dstpool_id;
7619 if (!strcmp(res->on, "on"))
7620 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7623 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7626 /* check the return value and print it if is < 0 */
7628 printf("mirror rule add error: (%s)\n", strerror(-ret));
7632 cmdline_parse_inst_t cmd_set_mirror_link = {
7633 .f = cmd_set_mirror_link_parsed,
7635 .help_str = "set port <port_id> mirror-rule <rule_id> "
7636 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7638 (void *)&cmd_mirror_link_set,
7639 (void *)&cmd_mirror_link_port,
7640 (void *)&cmd_mirror_link_portid,
7641 (void *)&cmd_mirror_link_mirror,
7642 (void *)&cmd_mirror_link_ruleid,
7643 (void *)&cmd_mirror_link_what,
7644 (void *)&cmd_mirror_link_dstpool,
7645 (void *)&cmd_mirror_link_poolid,
7646 (void *)&cmd_mirror_link_on,
7651 /* *** RESET VM MIRROR RULE *** */
7652 struct cmd_rm_mirror_rule_result {
7653 cmdline_fixed_string_t reset;
7654 cmdline_fixed_string_t port;
7656 cmdline_fixed_string_t mirror;
7660 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7661 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7663 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7664 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7666 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7667 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7669 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7670 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7671 mirror, "mirror-rule");
7672 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7673 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7677 cmd_reset_mirror_rule_parsed(void *parsed_result,
7678 __attribute__((unused)) struct cmdline *cl,
7679 __attribute__((unused)) void *data)
7682 struct cmd_set_mirror_link_result *res = parsed_result;
7684 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7686 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7689 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7690 .f = cmd_reset_mirror_rule_parsed,
7692 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7694 (void *)&cmd_rm_mirror_rule_reset,
7695 (void *)&cmd_rm_mirror_rule_port,
7696 (void *)&cmd_rm_mirror_rule_portid,
7697 (void *)&cmd_rm_mirror_rule_mirror,
7698 (void *)&cmd_rm_mirror_rule_ruleid,
7703 /* ******************************************************************************** */
7705 struct cmd_dump_result {
7706 cmdline_fixed_string_t dump;
7710 dump_struct_sizes(void)
7712 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7713 DUMP_SIZE(struct rte_mbuf);
7714 DUMP_SIZE(struct rte_mempool);
7715 DUMP_SIZE(struct rte_ring);
7719 static void cmd_dump_parsed(void *parsed_result,
7720 __attribute__((unused)) struct cmdline *cl,
7721 __attribute__((unused)) void *data)
7723 struct cmd_dump_result *res = parsed_result;
7725 if (!strcmp(res->dump, "dump_physmem"))
7726 rte_dump_physmem_layout(stdout);
7727 else if (!strcmp(res->dump, "dump_memzone"))
7728 rte_memzone_dump(stdout);
7729 else if (!strcmp(res->dump, "dump_struct_sizes"))
7730 dump_struct_sizes();
7731 else if (!strcmp(res->dump, "dump_ring"))
7732 rte_ring_list_dump(stdout);
7733 else if (!strcmp(res->dump, "dump_mempool"))
7734 rte_mempool_list_dump(stdout);
7735 else if (!strcmp(res->dump, "dump_devargs"))
7736 rte_eal_devargs_dump(stdout);
7737 else if (!strcmp(res->dump, "dump_log_types"))
7738 rte_log_dump(stdout);
7741 cmdline_parse_token_string_t cmd_dump_dump =
7742 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7745 "dump_struct_sizes#"
7751 cmdline_parse_inst_t cmd_dump = {
7752 .f = cmd_dump_parsed, /* function to call */
7753 .data = NULL, /* 2nd arg of func */
7754 .help_str = "Dump status",
7755 .tokens = { /* token list, NULL terminated */
7756 (void *)&cmd_dump_dump,
7761 /* ******************************************************************************** */
7763 struct cmd_dump_one_result {
7764 cmdline_fixed_string_t dump;
7765 cmdline_fixed_string_t name;
7768 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7769 __attribute__((unused)) void *data)
7771 struct cmd_dump_one_result *res = parsed_result;
7773 if (!strcmp(res->dump, "dump_ring")) {
7775 r = rte_ring_lookup(res->name);
7777 cmdline_printf(cl, "Cannot find ring\n");
7780 rte_ring_dump(stdout, r);
7781 } else if (!strcmp(res->dump, "dump_mempool")) {
7782 struct rte_mempool *mp;
7783 mp = rte_mempool_lookup(res->name);
7785 cmdline_printf(cl, "Cannot find mempool\n");
7788 rte_mempool_dump(stdout, mp);
7792 cmdline_parse_token_string_t cmd_dump_one_dump =
7793 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7794 "dump_ring#dump_mempool");
7796 cmdline_parse_token_string_t cmd_dump_one_name =
7797 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7799 cmdline_parse_inst_t cmd_dump_one = {
7800 .f = cmd_dump_one_parsed, /* function to call */
7801 .data = NULL, /* 2nd arg of func */
7802 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7803 .tokens = { /* token list, NULL terminated */
7804 (void *)&cmd_dump_one_dump,
7805 (void *)&cmd_dump_one_name,
7810 /* *** Add/Del syn filter *** */
7811 struct cmd_syn_filter_result {
7812 cmdline_fixed_string_t filter;
7814 cmdline_fixed_string_t ops;
7815 cmdline_fixed_string_t priority;
7816 cmdline_fixed_string_t high;
7817 cmdline_fixed_string_t queue;
7822 cmd_syn_filter_parsed(void *parsed_result,
7823 __attribute__((unused)) struct cmdline *cl,
7824 __attribute__((unused)) void *data)
7826 struct cmd_syn_filter_result *res = parsed_result;
7827 struct rte_eth_syn_filter syn_filter;
7830 ret = rte_eth_dev_filter_supported(res->port_id,
7831 RTE_ETH_FILTER_SYN);
7833 printf("syn filter is not supported on port %u.\n",
7838 memset(&syn_filter, 0, sizeof(syn_filter));
7840 if (!strcmp(res->ops, "add")) {
7841 if (!strcmp(res->high, "high"))
7842 syn_filter.hig_pri = 1;
7844 syn_filter.hig_pri = 0;
7846 syn_filter.queue = res->queue_id;
7847 ret = rte_eth_dev_filter_ctrl(res->port_id,
7852 ret = rte_eth_dev_filter_ctrl(res->port_id,
7854 RTE_ETH_FILTER_DELETE,
7858 printf("syn filter programming error: (%s)\n",
7862 cmdline_parse_token_string_t cmd_syn_filter_filter =
7863 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7864 filter, "syn_filter");
7865 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7866 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7868 cmdline_parse_token_string_t cmd_syn_filter_ops =
7869 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7871 cmdline_parse_token_string_t cmd_syn_filter_priority =
7872 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7873 priority, "priority");
7874 cmdline_parse_token_string_t cmd_syn_filter_high =
7875 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7877 cmdline_parse_token_string_t cmd_syn_filter_queue =
7878 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7880 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7881 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7884 cmdline_parse_inst_t cmd_syn_filter = {
7885 .f = cmd_syn_filter_parsed,
7887 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7888 "<queue_id>: Add/Delete syn filter",
7890 (void *)&cmd_syn_filter_filter,
7891 (void *)&cmd_syn_filter_port_id,
7892 (void *)&cmd_syn_filter_ops,
7893 (void *)&cmd_syn_filter_priority,
7894 (void *)&cmd_syn_filter_high,
7895 (void *)&cmd_syn_filter_queue,
7896 (void *)&cmd_syn_filter_queue_id,
7901 /* *** ADD/REMOVE A 2tuple FILTER *** */
7902 struct cmd_2tuple_filter_result {
7903 cmdline_fixed_string_t filter;
7905 cmdline_fixed_string_t ops;
7906 cmdline_fixed_string_t dst_port;
7907 uint16_t dst_port_value;
7908 cmdline_fixed_string_t protocol;
7909 uint8_t protocol_value;
7910 cmdline_fixed_string_t mask;
7912 cmdline_fixed_string_t tcp_flags;
7913 uint8_t tcp_flags_value;
7914 cmdline_fixed_string_t priority;
7915 uint8_t priority_value;
7916 cmdline_fixed_string_t queue;
7921 cmd_2tuple_filter_parsed(void *parsed_result,
7922 __attribute__((unused)) struct cmdline *cl,
7923 __attribute__((unused)) void *data)
7925 struct rte_eth_ntuple_filter filter;
7926 struct cmd_2tuple_filter_result *res = parsed_result;
7929 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7931 printf("ntuple filter is not supported on port %u.\n",
7936 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7938 filter.flags = RTE_2TUPLE_FLAGS;
7939 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7940 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7941 filter.proto = res->protocol_value;
7942 filter.priority = res->priority_value;
7943 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7944 printf("nonzero tcp_flags is only meaningful"
7945 " when protocol is TCP.\n");
7948 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7949 printf("invalid TCP flags.\n");
7953 if (res->tcp_flags_value != 0) {
7954 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7955 filter.tcp_flags = res->tcp_flags_value;
7958 /* need convert to big endian. */
7959 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7960 filter.queue = res->queue_id;
7962 if (!strcmp(res->ops, "add"))
7963 ret = rte_eth_dev_filter_ctrl(res->port_id,
7964 RTE_ETH_FILTER_NTUPLE,
7968 ret = rte_eth_dev_filter_ctrl(res->port_id,
7969 RTE_ETH_FILTER_NTUPLE,
7970 RTE_ETH_FILTER_DELETE,
7973 printf("2tuple filter programming error: (%s)\n",
7978 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7979 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7980 filter, "2tuple_filter");
7981 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7982 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7984 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7985 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7987 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7988 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7989 dst_port, "dst_port");
7990 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7991 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7992 dst_port_value, UINT16);
7993 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7994 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7995 protocol, "protocol");
7996 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7997 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7998 protocol_value, UINT8);
7999 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8000 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8002 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8003 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8005 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8006 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8007 tcp_flags, "tcp_flags");
8008 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8009 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8010 tcp_flags_value, UINT8);
8011 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8012 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8013 priority, "priority");
8014 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8015 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8016 priority_value, UINT8);
8017 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8018 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8020 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8021 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8024 cmdline_parse_inst_t cmd_2tuple_filter = {
8025 .f = cmd_2tuple_filter_parsed,
8027 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8028 "<value> mask <value> tcp_flags <value> priority <value> queue "
8029 "<queue_id>: Add a 2tuple filter",
8031 (void *)&cmd_2tuple_filter_filter,
8032 (void *)&cmd_2tuple_filter_port_id,
8033 (void *)&cmd_2tuple_filter_ops,
8034 (void *)&cmd_2tuple_filter_dst_port,
8035 (void *)&cmd_2tuple_filter_dst_port_value,
8036 (void *)&cmd_2tuple_filter_protocol,
8037 (void *)&cmd_2tuple_filter_protocol_value,
8038 (void *)&cmd_2tuple_filter_mask,
8039 (void *)&cmd_2tuple_filter_mask_value,
8040 (void *)&cmd_2tuple_filter_tcp_flags,
8041 (void *)&cmd_2tuple_filter_tcp_flags_value,
8042 (void *)&cmd_2tuple_filter_priority,
8043 (void *)&cmd_2tuple_filter_priority_value,
8044 (void *)&cmd_2tuple_filter_queue,
8045 (void *)&cmd_2tuple_filter_queue_id,
8050 /* *** ADD/REMOVE A 5tuple FILTER *** */
8051 struct cmd_5tuple_filter_result {
8052 cmdline_fixed_string_t filter;
8054 cmdline_fixed_string_t ops;
8055 cmdline_fixed_string_t dst_ip;
8056 cmdline_ipaddr_t dst_ip_value;
8057 cmdline_fixed_string_t src_ip;
8058 cmdline_ipaddr_t src_ip_value;
8059 cmdline_fixed_string_t dst_port;
8060 uint16_t dst_port_value;
8061 cmdline_fixed_string_t src_port;
8062 uint16_t src_port_value;
8063 cmdline_fixed_string_t protocol;
8064 uint8_t protocol_value;
8065 cmdline_fixed_string_t mask;
8067 cmdline_fixed_string_t tcp_flags;
8068 uint8_t tcp_flags_value;
8069 cmdline_fixed_string_t priority;
8070 uint8_t priority_value;
8071 cmdline_fixed_string_t queue;
8076 cmd_5tuple_filter_parsed(void *parsed_result,
8077 __attribute__((unused)) struct cmdline *cl,
8078 __attribute__((unused)) void *data)
8080 struct rte_eth_ntuple_filter filter;
8081 struct cmd_5tuple_filter_result *res = parsed_result;
8084 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8086 printf("ntuple filter is not supported on port %u.\n",
8091 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8093 filter.flags = RTE_5TUPLE_FLAGS;
8094 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8095 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8096 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8097 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8098 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8099 filter.proto = res->protocol_value;
8100 filter.priority = res->priority_value;
8101 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8102 printf("nonzero tcp_flags is only meaningful"
8103 " when protocol is TCP.\n");
8106 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8107 printf("invalid TCP flags.\n");
8111 if (res->tcp_flags_value != 0) {
8112 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8113 filter.tcp_flags = res->tcp_flags_value;
8116 if (res->dst_ip_value.family == AF_INET)
8117 /* no need to convert, already big endian. */
8118 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8120 if (filter.dst_ip_mask == 0) {
8121 printf("can not support ipv6 involved compare.\n");
8127 if (res->src_ip_value.family == AF_INET)
8128 /* no need to convert, already big endian. */
8129 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8131 if (filter.src_ip_mask == 0) {
8132 printf("can not support ipv6 involved compare.\n");
8137 /* need convert to big endian. */
8138 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8139 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8140 filter.queue = res->queue_id;
8142 if (!strcmp(res->ops, "add"))
8143 ret = rte_eth_dev_filter_ctrl(res->port_id,
8144 RTE_ETH_FILTER_NTUPLE,
8148 ret = rte_eth_dev_filter_ctrl(res->port_id,
8149 RTE_ETH_FILTER_NTUPLE,
8150 RTE_ETH_FILTER_DELETE,
8153 printf("5tuple filter programming error: (%s)\n",
8157 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8158 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8159 filter, "5tuple_filter");
8160 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8161 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8163 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8164 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8166 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8167 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8169 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8170 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8172 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8173 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8175 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8176 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8178 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8179 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8180 dst_port, "dst_port");
8181 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8182 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8183 dst_port_value, UINT16);
8184 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8185 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8186 src_port, "src_port");
8187 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8188 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8189 src_port_value, UINT16);
8190 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8191 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8192 protocol, "protocol");
8193 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8194 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8195 protocol_value, UINT8);
8196 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8197 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8199 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8200 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8202 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8203 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8204 tcp_flags, "tcp_flags");
8205 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8206 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8207 tcp_flags_value, UINT8);
8208 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8209 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8210 priority, "priority");
8211 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8212 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8213 priority_value, UINT8);
8214 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8215 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8217 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8218 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8221 cmdline_parse_inst_t cmd_5tuple_filter = {
8222 .f = cmd_5tuple_filter_parsed,
8224 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8225 "src_ip <value> dst_port <value> src_port <value> "
8226 "protocol <value> mask <value> tcp_flags <value> "
8227 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8229 (void *)&cmd_5tuple_filter_filter,
8230 (void *)&cmd_5tuple_filter_port_id,
8231 (void *)&cmd_5tuple_filter_ops,
8232 (void *)&cmd_5tuple_filter_dst_ip,
8233 (void *)&cmd_5tuple_filter_dst_ip_value,
8234 (void *)&cmd_5tuple_filter_src_ip,
8235 (void *)&cmd_5tuple_filter_src_ip_value,
8236 (void *)&cmd_5tuple_filter_dst_port,
8237 (void *)&cmd_5tuple_filter_dst_port_value,
8238 (void *)&cmd_5tuple_filter_src_port,
8239 (void *)&cmd_5tuple_filter_src_port_value,
8240 (void *)&cmd_5tuple_filter_protocol,
8241 (void *)&cmd_5tuple_filter_protocol_value,
8242 (void *)&cmd_5tuple_filter_mask,
8243 (void *)&cmd_5tuple_filter_mask_value,
8244 (void *)&cmd_5tuple_filter_tcp_flags,
8245 (void *)&cmd_5tuple_filter_tcp_flags_value,
8246 (void *)&cmd_5tuple_filter_priority,
8247 (void *)&cmd_5tuple_filter_priority_value,
8248 (void *)&cmd_5tuple_filter_queue,
8249 (void *)&cmd_5tuple_filter_queue_id,
8254 /* *** ADD/REMOVE A flex FILTER *** */
8255 struct cmd_flex_filter_result {
8256 cmdline_fixed_string_t filter;
8257 cmdline_fixed_string_t ops;
8259 cmdline_fixed_string_t len;
8261 cmdline_fixed_string_t bytes;
8262 cmdline_fixed_string_t bytes_value;
8263 cmdline_fixed_string_t mask;
8264 cmdline_fixed_string_t mask_value;
8265 cmdline_fixed_string_t priority;
8266 uint8_t priority_value;
8267 cmdline_fixed_string_t queue;
8271 static int xdigit2val(unsigned char c)
8276 else if (isupper(c))
8284 cmd_flex_filter_parsed(void *parsed_result,
8285 __attribute__((unused)) struct cmdline *cl,
8286 __attribute__((unused)) void *data)
8289 struct rte_eth_flex_filter filter;
8290 struct cmd_flex_filter_result *res = parsed_result;
8291 char *bytes_ptr, *mask_ptr;
8292 uint16_t len, i, j = 0;
8297 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8298 printf("the len exceed the max length 128\n");
8301 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8302 filter.len = res->len_value;
8303 filter.priority = res->priority_value;
8304 filter.queue = res->queue_id;
8305 bytes_ptr = res->bytes_value;
8306 mask_ptr = res->mask_value;
8308 /* translate bytes string to array. */
8309 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8310 (bytes_ptr[1] == 'X')))
8312 len = strnlen(bytes_ptr, res->len_value * 2);
8313 if (len == 0 || (len % 8 != 0)) {
8314 printf("please check len and bytes input\n");
8317 for (i = 0; i < len; i++) {
8319 if (isxdigit(c) == 0) {
8320 /* invalid characters. */
8321 printf("invalid input\n");
8324 val = xdigit2val(c);
8327 filter.bytes[j] = byte;
8328 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8335 /* translate mask string to uint8_t array. */
8336 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8337 (mask_ptr[1] == 'X')))
8339 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8341 printf("invalid input\n");
8346 for (i = 0; i < len; i++) {
8348 if (isxdigit(c) == 0) {
8349 /* invalid characters. */
8350 printf("invalid input\n");
8353 val = xdigit2val(c);
8356 filter.mask[j] = byte;
8357 printf("mask[%d]:%02x ", j, filter.mask[j]);
8365 if (!strcmp(res->ops, "add"))
8366 ret = rte_eth_dev_filter_ctrl(res->port_id,
8367 RTE_ETH_FILTER_FLEXIBLE,
8371 ret = rte_eth_dev_filter_ctrl(res->port_id,
8372 RTE_ETH_FILTER_FLEXIBLE,
8373 RTE_ETH_FILTER_DELETE,
8377 printf("flex filter setting error: (%s)\n", strerror(-ret));
8380 cmdline_parse_token_string_t cmd_flex_filter_filter =
8381 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8382 filter, "flex_filter");
8383 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8384 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8386 cmdline_parse_token_string_t cmd_flex_filter_ops =
8387 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8389 cmdline_parse_token_string_t cmd_flex_filter_len =
8390 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8392 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8393 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8395 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8396 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8398 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8399 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8401 cmdline_parse_token_string_t cmd_flex_filter_mask =
8402 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8404 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8405 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8407 cmdline_parse_token_string_t cmd_flex_filter_priority =
8408 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8409 priority, "priority");
8410 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8411 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8412 priority_value, UINT8);
8413 cmdline_parse_token_string_t cmd_flex_filter_queue =
8414 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8416 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8417 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8419 cmdline_parse_inst_t cmd_flex_filter = {
8420 .f = cmd_flex_filter_parsed,
8422 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8423 "<value> mask <value> priority <value> queue <queue_id>: "
8424 "Add/Del a flex filter",
8426 (void *)&cmd_flex_filter_filter,
8427 (void *)&cmd_flex_filter_port_id,
8428 (void *)&cmd_flex_filter_ops,
8429 (void *)&cmd_flex_filter_len,
8430 (void *)&cmd_flex_filter_len_value,
8431 (void *)&cmd_flex_filter_bytes,
8432 (void *)&cmd_flex_filter_bytes_value,
8433 (void *)&cmd_flex_filter_mask,
8434 (void *)&cmd_flex_filter_mask_value,
8435 (void *)&cmd_flex_filter_priority,
8436 (void *)&cmd_flex_filter_priority_value,
8437 (void *)&cmd_flex_filter_queue,
8438 (void *)&cmd_flex_filter_queue_id,
8443 /* *** Filters Control *** */
8445 /* *** deal with ethertype filter *** */
8446 struct cmd_ethertype_filter_result {
8447 cmdline_fixed_string_t filter;
8449 cmdline_fixed_string_t ops;
8450 cmdline_fixed_string_t mac;
8451 struct ether_addr mac_addr;
8452 cmdline_fixed_string_t ethertype;
8453 uint16_t ethertype_value;
8454 cmdline_fixed_string_t drop;
8455 cmdline_fixed_string_t queue;
8459 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8460 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8461 filter, "ethertype_filter");
8462 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8463 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8465 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8466 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8468 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8469 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8470 mac, "mac_addr#mac_ignr");
8471 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8472 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8474 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8475 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8476 ethertype, "ethertype");
8477 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8478 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8479 ethertype_value, UINT16);
8480 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8481 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8483 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8484 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8486 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8487 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8491 cmd_ethertype_filter_parsed(void *parsed_result,
8492 __attribute__((unused)) struct cmdline *cl,
8493 __attribute__((unused)) void *data)
8495 struct cmd_ethertype_filter_result *res = parsed_result;
8496 struct rte_eth_ethertype_filter filter;
8499 ret = rte_eth_dev_filter_supported(res->port_id,
8500 RTE_ETH_FILTER_ETHERTYPE);
8502 printf("ethertype filter is not supported on port %u.\n",
8507 memset(&filter, 0, sizeof(filter));
8508 if (!strcmp(res->mac, "mac_addr")) {
8509 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8510 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8511 sizeof(struct ether_addr));
8513 if (!strcmp(res->drop, "drop"))
8514 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8515 filter.ether_type = res->ethertype_value;
8516 filter.queue = res->queue_id;
8518 if (!strcmp(res->ops, "add"))
8519 ret = rte_eth_dev_filter_ctrl(res->port_id,
8520 RTE_ETH_FILTER_ETHERTYPE,
8524 ret = rte_eth_dev_filter_ctrl(res->port_id,
8525 RTE_ETH_FILTER_ETHERTYPE,
8526 RTE_ETH_FILTER_DELETE,
8529 printf("ethertype filter programming error: (%s)\n",
8533 cmdline_parse_inst_t cmd_ethertype_filter = {
8534 .f = cmd_ethertype_filter_parsed,
8536 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8537 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8538 "Add or delete an ethertype filter entry",
8540 (void *)&cmd_ethertype_filter_filter,
8541 (void *)&cmd_ethertype_filter_port_id,
8542 (void *)&cmd_ethertype_filter_ops,
8543 (void *)&cmd_ethertype_filter_mac,
8544 (void *)&cmd_ethertype_filter_mac_addr,
8545 (void *)&cmd_ethertype_filter_ethertype,
8546 (void *)&cmd_ethertype_filter_ethertype_value,
8547 (void *)&cmd_ethertype_filter_drop,
8548 (void *)&cmd_ethertype_filter_queue,
8549 (void *)&cmd_ethertype_filter_queue_id,
8554 /* *** deal with flow director filter *** */
8555 struct cmd_flow_director_result {
8556 cmdline_fixed_string_t flow_director_filter;
8558 cmdline_fixed_string_t mode;
8559 cmdline_fixed_string_t mode_value;
8560 cmdline_fixed_string_t ops;
8561 cmdline_fixed_string_t flow;
8562 cmdline_fixed_string_t flow_type;
8563 cmdline_fixed_string_t ether;
8564 uint16_t ether_type;
8565 cmdline_fixed_string_t src;
8566 cmdline_ipaddr_t ip_src;
8568 cmdline_fixed_string_t dst;
8569 cmdline_ipaddr_t ip_dst;
8571 cmdline_fixed_string_t verify_tag;
8572 uint32_t verify_tag_value;
8573 cmdline_ipaddr_t tos;
8575 cmdline_ipaddr_t proto;
8576 uint8_t proto_value;
8577 cmdline_ipaddr_t ttl;
8579 cmdline_fixed_string_t vlan;
8580 uint16_t vlan_value;
8581 cmdline_fixed_string_t flexbytes;
8582 cmdline_fixed_string_t flexbytes_value;
8583 cmdline_fixed_string_t pf_vf;
8584 cmdline_fixed_string_t drop;
8585 cmdline_fixed_string_t queue;
8587 cmdline_fixed_string_t fd_id;
8588 uint32_t fd_id_value;
8589 cmdline_fixed_string_t mac;
8590 struct ether_addr mac_addr;
8591 cmdline_fixed_string_t tunnel;
8592 cmdline_fixed_string_t tunnel_type;
8593 cmdline_fixed_string_t tunnel_id;
8594 uint32_t tunnel_id_value;
8598 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8601 const char *p, *p0 = q_arg;
8603 unsigned long int_fld;
8604 char *str_fld[max_num];
8609 p = strchr(p0, '(');
8613 p0 = strchr(p, ')');
8618 if (size >= sizeof(s))
8621 snprintf(s, sizeof(s), "%.*s", size, p);
8622 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8623 if (ret < 0 || ret > max_num)
8625 for (i = 0; i < ret; i++) {
8627 int_fld = strtoul(str_fld[i], &end, 0);
8628 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8630 flexbytes[i] = (uint8_t)int_fld;
8636 str2flowtype(char *string)
8639 static const struct {
8642 } flowtype_str[] = {
8643 {"raw", RTE_ETH_FLOW_RAW},
8644 {"ipv4", RTE_ETH_FLOW_IPV4},
8645 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8646 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8647 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8648 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8649 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8650 {"ipv6", RTE_ETH_FLOW_IPV6},
8651 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8652 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8653 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8654 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8655 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8656 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8659 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8660 if (!strcmp(flowtype_str[i].str, string))
8661 return flowtype_str[i].type;
8663 return RTE_ETH_FLOW_UNKNOWN;
8666 static enum rte_eth_fdir_tunnel_type
8667 str2fdir_tunneltype(char *string)
8671 static const struct {
8673 enum rte_eth_fdir_tunnel_type type;
8674 } tunneltype_str[] = {
8675 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8676 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8679 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8680 if (!strcmp(tunneltype_str[i].str, string))
8681 return tunneltype_str[i].type;
8683 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8686 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8688 if ((ip_addr).family == AF_INET) \
8689 (ip) = (ip_addr).addr.ipv4.s_addr; \
8691 printf("invalid parameter.\n"); \
8696 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8698 if ((ip_addr).family == AF_INET6) \
8699 (void)rte_memcpy(&(ip), \
8700 &((ip_addr).addr.ipv6), \
8701 sizeof(struct in6_addr)); \
8703 printf("invalid parameter.\n"); \
8709 cmd_flow_director_filter_parsed(void *parsed_result,
8710 __attribute__((unused)) struct cmdline *cl,
8711 __attribute__((unused)) void *data)
8713 struct cmd_flow_director_result *res = parsed_result;
8714 struct rte_eth_fdir_filter entry;
8715 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8717 unsigned long vf_id;
8720 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8722 printf("flow director is not supported on port %u.\n",
8726 memset(flexbytes, 0, sizeof(flexbytes));
8727 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8729 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8730 if (strcmp(res->mode_value, "MAC-VLAN")) {
8731 printf("Please set mode to MAC-VLAN.\n");
8734 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8735 if (strcmp(res->mode_value, "Tunnel")) {
8736 printf("Please set mode to Tunnel.\n");
8740 if (strcmp(res->mode_value, "IP")) {
8741 printf("Please set mode to IP.\n");
8744 entry.input.flow_type = str2flowtype(res->flow_type);
8747 ret = parse_flexbytes(res->flexbytes_value,
8749 RTE_ETH_FDIR_MAX_FLEXLEN);
8751 printf("error: Cannot parse flexbytes input.\n");
8755 switch (entry.input.flow_type) {
8756 case RTE_ETH_FLOW_FRAG_IPV4:
8757 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8758 entry.input.flow.ip4_flow.proto = res->proto_value;
8760 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8761 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8762 IPV4_ADDR_TO_UINT(res->ip_dst,
8763 entry.input.flow.ip4_flow.dst_ip);
8764 IPV4_ADDR_TO_UINT(res->ip_src,
8765 entry.input.flow.ip4_flow.src_ip);
8766 entry.input.flow.ip4_flow.tos = res->tos_value;
8767 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8768 /* need convert to big endian. */
8769 entry.input.flow.udp4_flow.dst_port =
8770 rte_cpu_to_be_16(res->port_dst);
8771 entry.input.flow.udp4_flow.src_port =
8772 rte_cpu_to_be_16(res->port_src);
8774 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8775 IPV4_ADDR_TO_UINT(res->ip_dst,
8776 entry.input.flow.sctp4_flow.ip.dst_ip);
8777 IPV4_ADDR_TO_UINT(res->ip_src,
8778 entry.input.flow.sctp4_flow.ip.src_ip);
8779 entry.input.flow.ip4_flow.tos = res->tos_value;
8780 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8781 /* need convert to big endian. */
8782 entry.input.flow.sctp4_flow.dst_port =
8783 rte_cpu_to_be_16(res->port_dst);
8784 entry.input.flow.sctp4_flow.src_port =
8785 rte_cpu_to_be_16(res->port_src);
8786 entry.input.flow.sctp4_flow.verify_tag =
8787 rte_cpu_to_be_32(res->verify_tag_value);
8789 case RTE_ETH_FLOW_FRAG_IPV6:
8790 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8791 entry.input.flow.ipv6_flow.proto = res->proto_value;
8793 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8794 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8795 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8796 entry.input.flow.ipv6_flow.dst_ip);
8797 IPV6_ADDR_TO_ARRAY(res->ip_src,
8798 entry.input.flow.ipv6_flow.src_ip);
8799 entry.input.flow.ipv6_flow.tc = res->tos_value;
8800 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8801 /* need convert to big endian. */
8802 entry.input.flow.udp6_flow.dst_port =
8803 rte_cpu_to_be_16(res->port_dst);
8804 entry.input.flow.udp6_flow.src_port =
8805 rte_cpu_to_be_16(res->port_src);
8807 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8808 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8809 entry.input.flow.sctp6_flow.ip.dst_ip);
8810 IPV6_ADDR_TO_ARRAY(res->ip_src,
8811 entry.input.flow.sctp6_flow.ip.src_ip);
8812 entry.input.flow.ipv6_flow.tc = res->tos_value;
8813 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8814 /* need convert to big endian. */
8815 entry.input.flow.sctp6_flow.dst_port =
8816 rte_cpu_to_be_16(res->port_dst);
8817 entry.input.flow.sctp6_flow.src_port =
8818 rte_cpu_to_be_16(res->port_src);
8819 entry.input.flow.sctp6_flow.verify_tag =
8820 rte_cpu_to_be_32(res->verify_tag_value);
8822 case RTE_ETH_FLOW_L2_PAYLOAD:
8823 entry.input.flow.l2_flow.ether_type =
8824 rte_cpu_to_be_16(res->ether_type);
8830 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8831 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8833 sizeof(struct ether_addr));
8835 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8836 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8838 sizeof(struct ether_addr));
8839 entry.input.flow.tunnel_flow.tunnel_type =
8840 str2fdir_tunneltype(res->tunnel_type);
8841 entry.input.flow.tunnel_flow.tunnel_id =
8842 rte_cpu_to_be_32(res->tunnel_id_value);
8845 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8847 RTE_ETH_FDIR_MAX_FLEXLEN);
8849 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8851 entry.action.flex_off = 0; /*use 0 by default */
8852 if (!strcmp(res->drop, "drop"))
8853 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8855 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8857 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8858 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8859 if (!strcmp(res->pf_vf, "pf"))
8860 entry.input.flow_ext.is_vf = 0;
8861 else if (!strncmp(res->pf_vf, "vf", 2)) {
8862 struct rte_eth_dev_info dev_info;
8864 memset(&dev_info, 0, sizeof(dev_info));
8865 rte_eth_dev_info_get(res->port_id, &dev_info);
8867 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8868 if (errno != 0 || *end != '\0' ||
8869 vf_id >= dev_info.max_vfs) {
8870 printf("invalid parameter %s.\n", res->pf_vf);
8873 entry.input.flow_ext.is_vf = 1;
8874 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8876 printf("invalid parameter %s.\n", res->pf_vf);
8881 /* set to report FD ID by default */
8882 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8883 entry.action.rx_queue = res->queue_id;
8884 entry.soft_id = res->fd_id_value;
8885 if (!strcmp(res->ops, "add"))
8886 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8887 RTE_ETH_FILTER_ADD, &entry);
8888 else if (!strcmp(res->ops, "del"))
8889 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8890 RTE_ETH_FILTER_DELETE, &entry);
8892 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8893 RTE_ETH_FILTER_UPDATE, &entry);
8895 printf("flow director programming error: (%s)\n",
8899 cmdline_parse_token_string_t cmd_flow_director_filter =
8900 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8901 flow_director_filter, "flow_director_filter");
8902 cmdline_parse_token_num_t cmd_flow_director_port_id =
8903 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8905 cmdline_parse_token_string_t cmd_flow_director_ops =
8906 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8907 ops, "add#del#update");
8908 cmdline_parse_token_string_t cmd_flow_director_flow =
8909 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8911 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8912 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8913 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8914 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8915 cmdline_parse_token_string_t cmd_flow_director_ether =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8918 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8919 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8920 ether_type, UINT16);
8921 cmdline_parse_token_string_t cmd_flow_director_src =
8922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8924 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8925 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8927 cmdline_parse_token_num_t cmd_flow_director_port_src =
8928 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8930 cmdline_parse_token_string_t cmd_flow_director_dst =
8931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8933 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8934 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8936 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8937 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8939 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8940 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8941 verify_tag, "verify_tag");
8942 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8943 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8944 verify_tag_value, UINT32);
8945 cmdline_parse_token_string_t cmd_flow_director_tos =
8946 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8948 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8949 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8951 cmdline_parse_token_string_t cmd_flow_director_proto =
8952 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8954 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8955 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8956 proto_value, UINT8);
8957 cmdline_parse_token_string_t cmd_flow_director_ttl =
8958 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8960 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8961 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8963 cmdline_parse_token_string_t cmd_flow_director_vlan =
8964 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8966 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8967 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8968 vlan_value, UINT16);
8969 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8970 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8971 flexbytes, "flexbytes");
8972 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8973 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8974 flexbytes_value, NULL);
8975 cmdline_parse_token_string_t cmd_flow_director_drop =
8976 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8978 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8979 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8981 cmdline_parse_token_string_t cmd_flow_director_queue =
8982 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8984 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8985 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8987 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8988 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8990 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8991 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8992 fd_id_value, UINT32);
8994 cmdline_parse_token_string_t cmd_flow_director_mode =
8995 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8997 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8998 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9000 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9001 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9002 mode_value, "MAC-VLAN");
9003 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9004 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9005 mode_value, "Tunnel");
9006 cmdline_parse_token_string_t cmd_flow_director_mac =
9007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9009 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9010 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9012 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9013 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9015 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9016 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9017 tunnel_type, "NVGRE#VxLAN");
9018 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9019 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9020 tunnel_id, "tunnel-id");
9021 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9022 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9023 tunnel_id_value, UINT32);
9025 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9026 .f = cmd_flow_director_filter_parsed,
9028 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9029 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9030 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9031 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9032 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9033 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9034 "fd_id <fd_id_value>: "
9035 "Add or delete an ip flow director entry on NIC",
9037 (void *)&cmd_flow_director_filter,
9038 (void *)&cmd_flow_director_port_id,
9039 (void *)&cmd_flow_director_mode,
9040 (void *)&cmd_flow_director_mode_ip,
9041 (void *)&cmd_flow_director_ops,
9042 (void *)&cmd_flow_director_flow,
9043 (void *)&cmd_flow_director_flow_type,
9044 (void *)&cmd_flow_director_src,
9045 (void *)&cmd_flow_director_ip_src,
9046 (void *)&cmd_flow_director_dst,
9047 (void *)&cmd_flow_director_ip_dst,
9048 (void *)&cmd_flow_director_tos,
9049 (void *)&cmd_flow_director_tos_value,
9050 (void *)&cmd_flow_director_proto,
9051 (void *)&cmd_flow_director_proto_value,
9052 (void *)&cmd_flow_director_ttl,
9053 (void *)&cmd_flow_director_ttl_value,
9054 (void *)&cmd_flow_director_vlan,
9055 (void *)&cmd_flow_director_vlan_value,
9056 (void *)&cmd_flow_director_flexbytes,
9057 (void *)&cmd_flow_director_flexbytes_value,
9058 (void *)&cmd_flow_director_drop,
9059 (void *)&cmd_flow_director_pf_vf,
9060 (void *)&cmd_flow_director_queue,
9061 (void *)&cmd_flow_director_queue_id,
9062 (void *)&cmd_flow_director_fd_id,
9063 (void *)&cmd_flow_director_fd_id_value,
9068 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9069 .f = cmd_flow_director_filter_parsed,
9071 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9072 "director entry on NIC",
9074 (void *)&cmd_flow_director_filter,
9075 (void *)&cmd_flow_director_port_id,
9076 (void *)&cmd_flow_director_mode,
9077 (void *)&cmd_flow_director_mode_ip,
9078 (void *)&cmd_flow_director_ops,
9079 (void *)&cmd_flow_director_flow,
9080 (void *)&cmd_flow_director_flow_type,
9081 (void *)&cmd_flow_director_src,
9082 (void *)&cmd_flow_director_ip_src,
9083 (void *)&cmd_flow_director_port_src,
9084 (void *)&cmd_flow_director_dst,
9085 (void *)&cmd_flow_director_ip_dst,
9086 (void *)&cmd_flow_director_port_dst,
9087 (void *)&cmd_flow_director_tos,
9088 (void *)&cmd_flow_director_tos_value,
9089 (void *)&cmd_flow_director_ttl,
9090 (void *)&cmd_flow_director_ttl_value,
9091 (void *)&cmd_flow_director_vlan,
9092 (void *)&cmd_flow_director_vlan_value,
9093 (void *)&cmd_flow_director_flexbytes,
9094 (void *)&cmd_flow_director_flexbytes_value,
9095 (void *)&cmd_flow_director_drop,
9096 (void *)&cmd_flow_director_pf_vf,
9097 (void *)&cmd_flow_director_queue,
9098 (void *)&cmd_flow_director_queue_id,
9099 (void *)&cmd_flow_director_fd_id,
9100 (void *)&cmd_flow_director_fd_id_value,
9105 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9106 .f = cmd_flow_director_filter_parsed,
9108 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9109 "director entry on NIC",
9111 (void *)&cmd_flow_director_filter,
9112 (void *)&cmd_flow_director_port_id,
9113 (void *)&cmd_flow_director_mode,
9114 (void *)&cmd_flow_director_mode_ip,
9115 (void *)&cmd_flow_director_ops,
9116 (void *)&cmd_flow_director_flow,
9117 (void *)&cmd_flow_director_flow_type,
9118 (void *)&cmd_flow_director_src,
9119 (void *)&cmd_flow_director_ip_src,
9120 (void *)&cmd_flow_director_port_dst,
9121 (void *)&cmd_flow_director_dst,
9122 (void *)&cmd_flow_director_ip_dst,
9123 (void *)&cmd_flow_director_port_dst,
9124 (void *)&cmd_flow_director_verify_tag,
9125 (void *)&cmd_flow_director_verify_tag_value,
9126 (void *)&cmd_flow_director_tos,
9127 (void *)&cmd_flow_director_tos_value,
9128 (void *)&cmd_flow_director_ttl,
9129 (void *)&cmd_flow_director_ttl_value,
9130 (void *)&cmd_flow_director_vlan,
9131 (void *)&cmd_flow_director_vlan_value,
9132 (void *)&cmd_flow_director_flexbytes,
9133 (void *)&cmd_flow_director_flexbytes_value,
9134 (void *)&cmd_flow_director_drop,
9135 (void *)&cmd_flow_director_pf_vf,
9136 (void *)&cmd_flow_director_queue,
9137 (void *)&cmd_flow_director_queue_id,
9138 (void *)&cmd_flow_director_fd_id,
9139 (void *)&cmd_flow_director_fd_id_value,
9144 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9145 .f = cmd_flow_director_filter_parsed,
9147 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9148 "director entry on NIC",
9150 (void *)&cmd_flow_director_filter,
9151 (void *)&cmd_flow_director_port_id,
9152 (void *)&cmd_flow_director_mode,
9153 (void *)&cmd_flow_director_mode_ip,
9154 (void *)&cmd_flow_director_ops,
9155 (void *)&cmd_flow_director_flow,
9156 (void *)&cmd_flow_director_flow_type,
9157 (void *)&cmd_flow_director_ether,
9158 (void *)&cmd_flow_director_ether_type,
9159 (void *)&cmd_flow_director_flexbytes,
9160 (void *)&cmd_flow_director_flexbytes_value,
9161 (void *)&cmd_flow_director_drop,
9162 (void *)&cmd_flow_director_pf_vf,
9163 (void *)&cmd_flow_director_queue,
9164 (void *)&cmd_flow_director_queue_id,
9165 (void *)&cmd_flow_director_fd_id,
9166 (void *)&cmd_flow_director_fd_id_value,
9171 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9172 .f = cmd_flow_director_filter_parsed,
9174 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9175 "director entry on NIC",
9177 (void *)&cmd_flow_director_filter,
9178 (void *)&cmd_flow_director_port_id,
9179 (void *)&cmd_flow_director_mode,
9180 (void *)&cmd_flow_director_mode_mac_vlan,
9181 (void *)&cmd_flow_director_ops,
9182 (void *)&cmd_flow_director_mac,
9183 (void *)&cmd_flow_director_mac_addr,
9184 (void *)&cmd_flow_director_vlan,
9185 (void *)&cmd_flow_director_vlan_value,
9186 (void *)&cmd_flow_director_flexbytes,
9187 (void *)&cmd_flow_director_flexbytes_value,
9188 (void *)&cmd_flow_director_drop,
9189 (void *)&cmd_flow_director_queue,
9190 (void *)&cmd_flow_director_queue_id,
9191 (void *)&cmd_flow_director_fd_id,
9192 (void *)&cmd_flow_director_fd_id_value,
9197 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9198 .f = cmd_flow_director_filter_parsed,
9200 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9201 "director entry on NIC",
9203 (void *)&cmd_flow_director_filter,
9204 (void *)&cmd_flow_director_port_id,
9205 (void *)&cmd_flow_director_mode,
9206 (void *)&cmd_flow_director_mode_tunnel,
9207 (void *)&cmd_flow_director_ops,
9208 (void *)&cmd_flow_director_mac,
9209 (void *)&cmd_flow_director_mac_addr,
9210 (void *)&cmd_flow_director_vlan,
9211 (void *)&cmd_flow_director_vlan_value,
9212 (void *)&cmd_flow_director_tunnel,
9213 (void *)&cmd_flow_director_tunnel_type,
9214 (void *)&cmd_flow_director_tunnel_id,
9215 (void *)&cmd_flow_director_tunnel_id_value,
9216 (void *)&cmd_flow_director_flexbytes,
9217 (void *)&cmd_flow_director_flexbytes_value,
9218 (void *)&cmd_flow_director_drop,
9219 (void *)&cmd_flow_director_queue,
9220 (void *)&cmd_flow_director_queue_id,
9221 (void *)&cmd_flow_director_fd_id,
9222 (void *)&cmd_flow_director_fd_id_value,
9227 struct cmd_flush_flow_director_result {
9228 cmdline_fixed_string_t flush_flow_director;
9232 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9233 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9234 flush_flow_director, "flush_flow_director");
9235 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9236 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9240 cmd_flush_flow_director_parsed(void *parsed_result,
9241 __attribute__((unused)) struct cmdline *cl,
9242 __attribute__((unused)) void *data)
9244 struct cmd_flow_director_result *res = parsed_result;
9247 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9249 printf("flow director is not supported on port %u.\n",
9254 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9255 RTE_ETH_FILTER_FLUSH, NULL);
9257 printf("flow director table flushing error: (%s)\n",
9261 cmdline_parse_inst_t cmd_flush_flow_director = {
9262 .f = cmd_flush_flow_director_parsed,
9264 .help_str = "flush_flow_director <port_id>: "
9265 "Flush all flow director entries of a device on NIC",
9267 (void *)&cmd_flush_flow_director_flush,
9268 (void *)&cmd_flush_flow_director_port_id,
9273 /* *** deal with flow director mask *** */
9274 struct cmd_flow_director_mask_result {
9275 cmdline_fixed_string_t flow_director_mask;
9277 cmdline_fixed_string_t mode;
9278 cmdline_fixed_string_t mode_value;
9279 cmdline_fixed_string_t vlan;
9281 cmdline_fixed_string_t src_mask;
9282 cmdline_ipaddr_t ipv4_src;
9283 cmdline_ipaddr_t ipv6_src;
9285 cmdline_fixed_string_t dst_mask;
9286 cmdline_ipaddr_t ipv4_dst;
9287 cmdline_ipaddr_t ipv6_dst;
9289 cmdline_fixed_string_t mac;
9290 uint8_t mac_addr_byte_mask;
9291 cmdline_fixed_string_t tunnel_id;
9292 uint32_t tunnel_id_mask;
9293 cmdline_fixed_string_t tunnel_type;
9294 uint8_t tunnel_type_mask;
9298 cmd_flow_director_mask_parsed(void *parsed_result,
9299 __attribute__((unused)) struct cmdline *cl,
9300 __attribute__((unused)) void *data)
9302 struct cmd_flow_director_mask_result *res = parsed_result;
9303 struct rte_eth_fdir_masks *mask;
9304 struct rte_port *port;
9306 if (res->port_id > nb_ports) {
9307 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9311 port = &ports[res->port_id];
9312 /** Check if the port is not started **/
9313 if (port->port_status != RTE_PORT_STOPPED) {
9314 printf("Please stop port %d first\n", res->port_id);
9318 mask = &port->dev_conf.fdir_conf.mask;
9320 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9321 if (strcmp(res->mode_value, "MAC-VLAN")) {
9322 printf("Please set mode to MAC-VLAN.\n");
9326 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9327 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9328 if (strcmp(res->mode_value, "Tunnel")) {
9329 printf("Please set mode to Tunnel.\n");
9333 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9334 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9335 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9336 mask->tunnel_type_mask = res->tunnel_type_mask;
9338 if (strcmp(res->mode_value, "IP")) {
9339 printf("Please set mode to IP.\n");
9343 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9344 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9345 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9346 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9347 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9348 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9349 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9352 cmd_reconfig_device_queue(res->port_id, 1, 1);
9355 cmdline_parse_token_string_t cmd_flow_director_mask =
9356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9357 flow_director_mask, "flow_director_mask");
9358 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9359 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9361 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9364 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9365 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9367 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9369 src_mask, "src_mask");
9370 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9371 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9373 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9374 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9376 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9377 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9379 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9380 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9381 dst_mask, "dst_mask");
9382 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9383 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9385 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9386 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9388 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9389 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9392 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9393 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9395 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9396 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9398 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9400 mode_value, "MAC-VLAN");
9401 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9402 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9403 mode_value, "Tunnel");
9404 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9407 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9408 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9409 mac_addr_byte_mask, UINT8);
9410 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9411 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9412 tunnel_type, "tunnel-type");
9413 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9414 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9415 tunnel_type_mask, UINT8);
9416 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9417 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9418 tunnel_id, "tunnel-id");
9419 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9420 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9421 tunnel_id_mask, UINT32);
9423 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9424 .f = cmd_flow_director_mask_parsed,
9426 .help_str = "flow_director_mask ... : "
9427 "Set IP mode flow director's mask on NIC",
9429 (void *)&cmd_flow_director_mask,
9430 (void *)&cmd_flow_director_mask_port_id,
9431 (void *)&cmd_flow_director_mask_mode,
9432 (void *)&cmd_flow_director_mask_mode_ip,
9433 (void *)&cmd_flow_director_mask_vlan,
9434 (void *)&cmd_flow_director_mask_vlan_value,
9435 (void *)&cmd_flow_director_mask_src,
9436 (void *)&cmd_flow_director_mask_ipv4_src,
9437 (void *)&cmd_flow_director_mask_ipv6_src,
9438 (void *)&cmd_flow_director_mask_port_src,
9439 (void *)&cmd_flow_director_mask_dst,
9440 (void *)&cmd_flow_director_mask_ipv4_dst,
9441 (void *)&cmd_flow_director_mask_ipv6_dst,
9442 (void *)&cmd_flow_director_mask_port_dst,
9447 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9448 .f = cmd_flow_director_mask_parsed,
9450 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9451 "flow director's mask on NIC",
9453 (void *)&cmd_flow_director_mask,
9454 (void *)&cmd_flow_director_mask_port_id,
9455 (void *)&cmd_flow_director_mask_mode,
9456 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9457 (void *)&cmd_flow_director_mask_vlan,
9458 (void *)&cmd_flow_director_mask_vlan_value,
9463 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9464 .f = cmd_flow_director_mask_parsed,
9466 .help_str = "flow_director_mask ... : Set tunnel mode "
9467 "flow director's mask on NIC",
9469 (void *)&cmd_flow_director_mask,
9470 (void *)&cmd_flow_director_mask_port_id,
9471 (void *)&cmd_flow_director_mask_mode,
9472 (void *)&cmd_flow_director_mask_mode_tunnel,
9473 (void *)&cmd_flow_director_mask_vlan,
9474 (void *)&cmd_flow_director_mask_vlan_value,
9475 (void *)&cmd_flow_director_mask_mac,
9476 (void *)&cmd_flow_director_mask_mac_value,
9477 (void *)&cmd_flow_director_mask_tunnel_type,
9478 (void *)&cmd_flow_director_mask_tunnel_type_value,
9479 (void *)&cmd_flow_director_mask_tunnel_id,
9480 (void *)&cmd_flow_director_mask_tunnel_id_value,
9485 /* *** deal with flow director mask on flexible payload *** */
9486 struct cmd_flow_director_flex_mask_result {
9487 cmdline_fixed_string_t flow_director_flexmask;
9489 cmdline_fixed_string_t flow;
9490 cmdline_fixed_string_t flow_type;
9491 cmdline_fixed_string_t mask;
9495 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9496 __attribute__((unused)) struct cmdline *cl,
9497 __attribute__((unused)) void *data)
9499 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9500 struct rte_eth_fdir_info fdir_info;
9501 struct rte_eth_fdir_flex_mask flex_mask;
9502 struct rte_port *port;
9503 uint32_t flow_type_mask;
9507 if (res->port_id > nb_ports) {
9508 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9512 port = &ports[res->port_id];
9513 /** Check if the port is not started **/
9514 if (port->port_status != RTE_PORT_STOPPED) {
9515 printf("Please stop port %d first\n", res->port_id);
9519 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9520 ret = parse_flexbytes(res->mask,
9522 RTE_ETH_FDIR_MAX_FLEXLEN);
9524 printf("error: Cannot parse mask input.\n");
9528 memset(&fdir_info, 0, sizeof(fdir_info));
9529 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9530 RTE_ETH_FILTER_INFO, &fdir_info);
9532 printf("Cannot get FDir filter info\n");
9536 if (!strcmp(res->flow_type, "none")) {
9537 /* means don't specify the flow type */
9538 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9539 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9540 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9541 0, sizeof(struct rte_eth_fdir_flex_mask));
9542 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9543 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9545 sizeof(struct rte_eth_fdir_flex_mask));
9546 cmd_reconfig_device_queue(res->port_id, 1, 1);
9549 flow_type_mask = fdir_info.flow_types_mask[0];
9550 if (!strcmp(res->flow_type, "all")) {
9551 if (!flow_type_mask) {
9552 printf("No flow type supported\n");
9555 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9556 if (flow_type_mask & (1 << i)) {
9557 flex_mask.flow_type = i;
9558 fdir_set_flex_mask(res->port_id, &flex_mask);
9561 cmd_reconfig_device_queue(res->port_id, 1, 1);
9564 flex_mask.flow_type = str2flowtype(res->flow_type);
9565 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9566 printf("Flow type %s not supported on port %d\n",
9567 res->flow_type, res->port_id);
9570 fdir_set_flex_mask(res->port_id, &flex_mask);
9571 cmd_reconfig_device_queue(res->port_id, 1, 1);
9574 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9575 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9576 flow_director_flexmask,
9577 "flow_director_flex_mask");
9578 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9579 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9581 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9582 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9584 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9585 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9586 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9587 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9588 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9589 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9592 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9593 .f = cmd_flow_director_flex_mask_parsed,
9595 .help_str = "flow_director_flex_mask ... : "
9596 "Set flow director's flex mask on NIC",
9598 (void *)&cmd_flow_director_flexmask,
9599 (void *)&cmd_flow_director_flexmask_port_id,
9600 (void *)&cmd_flow_director_flexmask_flow,
9601 (void *)&cmd_flow_director_flexmask_flow_type,
9602 (void *)&cmd_flow_director_flexmask_mask,
9607 /* *** deal with flow director flexible payload configuration *** */
9608 struct cmd_flow_director_flexpayload_result {
9609 cmdline_fixed_string_t flow_director_flexpayload;
9611 cmdline_fixed_string_t payload_layer;
9612 cmdline_fixed_string_t payload_cfg;
9616 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9619 const char *p, *p0 = q_arg;
9621 unsigned long int_fld;
9622 char *str_fld[max_num];
9627 p = strchr(p0, '(');
9631 p0 = strchr(p, ')');
9636 if (size >= sizeof(s))
9639 snprintf(s, sizeof(s), "%.*s", size, p);
9640 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9641 if (ret < 0 || ret > max_num)
9643 for (i = 0; i < ret; i++) {
9645 int_fld = strtoul(str_fld[i], &end, 0);
9646 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9648 offsets[i] = (uint16_t)int_fld;
9654 cmd_flow_director_flxpld_parsed(void *parsed_result,
9655 __attribute__((unused)) struct cmdline *cl,
9656 __attribute__((unused)) void *data)
9658 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9659 struct rte_eth_flex_payload_cfg flex_cfg;
9660 struct rte_port *port;
9663 if (res->port_id > nb_ports) {
9664 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9668 port = &ports[res->port_id];
9669 /** Check if the port is not started **/
9670 if (port->port_status != RTE_PORT_STOPPED) {
9671 printf("Please stop port %d first\n", res->port_id);
9675 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9677 if (!strcmp(res->payload_layer, "raw"))
9678 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9679 else if (!strcmp(res->payload_layer, "l2"))
9680 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9681 else if (!strcmp(res->payload_layer, "l3"))
9682 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9683 else if (!strcmp(res->payload_layer, "l4"))
9684 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9686 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9687 RTE_ETH_FDIR_MAX_FLEXLEN);
9689 printf("error: Cannot parse flex payload input.\n");
9693 fdir_set_flex_payload(res->port_id, &flex_cfg);
9694 cmd_reconfig_device_queue(res->port_id, 1, 1);
9697 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9698 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9699 flow_director_flexpayload,
9700 "flow_director_flex_payload");
9701 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9702 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9704 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9706 payload_layer, "raw#l2#l3#l4");
9707 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9708 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9711 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9712 .f = cmd_flow_director_flxpld_parsed,
9714 .help_str = "flow_director_flexpayload ... : "
9715 "Set flow director's flex payload on NIC",
9717 (void *)&cmd_flow_director_flexpayload,
9718 (void *)&cmd_flow_director_flexpayload_port_id,
9719 (void *)&cmd_flow_director_flexpayload_payload_layer,
9720 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9725 /* Generic flow interface command. */
9726 extern cmdline_parse_inst_t cmd_flow;
9728 /* *** Classification Filters Control *** */
9729 /* *** Get symmetric hash enable per port *** */
9730 struct cmd_get_sym_hash_ena_per_port_result {
9731 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9736 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9737 __rte_unused struct cmdline *cl,
9738 __rte_unused void *data)
9740 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9741 struct rte_eth_hash_filter_info info;
9744 if (rte_eth_dev_filter_supported(res->port_id,
9745 RTE_ETH_FILTER_HASH) < 0) {
9746 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9751 memset(&info, 0, sizeof(info));
9752 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9753 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9754 RTE_ETH_FILTER_GET, &info);
9757 printf("Cannot get symmetric hash enable per port "
9758 "on port %u\n", res->port_id);
9762 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9763 "enabled" : "disabled", res->port_id);
9766 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9767 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9768 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9769 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9770 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9773 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9774 .f = cmd_get_sym_hash_per_port_parsed,
9776 .help_str = "get_sym_hash_ena_per_port <port_id>",
9778 (void *)&cmd_get_sym_hash_ena_per_port_all,
9779 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9784 /* *** Set symmetric hash enable per port *** */
9785 struct cmd_set_sym_hash_ena_per_port_result {
9786 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9787 cmdline_fixed_string_t enable;
9792 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9793 __rte_unused struct cmdline *cl,
9794 __rte_unused void *data)
9796 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9797 struct rte_eth_hash_filter_info info;
9800 if (rte_eth_dev_filter_supported(res->port_id,
9801 RTE_ETH_FILTER_HASH) < 0) {
9802 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9807 memset(&info, 0, sizeof(info));
9808 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9809 if (!strcmp(res->enable, "enable"))
9810 info.info.enable = 1;
9811 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9812 RTE_ETH_FILTER_SET, &info);
9814 printf("Cannot set symmetric hash enable per port on "
9815 "port %u\n", res->port_id);
9818 printf("Symmetric hash has been set to %s on port %u\n",
9819 res->enable, res->port_id);
9822 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9823 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9824 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9825 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9826 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9828 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9829 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9830 enable, "enable#disable");
9832 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9833 .f = cmd_set_sym_hash_per_port_parsed,
9835 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9837 (void *)&cmd_set_sym_hash_ena_per_port_all,
9838 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9839 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9844 /* Get global config of hash function */
9845 struct cmd_get_hash_global_config_result {
9846 cmdline_fixed_string_t get_hash_global_config;
9851 flowtype_to_str(uint16_t ftype)
9858 {"ipv4", RTE_ETH_FLOW_IPV4},
9859 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9860 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9861 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9862 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9863 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9864 {"ipv6", RTE_ETH_FLOW_IPV6},
9865 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9866 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9867 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9868 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9869 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9870 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9871 {"port", RTE_ETH_FLOW_PORT},
9872 {"vxlan", RTE_ETH_FLOW_VXLAN},
9873 {"geneve", RTE_ETH_FLOW_GENEVE},
9874 {"nvgre", RTE_ETH_FLOW_NVGRE},
9877 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9878 if (ftype_table[i].ftype == ftype)
9879 return ftype_table[i].str;
9886 cmd_get_hash_global_config_parsed(void *parsed_result,
9887 __rte_unused struct cmdline *cl,
9888 __rte_unused void *data)
9890 struct cmd_get_hash_global_config_result *res = parsed_result;
9891 struct rte_eth_hash_filter_info info;
9892 uint32_t idx, offset;
9897 if (rte_eth_dev_filter_supported(res->port_id,
9898 RTE_ETH_FILTER_HASH) < 0) {
9899 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9904 memset(&info, 0, sizeof(info));
9905 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9906 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9907 RTE_ETH_FILTER_GET, &info);
9909 printf("Cannot get hash global configurations by port %d\n",
9914 switch (info.info.global_conf.hash_func) {
9915 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9916 printf("Hash function is Toeplitz\n");
9918 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9919 printf("Hash function is Simple XOR\n");
9922 printf("Unknown hash function\n");
9926 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9927 idx = i / UINT32_BIT;
9928 offset = i % UINT32_BIT;
9929 if (!(info.info.global_conf.valid_bit_mask[idx] &
9932 str = flowtype_to_str(i);
9935 printf("Symmetric hash is %s globally for flow type %s "
9937 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9938 (1UL << offset)) ? "enabled" : "disabled"), str,
9943 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9944 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9945 get_hash_global_config, "get_hash_global_config");
9946 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9947 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9950 cmdline_parse_inst_t cmd_get_hash_global_config = {
9951 .f = cmd_get_hash_global_config_parsed,
9953 .help_str = "get_hash_global_config <port_id>",
9955 (void *)&cmd_get_hash_global_config_all,
9956 (void *)&cmd_get_hash_global_config_port_id,
9961 /* Set global config of hash function */
9962 struct cmd_set_hash_global_config_result {
9963 cmdline_fixed_string_t set_hash_global_config;
9965 cmdline_fixed_string_t hash_func;
9966 cmdline_fixed_string_t flow_type;
9967 cmdline_fixed_string_t enable;
9971 cmd_set_hash_global_config_parsed(void *parsed_result,
9972 __rte_unused struct cmdline *cl,
9973 __rte_unused void *data)
9975 struct cmd_set_hash_global_config_result *res = parsed_result;
9976 struct rte_eth_hash_filter_info info;
9977 uint32_t ftype, idx, offset;
9980 if (rte_eth_dev_filter_supported(res->port_id,
9981 RTE_ETH_FILTER_HASH) < 0) {
9982 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9986 memset(&info, 0, sizeof(info));
9987 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9988 if (!strcmp(res->hash_func, "toeplitz"))
9989 info.info.global_conf.hash_func =
9990 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9991 else if (!strcmp(res->hash_func, "simple_xor"))
9992 info.info.global_conf.hash_func =
9993 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9994 else if (!strcmp(res->hash_func, "default"))
9995 info.info.global_conf.hash_func =
9996 RTE_ETH_HASH_FUNCTION_DEFAULT;
9998 ftype = str2flowtype(res->flow_type);
9999 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10000 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10001 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10002 if (!strcmp(res->enable, "enable"))
10003 info.info.global_conf.sym_hash_enable_mask[idx] |=
10005 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10006 RTE_ETH_FILTER_SET, &info);
10008 printf("Cannot set global hash configurations by port %d\n",
10011 printf("Global hash configurations have been set "
10012 "succcessfully by port %d\n", res->port_id);
10015 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10016 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10017 set_hash_global_config, "set_hash_global_config");
10018 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10019 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10021 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10022 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10023 hash_func, "toeplitz#simple_xor#default");
10024 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10025 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10027 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10028 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10029 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10030 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10031 enable, "enable#disable");
10033 cmdline_parse_inst_t cmd_set_hash_global_config = {
10034 .f = cmd_set_hash_global_config_parsed,
10036 .help_str = "set_hash_global_config <port_id> "
10037 "toeplitz|simple_xor|default "
10038 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10039 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10040 "l2_payload enable|disable",
10042 (void *)&cmd_set_hash_global_config_all,
10043 (void *)&cmd_set_hash_global_config_port_id,
10044 (void *)&cmd_set_hash_global_config_hash_func,
10045 (void *)&cmd_set_hash_global_config_flow_type,
10046 (void *)&cmd_set_hash_global_config_enable,
10051 /* Set hash input set */
10052 struct cmd_set_hash_input_set_result {
10053 cmdline_fixed_string_t set_hash_input_set;
10055 cmdline_fixed_string_t flow_type;
10056 cmdline_fixed_string_t inset_field;
10057 cmdline_fixed_string_t select;
10060 static enum rte_eth_input_set_field
10061 str2inset(char *string)
10065 static const struct {
10067 enum rte_eth_input_set_field inset;
10068 } inset_table[] = {
10069 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10070 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10071 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10072 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10073 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10074 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10075 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10076 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10077 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10078 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10079 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10080 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10081 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10082 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10083 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10084 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10085 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10086 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10087 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10088 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10089 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10090 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10091 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10092 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10093 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10094 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10095 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10096 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10097 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10098 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10099 {"none", RTE_ETH_INPUT_SET_NONE},
10102 for (i = 0; i < RTE_DIM(inset_table); i++) {
10103 if (!strcmp(string, inset_table[i].str))
10104 return inset_table[i].inset;
10107 return RTE_ETH_INPUT_SET_UNKNOWN;
10111 cmd_set_hash_input_set_parsed(void *parsed_result,
10112 __rte_unused struct cmdline *cl,
10113 __rte_unused void *data)
10115 struct cmd_set_hash_input_set_result *res = parsed_result;
10116 struct rte_eth_hash_filter_info info;
10118 memset(&info, 0, sizeof(info));
10119 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10120 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10121 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10122 info.info.input_set_conf.inset_size = 1;
10123 if (!strcmp(res->select, "select"))
10124 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10125 else if (!strcmp(res->select, "add"))
10126 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10127 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10128 RTE_ETH_FILTER_SET, &info);
10131 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10132 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10133 set_hash_input_set, "set_hash_input_set");
10134 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10135 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10137 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10138 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10140 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10141 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10142 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10143 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10145 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10146 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10147 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10148 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10149 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10151 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10152 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10153 select, "select#add");
10155 cmdline_parse_inst_t cmd_set_hash_input_set = {
10156 .f = cmd_set_hash_input_set_parsed,
10158 .help_str = "set_hash_input_set <port_id> "
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 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10162 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10163 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10164 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10165 "fld-7th|fld-8th|none select|add",
10167 (void *)&cmd_set_hash_input_set_cmd,
10168 (void *)&cmd_set_hash_input_set_port_id,
10169 (void *)&cmd_set_hash_input_set_flow_type,
10170 (void *)&cmd_set_hash_input_set_field,
10171 (void *)&cmd_set_hash_input_set_select,
10176 /* Set flow director input set */
10177 struct cmd_set_fdir_input_set_result {
10178 cmdline_fixed_string_t set_fdir_input_set;
10180 cmdline_fixed_string_t flow_type;
10181 cmdline_fixed_string_t inset_field;
10182 cmdline_fixed_string_t select;
10186 cmd_set_fdir_input_set_parsed(void *parsed_result,
10187 __rte_unused struct cmdline *cl,
10188 __rte_unused void *data)
10190 struct cmd_set_fdir_input_set_result *res = parsed_result;
10191 struct rte_eth_fdir_filter_info info;
10193 memset(&info, 0, sizeof(info));
10194 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10195 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10196 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10197 info.info.input_set_conf.inset_size = 1;
10198 if (!strcmp(res->select, "select"))
10199 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10200 else if (!strcmp(res->select, "add"))
10201 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10202 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10203 RTE_ETH_FILTER_SET, &info);
10206 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10207 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10208 set_fdir_input_set, "set_fdir_input_set");
10209 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10210 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10212 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10213 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10215 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10216 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10217 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10218 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10220 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10221 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10222 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10223 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10224 "sctp-veri-tag#none");
10225 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10226 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10227 select, "select#add");
10229 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10230 .f = cmd_set_fdir_input_set_parsed,
10232 .help_str = "set_fdir_input_set <port_id> "
10233 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10234 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10235 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10236 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10237 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10238 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10239 "sctp-veri-tag|none select|add",
10241 (void *)&cmd_set_fdir_input_set_cmd,
10242 (void *)&cmd_set_fdir_input_set_port_id,
10243 (void *)&cmd_set_fdir_input_set_flow_type,
10244 (void *)&cmd_set_fdir_input_set_field,
10245 (void *)&cmd_set_fdir_input_set_select,
10250 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10251 struct cmd_mcast_addr_result {
10252 cmdline_fixed_string_t mcast_addr_cmd;
10253 cmdline_fixed_string_t what;
10255 struct ether_addr mc_addr;
10258 static void cmd_mcast_addr_parsed(void *parsed_result,
10259 __attribute__((unused)) struct cmdline *cl,
10260 __attribute__((unused)) void *data)
10262 struct cmd_mcast_addr_result *res = parsed_result;
10264 if (!is_multicast_ether_addr(&res->mc_addr)) {
10265 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10266 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10267 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10268 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10271 if (strcmp(res->what, "add") == 0)
10272 mcast_addr_add(res->port_num, &res->mc_addr);
10274 mcast_addr_remove(res->port_num, &res->mc_addr);
10277 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10278 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10279 mcast_addr_cmd, "mcast_addr");
10280 cmdline_parse_token_string_t cmd_mcast_addr_what =
10281 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10283 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10284 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10285 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10286 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10288 cmdline_parse_inst_t cmd_mcast_addr = {
10289 .f = cmd_mcast_addr_parsed,
10291 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10292 "Add/Remove multicast MAC address on port_id",
10294 (void *)&cmd_mcast_addr_cmd,
10295 (void *)&cmd_mcast_addr_what,
10296 (void *)&cmd_mcast_addr_portnum,
10297 (void *)&cmd_mcast_addr_addr,
10302 /* l2 tunnel config
10303 * only support E-tag now.
10306 /* Ether type config */
10307 struct cmd_config_l2_tunnel_eth_type_result {
10308 cmdline_fixed_string_t port;
10309 cmdline_fixed_string_t config;
10310 cmdline_fixed_string_t all;
10312 cmdline_fixed_string_t l2_tunnel;
10313 cmdline_fixed_string_t l2_tunnel_type;
10314 cmdline_fixed_string_t eth_type;
10315 uint16_t eth_type_val;
10318 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10319 TOKEN_STRING_INITIALIZER
10320 (struct cmd_config_l2_tunnel_eth_type_result,
10322 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10323 TOKEN_STRING_INITIALIZER
10324 (struct cmd_config_l2_tunnel_eth_type_result,
10326 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10327 TOKEN_STRING_INITIALIZER
10328 (struct cmd_config_l2_tunnel_eth_type_result,
10330 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10331 TOKEN_NUM_INITIALIZER
10332 (struct cmd_config_l2_tunnel_eth_type_result,
10334 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10335 TOKEN_STRING_INITIALIZER
10336 (struct cmd_config_l2_tunnel_eth_type_result,
10337 l2_tunnel, "l2-tunnel");
10338 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10339 TOKEN_STRING_INITIALIZER
10340 (struct cmd_config_l2_tunnel_eth_type_result,
10341 l2_tunnel_type, "E-tag");
10342 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10343 TOKEN_STRING_INITIALIZER
10344 (struct cmd_config_l2_tunnel_eth_type_result,
10345 eth_type, "ether-type");
10346 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10347 TOKEN_NUM_INITIALIZER
10348 (struct cmd_config_l2_tunnel_eth_type_result,
10349 eth_type_val, UINT16);
10351 static enum rte_eth_tunnel_type
10352 str2fdir_l2_tunnel_type(char *string)
10356 static const struct {
10358 enum rte_eth_tunnel_type type;
10359 } l2_tunnel_type_str[] = {
10360 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10363 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10364 if (!strcmp(l2_tunnel_type_str[i].str, string))
10365 return l2_tunnel_type_str[i].type;
10367 return RTE_TUNNEL_TYPE_NONE;
10370 /* ether type config for all ports */
10372 cmd_config_l2_tunnel_eth_type_all_parsed
10373 (void *parsed_result,
10374 __attribute__((unused)) struct cmdline *cl,
10375 __attribute__((unused)) void *data)
10377 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10378 struct rte_eth_l2_tunnel_conf entry;
10381 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10382 entry.ether_type = res->eth_type_val;
10384 RTE_ETH_FOREACH_DEV(pid) {
10385 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10389 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10390 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10392 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10394 (void *)&cmd_config_l2_tunnel_eth_type_port,
10395 (void *)&cmd_config_l2_tunnel_eth_type_config,
10396 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10397 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10398 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10399 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10400 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10405 /* ether type config for a specific port */
10407 cmd_config_l2_tunnel_eth_type_specific_parsed(
10408 void *parsed_result,
10409 __attribute__((unused)) struct cmdline *cl,
10410 __attribute__((unused)) void *data)
10412 struct cmd_config_l2_tunnel_eth_type_result *res =
10414 struct rte_eth_l2_tunnel_conf entry;
10416 if (port_id_is_invalid(res->id, ENABLED_WARN))
10419 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10420 entry.ether_type = res->eth_type_val;
10422 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10425 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10426 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10428 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10430 (void *)&cmd_config_l2_tunnel_eth_type_port,
10431 (void *)&cmd_config_l2_tunnel_eth_type_config,
10432 (void *)&cmd_config_l2_tunnel_eth_type_id,
10433 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10434 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10435 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10436 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10441 /* Enable/disable l2 tunnel */
10442 struct cmd_config_l2_tunnel_en_dis_result {
10443 cmdline_fixed_string_t port;
10444 cmdline_fixed_string_t config;
10445 cmdline_fixed_string_t all;
10447 cmdline_fixed_string_t l2_tunnel;
10448 cmdline_fixed_string_t l2_tunnel_type;
10449 cmdline_fixed_string_t en_dis;
10452 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10453 TOKEN_STRING_INITIALIZER
10454 (struct cmd_config_l2_tunnel_en_dis_result,
10456 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10457 TOKEN_STRING_INITIALIZER
10458 (struct cmd_config_l2_tunnel_en_dis_result,
10460 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10461 TOKEN_STRING_INITIALIZER
10462 (struct cmd_config_l2_tunnel_en_dis_result,
10464 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10465 TOKEN_NUM_INITIALIZER
10466 (struct cmd_config_l2_tunnel_en_dis_result,
10468 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10469 TOKEN_STRING_INITIALIZER
10470 (struct cmd_config_l2_tunnel_en_dis_result,
10471 l2_tunnel, "l2-tunnel");
10472 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10473 TOKEN_STRING_INITIALIZER
10474 (struct cmd_config_l2_tunnel_en_dis_result,
10475 l2_tunnel_type, "E-tag");
10476 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10477 TOKEN_STRING_INITIALIZER
10478 (struct cmd_config_l2_tunnel_en_dis_result,
10479 en_dis, "enable#disable");
10481 /* enable/disable l2 tunnel for all ports */
10483 cmd_config_l2_tunnel_en_dis_all_parsed(
10484 void *parsed_result,
10485 __attribute__((unused)) struct cmdline *cl,
10486 __attribute__((unused)) void *data)
10488 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10489 struct rte_eth_l2_tunnel_conf entry;
10493 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10495 if (!strcmp("enable", res->en_dis))
10500 RTE_ETH_FOREACH_DEV(pid) {
10501 rte_eth_dev_l2_tunnel_offload_set(pid,
10503 ETH_L2_TUNNEL_ENABLE_MASK,
10508 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10509 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10511 .help_str = "port config all l2-tunnel E-tag enable|disable",
10513 (void *)&cmd_config_l2_tunnel_en_dis_port,
10514 (void *)&cmd_config_l2_tunnel_en_dis_config,
10515 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10516 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10517 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10518 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10523 /* enable/disable l2 tunnel for a port */
10525 cmd_config_l2_tunnel_en_dis_specific_parsed(
10526 void *parsed_result,
10527 __attribute__((unused)) struct cmdline *cl,
10528 __attribute__((unused)) void *data)
10530 struct cmd_config_l2_tunnel_en_dis_result *res =
10532 struct rte_eth_l2_tunnel_conf entry;
10534 if (port_id_is_invalid(res->id, ENABLED_WARN))
10537 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10539 if (!strcmp("enable", res->en_dis))
10540 rte_eth_dev_l2_tunnel_offload_set(res->id,
10542 ETH_L2_TUNNEL_ENABLE_MASK,
10545 rte_eth_dev_l2_tunnel_offload_set(res->id,
10547 ETH_L2_TUNNEL_ENABLE_MASK,
10551 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10552 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10554 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10556 (void *)&cmd_config_l2_tunnel_en_dis_port,
10557 (void *)&cmd_config_l2_tunnel_en_dis_config,
10558 (void *)&cmd_config_l2_tunnel_en_dis_id,
10559 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10560 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10561 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10566 /* E-tag configuration */
10568 /* Common result structure for all E-tag configuration */
10569 struct cmd_config_e_tag_result {
10570 cmdline_fixed_string_t e_tag;
10571 cmdline_fixed_string_t set;
10572 cmdline_fixed_string_t insertion;
10573 cmdline_fixed_string_t stripping;
10574 cmdline_fixed_string_t forwarding;
10575 cmdline_fixed_string_t filter;
10576 cmdline_fixed_string_t add;
10577 cmdline_fixed_string_t del;
10578 cmdline_fixed_string_t on;
10579 cmdline_fixed_string_t off;
10580 cmdline_fixed_string_t on_off;
10581 cmdline_fixed_string_t port_tag_id;
10582 uint32_t port_tag_id_val;
10583 cmdline_fixed_string_t e_tag_id;
10584 uint16_t e_tag_id_val;
10585 cmdline_fixed_string_t dst_pool;
10586 uint8_t dst_pool_val;
10587 cmdline_fixed_string_t port;
10589 cmdline_fixed_string_t vf;
10593 /* Common CLI fields for all E-tag configuration */
10594 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10595 TOKEN_STRING_INITIALIZER
10596 (struct cmd_config_e_tag_result,
10598 cmdline_parse_token_string_t cmd_config_e_tag_set =
10599 TOKEN_STRING_INITIALIZER
10600 (struct cmd_config_e_tag_result,
10602 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10603 TOKEN_STRING_INITIALIZER
10604 (struct cmd_config_e_tag_result,
10605 insertion, "insertion");
10606 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10607 TOKEN_STRING_INITIALIZER
10608 (struct cmd_config_e_tag_result,
10609 stripping, "stripping");
10610 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10611 TOKEN_STRING_INITIALIZER
10612 (struct cmd_config_e_tag_result,
10613 forwarding, "forwarding");
10614 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10615 TOKEN_STRING_INITIALIZER
10616 (struct cmd_config_e_tag_result,
10618 cmdline_parse_token_string_t cmd_config_e_tag_add =
10619 TOKEN_STRING_INITIALIZER
10620 (struct cmd_config_e_tag_result,
10622 cmdline_parse_token_string_t cmd_config_e_tag_del =
10623 TOKEN_STRING_INITIALIZER
10624 (struct cmd_config_e_tag_result,
10626 cmdline_parse_token_string_t cmd_config_e_tag_on =
10627 TOKEN_STRING_INITIALIZER
10628 (struct cmd_config_e_tag_result,
10630 cmdline_parse_token_string_t cmd_config_e_tag_off =
10631 TOKEN_STRING_INITIALIZER
10632 (struct cmd_config_e_tag_result,
10634 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10635 TOKEN_STRING_INITIALIZER
10636 (struct cmd_config_e_tag_result,
10638 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10639 TOKEN_STRING_INITIALIZER
10640 (struct cmd_config_e_tag_result,
10641 port_tag_id, "port-tag-id");
10642 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10643 TOKEN_NUM_INITIALIZER
10644 (struct cmd_config_e_tag_result,
10645 port_tag_id_val, UINT32);
10646 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10647 TOKEN_STRING_INITIALIZER
10648 (struct cmd_config_e_tag_result,
10649 e_tag_id, "e-tag-id");
10650 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10651 TOKEN_NUM_INITIALIZER
10652 (struct cmd_config_e_tag_result,
10653 e_tag_id_val, UINT16);
10654 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10655 TOKEN_STRING_INITIALIZER
10656 (struct cmd_config_e_tag_result,
10657 dst_pool, "dst-pool");
10658 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10659 TOKEN_NUM_INITIALIZER
10660 (struct cmd_config_e_tag_result,
10661 dst_pool_val, UINT8);
10662 cmdline_parse_token_string_t cmd_config_e_tag_port =
10663 TOKEN_STRING_INITIALIZER
10664 (struct cmd_config_e_tag_result,
10666 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10667 TOKEN_NUM_INITIALIZER
10668 (struct cmd_config_e_tag_result,
10670 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10671 TOKEN_STRING_INITIALIZER
10672 (struct cmd_config_e_tag_result,
10674 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10675 TOKEN_NUM_INITIALIZER
10676 (struct cmd_config_e_tag_result,
10679 /* E-tag insertion configuration */
10681 cmd_config_e_tag_insertion_en_parsed(
10682 void *parsed_result,
10683 __attribute__((unused)) struct cmdline *cl,
10684 __attribute__((unused)) void *data)
10686 struct cmd_config_e_tag_result *res =
10688 struct rte_eth_l2_tunnel_conf entry;
10690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10693 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10694 entry.tunnel_id = res->port_tag_id_val;
10695 entry.vf_id = res->vf_id;
10696 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10698 ETH_L2_TUNNEL_INSERTION_MASK,
10703 cmd_config_e_tag_insertion_dis_parsed(
10704 void *parsed_result,
10705 __attribute__((unused)) struct cmdline *cl,
10706 __attribute__((unused)) void *data)
10708 struct cmd_config_e_tag_result *res =
10710 struct rte_eth_l2_tunnel_conf entry;
10712 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10715 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10716 entry.vf_id = res->vf_id;
10718 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10720 ETH_L2_TUNNEL_INSERTION_MASK,
10724 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10725 .f = cmd_config_e_tag_insertion_en_parsed,
10727 .help_str = "E-tag ... : E-tag insertion enable",
10729 (void *)&cmd_config_e_tag_e_tag,
10730 (void *)&cmd_config_e_tag_set,
10731 (void *)&cmd_config_e_tag_insertion,
10732 (void *)&cmd_config_e_tag_on,
10733 (void *)&cmd_config_e_tag_port_tag_id,
10734 (void *)&cmd_config_e_tag_port_tag_id_val,
10735 (void *)&cmd_config_e_tag_port,
10736 (void *)&cmd_config_e_tag_port_id,
10737 (void *)&cmd_config_e_tag_vf,
10738 (void *)&cmd_config_e_tag_vf_id,
10743 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10744 .f = cmd_config_e_tag_insertion_dis_parsed,
10746 .help_str = "E-tag ... : E-tag insertion disable",
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_off,
10752 (void *)&cmd_config_e_tag_port,
10753 (void *)&cmd_config_e_tag_port_id,
10754 (void *)&cmd_config_e_tag_vf,
10755 (void *)&cmd_config_e_tag_vf_id,
10760 /* E-tag stripping configuration */
10762 cmd_config_e_tag_stripping_parsed(
10763 void *parsed_result,
10764 __attribute__((unused)) struct cmdline *cl,
10765 __attribute__((unused)) void *data)
10767 struct cmd_config_e_tag_result *res =
10769 struct rte_eth_l2_tunnel_conf entry;
10771 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10774 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10776 if (!strcmp(res->on_off, "on"))
10777 rte_eth_dev_l2_tunnel_offload_set
10780 ETH_L2_TUNNEL_STRIPPING_MASK,
10783 rte_eth_dev_l2_tunnel_offload_set
10786 ETH_L2_TUNNEL_STRIPPING_MASK,
10790 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10791 .f = cmd_config_e_tag_stripping_parsed,
10793 .help_str = "E-tag ... : E-tag stripping enable/disable",
10795 (void *)&cmd_config_e_tag_e_tag,
10796 (void *)&cmd_config_e_tag_set,
10797 (void *)&cmd_config_e_tag_stripping,
10798 (void *)&cmd_config_e_tag_on_off,
10799 (void *)&cmd_config_e_tag_port,
10800 (void *)&cmd_config_e_tag_port_id,
10805 /* E-tag forwarding configuration */
10807 cmd_config_e_tag_forwarding_parsed(
10808 void *parsed_result,
10809 __attribute__((unused)) struct cmdline *cl,
10810 __attribute__((unused)) void *data)
10812 struct cmd_config_e_tag_result *res = parsed_result;
10813 struct rte_eth_l2_tunnel_conf entry;
10815 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10818 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10820 if (!strcmp(res->on_off, "on"))
10821 rte_eth_dev_l2_tunnel_offload_set
10824 ETH_L2_TUNNEL_FORWARDING_MASK,
10827 rte_eth_dev_l2_tunnel_offload_set
10830 ETH_L2_TUNNEL_FORWARDING_MASK,
10834 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10835 .f = cmd_config_e_tag_forwarding_parsed,
10837 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10839 (void *)&cmd_config_e_tag_e_tag,
10840 (void *)&cmd_config_e_tag_set,
10841 (void *)&cmd_config_e_tag_forwarding,
10842 (void *)&cmd_config_e_tag_on_off,
10843 (void *)&cmd_config_e_tag_port,
10844 (void *)&cmd_config_e_tag_port_id,
10849 /* E-tag filter configuration */
10851 cmd_config_e_tag_filter_add_parsed(
10852 void *parsed_result,
10853 __attribute__((unused)) struct cmdline *cl,
10854 __attribute__((unused)) void *data)
10856 struct cmd_config_e_tag_result *res = parsed_result;
10857 struct rte_eth_l2_tunnel_conf entry;
10860 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10863 if (res->e_tag_id_val > 0x3fff) {
10864 printf("e-tag-id must be equal or less than 0x3fff.\n");
10868 ret = rte_eth_dev_filter_supported(res->port_id,
10869 RTE_ETH_FILTER_L2_TUNNEL);
10871 printf("E-tag filter is not supported on port %u.\n",
10876 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10877 entry.tunnel_id = res->e_tag_id_val;
10878 entry.pool = res->dst_pool_val;
10880 ret = rte_eth_dev_filter_ctrl(res->port_id,
10881 RTE_ETH_FILTER_L2_TUNNEL,
10882 RTE_ETH_FILTER_ADD,
10885 printf("E-tag filter programming error: (%s)\n",
10889 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10890 .f = cmd_config_e_tag_filter_add_parsed,
10892 .help_str = "E-tag ... : E-tag filter add",
10894 (void *)&cmd_config_e_tag_e_tag,
10895 (void *)&cmd_config_e_tag_set,
10896 (void *)&cmd_config_e_tag_filter,
10897 (void *)&cmd_config_e_tag_add,
10898 (void *)&cmd_config_e_tag_e_tag_id,
10899 (void *)&cmd_config_e_tag_e_tag_id_val,
10900 (void *)&cmd_config_e_tag_dst_pool,
10901 (void *)&cmd_config_e_tag_dst_pool_val,
10902 (void *)&cmd_config_e_tag_port,
10903 (void *)&cmd_config_e_tag_port_id,
10909 cmd_config_e_tag_filter_del_parsed(
10910 void *parsed_result,
10911 __attribute__((unused)) struct cmdline *cl,
10912 __attribute__((unused)) void *data)
10914 struct cmd_config_e_tag_result *res = parsed_result;
10915 struct rte_eth_l2_tunnel_conf entry;
10918 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10921 if (res->e_tag_id_val > 0x3fff) {
10922 printf("e-tag-id must be less than 0x3fff.\n");
10926 ret = rte_eth_dev_filter_supported(res->port_id,
10927 RTE_ETH_FILTER_L2_TUNNEL);
10929 printf("E-tag filter is not supported on port %u.\n",
10934 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10935 entry.tunnel_id = res->e_tag_id_val;
10937 ret = rte_eth_dev_filter_ctrl(res->port_id,
10938 RTE_ETH_FILTER_L2_TUNNEL,
10939 RTE_ETH_FILTER_DELETE,
10942 printf("E-tag filter programming error: (%s)\n",
10946 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10947 .f = cmd_config_e_tag_filter_del_parsed,
10949 .help_str = "E-tag ... : E-tag filter delete",
10951 (void *)&cmd_config_e_tag_e_tag,
10952 (void *)&cmd_config_e_tag_set,
10953 (void *)&cmd_config_e_tag_filter,
10954 (void *)&cmd_config_e_tag_del,
10955 (void *)&cmd_config_e_tag_e_tag_id,
10956 (void *)&cmd_config_e_tag_e_tag_id_val,
10957 (void *)&cmd_config_e_tag_port,
10958 (void *)&cmd_config_e_tag_port_id,
10963 /* vf vlan anti spoof configuration */
10965 /* Common result structure for vf vlan anti spoof */
10966 struct cmd_vf_vlan_anti_spoof_result {
10967 cmdline_fixed_string_t set;
10968 cmdline_fixed_string_t vf;
10969 cmdline_fixed_string_t vlan;
10970 cmdline_fixed_string_t antispoof;
10973 cmdline_fixed_string_t on_off;
10976 /* Common CLI fields for vf vlan anti spoof enable disable */
10977 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10978 TOKEN_STRING_INITIALIZER
10979 (struct cmd_vf_vlan_anti_spoof_result,
10981 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10982 TOKEN_STRING_INITIALIZER
10983 (struct cmd_vf_vlan_anti_spoof_result,
10985 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10986 TOKEN_STRING_INITIALIZER
10987 (struct cmd_vf_vlan_anti_spoof_result,
10989 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10990 TOKEN_STRING_INITIALIZER
10991 (struct cmd_vf_vlan_anti_spoof_result,
10992 antispoof, "antispoof");
10993 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10994 TOKEN_NUM_INITIALIZER
10995 (struct cmd_vf_vlan_anti_spoof_result,
10997 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10998 TOKEN_NUM_INITIALIZER
10999 (struct cmd_vf_vlan_anti_spoof_result,
11001 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11002 TOKEN_STRING_INITIALIZER
11003 (struct cmd_vf_vlan_anti_spoof_result,
11007 cmd_set_vf_vlan_anti_spoof_parsed(
11008 void *parsed_result,
11009 __attribute__((unused)) struct cmdline *cl,
11010 __attribute__((unused)) void *data)
11012 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11013 int ret = -ENOTSUP;
11015 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11017 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11020 #ifdef RTE_LIBRTE_IXGBE_PMD
11021 if (ret == -ENOTSUP)
11022 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11023 res->vf_id, is_on);
11025 #ifdef RTE_LIBRTE_I40E_PMD
11026 if (ret == -ENOTSUP)
11027 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11028 res->vf_id, is_on);
11035 printf("invalid vf_id %d\n", res->vf_id);
11038 printf("invalid port_id %d\n", res->port_id);
11041 printf("function not implemented\n");
11044 printf("programming error: (%s)\n", strerror(-ret));
11048 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11049 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11051 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11053 (void *)&cmd_vf_vlan_anti_spoof_set,
11054 (void *)&cmd_vf_vlan_anti_spoof_vf,
11055 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11056 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11057 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11058 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11059 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11064 /* vf mac anti spoof configuration */
11066 /* Common result structure for vf mac anti spoof */
11067 struct cmd_vf_mac_anti_spoof_result {
11068 cmdline_fixed_string_t set;
11069 cmdline_fixed_string_t vf;
11070 cmdline_fixed_string_t mac;
11071 cmdline_fixed_string_t antispoof;
11074 cmdline_fixed_string_t on_off;
11077 /* Common CLI fields for vf mac anti spoof enable disable */
11078 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11079 TOKEN_STRING_INITIALIZER
11080 (struct cmd_vf_mac_anti_spoof_result,
11082 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11083 TOKEN_STRING_INITIALIZER
11084 (struct cmd_vf_mac_anti_spoof_result,
11086 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11087 TOKEN_STRING_INITIALIZER
11088 (struct cmd_vf_mac_anti_spoof_result,
11090 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11091 TOKEN_STRING_INITIALIZER
11092 (struct cmd_vf_mac_anti_spoof_result,
11093 antispoof, "antispoof");
11094 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11095 TOKEN_NUM_INITIALIZER
11096 (struct cmd_vf_mac_anti_spoof_result,
11098 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11099 TOKEN_NUM_INITIALIZER
11100 (struct cmd_vf_mac_anti_spoof_result,
11102 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11103 TOKEN_STRING_INITIALIZER
11104 (struct cmd_vf_mac_anti_spoof_result,
11108 cmd_set_vf_mac_anti_spoof_parsed(
11109 void *parsed_result,
11110 __attribute__((unused)) struct cmdline *cl,
11111 __attribute__((unused)) void *data)
11113 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11114 int ret = -ENOTSUP;
11116 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11118 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11121 #ifdef RTE_LIBRTE_IXGBE_PMD
11122 if (ret == -ENOTSUP)
11123 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11124 res->vf_id, is_on);
11126 #ifdef RTE_LIBRTE_I40E_PMD
11127 if (ret == -ENOTSUP)
11128 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11129 res->vf_id, is_on);
11136 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11139 printf("invalid port_id %d\n", res->port_id);
11142 printf("function not implemented\n");
11145 printf("programming error: (%s)\n", strerror(-ret));
11149 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11150 .f = cmd_set_vf_mac_anti_spoof_parsed,
11152 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11154 (void *)&cmd_vf_mac_anti_spoof_set,
11155 (void *)&cmd_vf_mac_anti_spoof_vf,
11156 (void *)&cmd_vf_mac_anti_spoof_mac,
11157 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11158 (void *)&cmd_vf_mac_anti_spoof_port_id,
11159 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11160 (void *)&cmd_vf_mac_anti_spoof_on_off,
11165 /* vf vlan strip queue configuration */
11167 /* Common result structure for vf mac anti spoof */
11168 struct cmd_vf_vlan_stripq_result {
11169 cmdline_fixed_string_t set;
11170 cmdline_fixed_string_t vf;
11171 cmdline_fixed_string_t vlan;
11172 cmdline_fixed_string_t stripq;
11175 cmdline_fixed_string_t on_off;
11178 /* Common CLI fields for vf vlan strip enable disable */
11179 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11180 TOKEN_STRING_INITIALIZER
11181 (struct cmd_vf_vlan_stripq_result,
11183 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11184 TOKEN_STRING_INITIALIZER
11185 (struct cmd_vf_vlan_stripq_result,
11187 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11188 TOKEN_STRING_INITIALIZER
11189 (struct cmd_vf_vlan_stripq_result,
11191 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11192 TOKEN_STRING_INITIALIZER
11193 (struct cmd_vf_vlan_stripq_result,
11195 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11196 TOKEN_NUM_INITIALIZER
11197 (struct cmd_vf_vlan_stripq_result,
11199 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11200 TOKEN_NUM_INITIALIZER
11201 (struct cmd_vf_vlan_stripq_result,
11203 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11204 TOKEN_STRING_INITIALIZER
11205 (struct cmd_vf_vlan_stripq_result,
11209 cmd_set_vf_vlan_stripq_parsed(
11210 void *parsed_result,
11211 __attribute__((unused)) struct cmdline *cl,
11212 __attribute__((unused)) void *data)
11214 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11215 int ret = -ENOTSUP;
11217 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11219 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11222 #ifdef RTE_LIBRTE_IXGBE_PMD
11223 if (ret == -ENOTSUP)
11224 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11225 res->vf_id, is_on);
11227 #ifdef RTE_LIBRTE_I40E_PMD
11228 if (ret == -ENOTSUP)
11229 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11230 res->vf_id, is_on);
11237 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11240 printf("invalid port_id %d\n", res->port_id);
11243 printf("function not implemented\n");
11246 printf("programming error: (%s)\n", strerror(-ret));
11250 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11251 .f = cmd_set_vf_vlan_stripq_parsed,
11253 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11255 (void *)&cmd_vf_vlan_stripq_set,
11256 (void *)&cmd_vf_vlan_stripq_vf,
11257 (void *)&cmd_vf_vlan_stripq_vlan,
11258 (void *)&cmd_vf_vlan_stripq_stripq,
11259 (void *)&cmd_vf_vlan_stripq_port_id,
11260 (void *)&cmd_vf_vlan_stripq_vf_id,
11261 (void *)&cmd_vf_vlan_stripq_on_off,
11266 /* vf vlan insert configuration */
11268 /* Common result structure for vf vlan insert */
11269 struct cmd_vf_vlan_insert_result {
11270 cmdline_fixed_string_t set;
11271 cmdline_fixed_string_t vf;
11272 cmdline_fixed_string_t vlan;
11273 cmdline_fixed_string_t insert;
11279 /* Common CLI fields for vf vlan insert enable disable */
11280 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11281 TOKEN_STRING_INITIALIZER
11282 (struct cmd_vf_vlan_insert_result,
11284 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11285 TOKEN_STRING_INITIALIZER
11286 (struct cmd_vf_vlan_insert_result,
11288 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11289 TOKEN_STRING_INITIALIZER
11290 (struct cmd_vf_vlan_insert_result,
11292 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11293 TOKEN_STRING_INITIALIZER
11294 (struct cmd_vf_vlan_insert_result,
11296 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11297 TOKEN_NUM_INITIALIZER
11298 (struct cmd_vf_vlan_insert_result,
11300 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11301 TOKEN_NUM_INITIALIZER
11302 (struct cmd_vf_vlan_insert_result,
11304 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11305 TOKEN_NUM_INITIALIZER
11306 (struct cmd_vf_vlan_insert_result,
11310 cmd_set_vf_vlan_insert_parsed(
11311 void *parsed_result,
11312 __attribute__((unused)) struct cmdline *cl,
11313 __attribute__((unused)) void *data)
11315 struct cmd_vf_vlan_insert_result *res = parsed_result;
11316 int ret = -ENOTSUP;
11318 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11321 #ifdef RTE_LIBRTE_IXGBE_PMD
11322 if (ret == -ENOTSUP)
11323 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11326 #ifdef RTE_LIBRTE_I40E_PMD
11327 if (ret == -ENOTSUP)
11328 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11336 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11339 printf("invalid port_id %d\n", res->port_id);
11342 printf("function not implemented\n");
11345 printf("programming error: (%s)\n", strerror(-ret));
11349 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11350 .f = cmd_set_vf_vlan_insert_parsed,
11352 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11354 (void *)&cmd_vf_vlan_insert_set,
11355 (void *)&cmd_vf_vlan_insert_vf,
11356 (void *)&cmd_vf_vlan_insert_vlan,
11357 (void *)&cmd_vf_vlan_insert_insert,
11358 (void *)&cmd_vf_vlan_insert_port_id,
11359 (void *)&cmd_vf_vlan_insert_vf_id,
11360 (void *)&cmd_vf_vlan_insert_vlan_id,
11365 /* tx loopback configuration */
11367 /* Common result structure for tx loopback */
11368 struct cmd_tx_loopback_result {
11369 cmdline_fixed_string_t set;
11370 cmdline_fixed_string_t tx;
11371 cmdline_fixed_string_t loopback;
11373 cmdline_fixed_string_t on_off;
11376 /* Common CLI fields for tx loopback enable disable */
11377 cmdline_parse_token_string_t cmd_tx_loopback_set =
11378 TOKEN_STRING_INITIALIZER
11379 (struct cmd_tx_loopback_result,
11381 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11382 TOKEN_STRING_INITIALIZER
11383 (struct cmd_tx_loopback_result,
11385 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11386 TOKEN_STRING_INITIALIZER
11387 (struct cmd_tx_loopback_result,
11388 loopback, "loopback");
11389 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11390 TOKEN_NUM_INITIALIZER
11391 (struct cmd_tx_loopback_result,
11393 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11394 TOKEN_STRING_INITIALIZER
11395 (struct cmd_tx_loopback_result,
11399 cmd_set_tx_loopback_parsed(
11400 void *parsed_result,
11401 __attribute__((unused)) struct cmdline *cl,
11402 __attribute__((unused)) void *data)
11404 struct cmd_tx_loopback_result *res = parsed_result;
11405 int ret = -ENOTSUP;
11407 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11409 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11412 #ifdef RTE_LIBRTE_IXGBE_PMD
11413 if (ret == -ENOTSUP)
11414 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11416 #ifdef RTE_LIBRTE_I40E_PMD
11417 if (ret == -ENOTSUP)
11418 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11425 printf("invalid is_on %d\n", is_on);
11428 printf("invalid port_id %d\n", res->port_id);
11431 printf("function not implemented\n");
11434 printf("programming error: (%s)\n", strerror(-ret));
11438 cmdline_parse_inst_t cmd_set_tx_loopback = {
11439 .f = cmd_set_tx_loopback_parsed,
11441 .help_str = "set tx loopback <port_id> on|off",
11443 (void *)&cmd_tx_loopback_set,
11444 (void *)&cmd_tx_loopback_tx,
11445 (void *)&cmd_tx_loopback_loopback,
11446 (void *)&cmd_tx_loopback_port_id,
11447 (void *)&cmd_tx_loopback_on_off,
11452 #ifdef RTE_LIBRTE_IXGBE_PMD
11453 /* all queues drop enable configuration */
11455 /* Common result structure for all queues drop enable */
11456 struct cmd_all_queues_drop_en_result {
11457 cmdline_fixed_string_t set;
11458 cmdline_fixed_string_t all;
11459 cmdline_fixed_string_t queues;
11460 cmdline_fixed_string_t drop;
11462 cmdline_fixed_string_t on_off;
11465 /* Common CLI fields for tx loopback enable disable */
11466 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11467 TOKEN_STRING_INITIALIZER
11468 (struct cmd_all_queues_drop_en_result,
11470 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11471 TOKEN_STRING_INITIALIZER
11472 (struct cmd_all_queues_drop_en_result,
11474 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11475 TOKEN_STRING_INITIALIZER
11476 (struct cmd_all_queues_drop_en_result,
11478 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11479 TOKEN_STRING_INITIALIZER
11480 (struct cmd_all_queues_drop_en_result,
11482 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11483 TOKEN_NUM_INITIALIZER
11484 (struct cmd_all_queues_drop_en_result,
11486 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11487 TOKEN_STRING_INITIALIZER
11488 (struct cmd_all_queues_drop_en_result,
11492 cmd_set_all_queues_drop_en_parsed(
11493 void *parsed_result,
11494 __attribute__((unused)) struct cmdline *cl,
11495 __attribute__((unused)) void *data)
11497 struct cmd_all_queues_drop_en_result *res = parsed_result;
11499 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11501 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11504 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11509 printf("invalid is_on %d\n", is_on);
11512 printf("invalid port_id %d\n", res->port_id);
11515 printf("function not implemented\n");
11518 printf("programming error: (%s)\n", strerror(-ret));
11522 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11523 .f = cmd_set_all_queues_drop_en_parsed,
11525 .help_str = "set all queues drop <port_id> on|off",
11527 (void *)&cmd_all_queues_drop_en_set,
11528 (void *)&cmd_all_queues_drop_en_all,
11529 (void *)&cmd_all_queues_drop_en_queues,
11530 (void *)&cmd_all_queues_drop_en_drop,
11531 (void *)&cmd_all_queues_drop_en_port_id,
11532 (void *)&cmd_all_queues_drop_en_on_off,
11537 /* vf split drop enable configuration */
11539 /* Common result structure for vf split drop enable */
11540 struct cmd_vf_split_drop_en_result {
11541 cmdline_fixed_string_t set;
11542 cmdline_fixed_string_t vf;
11543 cmdline_fixed_string_t split;
11544 cmdline_fixed_string_t drop;
11547 cmdline_fixed_string_t on_off;
11550 /* Common CLI fields for vf split drop enable disable */
11551 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11552 TOKEN_STRING_INITIALIZER
11553 (struct cmd_vf_split_drop_en_result,
11555 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11556 TOKEN_STRING_INITIALIZER
11557 (struct cmd_vf_split_drop_en_result,
11559 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11560 TOKEN_STRING_INITIALIZER
11561 (struct cmd_vf_split_drop_en_result,
11563 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11564 TOKEN_STRING_INITIALIZER
11565 (struct cmd_vf_split_drop_en_result,
11567 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11568 TOKEN_NUM_INITIALIZER
11569 (struct cmd_vf_split_drop_en_result,
11571 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11572 TOKEN_NUM_INITIALIZER
11573 (struct cmd_vf_split_drop_en_result,
11575 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11576 TOKEN_STRING_INITIALIZER
11577 (struct cmd_vf_split_drop_en_result,
11581 cmd_set_vf_split_drop_en_parsed(
11582 void *parsed_result,
11583 __attribute__((unused)) struct cmdline *cl,
11584 __attribute__((unused)) void *data)
11586 struct cmd_vf_split_drop_en_result *res = parsed_result;
11588 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11590 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11593 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11599 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11602 printf("invalid port_id %d\n", res->port_id);
11605 printf("programming error: (%s)\n", strerror(-ret));
11609 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11610 .f = cmd_set_vf_split_drop_en_parsed,
11612 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11614 (void *)&cmd_vf_split_drop_en_set,
11615 (void *)&cmd_vf_split_drop_en_vf,
11616 (void *)&cmd_vf_split_drop_en_split,
11617 (void *)&cmd_vf_split_drop_en_drop,
11618 (void *)&cmd_vf_split_drop_en_port_id,
11619 (void *)&cmd_vf_split_drop_en_vf_id,
11620 (void *)&cmd_vf_split_drop_en_on_off,
11626 /* vf mac address configuration */
11628 /* Common result structure for vf mac address */
11629 struct cmd_set_vf_mac_addr_result {
11630 cmdline_fixed_string_t set;
11631 cmdline_fixed_string_t vf;
11632 cmdline_fixed_string_t mac;
11633 cmdline_fixed_string_t addr;
11636 struct ether_addr mac_addr;
11640 /* Common CLI fields for vf split drop enable disable */
11641 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11642 TOKEN_STRING_INITIALIZER
11643 (struct cmd_set_vf_mac_addr_result,
11645 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11646 TOKEN_STRING_INITIALIZER
11647 (struct cmd_set_vf_mac_addr_result,
11649 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11650 TOKEN_STRING_INITIALIZER
11651 (struct cmd_set_vf_mac_addr_result,
11653 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11654 TOKEN_STRING_INITIALIZER
11655 (struct cmd_set_vf_mac_addr_result,
11657 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11658 TOKEN_NUM_INITIALIZER
11659 (struct cmd_set_vf_mac_addr_result,
11661 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11662 TOKEN_NUM_INITIALIZER
11663 (struct cmd_set_vf_mac_addr_result,
11665 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11666 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11670 cmd_set_vf_mac_addr_parsed(
11671 void *parsed_result,
11672 __attribute__((unused)) struct cmdline *cl,
11673 __attribute__((unused)) void *data)
11675 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11676 int ret = -ENOTSUP;
11678 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11681 #ifdef RTE_LIBRTE_IXGBE_PMD
11682 if (ret == -ENOTSUP)
11683 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11686 #ifdef RTE_LIBRTE_I40E_PMD
11687 if (ret == -ENOTSUP)
11688 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11696 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11699 printf("invalid port_id %d\n", res->port_id);
11702 printf("function not implemented\n");
11705 printf("programming error: (%s)\n", strerror(-ret));
11709 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11710 .f = cmd_set_vf_mac_addr_parsed,
11712 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11714 (void *)&cmd_set_vf_mac_addr_set,
11715 (void *)&cmd_set_vf_mac_addr_vf,
11716 (void *)&cmd_set_vf_mac_addr_mac,
11717 (void *)&cmd_set_vf_mac_addr_addr,
11718 (void *)&cmd_set_vf_mac_addr_port_id,
11719 (void *)&cmd_set_vf_mac_addr_vf_id,
11720 (void *)&cmd_set_vf_mac_addr_mac_addr,
11725 #ifdef RTE_LIBRTE_IXGBE_PMD
11726 /* MACsec configuration */
11728 /* Common result structure for MACsec offload enable */
11729 struct cmd_macsec_offload_on_result {
11730 cmdline_fixed_string_t set;
11731 cmdline_fixed_string_t macsec;
11732 cmdline_fixed_string_t offload;
11734 cmdline_fixed_string_t on;
11735 cmdline_fixed_string_t encrypt;
11736 cmdline_fixed_string_t en_on_off;
11737 cmdline_fixed_string_t replay_protect;
11738 cmdline_fixed_string_t rp_on_off;
11741 /* Common CLI fields for MACsec offload disable */
11742 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11743 TOKEN_STRING_INITIALIZER
11744 (struct cmd_macsec_offload_on_result,
11746 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11747 TOKEN_STRING_INITIALIZER
11748 (struct cmd_macsec_offload_on_result,
11750 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11751 TOKEN_STRING_INITIALIZER
11752 (struct cmd_macsec_offload_on_result,
11753 offload, "offload");
11754 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11755 TOKEN_NUM_INITIALIZER
11756 (struct cmd_macsec_offload_on_result,
11758 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11759 TOKEN_STRING_INITIALIZER
11760 (struct cmd_macsec_offload_on_result,
11762 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11763 TOKEN_STRING_INITIALIZER
11764 (struct cmd_macsec_offload_on_result,
11765 encrypt, "encrypt");
11766 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11767 TOKEN_STRING_INITIALIZER
11768 (struct cmd_macsec_offload_on_result,
11769 en_on_off, "on#off");
11770 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11771 TOKEN_STRING_INITIALIZER
11772 (struct cmd_macsec_offload_on_result,
11773 replay_protect, "replay-protect");
11774 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11775 TOKEN_STRING_INITIALIZER
11776 (struct cmd_macsec_offload_on_result,
11777 rp_on_off, "on#off");
11780 cmd_set_macsec_offload_on_parsed(
11781 void *parsed_result,
11782 __attribute__((unused)) struct cmdline *cl,
11783 __attribute__((unused)) void *data)
11785 struct cmd_macsec_offload_on_result *res = parsed_result;
11787 portid_t port_id = res->port_id;
11788 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11789 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11791 if (port_id_is_invalid(port_id, ENABLED_WARN))
11794 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11795 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11801 printf("invalid port_id %d\n", port_id);
11804 printf("programming error: (%s)\n", strerror(-ret));
11808 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11809 .f = cmd_set_macsec_offload_on_parsed,
11811 .help_str = "set macsec offload <port_id> on "
11812 "encrypt on|off replay-protect on|off",
11814 (void *)&cmd_macsec_offload_on_set,
11815 (void *)&cmd_macsec_offload_on_macsec,
11816 (void *)&cmd_macsec_offload_on_offload,
11817 (void *)&cmd_macsec_offload_on_port_id,
11818 (void *)&cmd_macsec_offload_on_on,
11819 (void *)&cmd_macsec_offload_on_encrypt,
11820 (void *)&cmd_macsec_offload_on_en_on_off,
11821 (void *)&cmd_macsec_offload_on_replay_protect,
11822 (void *)&cmd_macsec_offload_on_rp_on_off,
11827 /* Common result structure for MACsec offload disable */
11828 struct cmd_macsec_offload_off_result {
11829 cmdline_fixed_string_t set;
11830 cmdline_fixed_string_t macsec;
11831 cmdline_fixed_string_t offload;
11833 cmdline_fixed_string_t off;
11836 /* Common CLI fields for MACsec offload disable */
11837 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11838 TOKEN_STRING_INITIALIZER
11839 (struct cmd_macsec_offload_off_result,
11841 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11842 TOKEN_STRING_INITIALIZER
11843 (struct cmd_macsec_offload_off_result,
11845 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11846 TOKEN_STRING_INITIALIZER
11847 (struct cmd_macsec_offload_off_result,
11848 offload, "offload");
11849 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11850 TOKEN_NUM_INITIALIZER
11851 (struct cmd_macsec_offload_off_result,
11853 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11854 TOKEN_STRING_INITIALIZER
11855 (struct cmd_macsec_offload_off_result,
11859 cmd_set_macsec_offload_off_parsed(
11860 void *parsed_result,
11861 __attribute__((unused)) struct cmdline *cl,
11862 __attribute__((unused)) void *data)
11864 struct cmd_macsec_offload_off_result *res = parsed_result;
11866 portid_t port_id = res->port_id;
11868 if (port_id_is_invalid(port_id, ENABLED_WARN))
11871 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11872 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11878 printf("invalid port_id %d\n", port_id);
11881 printf("programming error: (%s)\n", strerror(-ret));
11885 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11886 .f = cmd_set_macsec_offload_off_parsed,
11888 .help_str = "set macsec offload <port_id> off",
11890 (void *)&cmd_macsec_offload_off_set,
11891 (void *)&cmd_macsec_offload_off_macsec,
11892 (void *)&cmd_macsec_offload_off_offload,
11893 (void *)&cmd_macsec_offload_off_port_id,
11894 (void *)&cmd_macsec_offload_off_off,
11899 /* Common result structure for MACsec secure connection configure */
11900 struct cmd_macsec_sc_result {
11901 cmdline_fixed_string_t set;
11902 cmdline_fixed_string_t macsec;
11903 cmdline_fixed_string_t sc;
11904 cmdline_fixed_string_t tx_rx;
11906 struct ether_addr mac;
11910 /* Common CLI fields for MACsec secure connection configure */
11911 cmdline_parse_token_string_t cmd_macsec_sc_set =
11912 TOKEN_STRING_INITIALIZER
11913 (struct cmd_macsec_sc_result,
11915 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11916 TOKEN_STRING_INITIALIZER
11917 (struct cmd_macsec_sc_result,
11919 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11920 TOKEN_STRING_INITIALIZER
11921 (struct cmd_macsec_sc_result,
11923 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11924 TOKEN_STRING_INITIALIZER
11925 (struct cmd_macsec_sc_result,
11927 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11928 TOKEN_NUM_INITIALIZER
11929 (struct cmd_macsec_sc_result,
11931 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11932 TOKEN_ETHERADDR_INITIALIZER
11933 (struct cmd_macsec_sc_result,
11935 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11936 TOKEN_NUM_INITIALIZER
11937 (struct cmd_macsec_sc_result,
11941 cmd_set_macsec_sc_parsed(
11942 void *parsed_result,
11943 __attribute__((unused)) struct cmdline *cl,
11944 __attribute__((unused)) void *data)
11946 struct cmd_macsec_sc_result *res = parsed_result;
11948 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11951 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11952 res->mac.addr_bytes) :
11953 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11954 res->mac.addr_bytes, res->pi);
11959 printf("invalid port_id %d\n", res->port_id);
11962 printf("programming error: (%s)\n", strerror(-ret));
11966 cmdline_parse_inst_t cmd_set_macsec_sc = {
11967 .f = cmd_set_macsec_sc_parsed,
11969 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11971 (void *)&cmd_macsec_sc_set,
11972 (void *)&cmd_macsec_sc_macsec,
11973 (void *)&cmd_macsec_sc_sc,
11974 (void *)&cmd_macsec_sc_tx_rx,
11975 (void *)&cmd_macsec_sc_port_id,
11976 (void *)&cmd_macsec_sc_mac,
11977 (void *)&cmd_macsec_sc_pi,
11982 /* Common result structure for MACsec secure connection configure */
11983 struct cmd_macsec_sa_result {
11984 cmdline_fixed_string_t set;
11985 cmdline_fixed_string_t macsec;
11986 cmdline_fixed_string_t sa;
11987 cmdline_fixed_string_t tx_rx;
11992 cmdline_fixed_string_t key;
11995 /* Common CLI fields for MACsec secure connection configure */
11996 cmdline_parse_token_string_t cmd_macsec_sa_set =
11997 TOKEN_STRING_INITIALIZER
11998 (struct cmd_macsec_sa_result,
12000 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12001 TOKEN_STRING_INITIALIZER
12002 (struct cmd_macsec_sa_result,
12004 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12005 TOKEN_STRING_INITIALIZER
12006 (struct cmd_macsec_sa_result,
12008 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12009 TOKEN_STRING_INITIALIZER
12010 (struct cmd_macsec_sa_result,
12012 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12013 TOKEN_NUM_INITIALIZER
12014 (struct cmd_macsec_sa_result,
12016 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12017 TOKEN_NUM_INITIALIZER
12018 (struct cmd_macsec_sa_result,
12020 cmdline_parse_token_num_t cmd_macsec_sa_an =
12021 TOKEN_NUM_INITIALIZER
12022 (struct cmd_macsec_sa_result,
12024 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12025 TOKEN_NUM_INITIALIZER
12026 (struct cmd_macsec_sa_result,
12028 cmdline_parse_token_string_t cmd_macsec_sa_key =
12029 TOKEN_STRING_INITIALIZER
12030 (struct cmd_macsec_sa_result,
12034 cmd_set_macsec_sa_parsed(
12035 void *parsed_result,
12036 __attribute__((unused)) struct cmdline *cl,
12037 __attribute__((unused)) void *data)
12039 struct cmd_macsec_sa_result *res = parsed_result;
12041 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12042 uint8_t key[16] = { 0 };
12048 key_len = strlen(res->key) / 2;
12052 for (i = 0; i < key_len; i++) {
12053 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12056 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12059 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12063 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12064 res->idx, res->an, res->pn, key) :
12065 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12066 res->idx, res->an, res->pn, key);
12071 printf("invalid idx %d or an %d\n", res->idx, res->an);
12074 printf("invalid port_id %d\n", res->port_id);
12077 printf("programming error: (%s)\n", strerror(-ret));
12081 cmdline_parse_inst_t cmd_set_macsec_sa = {
12082 .f = cmd_set_macsec_sa_parsed,
12084 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12086 (void *)&cmd_macsec_sa_set,
12087 (void *)&cmd_macsec_sa_macsec,
12088 (void *)&cmd_macsec_sa_sa,
12089 (void *)&cmd_macsec_sa_tx_rx,
12090 (void *)&cmd_macsec_sa_port_id,
12091 (void *)&cmd_macsec_sa_idx,
12092 (void *)&cmd_macsec_sa_an,
12093 (void *)&cmd_macsec_sa_pn,
12094 (void *)&cmd_macsec_sa_key,
12100 /* VF unicast promiscuous mode configuration */
12102 /* Common result structure for VF unicast promiscuous mode */
12103 struct cmd_vf_promisc_result {
12104 cmdline_fixed_string_t set;
12105 cmdline_fixed_string_t vf;
12106 cmdline_fixed_string_t promisc;
12109 cmdline_fixed_string_t on_off;
12112 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12113 cmdline_parse_token_string_t cmd_vf_promisc_set =
12114 TOKEN_STRING_INITIALIZER
12115 (struct cmd_vf_promisc_result,
12117 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12118 TOKEN_STRING_INITIALIZER
12119 (struct cmd_vf_promisc_result,
12121 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12122 TOKEN_STRING_INITIALIZER
12123 (struct cmd_vf_promisc_result,
12124 promisc, "promisc");
12125 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12126 TOKEN_NUM_INITIALIZER
12127 (struct cmd_vf_promisc_result,
12129 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12130 TOKEN_NUM_INITIALIZER
12131 (struct cmd_vf_promisc_result,
12133 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12134 TOKEN_STRING_INITIALIZER
12135 (struct cmd_vf_promisc_result,
12139 cmd_set_vf_promisc_parsed(
12140 void *parsed_result,
12141 __attribute__((unused)) struct cmdline *cl,
12142 __attribute__((unused)) void *data)
12144 struct cmd_vf_promisc_result *res = parsed_result;
12145 int ret = -ENOTSUP;
12147 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12149 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12152 #ifdef RTE_LIBRTE_I40E_PMD
12153 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12154 res->vf_id, is_on);
12161 printf("invalid vf_id %d\n", res->vf_id);
12164 printf("invalid port_id %d\n", res->port_id);
12167 printf("function not implemented\n");
12170 printf("programming error: (%s)\n", strerror(-ret));
12174 cmdline_parse_inst_t cmd_set_vf_promisc = {
12175 .f = cmd_set_vf_promisc_parsed,
12177 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12178 "Set unicast promiscuous mode for a VF from the PF",
12180 (void *)&cmd_vf_promisc_set,
12181 (void *)&cmd_vf_promisc_vf,
12182 (void *)&cmd_vf_promisc_promisc,
12183 (void *)&cmd_vf_promisc_port_id,
12184 (void *)&cmd_vf_promisc_vf_id,
12185 (void *)&cmd_vf_promisc_on_off,
12190 /* VF multicast promiscuous mode configuration */
12192 /* Common result structure for VF multicast promiscuous mode */
12193 struct cmd_vf_allmulti_result {
12194 cmdline_fixed_string_t set;
12195 cmdline_fixed_string_t vf;
12196 cmdline_fixed_string_t allmulti;
12199 cmdline_fixed_string_t on_off;
12202 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12203 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12204 TOKEN_STRING_INITIALIZER
12205 (struct cmd_vf_allmulti_result,
12207 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12208 TOKEN_STRING_INITIALIZER
12209 (struct cmd_vf_allmulti_result,
12211 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12212 TOKEN_STRING_INITIALIZER
12213 (struct cmd_vf_allmulti_result,
12214 allmulti, "allmulti");
12215 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12216 TOKEN_NUM_INITIALIZER
12217 (struct cmd_vf_allmulti_result,
12219 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12220 TOKEN_NUM_INITIALIZER
12221 (struct cmd_vf_allmulti_result,
12223 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12224 TOKEN_STRING_INITIALIZER
12225 (struct cmd_vf_allmulti_result,
12229 cmd_set_vf_allmulti_parsed(
12230 void *parsed_result,
12231 __attribute__((unused)) struct cmdline *cl,
12232 __attribute__((unused)) void *data)
12234 struct cmd_vf_allmulti_result *res = parsed_result;
12235 int ret = -ENOTSUP;
12237 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12239 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12242 #ifdef RTE_LIBRTE_I40E_PMD
12243 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12244 res->vf_id, is_on);
12251 printf("invalid vf_id %d\n", res->vf_id);
12254 printf("invalid port_id %d\n", res->port_id);
12257 printf("function not implemented\n");
12260 printf("programming error: (%s)\n", strerror(-ret));
12264 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12265 .f = cmd_set_vf_allmulti_parsed,
12267 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12268 "Set multicast promiscuous mode for a VF from the PF",
12270 (void *)&cmd_vf_allmulti_set,
12271 (void *)&cmd_vf_allmulti_vf,
12272 (void *)&cmd_vf_allmulti_allmulti,
12273 (void *)&cmd_vf_allmulti_port_id,
12274 (void *)&cmd_vf_allmulti_vf_id,
12275 (void *)&cmd_vf_allmulti_on_off,
12280 /* vf broadcast mode configuration */
12282 /* Common result structure for vf broadcast */
12283 struct cmd_set_vf_broadcast_result {
12284 cmdline_fixed_string_t set;
12285 cmdline_fixed_string_t vf;
12286 cmdline_fixed_string_t broadcast;
12289 cmdline_fixed_string_t on_off;
12292 /* Common CLI fields for vf broadcast enable disable */
12293 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12294 TOKEN_STRING_INITIALIZER
12295 (struct cmd_set_vf_broadcast_result,
12297 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12298 TOKEN_STRING_INITIALIZER
12299 (struct cmd_set_vf_broadcast_result,
12301 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12302 TOKEN_STRING_INITIALIZER
12303 (struct cmd_set_vf_broadcast_result,
12304 broadcast, "broadcast");
12305 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12306 TOKEN_NUM_INITIALIZER
12307 (struct cmd_set_vf_broadcast_result,
12309 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12310 TOKEN_NUM_INITIALIZER
12311 (struct cmd_set_vf_broadcast_result,
12313 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12314 TOKEN_STRING_INITIALIZER
12315 (struct cmd_set_vf_broadcast_result,
12319 cmd_set_vf_broadcast_parsed(
12320 void *parsed_result,
12321 __attribute__((unused)) struct cmdline *cl,
12322 __attribute__((unused)) void *data)
12324 struct cmd_set_vf_broadcast_result *res = parsed_result;
12325 int ret = -ENOTSUP;
12327 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12329 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12332 #ifdef RTE_LIBRTE_I40E_PMD
12333 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12334 res->vf_id, is_on);
12341 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12344 printf("invalid port_id %d\n", res->port_id);
12347 printf("function not implemented\n");
12350 printf("programming error: (%s)\n", strerror(-ret));
12354 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12355 .f = cmd_set_vf_broadcast_parsed,
12357 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12359 (void *)&cmd_set_vf_broadcast_set,
12360 (void *)&cmd_set_vf_broadcast_vf,
12361 (void *)&cmd_set_vf_broadcast_broadcast,
12362 (void *)&cmd_set_vf_broadcast_port_id,
12363 (void *)&cmd_set_vf_broadcast_vf_id,
12364 (void *)&cmd_set_vf_broadcast_on_off,
12369 /* vf vlan tag configuration */
12371 /* Common result structure for vf vlan tag */
12372 struct cmd_set_vf_vlan_tag_result {
12373 cmdline_fixed_string_t set;
12374 cmdline_fixed_string_t vf;
12375 cmdline_fixed_string_t vlan;
12376 cmdline_fixed_string_t tag;
12379 cmdline_fixed_string_t on_off;
12382 /* Common CLI fields for vf vlan tag enable disable */
12383 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12384 TOKEN_STRING_INITIALIZER
12385 (struct cmd_set_vf_vlan_tag_result,
12387 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12388 TOKEN_STRING_INITIALIZER
12389 (struct cmd_set_vf_vlan_tag_result,
12391 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12392 TOKEN_STRING_INITIALIZER
12393 (struct cmd_set_vf_vlan_tag_result,
12395 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12396 TOKEN_STRING_INITIALIZER
12397 (struct cmd_set_vf_vlan_tag_result,
12399 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12400 TOKEN_NUM_INITIALIZER
12401 (struct cmd_set_vf_vlan_tag_result,
12403 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12404 TOKEN_NUM_INITIALIZER
12405 (struct cmd_set_vf_vlan_tag_result,
12407 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12408 TOKEN_STRING_INITIALIZER
12409 (struct cmd_set_vf_vlan_tag_result,
12413 cmd_set_vf_vlan_tag_parsed(
12414 void *parsed_result,
12415 __attribute__((unused)) struct cmdline *cl,
12416 __attribute__((unused)) void *data)
12418 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12419 int ret = -ENOTSUP;
12421 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12423 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12426 #ifdef RTE_LIBRTE_I40E_PMD
12427 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12428 res->vf_id, is_on);
12435 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12438 printf("invalid port_id %d\n", res->port_id);
12441 printf("function not implemented\n");
12444 printf("programming error: (%s)\n", strerror(-ret));
12448 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12449 .f = cmd_set_vf_vlan_tag_parsed,
12451 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12453 (void *)&cmd_set_vf_vlan_tag_set,
12454 (void *)&cmd_set_vf_vlan_tag_vf,
12455 (void *)&cmd_set_vf_vlan_tag_vlan,
12456 (void *)&cmd_set_vf_vlan_tag_tag,
12457 (void *)&cmd_set_vf_vlan_tag_port_id,
12458 (void *)&cmd_set_vf_vlan_tag_vf_id,
12459 (void *)&cmd_set_vf_vlan_tag_on_off,
12464 /* Common definition of VF and TC TX bandwidth configuration */
12465 struct cmd_vf_tc_bw_result {
12466 cmdline_fixed_string_t set;
12467 cmdline_fixed_string_t vf;
12468 cmdline_fixed_string_t tc;
12469 cmdline_fixed_string_t tx;
12470 cmdline_fixed_string_t min_bw;
12471 cmdline_fixed_string_t max_bw;
12472 cmdline_fixed_string_t strict_link_prio;
12477 cmdline_fixed_string_t bw_list;
12481 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12482 TOKEN_STRING_INITIALIZER
12483 (struct cmd_vf_tc_bw_result,
12485 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12486 TOKEN_STRING_INITIALIZER
12487 (struct cmd_vf_tc_bw_result,
12489 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12490 TOKEN_STRING_INITIALIZER
12491 (struct cmd_vf_tc_bw_result,
12493 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12494 TOKEN_STRING_INITIALIZER
12495 (struct cmd_vf_tc_bw_result,
12497 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12498 TOKEN_STRING_INITIALIZER
12499 (struct cmd_vf_tc_bw_result,
12500 strict_link_prio, "strict-link-priority");
12501 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12502 TOKEN_STRING_INITIALIZER
12503 (struct cmd_vf_tc_bw_result,
12504 min_bw, "min-bandwidth");
12505 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12506 TOKEN_STRING_INITIALIZER
12507 (struct cmd_vf_tc_bw_result,
12508 max_bw, "max-bandwidth");
12509 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12510 TOKEN_NUM_INITIALIZER
12511 (struct cmd_vf_tc_bw_result,
12513 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12514 TOKEN_NUM_INITIALIZER
12515 (struct cmd_vf_tc_bw_result,
12517 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12518 TOKEN_NUM_INITIALIZER
12519 (struct cmd_vf_tc_bw_result,
12521 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12522 TOKEN_NUM_INITIALIZER
12523 (struct cmd_vf_tc_bw_result,
12525 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12526 TOKEN_STRING_INITIALIZER
12527 (struct cmd_vf_tc_bw_result,
12529 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12530 TOKEN_NUM_INITIALIZER
12531 (struct cmd_vf_tc_bw_result,
12534 /* VF max bandwidth setting */
12536 cmd_vf_max_bw_parsed(
12537 void *parsed_result,
12538 __attribute__((unused)) struct cmdline *cl,
12539 __attribute__((unused)) void *data)
12541 struct cmd_vf_tc_bw_result *res = parsed_result;
12542 int ret = -ENOTSUP;
12544 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12547 #ifdef RTE_LIBRTE_I40E_PMD
12548 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12549 res->vf_id, res->bw);
12556 printf("invalid vf_id %d or bandwidth %d\n",
12557 res->vf_id, res->bw);
12560 printf("invalid port_id %d\n", res->port_id);
12563 printf("function not implemented\n");
12566 printf("programming error: (%s)\n", strerror(-ret));
12570 cmdline_parse_inst_t cmd_vf_max_bw = {
12571 .f = cmd_vf_max_bw_parsed,
12573 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12575 (void *)&cmd_vf_tc_bw_set,
12576 (void *)&cmd_vf_tc_bw_vf,
12577 (void *)&cmd_vf_tc_bw_tx,
12578 (void *)&cmd_vf_tc_bw_max_bw,
12579 (void *)&cmd_vf_tc_bw_port_id,
12580 (void *)&cmd_vf_tc_bw_vf_id,
12581 (void *)&cmd_vf_tc_bw_bw,
12587 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12592 const char *p, *p0 = str;
12599 p = strchr(p0, '(');
12601 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12605 p0 = strchr(p, ')');
12607 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12611 if (size >= sizeof(s)) {
12612 printf("The string size exceeds the internal buffer size\n");
12615 snprintf(s, sizeof(s), "%.*s", size, p);
12616 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12618 printf("Failed to get the bandwidth list. ");
12622 for (i = 0; i < ret; i++)
12623 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12628 /* TC min bandwidth setting */
12630 cmd_vf_tc_min_bw_parsed(
12631 void *parsed_result,
12632 __attribute__((unused)) struct cmdline *cl,
12633 __attribute__((unused)) void *data)
12635 struct cmd_vf_tc_bw_result *res = parsed_result;
12638 int ret = -ENOTSUP;
12640 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12643 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12647 #ifdef RTE_LIBRTE_I40E_PMD
12648 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12656 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12659 printf("invalid port_id %d\n", res->port_id);
12662 printf("function not implemented\n");
12665 printf("programming error: (%s)\n", strerror(-ret));
12669 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12670 .f = cmd_vf_tc_min_bw_parsed,
12672 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12673 " <bw1, bw2, ...>",
12675 (void *)&cmd_vf_tc_bw_set,
12676 (void *)&cmd_vf_tc_bw_vf,
12677 (void *)&cmd_vf_tc_bw_tc,
12678 (void *)&cmd_vf_tc_bw_tx,
12679 (void *)&cmd_vf_tc_bw_min_bw,
12680 (void *)&cmd_vf_tc_bw_port_id,
12681 (void *)&cmd_vf_tc_bw_vf_id,
12682 (void *)&cmd_vf_tc_bw_bw_list,
12688 cmd_tc_min_bw_parsed(
12689 void *parsed_result,
12690 __attribute__((unused)) struct cmdline *cl,
12691 __attribute__((unused)) void *data)
12693 struct cmd_vf_tc_bw_result *res = parsed_result;
12694 struct rte_port *port;
12697 int ret = -ENOTSUP;
12699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12702 port = &ports[res->port_id];
12703 /** Check if the port is not started **/
12704 if (port->port_status != RTE_PORT_STOPPED) {
12705 printf("Please stop port %d first\n", res->port_id);
12709 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12713 #ifdef RTE_LIBRTE_IXGBE_PMD
12714 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12721 printf("invalid bandwidth\n");
12724 printf("invalid port_id %d\n", res->port_id);
12727 printf("function not implemented\n");
12730 printf("programming error: (%s)\n", strerror(-ret));
12734 cmdline_parse_inst_t cmd_tc_min_bw = {
12735 .f = cmd_tc_min_bw_parsed,
12737 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12739 (void *)&cmd_vf_tc_bw_set,
12740 (void *)&cmd_vf_tc_bw_tc,
12741 (void *)&cmd_vf_tc_bw_tx,
12742 (void *)&cmd_vf_tc_bw_min_bw,
12743 (void *)&cmd_vf_tc_bw_port_id,
12744 (void *)&cmd_vf_tc_bw_bw_list,
12749 /* TC max bandwidth setting */
12751 cmd_vf_tc_max_bw_parsed(
12752 void *parsed_result,
12753 __attribute__((unused)) struct cmdline *cl,
12754 __attribute__((unused)) void *data)
12756 struct cmd_vf_tc_bw_result *res = parsed_result;
12757 int ret = -ENOTSUP;
12759 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12762 #ifdef RTE_LIBRTE_I40E_PMD
12763 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12764 res->tc_no, res->bw);
12771 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12772 res->vf_id, res->tc_no, res->bw);
12775 printf("invalid port_id %d\n", res->port_id);
12778 printf("function not implemented\n");
12781 printf("programming error: (%s)\n", strerror(-ret));
12785 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12786 .f = cmd_vf_tc_max_bw_parsed,
12788 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12791 (void *)&cmd_vf_tc_bw_set,
12792 (void *)&cmd_vf_tc_bw_vf,
12793 (void *)&cmd_vf_tc_bw_tc,
12794 (void *)&cmd_vf_tc_bw_tx,
12795 (void *)&cmd_vf_tc_bw_max_bw,
12796 (void *)&cmd_vf_tc_bw_port_id,
12797 (void *)&cmd_vf_tc_bw_vf_id,
12798 (void *)&cmd_vf_tc_bw_tc_no,
12799 (void *)&cmd_vf_tc_bw_bw,
12804 /* Strict link priority scheduling mode setting */
12806 cmd_strict_link_prio_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_tc_strict_prio(res->port_id, res->tc_map);
12825 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12828 printf("invalid port_id %d\n", res->port_id);
12831 printf("function not implemented\n");
12834 printf("programming error: (%s)\n", strerror(-ret));
12838 cmdline_parse_inst_t cmd_strict_link_prio = {
12839 .f = cmd_strict_link_prio_parsed,
12841 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12843 (void *)&cmd_vf_tc_bw_set,
12844 (void *)&cmd_vf_tc_bw_tx,
12845 (void *)&cmd_vf_tc_bw_strict_link_prio,
12846 (void *)&cmd_vf_tc_bw_port_id,
12847 (void *)&cmd_vf_tc_bw_tc_map,
12852 /* Load dynamic device personalization*/
12853 struct cmd_ddp_add_result {
12854 cmdline_fixed_string_t ddp;
12855 cmdline_fixed_string_t add;
12860 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12861 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12862 cmdline_parse_token_string_t cmd_ddp_add_add =
12863 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12864 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12865 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12866 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12867 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12870 cmd_ddp_add_parsed(
12871 void *parsed_result,
12872 __attribute__((unused)) struct cmdline *cl,
12873 __attribute__((unused)) void *data)
12875 struct cmd_ddp_add_result *res = parsed_result;
12878 int ret = -ENOTSUP;
12880 if (res->port_id > nb_ports) {
12881 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12885 if (!all_ports_stopped()) {
12886 printf("Please stop all ports first\n");
12890 buff = open_ddp_package_file(res->filepath, &size);
12894 #ifdef RTE_LIBRTE_I40E_PMD
12895 if (ret == -ENOTSUP)
12896 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12898 RTE_PMD_I40E_PKG_OP_WR_ADD);
12902 printf("Failed to load profile.\n");
12904 printf("Profile has already existed.\n");
12906 close_ddp_package_file(buff);
12909 cmdline_parse_inst_t cmd_ddp_add = {
12910 .f = cmd_ddp_add_parsed,
12912 .help_str = "ddp add <port_id> <profile_path>",
12914 (void *)&cmd_ddp_add_ddp,
12915 (void *)&cmd_ddp_add_add,
12916 (void *)&cmd_ddp_add_port_id,
12917 (void *)&cmd_ddp_add_filepath,
12922 /* Get dynamic device personalization profile info list*/
12923 #define PROFILE_INFO_SIZE 48
12924 #define MAX_PROFILE_NUM 16
12926 struct cmd_ddp_get_list_result {
12927 cmdline_fixed_string_t ddp;
12928 cmdline_fixed_string_t get;
12929 cmdline_fixed_string_t list;
12933 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
12934 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
12935 cmdline_parse_token_string_t cmd_ddp_get_list_get =
12936 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
12937 cmdline_parse_token_string_t cmd_ddp_get_list_list =
12938 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
12939 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
12940 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
12943 cmd_ddp_get_list_parsed(
12944 void *parsed_result,
12945 __attribute__((unused)) struct cmdline *cl,
12946 __attribute__((unused)) void *data)
12948 struct cmd_ddp_get_list_result *res = parsed_result;
12949 #ifdef RTE_LIBRTE_I40E_PMD
12950 struct rte_pmd_i40e_profile_list *p_list;
12951 struct rte_pmd_i40e_profile_info *p_info;
12956 int ret = -ENOTSUP;
12958 if (res->port_id > nb_ports) {
12959 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12963 #ifdef RTE_LIBRTE_I40E_PMD
12964 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
12965 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
12967 printf("%s: Failed to malloc buffer\n", __func__);
12969 if (ret == -ENOTSUP)
12970 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
12971 (uint8_t *)p_list, size);
12974 p_num = p_list->p_count;
12975 printf("Profile number is: %d\n\n", p_num);
12977 for (i = 0; i < p_num; i++) {
12978 p_info = &p_list->p_info[i];
12979 printf("Profile %d:\n", i);
12980 printf("Track id: 0x%x\n", p_info->track_id);
12981 printf("Version: %d.%d.%d.%d\n",
12982 p_info->version.major,
12983 p_info->version.minor,
12984 p_info->version.update,
12985 p_info->version.draft);
12986 printf("Profile name: %s\n\n", p_info->name);
12994 printf("Failed to get ddp list\n");
12997 cmdline_parse_inst_t cmd_ddp_get_list = {
12998 .f = cmd_ddp_get_list_parsed,
13000 .help_str = "ddp get list <port_id>",
13002 (void *)&cmd_ddp_get_list_ddp,
13003 (void *)&cmd_ddp_get_list_get,
13004 (void *)&cmd_ddp_get_list_list,
13005 (void *)&cmd_ddp_get_list_port_id,
13010 /* show vf stats */
13012 /* Common result structure for show vf stats */
13013 struct cmd_show_vf_stats_result {
13014 cmdline_fixed_string_t show;
13015 cmdline_fixed_string_t vf;
13016 cmdline_fixed_string_t stats;
13021 /* Common CLI fields show vf stats*/
13022 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13023 TOKEN_STRING_INITIALIZER
13024 (struct cmd_show_vf_stats_result,
13026 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13027 TOKEN_STRING_INITIALIZER
13028 (struct cmd_show_vf_stats_result,
13030 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13031 TOKEN_STRING_INITIALIZER
13032 (struct cmd_show_vf_stats_result,
13034 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13035 TOKEN_NUM_INITIALIZER
13036 (struct cmd_show_vf_stats_result,
13038 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13039 TOKEN_NUM_INITIALIZER
13040 (struct cmd_show_vf_stats_result,
13044 cmd_show_vf_stats_parsed(
13045 void *parsed_result,
13046 __attribute__((unused)) struct cmdline *cl,
13047 __attribute__((unused)) void *data)
13049 struct cmd_show_vf_stats_result *res = parsed_result;
13050 struct rte_eth_stats stats;
13051 int ret = -ENOTSUP;
13052 static const char *nic_stats_border = "########################";
13054 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13057 memset(&stats, 0, sizeof(stats));
13059 #ifdef RTE_LIBRTE_I40E_PMD
13060 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13069 printf("invalid vf_id %d\n", res->vf_id);
13072 printf("invalid port_id %d\n", res->port_id);
13075 printf("function not implemented\n");
13078 printf("programming error: (%s)\n", strerror(-ret));
13081 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13082 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13084 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13086 stats.ipackets, stats.imissed, stats.ibytes);
13087 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13088 printf(" RX-nombuf: %-10"PRIu64"\n",
13090 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13092 stats.opackets, stats.oerrors, stats.obytes);
13094 printf(" %s############################%s\n",
13095 nic_stats_border, nic_stats_border);
13098 cmdline_parse_inst_t cmd_show_vf_stats = {
13099 .f = cmd_show_vf_stats_parsed,
13101 .help_str = "show vf stats <port_id> <vf_id>",
13103 (void *)&cmd_show_vf_stats_show,
13104 (void *)&cmd_show_vf_stats_vf,
13105 (void *)&cmd_show_vf_stats_stats,
13106 (void *)&cmd_show_vf_stats_port_id,
13107 (void *)&cmd_show_vf_stats_vf_id,
13112 /* clear vf stats */
13114 /* Common result structure for clear vf stats */
13115 struct cmd_clear_vf_stats_result {
13116 cmdline_fixed_string_t clear;
13117 cmdline_fixed_string_t vf;
13118 cmdline_fixed_string_t stats;
13123 /* Common CLI fields clear vf stats*/
13124 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13125 TOKEN_STRING_INITIALIZER
13126 (struct cmd_clear_vf_stats_result,
13128 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13129 TOKEN_STRING_INITIALIZER
13130 (struct cmd_clear_vf_stats_result,
13132 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13133 TOKEN_STRING_INITIALIZER
13134 (struct cmd_clear_vf_stats_result,
13136 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13137 TOKEN_NUM_INITIALIZER
13138 (struct cmd_clear_vf_stats_result,
13140 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13141 TOKEN_NUM_INITIALIZER
13142 (struct cmd_clear_vf_stats_result,
13146 cmd_clear_vf_stats_parsed(
13147 void *parsed_result,
13148 __attribute__((unused)) struct cmdline *cl,
13149 __attribute__((unused)) void *data)
13151 struct cmd_clear_vf_stats_result *res = parsed_result;
13152 int ret = -ENOTSUP;
13154 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13157 #ifdef RTE_LIBRTE_I40E_PMD
13158 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13166 printf("invalid vf_id %d\n", res->vf_id);
13169 printf("invalid port_id %d\n", res->port_id);
13172 printf("function not implemented\n");
13175 printf("programming error: (%s)\n", strerror(-ret));
13179 cmdline_parse_inst_t cmd_clear_vf_stats = {
13180 .f = cmd_clear_vf_stats_parsed,
13182 .help_str = "clear vf stats <port_id> <vf_id>",
13184 (void *)&cmd_clear_vf_stats_clear,
13185 (void *)&cmd_clear_vf_stats_vf,
13186 (void *)&cmd_clear_vf_stats_stats,
13187 (void *)&cmd_clear_vf_stats_port_id,
13188 (void *)&cmd_clear_vf_stats_vf_id,
13193 /* ptype mapping get */
13195 /* Common result structure for ptype mapping get */
13196 struct cmd_ptype_mapping_get_result {
13197 cmdline_fixed_string_t ptype;
13198 cmdline_fixed_string_t mapping;
13199 cmdline_fixed_string_t get;
13201 uint8_t valid_only;
13204 /* Common CLI fields for ptype mapping get */
13205 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
13206 TOKEN_STRING_INITIALIZER
13207 (struct cmd_ptype_mapping_get_result,
13209 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
13210 TOKEN_STRING_INITIALIZER
13211 (struct cmd_ptype_mapping_get_result,
13212 mapping, "mapping");
13213 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
13214 TOKEN_STRING_INITIALIZER
13215 (struct cmd_ptype_mapping_get_result,
13217 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
13218 TOKEN_NUM_INITIALIZER
13219 (struct cmd_ptype_mapping_get_result,
13221 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
13222 TOKEN_NUM_INITIALIZER
13223 (struct cmd_ptype_mapping_get_result,
13224 valid_only, UINT8);
13227 cmd_ptype_mapping_get_parsed(
13228 void *parsed_result,
13229 __attribute__((unused)) struct cmdline *cl,
13230 __attribute__((unused)) void *data)
13232 struct cmd_ptype_mapping_get_result *res = parsed_result;
13233 int ret = -ENOTSUP;
13234 #ifdef RTE_LIBRTE_I40E_PMD
13235 int max_ptype_num = 256;
13236 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
13241 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13244 #ifdef RTE_LIBRTE_I40E_PMD
13245 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
13256 printf("invalid port_id %d\n", res->port_id);
13259 printf("function not implemented\n");
13262 printf("programming error: (%s)\n", strerror(-ret));
13265 #ifdef RTE_LIBRTE_I40E_PMD
13267 for (i = 0; i < count; i++)
13268 printf("%3d\t0x%08x\n",
13269 mapping[i].hw_ptype, mapping[i].sw_ptype);
13274 cmdline_parse_inst_t cmd_ptype_mapping_get = {
13275 .f = cmd_ptype_mapping_get_parsed,
13277 .help_str = "ptype mapping get <port_id> <valid_only>",
13279 (void *)&cmd_ptype_mapping_get_ptype,
13280 (void *)&cmd_ptype_mapping_get_mapping,
13281 (void *)&cmd_ptype_mapping_get_get,
13282 (void *)&cmd_ptype_mapping_get_port_id,
13283 (void *)&cmd_ptype_mapping_get_valid_only,
13288 /* ptype mapping replace */
13290 /* Common result structure for ptype mapping replace */
13291 struct cmd_ptype_mapping_replace_result {
13292 cmdline_fixed_string_t ptype;
13293 cmdline_fixed_string_t mapping;
13294 cmdline_fixed_string_t replace;
13301 /* Common CLI fields for ptype mapping replace */
13302 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
13303 TOKEN_STRING_INITIALIZER
13304 (struct cmd_ptype_mapping_replace_result,
13306 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
13307 TOKEN_STRING_INITIALIZER
13308 (struct cmd_ptype_mapping_replace_result,
13309 mapping, "mapping");
13310 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
13311 TOKEN_STRING_INITIALIZER
13312 (struct cmd_ptype_mapping_replace_result,
13313 replace, "replace");
13314 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
13315 TOKEN_NUM_INITIALIZER
13316 (struct cmd_ptype_mapping_replace_result,
13318 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
13319 TOKEN_NUM_INITIALIZER
13320 (struct cmd_ptype_mapping_replace_result,
13322 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
13323 TOKEN_NUM_INITIALIZER
13324 (struct cmd_ptype_mapping_replace_result,
13326 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
13327 TOKEN_NUM_INITIALIZER
13328 (struct cmd_ptype_mapping_replace_result,
13332 cmd_ptype_mapping_replace_parsed(
13333 void *parsed_result,
13334 __attribute__((unused)) struct cmdline *cl,
13335 __attribute__((unused)) void *data)
13337 struct cmd_ptype_mapping_replace_result *res = parsed_result;
13338 int ret = -ENOTSUP;
13340 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13343 #ifdef RTE_LIBRTE_I40E_PMD
13344 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
13354 printf("invalid ptype 0x%8x or 0x%8x\n",
13355 res->target, res->pkt_type);
13358 printf("invalid port_id %d\n", res->port_id);
13361 printf("function not implemented\n");
13364 printf("programming error: (%s)\n", strerror(-ret));
13368 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
13369 .f = cmd_ptype_mapping_replace_parsed,
13372 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
13374 (void *)&cmd_ptype_mapping_replace_ptype,
13375 (void *)&cmd_ptype_mapping_replace_mapping,
13376 (void *)&cmd_ptype_mapping_replace_replace,
13377 (void *)&cmd_ptype_mapping_replace_port_id,
13378 (void *)&cmd_ptype_mapping_replace_target,
13379 (void *)&cmd_ptype_mapping_replace_mask,
13380 (void *)&cmd_ptype_mapping_replace_pkt_type,
13385 /* ptype mapping reset */
13387 /* Common result structure for ptype mapping reset */
13388 struct cmd_ptype_mapping_reset_result {
13389 cmdline_fixed_string_t ptype;
13390 cmdline_fixed_string_t mapping;
13391 cmdline_fixed_string_t reset;
13395 /* Common CLI fields for ptype mapping reset*/
13396 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
13397 TOKEN_STRING_INITIALIZER
13398 (struct cmd_ptype_mapping_reset_result,
13400 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
13401 TOKEN_STRING_INITIALIZER
13402 (struct cmd_ptype_mapping_reset_result,
13403 mapping, "mapping");
13404 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
13405 TOKEN_STRING_INITIALIZER
13406 (struct cmd_ptype_mapping_reset_result,
13408 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
13409 TOKEN_NUM_INITIALIZER
13410 (struct cmd_ptype_mapping_reset_result,
13414 cmd_ptype_mapping_reset_parsed(
13415 void *parsed_result,
13416 __attribute__((unused)) struct cmdline *cl,
13417 __attribute__((unused)) void *data)
13419 struct cmd_ptype_mapping_reset_result *res = parsed_result;
13420 int ret = -ENOTSUP;
13422 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13425 #ifdef RTE_LIBRTE_I40E_PMD
13426 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
13433 printf("invalid port_id %d\n", res->port_id);
13436 printf("function not implemented\n");
13439 printf("programming error: (%s)\n", strerror(-ret));
13443 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
13444 .f = cmd_ptype_mapping_reset_parsed,
13446 .help_str = "ptype mapping reset <port_id>",
13448 (void *)&cmd_ptype_mapping_reset_ptype,
13449 (void *)&cmd_ptype_mapping_reset_mapping,
13450 (void *)&cmd_ptype_mapping_reset_reset,
13451 (void *)&cmd_ptype_mapping_reset_port_id,
13456 /* ptype mapping update */
13458 /* Common result structure for ptype mapping update */
13459 struct cmd_ptype_mapping_update_result {
13460 cmdline_fixed_string_t ptype;
13461 cmdline_fixed_string_t mapping;
13462 cmdline_fixed_string_t reset;
13468 /* Common CLI fields for ptype mapping update*/
13469 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
13470 TOKEN_STRING_INITIALIZER
13471 (struct cmd_ptype_mapping_update_result,
13473 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
13474 TOKEN_STRING_INITIALIZER
13475 (struct cmd_ptype_mapping_update_result,
13476 mapping, "mapping");
13477 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
13478 TOKEN_STRING_INITIALIZER
13479 (struct cmd_ptype_mapping_update_result,
13481 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
13482 TOKEN_NUM_INITIALIZER
13483 (struct cmd_ptype_mapping_update_result,
13485 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
13486 TOKEN_NUM_INITIALIZER
13487 (struct cmd_ptype_mapping_update_result,
13489 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
13490 TOKEN_NUM_INITIALIZER
13491 (struct cmd_ptype_mapping_update_result,
13495 cmd_ptype_mapping_update_parsed(
13496 void *parsed_result,
13497 __attribute__((unused)) struct cmdline *cl,
13498 __attribute__((unused)) void *data)
13500 struct cmd_ptype_mapping_update_result *res = parsed_result;
13501 int ret = -ENOTSUP;
13502 #ifdef RTE_LIBRTE_I40E_PMD
13503 struct rte_pmd_i40e_ptype_mapping mapping;
13505 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13508 #ifdef RTE_LIBRTE_I40E_PMD
13509 mapping.hw_ptype = res->hw_ptype;
13510 mapping.sw_ptype = res->sw_ptype;
13511 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
13521 printf("invalid ptype 0x%8x\n", res->sw_ptype);
13524 printf("invalid port_id %d\n", res->port_id);
13527 printf("function not implemented\n");
13530 printf("programming error: (%s)\n", strerror(-ret));
13534 cmdline_parse_inst_t cmd_ptype_mapping_update = {
13535 .f = cmd_ptype_mapping_update_parsed,
13537 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
13539 (void *)&cmd_ptype_mapping_update_ptype,
13540 (void *)&cmd_ptype_mapping_update_mapping,
13541 (void *)&cmd_ptype_mapping_update_update,
13542 (void *)&cmd_ptype_mapping_update_port_id,
13543 (void *)&cmd_ptype_mapping_update_hw_ptype,
13544 (void *)&cmd_ptype_mapping_update_sw_ptype,
13549 /* Common result structure for file commands */
13550 struct cmd_cmdfile_result {
13551 cmdline_fixed_string_t load;
13552 cmdline_fixed_string_t filename;
13555 /* Common CLI fields for file commands */
13556 cmdline_parse_token_string_t cmd_load_cmdfile =
13557 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
13558 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
13559 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
13562 cmd_load_from_file_parsed(
13563 void *parsed_result,
13564 __attribute__((unused)) struct cmdline *cl,
13565 __attribute__((unused)) void *data)
13567 struct cmd_cmdfile_result *res = parsed_result;
13569 cmdline_read_from_file(res->filename);
13572 cmdline_parse_inst_t cmd_load_from_file = {
13573 .f = cmd_load_from_file_parsed,
13575 .help_str = "load <filename>",
13577 (void *)&cmd_load_cmdfile,
13578 (void *)&cmd_load_cmdfile_filename,
13583 /* ******************************************************************************** */
13585 /* list of instructions */
13586 cmdline_parse_ctx_t main_ctx[] = {
13587 (cmdline_parse_inst_t *)&cmd_help_brief,
13588 (cmdline_parse_inst_t *)&cmd_help_long,
13589 (cmdline_parse_inst_t *)&cmd_quit,
13590 (cmdline_parse_inst_t *)&cmd_load_from_file,
13591 (cmdline_parse_inst_t *)&cmd_showport,
13592 (cmdline_parse_inst_t *)&cmd_showqueue,
13593 (cmdline_parse_inst_t *)&cmd_showportall,
13594 (cmdline_parse_inst_t *)&cmd_showcfg,
13595 (cmdline_parse_inst_t *)&cmd_start,
13596 (cmdline_parse_inst_t *)&cmd_start_tx_first,
13597 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13598 (cmdline_parse_inst_t *)&cmd_set_link_up,
13599 (cmdline_parse_inst_t *)&cmd_set_link_down,
13600 (cmdline_parse_inst_t *)&cmd_reset,
13601 (cmdline_parse_inst_t *)&cmd_set_numbers,
13602 (cmdline_parse_inst_t *)&cmd_set_txpkts,
13603 (cmdline_parse_inst_t *)&cmd_set_txsplit,
13604 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13605 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13606 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13607 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13608 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13609 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13610 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13611 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13612 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13613 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13614 (cmdline_parse_inst_t *)&cmd_set_link_check,
13615 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
13616 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
13617 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
13618 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
13619 #ifdef RTE_LIBRTE_PMD_BOND
13620 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
13621 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
13622 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
13623 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
13624 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
13625 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
13626 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
13627 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
13628 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
13630 (cmdline_parse_inst_t *)&cmd_vlan_offload,
13631 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13632 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13633 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13634 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13635 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13636 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13637 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13638 (cmdline_parse_inst_t *)&cmd_csum_set,
13639 (cmdline_parse_inst_t *)&cmd_csum_show,
13640 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13641 (cmdline_parse_inst_t *)&cmd_tso_set,
13642 (cmdline_parse_inst_t *)&cmd_tso_show,
13643 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13644 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13645 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13646 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13647 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13648 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13649 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13650 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13651 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13652 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13653 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13654 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13655 (cmdline_parse_inst_t *)&cmd_config_dcb,
13656 (cmdline_parse_inst_t *)&cmd_read_reg,
13657 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
13658 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
13659 (cmdline_parse_inst_t *)&cmd_write_reg,
13660 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
13661 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
13662 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13663 (cmdline_parse_inst_t *)&cmd_stop,
13664 (cmdline_parse_inst_t *)&cmd_mac_addr,
13665 (cmdline_parse_inst_t *)&cmd_set_qmap,
13666 (cmdline_parse_inst_t *)&cmd_operate_port,
13667 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13668 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13669 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13670 (cmdline_parse_inst_t *)&cmd_config_speed_all,
13671 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13672 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13673 (cmdline_parse_inst_t *)&cmd_config_mtu,
13674 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13675 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13676 (cmdline_parse_inst_t *)&cmd_config_rss,
13677 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13678 (cmdline_parse_inst_t *)&cmd_config_txqflags,
13679 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13680 (cmdline_parse_inst_t *)&cmd_showport_reta,
13681 (cmdline_parse_inst_t *)&cmd_config_burst,
13682 (cmdline_parse_inst_t *)&cmd_config_thresh,
13683 (cmdline_parse_inst_t *)&cmd_config_threshold,
13684 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13685 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13686 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13687 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
13688 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13689 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
13690 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13691 (cmdline_parse_inst_t *)&cmd_global_config,
13692 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
13693 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
13694 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
13695 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13696 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13697 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13698 (cmdline_parse_inst_t *)&cmd_dump,
13699 (cmdline_parse_inst_t *)&cmd_dump_one,
13700 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
13701 (cmdline_parse_inst_t *)&cmd_syn_filter,
13702 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
13703 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
13704 (cmdline_parse_inst_t *)&cmd_flex_filter,
13705 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
13706 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
13707 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
13708 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
13709 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
13710 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
13711 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
13712 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
13713 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
13714 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
13715 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
13716 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
13717 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
13718 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
13719 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
13720 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
13721 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
13722 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
13723 (cmdline_parse_inst_t *)&cmd_flow,
13724 (cmdline_parse_inst_t *)&cmd_mcast_addr,
13725 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
13726 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
13727 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
13728 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
13729 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
13730 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
13731 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
13732 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
13733 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
13734 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
13735 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13736 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13737 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13738 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13739 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13740 #ifdef RTE_LIBRTE_IXGBE_PMD
13741 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13742 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
13743 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
13744 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
13745 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
13746 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
13747 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13748 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13749 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13751 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13752 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13753 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
13754 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
13755 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
13756 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
13757 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
13758 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
13759 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
13760 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
13761 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
13762 (cmdline_parse_inst_t *)&cmd_ddp_add,
13763 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
13764 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
13765 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
13766 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
13767 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
13768 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
13769 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
13773 /* read cmdline commands from file */
13775 cmdline_read_from_file(const char *filename)
13777 struct cmdline *cl;
13779 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
13781 printf("Failed to create file based cmdline context: %s\n",
13786 cmdline_interact(cl);
13791 printf("Read CLI commands from %s\n", filename);
13794 /* prompt function, called from main on MASTER lcore */
13798 /* initialize non-constant commands */
13799 cmd_set_fwd_mode_init();
13800 cmd_set_fwd_retry_mode_init();
13802 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13803 if (testpmd_cl == NULL)
13805 cmdline_interact(testpmd_cl);
13806 cmdline_stdin_exit(testpmd_cl);
13812 if (testpmd_cl != NULL)
13813 cmdline_quit(testpmd_cl);
13817 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13819 if (id == (portid_t)RTE_PORT_ALL) {
13822 RTE_ETH_FOREACH_DEV(pid) {
13823 /* check if need_reconfig has been set to 1 */
13824 if (ports[pid].need_reconfig == 0)
13825 ports[pid].need_reconfig = dev;
13826 /* check if need_reconfig_queues has been set to 1 */
13827 if (ports[pid].need_reconfig_queues == 0)
13828 ports[pid].need_reconfig_queues = queue;
13830 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13831 /* check if need_reconfig has been set to 1 */
13832 if (ports[id].need_reconfig == 0)
13833 ports[id].need_reconfig = dev;
13834 /* check if need_reconfig_queues has been set to 1 */
13835 if (ports[id].need_reconfig_queues == 0)
13836 ports[id].need_reconfig_queues = queue;