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"
220 if (show_all || !strcmp(res->section, "config")) {
226 "Configuration changes only become active when"
227 " forwarding is started/restarted.\n\n"
230 " Reset forwarding to the default configuration.\n\n"
232 "set verbose (level)\n"
233 " Set the debug verbosity level X.\n\n"
236 " Set number of ports.\n\n"
239 " Set number of cores.\n\n"
241 "set coremask (mask)\n"
242 " Set the forwarding cores hexadecimal mask.\n\n"
244 "set portmask (mask)\n"
245 " Set the forwarding ports hexadecimal mask.\n\n"
248 " Set number of packets per burst.\n\n"
250 "set burst tx delay (microseconds) retry (num)\n"
251 " Set the transmit delay time and number of retries,"
252 " effective when retry is enabled.\n\n"
254 "set txpkts (x[,y]*)\n"
255 " Set the length of each segment of TXONLY"
256 " and optionally CSUM packets.\n\n"
258 "set txsplit (off|on|rand)\n"
259 " Set the split policy for the TX packets."
260 " Right now only applicable for CSUM and TXONLY"
263 "set corelist (x[,y]*)\n"
264 " Set the list of forwarding cores.\n\n"
266 "set portlist (x[,y]*)\n"
267 " Set the list of forwarding ports.\n\n"
269 "set tx loopback (port_id) (on|off)\n"
270 " Enable or disable tx loopback.\n\n"
272 #ifdef RTE_LIBRTE_IXGBE_PMD
273 "set all queues drop (port_id) (on|off)\n"
274 " Set drop enable bit for all queues.\n\n"
276 "set vf split drop (port_id) (vf_id) (on|off)\n"
277 " Set split drop enable bit for a VF from the PF.\n\n"
280 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
281 " Set MAC antispoof for a VF from the PF.\n\n"
283 #ifdef RTE_LIBRTE_IXGBE_PMD
284 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
285 " Enable MACsec offload.\n\n"
287 "set macsec offload (port_id) off\n"
288 " Disable MACsec offload.\n\n"
290 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
291 " Configure MACsec secure connection (SC).\n\n"
293 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
294 " Configure MACsec secure association (SA).\n\n"
297 "set vf broadcast (port_id) (vf_id) (on|off)\n"
298 " Set VF broadcast for a VF from the PF.\n\n"
300 "vlan set strip (on|off) (port_id)\n"
301 " Set the VLAN strip on a port.\n\n"
303 "vlan set stripq (on|off) (port_id,queue_id)\n"
304 " Set the VLAN strip for a queue on a port.\n\n"
306 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
307 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
309 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
310 " Set VLAN insert for a VF from the PF.\n\n"
312 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
313 " Set VLAN antispoof for a VF from the PF.\n\n"
315 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
316 " Set VLAN tag for a VF from the PF.\n\n"
318 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
319 " Set a VF's max bandwidth(Mbps).\n\n"
321 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
322 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
324 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
325 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
327 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
328 " Set some TCs' strict link priority mode on a physical port.\n\n"
330 "vlan set filter (on|off) (port_id)\n"
331 " Set the VLAN filter on a port.\n\n"
333 "vlan set qinq (on|off) (port_id)\n"
334 " Set the VLAN QinQ (extended queue in queue)"
337 "vlan set (inner|outer) tpid (value) (port_id)\n"
338 " Set the VLAN TPID for Packet Filtering on"
341 "rx_vlan add (vlan_id|all) (port_id)\n"
342 " Add a vlan_id, or all identifiers, to the set"
343 " of VLAN identifiers filtered by port_id.\n\n"
345 "rx_vlan rm (vlan_id|all) (port_id)\n"
346 " Remove a vlan_id, or all identifiers, from the set"
347 " of VLAN identifiers filtered by port_id.\n\n"
349 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
350 " Add a vlan_id, to the set of VLAN identifiers"
351 "filtered for VF(s) from port_id.\n\n"
353 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
354 " Remove a vlan_id, to the set of VLAN identifiers"
355 "filtered for VF(s) from port_id.\n\n"
357 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
358 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
359 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
360 " add a tunnel filter of a port.\n\n"
362 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
363 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
364 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
365 " remove a tunnel filter of a port.\n\n"
367 "rx_vxlan_port add (udp_port) (port_id)\n"
368 " Add an UDP port for VXLAN packet filter on a port\n\n"
370 "rx_vxlan_port rm (udp_port) (port_id)\n"
371 " Remove an UDP port for VXLAN packet filter on a port\n\n"
373 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
374 " Set hardware insertion of VLAN IDs (single or double VLAN "
375 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
377 "tx_vlan set pvid port_id vlan_id (on|off)\n"
378 " Set port based TX VLAN insertion.\n\n"
380 "tx_vlan reset (port_id)\n"
381 " Disable hardware insertion of a VLAN header in"
382 " packets sent on a port.\n\n"
384 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
385 " Select hardware or software calculation of the"
386 " checksum when transmitting a packet using the"
387 " csum forward engine.\n"
388 " ip|udp|tcp|sctp always concern the inner layer.\n"
389 " outer-ip concerns the outer IP layer in"
390 " case the packet is recognized as a tunnel packet by"
391 " the forward engine (vxlan, gre and ipip are supported)\n"
392 " Please check the NIC datasheet for HW limits.\n\n"
394 "csum parse-tunnel (on|off) (tx_port_id)\n"
395 " If disabled, treat tunnel packets as non-tunneled"
396 " packets (treat inner headers as payload). The port\n"
397 " argument is the port used for TX in csum forward"
400 "csum show (port_id)\n"
401 " Display tx checksum offload configuration\n\n"
403 "tso set (segsize) (portid)\n"
404 " Enable TCP Segmentation Offload in csum forward"
406 " Please check the NIC datasheet for HW limits.\n\n"
409 " Display the status of TCP Segmentation Offload.\n\n"
412 " Set packet forwarding mode.\n\n"
414 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
415 " Add a MAC address on port_id.\n\n"
417 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
418 " Remove a MAC address from port_id.\n\n"
420 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
421 " Set the default MAC address for port_id.\n\n"
423 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
424 " Add a MAC address for a VF on the port.\n\n"
426 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
427 " Set the MAC address for a VF from the PF.\n\n"
429 "set port (port_id) uta (mac_address|all) (on|off)\n"
430 " Add/Remove a or all unicast hash filter(s)"
433 "set promisc (port_id|all) (on|off)\n"
434 " Set the promiscuous mode on port_id, or all.\n\n"
436 "set allmulti (port_id|all) (on|off)\n"
437 " Set the allmulti mode on port_id, or all.\n\n"
439 "set vf promisc (port_id) (vf_id) (on|off)\n"
440 " Set unicast promiscuous mode for a VF from the PF.\n\n"
442 "set vf allmulti (port_id) (vf_id) (on|off)\n"
443 " Set multicast promiscuous mode for a VF from the PF.\n\n"
445 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
446 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
447 " (on|off) autoneg (on|off) (port_id)\n"
448 "set flow_ctrl rx (on|off) (portid)\n"
449 "set flow_ctrl tx (on|off) (portid)\n"
450 "set flow_ctrl high_water (high_water) (portid)\n"
451 "set flow_ctrl low_water (low_water) (portid)\n"
452 "set flow_ctrl pause_time (pause_time) (portid)\n"
453 "set flow_ctrl send_xon (send_xon) (portid)\n"
454 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
455 "set flow_ctrl autoneg (on|off) (port_id)\n"
456 " Set the link flow control parameter on a port.\n\n"
458 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
459 " (low_water) (pause_time) (priority) (port_id)\n"
460 " Set the priority flow control parameter on a"
463 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
464 " Set statistics mapping (qmapping 0..15) for RX/TX"
466 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
467 " on port 0 to mapping 5.\n\n"
469 "set port (port_id) vf (vf_id) rx|tx on|off\n"
470 " Enable/Disable a VF receive/tranmit from a port\n\n"
472 "set port (port_id) vf (vf_id) (mac_addr)"
473 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
474 " Add/Remove unicast or multicast MAC addr filter"
477 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
479 " AUPE:accepts untagged VLAN;"
480 "ROPE:accept unicast hash\n\n"
481 " BAM:accepts broadcast packets;"
482 "MPE:accepts all multicast packets\n\n"
483 " Enable/Disable a VF receive mode of a port\n\n"
485 "set port (port_id) queue (queue_id) rate (rate_num)\n"
486 " Set rate limit for a queue of a port\n\n"
488 "set port (port_id) vf (vf_id) rate (rate_num) "
489 "queue_mask (queue_mask_value)\n"
490 " Set rate limit for queues in VF of a port\n\n"
492 "set port (port_id) mirror-rule (rule_id)"
493 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
494 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
495 " Set pool or vlan type mirror rule on a port.\n"
496 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
497 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
500 "set port (port_id) mirror-rule (rule_id)"
501 " (uplink-mirror|downlink-mirror) dst-pool"
502 " (pool_id) (on|off)\n"
503 " Set uplink or downlink type mirror rule on a port.\n"
504 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
505 " 0 on' enable mirror income traffic to pool 0.\n\n"
507 "reset port (port_id) mirror-rule (rule_id)\n"
508 " Reset a mirror rule.\n\n"
510 "set flush_rx (on|off)\n"
511 " Flush (default) or don't flush RX streams before"
512 " forwarding. Mainly used with PCAP drivers.\n\n"
514 #ifdef RTE_NIC_BYPASS
515 "set bypass mode (normal|bypass|isolate) (port_id)\n"
516 " Set the bypass mode for the lowest port on bypass enabled"
519 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
520 "mode (normal|bypass|isolate) (port_id)\n"
521 " Set the event required to initiate specified bypass mode for"
522 " the lowest port on a bypass enabled NIC where:\n"
523 " timeout = enable bypass after watchdog timeout.\n"
524 " os_on = enable bypass when OS/board is powered on.\n"
525 " os_off = enable bypass when OS/board is powered off.\n"
526 " power_on = enable bypass when power supply is turned on.\n"
527 " power_off = enable bypass when power supply is turned off."
530 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
531 " Set the bypass watchdog timeout to 'n' seconds"
532 " where 0 = instant.\n\n"
534 "show bypass config (port_id)\n"
535 " Show the bypass configuration for a bypass enabled NIC"
536 " using the lowest port on the NIC.\n\n"
538 #ifdef RTE_LIBRTE_PMD_BOND
539 "create bonded device (mode) (socket)\n"
540 " Create a new bonded device with specific bonding mode and socket.\n\n"
542 "add bonding slave (slave_id) (port_id)\n"
543 " Add a slave device to a bonded device.\n\n"
545 "remove bonding slave (slave_id) (port_id)\n"
546 " Remove a slave device from a bonded device.\n\n"
548 "set bonding mode (value) (port_id)\n"
549 " Set the bonding mode on a bonded device.\n\n"
551 "set bonding primary (slave_id) (port_id)\n"
552 " Set the primary slave for a bonded device.\n\n"
554 "show bonding config (port_id)\n"
555 " Show the bonding config for port_id.\n\n"
557 "set bonding mac_addr (port_id) (address)\n"
558 " Set the MAC address of a bonded device.\n\n"
560 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
561 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
563 "set bonding mon_period (port_id) (value)\n"
564 " Set the bonding link status monitoring polling period in ms.\n\n"
566 "set link-up port (port_id)\n"
567 " Set link up for a port.\n\n"
569 "set link-down port (port_id)\n"
570 " Set link down for a port.\n\n"
572 "E-tag set insertion on port-tag-id (value)"
573 " port (port_id) vf (vf_id)\n"
574 " Enable E-tag insertion for a VF on a port\n\n"
576 "E-tag set insertion off port (port_id) vf (vf_id)\n"
577 " Disable E-tag insertion for a VF on a port\n\n"
579 "E-tag set stripping (on|off) port (port_id)\n"
580 " Enable/disable E-tag stripping on a port\n\n"
582 "E-tag set forwarding (on|off) port (port_id)\n"
583 " Enable/disable E-tag based forwarding"
586 "E-tag set filter add e-tag-id (value) dst-pool"
587 " (pool_id) port (port_id)\n"
588 " Add an E-tag forwarding filter on a port\n\n"
590 "E-tag set filter del e-tag-id (value) port (port_id)\n"
591 " Delete an E-tag forwarding filter on a port\n\n"
593 "ddp add (port_id) (profile_path)\n"
594 " Load a profile package on a port\n\n"
596 , list_pkt_forwarding_modes()
600 if (show_all || !strcmp(res->section, "ports")) {
606 "----------------\n\n"
608 "port start (port_id|all)\n"
609 " Start all ports or port_id.\n\n"
611 "port stop (port_id|all)\n"
612 " Stop all ports or port_id.\n\n"
614 "port close (port_id|all)\n"
615 " Close all ports or port_id.\n\n"
617 "port attach (ident)\n"
618 " Attach physical or virtual dev by pci address or virtual device name\n\n"
620 "port detach (port_id)\n"
621 " Detach physical or virtual dev by port_id\n\n"
623 "port config (port_id|all)"
624 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
625 " duplex (half|full|auto)\n"
626 " Set speed and duplex for all ports or port_id\n\n"
628 "port config all (rxq|txq|rxd|txd) (value)\n"
629 " Set number for rxq/txq/rxd/txd.\n\n"
631 "port config all max-pkt-len (value)\n"
632 " Set the max packet length.\n\n"
634 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
635 "hw-vlan-strip|hw-vlan-extend|drop-en)"
637 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
640 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
641 " Set the RSS mode.\n\n"
643 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
644 " Set the RSS redirection table.\n\n"
646 "port config (port_id) dcb vt (on|off) (traffic_class)"
648 " Set the DCB mode.\n\n"
650 "port config all burst (value)\n"
651 " Set the number of packets per burst.\n\n"
653 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
655 " Set the ring prefetch/host/writeback threshold"
656 " for tx/rx queue.\n\n"
658 "port config all (txfreet|txrst|rxfreet) (value)\n"
659 " Set free threshold for rx/tx, or set"
660 " tx rs bit threshold.\n\n"
661 "port config mtu X value\n"
662 " Set the MTU of port X to a given value\n\n"
664 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
665 " Start/stop a rx/tx queue of port X. Only take effect"
666 " when port X is started\n\n"
668 "port config (port_id|all) l2-tunnel E-tag ether-type"
670 " Set the value of E-tag ether-type.\n\n"
672 "port config (port_id|all) l2-tunnel E-tag"
673 " (enable|disable)\n"
674 " Enable/disable the E-tag support.\n\n"
678 if (show_all || !strcmp(res->section, "registers")) {
686 "read reg (port_id) (address)\n"
687 " Display value of a port register.\n\n"
689 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
690 " Display a port register bit field.\n\n"
692 "read regbit (port_id) (address) (bit_x)\n"
693 " Display a single port register bit.\n\n"
695 "write reg (port_id) (address) (value)\n"
696 " Set value of a port register.\n\n"
698 "write regfield (port_id) (address) (bit_x) (bit_y)"
700 " Set bit field of a port register.\n\n"
702 "write regbit (port_id) (address) (bit_x) (value)\n"
703 " Set single bit value of a port register.\n\n"
706 if (show_all || !strcmp(res->section, "filters")) {
714 "ethertype_filter (port_id) (add|del)"
715 " (mac_addr|mac_ignr) (mac_address) ethertype"
716 " (ether_type) (drop|fwd) queue (queue_id)\n"
717 " Add/Del an ethertype filter.\n\n"
719 "2tuple_filter (port_id) (add|del)"
720 " dst_port (dst_port_value) protocol (protocol_value)"
721 " mask (mask_value) tcp_flags (tcp_flags_value)"
722 " priority (prio_value) queue (queue_id)\n"
723 " Add/Del a 2tuple filter.\n\n"
725 "5tuple_filter (port_id) (add|del)"
726 " dst_ip (dst_address) src_ip (src_address)"
727 " dst_port (dst_port_value) src_port (src_port_value)"
728 " protocol (protocol_value)"
729 " mask (mask_value) tcp_flags (tcp_flags_value)"
730 " priority (prio_value) queue (queue_id)\n"
731 " Add/Del a 5tuple filter.\n\n"
733 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
734 " Add/Del syn filter.\n\n"
736 "flex_filter (port_id) (add|del) len (len_value)"
737 " bytes (bytes_value) mask (mask_value)"
738 " priority (prio_value) queue (queue_id)\n"
739 " Add/Del a flex filter.\n\n"
741 "flow_director_filter (port_id) mode IP (add|del|update)"
742 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
743 " src (src_ip_address) dst (dst_ip_address)"
744 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
745 " vlan (vlan_value) flexbytes (flexbytes_value)"
746 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
747 " fd_id (fd_id_value)\n"
748 " Add/Del an IP type flow director filter.\n\n"
750 "flow_director_filter (port_id) mode IP (add|del|update)"
751 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
752 " src (src_ip_address) (src_port)"
753 " dst (dst_ip_address) (dst_port)"
754 " tos (tos_value) ttl (ttl_value)"
755 " vlan (vlan_value) flexbytes (flexbytes_value)"
756 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
757 " fd_id (fd_id_value)\n"
758 " Add/Del an UDP/TCP type flow director filter.\n\n"
760 "flow_director_filter (port_id) mode IP (add|del|update)"
761 " flow (ipv4-sctp|ipv6-sctp)"
762 " src (src_ip_address) (src_port)"
763 " dst (dst_ip_address) (dst_port)"
764 " tag (verification_tag) "
765 " tos (tos_value) ttl (ttl_value)"
767 " flexbytes (flexbytes_value) (drop|fwd)"
768 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
769 " Add/Del a SCTP type flow director filter.\n\n"
771 "flow_director_filter (port_id) mode IP (add|del|update)"
772 " flow l2_payload ether (ethertype)"
773 " flexbytes (flexbytes_value) (drop|fwd)"
774 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
775 " Add/Del a l2 payload type flow director filter.\n\n"
777 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
778 " mac (mac_address) vlan (vlan_value)"
779 " flexbytes (flexbytes_value) (drop|fwd)"
780 " queue (queue_id) fd_id (fd_id_value)\n"
781 " Add/Del a MAC-VLAN flow director filter.\n\n"
783 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
784 " mac (mac_address) vlan (vlan_value)"
785 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
786 " flexbytes (flexbytes_value) (drop|fwd)"
787 " queue (queue_id) fd_id (fd_id_value)\n"
788 " Add/Del a Tunnel flow director filter.\n\n"
790 "flush_flow_director (port_id)\n"
791 " Flush all flow director entries of a device.\n\n"
793 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
794 " src_mask (ipv4_src) (ipv6_src) (src_port)"
795 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
796 " Set flow director IP mask.\n\n"
798 "flow_director_mask (port_id) mode MAC-VLAN"
799 " vlan (vlan_value)\n"
800 " Set flow director MAC-VLAN mask.\n\n"
802 "flow_director_mask (port_id) mode Tunnel"
803 " vlan (vlan_value) mac (mac_value)"
804 " tunnel-type (tunnel_type_value)"
805 " tunnel-id (tunnel_id_value)\n"
806 " Set flow director Tunnel mask.\n\n"
808 "flow_director_flex_mask (port_id)"
809 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
810 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
812 " Configure mask of flex payload.\n\n"
814 "flow_director_flex_payload (port_id)"
815 " (raw|l2|l3|l4) (config)\n"
816 " Configure flex payload selection.\n\n"
818 "get_sym_hash_ena_per_port (port_id)\n"
819 " get symmetric hash enable configuration per port.\n\n"
821 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
822 " set symmetric hash enable configuration per port"
823 " to enable or disable.\n\n"
825 "get_hash_global_config (port_id)\n"
826 " Get the global configurations of hash filters.\n\n"
828 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
829 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
830 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
831 " (enable|disable)\n"
832 " Set the global configurations of hash filters.\n\n"
834 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
835 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
836 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
837 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
838 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
839 "ipv6-next-header|udp-src-port|udp-dst-port|"
840 "tcp-src-port|tcp-dst-port|sctp-src-port|"
841 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
842 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
843 "fld-8th|none) (select|add)\n"
844 " Set the input set for hash.\n\n"
846 "set_fdir_input_set (port_id) "
847 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
848 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
849 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
850 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
851 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
852 "udp-dst-port|tcp-src-port|tcp-dst-port|"
853 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
855 " Set the input set for FDir.\n\n"
857 "flow validate {port_id}"
858 " [group {group_id}] [priority {level}]"
859 " [ingress] [egress]"
860 " pattern {item} [/ {item} [...]] / end"
861 " actions {action} [/ {action} [...]] / end\n"
862 " Check whether a flow rule can be created.\n\n"
864 "flow create {port_id}"
865 " [group {group_id}] [priority {level}]"
866 " [ingress] [egress]"
867 " pattern {item} [/ {item} [...]] / end"
868 " actions {action} [/ {action} [...]] / end\n"
869 " Create a flow rule.\n\n"
871 "flow destroy {port_id} rule {rule_id} [...]\n"
872 " Destroy specific flow rules.\n\n"
874 "flow flush {port_id}\n"
875 " Destroy all flow rules.\n\n"
877 "flow query {port_id} {rule_id} {action}\n"
878 " Query an existing flow rule.\n\n"
880 "flow list {port_id} [group {group_id}] [...]\n"
881 " List existing flow rules sorted by priority,"
882 " filtered by group identifiers.\n\n"
887 cmdline_parse_token_string_t cmd_help_long_help =
888 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
890 cmdline_parse_token_string_t cmd_help_long_section =
891 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
892 "all#control#display#config#"
893 "ports#registers#filters");
895 cmdline_parse_inst_t cmd_help_long = {
896 .f = cmd_help_long_parsed,
898 .help_str = "help all|control|display|config|ports|register|filters: "
901 (void *)&cmd_help_long_help,
902 (void *)&cmd_help_long_section,
908 /* *** start/stop/close all ports *** */
909 struct cmd_operate_port_result {
910 cmdline_fixed_string_t keyword;
911 cmdline_fixed_string_t name;
912 cmdline_fixed_string_t value;
915 static void cmd_operate_port_parsed(void *parsed_result,
916 __attribute__((unused)) struct cmdline *cl,
917 __attribute__((unused)) void *data)
919 struct cmd_operate_port_result *res = parsed_result;
921 if (!strcmp(res->name, "start"))
922 start_port(RTE_PORT_ALL);
923 else if (!strcmp(res->name, "stop"))
924 stop_port(RTE_PORT_ALL);
925 else if (!strcmp(res->name, "close"))
926 close_port(RTE_PORT_ALL);
928 printf("Unknown parameter\n");
931 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
932 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
934 cmdline_parse_token_string_t cmd_operate_port_all_port =
935 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
937 cmdline_parse_token_string_t cmd_operate_port_all_all =
938 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
940 cmdline_parse_inst_t cmd_operate_port = {
941 .f = cmd_operate_port_parsed,
943 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
945 (void *)&cmd_operate_port_all_cmd,
946 (void *)&cmd_operate_port_all_port,
947 (void *)&cmd_operate_port_all_all,
952 /* *** start/stop/close specific port *** */
953 struct cmd_operate_specific_port_result {
954 cmdline_fixed_string_t keyword;
955 cmdline_fixed_string_t name;
959 static void cmd_operate_specific_port_parsed(void *parsed_result,
960 __attribute__((unused)) struct cmdline *cl,
961 __attribute__((unused)) void *data)
963 struct cmd_operate_specific_port_result *res = parsed_result;
965 if (!strcmp(res->name, "start"))
966 start_port(res->value);
967 else if (!strcmp(res->name, "stop"))
968 stop_port(res->value);
969 else if (!strcmp(res->name, "close"))
970 close_port(res->value);
972 printf("Unknown parameter\n");
975 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
976 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
978 cmdline_parse_token_string_t cmd_operate_specific_port_port =
979 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
980 name, "start#stop#close");
981 cmdline_parse_token_num_t cmd_operate_specific_port_id =
982 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
985 cmdline_parse_inst_t cmd_operate_specific_port = {
986 .f = cmd_operate_specific_port_parsed,
988 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
990 (void *)&cmd_operate_specific_port_cmd,
991 (void *)&cmd_operate_specific_port_port,
992 (void *)&cmd_operate_specific_port_id,
997 /* *** attach a specified port *** */
998 struct cmd_operate_attach_port_result {
999 cmdline_fixed_string_t port;
1000 cmdline_fixed_string_t keyword;
1001 cmdline_fixed_string_t identifier;
1004 static void cmd_operate_attach_port_parsed(void *parsed_result,
1005 __attribute__((unused)) struct cmdline *cl,
1006 __attribute__((unused)) void *data)
1008 struct cmd_operate_attach_port_result *res = parsed_result;
1010 if (!strcmp(res->keyword, "attach"))
1011 attach_port(res->identifier);
1013 printf("Unknown parameter\n");
1016 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1017 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1019 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1020 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1022 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1023 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1026 cmdline_parse_inst_t cmd_operate_attach_port = {
1027 .f = cmd_operate_attach_port_parsed,
1029 .help_str = "port attach <identifier>: "
1030 "(identifier: pci address or virtual dev name)",
1032 (void *)&cmd_operate_attach_port_port,
1033 (void *)&cmd_operate_attach_port_keyword,
1034 (void *)&cmd_operate_attach_port_identifier,
1039 /* *** detach a specified port *** */
1040 struct cmd_operate_detach_port_result {
1041 cmdline_fixed_string_t port;
1042 cmdline_fixed_string_t keyword;
1046 static void cmd_operate_detach_port_parsed(void *parsed_result,
1047 __attribute__((unused)) struct cmdline *cl,
1048 __attribute__((unused)) void *data)
1050 struct cmd_operate_detach_port_result *res = parsed_result;
1052 if (!strcmp(res->keyword, "detach"))
1053 detach_port(res->port_id);
1055 printf("Unknown parameter\n");
1058 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1059 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1061 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1062 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1064 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1065 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1068 cmdline_parse_inst_t cmd_operate_detach_port = {
1069 .f = cmd_operate_detach_port_parsed,
1071 .help_str = "port detach <port_id>",
1073 (void *)&cmd_operate_detach_port_port,
1074 (void *)&cmd_operate_detach_port_keyword,
1075 (void *)&cmd_operate_detach_port_port_id,
1080 /* *** configure speed for all ports *** */
1081 struct cmd_config_speed_all {
1082 cmdline_fixed_string_t port;
1083 cmdline_fixed_string_t keyword;
1084 cmdline_fixed_string_t all;
1085 cmdline_fixed_string_t item1;
1086 cmdline_fixed_string_t item2;
1087 cmdline_fixed_string_t value1;
1088 cmdline_fixed_string_t value2;
1092 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1097 if (!strcmp(duplexstr, "half")) {
1098 duplex = ETH_LINK_HALF_DUPLEX;
1099 } else if (!strcmp(duplexstr, "full")) {
1100 duplex = ETH_LINK_FULL_DUPLEX;
1101 } else if (!strcmp(duplexstr, "auto")) {
1102 duplex = ETH_LINK_FULL_DUPLEX;
1104 printf("Unknown duplex parameter\n");
1108 if (!strcmp(speedstr, "10")) {
1109 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1110 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1111 } else if (!strcmp(speedstr, "100")) {
1112 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1113 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1115 if (duplex != ETH_LINK_FULL_DUPLEX) {
1116 printf("Invalid speed/duplex parameters\n");
1119 if (!strcmp(speedstr, "1000")) {
1120 *speed = ETH_LINK_SPEED_1G;
1121 } else if (!strcmp(speedstr, "10000")) {
1122 *speed = ETH_LINK_SPEED_10G;
1123 } else if (!strcmp(speedstr, "25000")) {
1124 *speed = ETH_LINK_SPEED_25G;
1125 } else if (!strcmp(speedstr, "40000")) {
1126 *speed = ETH_LINK_SPEED_40G;
1127 } else if (!strcmp(speedstr, "50000")) {
1128 *speed = ETH_LINK_SPEED_50G;
1129 } else if (!strcmp(speedstr, "100000")) {
1130 *speed = ETH_LINK_SPEED_100G;
1131 } else if (!strcmp(speedstr, "auto")) {
1132 *speed = ETH_LINK_SPEED_AUTONEG;
1134 printf("Unknown speed parameter\n");
1143 cmd_config_speed_all_parsed(void *parsed_result,
1144 __attribute__((unused)) struct cmdline *cl,
1145 __attribute__((unused)) void *data)
1147 struct cmd_config_speed_all *res = parsed_result;
1148 uint32_t link_speed;
1151 if (!all_ports_stopped()) {
1152 printf("Please stop all ports first\n");
1156 if (parse_and_check_speed_duplex(res->value1, res->value2,
1160 FOREACH_PORT(pid, ports) {
1161 ports[pid].dev_conf.link_speeds = link_speed;
1164 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1167 cmdline_parse_token_string_t cmd_config_speed_all_port =
1168 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1169 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1170 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1172 cmdline_parse_token_string_t cmd_config_speed_all_all =
1173 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1174 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1175 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1176 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1177 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1178 "10#100#1000#10000#25000#40000#50000#100000#auto");
1179 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1180 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1181 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1182 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1185 cmdline_parse_inst_t cmd_config_speed_all = {
1186 .f = cmd_config_speed_all_parsed,
1188 .help_str = "port config all speed "
1189 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1192 (void *)&cmd_config_speed_all_port,
1193 (void *)&cmd_config_speed_all_keyword,
1194 (void *)&cmd_config_speed_all_all,
1195 (void *)&cmd_config_speed_all_item1,
1196 (void *)&cmd_config_speed_all_value1,
1197 (void *)&cmd_config_speed_all_item2,
1198 (void *)&cmd_config_speed_all_value2,
1203 /* *** configure speed for specific port *** */
1204 struct cmd_config_speed_specific {
1205 cmdline_fixed_string_t port;
1206 cmdline_fixed_string_t keyword;
1208 cmdline_fixed_string_t item1;
1209 cmdline_fixed_string_t item2;
1210 cmdline_fixed_string_t value1;
1211 cmdline_fixed_string_t value2;
1215 cmd_config_speed_specific_parsed(void *parsed_result,
1216 __attribute__((unused)) struct cmdline *cl,
1217 __attribute__((unused)) void *data)
1219 struct cmd_config_speed_specific *res = parsed_result;
1220 uint32_t link_speed;
1222 if (!all_ports_stopped()) {
1223 printf("Please stop all ports first\n");
1227 if (port_id_is_invalid(res->id, ENABLED_WARN))
1230 if (parse_and_check_speed_duplex(res->value1, res->value2,
1234 ports[res->id].dev_conf.link_speeds = link_speed;
1236 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1240 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1241 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1243 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1244 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1246 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1247 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1248 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1249 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1251 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1252 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1253 "10#100#1000#10000#25000#40000#50000#100000#auto");
1254 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1255 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1257 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1258 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1261 cmdline_parse_inst_t cmd_config_speed_specific = {
1262 .f = cmd_config_speed_specific_parsed,
1264 .help_str = "port config <port_id> speed "
1265 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1268 (void *)&cmd_config_speed_specific_port,
1269 (void *)&cmd_config_speed_specific_keyword,
1270 (void *)&cmd_config_speed_specific_id,
1271 (void *)&cmd_config_speed_specific_item1,
1272 (void *)&cmd_config_speed_specific_value1,
1273 (void *)&cmd_config_speed_specific_item2,
1274 (void *)&cmd_config_speed_specific_value2,
1279 /* *** configure txq/rxq, txd/rxd *** */
1280 struct cmd_config_rx_tx {
1281 cmdline_fixed_string_t port;
1282 cmdline_fixed_string_t keyword;
1283 cmdline_fixed_string_t all;
1284 cmdline_fixed_string_t name;
1289 cmd_config_rx_tx_parsed(void *parsed_result,
1290 __attribute__((unused)) struct cmdline *cl,
1291 __attribute__((unused)) void *data)
1293 struct cmd_config_rx_tx *res = parsed_result;
1295 if (!all_ports_stopped()) {
1296 printf("Please stop all ports first\n");
1299 if (!strcmp(res->name, "rxq")) {
1300 if (!res->value && !nb_txq) {
1301 printf("Warning: Either rx or tx queues should be non zero\n");
1304 nb_rxq = res->value;
1306 else if (!strcmp(res->name, "txq")) {
1307 if (!res->value && !nb_rxq) {
1308 printf("Warning: Either rx or tx queues should be non zero\n");
1311 nb_txq = res->value;
1313 else if (!strcmp(res->name, "rxd")) {
1314 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1315 printf("rxd %d invalid - must be > 0 && <= %d\n",
1316 res->value, RTE_TEST_RX_DESC_MAX);
1319 nb_rxd = res->value;
1320 } else if (!strcmp(res->name, "txd")) {
1321 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1322 printf("txd %d invalid - must be > 0 && <= %d\n",
1323 res->value, RTE_TEST_TX_DESC_MAX);
1326 nb_txd = res->value;
1328 printf("Unknown parameter\n");
1336 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1339 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1340 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1341 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1342 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1343 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1344 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1345 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1346 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1348 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1349 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1351 cmdline_parse_inst_t cmd_config_rx_tx = {
1352 .f = cmd_config_rx_tx_parsed,
1354 .help_str = "port config all rxq|txq|rxd|txd <value>",
1356 (void *)&cmd_config_rx_tx_port,
1357 (void *)&cmd_config_rx_tx_keyword,
1358 (void *)&cmd_config_rx_tx_all,
1359 (void *)&cmd_config_rx_tx_name,
1360 (void *)&cmd_config_rx_tx_value,
1365 /* *** config max packet length *** */
1366 struct cmd_config_max_pkt_len_result {
1367 cmdline_fixed_string_t port;
1368 cmdline_fixed_string_t keyword;
1369 cmdline_fixed_string_t all;
1370 cmdline_fixed_string_t name;
1375 cmd_config_max_pkt_len_parsed(void *parsed_result,
1376 __attribute__((unused)) struct cmdline *cl,
1377 __attribute__((unused)) void *data)
1379 struct cmd_config_max_pkt_len_result *res = parsed_result;
1381 if (!all_ports_stopped()) {
1382 printf("Please stop all ports first\n");
1386 if (!strcmp(res->name, "max-pkt-len")) {
1387 if (res->value < ETHER_MIN_LEN) {
1388 printf("max-pkt-len can not be less than %d\n",
1392 if (res->value == rx_mode.max_rx_pkt_len)
1395 rx_mode.max_rx_pkt_len = res->value;
1396 if (res->value > ETHER_MAX_LEN)
1397 rx_mode.jumbo_frame = 1;
1399 rx_mode.jumbo_frame = 0;
1401 printf("Unknown parameter\n");
1407 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1410 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1411 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1413 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1414 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1416 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1419 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1420 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1422 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1423 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1426 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1427 .f = cmd_config_max_pkt_len_parsed,
1429 .help_str = "port config all max-pkt-len <value>",
1431 (void *)&cmd_config_max_pkt_len_port,
1432 (void *)&cmd_config_max_pkt_len_keyword,
1433 (void *)&cmd_config_max_pkt_len_all,
1434 (void *)&cmd_config_max_pkt_len_name,
1435 (void *)&cmd_config_max_pkt_len_value,
1440 /* *** configure port MTU *** */
1441 struct cmd_config_mtu_result {
1442 cmdline_fixed_string_t port;
1443 cmdline_fixed_string_t keyword;
1444 cmdline_fixed_string_t mtu;
1450 cmd_config_mtu_parsed(void *parsed_result,
1451 __attribute__((unused)) struct cmdline *cl,
1452 __attribute__((unused)) void *data)
1454 struct cmd_config_mtu_result *res = parsed_result;
1456 if (res->value < ETHER_MIN_LEN) {
1457 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1460 port_mtu_set(res->port_id, res->value);
1463 cmdline_parse_token_string_t cmd_config_mtu_port =
1464 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1466 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1467 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1469 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1470 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1472 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1473 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1474 cmdline_parse_token_num_t cmd_config_mtu_value =
1475 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1477 cmdline_parse_inst_t cmd_config_mtu = {
1478 .f = cmd_config_mtu_parsed,
1480 .help_str = "port config mtu <port_id> <value>",
1482 (void *)&cmd_config_mtu_port,
1483 (void *)&cmd_config_mtu_keyword,
1484 (void *)&cmd_config_mtu_mtu,
1485 (void *)&cmd_config_mtu_port_id,
1486 (void *)&cmd_config_mtu_value,
1491 /* *** configure rx mode *** */
1492 struct cmd_config_rx_mode_flag {
1493 cmdline_fixed_string_t port;
1494 cmdline_fixed_string_t keyword;
1495 cmdline_fixed_string_t all;
1496 cmdline_fixed_string_t name;
1497 cmdline_fixed_string_t value;
1501 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1502 __attribute__((unused)) struct cmdline *cl,
1503 __attribute__((unused)) void *data)
1505 struct cmd_config_rx_mode_flag *res = parsed_result;
1507 if (!all_ports_stopped()) {
1508 printf("Please stop all ports first\n");
1512 if (!strcmp(res->name, "crc-strip")) {
1513 if (!strcmp(res->value, "on"))
1514 rx_mode.hw_strip_crc = 1;
1515 else if (!strcmp(res->value, "off"))
1516 rx_mode.hw_strip_crc = 0;
1518 printf("Unknown parameter\n");
1521 } else if (!strcmp(res->name, "scatter")) {
1522 if (!strcmp(res->value, "on"))
1523 rx_mode.enable_scatter = 1;
1524 else if (!strcmp(res->value, "off"))
1525 rx_mode.enable_scatter = 0;
1527 printf("Unknown parameter\n");
1530 } else if (!strcmp(res->name, "rx-cksum")) {
1531 if (!strcmp(res->value, "on"))
1532 rx_mode.hw_ip_checksum = 1;
1533 else if (!strcmp(res->value, "off"))
1534 rx_mode.hw_ip_checksum = 0;
1536 printf("Unknown parameter\n");
1539 } else if (!strcmp(res->name, "hw-vlan")) {
1540 if (!strcmp(res->value, "on")) {
1541 rx_mode.hw_vlan_filter = 1;
1542 rx_mode.hw_vlan_strip = 1;
1544 else if (!strcmp(res->value, "off")) {
1545 rx_mode.hw_vlan_filter = 0;
1546 rx_mode.hw_vlan_strip = 0;
1549 printf("Unknown parameter\n");
1552 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1553 if (!strcmp(res->value, "on"))
1554 rx_mode.hw_vlan_filter = 1;
1555 else if (!strcmp(res->value, "off"))
1556 rx_mode.hw_vlan_filter = 0;
1558 printf("Unknown parameter\n");
1561 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1562 if (!strcmp(res->value, "on"))
1563 rx_mode.hw_vlan_strip = 1;
1564 else if (!strcmp(res->value, "off"))
1565 rx_mode.hw_vlan_strip = 0;
1567 printf("Unknown parameter\n");
1570 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1571 if (!strcmp(res->value, "on"))
1572 rx_mode.hw_vlan_extend = 1;
1573 else if (!strcmp(res->value, "off"))
1574 rx_mode.hw_vlan_extend = 0;
1576 printf("Unknown parameter\n");
1579 } else if (!strcmp(res->name, "drop-en")) {
1580 if (!strcmp(res->value, "on"))
1582 else if (!strcmp(res->value, "off"))
1585 printf("Unknown parameter\n");
1589 printf("Unknown parameter\n");
1595 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1598 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1599 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1600 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1601 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1603 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1604 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1605 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1606 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1607 "crc-strip#scatter#rx-cksum#hw-vlan#"
1608 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1609 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1610 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1613 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1614 .f = cmd_config_rx_mode_flag_parsed,
1616 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1617 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1619 (void *)&cmd_config_rx_mode_flag_port,
1620 (void *)&cmd_config_rx_mode_flag_keyword,
1621 (void *)&cmd_config_rx_mode_flag_all,
1622 (void *)&cmd_config_rx_mode_flag_name,
1623 (void *)&cmd_config_rx_mode_flag_value,
1628 /* *** configure rss *** */
1629 struct cmd_config_rss {
1630 cmdline_fixed_string_t port;
1631 cmdline_fixed_string_t keyword;
1632 cmdline_fixed_string_t all;
1633 cmdline_fixed_string_t name;
1634 cmdline_fixed_string_t value;
1638 cmd_config_rss_parsed(void *parsed_result,
1639 __attribute__((unused)) struct cmdline *cl,
1640 __attribute__((unused)) void *data)
1642 struct cmd_config_rss *res = parsed_result;
1643 struct rte_eth_rss_conf rss_conf;
1647 if (!strcmp(res->value, "all"))
1648 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1649 ETH_RSS_UDP | ETH_RSS_SCTP |
1651 else if (!strcmp(res->value, "ip"))
1652 rss_conf.rss_hf = ETH_RSS_IP;
1653 else if (!strcmp(res->value, "udp"))
1654 rss_conf.rss_hf = ETH_RSS_UDP;
1655 else if (!strcmp(res->value, "tcp"))
1656 rss_conf.rss_hf = ETH_RSS_TCP;
1657 else if (!strcmp(res->value, "sctp"))
1658 rss_conf.rss_hf = ETH_RSS_SCTP;
1659 else if (!strcmp(res->value, "ether"))
1660 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1661 else if (!strcmp(res->value, "port"))
1662 rss_conf.rss_hf = ETH_RSS_PORT;
1663 else if (!strcmp(res->value, "vxlan"))
1664 rss_conf.rss_hf = ETH_RSS_VXLAN;
1665 else if (!strcmp(res->value, "geneve"))
1666 rss_conf.rss_hf = ETH_RSS_GENEVE;
1667 else if (!strcmp(res->value, "nvgre"))
1668 rss_conf.rss_hf = ETH_RSS_NVGRE;
1669 else if (!strcmp(res->value, "none"))
1670 rss_conf.rss_hf = 0;
1672 printf("Unknown parameter\n");
1675 rss_conf.rss_key = NULL;
1676 for (i = 0; i < rte_eth_dev_count(); i++) {
1677 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1679 printf("Configuration of RSS hash at ethernet port %d "
1680 "failed with error (%d): %s.\n",
1681 i, -diag, strerror(-diag));
1685 cmdline_parse_token_string_t cmd_config_rss_port =
1686 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1687 cmdline_parse_token_string_t cmd_config_rss_keyword =
1688 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1689 cmdline_parse_token_string_t cmd_config_rss_all =
1690 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1691 cmdline_parse_token_string_t cmd_config_rss_name =
1692 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1693 cmdline_parse_token_string_t cmd_config_rss_value =
1694 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1695 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1697 cmdline_parse_inst_t cmd_config_rss = {
1698 .f = cmd_config_rss_parsed,
1700 .help_str = "port config all rss "
1701 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1703 (void *)&cmd_config_rss_port,
1704 (void *)&cmd_config_rss_keyword,
1705 (void *)&cmd_config_rss_all,
1706 (void *)&cmd_config_rss_name,
1707 (void *)&cmd_config_rss_value,
1712 /* *** configure rss hash key *** */
1713 struct cmd_config_rss_hash_key {
1714 cmdline_fixed_string_t port;
1715 cmdline_fixed_string_t config;
1717 cmdline_fixed_string_t rss_hash_key;
1718 cmdline_fixed_string_t rss_type;
1719 cmdline_fixed_string_t key;
1723 hexa_digit_to_value(char hexa_digit)
1725 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1726 return (uint8_t) (hexa_digit - '0');
1727 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1728 return (uint8_t) ((hexa_digit - 'a') + 10);
1729 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1730 return (uint8_t) ((hexa_digit - 'A') + 10);
1731 /* Invalid hexa digit */
1736 parse_and_check_key_hexa_digit(char *key, int idx)
1740 hexa_v = hexa_digit_to_value(key[idx]);
1742 printf("invalid key: character %c at position %d is not a "
1743 "valid hexa digit\n", key[idx], idx);
1748 cmd_config_rss_hash_key_parsed(void *parsed_result,
1749 __attribute__((unused)) struct cmdline *cl,
1750 __attribute__((unused)) void *data)
1752 struct cmd_config_rss_hash_key *res = parsed_result;
1753 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1757 struct rte_eth_dev_info dev_info;
1758 uint8_t hash_key_size;
1761 memset(&dev_info, 0, sizeof(dev_info));
1762 rte_eth_dev_info_get(res->port_id, &dev_info);
1763 if (dev_info.hash_key_size > 0 &&
1764 dev_info.hash_key_size <= sizeof(hash_key))
1765 hash_key_size = dev_info.hash_key_size;
1767 printf("dev_info did not provide a valid hash key size\n");
1770 /* Check the length of the RSS hash key */
1771 key_len = strlen(res->key);
1772 if (key_len != (hash_key_size * 2)) {
1773 printf("key length: %d invalid - key must be a string of %d"
1774 " hexa-decimal numbers\n",
1775 (int) key_len, hash_key_size * 2);
1778 /* Translate RSS hash key into binary representation */
1779 for (i = 0; i < hash_key_size; i++) {
1780 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1783 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1786 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1788 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1792 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1793 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1794 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1795 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1797 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1798 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1799 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1801 rss_hash_key, "rss-hash-key");
1802 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1803 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1804 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1805 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1806 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1807 "ipv6-tcp-ex#ipv6-udp-ex");
1808 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1809 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1811 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1812 .f = cmd_config_rss_hash_key_parsed,
1814 .help_str = "port config <port_id> rss-hash-key "
1815 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1816 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1817 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1818 "<string of hex digits (variable length, NIC dependent)>",
1820 (void *)&cmd_config_rss_hash_key_port,
1821 (void *)&cmd_config_rss_hash_key_config,
1822 (void *)&cmd_config_rss_hash_key_port_id,
1823 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1824 (void *)&cmd_config_rss_hash_key_rss_type,
1825 (void *)&cmd_config_rss_hash_key_value,
1830 /* *** configure port rxq/txq start/stop *** */
1831 struct cmd_config_rxtx_queue {
1832 cmdline_fixed_string_t port;
1834 cmdline_fixed_string_t rxtxq;
1836 cmdline_fixed_string_t opname;
1840 cmd_config_rxtx_queue_parsed(void *parsed_result,
1841 __attribute__((unused)) struct cmdline *cl,
1842 __attribute__((unused)) void *data)
1844 struct cmd_config_rxtx_queue *res = parsed_result;
1849 if (test_done == 0) {
1850 printf("Please stop forwarding first\n");
1854 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1857 if (port_is_started(res->portid) != 1) {
1858 printf("Please start port %u first\n", res->portid);
1862 if (!strcmp(res->rxtxq, "rxq"))
1864 else if (!strcmp(res->rxtxq, "txq"))
1867 printf("Unknown parameter\n");
1871 if (isrx && rx_queue_id_is_invalid(res->qid))
1873 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1876 if (!strcmp(res->opname, "start"))
1878 else if (!strcmp(res->opname, "stop"))
1881 printf("Unknown parameter\n");
1885 if (isstart && isrx)
1886 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1887 else if (!isstart && isrx)
1888 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1889 else if (isstart && !isrx)
1890 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1892 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1894 if (ret == -ENOTSUP)
1895 printf("Function not supported in PMD driver\n");
1898 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1899 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1900 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1901 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1902 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1903 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1904 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1905 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1906 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1907 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1910 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1911 .f = cmd_config_rxtx_queue_parsed,
1913 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1915 (void *)&cmd_config_speed_all_port,
1916 (void *)&cmd_config_rxtx_queue_portid,
1917 (void *)&cmd_config_rxtx_queue_rxtxq,
1918 (void *)&cmd_config_rxtx_queue_qid,
1919 (void *)&cmd_config_rxtx_queue_opname,
1924 /* *** Configure RSS RETA *** */
1925 struct cmd_config_rss_reta {
1926 cmdline_fixed_string_t port;
1927 cmdline_fixed_string_t keyword;
1929 cmdline_fixed_string_t name;
1930 cmdline_fixed_string_t list_name;
1931 cmdline_fixed_string_t list_of_items;
1935 parse_reta_config(const char *str,
1936 struct rte_eth_rss_reta_entry64 *reta_conf,
1937 uint16_t nb_entries)
1941 uint16_t hash_index, idx, shift;
1944 const char *p, *p0 = str;
1951 unsigned long int_fld[_NUM_FLD];
1952 char *str_fld[_NUM_FLD];
1954 while ((p = strchr(p0,'(')) != NULL) {
1956 if((p0 = strchr(p,')')) == NULL)
1960 if(size >= sizeof(s))
1963 snprintf(s, sizeof(s), "%.*s", size, p);
1964 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1966 for (i = 0; i < _NUM_FLD; i++) {
1968 int_fld[i] = strtoul(str_fld[i], &end, 0);
1969 if (errno != 0 || end == str_fld[i] ||
1974 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1975 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1977 if (hash_index >= nb_entries) {
1978 printf("Invalid RETA hash index=%d\n", hash_index);
1982 idx = hash_index / RTE_RETA_GROUP_SIZE;
1983 shift = hash_index % RTE_RETA_GROUP_SIZE;
1984 reta_conf[idx].mask |= (1ULL << shift);
1985 reta_conf[idx].reta[shift] = nb_queue;
1992 cmd_set_rss_reta_parsed(void *parsed_result,
1993 __attribute__((unused)) struct cmdline *cl,
1994 __attribute__((unused)) void *data)
1997 struct rte_eth_dev_info dev_info;
1998 struct rte_eth_rss_reta_entry64 reta_conf[8];
1999 struct cmd_config_rss_reta *res = parsed_result;
2001 memset(&dev_info, 0, sizeof(dev_info));
2002 rte_eth_dev_info_get(res->port_id, &dev_info);
2003 if (dev_info.reta_size == 0) {
2004 printf("Redirection table size is 0 which is "
2005 "invalid for RSS\n");
2008 printf("The reta size of port %d is %u\n",
2009 res->port_id, dev_info.reta_size);
2010 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2011 printf("Currently do not support more than %u entries of "
2012 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2016 memset(reta_conf, 0, sizeof(reta_conf));
2017 if (!strcmp(res->list_name, "reta")) {
2018 if (parse_reta_config(res->list_of_items, reta_conf,
2019 dev_info.reta_size)) {
2020 printf("Invalid RSS Redirection Table "
2021 "config entered\n");
2024 ret = rte_eth_dev_rss_reta_update(res->port_id,
2025 reta_conf, dev_info.reta_size);
2027 printf("Bad redirection table parameter, "
2028 "return code = %d \n", ret);
2032 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2034 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2035 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2036 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2037 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2038 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2039 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2040 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2041 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2042 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2043 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2045 cmdline_parse_inst_t cmd_config_rss_reta = {
2046 .f = cmd_set_rss_reta_parsed,
2048 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2050 (void *)&cmd_config_rss_reta_port,
2051 (void *)&cmd_config_rss_reta_keyword,
2052 (void *)&cmd_config_rss_reta_port_id,
2053 (void *)&cmd_config_rss_reta_name,
2054 (void *)&cmd_config_rss_reta_list_name,
2055 (void *)&cmd_config_rss_reta_list_of_items,
2060 /* *** SHOW PORT RETA INFO *** */
2061 struct cmd_showport_reta {
2062 cmdline_fixed_string_t show;
2063 cmdline_fixed_string_t port;
2065 cmdline_fixed_string_t rss;
2066 cmdline_fixed_string_t reta;
2068 cmdline_fixed_string_t list_of_items;
2072 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2073 uint16_t nb_entries,
2077 const char *p, *p0 = str;
2081 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2084 p = strchr(p0, '(');
2088 p0 = strchr(p, ')');
2092 if (size >= sizeof(s)) {
2093 printf("The string size exceeds the internal buffer size\n");
2096 snprintf(s, sizeof(s), "%.*s", size, p);
2097 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2098 if (ret <= 0 || ret != num) {
2099 printf("The bits of masks do not match the number of "
2100 "reta entries: %u\n", num);
2103 for (i = 0; i < ret; i++)
2104 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2110 cmd_showport_reta_parsed(void *parsed_result,
2111 __attribute__((unused)) struct cmdline *cl,
2112 __attribute__((unused)) void *data)
2114 struct cmd_showport_reta *res = parsed_result;
2115 struct rte_eth_rss_reta_entry64 reta_conf[8];
2116 struct rte_eth_dev_info dev_info;
2118 memset(&dev_info, 0, sizeof(dev_info));
2119 rte_eth_dev_info_get(res->port_id, &dev_info);
2120 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2121 res->size > ETH_RSS_RETA_SIZE_512) {
2122 printf("Invalid redirection table size: %u\n", res->size);
2126 memset(reta_conf, 0, sizeof(reta_conf));
2127 if (showport_parse_reta_config(reta_conf, res->size,
2128 res->list_of_items) < 0) {
2129 printf("Invalid string: %s for reta masks\n",
2130 res->list_of_items);
2133 port_rss_reta_info(res->port_id, reta_conf, res->size);
2136 cmdline_parse_token_string_t cmd_showport_reta_show =
2137 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2138 cmdline_parse_token_string_t cmd_showport_reta_port =
2139 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2140 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2141 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2142 cmdline_parse_token_string_t cmd_showport_reta_rss =
2143 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2144 cmdline_parse_token_string_t cmd_showport_reta_reta =
2145 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2146 cmdline_parse_token_num_t cmd_showport_reta_size =
2147 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2148 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2149 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2150 list_of_items, NULL);
2152 cmdline_parse_inst_t cmd_showport_reta = {
2153 .f = cmd_showport_reta_parsed,
2155 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2157 (void *)&cmd_showport_reta_show,
2158 (void *)&cmd_showport_reta_port,
2159 (void *)&cmd_showport_reta_port_id,
2160 (void *)&cmd_showport_reta_rss,
2161 (void *)&cmd_showport_reta_reta,
2162 (void *)&cmd_showport_reta_size,
2163 (void *)&cmd_showport_reta_list_of_items,
2168 /* *** Show RSS hash configuration *** */
2169 struct cmd_showport_rss_hash {
2170 cmdline_fixed_string_t show;
2171 cmdline_fixed_string_t port;
2173 cmdline_fixed_string_t rss_hash;
2174 cmdline_fixed_string_t rss_type;
2175 cmdline_fixed_string_t key; /* optional argument */
2178 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2179 __attribute__((unused)) struct cmdline *cl,
2182 struct cmd_showport_rss_hash *res = parsed_result;
2184 port_rss_hash_conf_show(res->port_id, res->rss_type,
2185 show_rss_key != NULL);
2188 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2189 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2190 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2191 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2192 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2193 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2194 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2195 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2197 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2198 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2199 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2200 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2201 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2202 "ipv6-tcp-ex#ipv6-udp-ex");
2203 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2204 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2206 cmdline_parse_inst_t cmd_showport_rss_hash = {
2207 .f = cmd_showport_rss_hash_parsed,
2209 .help_str = "show port <port_id> rss-hash "
2210 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2211 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2212 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2214 (void *)&cmd_showport_rss_hash_show,
2215 (void *)&cmd_showport_rss_hash_port,
2216 (void *)&cmd_showport_rss_hash_port_id,
2217 (void *)&cmd_showport_rss_hash_rss_hash,
2218 (void *)&cmd_showport_rss_hash_rss_hash_info,
2223 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2224 .f = cmd_showport_rss_hash_parsed,
2226 .help_str = "show port <port_id> rss-hash "
2227 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2228 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2229 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2231 (void *)&cmd_showport_rss_hash_show,
2232 (void *)&cmd_showport_rss_hash_port,
2233 (void *)&cmd_showport_rss_hash_port_id,
2234 (void *)&cmd_showport_rss_hash_rss_hash,
2235 (void *)&cmd_showport_rss_hash_rss_hash_info,
2236 (void *)&cmd_showport_rss_hash_rss_key,
2241 /* *** Configure DCB *** */
2242 struct cmd_config_dcb {
2243 cmdline_fixed_string_t port;
2244 cmdline_fixed_string_t config;
2246 cmdline_fixed_string_t dcb;
2247 cmdline_fixed_string_t vt;
2248 cmdline_fixed_string_t vt_en;
2250 cmdline_fixed_string_t pfc;
2251 cmdline_fixed_string_t pfc_en;
2255 cmd_config_dcb_parsed(void *parsed_result,
2256 __attribute__((unused)) struct cmdline *cl,
2257 __attribute__((unused)) void *data)
2259 struct cmd_config_dcb *res = parsed_result;
2260 portid_t port_id = res->port_id;
2261 struct rte_port *port;
2265 port = &ports[port_id];
2266 /** Check if the port is not started **/
2267 if (port->port_status != RTE_PORT_STOPPED) {
2268 printf("Please stop port %d first\n", port_id);
2272 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2273 printf("The invalid number of traffic class,"
2274 " only 4 or 8 allowed.\n");
2278 if (nb_fwd_lcores < res->num_tcs) {
2279 printf("nb_cores shouldn't be less than number of TCs.\n");
2282 if (!strncmp(res->pfc_en, "on", 2))
2287 /* DCB in VT mode */
2288 if (!strncmp(res->vt_en, "on", 2))
2289 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2290 (enum rte_eth_nb_tcs)res->num_tcs,
2293 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2294 (enum rte_eth_nb_tcs)res->num_tcs,
2299 printf("Cannot initialize network ports.\n");
2303 cmd_reconfig_device_queue(port_id, 1, 1);
2306 cmdline_parse_token_string_t cmd_config_dcb_port =
2307 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2308 cmdline_parse_token_string_t cmd_config_dcb_config =
2309 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2310 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2311 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2312 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2313 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2314 cmdline_parse_token_string_t cmd_config_dcb_vt =
2315 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2316 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2317 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2318 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2319 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2320 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2321 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2322 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2323 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2325 cmdline_parse_inst_t cmd_config_dcb = {
2326 .f = cmd_config_dcb_parsed,
2328 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2330 (void *)&cmd_config_dcb_port,
2331 (void *)&cmd_config_dcb_config,
2332 (void *)&cmd_config_dcb_port_id,
2333 (void *)&cmd_config_dcb_dcb,
2334 (void *)&cmd_config_dcb_vt,
2335 (void *)&cmd_config_dcb_vt_en,
2336 (void *)&cmd_config_dcb_num_tcs,
2337 (void *)&cmd_config_dcb_pfc,
2338 (void *)&cmd_config_dcb_pfc_en,
2343 /* *** configure number of packets per burst *** */
2344 struct cmd_config_burst {
2345 cmdline_fixed_string_t port;
2346 cmdline_fixed_string_t keyword;
2347 cmdline_fixed_string_t all;
2348 cmdline_fixed_string_t name;
2353 cmd_config_burst_parsed(void *parsed_result,
2354 __attribute__((unused)) struct cmdline *cl,
2355 __attribute__((unused)) void *data)
2357 struct cmd_config_burst *res = parsed_result;
2359 if (!all_ports_stopped()) {
2360 printf("Please stop all ports first\n");
2364 if (!strcmp(res->name, "burst")) {
2365 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2366 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2369 nb_pkt_per_burst = res->value;
2371 printf("Unknown parameter\n");
2377 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2380 cmdline_parse_token_string_t cmd_config_burst_port =
2381 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2382 cmdline_parse_token_string_t cmd_config_burst_keyword =
2383 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2384 cmdline_parse_token_string_t cmd_config_burst_all =
2385 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2386 cmdline_parse_token_string_t cmd_config_burst_name =
2387 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2388 cmdline_parse_token_num_t cmd_config_burst_value =
2389 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2391 cmdline_parse_inst_t cmd_config_burst = {
2392 .f = cmd_config_burst_parsed,
2394 .help_str = "port config all burst <value>",
2396 (void *)&cmd_config_burst_port,
2397 (void *)&cmd_config_burst_keyword,
2398 (void *)&cmd_config_burst_all,
2399 (void *)&cmd_config_burst_name,
2400 (void *)&cmd_config_burst_value,
2405 /* *** configure rx/tx queues *** */
2406 struct cmd_config_thresh {
2407 cmdline_fixed_string_t port;
2408 cmdline_fixed_string_t keyword;
2409 cmdline_fixed_string_t all;
2410 cmdline_fixed_string_t name;
2415 cmd_config_thresh_parsed(void *parsed_result,
2416 __attribute__((unused)) struct cmdline *cl,
2417 __attribute__((unused)) void *data)
2419 struct cmd_config_thresh *res = parsed_result;
2421 if (!all_ports_stopped()) {
2422 printf("Please stop all ports first\n");
2426 if (!strcmp(res->name, "txpt"))
2427 tx_pthresh = res->value;
2428 else if(!strcmp(res->name, "txht"))
2429 tx_hthresh = res->value;
2430 else if(!strcmp(res->name, "txwt"))
2431 tx_wthresh = res->value;
2432 else if(!strcmp(res->name, "rxpt"))
2433 rx_pthresh = res->value;
2434 else if(!strcmp(res->name, "rxht"))
2435 rx_hthresh = res->value;
2436 else if(!strcmp(res->name, "rxwt"))
2437 rx_wthresh = res->value;
2439 printf("Unknown parameter\n");
2445 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2448 cmdline_parse_token_string_t cmd_config_thresh_port =
2449 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2450 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2451 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2452 cmdline_parse_token_string_t cmd_config_thresh_all =
2453 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2454 cmdline_parse_token_string_t cmd_config_thresh_name =
2455 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2456 "txpt#txht#txwt#rxpt#rxht#rxwt");
2457 cmdline_parse_token_num_t cmd_config_thresh_value =
2458 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2460 cmdline_parse_inst_t cmd_config_thresh = {
2461 .f = cmd_config_thresh_parsed,
2463 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2465 (void *)&cmd_config_thresh_port,
2466 (void *)&cmd_config_thresh_keyword,
2467 (void *)&cmd_config_thresh_all,
2468 (void *)&cmd_config_thresh_name,
2469 (void *)&cmd_config_thresh_value,
2474 /* *** configure free/rs threshold *** */
2475 struct cmd_config_threshold {
2476 cmdline_fixed_string_t port;
2477 cmdline_fixed_string_t keyword;
2478 cmdline_fixed_string_t all;
2479 cmdline_fixed_string_t name;
2484 cmd_config_threshold_parsed(void *parsed_result,
2485 __attribute__((unused)) struct cmdline *cl,
2486 __attribute__((unused)) void *data)
2488 struct cmd_config_threshold *res = parsed_result;
2490 if (!all_ports_stopped()) {
2491 printf("Please stop all ports first\n");
2495 if (!strcmp(res->name, "txfreet"))
2496 tx_free_thresh = res->value;
2497 else if (!strcmp(res->name, "txrst"))
2498 tx_rs_thresh = res->value;
2499 else if (!strcmp(res->name, "rxfreet"))
2500 rx_free_thresh = res->value;
2502 printf("Unknown parameter\n");
2508 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2511 cmdline_parse_token_string_t cmd_config_threshold_port =
2512 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2513 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2514 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2516 cmdline_parse_token_string_t cmd_config_threshold_all =
2517 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2518 cmdline_parse_token_string_t cmd_config_threshold_name =
2519 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2520 "txfreet#txrst#rxfreet");
2521 cmdline_parse_token_num_t cmd_config_threshold_value =
2522 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2524 cmdline_parse_inst_t cmd_config_threshold = {
2525 .f = cmd_config_threshold_parsed,
2527 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2529 (void *)&cmd_config_threshold_port,
2530 (void *)&cmd_config_threshold_keyword,
2531 (void *)&cmd_config_threshold_all,
2532 (void *)&cmd_config_threshold_name,
2533 (void *)&cmd_config_threshold_value,
2539 struct cmd_stop_result {
2540 cmdline_fixed_string_t stop;
2543 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2544 __attribute__((unused)) struct cmdline *cl,
2545 __attribute__((unused)) void *data)
2547 stop_packet_forwarding();
2550 cmdline_parse_token_string_t cmd_stop_stop =
2551 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2553 cmdline_parse_inst_t cmd_stop = {
2554 .f = cmd_stop_parsed,
2556 .help_str = "stop: Stop packet forwarding",
2558 (void *)&cmd_stop_stop,
2563 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2566 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2567 unsigned int *parsed_items, int check_unique_values)
2569 unsigned int nb_item;
2577 * First parse all items in the list and store their value.
2582 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2584 if ((c >= '0') && (c <= '9')) {
2585 value = (unsigned int) (value * 10 + (c - '0'));
2590 printf("character %c is not a decimal digit\n", c);
2594 printf("No valid value before comma\n");
2597 if (nb_item < max_items) {
2598 parsed_items[nb_item] = value;
2604 if (nb_item >= max_items) {
2605 printf("Number of %s = %u > %u (maximum items)\n",
2606 item_name, nb_item + 1, max_items);
2609 parsed_items[nb_item++] = value;
2610 if (! check_unique_values)
2614 * Then, check that all values in the list are differents.
2615 * No optimization here...
2617 for (i = 0; i < nb_item; i++) {
2618 for (j = i + 1; j < nb_item; j++) {
2619 if (parsed_items[j] == parsed_items[i]) {
2620 printf("duplicated %s %u at index %u and %u\n",
2621 item_name, parsed_items[i], i, j);
2629 struct cmd_set_list_result {
2630 cmdline_fixed_string_t cmd_keyword;
2631 cmdline_fixed_string_t list_name;
2632 cmdline_fixed_string_t list_of_items;
2635 static void cmd_set_list_parsed(void *parsed_result,
2636 __attribute__((unused)) struct cmdline *cl,
2637 __attribute__((unused)) void *data)
2639 struct cmd_set_list_result *res;
2641 unsigned int lcorelist[RTE_MAX_LCORE];
2642 unsigned int portlist[RTE_MAX_ETHPORTS];
2644 unsigned int nb_item;
2646 if (test_done == 0) {
2647 printf("Please stop forwarding first\n");
2651 res = parsed_result;
2652 if (!strcmp(res->list_name, "corelist")) {
2653 nb_item = parse_item_list(res->list_of_items, "core",
2655 parsed_items.lcorelist, 1);
2657 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2662 if (!strcmp(res->list_name, "portlist")) {
2663 nb_item = parse_item_list(res->list_of_items, "port",
2665 parsed_items.portlist, 1);
2667 set_fwd_ports_list(parsed_items.portlist, nb_item);
2673 cmdline_parse_token_string_t cmd_set_list_keyword =
2674 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2676 cmdline_parse_token_string_t cmd_set_list_name =
2677 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2678 "corelist#portlist");
2679 cmdline_parse_token_string_t cmd_set_list_of_items =
2680 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2683 cmdline_parse_inst_t cmd_set_fwd_list = {
2684 .f = cmd_set_list_parsed,
2686 .help_str = "set corelist|portlist <list0[,list1]*>",
2688 (void *)&cmd_set_list_keyword,
2689 (void *)&cmd_set_list_name,
2690 (void *)&cmd_set_list_of_items,
2695 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2697 struct cmd_setmask_result {
2698 cmdline_fixed_string_t set;
2699 cmdline_fixed_string_t mask;
2703 static void cmd_set_mask_parsed(void *parsed_result,
2704 __attribute__((unused)) struct cmdline *cl,
2705 __attribute__((unused)) void *data)
2707 struct cmd_setmask_result *res = parsed_result;
2709 if (test_done == 0) {
2710 printf("Please stop forwarding first\n");
2713 if (!strcmp(res->mask, "coremask")) {
2714 set_fwd_lcores_mask(res->hexavalue);
2716 } else if (!strcmp(res->mask, "portmask")) {
2717 set_fwd_ports_mask(res->hexavalue);
2722 cmdline_parse_token_string_t cmd_setmask_set =
2723 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2724 cmdline_parse_token_string_t cmd_setmask_mask =
2725 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2726 "coremask#portmask");
2727 cmdline_parse_token_num_t cmd_setmask_value =
2728 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2730 cmdline_parse_inst_t cmd_set_fwd_mask = {
2731 .f = cmd_set_mask_parsed,
2733 .help_str = "set coremask|portmask <hexadecimal value>",
2735 (void *)&cmd_setmask_set,
2736 (void *)&cmd_setmask_mask,
2737 (void *)&cmd_setmask_value,
2743 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2745 struct cmd_set_result {
2746 cmdline_fixed_string_t set;
2747 cmdline_fixed_string_t what;
2751 static void cmd_set_parsed(void *parsed_result,
2752 __attribute__((unused)) struct cmdline *cl,
2753 __attribute__((unused)) void *data)
2755 struct cmd_set_result *res = parsed_result;
2756 if (!strcmp(res->what, "nbport")) {
2757 set_fwd_ports_number(res->value);
2759 } else if (!strcmp(res->what, "nbcore")) {
2760 set_fwd_lcores_number(res->value);
2762 } else if (!strcmp(res->what, "burst"))
2763 set_nb_pkt_per_burst(res->value);
2764 else if (!strcmp(res->what, "verbose"))
2765 set_verbose_level(res->value);
2768 cmdline_parse_token_string_t cmd_set_set =
2769 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2770 cmdline_parse_token_string_t cmd_set_what =
2771 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2772 "nbport#nbcore#burst#verbose");
2773 cmdline_parse_token_num_t cmd_set_value =
2774 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2776 cmdline_parse_inst_t cmd_set_numbers = {
2777 .f = cmd_set_parsed,
2779 .help_str = "set nbport|nbcore|burst|verbose <value>",
2781 (void *)&cmd_set_set,
2782 (void *)&cmd_set_what,
2783 (void *)&cmd_set_value,
2788 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2790 struct cmd_set_txpkts_result {
2791 cmdline_fixed_string_t cmd_keyword;
2792 cmdline_fixed_string_t txpkts;
2793 cmdline_fixed_string_t seg_lengths;
2797 cmd_set_txpkts_parsed(void *parsed_result,
2798 __attribute__((unused)) struct cmdline *cl,
2799 __attribute__((unused)) void *data)
2801 struct cmd_set_txpkts_result *res;
2802 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2803 unsigned int nb_segs;
2805 res = parsed_result;
2806 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2807 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2809 set_tx_pkt_segments(seg_lengths, nb_segs);
2812 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2813 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2814 cmd_keyword, "set");
2815 cmdline_parse_token_string_t cmd_set_txpkts_name =
2816 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2818 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2819 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2822 cmdline_parse_inst_t cmd_set_txpkts = {
2823 .f = cmd_set_txpkts_parsed,
2825 .help_str = "set txpkts <len0[,len1]*>",
2827 (void *)&cmd_set_txpkts_keyword,
2828 (void *)&cmd_set_txpkts_name,
2829 (void *)&cmd_set_txpkts_lengths,
2834 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2836 struct cmd_set_txsplit_result {
2837 cmdline_fixed_string_t cmd_keyword;
2838 cmdline_fixed_string_t txsplit;
2839 cmdline_fixed_string_t mode;
2843 cmd_set_txsplit_parsed(void *parsed_result,
2844 __attribute__((unused)) struct cmdline *cl,
2845 __attribute__((unused)) void *data)
2847 struct cmd_set_txsplit_result *res;
2849 res = parsed_result;
2850 set_tx_pkt_split(res->mode);
2853 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2854 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2855 cmd_keyword, "set");
2856 cmdline_parse_token_string_t cmd_set_txsplit_name =
2857 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2858 txsplit, "txsplit");
2859 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2860 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2863 cmdline_parse_inst_t cmd_set_txsplit = {
2864 .f = cmd_set_txsplit_parsed,
2866 .help_str = "set txsplit on|off|rand",
2868 (void *)&cmd_set_txsplit_keyword,
2869 (void *)&cmd_set_txsplit_name,
2870 (void *)&cmd_set_txsplit_mode,
2875 /* *** CONFIG TX QUEUE FLAGS *** */
2877 struct cmd_config_txqflags_result {
2878 cmdline_fixed_string_t port;
2879 cmdline_fixed_string_t config;
2880 cmdline_fixed_string_t all;
2881 cmdline_fixed_string_t what;
2885 static void cmd_config_txqflags_parsed(void *parsed_result,
2886 __attribute__((unused)) struct cmdline *cl,
2887 __attribute__((unused)) void *data)
2889 struct cmd_config_txqflags_result *res = parsed_result;
2891 if (!all_ports_stopped()) {
2892 printf("Please stop all ports first\n");
2896 if (strcmp(res->what, "txqflags")) {
2897 printf("Unknown parameter\n");
2901 if (res->hexvalue >= 0) {
2902 txq_flags = res->hexvalue;
2904 printf("txqflags must be >= 0\n");
2910 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2913 cmdline_parse_token_string_t cmd_config_txqflags_port =
2914 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2916 cmdline_parse_token_string_t cmd_config_txqflags_config =
2917 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2919 cmdline_parse_token_string_t cmd_config_txqflags_all =
2920 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2922 cmdline_parse_token_string_t cmd_config_txqflags_what =
2923 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2925 cmdline_parse_token_num_t cmd_config_txqflags_value =
2926 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2929 cmdline_parse_inst_t cmd_config_txqflags = {
2930 .f = cmd_config_txqflags_parsed,
2932 .help_str = "port config all txqflags <value>",
2934 (void *)&cmd_config_txqflags_port,
2935 (void *)&cmd_config_txqflags_config,
2936 (void *)&cmd_config_txqflags_all,
2937 (void *)&cmd_config_txqflags_what,
2938 (void *)&cmd_config_txqflags_value,
2943 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2944 struct cmd_rx_vlan_filter_all_result {
2945 cmdline_fixed_string_t rx_vlan;
2946 cmdline_fixed_string_t what;
2947 cmdline_fixed_string_t all;
2952 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2953 __attribute__((unused)) struct cmdline *cl,
2954 __attribute__((unused)) void *data)
2956 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2958 if (!strcmp(res->what, "add"))
2959 rx_vlan_all_filter_set(res->port_id, 1);
2961 rx_vlan_all_filter_set(res->port_id, 0);
2964 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2965 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2966 rx_vlan, "rx_vlan");
2967 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2968 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2970 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2971 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2973 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2974 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2977 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2978 .f = cmd_rx_vlan_filter_all_parsed,
2980 .help_str = "rx_vlan add|rm all <port_id>: "
2981 "Add/Remove all identifiers to/from the set of VLAN "
2982 "identifiers filtered by a port",
2984 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2985 (void *)&cmd_rx_vlan_filter_all_what,
2986 (void *)&cmd_rx_vlan_filter_all_all,
2987 (void *)&cmd_rx_vlan_filter_all_portid,
2992 /* *** VLAN OFFLOAD SET ON A PORT *** */
2993 struct cmd_vlan_offload_result {
2994 cmdline_fixed_string_t vlan;
2995 cmdline_fixed_string_t set;
2996 cmdline_fixed_string_t vlan_type;
2997 cmdline_fixed_string_t what;
2998 cmdline_fixed_string_t on;
2999 cmdline_fixed_string_t port_id;
3003 cmd_vlan_offload_parsed(void *parsed_result,
3004 __attribute__((unused)) struct cmdline *cl,
3005 __attribute__((unused)) void *data)
3008 struct cmd_vlan_offload_result *res = parsed_result;
3011 portid_t port_id = 0;
3015 len = strnlen(str, STR_TOKEN_SIZE);
3017 /* Get port_id first */
3025 tmp = strtoul(str, NULL, 0);
3026 /* If port_id greater that what portid_t can represent, return */
3027 if(tmp >= RTE_MAX_ETHPORTS)
3029 port_id = (portid_t)tmp;
3031 if (!strcmp(res->on, "on"))
3036 if (!strcmp(res->what, "strip"))
3037 rx_vlan_strip_set(port_id, on);
3038 else if(!strcmp(res->what, "stripq")){
3039 uint16_t queue_id = 0;
3041 /* No queue_id, return */
3043 printf("must specify (port,queue_id)\n");
3046 tmp = strtoul(str + i + 1, NULL, 0);
3047 /* If queue_id greater that what 16-bits can represent, return */
3051 queue_id = (uint16_t)tmp;
3052 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3054 else if (!strcmp(res->what, "filter"))
3055 rx_vlan_filter_set(port_id, on);
3057 vlan_extend_set(port_id, on);
3062 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3063 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3065 cmdline_parse_token_string_t cmd_vlan_offload_set =
3066 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3068 cmdline_parse_token_string_t cmd_vlan_offload_what =
3069 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3070 what, "strip#filter#qinq#stripq");
3071 cmdline_parse_token_string_t cmd_vlan_offload_on =
3072 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3074 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3075 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3078 cmdline_parse_inst_t cmd_vlan_offload = {
3079 .f = cmd_vlan_offload_parsed,
3081 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3082 "<port_id[,queue_id]>: "
3083 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3085 (void *)&cmd_vlan_offload_vlan,
3086 (void *)&cmd_vlan_offload_set,
3087 (void *)&cmd_vlan_offload_what,
3088 (void *)&cmd_vlan_offload_on,
3089 (void *)&cmd_vlan_offload_portid,
3094 /* *** VLAN TPID SET ON A PORT *** */
3095 struct cmd_vlan_tpid_result {
3096 cmdline_fixed_string_t vlan;
3097 cmdline_fixed_string_t set;
3098 cmdline_fixed_string_t vlan_type;
3099 cmdline_fixed_string_t what;
3105 cmd_vlan_tpid_parsed(void *parsed_result,
3106 __attribute__((unused)) struct cmdline *cl,
3107 __attribute__((unused)) void *data)
3109 struct cmd_vlan_tpid_result *res = parsed_result;
3110 enum rte_vlan_type vlan_type;
3112 if (!strcmp(res->vlan_type, "inner"))
3113 vlan_type = ETH_VLAN_TYPE_INNER;
3114 else if (!strcmp(res->vlan_type, "outer"))
3115 vlan_type = ETH_VLAN_TYPE_OUTER;
3117 printf("Unknown vlan type\n");
3120 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3123 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3124 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3126 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3127 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3129 cmdline_parse_token_string_t cmd_vlan_type =
3130 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3131 vlan_type, "inner#outer");
3132 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3133 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3135 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3136 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3138 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3139 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3142 cmdline_parse_inst_t cmd_vlan_tpid = {
3143 .f = cmd_vlan_tpid_parsed,
3145 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3146 "Set the VLAN Ether type",
3148 (void *)&cmd_vlan_tpid_vlan,
3149 (void *)&cmd_vlan_tpid_set,
3150 (void *)&cmd_vlan_type,
3151 (void *)&cmd_vlan_tpid_what,
3152 (void *)&cmd_vlan_tpid_tpid,
3153 (void *)&cmd_vlan_tpid_portid,
3158 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3159 struct cmd_rx_vlan_filter_result {
3160 cmdline_fixed_string_t rx_vlan;
3161 cmdline_fixed_string_t what;
3167 cmd_rx_vlan_filter_parsed(void *parsed_result,
3168 __attribute__((unused)) struct cmdline *cl,
3169 __attribute__((unused)) void *data)
3171 struct cmd_rx_vlan_filter_result *res = parsed_result;
3173 if (!strcmp(res->what, "add"))
3174 rx_vft_set(res->port_id, res->vlan_id, 1);
3176 rx_vft_set(res->port_id, res->vlan_id, 0);
3179 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3180 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3181 rx_vlan, "rx_vlan");
3182 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3183 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3185 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3186 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3188 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3189 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3192 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3193 .f = cmd_rx_vlan_filter_parsed,
3195 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3196 "Add/Remove a VLAN identifier to/from the set of VLAN "
3197 "identifiers filtered by a port",
3199 (void *)&cmd_rx_vlan_filter_rx_vlan,
3200 (void *)&cmd_rx_vlan_filter_what,
3201 (void *)&cmd_rx_vlan_filter_vlanid,
3202 (void *)&cmd_rx_vlan_filter_portid,
3207 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3208 struct cmd_tx_vlan_set_result {
3209 cmdline_fixed_string_t tx_vlan;
3210 cmdline_fixed_string_t set;
3216 cmd_tx_vlan_set_parsed(void *parsed_result,
3217 __attribute__((unused)) struct cmdline *cl,
3218 __attribute__((unused)) void *data)
3220 struct cmd_tx_vlan_set_result *res = parsed_result;
3222 tx_vlan_set(res->port_id, res->vlan_id);
3225 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3226 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3227 tx_vlan, "tx_vlan");
3228 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3229 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3231 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3232 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3234 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3235 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3238 cmdline_parse_inst_t cmd_tx_vlan_set = {
3239 .f = cmd_tx_vlan_set_parsed,
3241 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3242 "Enable hardware insertion of a single VLAN header "
3243 "with a given TAG Identifier in packets sent on a port",
3245 (void *)&cmd_tx_vlan_set_tx_vlan,
3246 (void *)&cmd_tx_vlan_set_set,
3247 (void *)&cmd_tx_vlan_set_portid,
3248 (void *)&cmd_tx_vlan_set_vlanid,
3253 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3254 struct cmd_tx_vlan_set_qinq_result {
3255 cmdline_fixed_string_t tx_vlan;
3256 cmdline_fixed_string_t set;
3259 uint16_t vlan_id_outer;
3263 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3264 __attribute__((unused)) struct cmdline *cl,
3265 __attribute__((unused)) void *data)
3267 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3269 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3272 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3273 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3274 tx_vlan, "tx_vlan");
3275 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3276 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3278 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3279 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3281 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3282 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3284 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3285 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3286 vlan_id_outer, UINT16);
3288 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3289 .f = cmd_tx_vlan_set_qinq_parsed,
3291 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3292 "Enable hardware insertion of double VLAN header "
3293 "with given TAG Identifiers in packets sent on a port",
3295 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3296 (void *)&cmd_tx_vlan_set_qinq_set,
3297 (void *)&cmd_tx_vlan_set_qinq_portid,
3298 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3299 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3304 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3305 struct cmd_tx_vlan_set_pvid_result {
3306 cmdline_fixed_string_t tx_vlan;
3307 cmdline_fixed_string_t set;
3308 cmdline_fixed_string_t pvid;
3311 cmdline_fixed_string_t mode;
3315 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3316 __attribute__((unused)) struct cmdline *cl,
3317 __attribute__((unused)) void *data)
3319 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3321 if (strcmp(res->mode, "on") == 0)
3322 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3324 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3327 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3328 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3329 tx_vlan, "tx_vlan");
3330 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3331 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3333 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3334 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3336 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3337 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3339 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3340 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3342 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3343 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3346 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3347 .f = cmd_tx_vlan_set_pvid_parsed,
3349 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3351 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3352 (void *)&cmd_tx_vlan_set_pvid_set,
3353 (void *)&cmd_tx_vlan_set_pvid_pvid,
3354 (void *)&cmd_tx_vlan_set_pvid_port_id,
3355 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3356 (void *)&cmd_tx_vlan_set_pvid_mode,
3361 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3362 struct cmd_tx_vlan_reset_result {
3363 cmdline_fixed_string_t tx_vlan;
3364 cmdline_fixed_string_t reset;
3369 cmd_tx_vlan_reset_parsed(void *parsed_result,
3370 __attribute__((unused)) struct cmdline *cl,
3371 __attribute__((unused)) void *data)
3373 struct cmd_tx_vlan_reset_result *res = parsed_result;
3375 tx_vlan_reset(res->port_id);
3378 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3379 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3380 tx_vlan, "tx_vlan");
3381 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3382 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3384 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3385 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3388 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3389 .f = cmd_tx_vlan_reset_parsed,
3391 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3392 "VLAN header in packets sent on a port",
3394 (void *)&cmd_tx_vlan_reset_tx_vlan,
3395 (void *)&cmd_tx_vlan_reset_reset,
3396 (void *)&cmd_tx_vlan_reset_portid,
3402 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3403 struct cmd_csum_result {
3404 cmdline_fixed_string_t csum;
3405 cmdline_fixed_string_t mode;
3406 cmdline_fixed_string_t proto;
3407 cmdline_fixed_string_t hwsw;
3412 csum_show(int port_id)
3414 struct rte_eth_dev_info dev_info;
3417 ol_flags = ports[port_id].tx_ol_flags;
3418 printf("Parse tunnel is %s\n",
3419 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3420 printf("IP checksum offload is %s\n",
3421 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3422 printf("UDP checksum offload is %s\n",
3423 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3424 printf("TCP checksum offload is %s\n",
3425 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3426 printf("SCTP checksum offload is %s\n",
3427 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3428 printf("Outer-Ip checksum offload is %s\n",
3429 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3431 /* display warnings if configuration is not supported by the NIC */
3432 rte_eth_dev_info_get(port_id, &dev_info);
3433 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3434 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3435 printf("Warning: hardware IP checksum enabled but not "
3436 "supported by port %d\n", port_id);
3438 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3439 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3440 printf("Warning: hardware UDP checksum enabled but not "
3441 "supported by port %d\n", port_id);
3443 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3444 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3445 printf("Warning: hardware TCP checksum enabled but not "
3446 "supported by port %d\n", port_id);
3448 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3449 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3450 printf("Warning: hardware SCTP checksum enabled but not "
3451 "supported by port %d\n", port_id);
3453 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3454 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3455 printf("Warning: hardware outer IP checksum enabled but not "
3456 "supported by port %d\n", port_id);
3461 cmd_csum_parsed(void *parsed_result,
3462 __attribute__((unused)) struct cmdline *cl,
3463 __attribute__((unused)) void *data)
3465 struct cmd_csum_result *res = parsed_result;
3469 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3470 printf("invalid port %d\n", res->port_id);
3474 if (!strcmp(res->mode, "set")) {
3476 if (!strcmp(res->hwsw, "hw"))
3479 if (!strcmp(res->proto, "ip")) {
3480 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3481 } else if (!strcmp(res->proto, "udp")) {
3482 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3483 } else if (!strcmp(res->proto, "tcp")) {
3484 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3485 } else if (!strcmp(res->proto, "sctp")) {
3486 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3487 } else if (!strcmp(res->proto, "outer-ip")) {
3488 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3492 ports[res->port_id].tx_ol_flags |= mask;
3494 ports[res->port_id].tx_ol_flags &= (~mask);
3496 csum_show(res->port_id);
3499 cmdline_parse_token_string_t cmd_csum_csum =
3500 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3502 cmdline_parse_token_string_t cmd_csum_mode =
3503 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3505 cmdline_parse_token_string_t cmd_csum_proto =
3506 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3507 proto, "ip#tcp#udp#sctp#outer-ip");
3508 cmdline_parse_token_string_t cmd_csum_hwsw =
3509 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3511 cmdline_parse_token_num_t cmd_csum_portid =
3512 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3515 cmdline_parse_inst_t cmd_csum_set = {
3516 .f = cmd_csum_parsed,
3518 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3519 "Enable/Disable hardware calculation of L3/L4 checksum when "
3520 "using csum forward engine",
3522 (void *)&cmd_csum_csum,
3523 (void *)&cmd_csum_mode,
3524 (void *)&cmd_csum_proto,
3525 (void *)&cmd_csum_hwsw,
3526 (void *)&cmd_csum_portid,
3531 cmdline_parse_token_string_t cmd_csum_mode_show =
3532 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3535 cmdline_parse_inst_t cmd_csum_show = {
3536 .f = cmd_csum_parsed,
3538 .help_str = "csum show <port_id>: Show checksum offload configuration",
3540 (void *)&cmd_csum_csum,
3541 (void *)&cmd_csum_mode_show,
3542 (void *)&cmd_csum_portid,
3547 /* Enable/disable tunnel parsing */
3548 struct cmd_csum_tunnel_result {
3549 cmdline_fixed_string_t csum;
3550 cmdline_fixed_string_t parse;
3551 cmdline_fixed_string_t onoff;
3556 cmd_csum_tunnel_parsed(void *parsed_result,
3557 __attribute__((unused)) struct cmdline *cl,
3558 __attribute__((unused)) void *data)
3560 struct cmd_csum_tunnel_result *res = parsed_result;
3562 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3565 if (!strcmp(res->onoff, "on"))
3566 ports[res->port_id].tx_ol_flags |=
3567 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3569 ports[res->port_id].tx_ol_flags &=
3570 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3572 csum_show(res->port_id);
3575 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3576 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3578 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3579 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3580 parse, "parse_tunnel");
3581 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3582 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3584 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3585 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3588 cmdline_parse_inst_t cmd_csum_tunnel = {
3589 .f = cmd_csum_tunnel_parsed,
3591 .help_str = "csum parse_tunnel on|off <port_id>: "
3592 "Enable/Disable parsing of tunnels for csum engine",
3594 (void *)&cmd_csum_tunnel_csum,
3595 (void *)&cmd_csum_tunnel_parse,
3596 (void *)&cmd_csum_tunnel_onoff,
3597 (void *)&cmd_csum_tunnel_portid,
3602 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3603 struct cmd_tso_set_result {
3604 cmdline_fixed_string_t tso;
3605 cmdline_fixed_string_t mode;
3611 cmd_tso_set_parsed(void *parsed_result,
3612 __attribute__((unused)) struct cmdline *cl,
3613 __attribute__((unused)) void *data)
3615 struct cmd_tso_set_result *res = parsed_result;
3616 struct rte_eth_dev_info dev_info;
3618 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3621 if (!strcmp(res->mode, "set"))
3622 ports[res->port_id].tso_segsz = res->tso_segsz;
3624 if (ports[res->port_id].tso_segsz == 0)
3625 printf("TSO for non-tunneled packets is disabled\n");
3627 printf("TSO segment size for non-tunneled packets is %d\n",
3628 ports[res->port_id].tso_segsz);
3630 /* display warnings if configuration is not supported by the NIC */
3631 rte_eth_dev_info_get(res->port_id, &dev_info);
3632 if ((ports[res->port_id].tso_segsz != 0) &&
3633 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3634 printf("Warning: TSO enabled but not "
3635 "supported by port %d\n", res->port_id);
3639 cmdline_parse_token_string_t cmd_tso_set_tso =
3640 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3642 cmdline_parse_token_string_t cmd_tso_set_mode =
3643 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3645 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3646 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3648 cmdline_parse_token_num_t cmd_tso_set_portid =
3649 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3652 cmdline_parse_inst_t cmd_tso_set = {
3653 .f = cmd_tso_set_parsed,
3655 .help_str = "tso set <tso_segsz> <port_id>: "
3656 "Set TSO segment size of non-tunneled packets for csum engine "
3659 (void *)&cmd_tso_set_tso,
3660 (void *)&cmd_tso_set_mode,
3661 (void *)&cmd_tso_set_tso_segsz,
3662 (void *)&cmd_tso_set_portid,
3667 cmdline_parse_token_string_t cmd_tso_show_mode =
3668 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3672 cmdline_parse_inst_t cmd_tso_show = {
3673 .f = cmd_tso_set_parsed,
3675 .help_str = "tso show <port_id>: "
3676 "Show TSO segment size of non-tunneled packets for csum engine",
3678 (void *)&cmd_tso_set_tso,
3679 (void *)&cmd_tso_show_mode,
3680 (void *)&cmd_tso_set_portid,
3685 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3686 struct cmd_tunnel_tso_set_result {
3687 cmdline_fixed_string_t tso;
3688 cmdline_fixed_string_t mode;
3694 check_tunnel_tso_nic_support(uint8_t port_id)
3696 struct rte_eth_dev_info dev_info;
3698 rte_eth_dev_info_get(port_id, &dev_info);
3699 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3700 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3701 "supported by port %d\n", port_id);
3702 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3703 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3704 "supported by port %d\n", port_id);
3705 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3706 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3707 "supported by port %d\n", port_id);
3708 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3709 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3710 "supported by port %d\n", port_id);
3714 cmd_tunnel_tso_set_parsed(void *parsed_result,
3715 __attribute__((unused)) struct cmdline *cl,
3716 __attribute__((unused)) void *data)
3718 struct cmd_tunnel_tso_set_result *res = parsed_result;
3720 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3723 if (!strcmp(res->mode, "set"))
3724 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3726 if (ports[res->port_id].tunnel_tso_segsz == 0)
3727 printf("TSO for tunneled packets is disabled\n");
3729 printf("TSO segment size for tunneled packets is %d\n",
3730 ports[res->port_id].tunnel_tso_segsz);
3732 /* Below conditions are needed to make it work:
3733 * (1) tunnel TSO is supported by the NIC;
3734 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3736 * (3) for tunneled pkts with outer L3 of IPv4,
3737 * "csum set outer-ip" must be set to hw, because after tso,
3738 * total_len of outer IP header is changed, and the checksum
3739 * of outer IP header calculated by sw should be wrong; that
3740 * is not necessary for IPv6 tunneled pkts because there's no
3741 * checksum in IP header anymore.
3743 check_tunnel_tso_nic_support(res->port_id);
3745 if (!(ports[res->port_id].tx_ol_flags &
3746 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3747 printf("Warning: csum parse_tunnel must be set "
3748 "so that tunneled packets are recognized\n");
3749 if (!(ports[res->port_id].tx_ol_flags &
3750 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3751 printf("Warning: csum set outer-ip must be set to hw "
3752 "if outer L3 is IPv4; not necessary for IPv6\n");
3756 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3757 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3759 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3760 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3762 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3763 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3765 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3766 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3769 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3770 .f = cmd_tunnel_tso_set_parsed,
3772 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3773 "Set TSO segment size of tunneled packets for csum engine "
3776 (void *)&cmd_tunnel_tso_set_tso,
3777 (void *)&cmd_tunnel_tso_set_mode,
3778 (void *)&cmd_tunnel_tso_set_tso_segsz,
3779 (void *)&cmd_tunnel_tso_set_portid,
3784 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3785 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3789 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3790 .f = cmd_tunnel_tso_set_parsed,
3792 .help_str = "tunnel_tso show <port_id> "
3793 "Show TSO segment size of tunneled packets for csum engine",
3795 (void *)&cmd_tunnel_tso_set_tso,
3796 (void *)&cmd_tunnel_tso_show_mode,
3797 (void *)&cmd_tunnel_tso_set_portid,
3802 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3803 struct cmd_set_flush_rx {
3804 cmdline_fixed_string_t set;
3805 cmdline_fixed_string_t flush_rx;
3806 cmdline_fixed_string_t mode;
3810 cmd_set_flush_rx_parsed(void *parsed_result,
3811 __attribute__((unused)) struct cmdline *cl,
3812 __attribute__((unused)) void *data)
3814 struct cmd_set_flush_rx *res = parsed_result;
3815 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3818 cmdline_parse_token_string_t cmd_setflushrx_set =
3819 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3821 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3822 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3823 flush_rx, "flush_rx");
3824 cmdline_parse_token_string_t cmd_setflushrx_mode =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3829 cmdline_parse_inst_t cmd_set_flush_rx = {
3830 .f = cmd_set_flush_rx_parsed,
3831 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3834 (void *)&cmd_setflushrx_set,
3835 (void *)&cmd_setflushrx_flush_rx,
3836 (void *)&cmd_setflushrx_mode,
3841 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3842 struct cmd_set_link_check {
3843 cmdline_fixed_string_t set;
3844 cmdline_fixed_string_t link_check;
3845 cmdline_fixed_string_t mode;
3849 cmd_set_link_check_parsed(void *parsed_result,
3850 __attribute__((unused)) struct cmdline *cl,
3851 __attribute__((unused)) void *data)
3853 struct cmd_set_link_check *res = parsed_result;
3854 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3857 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3858 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3860 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3861 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3862 link_check, "link_check");
3863 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3864 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3868 cmdline_parse_inst_t cmd_set_link_check = {
3869 .f = cmd_set_link_check_parsed,
3870 .help_str = "set link_check on|off: Enable/Disable link status check "
3871 "when starting/stopping a port",
3874 (void *)&cmd_setlinkcheck_set,
3875 (void *)&cmd_setlinkcheck_link_check,
3876 (void *)&cmd_setlinkcheck_mode,
3881 #ifdef RTE_NIC_BYPASS
3882 /* *** SET NIC BYPASS MODE *** */
3883 struct cmd_set_bypass_mode_result {
3884 cmdline_fixed_string_t set;
3885 cmdline_fixed_string_t bypass;
3886 cmdline_fixed_string_t mode;
3887 cmdline_fixed_string_t value;
3892 cmd_set_bypass_mode_parsed(void *parsed_result,
3893 __attribute__((unused)) struct cmdline *cl,
3894 __attribute__((unused)) void *data)
3896 struct cmd_set_bypass_mode_result *res = parsed_result;
3897 portid_t port_id = res->port_id;
3898 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3900 if (!strcmp(res->value, "bypass"))
3901 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3902 else if (!strcmp(res->value, "isolate"))
3903 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3905 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3907 /* Set the bypass mode for the relevant port. */
3908 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3909 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3913 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3914 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3916 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3917 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3919 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3920 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3922 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3923 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3924 value, "normal#bypass#isolate");
3925 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3926 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3929 cmdline_parse_inst_t cmd_set_bypass_mode = {
3930 .f = cmd_set_bypass_mode_parsed,
3931 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3932 "Set the NIC bypass mode for port_id",
3935 (void *)&cmd_setbypass_mode_set,
3936 (void *)&cmd_setbypass_mode_bypass,
3937 (void *)&cmd_setbypass_mode_mode,
3938 (void *)&cmd_setbypass_mode_value,
3939 (void *)&cmd_setbypass_mode_port,
3944 /* *** SET NIC BYPASS EVENT *** */
3945 struct cmd_set_bypass_event_result {
3946 cmdline_fixed_string_t set;
3947 cmdline_fixed_string_t bypass;
3948 cmdline_fixed_string_t event;
3949 cmdline_fixed_string_t event_value;
3950 cmdline_fixed_string_t mode;
3951 cmdline_fixed_string_t mode_value;
3956 cmd_set_bypass_event_parsed(void *parsed_result,
3957 __attribute__((unused)) struct cmdline *cl,
3958 __attribute__((unused)) void *data)
3961 struct cmd_set_bypass_event_result *res = parsed_result;
3962 portid_t port_id = res->port_id;
3963 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3964 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3966 if (!strcmp(res->event_value, "timeout"))
3967 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3968 else if (!strcmp(res->event_value, "os_on"))
3969 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3970 else if (!strcmp(res->event_value, "os_off"))
3971 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3972 else if (!strcmp(res->event_value, "power_on"))
3973 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3974 else if (!strcmp(res->event_value, "power_off"))
3975 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3977 bypass_event = RTE_BYPASS_EVENT_NONE;
3979 if (!strcmp(res->mode_value, "bypass"))
3980 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3981 else if (!strcmp(res->mode_value, "isolate"))
3982 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3984 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3986 /* Set the watchdog timeout. */
3987 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3990 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3991 (rc = rte_eth_dev_wd_timeout_store(port_id,
3992 bypass_timeout)) != 0) {
3993 printf("Failed to set timeout value %u "
3994 "for port %d, errto code: %d.\n",
3995 bypass_timeout, port_id, rc);
3999 /* Set the bypass event to transition to bypass mode. */
4000 if (0 != rte_eth_dev_bypass_event_store(port_id,
4001 bypass_event, bypass_mode)) {
4002 printf("\t Failed to set bypass event for port = %d.\n", port_id);
4007 cmdline_parse_token_string_t cmd_setbypass_event_set =
4008 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4010 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4011 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4013 cmdline_parse_token_string_t cmd_setbypass_event_event =
4014 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4016 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4017 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4018 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4019 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4020 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4022 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4023 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4024 mode_value, "normal#bypass#isolate");
4025 cmdline_parse_token_num_t cmd_setbypass_event_port =
4026 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4029 cmdline_parse_inst_t cmd_set_bypass_event = {
4030 .f = cmd_set_bypass_event_parsed,
4031 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4032 "power_off mode normal|bypass|isolate <port_id>: "
4033 "Set the NIC bypass event mode for port_id",
4036 (void *)&cmd_setbypass_event_set,
4037 (void *)&cmd_setbypass_event_bypass,
4038 (void *)&cmd_setbypass_event_event,
4039 (void *)&cmd_setbypass_event_event_value,
4040 (void *)&cmd_setbypass_event_mode,
4041 (void *)&cmd_setbypass_event_mode_value,
4042 (void *)&cmd_setbypass_event_port,
4048 /* *** SET NIC BYPASS TIMEOUT *** */
4049 struct cmd_set_bypass_timeout_result {
4050 cmdline_fixed_string_t set;
4051 cmdline_fixed_string_t bypass;
4052 cmdline_fixed_string_t timeout;
4053 cmdline_fixed_string_t value;
4057 cmd_set_bypass_timeout_parsed(void *parsed_result,
4058 __attribute__((unused)) struct cmdline *cl,
4059 __attribute__((unused)) void *data)
4061 struct cmd_set_bypass_timeout_result *res = parsed_result;
4063 if (!strcmp(res->value, "1.5"))
4064 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4065 else if (!strcmp(res->value, "2"))
4066 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4067 else if (!strcmp(res->value, "3"))
4068 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4069 else if (!strcmp(res->value, "4"))
4070 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4071 else if (!strcmp(res->value, "8"))
4072 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4073 else if (!strcmp(res->value, "16"))
4074 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4075 else if (!strcmp(res->value, "32"))
4076 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4078 bypass_timeout = RTE_BYPASS_TMT_OFF;
4081 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4082 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4084 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4085 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4087 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4088 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4089 timeout, "timeout");
4090 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4091 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4092 value, "0#1.5#2#3#4#8#16#32");
4094 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4095 .f = cmd_set_bypass_timeout_parsed,
4096 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4097 "Set the NIC bypass watchdog timeout in seconds",
4100 (void *)&cmd_setbypass_timeout_set,
4101 (void *)&cmd_setbypass_timeout_bypass,
4102 (void *)&cmd_setbypass_timeout_timeout,
4103 (void *)&cmd_setbypass_timeout_value,
4108 /* *** SHOW NIC BYPASS MODE *** */
4109 struct cmd_show_bypass_config_result {
4110 cmdline_fixed_string_t show;
4111 cmdline_fixed_string_t bypass;
4112 cmdline_fixed_string_t config;
4117 cmd_show_bypass_config_parsed(void *parsed_result,
4118 __attribute__((unused)) struct cmdline *cl,
4119 __attribute__((unused)) void *data)
4121 struct cmd_show_bypass_config_result *res = parsed_result;
4122 uint32_t event_mode;
4123 uint32_t bypass_mode;
4124 portid_t port_id = res->port_id;
4125 uint32_t timeout = bypass_timeout;
4128 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4129 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4130 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4131 {"UNKNOWN", "normal", "bypass", "isolate"};
4132 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4139 int num_events = (sizeof events) / (sizeof events[0]);
4141 /* Display the bypass mode.*/
4142 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4143 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4147 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4148 bypass_mode = RTE_BYPASS_MODE_NONE;
4150 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4153 /* Display the bypass timeout.*/
4154 if (!RTE_BYPASS_TMT_VALID(timeout))
4155 timeout = RTE_BYPASS_TMT_OFF;
4157 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4159 /* Display the bypass events and associated modes. */
4160 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4162 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4163 printf("\tFailed to get bypass mode for event = %s\n",
4166 if (!RTE_BYPASS_MODE_VALID(event_mode))
4167 event_mode = RTE_BYPASS_MODE_NONE;
4169 printf("\tbypass event: %-16s = %s\n", events[i],
4175 cmdline_parse_token_string_t cmd_showbypass_config_show =
4176 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4178 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4179 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4181 cmdline_parse_token_string_t cmd_showbypass_config_config =
4182 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4184 cmdline_parse_token_num_t cmd_showbypass_config_port =
4185 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4188 cmdline_parse_inst_t cmd_show_bypass_config = {
4189 .f = cmd_show_bypass_config_parsed,
4190 .help_str = "show bypass config <port_id>: "
4191 "Show the NIC bypass config for port_id",
4194 (void *)&cmd_showbypass_config_show,
4195 (void *)&cmd_showbypass_config_bypass,
4196 (void *)&cmd_showbypass_config_config,
4197 (void *)&cmd_showbypass_config_port,
4203 #ifdef RTE_LIBRTE_PMD_BOND
4204 /* *** SET BONDING MODE *** */
4205 struct cmd_set_bonding_mode_result {
4206 cmdline_fixed_string_t set;
4207 cmdline_fixed_string_t bonding;
4208 cmdline_fixed_string_t mode;
4213 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4214 __attribute__((unused)) struct cmdline *cl,
4215 __attribute__((unused)) void *data)
4217 struct cmd_set_bonding_mode_result *res = parsed_result;
4218 portid_t port_id = res->port_id;
4220 /* Set the bonding mode for the relevant port. */
4221 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4222 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4225 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4226 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4228 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4229 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4230 bonding, "bonding");
4231 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4232 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4234 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4235 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4237 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4238 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4241 cmdline_parse_inst_t cmd_set_bonding_mode = {
4242 .f = cmd_set_bonding_mode_parsed,
4243 .help_str = "set bonding mode <mode_value> <port_id>: "
4244 "Set the bonding mode for port_id",
4247 (void *) &cmd_setbonding_mode_set,
4248 (void *) &cmd_setbonding_mode_bonding,
4249 (void *) &cmd_setbonding_mode_mode,
4250 (void *) &cmd_setbonding_mode_value,
4251 (void *) &cmd_setbonding_mode_port,
4256 /* *** SET BALANCE XMIT POLICY *** */
4257 struct cmd_set_bonding_balance_xmit_policy_result {
4258 cmdline_fixed_string_t set;
4259 cmdline_fixed_string_t bonding;
4260 cmdline_fixed_string_t balance_xmit_policy;
4262 cmdline_fixed_string_t policy;
4265 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4266 __attribute__((unused)) struct cmdline *cl,
4267 __attribute__((unused)) void *data)
4269 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4270 portid_t port_id = res->port_id;
4273 if (!strcmp(res->policy, "l2")) {
4274 policy = BALANCE_XMIT_POLICY_LAYER2;
4275 } else if (!strcmp(res->policy, "l23")) {
4276 policy = BALANCE_XMIT_POLICY_LAYER23;
4277 } else if (!strcmp(res->policy, "l34")) {
4278 policy = BALANCE_XMIT_POLICY_LAYER34;
4280 printf("\t Invalid xmit policy selection");
4284 /* Set the bonding mode for the relevant port. */
4285 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4286 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4291 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4292 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4294 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4295 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4296 bonding, "bonding");
4297 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4298 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4299 balance_xmit_policy, "balance_xmit_policy");
4300 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4301 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4303 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4304 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4305 policy, "l2#l23#l34");
4307 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4308 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4309 .help_str = "set bonding balance_xmit_policy <port_id> "
4311 "Set the bonding balance_xmit_policy for port_id",
4314 (void *)&cmd_setbonding_balance_xmit_policy_set,
4315 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4316 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4317 (void *)&cmd_setbonding_balance_xmit_policy_port,
4318 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4323 /* *** SHOW NIC BONDING CONFIGURATION *** */
4324 struct cmd_show_bonding_config_result {
4325 cmdline_fixed_string_t show;
4326 cmdline_fixed_string_t bonding;
4327 cmdline_fixed_string_t config;
4331 static void cmd_show_bonding_config_parsed(void *parsed_result,
4332 __attribute__((unused)) struct cmdline *cl,
4333 __attribute__((unused)) void *data)
4335 struct cmd_show_bonding_config_result *res = parsed_result;
4337 uint8_t slaves[RTE_MAX_ETHPORTS];
4338 int num_slaves, num_active_slaves;
4341 portid_t port_id = res->port_id;
4343 /* Display the bonding mode.*/
4344 bonding_mode = rte_eth_bond_mode_get(port_id);
4345 if (bonding_mode < 0) {
4346 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4349 printf("\tBonding mode: %d\n", bonding_mode);
4351 if (bonding_mode == BONDING_MODE_BALANCE) {
4352 int balance_xmit_policy;
4354 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4355 if (balance_xmit_policy < 0) {
4356 printf("\tFailed to get balance xmit policy for port = %d\n",
4360 printf("\tBalance Xmit Policy: ");
4362 switch (balance_xmit_policy) {
4363 case BALANCE_XMIT_POLICY_LAYER2:
4364 printf("BALANCE_XMIT_POLICY_LAYER2");
4366 case BALANCE_XMIT_POLICY_LAYER23:
4367 printf("BALANCE_XMIT_POLICY_LAYER23");
4369 case BALANCE_XMIT_POLICY_LAYER34:
4370 printf("BALANCE_XMIT_POLICY_LAYER34");
4377 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4379 if (num_slaves < 0) {
4380 printf("\tFailed to get slave list for port = %d\n", port_id);
4383 if (num_slaves > 0) {
4384 printf("\tSlaves (%d): [", num_slaves);
4385 for (i = 0; i < num_slaves - 1; i++)
4386 printf("%d ", slaves[i]);
4388 printf("%d]\n", slaves[num_slaves - 1]);
4390 printf("\tSlaves: []\n");
4394 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4397 if (num_active_slaves < 0) {
4398 printf("\tFailed to get active slave list for port = %d\n", port_id);
4401 if (num_active_slaves > 0) {
4402 printf("\tActive Slaves (%d): [", num_active_slaves);
4403 for (i = 0; i < num_active_slaves - 1; i++)
4404 printf("%d ", slaves[i]);
4406 printf("%d]\n", slaves[num_active_slaves - 1]);
4409 printf("\tActive Slaves: []\n");
4413 primary_id = rte_eth_bond_primary_get(port_id);
4414 if (primary_id < 0) {
4415 printf("\tFailed to get primary slave for port = %d\n", port_id);
4418 printf("\tPrimary: [%d]\n", primary_id);
4422 cmdline_parse_token_string_t cmd_showbonding_config_show =
4423 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4425 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4426 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4427 bonding, "bonding");
4428 cmdline_parse_token_string_t cmd_showbonding_config_config =
4429 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4431 cmdline_parse_token_num_t cmd_showbonding_config_port =
4432 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4435 cmdline_parse_inst_t cmd_show_bonding_config = {
4436 .f = cmd_show_bonding_config_parsed,
4437 .help_str = "show bonding config <port_id>: "
4438 "Show the bonding config for port_id",
4441 (void *)&cmd_showbonding_config_show,
4442 (void *)&cmd_showbonding_config_bonding,
4443 (void *)&cmd_showbonding_config_config,
4444 (void *)&cmd_showbonding_config_port,
4449 /* *** SET BONDING PRIMARY *** */
4450 struct cmd_set_bonding_primary_result {
4451 cmdline_fixed_string_t set;
4452 cmdline_fixed_string_t bonding;
4453 cmdline_fixed_string_t primary;
4458 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4459 __attribute__((unused)) struct cmdline *cl,
4460 __attribute__((unused)) void *data)
4462 struct cmd_set_bonding_primary_result *res = parsed_result;
4463 portid_t master_port_id = res->port_id;
4464 portid_t slave_port_id = res->slave_id;
4466 /* Set the primary slave for a bonded device. */
4467 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4468 printf("\t Failed to set primary slave for port = %d.\n",
4475 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4476 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4478 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4479 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4480 bonding, "bonding");
4481 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4482 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4483 primary, "primary");
4484 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4485 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4487 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4488 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4491 cmdline_parse_inst_t cmd_set_bonding_primary = {
4492 .f = cmd_set_bonding_primary_parsed,
4493 .help_str = "set bonding primary <slave_id> <port_id>: "
4494 "Set the primary slave for port_id",
4497 (void *)&cmd_setbonding_primary_set,
4498 (void *)&cmd_setbonding_primary_bonding,
4499 (void *)&cmd_setbonding_primary_primary,
4500 (void *)&cmd_setbonding_primary_slave,
4501 (void *)&cmd_setbonding_primary_port,
4506 /* *** ADD SLAVE *** */
4507 struct cmd_add_bonding_slave_result {
4508 cmdline_fixed_string_t add;
4509 cmdline_fixed_string_t bonding;
4510 cmdline_fixed_string_t slave;
4515 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4516 __attribute__((unused)) struct cmdline *cl,
4517 __attribute__((unused)) void *data)
4519 struct cmd_add_bonding_slave_result *res = parsed_result;
4520 portid_t master_port_id = res->port_id;
4521 portid_t slave_port_id = res->slave_id;
4523 /* Set the primary slave for a bonded device. */
4524 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4525 printf("\t Failed to add slave %d to master port = %d.\n",
4526 slave_port_id, master_port_id);
4530 set_port_slave_flag(slave_port_id);
4533 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4534 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4536 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4537 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4538 bonding, "bonding");
4539 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4540 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4542 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4543 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4545 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4546 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4549 cmdline_parse_inst_t cmd_add_bonding_slave = {
4550 .f = cmd_add_bonding_slave_parsed,
4551 .help_str = "add bonding slave <slave_id> <port_id>: "
4552 "Add a slave device to a bonded device",
4555 (void *)&cmd_addbonding_slave_add,
4556 (void *)&cmd_addbonding_slave_bonding,
4557 (void *)&cmd_addbonding_slave_slave,
4558 (void *)&cmd_addbonding_slave_slaveid,
4559 (void *)&cmd_addbonding_slave_port,
4564 /* *** REMOVE SLAVE *** */
4565 struct cmd_remove_bonding_slave_result {
4566 cmdline_fixed_string_t remove;
4567 cmdline_fixed_string_t bonding;
4568 cmdline_fixed_string_t slave;
4573 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4574 __attribute__((unused)) struct cmdline *cl,
4575 __attribute__((unused)) void *data)
4577 struct cmd_remove_bonding_slave_result *res = parsed_result;
4578 portid_t master_port_id = res->port_id;
4579 portid_t slave_port_id = res->slave_id;
4581 /* Set the primary slave for a bonded device. */
4582 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4583 printf("\t Failed to remove slave %d from master port = %d.\n",
4584 slave_port_id, master_port_id);
4588 clear_port_slave_flag(slave_port_id);
4591 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4592 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4594 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4595 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4596 bonding, "bonding");
4597 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4598 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4600 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4601 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4603 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4604 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4607 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4608 .f = cmd_remove_bonding_slave_parsed,
4609 .help_str = "remove bonding slave <slave_id> <port_id>: "
4610 "Remove a slave device from a bonded device",
4613 (void *)&cmd_removebonding_slave_remove,
4614 (void *)&cmd_removebonding_slave_bonding,
4615 (void *)&cmd_removebonding_slave_slave,
4616 (void *)&cmd_removebonding_slave_slaveid,
4617 (void *)&cmd_removebonding_slave_port,
4622 /* *** CREATE BONDED DEVICE *** */
4623 struct cmd_create_bonded_device_result {
4624 cmdline_fixed_string_t create;
4625 cmdline_fixed_string_t bonded;
4626 cmdline_fixed_string_t device;
4631 static int bond_dev_num = 0;
4633 static void cmd_create_bonded_device_parsed(void *parsed_result,
4634 __attribute__((unused)) struct cmdline *cl,
4635 __attribute__((unused)) void *data)
4637 struct cmd_create_bonded_device_result *res = parsed_result;
4638 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4641 if (test_done == 0) {
4642 printf("Please stop forwarding first\n");
4646 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4649 /* Create a new bonded device. */
4650 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4652 printf("\t Failed to create bonded device.\n");
4655 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4658 /* Update number of ports */
4659 nb_ports = rte_eth_dev_count();
4660 reconfig(port_id, res->socket);
4661 rte_eth_promiscuous_enable(port_id);
4662 ports[port_id].enabled = 1;
4667 cmdline_parse_token_string_t cmd_createbonded_device_create =
4668 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4670 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4671 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4673 cmdline_parse_token_string_t cmd_createbonded_device_device =
4674 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4676 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4677 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4679 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4680 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4683 cmdline_parse_inst_t cmd_create_bonded_device = {
4684 .f = cmd_create_bonded_device_parsed,
4685 .help_str = "create bonded device <mode> <socket>: "
4686 "Create a new bonded device with specific bonding mode and socket",
4689 (void *)&cmd_createbonded_device_create,
4690 (void *)&cmd_createbonded_device_bonded,
4691 (void *)&cmd_createbonded_device_device,
4692 (void *)&cmd_createbonded_device_mode,
4693 (void *)&cmd_createbonded_device_socket,
4698 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4699 struct cmd_set_bond_mac_addr_result {
4700 cmdline_fixed_string_t set;
4701 cmdline_fixed_string_t bonding;
4702 cmdline_fixed_string_t mac_addr;
4704 struct ether_addr address;
4707 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4708 __attribute__((unused)) struct cmdline *cl,
4709 __attribute__((unused)) void *data)
4711 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4714 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4717 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4719 /* check the return value and print it if is < 0 */
4721 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4724 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4725 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4726 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4727 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4729 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4730 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4732 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4733 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4734 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4735 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4737 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4738 .f = cmd_set_bond_mac_addr_parsed,
4740 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4742 (void *)&cmd_set_bond_mac_addr_set,
4743 (void *)&cmd_set_bond_mac_addr_bonding,
4744 (void *)&cmd_set_bond_mac_addr_mac,
4745 (void *)&cmd_set_bond_mac_addr_portnum,
4746 (void *)&cmd_set_bond_mac_addr_addr,
4752 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4753 struct cmd_set_bond_mon_period_result {
4754 cmdline_fixed_string_t set;
4755 cmdline_fixed_string_t bonding;
4756 cmdline_fixed_string_t mon_period;
4761 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4762 __attribute__((unused)) struct cmdline *cl,
4763 __attribute__((unused)) void *data)
4765 struct cmd_set_bond_mon_period_result *res = parsed_result;
4768 if (res->port_num >= nb_ports) {
4769 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4773 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4775 /* check the return value and print it if is < 0 */
4777 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4780 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4781 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4783 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4784 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4785 bonding, "bonding");
4786 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4787 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4788 mon_period, "mon_period");
4789 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4790 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4792 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4793 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4796 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4797 .f = cmd_set_bond_mon_period_parsed,
4799 .help_str = "set bonding mon_period <port_id> <period_ms>",
4801 (void *)&cmd_set_bond_mon_period_set,
4802 (void *)&cmd_set_bond_mon_period_bonding,
4803 (void *)&cmd_set_bond_mon_period_mon_period,
4804 (void *)&cmd_set_bond_mon_period_portnum,
4805 (void *)&cmd_set_bond_mon_period_period_ms,
4810 #endif /* RTE_LIBRTE_PMD_BOND */
4812 /* *** SET FORWARDING MODE *** */
4813 struct cmd_set_fwd_mode_result {
4814 cmdline_fixed_string_t set;
4815 cmdline_fixed_string_t fwd;
4816 cmdline_fixed_string_t mode;
4819 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4820 __attribute__((unused)) struct cmdline *cl,
4821 __attribute__((unused)) void *data)
4823 struct cmd_set_fwd_mode_result *res = parsed_result;
4826 set_pkt_forwarding_mode(res->mode);
4829 cmdline_parse_token_string_t cmd_setfwd_set =
4830 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4831 cmdline_parse_token_string_t cmd_setfwd_fwd =
4832 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4833 cmdline_parse_token_string_t cmd_setfwd_mode =
4834 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4835 "" /* defined at init */);
4837 cmdline_parse_inst_t cmd_set_fwd_mode = {
4838 .f = cmd_set_fwd_mode_parsed,
4840 .help_str = NULL, /* defined at init */
4842 (void *)&cmd_setfwd_set,
4843 (void *)&cmd_setfwd_fwd,
4844 (void *)&cmd_setfwd_mode,
4849 static void cmd_set_fwd_mode_init(void)
4852 static char token[128];
4853 static char help[256];
4854 cmdline_parse_token_string_t *token_struct;
4856 modes = list_pkt_forwarding_modes();
4857 snprintf(help, sizeof(help), "set fwd %s: "
4858 "Set packet forwarding mode", modes);
4859 cmd_set_fwd_mode.help_str = help;
4861 /* string token separator is # */
4862 for (c = token; *modes != '\0'; modes++)
4867 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4868 token_struct->string_data.str = token;
4871 /* *** SET RETRY FORWARDING MODE *** */
4872 struct cmd_set_fwd_retry_mode_result {
4873 cmdline_fixed_string_t set;
4874 cmdline_fixed_string_t fwd;
4875 cmdline_fixed_string_t mode;
4876 cmdline_fixed_string_t retry;
4879 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4880 __attribute__((unused)) struct cmdline *cl,
4881 __attribute__((unused)) void *data)
4883 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4886 set_pkt_forwarding_mode(res->mode);
4889 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4890 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4892 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4893 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4895 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4896 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4898 "" /* defined at init */);
4899 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4900 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4903 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4904 .f = cmd_set_fwd_retry_mode_parsed,
4906 .help_str = NULL, /* defined at init */
4908 (void *)&cmd_setfwd_retry_set,
4909 (void *)&cmd_setfwd_retry_fwd,
4910 (void *)&cmd_setfwd_retry_mode,
4911 (void *)&cmd_setfwd_retry_retry,
4916 static void cmd_set_fwd_retry_mode_init(void)
4919 static char token[128];
4920 static char help[256];
4921 cmdline_parse_token_string_t *token_struct;
4923 modes = list_pkt_forwarding_retry_modes();
4924 snprintf(help, sizeof(help), "set fwd %s retry: "
4925 "Set packet forwarding mode with retry", modes);
4926 cmd_set_fwd_retry_mode.help_str = help;
4928 /* string token separator is # */
4929 for (c = token; *modes != '\0'; modes++)
4934 token_struct = (cmdline_parse_token_string_t *)
4935 cmd_set_fwd_retry_mode.tokens[2];
4936 token_struct->string_data.str = token;
4939 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4940 struct cmd_set_burst_tx_retry_result {
4941 cmdline_fixed_string_t set;
4942 cmdline_fixed_string_t burst;
4943 cmdline_fixed_string_t tx;
4944 cmdline_fixed_string_t delay;
4946 cmdline_fixed_string_t retry;
4950 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4951 __attribute__((unused)) struct cmdline *cl,
4952 __attribute__((unused)) void *data)
4954 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4956 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4957 && !strcmp(res->tx, "tx")) {
4958 if (!strcmp(res->delay, "delay"))
4959 burst_tx_delay_time = res->time;
4960 if (!strcmp(res->retry, "retry"))
4961 burst_tx_retry_num = res->retry_num;
4966 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4967 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4968 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4969 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4971 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4972 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4973 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4974 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4975 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4976 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4977 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4978 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4979 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4980 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4982 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4983 .f = cmd_set_burst_tx_retry_parsed,
4984 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4986 (void *)&cmd_set_burst_tx_retry_set,
4987 (void *)&cmd_set_burst_tx_retry_burst,
4988 (void *)&cmd_set_burst_tx_retry_tx,
4989 (void *)&cmd_set_burst_tx_retry_delay,
4990 (void *)&cmd_set_burst_tx_retry_time,
4991 (void *)&cmd_set_burst_tx_retry_retry,
4992 (void *)&cmd_set_burst_tx_retry_retry_num,
4997 /* *** SET PROMISC MODE *** */
4998 struct cmd_set_promisc_mode_result {
4999 cmdline_fixed_string_t set;
5000 cmdline_fixed_string_t promisc;
5001 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5002 uint8_t port_num; /* valid if "allports" argument == 0 */
5003 cmdline_fixed_string_t mode;
5006 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5007 __attribute__((unused)) struct cmdline *cl,
5010 struct cmd_set_promisc_mode_result *res = parsed_result;
5014 if (!strcmp(res->mode, "on"))
5021 FOREACH_PORT(i, ports) {
5023 rte_eth_promiscuous_enable(i);
5025 rte_eth_promiscuous_disable(i);
5030 rte_eth_promiscuous_enable(res->port_num);
5032 rte_eth_promiscuous_disable(res->port_num);
5036 cmdline_parse_token_string_t cmd_setpromisc_set =
5037 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5038 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5039 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5041 cmdline_parse_token_string_t cmd_setpromisc_portall =
5042 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5044 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5045 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5047 cmdline_parse_token_string_t cmd_setpromisc_mode =
5048 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5051 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5052 .f = cmd_set_promisc_mode_parsed,
5054 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5056 (void *)&cmd_setpromisc_set,
5057 (void *)&cmd_setpromisc_promisc,
5058 (void *)&cmd_setpromisc_portall,
5059 (void *)&cmd_setpromisc_mode,
5064 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5065 .f = cmd_set_promisc_mode_parsed,
5067 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5069 (void *)&cmd_setpromisc_set,
5070 (void *)&cmd_setpromisc_promisc,
5071 (void *)&cmd_setpromisc_portnum,
5072 (void *)&cmd_setpromisc_mode,
5077 /* *** SET ALLMULTI MODE *** */
5078 struct cmd_set_allmulti_mode_result {
5079 cmdline_fixed_string_t set;
5080 cmdline_fixed_string_t allmulti;
5081 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5082 uint8_t port_num; /* valid if "allports" argument == 0 */
5083 cmdline_fixed_string_t mode;
5086 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5087 __attribute__((unused)) struct cmdline *cl,
5090 struct cmd_set_allmulti_mode_result *res = parsed_result;
5094 if (!strcmp(res->mode, "on"))
5101 FOREACH_PORT(i, ports) {
5103 rte_eth_allmulticast_enable(i);
5105 rte_eth_allmulticast_disable(i);
5110 rte_eth_allmulticast_enable(res->port_num);
5112 rte_eth_allmulticast_disable(res->port_num);
5116 cmdline_parse_token_string_t cmd_setallmulti_set =
5117 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5118 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5119 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5121 cmdline_parse_token_string_t cmd_setallmulti_portall =
5122 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5124 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5125 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5127 cmdline_parse_token_string_t cmd_setallmulti_mode =
5128 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5131 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5132 .f = cmd_set_allmulti_mode_parsed,
5134 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5136 (void *)&cmd_setallmulti_set,
5137 (void *)&cmd_setallmulti_allmulti,
5138 (void *)&cmd_setallmulti_portall,
5139 (void *)&cmd_setallmulti_mode,
5144 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5145 .f = cmd_set_allmulti_mode_parsed,
5147 .help_str = "set allmulti <port_id> on|off: "
5148 "Set allmulti mode on port_id",
5150 (void *)&cmd_setallmulti_set,
5151 (void *)&cmd_setallmulti_allmulti,
5152 (void *)&cmd_setallmulti_portnum,
5153 (void *)&cmd_setallmulti_mode,
5158 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5159 struct cmd_link_flow_ctrl_set_result {
5160 cmdline_fixed_string_t set;
5161 cmdline_fixed_string_t flow_ctrl;
5162 cmdline_fixed_string_t rx;
5163 cmdline_fixed_string_t rx_lfc_mode;
5164 cmdline_fixed_string_t tx;
5165 cmdline_fixed_string_t tx_lfc_mode;
5166 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5167 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5168 cmdline_fixed_string_t autoneg_str;
5169 cmdline_fixed_string_t autoneg;
5170 cmdline_fixed_string_t hw_str;
5171 uint32_t high_water;
5172 cmdline_fixed_string_t lw_str;
5174 cmdline_fixed_string_t pt_str;
5175 uint16_t pause_time;
5176 cmdline_fixed_string_t xon_str;
5181 cmdline_parse_token_string_t cmd_lfc_set_set =
5182 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5184 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5185 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5186 flow_ctrl, "flow_ctrl");
5187 cmdline_parse_token_string_t cmd_lfc_set_rx =
5188 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5190 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5191 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5192 rx_lfc_mode, "on#off");
5193 cmdline_parse_token_string_t cmd_lfc_set_tx =
5194 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5196 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5197 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5198 tx_lfc_mode, "on#off");
5199 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5200 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5201 hw_str, "high_water");
5202 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5203 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5204 high_water, UINT32);
5205 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5206 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5207 lw_str, "low_water");
5208 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5209 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5211 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5212 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5213 pt_str, "pause_time");
5214 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5215 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5216 pause_time, UINT16);
5217 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5218 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5219 xon_str, "send_xon");
5220 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5221 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5223 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5224 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5225 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5226 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5227 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5228 mac_ctrl_frame_fwd_mode, "on#off");
5229 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5230 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5231 autoneg_str, "autoneg");
5232 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5233 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5235 cmdline_parse_token_num_t cmd_lfc_set_portid =
5236 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5239 /* forward declaration */
5241 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5244 cmdline_parse_inst_t cmd_link_flow_control_set = {
5245 .f = cmd_link_flow_ctrl_set_parsed,
5247 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5248 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5249 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5251 (void *)&cmd_lfc_set_set,
5252 (void *)&cmd_lfc_set_flow_ctrl,
5253 (void *)&cmd_lfc_set_rx,
5254 (void *)&cmd_lfc_set_rx_mode,
5255 (void *)&cmd_lfc_set_tx,
5256 (void *)&cmd_lfc_set_tx_mode,
5257 (void *)&cmd_lfc_set_high_water,
5258 (void *)&cmd_lfc_set_low_water,
5259 (void *)&cmd_lfc_set_pause_time,
5260 (void *)&cmd_lfc_set_send_xon,
5261 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5262 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5263 (void *)&cmd_lfc_set_autoneg_str,
5264 (void *)&cmd_lfc_set_autoneg,
5265 (void *)&cmd_lfc_set_portid,
5270 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5271 .f = cmd_link_flow_ctrl_set_parsed,
5272 .data = (void *)&cmd_link_flow_control_set_rx,
5273 .help_str = "set flow_ctrl rx on|off <port_id>: "
5274 "Change rx flow control parameter",
5276 (void *)&cmd_lfc_set_set,
5277 (void *)&cmd_lfc_set_flow_ctrl,
5278 (void *)&cmd_lfc_set_rx,
5279 (void *)&cmd_lfc_set_rx_mode,
5280 (void *)&cmd_lfc_set_portid,
5285 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5286 .f = cmd_link_flow_ctrl_set_parsed,
5287 .data = (void *)&cmd_link_flow_control_set_tx,
5288 .help_str = "set flow_ctrl tx on|off <port_id>: "
5289 "Change tx flow control parameter",
5291 (void *)&cmd_lfc_set_set,
5292 (void *)&cmd_lfc_set_flow_ctrl,
5293 (void *)&cmd_lfc_set_tx,
5294 (void *)&cmd_lfc_set_tx_mode,
5295 (void *)&cmd_lfc_set_portid,
5300 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5301 .f = cmd_link_flow_ctrl_set_parsed,
5302 .data = (void *)&cmd_link_flow_control_set_hw,
5303 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5304 "Change high water flow control parameter",
5306 (void *)&cmd_lfc_set_set,
5307 (void *)&cmd_lfc_set_flow_ctrl,
5308 (void *)&cmd_lfc_set_high_water_str,
5309 (void *)&cmd_lfc_set_high_water,
5310 (void *)&cmd_lfc_set_portid,
5315 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5316 .f = cmd_link_flow_ctrl_set_parsed,
5317 .data = (void *)&cmd_link_flow_control_set_lw,
5318 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5319 "Change low water flow control parameter",
5321 (void *)&cmd_lfc_set_set,
5322 (void *)&cmd_lfc_set_flow_ctrl,
5323 (void *)&cmd_lfc_set_low_water_str,
5324 (void *)&cmd_lfc_set_low_water,
5325 (void *)&cmd_lfc_set_portid,
5330 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5331 .f = cmd_link_flow_ctrl_set_parsed,
5332 .data = (void *)&cmd_link_flow_control_set_pt,
5333 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5334 "Change pause time flow control parameter",
5336 (void *)&cmd_lfc_set_set,
5337 (void *)&cmd_lfc_set_flow_ctrl,
5338 (void *)&cmd_lfc_set_pause_time_str,
5339 (void *)&cmd_lfc_set_pause_time,
5340 (void *)&cmd_lfc_set_portid,
5345 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5346 .f = cmd_link_flow_ctrl_set_parsed,
5347 .data = (void *)&cmd_link_flow_control_set_xon,
5348 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5349 "Change send_xon flow control parameter",
5351 (void *)&cmd_lfc_set_set,
5352 (void *)&cmd_lfc_set_flow_ctrl,
5353 (void *)&cmd_lfc_set_send_xon_str,
5354 (void *)&cmd_lfc_set_send_xon,
5355 (void *)&cmd_lfc_set_portid,
5360 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5361 .f = cmd_link_flow_ctrl_set_parsed,
5362 .data = (void *)&cmd_link_flow_control_set_macfwd,
5363 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5364 "Change mac ctrl fwd flow control parameter",
5366 (void *)&cmd_lfc_set_set,
5367 (void *)&cmd_lfc_set_flow_ctrl,
5368 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5369 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5370 (void *)&cmd_lfc_set_portid,
5375 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5376 .f = cmd_link_flow_ctrl_set_parsed,
5377 .data = (void *)&cmd_link_flow_control_set_autoneg,
5378 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5379 "Change autoneg flow control parameter",
5381 (void *)&cmd_lfc_set_set,
5382 (void *)&cmd_lfc_set_flow_ctrl,
5383 (void *)&cmd_lfc_set_autoneg_str,
5384 (void *)&cmd_lfc_set_autoneg,
5385 (void *)&cmd_lfc_set_portid,
5391 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5392 __attribute__((unused)) struct cmdline *cl,
5395 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5396 cmdline_parse_inst_t *cmd = data;
5397 struct rte_eth_fc_conf fc_conf;
5403 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5404 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5405 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5406 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5408 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5409 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5412 /* Partial command line, retrieve current configuration */
5414 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5416 printf("cannot get current flow ctrl parameters, return"
5417 "code = %d\n", ret);
5421 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5422 (fc_conf.mode == RTE_FC_FULL))
5424 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5425 (fc_conf.mode == RTE_FC_FULL))
5429 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5430 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5432 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5433 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5435 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5437 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5438 fc_conf.high_water = res->high_water;
5440 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5441 fc_conf.low_water = res->low_water;
5443 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5444 fc_conf.pause_time = res->pause_time;
5446 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5447 fc_conf.send_xon = res->send_xon;
5449 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5450 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5451 fc_conf.mac_ctrl_frame_fwd = 1;
5453 fc_conf.mac_ctrl_frame_fwd = 0;
5456 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5457 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5459 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5461 printf("bad flow contrl parameter, return code = %d \n", ret);
5464 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5465 struct cmd_priority_flow_ctrl_set_result {
5466 cmdline_fixed_string_t set;
5467 cmdline_fixed_string_t pfc_ctrl;
5468 cmdline_fixed_string_t rx;
5469 cmdline_fixed_string_t rx_pfc_mode;
5470 cmdline_fixed_string_t tx;
5471 cmdline_fixed_string_t tx_pfc_mode;
5472 uint32_t high_water;
5474 uint16_t pause_time;
5480 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5481 __attribute__((unused)) struct cmdline *cl,
5482 __attribute__((unused)) void *data)
5484 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5485 struct rte_eth_pfc_conf pfc_conf;
5486 int rx_fc_enable, tx_fc_enable;
5490 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5491 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5492 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5493 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5495 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5496 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5499 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5500 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5501 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5502 pfc_conf.fc.high_water = res->high_water;
5503 pfc_conf.fc.low_water = res->low_water;
5504 pfc_conf.fc.pause_time = res->pause_time;
5505 pfc_conf.priority = res->priority;
5507 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5509 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5512 cmdline_parse_token_string_t cmd_pfc_set_set =
5513 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5515 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5516 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5517 pfc_ctrl, "pfc_ctrl");
5518 cmdline_parse_token_string_t cmd_pfc_set_rx =
5519 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5521 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5522 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5523 rx_pfc_mode, "on#off");
5524 cmdline_parse_token_string_t cmd_pfc_set_tx =
5525 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5527 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5528 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5529 tx_pfc_mode, "on#off");
5530 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5531 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5532 high_water, UINT32);
5533 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5534 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5536 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5537 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5538 pause_time, UINT16);
5539 cmdline_parse_token_num_t cmd_pfc_set_priority =
5540 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5542 cmdline_parse_token_num_t cmd_pfc_set_portid =
5543 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5546 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5547 .f = cmd_priority_flow_ctrl_set_parsed,
5549 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5550 "<pause_time> <priority> <port_id>: "
5551 "Configure the Ethernet priority flow control",
5553 (void *)&cmd_pfc_set_set,
5554 (void *)&cmd_pfc_set_flow_ctrl,
5555 (void *)&cmd_pfc_set_rx,
5556 (void *)&cmd_pfc_set_rx_mode,
5557 (void *)&cmd_pfc_set_tx,
5558 (void *)&cmd_pfc_set_tx_mode,
5559 (void *)&cmd_pfc_set_high_water,
5560 (void *)&cmd_pfc_set_low_water,
5561 (void *)&cmd_pfc_set_pause_time,
5562 (void *)&cmd_pfc_set_priority,
5563 (void *)&cmd_pfc_set_portid,
5568 /* *** RESET CONFIGURATION *** */
5569 struct cmd_reset_result {
5570 cmdline_fixed_string_t reset;
5571 cmdline_fixed_string_t def;
5574 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5576 __attribute__((unused)) void *data)
5578 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5579 set_def_fwd_config();
5582 cmdline_parse_token_string_t cmd_reset_set =
5583 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5584 cmdline_parse_token_string_t cmd_reset_def =
5585 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5588 cmdline_parse_inst_t cmd_reset = {
5589 .f = cmd_reset_parsed,
5591 .help_str = "set default: Reset default forwarding configuration",
5593 (void *)&cmd_reset_set,
5594 (void *)&cmd_reset_def,
5599 /* *** START FORWARDING *** */
5600 struct cmd_start_result {
5601 cmdline_fixed_string_t start;
5604 cmdline_parse_token_string_t cmd_start_start =
5605 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5607 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5608 __attribute__((unused)) struct cmdline *cl,
5609 __attribute__((unused)) void *data)
5611 start_packet_forwarding(0);
5614 cmdline_parse_inst_t cmd_start = {
5615 .f = cmd_start_parsed,
5617 .help_str = "start: Start packet forwarding",
5619 (void *)&cmd_start_start,
5624 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5625 struct cmd_start_tx_first_result {
5626 cmdline_fixed_string_t start;
5627 cmdline_fixed_string_t tx_first;
5631 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5632 __attribute__((unused)) struct cmdline *cl,
5633 __attribute__((unused)) void *data)
5635 start_packet_forwarding(1);
5638 cmdline_parse_token_string_t cmd_start_tx_first_start =
5639 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5641 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5642 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5643 tx_first, "tx_first");
5645 cmdline_parse_inst_t cmd_start_tx_first = {
5646 .f = cmd_start_tx_first_parsed,
5648 .help_str = "start tx_first: Start packet forwarding, "
5649 "after sending 1 burst of packets",
5651 (void *)&cmd_start_tx_first_start,
5652 (void *)&cmd_start_tx_first_tx_first,
5657 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5658 struct cmd_start_tx_first_n_result {
5659 cmdline_fixed_string_t start;
5660 cmdline_fixed_string_t tx_first;
5665 cmd_start_tx_first_n_parsed(void *parsed_result,
5666 __attribute__((unused)) struct cmdline *cl,
5667 __attribute__((unused)) void *data)
5669 struct cmd_start_tx_first_n_result *res = parsed_result;
5671 start_packet_forwarding(res->tx_num);
5674 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5675 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5677 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5678 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5679 tx_first, "tx_first");
5680 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5681 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5684 cmdline_parse_inst_t cmd_start_tx_first_n = {
5685 .f = cmd_start_tx_first_n_parsed,
5687 .help_str = "start tx_first <num>: "
5688 "packet forwarding, after sending <num> bursts of packets",
5690 (void *)&cmd_start_tx_first_n_start,
5691 (void *)&cmd_start_tx_first_n_tx_first,
5692 (void *)&cmd_start_tx_first_n_tx_num,
5697 /* *** SET LINK UP *** */
5698 struct cmd_set_link_up_result {
5699 cmdline_fixed_string_t set;
5700 cmdline_fixed_string_t link_up;
5701 cmdline_fixed_string_t port;
5705 cmdline_parse_token_string_t cmd_set_link_up_set =
5706 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5707 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5708 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5710 cmdline_parse_token_string_t cmd_set_link_up_port =
5711 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5712 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5713 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5715 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5716 __attribute__((unused)) struct cmdline *cl,
5717 __attribute__((unused)) void *data)
5719 struct cmd_set_link_up_result *res = parsed_result;
5720 dev_set_link_up(res->port_id);
5723 cmdline_parse_inst_t cmd_set_link_up = {
5724 .f = cmd_set_link_up_parsed,
5726 .help_str = "set link-up port <port id>",
5728 (void *)&cmd_set_link_up_set,
5729 (void *)&cmd_set_link_up_link_up,
5730 (void *)&cmd_set_link_up_port,
5731 (void *)&cmd_set_link_up_port_id,
5736 /* *** SET LINK DOWN *** */
5737 struct cmd_set_link_down_result {
5738 cmdline_fixed_string_t set;
5739 cmdline_fixed_string_t link_down;
5740 cmdline_fixed_string_t port;
5744 cmdline_parse_token_string_t cmd_set_link_down_set =
5745 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5746 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5749 cmdline_parse_token_string_t cmd_set_link_down_port =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5751 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5752 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5754 static void cmd_set_link_down_parsed(
5755 __attribute__((unused)) void *parsed_result,
5756 __attribute__((unused)) struct cmdline *cl,
5757 __attribute__((unused)) void *data)
5759 struct cmd_set_link_down_result *res = parsed_result;
5760 dev_set_link_down(res->port_id);
5763 cmdline_parse_inst_t cmd_set_link_down = {
5764 .f = cmd_set_link_down_parsed,
5766 .help_str = "set link-down port <port id>",
5768 (void *)&cmd_set_link_down_set,
5769 (void *)&cmd_set_link_down_link_down,
5770 (void *)&cmd_set_link_down_port,
5771 (void *)&cmd_set_link_down_port_id,
5776 /* *** SHOW CFG *** */
5777 struct cmd_showcfg_result {
5778 cmdline_fixed_string_t show;
5779 cmdline_fixed_string_t cfg;
5780 cmdline_fixed_string_t what;
5783 static void cmd_showcfg_parsed(void *parsed_result,
5784 __attribute__((unused)) struct cmdline *cl,
5785 __attribute__((unused)) void *data)
5787 struct cmd_showcfg_result *res = parsed_result;
5788 if (!strcmp(res->what, "rxtx"))
5789 rxtx_config_display();
5790 else if (!strcmp(res->what, "cores"))
5791 fwd_lcores_config_display();
5792 else if (!strcmp(res->what, "fwd"))
5793 pkt_fwd_config_display(&cur_fwd_config);
5794 else if (!strcmp(res->what, "txpkts"))
5795 show_tx_pkt_segments();
5798 cmdline_parse_token_string_t cmd_showcfg_show =
5799 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5800 cmdline_parse_token_string_t cmd_showcfg_port =
5801 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5802 cmdline_parse_token_string_t cmd_showcfg_what =
5803 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5804 "rxtx#cores#fwd#txpkts");
5806 cmdline_parse_inst_t cmd_showcfg = {
5807 .f = cmd_showcfg_parsed,
5809 .help_str = "show config rxtx|cores|fwd|txpkts",
5811 (void *)&cmd_showcfg_show,
5812 (void *)&cmd_showcfg_port,
5813 (void *)&cmd_showcfg_what,
5818 /* *** SHOW ALL PORT INFO *** */
5819 struct cmd_showportall_result {
5820 cmdline_fixed_string_t show;
5821 cmdline_fixed_string_t port;
5822 cmdline_fixed_string_t what;
5823 cmdline_fixed_string_t all;
5826 static void cmd_showportall_parsed(void *parsed_result,
5827 __attribute__((unused)) struct cmdline *cl,
5828 __attribute__((unused)) void *data)
5832 struct cmd_showportall_result *res = parsed_result;
5833 if (!strcmp(res->show, "clear")) {
5834 if (!strcmp(res->what, "stats"))
5835 FOREACH_PORT(i, ports)
5837 else if (!strcmp(res->what, "xstats"))
5838 FOREACH_PORT(i, ports)
5839 nic_xstats_clear(i);
5840 } else if (!strcmp(res->what, "info"))
5841 FOREACH_PORT(i, ports)
5842 port_infos_display(i);
5843 else if (!strcmp(res->what, "stats"))
5844 FOREACH_PORT(i, ports)
5845 nic_stats_display(i);
5846 else if (!strcmp(res->what, "xstats"))
5847 FOREACH_PORT(i, ports)
5848 nic_xstats_display(i);
5849 else if (!strcmp(res->what, "fdir"))
5850 FOREACH_PORT(i, ports)
5852 else if (!strcmp(res->what, "stat_qmap"))
5853 FOREACH_PORT(i, ports)
5854 nic_stats_mapping_display(i);
5855 else if (!strcmp(res->what, "dcb_tc"))
5856 FOREACH_PORT(i, ports)
5857 port_dcb_info_display(i);
5858 else if (!strcmp(res->what, "cap"))
5859 FOREACH_PORT(i, ports)
5860 port_offload_cap_display(i);
5863 cmdline_parse_token_string_t cmd_showportall_show =
5864 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5866 cmdline_parse_token_string_t cmd_showportall_port =
5867 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5868 cmdline_parse_token_string_t cmd_showportall_what =
5869 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5870 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5871 cmdline_parse_token_string_t cmd_showportall_all =
5872 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5873 cmdline_parse_inst_t cmd_showportall = {
5874 .f = cmd_showportall_parsed,
5876 .help_str = "show|clear port "
5877 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5879 (void *)&cmd_showportall_show,
5880 (void *)&cmd_showportall_port,
5881 (void *)&cmd_showportall_what,
5882 (void *)&cmd_showportall_all,
5887 /* *** SHOW PORT INFO *** */
5888 struct cmd_showport_result {
5889 cmdline_fixed_string_t show;
5890 cmdline_fixed_string_t port;
5891 cmdline_fixed_string_t what;
5895 static void cmd_showport_parsed(void *parsed_result,
5896 __attribute__((unused)) struct cmdline *cl,
5897 __attribute__((unused)) void *data)
5899 struct cmd_showport_result *res = parsed_result;
5900 if (!strcmp(res->show, "clear")) {
5901 if (!strcmp(res->what, "stats"))
5902 nic_stats_clear(res->portnum);
5903 else if (!strcmp(res->what, "xstats"))
5904 nic_xstats_clear(res->portnum);
5905 } else if (!strcmp(res->what, "info"))
5906 port_infos_display(res->portnum);
5907 else if (!strcmp(res->what, "stats"))
5908 nic_stats_display(res->portnum);
5909 else if (!strcmp(res->what, "xstats"))
5910 nic_xstats_display(res->portnum);
5911 else if (!strcmp(res->what, "fdir"))
5912 fdir_get_infos(res->portnum);
5913 else if (!strcmp(res->what, "stat_qmap"))
5914 nic_stats_mapping_display(res->portnum);
5915 else if (!strcmp(res->what, "dcb_tc"))
5916 port_dcb_info_display(res->portnum);
5917 else if (!strcmp(res->what, "cap"))
5918 port_offload_cap_display(res->portnum);
5921 cmdline_parse_token_string_t cmd_showport_show =
5922 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5924 cmdline_parse_token_string_t cmd_showport_port =
5925 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5926 cmdline_parse_token_string_t cmd_showport_what =
5927 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5928 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5929 cmdline_parse_token_num_t cmd_showport_portnum =
5930 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5932 cmdline_parse_inst_t cmd_showport = {
5933 .f = cmd_showport_parsed,
5935 .help_str = "show|clear port "
5936 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5939 (void *)&cmd_showport_show,
5940 (void *)&cmd_showport_port,
5941 (void *)&cmd_showport_what,
5942 (void *)&cmd_showport_portnum,
5947 /* *** SHOW QUEUE INFO *** */
5948 struct cmd_showqueue_result {
5949 cmdline_fixed_string_t show;
5950 cmdline_fixed_string_t type;
5951 cmdline_fixed_string_t what;
5957 cmd_showqueue_parsed(void *parsed_result,
5958 __attribute__((unused)) struct cmdline *cl,
5959 __attribute__((unused)) void *data)
5961 struct cmd_showqueue_result *res = parsed_result;
5963 if (!strcmp(res->type, "rxq"))
5964 rx_queue_infos_display(res->portnum, res->queuenum);
5965 else if (!strcmp(res->type, "txq"))
5966 tx_queue_infos_display(res->portnum, res->queuenum);
5969 cmdline_parse_token_string_t cmd_showqueue_show =
5970 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5971 cmdline_parse_token_string_t cmd_showqueue_type =
5972 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5973 cmdline_parse_token_string_t cmd_showqueue_what =
5974 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5975 cmdline_parse_token_num_t cmd_showqueue_portnum =
5976 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5977 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5978 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5980 cmdline_parse_inst_t cmd_showqueue = {
5981 .f = cmd_showqueue_parsed,
5983 .help_str = "show rxq|txq info <port_id> <queue_id>",
5985 (void *)&cmd_showqueue_show,
5986 (void *)&cmd_showqueue_type,
5987 (void *)&cmd_showqueue_what,
5988 (void *)&cmd_showqueue_portnum,
5989 (void *)&cmd_showqueue_queuenum,
5994 /* *** READ PORT REGISTER *** */
5995 struct cmd_read_reg_result {
5996 cmdline_fixed_string_t read;
5997 cmdline_fixed_string_t reg;
6003 cmd_read_reg_parsed(void *parsed_result,
6004 __attribute__((unused)) struct cmdline *cl,
6005 __attribute__((unused)) void *data)
6007 struct cmd_read_reg_result *res = parsed_result;
6008 port_reg_display(res->port_id, res->reg_off);
6011 cmdline_parse_token_string_t cmd_read_reg_read =
6012 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6013 cmdline_parse_token_string_t cmd_read_reg_reg =
6014 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6015 cmdline_parse_token_num_t cmd_read_reg_port_id =
6016 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6017 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6018 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6020 cmdline_parse_inst_t cmd_read_reg = {
6021 .f = cmd_read_reg_parsed,
6023 .help_str = "read reg <port_id> <reg_off>",
6025 (void *)&cmd_read_reg_read,
6026 (void *)&cmd_read_reg_reg,
6027 (void *)&cmd_read_reg_port_id,
6028 (void *)&cmd_read_reg_reg_off,
6033 /* *** READ PORT REGISTER BIT FIELD *** */
6034 struct cmd_read_reg_bit_field_result {
6035 cmdline_fixed_string_t read;
6036 cmdline_fixed_string_t regfield;
6044 cmd_read_reg_bit_field_parsed(void *parsed_result,
6045 __attribute__((unused)) struct cmdline *cl,
6046 __attribute__((unused)) void *data)
6048 struct cmd_read_reg_bit_field_result *res = parsed_result;
6049 port_reg_bit_field_display(res->port_id, res->reg_off,
6050 res->bit1_pos, res->bit2_pos);
6053 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6054 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6056 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6057 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6058 regfield, "regfield");
6059 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6060 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6062 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6063 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6065 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6066 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6068 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6069 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6072 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6073 .f = cmd_read_reg_bit_field_parsed,
6075 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6076 "Read register bit field between bit_x and bit_y included",
6078 (void *)&cmd_read_reg_bit_field_read,
6079 (void *)&cmd_read_reg_bit_field_regfield,
6080 (void *)&cmd_read_reg_bit_field_port_id,
6081 (void *)&cmd_read_reg_bit_field_reg_off,
6082 (void *)&cmd_read_reg_bit_field_bit1_pos,
6083 (void *)&cmd_read_reg_bit_field_bit2_pos,
6088 /* *** READ PORT REGISTER BIT *** */
6089 struct cmd_read_reg_bit_result {
6090 cmdline_fixed_string_t read;
6091 cmdline_fixed_string_t regbit;
6098 cmd_read_reg_bit_parsed(void *parsed_result,
6099 __attribute__((unused)) struct cmdline *cl,
6100 __attribute__((unused)) void *data)
6102 struct cmd_read_reg_bit_result *res = parsed_result;
6103 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6106 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6107 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6108 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6109 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6111 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6112 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6113 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6114 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6115 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6116 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6118 cmdline_parse_inst_t cmd_read_reg_bit = {
6119 .f = cmd_read_reg_bit_parsed,
6121 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6123 (void *)&cmd_read_reg_bit_read,
6124 (void *)&cmd_read_reg_bit_regbit,
6125 (void *)&cmd_read_reg_bit_port_id,
6126 (void *)&cmd_read_reg_bit_reg_off,
6127 (void *)&cmd_read_reg_bit_bit_pos,
6132 /* *** WRITE PORT REGISTER *** */
6133 struct cmd_write_reg_result {
6134 cmdline_fixed_string_t write;
6135 cmdline_fixed_string_t reg;
6142 cmd_write_reg_parsed(void *parsed_result,
6143 __attribute__((unused)) struct cmdline *cl,
6144 __attribute__((unused)) void *data)
6146 struct cmd_write_reg_result *res = parsed_result;
6147 port_reg_set(res->port_id, res->reg_off, res->value);
6150 cmdline_parse_token_string_t cmd_write_reg_write =
6151 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6152 cmdline_parse_token_string_t cmd_write_reg_reg =
6153 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6154 cmdline_parse_token_num_t cmd_write_reg_port_id =
6155 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6156 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6157 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6158 cmdline_parse_token_num_t cmd_write_reg_value =
6159 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6161 cmdline_parse_inst_t cmd_write_reg = {
6162 .f = cmd_write_reg_parsed,
6164 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6166 (void *)&cmd_write_reg_write,
6167 (void *)&cmd_write_reg_reg,
6168 (void *)&cmd_write_reg_port_id,
6169 (void *)&cmd_write_reg_reg_off,
6170 (void *)&cmd_write_reg_value,
6175 /* *** WRITE PORT REGISTER BIT FIELD *** */
6176 struct cmd_write_reg_bit_field_result {
6177 cmdline_fixed_string_t write;
6178 cmdline_fixed_string_t regfield;
6187 cmd_write_reg_bit_field_parsed(void *parsed_result,
6188 __attribute__((unused)) struct cmdline *cl,
6189 __attribute__((unused)) void *data)
6191 struct cmd_write_reg_bit_field_result *res = parsed_result;
6192 port_reg_bit_field_set(res->port_id, res->reg_off,
6193 res->bit1_pos, res->bit2_pos, res->value);
6196 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6197 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6199 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6200 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6201 regfield, "regfield");
6202 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6203 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6205 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6206 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6208 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6209 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6211 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6212 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6214 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6215 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6218 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6219 .f = cmd_write_reg_bit_field_parsed,
6221 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6223 "Set register bit field between bit_x and bit_y included",
6225 (void *)&cmd_write_reg_bit_field_write,
6226 (void *)&cmd_write_reg_bit_field_regfield,
6227 (void *)&cmd_write_reg_bit_field_port_id,
6228 (void *)&cmd_write_reg_bit_field_reg_off,
6229 (void *)&cmd_write_reg_bit_field_bit1_pos,
6230 (void *)&cmd_write_reg_bit_field_bit2_pos,
6231 (void *)&cmd_write_reg_bit_field_value,
6236 /* *** WRITE PORT REGISTER BIT *** */
6237 struct cmd_write_reg_bit_result {
6238 cmdline_fixed_string_t write;
6239 cmdline_fixed_string_t regbit;
6247 cmd_write_reg_bit_parsed(void *parsed_result,
6248 __attribute__((unused)) struct cmdline *cl,
6249 __attribute__((unused)) void *data)
6251 struct cmd_write_reg_bit_result *res = parsed_result;
6252 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6255 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6256 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6258 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6259 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6261 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6262 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6263 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6264 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6265 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6266 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6267 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6268 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6270 cmdline_parse_inst_t cmd_write_reg_bit = {
6271 .f = cmd_write_reg_bit_parsed,
6273 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6276 (void *)&cmd_write_reg_bit_write,
6277 (void *)&cmd_write_reg_bit_regbit,
6278 (void *)&cmd_write_reg_bit_port_id,
6279 (void *)&cmd_write_reg_bit_reg_off,
6280 (void *)&cmd_write_reg_bit_bit_pos,
6281 (void *)&cmd_write_reg_bit_value,
6286 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6287 struct cmd_read_rxd_txd_result {
6288 cmdline_fixed_string_t read;
6289 cmdline_fixed_string_t rxd_txd;
6296 cmd_read_rxd_txd_parsed(void *parsed_result,
6297 __attribute__((unused)) struct cmdline *cl,
6298 __attribute__((unused)) void *data)
6300 struct cmd_read_rxd_txd_result *res = parsed_result;
6302 if (!strcmp(res->rxd_txd, "rxd"))
6303 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6304 else if (!strcmp(res->rxd_txd, "txd"))
6305 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6308 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6309 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6310 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6311 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6313 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6314 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6315 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6316 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6317 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6318 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6320 cmdline_parse_inst_t cmd_read_rxd_txd = {
6321 .f = cmd_read_rxd_txd_parsed,
6323 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6325 (void *)&cmd_read_rxd_txd_read,
6326 (void *)&cmd_read_rxd_txd_rxd_txd,
6327 (void *)&cmd_read_rxd_txd_port_id,
6328 (void *)&cmd_read_rxd_txd_queue_id,
6329 (void *)&cmd_read_rxd_txd_desc_id,
6335 struct cmd_quit_result {
6336 cmdline_fixed_string_t quit;
6339 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6341 __attribute__((unused)) void *data)
6347 cmdline_parse_token_string_t cmd_quit_quit =
6348 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6350 cmdline_parse_inst_t cmd_quit = {
6351 .f = cmd_quit_parsed,
6353 .help_str = "quit: Exit application",
6355 (void *)&cmd_quit_quit,
6360 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6361 struct cmd_mac_addr_result {
6362 cmdline_fixed_string_t mac_addr_cmd;
6363 cmdline_fixed_string_t what;
6365 struct ether_addr address;
6368 static void cmd_mac_addr_parsed(void *parsed_result,
6369 __attribute__((unused)) struct cmdline *cl,
6370 __attribute__((unused)) void *data)
6372 struct cmd_mac_addr_result *res = parsed_result;
6375 if (strcmp(res->what, "add") == 0)
6376 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6377 else if (strcmp(res->what, "set") == 0)
6378 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6381 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6383 /* check the return value and print it if is < 0 */
6385 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6389 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6390 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6392 cmdline_parse_token_string_t cmd_mac_addr_what =
6393 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6395 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6396 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6397 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6398 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6400 cmdline_parse_inst_t cmd_mac_addr = {
6401 .f = cmd_mac_addr_parsed,
6403 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6404 "Add/Remove/Set MAC address on port_id",
6406 (void *)&cmd_mac_addr_cmd,
6407 (void *)&cmd_mac_addr_what,
6408 (void *)&cmd_mac_addr_portnum,
6409 (void *)&cmd_mac_addr_addr,
6415 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6416 struct cmd_set_qmap_result {
6417 cmdline_fixed_string_t set;
6418 cmdline_fixed_string_t qmap;
6419 cmdline_fixed_string_t what;
6426 cmd_set_qmap_parsed(void *parsed_result,
6427 __attribute__((unused)) struct cmdline *cl,
6428 __attribute__((unused)) void *data)
6430 struct cmd_set_qmap_result *res = parsed_result;
6431 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6433 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6436 cmdline_parse_token_string_t cmd_setqmap_set =
6437 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6439 cmdline_parse_token_string_t cmd_setqmap_qmap =
6440 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6442 cmdline_parse_token_string_t cmd_setqmap_what =
6443 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6445 cmdline_parse_token_num_t cmd_setqmap_portid =
6446 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6448 cmdline_parse_token_num_t cmd_setqmap_queueid =
6449 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6451 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6452 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6455 cmdline_parse_inst_t cmd_set_qmap = {
6456 .f = cmd_set_qmap_parsed,
6458 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6459 "Set statistics mapping value on tx|rx queue_id of port_id",
6461 (void *)&cmd_setqmap_set,
6462 (void *)&cmd_setqmap_qmap,
6463 (void *)&cmd_setqmap_what,
6464 (void *)&cmd_setqmap_portid,
6465 (void *)&cmd_setqmap_queueid,
6466 (void *)&cmd_setqmap_mapvalue,
6471 /* *** CONFIGURE UNICAST HASH TABLE *** */
6472 struct cmd_set_uc_hash_table {
6473 cmdline_fixed_string_t set;
6474 cmdline_fixed_string_t port;
6476 cmdline_fixed_string_t what;
6477 struct ether_addr address;
6478 cmdline_fixed_string_t mode;
6482 cmd_set_uc_hash_parsed(void *parsed_result,
6483 __attribute__((unused)) struct cmdline *cl,
6484 __attribute__((unused)) void *data)
6487 struct cmd_set_uc_hash_table *res = parsed_result;
6489 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6491 if (strcmp(res->what, "uta") == 0)
6492 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6493 &res->address,(uint8_t)is_on);
6495 printf("bad unicast hash table parameter, return code = %d \n", ret);
6499 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6502 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6503 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6505 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6506 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6508 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6509 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6511 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6512 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6514 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6515 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6518 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6519 .f = cmd_set_uc_hash_parsed,
6521 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6523 (void *)&cmd_set_uc_hash_set,
6524 (void *)&cmd_set_uc_hash_port,
6525 (void *)&cmd_set_uc_hash_portid,
6526 (void *)&cmd_set_uc_hash_what,
6527 (void *)&cmd_set_uc_hash_mac,
6528 (void *)&cmd_set_uc_hash_mode,
6533 struct cmd_set_uc_all_hash_table {
6534 cmdline_fixed_string_t set;
6535 cmdline_fixed_string_t port;
6537 cmdline_fixed_string_t what;
6538 cmdline_fixed_string_t value;
6539 cmdline_fixed_string_t mode;
6543 cmd_set_uc_all_hash_parsed(void *parsed_result,
6544 __attribute__((unused)) struct cmdline *cl,
6545 __attribute__((unused)) void *data)
6548 struct cmd_set_uc_all_hash_table *res = parsed_result;
6550 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6552 if ((strcmp(res->what, "uta") == 0) &&
6553 (strcmp(res->value, "all") == 0))
6554 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6556 printf("bad unicast hash table parameter,"
6557 "return code = %d \n", ret);
6560 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6561 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6563 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6564 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6566 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6567 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6569 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6570 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6572 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6573 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6575 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6576 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6579 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6580 .f = cmd_set_uc_all_hash_parsed,
6582 .help_str = "set port <port_id> uta all on|off",
6584 (void *)&cmd_set_uc_all_hash_set,
6585 (void *)&cmd_set_uc_all_hash_port,
6586 (void *)&cmd_set_uc_all_hash_portid,
6587 (void *)&cmd_set_uc_all_hash_what,
6588 (void *)&cmd_set_uc_all_hash_value,
6589 (void *)&cmd_set_uc_all_hash_mode,
6594 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6595 struct cmd_set_vf_macvlan_filter {
6596 cmdline_fixed_string_t set;
6597 cmdline_fixed_string_t port;
6599 cmdline_fixed_string_t vf;
6601 struct ether_addr address;
6602 cmdline_fixed_string_t filter_type;
6603 cmdline_fixed_string_t mode;
6607 cmd_set_vf_macvlan_parsed(void *parsed_result,
6608 __attribute__((unused)) struct cmdline *cl,
6609 __attribute__((unused)) void *data)
6612 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6613 struct rte_eth_mac_filter filter;
6615 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6617 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6619 /* set VF MAC filter */
6623 filter.dst_id = res->vf_id;
6625 if (!strcmp(res->filter_type, "exact-mac"))
6626 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6627 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6628 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6629 else if (!strcmp(res->filter_type, "hashmac"))
6630 filter.filter_type = RTE_MAC_HASH_MATCH;
6631 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6632 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6634 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6637 ret = rte_eth_dev_filter_ctrl(res->port_id,
6638 RTE_ETH_FILTER_MACVLAN,
6642 ret = rte_eth_dev_filter_ctrl(res->port_id,
6643 RTE_ETH_FILTER_MACVLAN,
6644 RTE_ETH_FILTER_DELETE,
6648 printf("bad set MAC hash parameter, return code = %d\n", ret);
6652 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6653 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6655 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6656 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6658 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6659 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6661 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6662 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6664 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6665 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6667 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6668 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6670 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6671 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6672 filter_type, "exact-mac#exact-mac-vlan"
6673 "#hashmac#hashmac-vlan");
6674 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6675 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6678 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6679 .f = cmd_set_vf_macvlan_parsed,
6681 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6682 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6683 "Exact match rule: exact match of MAC or MAC and VLAN; "
6684 "hash match rule: hash match of MAC and exact match of VLAN",
6686 (void *)&cmd_set_vf_macvlan_set,
6687 (void *)&cmd_set_vf_macvlan_port,
6688 (void *)&cmd_set_vf_macvlan_portid,
6689 (void *)&cmd_set_vf_macvlan_vf,
6690 (void *)&cmd_set_vf_macvlan_vf_id,
6691 (void *)&cmd_set_vf_macvlan_mac,
6692 (void *)&cmd_set_vf_macvlan_filter_type,
6693 (void *)&cmd_set_vf_macvlan_mode,
6698 #ifdef RTE_LIBRTE_IXGBE_PMD
6699 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6700 struct cmd_set_vf_traffic {
6701 cmdline_fixed_string_t set;
6702 cmdline_fixed_string_t port;
6704 cmdline_fixed_string_t vf;
6706 cmdline_fixed_string_t what;
6707 cmdline_fixed_string_t mode;
6711 cmd_set_vf_traffic_parsed(void *parsed_result,
6712 __attribute__((unused)) struct cmdline *cl,
6713 __attribute__((unused)) void *data)
6715 struct cmd_set_vf_traffic *res = parsed_result;
6716 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6717 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6719 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6722 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6723 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6725 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6726 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6728 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6729 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6731 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6732 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6734 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6735 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6737 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6738 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6740 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6744 cmdline_parse_inst_t cmd_set_vf_traffic = {
6745 .f = cmd_set_vf_traffic_parsed,
6747 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6749 (void *)&cmd_setvf_traffic_set,
6750 (void *)&cmd_setvf_traffic_port,
6751 (void *)&cmd_setvf_traffic_portid,
6752 (void *)&cmd_setvf_traffic_vf,
6753 (void *)&cmd_setvf_traffic_vfid,
6754 (void *)&cmd_setvf_traffic_what,
6755 (void *)&cmd_setvf_traffic_mode,
6760 /* *** CONFIGURE VF RECEIVE MODE *** */
6761 struct cmd_set_vf_rxmode {
6762 cmdline_fixed_string_t set;
6763 cmdline_fixed_string_t port;
6765 cmdline_fixed_string_t vf;
6767 cmdline_fixed_string_t what;
6768 cmdline_fixed_string_t mode;
6769 cmdline_fixed_string_t on;
6773 cmd_set_vf_rxmode_parsed(void *parsed_result,
6774 __attribute__((unused)) struct cmdline *cl,
6775 __attribute__((unused)) void *data)
6778 uint16_t rx_mode = 0;
6779 struct cmd_set_vf_rxmode *res = parsed_result;
6781 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6782 if (!strcmp(res->what,"rxmode")) {
6783 if (!strcmp(res->mode, "AUPE"))
6784 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6785 else if (!strcmp(res->mode, "ROPE"))
6786 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6787 else if (!strcmp(res->mode, "BAM"))
6788 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6789 else if (!strncmp(res->mode, "MPE",3))
6790 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6793 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6795 printf("bad VF receive mode parameter, return code = %d \n",
6799 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6800 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6802 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6803 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6805 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6806 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6808 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6809 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6811 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6812 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6814 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6815 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6817 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6818 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6819 mode, "AUPE#ROPE#BAM#MPE");
6820 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6821 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6824 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6825 .f = cmd_set_vf_rxmode_parsed,
6827 .help_str = "set port <port_id> vf <vf_id> rxmode "
6828 "AUPE|ROPE|BAM|MPE on|off",
6830 (void *)&cmd_set_vf_rxmode_set,
6831 (void *)&cmd_set_vf_rxmode_port,
6832 (void *)&cmd_set_vf_rxmode_portid,
6833 (void *)&cmd_set_vf_rxmode_vf,
6834 (void *)&cmd_set_vf_rxmode_vfid,
6835 (void *)&cmd_set_vf_rxmode_what,
6836 (void *)&cmd_set_vf_rxmode_mode,
6837 (void *)&cmd_set_vf_rxmode_on,
6843 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6844 struct cmd_vf_mac_addr_result {
6845 cmdline_fixed_string_t mac_addr_cmd;
6846 cmdline_fixed_string_t what;
6847 cmdline_fixed_string_t port;
6849 cmdline_fixed_string_t vf;
6851 struct ether_addr address;
6854 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6855 __attribute__((unused)) struct cmdline *cl,
6856 __attribute__((unused)) void *data)
6858 struct cmd_vf_mac_addr_result *res = parsed_result;
6861 if (strcmp(res->what, "add") == 0)
6862 ret = rte_eth_dev_mac_addr_add(res->port_num,
6863 &res->address, res->vf_num);
6865 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6869 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6870 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6871 mac_addr_cmd,"mac_addr");
6872 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6873 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6875 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6876 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6878 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6879 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6881 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6882 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6884 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6885 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6887 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6888 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6891 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6892 .f = cmd_vf_mac_addr_parsed,
6894 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6895 "Add MAC address filtering for a VF on port_id",
6897 (void *)&cmd_vf_mac_addr_cmd,
6898 (void *)&cmd_vf_mac_addr_what,
6899 (void *)&cmd_vf_mac_addr_port,
6900 (void *)&cmd_vf_mac_addr_portnum,
6901 (void *)&cmd_vf_mac_addr_vf,
6902 (void *)&cmd_vf_mac_addr_vfnum,
6903 (void *)&cmd_vf_mac_addr_addr,
6908 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6909 struct cmd_vf_rx_vlan_filter {
6910 cmdline_fixed_string_t rx_vlan;
6911 cmdline_fixed_string_t what;
6913 cmdline_fixed_string_t port;
6915 cmdline_fixed_string_t vf;
6920 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6921 __attribute__((unused)) struct cmdline *cl,
6922 __attribute__((unused)) void *data)
6924 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6927 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6929 #ifdef RTE_LIBRTE_IXGBE_PMD
6930 if (ret == -ENOTSUP)
6931 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6932 res->vlan_id, res->vf_mask, is_add);
6934 #ifdef RTE_LIBRTE_I40E_PMD
6935 if (ret == -ENOTSUP)
6936 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6937 res->vlan_id, res->vf_mask, is_add);
6944 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6945 res->vlan_id, res->vf_mask);
6948 printf("invalid port_id %d\n", res->port_id);
6951 printf("function not implemented or supported\n");
6954 printf("programming error: (%s)\n", strerror(-ret));
6958 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6959 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6960 rx_vlan, "rx_vlan");
6961 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6962 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6964 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6965 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6967 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6968 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6970 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6971 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6973 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6974 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6976 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6977 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6980 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6981 .f = cmd_vf_rx_vlan_filter_parsed,
6983 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6984 "(vf_mask = hexadecimal VF mask)",
6986 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6987 (void *)&cmd_vf_rx_vlan_filter_what,
6988 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6989 (void *)&cmd_vf_rx_vlan_filter_port,
6990 (void *)&cmd_vf_rx_vlan_filter_portid,
6991 (void *)&cmd_vf_rx_vlan_filter_vf,
6992 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6997 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6998 struct cmd_queue_rate_limit_result {
6999 cmdline_fixed_string_t set;
7000 cmdline_fixed_string_t port;
7002 cmdline_fixed_string_t queue;
7004 cmdline_fixed_string_t rate;
7008 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7009 __attribute__((unused)) struct cmdline *cl,
7010 __attribute__((unused)) void *data)
7012 struct cmd_queue_rate_limit_result *res = parsed_result;
7015 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7016 && (strcmp(res->queue, "queue") == 0)
7017 && (strcmp(res->rate, "rate") == 0))
7018 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7021 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7025 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7026 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7028 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7029 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7031 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7032 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7034 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7035 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7037 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7038 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7040 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7041 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7043 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7044 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7047 cmdline_parse_inst_t cmd_queue_rate_limit = {
7048 .f = cmd_queue_rate_limit_parsed,
7050 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7051 "Set rate limit for a queue on port_id",
7053 (void *)&cmd_queue_rate_limit_set,
7054 (void *)&cmd_queue_rate_limit_port,
7055 (void *)&cmd_queue_rate_limit_portnum,
7056 (void *)&cmd_queue_rate_limit_queue,
7057 (void *)&cmd_queue_rate_limit_queuenum,
7058 (void *)&cmd_queue_rate_limit_rate,
7059 (void *)&cmd_queue_rate_limit_ratenum,
7064 #ifdef RTE_LIBRTE_IXGBE_PMD
7065 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7066 struct cmd_vf_rate_limit_result {
7067 cmdline_fixed_string_t set;
7068 cmdline_fixed_string_t port;
7070 cmdline_fixed_string_t vf;
7072 cmdline_fixed_string_t rate;
7074 cmdline_fixed_string_t q_msk;
7078 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7079 __attribute__((unused)) struct cmdline *cl,
7080 __attribute__((unused)) void *data)
7082 struct cmd_vf_rate_limit_result *res = parsed_result;
7085 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7086 && (strcmp(res->vf, "vf") == 0)
7087 && (strcmp(res->rate, "rate") == 0)
7088 && (strcmp(res->q_msk, "queue_mask") == 0))
7089 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7090 res->rate_num, res->q_msk_val);
7092 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7096 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7097 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7099 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7100 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7102 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7103 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7105 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7106 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7108 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7109 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7111 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7112 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7114 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7115 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7117 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7118 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7119 q_msk, "queue_mask");
7120 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7121 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7124 cmdline_parse_inst_t cmd_vf_rate_limit = {
7125 .f = cmd_vf_rate_limit_parsed,
7127 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7128 "queue_mask <queue_mask_value>: "
7129 "Set rate limit for queues of VF on port_id",
7131 (void *)&cmd_vf_rate_limit_set,
7132 (void *)&cmd_vf_rate_limit_port,
7133 (void *)&cmd_vf_rate_limit_portnum,
7134 (void *)&cmd_vf_rate_limit_vf,
7135 (void *)&cmd_vf_rate_limit_vfnum,
7136 (void *)&cmd_vf_rate_limit_rate,
7137 (void *)&cmd_vf_rate_limit_ratenum,
7138 (void *)&cmd_vf_rate_limit_q_msk,
7139 (void *)&cmd_vf_rate_limit_q_msk_val,
7145 /* *** ADD TUNNEL FILTER OF A PORT *** */
7146 struct cmd_tunnel_filter_result {
7147 cmdline_fixed_string_t cmd;
7148 cmdline_fixed_string_t what;
7150 struct ether_addr outer_mac;
7151 struct ether_addr inner_mac;
7152 cmdline_ipaddr_t ip_value;
7153 uint16_t inner_vlan;
7154 cmdline_fixed_string_t tunnel_type;
7155 cmdline_fixed_string_t filter_type;
7161 cmd_tunnel_filter_parsed(void *parsed_result,
7162 __attribute__((unused)) struct cmdline *cl,
7163 __attribute__((unused)) void *data)
7165 struct cmd_tunnel_filter_result *res = parsed_result;
7166 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7169 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7171 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7172 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7173 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7175 if (res->ip_value.family == AF_INET) {
7176 tunnel_filter_conf.ip_addr.ipv4_addr =
7177 res->ip_value.addr.ipv4.s_addr;
7178 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7180 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7181 &(res->ip_value.addr.ipv6),
7182 sizeof(struct in6_addr));
7183 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7186 if (!strcmp(res->filter_type, "imac-ivlan"))
7187 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7188 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7189 tunnel_filter_conf.filter_type =
7190 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7191 else if (!strcmp(res->filter_type, "imac-tenid"))
7192 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7193 else if (!strcmp(res->filter_type, "imac"))
7194 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7195 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7196 tunnel_filter_conf.filter_type =
7197 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7198 else if (!strcmp(res->filter_type, "oip"))
7199 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7200 else if (!strcmp(res->filter_type, "iip"))
7201 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7203 printf("The filter type is not supported");
7207 if (!strcmp(res->tunnel_type, "vxlan"))
7208 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7209 else if (!strcmp(res->tunnel_type, "nvgre"))
7210 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7211 else if (!strcmp(res->tunnel_type, "ipingre"))
7212 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7214 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7218 tunnel_filter_conf.tenant_id = res->tenant_id;
7219 tunnel_filter_conf.queue_id = res->queue_num;
7220 if (!strcmp(res->what, "add"))
7221 ret = rte_eth_dev_filter_ctrl(res->port_id,
7222 RTE_ETH_FILTER_TUNNEL,
7224 &tunnel_filter_conf);
7226 ret = rte_eth_dev_filter_ctrl(res->port_id,
7227 RTE_ETH_FILTER_TUNNEL,
7228 RTE_ETH_FILTER_DELETE,
7229 &tunnel_filter_conf);
7231 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7235 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7236 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7237 cmd, "tunnel_filter");
7238 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7239 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7241 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7242 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7244 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7245 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7247 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7248 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7250 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7251 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7252 inner_vlan, UINT16);
7253 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7254 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7256 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7257 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7258 tunnel_type, "vxlan#nvgre#ipingre");
7260 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7261 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7262 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7263 "imac#omac-imac-tenid");
7264 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7265 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7267 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7268 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7271 cmdline_parse_inst_t cmd_tunnel_filter = {
7272 .f = cmd_tunnel_filter_parsed,
7274 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7275 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7276 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7277 "<queue_id>: Add/Rm tunnel filter of a port",
7279 (void *)&cmd_tunnel_filter_cmd,
7280 (void *)&cmd_tunnel_filter_what,
7281 (void *)&cmd_tunnel_filter_port_id,
7282 (void *)&cmd_tunnel_filter_outer_mac,
7283 (void *)&cmd_tunnel_filter_inner_mac,
7284 (void *)&cmd_tunnel_filter_ip_value,
7285 (void *)&cmd_tunnel_filter_innner_vlan,
7286 (void *)&cmd_tunnel_filter_tunnel_type,
7287 (void *)&cmd_tunnel_filter_filter_type,
7288 (void *)&cmd_tunnel_filter_tenant_id,
7289 (void *)&cmd_tunnel_filter_queue_num,
7294 /* *** CONFIGURE TUNNEL UDP PORT *** */
7295 struct cmd_tunnel_udp_config {
7296 cmdline_fixed_string_t cmd;
7297 cmdline_fixed_string_t what;
7303 cmd_tunnel_udp_config_parsed(void *parsed_result,
7304 __attribute__((unused)) struct cmdline *cl,
7305 __attribute__((unused)) void *data)
7307 struct cmd_tunnel_udp_config *res = parsed_result;
7308 struct rte_eth_udp_tunnel tunnel_udp;
7311 tunnel_udp.udp_port = res->udp_port;
7313 if (!strcmp(res->cmd, "rx_vxlan_port"))
7314 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7316 if (!strcmp(res->what, "add"))
7317 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7320 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7324 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7327 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7328 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7329 cmd, "rx_vxlan_port");
7330 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7331 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7333 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7334 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7336 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7337 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7340 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7341 .f = cmd_tunnel_udp_config_parsed,
7343 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7344 "Add/Remove a tunneling UDP port filter",
7346 (void *)&cmd_tunnel_udp_config_cmd,
7347 (void *)&cmd_tunnel_udp_config_what,
7348 (void *)&cmd_tunnel_udp_config_udp_port,
7349 (void *)&cmd_tunnel_udp_config_port_id,
7354 /* *** GLOBAL CONFIG *** */
7355 struct cmd_global_config_result {
7356 cmdline_fixed_string_t cmd;
7358 cmdline_fixed_string_t cfg_type;
7363 cmd_global_config_parsed(void *parsed_result,
7364 __attribute__((unused)) struct cmdline *cl,
7365 __attribute__((unused)) void *data)
7367 struct cmd_global_config_result *res = parsed_result;
7368 struct rte_eth_global_cfg conf;
7371 memset(&conf, 0, sizeof(conf));
7372 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7373 conf.cfg.gre_key_len = res->len;
7374 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7375 RTE_ETH_FILTER_SET, &conf);
7377 printf("Global config error\n");
7380 cmdline_parse_token_string_t cmd_global_config_cmd =
7381 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7383 cmdline_parse_token_num_t cmd_global_config_port_id =
7384 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7385 cmdline_parse_token_string_t cmd_global_config_type =
7386 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7387 cfg_type, "gre-key-len");
7388 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7389 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7392 cmdline_parse_inst_t cmd_global_config = {
7393 .f = cmd_global_config_parsed,
7394 .data = (void *)NULL,
7395 .help_str = "global_config <port_id> gre-key-len <key_len>",
7397 (void *)&cmd_global_config_cmd,
7398 (void *)&cmd_global_config_port_id,
7399 (void *)&cmd_global_config_type,
7400 (void *)&cmd_global_config_gre_key_len,
7405 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7406 struct cmd_set_mirror_mask_result {
7407 cmdline_fixed_string_t set;
7408 cmdline_fixed_string_t port;
7410 cmdline_fixed_string_t mirror;
7412 cmdline_fixed_string_t what;
7413 cmdline_fixed_string_t value;
7414 cmdline_fixed_string_t dstpool;
7416 cmdline_fixed_string_t on;
7419 cmdline_parse_token_string_t cmd_mirror_mask_set =
7420 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7422 cmdline_parse_token_string_t cmd_mirror_mask_port =
7423 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7425 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7426 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7428 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7429 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7430 mirror, "mirror-rule");
7431 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7432 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7434 cmdline_parse_token_string_t cmd_mirror_mask_what =
7435 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7436 what, "pool-mirror-up#pool-mirror-down"
7438 cmdline_parse_token_string_t cmd_mirror_mask_value =
7439 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7441 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7442 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7443 dstpool, "dst-pool");
7444 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7445 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7447 cmdline_parse_token_string_t cmd_mirror_mask_on =
7448 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7452 cmd_set_mirror_mask_parsed(void *parsed_result,
7453 __attribute__((unused)) struct cmdline *cl,
7454 __attribute__((unused)) void *data)
7457 struct cmd_set_mirror_mask_result *res = parsed_result;
7458 struct rte_eth_mirror_conf mr_conf;
7460 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7462 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7464 mr_conf.dst_pool = res->dstpool_id;
7466 if (!strcmp(res->what, "pool-mirror-up")) {
7467 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7468 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7469 } else if (!strcmp(res->what, "pool-mirror-down")) {
7470 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7471 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7472 } else if (!strcmp(res->what, "vlan-mirror")) {
7473 mr_conf.rule_type = ETH_MIRROR_VLAN;
7474 nb_item = parse_item_list(res->value, "vlan",
7475 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7479 for (i = 0; i < nb_item; i++) {
7480 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7481 printf("Invalid vlan_id: must be < 4096\n");
7485 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7486 mr_conf.vlan.vlan_mask |= 1ULL << i;
7490 if (!strcmp(res->on, "on"))
7491 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7494 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7497 printf("mirror rule add error: (%s)\n", strerror(-ret));
7500 cmdline_parse_inst_t cmd_set_mirror_mask = {
7501 .f = cmd_set_mirror_mask_parsed,
7503 .help_str = "set port <port_id> mirror-rule <rule_id> "
7504 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7505 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7507 (void *)&cmd_mirror_mask_set,
7508 (void *)&cmd_mirror_mask_port,
7509 (void *)&cmd_mirror_mask_portid,
7510 (void *)&cmd_mirror_mask_mirror,
7511 (void *)&cmd_mirror_mask_ruleid,
7512 (void *)&cmd_mirror_mask_what,
7513 (void *)&cmd_mirror_mask_value,
7514 (void *)&cmd_mirror_mask_dstpool,
7515 (void *)&cmd_mirror_mask_poolid,
7516 (void *)&cmd_mirror_mask_on,
7521 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7522 struct cmd_set_mirror_link_result {
7523 cmdline_fixed_string_t set;
7524 cmdline_fixed_string_t port;
7526 cmdline_fixed_string_t mirror;
7528 cmdline_fixed_string_t what;
7529 cmdline_fixed_string_t dstpool;
7531 cmdline_fixed_string_t on;
7534 cmdline_parse_token_string_t cmd_mirror_link_set =
7535 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7537 cmdline_parse_token_string_t cmd_mirror_link_port =
7538 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7540 cmdline_parse_token_num_t cmd_mirror_link_portid =
7541 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7543 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7544 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7545 mirror, "mirror-rule");
7546 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7547 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7549 cmdline_parse_token_string_t cmd_mirror_link_what =
7550 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7551 what, "uplink-mirror#downlink-mirror");
7552 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7553 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7554 dstpool, "dst-pool");
7555 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7556 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7558 cmdline_parse_token_string_t cmd_mirror_link_on =
7559 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7563 cmd_set_mirror_link_parsed(void *parsed_result,
7564 __attribute__((unused)) struct cmdline *cl,
7565 __attribute__((unused)) void *data)
7568 struct cmd_set_mirror_link_result *res = parsed_result;
7569 struct rte_eth_mirror_conf mr_conf;
7571 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7572 if (!strcmp(res->what, "uplink-mirror"))
7573 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7575 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7577 mr_conf.dst_pool = res->dstpool_id;
7579 if (!strcmp(res->on, "on"))
7580 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7583 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7586 /* check the return value and print it if is < 0 */
7588 printf("mirror rule add error: (%s)\n", strerror(-ret));
7592 cmdline_parse_inst_t cmd_set_mirror_link = {
7593 .f = cmd_set_mirror_link_parsed,
7595 .help_str = "set port <port_id> mirror-rule <rule_id> "
7596 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7598 (void *)&cmd_mirror_link_set,
7599 (void *)&cmd_mirror_link_port,
7600 (void *)&cmd_mirror_link_portid,
7601 (void *)&cmd_mirror_link_mirror,
7602 (void *)&cmd_mirror_link_ruleid,
7603 (void *)&cmd_mirror_link_what,
7604 (void *)&cmd_mirror_link_dstpool,
7605 (void *)&cmd_mirror_link_poolid,
7606 (void *)&cmd_mirror_link_on,
7611 /* *** RESET VM MIRROR RULE *** */
7612 struct cmd_rm_mirror_rule_result {
7613 cmdline_fixed_string_t reset;
7614 cmdline_fixed_string_t port;
7616 cmdline_fixed_string_t mirror;
7620 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7621 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7623 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7624 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7626 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7627 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7629 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7630 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7631 mirror, "mirror-rule");
7632 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7633 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7637 cmd_reset_mirror_rule_parsed(void *parsed_result,
7638 __attribute__((unused)) struct cmdline *cl,
7639 __attribute__((unused)) void *data)
7642 struct cmd_set_mirror_link_result *res = parsed_result;
7644 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7646 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7649 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7650 .f = cmd_reset_mirror_rule_parsed,
7652 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7654 (void *)&cmd_rm_mirror_rule_reset,
7655 (void *)&cmd_rm_mirror_rule_port,
7656 (void *)&cmd_rm_mirror_rule_portid,
7657 (void *)&cmd_rm_mirror_rule_mirror,
7658 (void *)&cmd_rm_mirror_rule_ruleid,
7663 /* ******************************************************************************** */
7665 struct cmd_dump_result {
7666 cmdline_fixed_string_t dump;
7670 dump_struct_sizes(void)
7672 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7673 DUMP_SIZE(struct rte_mbuf);
7674 DUMP_SIZE(struct rte_mempool);
7675 DUMP_SIZE(struct rte_ring);
7679 static void cmd_dump_parsed(void *parsed_result,
7680 __attribute__((unused)) struct cmdline *cl,
7681 __attribute__((unused)) void *data)
7683 struct cmd_dump_result *res = parsed_result;
7685 if (!strcmp(res->dump, "dump_physmem"))
7686 rte_dump_physmem_layout(stdout);
7687 else if (!strcmp(res->dump, "dump_memzone"))
7688 rte_memzone_dump(stdout);
7689 else if (!strcmp(res->dump, "dump_struct_sizes"))
7690 dump_struct_sizes();
7691 else if (!strcmp(res->dump, "dump_ring"))
7692 rte_ring_list_dump(stdout);
7693 else if (!strcmp(res->dump, "dump_mempool"))
7694 rte_mempool_list_dump(stdout);
7695 else if (!strcmp(res->dump, "dump_devargs"))
7696 rte_eal_devargs_dump(stdout);
7699 cmdline_parse_token_string_t cmd_dump_dump =
7700 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7703 "dump_struct_sizes#"
7708 cmdline_parse_inst_t cmd_dump = {
7709 .f = cmd_dump_parsed, /* function to call */
7710 .data = NULL, /* 2nd arg of func */
7711 .help_str = "Dump status",
7712 .tokens = { /* token list, NULL terminated */
7713 (void *)&cmd_dump_dump,
7718 /* ******************************************************************************** */
7720 struct cmd_dump_one_result {
7721 cmdline_fixed_string_t dump;
7722 cmdline_fixed_string_t name;
7725 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7726 __attribute__((unused)) void *data)
7728 struct cmd_dump_one_result *res = parsed_result;
7730 if (!strcmp(res->dump, "dump_ring")) {
7732 r = rte_ring_lookup(res->name);
7734 cmdline_printf(cl, "Cannot find ring\n");
7737 rte_ring_dump(stdout, r);
7738 } else if (!strcmp(res->dump, "dump_mempool")) {
7739 struct rte_mempool *mp;
7740 mp = rte_mempool_lookup(res->name);
7742 cmdline_printf(cl, "Cannot find mempool\n");
7745 rte_mempool_dump(stdout, mp);
7749 cmdline_parse_token_string_t cmd_dump_one_dump =
7750 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7751 "dump_ring#dump_mempool");
7753 cmdline_parse_token_string_t cmd_dump_one_name =
7754 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7756 cmdline_parse_inst_t cmd_dump_one = {
7757 .f = cmd_dump_one_parsed, /* function to call */
7758 .data = NULL, /* 2nd arg of func */
7759 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7760 .tokens = { /* token list, NULL terminated */
7761 (void *)&cmd_dump_one_dump,
7762 (void *)&cmd_dump_one_name,
7767 /* *** Add/Del syn filter *** */
7768 struct cmd_syn_filter_result {
7769 cmdline_fixed_string_t filter;
7771 cmdline_fixed_string_t ops;
7772 cmdline_fixed_string_t priority;
7773 cmdline_fixed_string_t high;
7774 cmdline_fixed_string_t queue;
7779 cmd_syn_filter_parsed(void *parsed_result,
7780 __attribute__((unused)) struct cmdline *cl,
7781 __attribute__((unused)) void *data)
7783 struct cmd_syn_filter_result *res = parsed_result;
7784 struct rte_eth_syn_filter syn_filter;
7787 ret = rte_eth_dev_filter_supported(res->port_id,
7788 RTE_ETH_FILTER_SYN);
7790 printf("syn filter is not supported on port %u.\n",
7795 memset(&syn_filter, 0, sizeof(syn_filter));
7797 if (!strcmp(res->ops, "add")) {
7798 if (!strcmp(res->high, "high"))
7799 syn_filter.hig_pri = 1;
7801 syn_filter.hig_pri = 0;
7803 syn_filter.queue = res->queue_id;
7804 ret = rte_eth_dev_filter_ctrl(res->port_id,
7809 ret = rte_eth_dev_filter_ctrl(res->port_id,
7811 RTE_ETH_FILTER_DELETE,
7815 printf("syn filter programming error: (%s)\n",
7819 cmdline_parse_token_string_t cmd_syn_filter_filter =
7820 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7821 filter, "syn_filter");
7822 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7823 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7825 cmdline_parse_token_string_t cmd_syn_filter_ops =
7826 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7828 cmdline_parse_token_string_t cmd_syn_filter_priority =
7829 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7830 priority, "priority");
7831 cmdline_parse_token_string_t cmd_syn_filter_high =
7832 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7834 cmdline_parse_token_string_t cmd_syn_filter_queue =
7835 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7837 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7838 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7841 cmdline_parse_inst_t cmd_syn_filter = {
7842 .f = cmd_syn_filter_parsed,
7844 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7845 "<queue_id>: Add/Delete syn filter",
7847 (void *)&cmd_syn_filter_filter,
7848 (void *)&cmd_syn_filter_port_id,
7849 (void *)&cmd_syn_filter_ops,
7850 (void *)&cmd_syn_filter_priority,
7851 (void *)&cmd_syn_filter_high,
7852 (void *)&cmd_syn_filter_queue,
7853 (void *)&cmd_syn_filter_queue_id,
7858 /* *** ADD/REMOVE A 2tuple FILTER *** */
7859 struct cmd_2tuple_filter_result {
7860 cmdline_fixed_string_t filter;
7862 cmdline_fixed_string_t ops;
7863 cmdline_fixed_string_t dst_port;
7864 uint16_t dst_port_value;
7865 cmdline_fixed_string_t protocol;
7866 uint8_t protocol_value;
7867 cmdline_fixed_string_t mask;
7869 cmdline_fixed_string_t tcp_flags;
7870 uint8_t tcp_flags_value;
7871 cmdline_fixed_string_t priority;
7872 uint8_t priority_value;
7873 cmdline_fixed_string_t queue;
7878 cmd_2tuple_filter_parsed(void *parsed_result,
7879 __attribute__((unused)) struct cmdline *cl,
7880 __attribute__((unused)) void *data)
7882 struct rte_eth_ntuple_filter filter;
7883 struct cmd_2tuple_filter_result *res = parsed_result;
7886 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7888 printf("ntuple filter is not supported on port %u.\n",
7893 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7895 filter.flags = RTE_2TUPLE_FLAGS;
7896 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7897 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7898 filter.proto = res->protocol_value;
7899 filter.priority = res->priority_value;
7900 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7901 printf("nonzero tcp_flags is only meaningful"
7902 " when protocol is TCP.\n");
7905 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7906 printf("invalid TCP flags.\n");
7910 if (res->tcp_flags_value != 0) {
7911 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7912 filter.tcp_flags = res->tcp_flags_value;
7915 /* need convert to big endian. */
7916 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7917 filter.queue = res->queue_id;
7919 if (!strcmp(res->ops, "add"))
7920 ret = rte_eth_dev_filter_ctrl(res->port_id,
7921 RTE_ETH_FILTER_NTUPLE,
7925 ret = rte_eth_dev_filter_ctrl(res->port_id,
7926 RTE_ETH_FILTER_NTUPLE,
7927 RTE_ETH_FILTER_DELETE,
7930 printf("2tuple filter programming error: (%s)\n",
7935 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7936 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7937 filter, "2tuple_filter");
7938 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7939 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7941 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7942 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7944 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7945 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7946 dst_port, "dst_port");
7947 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7948 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7949 dst_port_value, UINT16);
7950 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7951 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7952 protocol, "protocol");
7953 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7954 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7955 protocol_value, UINT8);
7956 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7957 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7959 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7960 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7962 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7963 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7964 tcp_flags, "tcp_flags");
7965 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7966 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7967 tcp_flags_value, UINT8);
7968 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7969 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7970 priority, "priority");
7971 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7972 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7973 priority_value, UINT8);
7974 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7975 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7977 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7978 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7981 cmdline_parse_inst_t cmd_2tuple_filter = {
7982 .f = cmd_2tuple_filter_parsed,
7984 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7985 "<value> mask <value> tcp_flags <value> priority <value> queue "
7986 "<queue_id>: Add a 2tuple filter",
7988 (void *)&cmd_2tuple_filter_filter,
7989 (void *)&cmd_2tuple_filter_port_id,
7990 (void *)&cmd_2tuple_filter_ops,
7991 (void *)&cmd_2tuple_filter_dst_port,
7992 (void *)&cmd_2tuple_filter_dst_port_value,
7993 (void *)&cmd_2tuple_filter_protocol,
7994 (void *)&cmd_2tuple_filter_protocol_value,
7995 (void *)&cmd_2tuple_filter_mask,
7996 (void *)&cmd_2tuple_filter_mask_value,
7997 (void *)&cmd_2tuple_filter_tcp_flags,
7998 (void *)&cmd_2tuple_filter_tcp_flags_value,
7999 (void *)&cmd_2tuple_filter_priority,
8000 (void *)&cmd_2tuple_filter_priority_value,
8001 (void *)&cmd_2tuple_filter_queue,
8002 (void *)&cmd_2tuple_filter_queue_id,
8007 /* *** ADD/REMOVE A 5tuple FILTER *** */
8008 struct cmd_5tuple_filter_result {
8009 cmdline_fixed_string_t filter;
8011 cmdline_fixed_string_t ops;
8012 cmdline_fixed_string_t dst_ip;
8013 cmdline_ipaddr_t dst_ip_value;
8014 cmdline_fixed_string_t src_ip;
8015 cmdline_ipaddr_t src_ip_value;
8016 cmdline_fixed_string_t dst_port;
8017 uint16_t dst_port_value;
8018 cmdline_fixed_string_t src_port;
8019 uint16_t src_port_value;
8020 cmdline_fixed_string_t protocol;
8021 uint8_t protocol_value;
8022 cmdline_fixed_string_t mask;
8024 cmdline_fixed_string_t tcp_flags;
8025 uint8_t tcp_flags_value;
8026 cmdline_fixed_string_t priority;
8027 uint8_t priority_value;
8028 cmdline_fixed_string_t queue;
8033 cmd_5tuple_filter_parsed(void *parsed_result,
8034 __attribute__((unused)) struct cmdline *cl,
8035 __attribute__((unused)) void *data)
8037 struct rte_eth_ntuple_filter filter;
8038 struct cmd_5tuple_filter_result *res = parsed_result;
8041 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8043 printf("ntuple filter is not supported on port %u.\n",
8048 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8050 filter.flags = RTE_5TUPLE_FLAGS;
8051 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8052 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8053 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8054 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8055 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8056 filter.proto = res->protocol_value;
8057 filter.priority = res->priority_value;
8058 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8059 printf("nonzero tcp_flags is only meaningful"
8060 " when protocol is TCP.\n");
8063 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8064 printf("invalid TCP flags.\n");
8068 if (res->tcp_flags_value != 0) {
8069 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8070 filter.tcp_flags = res->tcp_flags_value;
8073 if (res->dst_ip_value.family == AF_INET)
8074 /* no need to convert, already big endian. */
8075 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8077 if (filter.dst_ip_mask == 0) {
8078 printf("can not support ipv6 involved compare.\n");
8084 if (res->src_ip_value.family == AF_INET)
8085 /* no need to convert, already big endian. */
8086 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8088 if (filter.src_ip_mask == 0) {
8089 printf("can not support ipv6 involved compare.\n");
8094 /* need convert to big endian. */
8095 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8096 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8097 filter.queue = res->queue_id;
8099 if (!strcmp(res->ops, "add"))
8100 ret = rte_eth_dev_filter_ctrl(res->port_id,
8101 RTE_ETH_FILTER_NTUPLE,
8105 ret = rte_eth_dev_filter_ctrl(res->port_id,
8106 RTE_ETH_FILTER_NTUPLE,
8107 RTE_ETH_FILTER_DELETE,
8110 printf("5tuple filter programming error: (%s)\n",
8114 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8115 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8116 filter, "5tuple_filter");
8117 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8118 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8120 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8121 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8123 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8124 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8126 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8127 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8129 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8130 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8132 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8133 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8135 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8136 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8137 dst_port, "dst_port");
8138 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8139 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8140 dst_port_value, UINT16);
8141 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8142 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8143 src_port, "src_port");
8144 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8145 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8146 src_port_value, UINT16);
8147 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8148 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8149 protocol, "protocol");
8150 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8151 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8152 protocol_value, UINT8);
8153 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8154 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8156 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8157 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8159 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8160 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8161 tcp_flags, "tcp_flags");
8162 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8163 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8164 tcp_flags_value, UINT8);
8165 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8166 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8167 priority, "priority");
8168 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8169 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8170 priority_value, UINT8);
8171 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8172 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8174 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8175 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8178 cmdline_parse_inst_t cmd_5tuple_filter = {
8179 .f = cmd_5tuple_filter_parsed,
8181 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8182 "src_ip <value> dst_port <value> src_port <value> "
8183 "protocol <value> mask <value> tcp_flags <value> "
8184 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8186 (void *)&cmd_5tuple_filter_filter,
8187 (void *)&cmd_5tuple_filter_port_id,
8188 (void *)&cmd_5tuple_filter_ops,
8189 (void *)&cmd_5tuple_filter_dst_ip,
8190 (void *)&cmd_5tuple_filter_dst_ip_value,
8191 (void *)&cmd_5tuple_filter_src_ip,
8192 (void *)&cmd_5tuple_filter_src_ip_value,
8193 (void *)&cmd_5tuple_filter_dst_port,
8194 (void *)&cmd_5tuple_filter_dst_port_value,
8195 (void *)&cmd_5tuple_filter_src_port,
8196 (void *)&cmd_5tuple_filter_src_port_value,
8197 (void *)&cmd_5tuple_filter_protocol,
8198 (void *)&cmd_5tuple_filter_protocol_value,
8199 (void *)&cmd_5tuple_filter_mask,
8200 (void *)&cmd_5tuple_filter_mask_value,
8201 (void *)&cmd_5tuple_filter_tcp_flags,
8202 (void *)&cmd_5tuple_filter_tcp_flags_value,
8203 (void *)&cmd_5tuple_filter_priority,
8204 (void *)&cmd_5tuple_filter_priority_value,
8205 (void *)&cmd_5tuple_filter_queue,
8206 (void *)&cmd_5tuple_filter_queue_id,
8211 /* *** ADD/REMOVE A flex FILTER *** */
8212 struct cmd_flex_filter_result {
8213 cmdline_fixed_string_t filter;
8214 cmdline_fixed_string_t ops;
8216 cmdline_fixed_string_t len;
8218 cmdline_fixed_string_t bytes;
8219 cmdline_fixed_string_t bytes_value;
8220 cmdline_fixed_string_t mask;
8221 cmdline_fixed_string_t mask_value;
8222 cmdline_fixed_string_t priority;
8223 uint8_t priority_value;
8224 cmdline_fixed_string_t queue;
8228 static int xdigit2val(unsigned char c)
8233 else if (isupper(c))
8241 cmd_flex_filter_parsed(void *parsed_result,
8242 __attribute__((unused)) struct cmdline *cl,
8243 __attribute__((unused)) void *data)
8246 struct rte_eth_flex_filter filter;
8247 struct cmd_flex_filter_result *res = parsed_result;
8248 char *bytes_ptr, *mask_ptr;
8249 uint16_t len, i, j = 0;
8254 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8255 printf("the len exceed the max length 128\n");
8258 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8259 filter.len = res->len_value;
8260 filter.priority = res->priority_value;
8261 filter.queue = res->queue_id;
8262 bytes_ptr = res->bytes_value;
8263 mask_ptr = res->mask_value;
8265 /* translate bytes string to array. */
8266 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8267 (bytes_ptr[1] == 'X')))
8269 len = strnlen(bytes_ptr, res->len_value * 2);
8270 if (len == 0 || (len % 8 != 0)) {
8271 printf("please check len and bytes input\n");
8274 for (i = 0; i < len; i++) {
8276 if (isxdigit(c) == 0) {
8277 /* invalid characters. */
8278 printf("invalid input\n");
8281 val = xdigit2val(c);
8284 filter.bytes[j] = byte;
8285 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8292 /* translate mask string to uint8_t array. */
8293 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8294 (mask_ptr[1] == 'X')))
8296 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8298 printf("invalid input\n");
8303 for (i = 0; i < len; i++) {
8305 if (isxdigit(c) == 0) {
8306 /* invalid characters. */
8307 printf("invalid input\n");
8310 val = xdigit2val(c);
8313 filter.mask[j] = byte;
8314 printf("mask[%d]:%02x ", j, filter.mask[j]);
8322 if (!strcmp(res->ops, "add"))
8323 ret = rte_eth_dev_filter_ctrl(res->port_id,
8324 RTE_ETH_FILTER_FLEXIBLE,
8328 ret = rte_eth_dev_filter_ctrl(res->port_id,
8329 RTE_ETH_FILTER_FLEXIBLE,
8330 RTE_ETH_FILTER_DELETE,
8334 printf("flex filter setting error: (%s)\n", strerror(-ret));
8337 cmdline_parse_token_string_t cmd_flex_filter_filter =
8338 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8339 filter, "flex_filter");
8340 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8341 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8343 cmdline_parse_token_string_t cmd_flex_filter_ops =
8344 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8346 cmdline_parse_token_string_t cmd_flex_filter_len =
8347 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8349 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8350 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8352 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8353 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8355 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8356 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8358 cmdline_parse_token_string_t cmd_flex_filter_mask =
8359 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8361 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8362 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8364 cmdline_parse_token_string_t cmd_flex_filter_priority =
8365 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8366 priority, "priority");
8367 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8368 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8369 priority_value, UINT8);
8370 cmdline_parse_token_string_t cmd_flex_filter_queue =
8371 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8373 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8374 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8376 cmdline_parse_inst_t cmd_flex_filter = {
8377 .f = cmd_flex_filter_parsed,
8379 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8380 "<value> mask <value> priority <value> queue <queue_id>: "
8381 "Add/Del a flex filter",
8383 (void *)&cmd_flex_filter_filter,
8384 (void *)&cmd_flex_filter_port_id,
8385 (void *)&cmd_flex_filter_ops,
8386 (void *)&cmd_flex_filter_len,
8387 (void *)&cmd_flex_filter_len_value,
8388 (void *)&cmd_flex_filter_bytes,
8389 (void *)&cmd_flex_filter_bytes_value,
8390 (void *)&cmd_flex_filter_mask,
8391 (void *)&cmd_flex_filter_mask_value,
8392 (void *)&cmd_flex_filter_priority,
8393 (void *)&cmd_flex_filter_priority_value,
8394 (void *)&cmd_flex_filter_queue,
8395 (void *)&cmd_flex_filter_queue_id,
8400 /* *** Filters Control *** */
8402 /* *** deal with ethertype filter *** */
8403 struct cmd_ethertype_filter_result {
8404 cmdline_fixed_string_t filter;
8406 cmdline_fixed_string_t ops;
8407 cmdline_fixed_string_t mac;
8408 struct ether_addr mac_addr;
8409 cmdline_fixed_string_t ethertype;
8410 uint16_t ethertype_value;
8411 cmdline_fixed_string_t drop;
8412 cmdline_fixed_string_t queue;
8416 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8417 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8418 filter, "ethertype_filter");
8419 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8420 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8422 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8423 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8425 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8426 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8427 mac, "mac_addr#mac_ignr");
8428 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8429 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8431 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8432 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8433 ethertype, "ethertype");
8434 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8435 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8436 ethertype_value, UINT16);
8437 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8438 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8440 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8441 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8443 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8444 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8448 cmd_ethertype_filter_parsed(void *parsed_result,
8449 __attribute__((unused)) struct cmdline *cl,
8450 __attribute__((unused)) void *data)
8452 struct cmd_ethertype_filter_result *res = parsed_result;
8453 struct rte_eth_ethertype_filter filter;
8456 ret = rte_eth_dev_filter_supported(res->port_id,
8457 RTE_ETH_FILTER_ETHERTYPE);
8459 printf("ethertype filter is not supported on port %u.\n",
8464 memset(&filter, 0, sizeof(filter));
8465 if (!strcmp(res->mac, "mac_addr")) {
8466 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8467 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8468 sizeof(struct ether_addr));
8470 if (!strcmp(res->drop, "drop"))
8471 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8472 filter.ether_type = res->ethertype_value;
8473 filter.queue = res->queue_id;
8475 if (!strcmp(res->ops, "add"))
8476 ret = rte_eth_dev_filter_ctrl(res->port_id,
8477 RTE_ETH_FILTER_ETHERTYPE,
8481 ret = rte_eth_dev_filter_ctrl(res->port_id,
8482 RTE_ETH_FILTER_ETHERTYPE,
8483 RTE_ETH_FILTER_DELETE,
8486 printf("ethertype filter programming error: (%s)\n",
8490 cmdline_parse_inst_t cmd_ethertype_filter = {
8491 .f = cmd_ethertype_filter_parsed,
8493 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8494 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8495 "Add or delete an ethertype filter entry",
8497 (void *)&cmd_ethertype_filter_filter,
8498 (void *)&cmd_ethertype_filter_port_id,
8499 (void *)&cmd_ethertype_filter_ops,
8500 (void *)&cmd_ethertype_filter_mac,
8501 (void *)&cmd_ethertype_filter_mac_addr,
8502 (void *)&cmd_ethertype_filter_ethertype,
8503 (void *)&cmd_ethertype_filter_ethertype_value,
8504 (void *)&cmd_ethertype_filter_drop,
8505 (void *)&cmd_ethertype_filter_queue,
8506 (void *)&cmd_ethertype_filter_queue_id,
8511 /* *** deal with flow director filter *** */
8512 struct cmd_flow_director_result {
8513 cmdline_fixed_string_t flow_director_filter;
8515 cmdline_fixed_string_t mode;
8516 cmdline_fixed_string_t mode_value;
8517 cmdline_fixed_string_t ops;
8518 cmdline_fixed_string_t flow;
8519 cmdline_fixed_string_t flow_type;
8520 cmdline_fixed_string_t ether;
8521 uint16_t ether_type;
8522 cmdline_fixed_string_t src;
8523 cmdline_ipaddr_t ip_src;
8525 cmdline_fixed_string_t dst;
8526 cmdline_ipaddr_t ip_dst;
8528 cmdline_fixed_string_t verify_tag;
8529 uint32_t verify_tag_value;
8530 cmdline_ipaddr_t tos;
8532 cmdline_ipaddr_t proto;
8533 uint8_t proto_value;
8534 cmdline_ipaddr_t ttl;
8536 cmdline_fixed_string_t vlan;
8537 uint16_t vlan_value;
8538 cmdline_fixed_string_t flexbytes;
8539 cmdline_fixed_string_t flexbytes_value;
8540 cmdline_fixed_string_t pf_vf;
8541 cmdline_fixed_string_t drop;
8542 cmdline_fixed_string_t queue;
8544 cmdline_fixed_string_t fd_id;
8545 uint32_t fd_id_value;
8546 cmdline_fixed_string_t mac;
8547 struct ether_addr mac_addr;
8548 cmdline_fixed_string_t tunnel;
8549 cmdline_fixed_string_t tunnel_type;
8550 cmdline_fixed_string_t tunnel_id;
8551 uint32_t tunnel_id_value;
8555 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8558 const char *p, *p0 = q_arg;
8560 unsigned long int_fld;
8561 char *str_fld[max_num];
8566 p = strchr(p0, '(');
8570 p0 = strchr(p, ')');
8575 if (size >= sizeof(s))
8578 snprintf(s, sizeof(s), "%.*s", size, p);
8579 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8580 if (ret < 0 || ret > max_num)
8582 for (i = 0; i < ret; i++) {
8584 int_fld = strtoul(str_fld[i], &end, 0);
8585 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8587 flexbytes[i] = (uint8_t)int_fld;
8593 str2flowtype(char *string)
8596 static const struct {
8599 } flowtype_str[] = {
8600 {"raw", RTE_ETH_FLOW_RAW},
8601 {"ipv4", RTE_ETH_FLOW_IPV4},
8602 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8603 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8604 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8605 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8606 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8607 {"ipv6", RTE_ETH_FLOW_IPV6},
8608 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8609 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8610 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8611 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8612 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8613 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8616 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8617 if (!strcmp(flowtype_str[i].str, string))
8618 return flowtype_str[i].type;
8620 return RTE_ETH_FLOW_UNKNOWN;
8623 static enum rte_eth_fdir_tunnel_type
8624 str2fdir_tunneltype(char *string)
8628 static const struct {
8630 enum rte_eth_fdir_tunnel_type type;
8631 } tunneltype_str[] = {
8632 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8633 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8636 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8637 if (!strcmp(tunneltype_str[i].str, string))
8638 return tunneltype_str[i].type;
8640 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8643 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8645 if ((ip_addr).family == AF_INET) \
8646 (ip) = (ip_addr).addr.ipv4.s_addr; \
8648 printf("invalid parameter.\n"); \
8653 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8655 if ((ip_addr).family == AF_INET6) \
8656 (void)rte_memcpy(&(ip), \
8657 &((ip_addr).addr.ipv6), \
8658 sizeof(struct in6_addr)); \
8660 printf("invalid parameter.\n"); \
8666 cmd_flow_director_filter_parsed(void *parsed_result,
8667 __attribute__((unused)) struct cmdline *cl,
8668 __attribute__((unused)) void *data)
8670 struct cmd_flow_director_result *res = parsed_result;
8671 struct rte_eth_fdir_filter entry;
8672 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8674 unsigned long vf_id;
8677 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8679 printf("flow director is not supported on port %u.\n",
8683 memset(flexbytes, 0, sizeof(flexbytes));
8684 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8686 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8687 if (strcmp(res->mode_value, "MAC-VLAN")) {
8688 printf("Please set mode to MAC-VLAN.\n");
8691 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8692 if (strcmp(res->mode_value, "Tunnel")) {
8693 printf("Please set mode to Tunnel.\n");
8697 if (strcmp(res->mode_value, "IP")) {
8698 printf("Please set mode to IP.\n");
8701 entry.input.flow_type = str2flowtype(res->flow_type);
8704 ret = parse_flexbytes(res->flexbytes_value,
8706 RTE_ETH_FDIR_MAX_FLEXLEN);
8708 printf("error: Cannot parse flexbytes input.\n");
8712 switch (entry.input.flow_type) {
8713 case RTE_ETH_FLOW_FRAG_IPV4:
8714 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8715 entry.input.flow.ip4_flow.proto = res->proto_value;
8716 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8717 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8718 IPV4_ADDR_TO_UINT(res->ip_dst,
8719 entry.input.flow.ip4_flow.dst_ip);
8720 IPV4_ADDR_TO_UINT(res->ip_src,
8721 entry.input.flow.ip4_flow.src_ip);
8722 entry.input.flow.ip4_flow.tos = res->tos_value;
8723 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8724 /* need convert to big endian. */
8725 entry.input.flow.udp4_flow.dst_port =
8726 rte_cpu_to_be_16(res->port_dst);
8727 entry.input.flow.udp4_flow.src_port =
8728 rte_cpu_to_be_16(res->port_src);
8730 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8731 IPV4_ADDR_TO_UINT(res->ip_dst,
8732 entry.input.flow.sctp4_flow.ip.dst_ip);
8733 IPV4_ADDR_TO_UINT(res->ip_src,
8734 entry.input.flow.sctp4_flow.ip.src_ip);
8735 entry.input.flow.ip4_flow.tos = res->tos_value;
8736 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8737 /* need convert to big endian. */
8738 entry.input.flow.sctp4_flow.dst_port =
8739 rte_cpu_to_be_16(res->port_dst);
8740 entry.input.flow.sctp4_flow.src_port =
8741 rte_cpu_to_be_16(res->port_src);
8742 entry.input.flow.sctp4_flow.verify_tag =
8743 rte_cpu_to_be_32(res->verify_tag_value);
8745 case RTE_ETH_FLOW_FRAG_IPV6:
8746 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8747 entry.input.flow.ipv6_flow.proto = res->proto_value;
8748 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8749 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8750 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8751 entry.input.flow.ipv6_flow.dst_ip);
8752 IPV6_ADDR_TO_ARRAY(res->ip_src,
8753 entry.input.flow.ipv6_flow.src_ip);
8754 entry.input.flow.ipv6_flow.tc = res->tos_value;
8755 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8756 /* need convert to big endian. */
8757 entry.input.flow.udp6_flow.dst_port =
8758 rte_cpu_to_be_16(res->port_dst);
8759 entry.input.flow.udp6_flow.src_port =
8760 rte_cpu_to_be_16(res->port_src);
8762 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8763 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8764 entry.input.flow.sctp6_flow.ip.dst_ip);
8765 IPV6_ADDR_TO_ARRAY(res->ip_src,
8766 entry.input.flow.sctp6_flow.ip.src_ip);
8767 entry.input.flow.ipv6_flow.tc = res->tos_value;
8768 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8769 /* need convert to big endian. */
8770 entry.input.flow.sctp6_flow.dst_port =
8771 rte_cpu_to_be_16(res->port_dst);
8772 entry.input.flow.sctp6_flow.src_port =
8773 rte_cpu_to_be_16(res->port_src);
8774 entry.input.flow.sctp6_flow.verify_tag =
8775 rte_cpu_to_be_32(res->verify_tag_value);
8777 case RTE_ETH_FLOW_L2_PAYLOAD:
8778 entry.input.flow.l2_flow.ether_type =
8779 rte_cpu_to_be_16(res->ether_type);
8785 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8786 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8788 sizeof(struct ether_addr));
8790 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8791 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8793 sizeof(struct ether_addr));
8794 entry.input.flow.tunnel_flow.tunnel_type =
8795 str2fdir_tunneltype(res->tunnel_type);
8796 entry.input.flow.tunnel_flow.tunnel_id =
8797 rte_cpu_to_be_32(res->tunnel_id_value);
8800 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8802 RTE_ETH_FDIR_MAX_FLEXLEN);
8804 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8806 entry.action.flex_off = 0; /*use 0 by default */
8807 if (!strcmp(res->drop, "drop"))
8808 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8810 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8812 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8813 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8814 if (!strcmp(res->pf_vf, "pf"))
8815 entry.input.flow_ext.is_vf = 0;
8816 else if (!strncmp(res->pf_vf, "vf", 2)) {
8817 struct rte_eth_dev_info dev_info;
8819 memset(&dev_info, 0, sizeof(dev_info));
8820 rte_eth_dev_info_get(res->port_id, &dev_info);
8822 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8823 if (errno != 0 || *end != '\0' ||
8824 vf_id >= dev_info.max_vfs) {
8825 printf("invalid parameter %s.\n", res->pf_vf);
8828 entry.input.flow_ext.is_vf = 1;
8829 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8831 printf("invalid parameter %s.\n", res->pf_vf);
8836 /* set to report FD ID by default */
8837 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8838 entry.action.rx_queue = res->queue_id;
8839 entry.soft_id = res->fd_id_value;
8840 if (!strcmp(res->ops, "add"))
8841 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8842 RTE_ETH_FILTER_ADD, &entry);
8843 else if (!strcmp(res->ops, "del"))
8844 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8845 RTE_ETH_FILTER_DELETE, &entry);
8847 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8848 RTE_ETH_FILTER_UPDATE, &entry);
8850 printf("flow director programming error: (%s)\n",
8854 cmdline_parse_token_string_t cmd_flow_director_filter =
8855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8856 flow_director_filter, "flow_director_filter");
8857 cmdline_parse_token_num_t cmd_flow_director_port_id =
8858 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8860 cmdline_parse_token_string_t cmd_flow_director_ops =
8861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8862 ops, "add#del#update");
8863 cmdline_parse_token_string_t cmd_flow_director_flow =
8864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8866 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8868 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8869 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8870 cmdline_parse_token_string_t cmd_flow_director_ether =
8871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8873 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8874 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8875 ether_type, UINT16);
8876 cmdline_parse_token_string_t cmd_flow_director_src =
8877 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8879 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8880 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8882 cmdline_parse_token_num_t cmd_flow_director_port_src =
8883 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8885 cmdline_parse_token_string_t cmd_flow_director_dst =
8886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8888 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8889 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8891 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8892 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8894 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8896 verify_tag, "verify_tag");
8897 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8898 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8899 verify_tag_value, UINT32);
8900 cmdline_parse_token_string_t cmd_flow_director_tos =
8901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8903 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8904 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8906 cmdline_parse_token_string_t cmd_flow_director_proto =
8907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8909 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8910 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8911 proto_value, UINT8);
8912 cmdline_parse_token_string_t cmd_flow_director_ttl =
8913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8915 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8916 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8918 cmdline_parse_token_string_t cmd_flow_director_vlan =
8919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8921 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8922 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8923 vlan_value, UINT16);
8924 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8926 flexbytes, "flexbytes");
8927 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8929 flexbytes_value, NULL);
8930 cmdline_parse_token_string_t cmd_flow_director_drop =
8931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8933 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8936 cmdline_parse_token_string_t cmd_flow_director_queue =
8937 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8939 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8940 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8942 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8943 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8945 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8946 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8947 fd_id_value, UINT32);
8949 cmdline_parse_token_string_t cmd_flow_director_mode =
8950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8952 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8955 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8957 mode_value, "MAC-VLAN");
8958 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8960 mode_value, "Tunnel");
8961 cmdline_parse_token_string_t cmd_flow_director_mac =
8962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8964 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8965 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8967 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8970 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8972 tunnel_type, "NVGRE#VxLAN");
8973 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8974 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8975 tunnel_id, "tunnel-id");
8976 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8977 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8978 tunnel_id_value, UINT32);
8980 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8981 .f = cmd_flow_director_filter_parsed,
8983 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8984 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8985 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8986 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8987 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8988 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8989 "fd_id <fd_id_value>: "
8990 "Add or delete an ip flow director entry on NIC",
8992 (void *)&cmd_flow_director_filter,
8993 (void *)&cmd_flow_director_port_id,
8994 (void *)&cmd_flow_director_mode,
8995 (void *)&cmd_flow_director_mode_ip,
8996 (void *)&cmd_flow_director_ops,
8997 (void *)&cmd_flow_director_flow,
8998 (void *)&cmd_flow_director_flow_type,
8999 (void *)&cmd_flow_director_src,
9000 (void *)&cmd_flow_director_ip_src,
9001 (void *)&cmd_flow_director_dst,
9002 (void *)&cmd_flow_director_ip_dst,
9003 (void *)&cmd_flow_director_tos,
9004 (void *)&cmd_flow_director_tos_value,
9005 (void *)&cmd_flow_director_proto,
9006 (void *)&cmd_flow_director_proto_value,
9007 (void *)&cmd_flow_director_ttl,
9008 (void *)&cmd_flow_director_ttl_value,
9009 (void *)&cmd_flow_director_vlan,
9010 (void *)&cmd_flow_director_vlan_value,
9011 (void *)&cmd_flow_director_flexbytes,
9012 (void *)&cmd_flow_director_flexbytes_value,
9013 (void *)&cmd_flow_director_drop,
9014 (void *)&cmd_flow_director_pf_vf,
9015 (void *)&cmd_flow_director_queue,
9016 (void *)&cmd_flow_director_queue_id,
9017 (void *)&cmd_flow_director_fd_id,
9018 (void *)&cmd_flow_director_fd_id_value,
9023 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9024 .f = cmd_flow_director_filter_parsed,
9026 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9027 "director entry on NIC",
9029 (void *)&cmd_flow_director_filter,
9030 (void *)&cmd_flow_director_port_id,
9031 (void *)&cmd_flow_director_mode,
9032 (void *)&cmd_flow_director_mode_ip,
9033 (void *)&cmd_flow_director_ops,
9034 (void *)&cmd_flow_director_flow,
9035 (void *)&cmd_flow_director_flow_type,
9036 (void *)&cmd_flow_director_src,
9037 (void *)&cmd_flow_director_ip_src,
9038 (void *)&cmd_flow_director_port_src,
9039 (void *)&cmd_flow_director_dst,
9040 (void *)&cmd_flow_director_ip_dst,
9041 (void *)&cmd_flow_director_port_dst,
9042 (void *)&cmd_flow_director_tos,
9043 (void *)&cmd_flow_director_tos_value,
9044 (void *)&cmd_flow_director_ttl,
9045 (void *)&cmd_flow_director_ttl_value,
9046 (void *)&cmd_flow_director_vlan,
9047 (void *)&cmd_flow_director_vlan_value,
9048 (void *)&cmd_flow_director_flexbytes,
9049 (void *)&cmd_flow_director_flexbytes_value,
9050 (void *)&cmd_flow_director_drop,
9051 (void *)&cmd_flow_director_pf_vf,
9052 (void *)&cmd_flow_director_queue,
9053 (void *)&cmd_flow_director_queue_id,
9054 (void *)&cmd_flow_director_fd_id,
9055 (void *)&cmd_flow_director_fd_id_value,
9060 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9061 .f = cmd_flow_director_filter_parsed,
9063 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9064 "director entry on NIC",
9066 (void *)&cmd_flow_director_filter,
9067 (void *)&cmd_flow_director_port_id,
9068 (void *)&cmd_flow_director_mode,
9069 (void *)&cmd_flow_director_mode_ip,
9070 (void *)&cmd_flow_director_ops,
9071 (void *)&cmd_flow_director_flow,
9072 (void *)&cmd_flow_director_flow_type,
9073 (void *)&cmd_flow_director_src,
9074 (void *)&cmd_flow_director_ip_src,
9075 (void *)&cmd_flow_director_port_dst,
9076 (void *)&cmd_flow_director_dst,
9077 (void *)&cmd_flow_director_ip_dst,
9078 (void *)&cmd_flow_director_port_dst,
9079 (void *)&cmd_flow_director_verify_tag,
9080 (void *)&cmd_flow_director_verify_tag_value,
9081 (void *)&cmd_flow_director_tos,
9082 (void *)&cmd_flow_director_tos_value,
9083 (void *)&cmd_flow_director_ttl,
9084 (void *)&cmd_flow_director_ttl_value,
9085 (void *)&cmd_flow_director_vlan,
9086 (void *)&cmd_flow_director_vlan_value,
9087 (void *)&cmd_flow_director_flexbytes,
9088 (void *)&cmd_flow_director_flexbytes_value,
9089 (void *)&cmd_flow_director_drop,
9090 (void *)&cmd_flow_director_pf_vf,
9091 (void *)&cmd_flow_director_queue,
9092 (void *)&cmd_flow_director_queue_id,
9093 (void *)&cmd_flow_director_fd_id,
9094 (void *)&cmd_flow_director_fd_id_value,
9099 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9100 .f = cmd_flow_director_filter_parsed,
9102 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9103 "director entry on NIC",
9105 (void *)&cmd_flow_director_filter,
9106 (void *)&cmd_flow_director_port_id,
9107 (void *)&cmd_flow_director_mode,
9108 (void *)&cmd_flow_director_mode_ip,
9109 (void *)&cmd_flow_director_ops,
9110 (void *)&cmd_flow_director_flow,
9111 (void *)&cmd_flow_director_flow_type,
9112 (void *)&cmd_flow_director_ether,
9113 (void *)&cmd_flow_director_ether_type,
9114 (void *)&cmd_flow_director_flexbytes,
9115 (void *)&cmd_flow_director_flexbytes_value,
9116 (void *)&cmd_flow_director_drop,
9117 (void *)&cmd_flow_director_pf_vf,
9118 (void *)&cmd_flow_director_queue,
9119 (void *)&cmd_flow_director_queue_id,
9120 (void *)&cmd_flow_director_fd_id,
9121 (void *)&cmd_flow_director_fd_id_value,
9126 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9127 .f = cmd_flow_director_filter_parsed,
9129 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9130 "director entry on NIC",
9132 (void *)&cmd_flow_director_filter,
9133 (void *)&cmd_flow_director_port_id,
9134 (void *)&cmd_flow_director_mode,
9135 (void *)&cmd_flow_director_mode_mac_vlan,
9136 (void *)&cmd_flow_director_ops,
9137 (void *)&cmd_flow_director_mac,
9138 (void *)&cmd_flow_director_mac_addr,
9139 (void *)&cmd_flow_director_vlan,
9140 (void *)&cmd_flow_director_vlan_value,
9141 (void *)&cmd_flow_director_flexbytes,
9142 (void *)&cmd_flow_director_flexbytes_value,
9143 (void *)&cmd_flow_director_drop,
9144 (void *)&cmd_flow_director_queue,
9145 (void *)&cmd_flow_director_queue_id,
9146 (void *)&cmd_flow_director_fd_id,
9147 (void *)&cmd_flow_director_fd_id_value,
9152 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9153 .f = cmd_flow_director_filter_parsed,
9155 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9156 "director entry on NIC",
9158 (void *)&cmd_flow_director_filter,
9159 (void *)&cmd_flow_director_port_id,
9160 (void *)&cmd_flow_director_mode,
9161 (void *)&cmd_flow_director_mode_tunnel,
9162 (void *)&cmd_flow_director_ops,
9163 (void *)&cmd_flow_director_mac,
9164 (void *)&cmd_flow_director_mac_addr,
9165 (void *)&cmd_flow_director_vlan,
9166 (void *)&cmd_flow_director_vlan_value,
9167 (void *)&cmd_flow_director_tunnel,
9168 (void *)&cmd_flow_director_tunnel_type,
9169 (void *)&cmd_flow_director_tunnel_id,
9170 (void *)&cmd_flow_director_tunnel_id_value,
9171 (void *)&cmd_flow_director_flexbytes,
9172 (void *)&cmd_flow_director_flexbytes_value,
9173 (void *)&cmd_flow_director_drop,
9174 (void *)&cmd_flow_director_queue,
9175 (void *)&cmd_flow_director_queue_id,
9176 (void *)&cmd_flow_director_fd_id,
9177 (void *)&cmd_flow_director_fd_id_value,
9182 struct cmd_flush_flow_director_result {
9183 cmdline_fixed_string_t flush_flow_director;
9187 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9188 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9189 flush_flow_director, "flush_flow_director");
9190 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9191 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9195 cmd_flush_flow_director_parsed(void *parsed_result,
9196 __attribute__((unused)) struct cmdline *cl,
9197 __attribute__((unused)) void *data)
9199 struct cmd_flow_director_result *res = parsed_result;
9202 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9204 printf("flow director is not supported on port %u.\n",
9209 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9210 RTE_ETH_FILTER_FLUSH, NULL);
9212 printf("flow director table flushing error: (%s)\n",
9216 cmdline_parse_inst_t cmd_flush_flow_director = {
9217 .f = cmd_flush_flow_director_parsed,
9219 .help_str = "flush_flow_director <port_id>: "
9220 "Flush all flow director entries of a device on NIC",
9222 (void *)&cmd_flush_flow_director_flush,
9223 (void *)&cmd_flush_flow_director_port_id,
9228 /* *** deal with flow director mask *** */
9229 struct cmd_flow_director_mask_result {
9230 cmdline_fixed_string_t flow_director_mask;
9232 cmdline_fixed_string_t mode;
9233 cmdline_fixed_string_t mode_value;
9234 cmdline_fixed_string_t vlan;
9236 cmdline_fixed_string_t src_mask;
9237 cmdline_ipaddr_t ipv4_src;
9238 cmdline_ipaddr_t ipv6_src;
9240 cmdline_fixed_string_t dst_mask;
9241 cmdline_ipaddr_t ipv4_dst;
9242 cmdline_ipaddr_t ipv6_dst;
9244 cmdline_fixed_string_t mac;
9245 uint8_t mac_addr_byte_mask;
9246 cmdline_fixed_string_t tunnel_id;
9247 uint32_t tunnel_id_mask;
9248 cmdline_fixed_string_t tunnel_type;
9249 uint8_t tunnel_type_mask;
9253 cmd_flow_director_mask_parsed(void *parsed_result,
9254 __attribute__((unused)) struct cmdline *cl,
9255 __attribute__((unused)) void *data)
9257 struct cmd_flow_director_mask_result *res = parsed_result;
9258 struct rte_eth_fdir_masks *mask;
9259 struct rte_port *port;
9261 if (res->port_id > nb_ports) {
9262 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9266 port = &ports[res->port_id];
9267 /** Check if the port is not started **/
9268 if (port->port_status != RTE_PORT_STOPPED) {
9269 printf("Please stop port %d first\n", res->port_id);
9273 mask = &port->dev_conf.fdir_conf.mask;
9275 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9276 if (strcmp(res->mode_value, "MAC-VLAN")) {
9277 printf("Please set mode to MAC-VLAN.\n");
9281 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9282 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9283 if (strcmp(res->mode_value, "Tunnel")) {
9284 printf("Please set mode to Tunnel.\n");
9288 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9289 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9290 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9291 mask->tunnel_type_mask = res->tunnel_type_mask;
9293 if (strcmp(res->mode_value, "IP")) {
9294 printf("Please set mode to IP.\n");
9298 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9299 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9300 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9301 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9302 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9303 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9304 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9307 cmd_reconfig_device_queue(res->port_id, 1, 1);
9310 cmdline_parse_token_string_t cmd_flow_director_mask =
9311 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9312 flow_director_mask, "flow_director_mask");
9313 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9314 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9316 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9317 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9319 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9320 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9322 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9323 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9324 src_mask, "src_mask");
9325 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9326 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9328 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9329 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9331 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9332 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9334 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9335 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9336 dst_mask, "dst_mask");
9337 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9338 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9340 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9341 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9343 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9344 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9347 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9350 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9353 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9355 mode_value, "MAC-VLAN");
9356 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9358 mode_value, "Tunnel");
9359 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9360 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9362 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9363 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9364 mac_addr_byte_mask, UINT8);
9365 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9366 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9367 tunnel_type, "tunnel-type");
9368 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9369 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9370 tunnel_type_mask, UINT8);
9371 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9372 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9373 tunnel_id, "tunnel-id");
9374 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9375 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9376 tunnel_id_mask, UINT32);
9378 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9379 .f = cmd_flow_director_mask_parsed,
9381 .help_str = "flow_director_mask ... : "
9382 "Set IP mode flow director's mask on NIC",
9384 (void *)&cmd_flow_director_mask,
9385 (void *)&cmd_flow_director_mask_port_id,
9386 (void *)&cmd_flow_director_mask_mode,
9387 (void *)&cmd_flow_director_mask_mode_ip,
9388 (void *)&cmd_flow_director_mask_vlan,
9389 (void *)&cmd_flow_director_mask_vlan_value,
9390 (void *)&cmd_flow_director_mask_src,
9391 (void *)&cmd_flow_director_mask_ipv4_src,
9392 (void *)&cmd_flow_director_mask_ipv6_src,
9393 (void *)&cmd_flow_director_mask_port_src,
9394 (void *)&cmd_flow_director_mask_dst,
9395 (void *)&cmd_flow_director_mask_ipv4_dst,
9396 (void *)&cmd_flow_director_mask_ipv6_dst,
9397 (void *)&cmd_flow_director_mask_port_dst,
9402 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9403 .f = cmd_flow_director_mask_parsed,
9405 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9406 "flow director's mask on NIC",
9408 (void *)&cmd_flow_director_mask,
9409 (void *)&cmd_flow_director_mask_port_id,
9410 (void *)&cmd_flow_director_mask_mode,
9411 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9412 (void *)&cmd_flow_director_mask_vlan,
9413 (void *)&cmd_flow_director_mask_vlan_value,
9418 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9419 .f = cmd_flow_director_mask_parsed,
9421 .help_str = "flow_director_mask ... : Set tunnel mode "
9422 "flow director's mask on NIC",
9424 (void *)&cmd_flow_director_mask,
9425 (void *)&cmd_flow_director_mask_port_id,
9426 (void *)&cmd_flow_director_mask_mode,
9427 (void *)&cmd_flow_director_mask_mode_tunnel,
9428 (void *)&cmd_flow_director_mask_vlan,
9429 (void *)&cmd_flow_director_mask_vlan_value,
9430 (void *)&cmd_flow_director_mask_mac,
9431 (void *)&cmd_flow_director_mask_mac_value,
9432 (void *)&cmd_flow_director_mask_tunnel_type,
9433 (void *)&cmd_flow_director_mask_tunnel_type_value,
9434 (void *)&cmd_flow_director_mask_tunnel_id,
9435 (void *)&cmd_flow_director_mask_tunnel_id_value,
9440 /* *** deal with flow director mask on flexible payload *** */
9441 struct cmd_flow_director_flex_mask_result {
9442 cmdline_fixed_string_t flow_director_flexmask;
9444 cmdline_fixed_string_t flow;
9445 cmdline_fixed_string_t flow_type;
9446 cmdline_fixed_string_t mask;
9450 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9451 __attribute__((unused)) struct cmdline *cl,
9452 __attribute__((unused)) void *data)
9454 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9455 struct rte_eth_fdir_info fdir_info;
9456 struct rte_eth_fdir_flex_mask flex_mask;
9457 struct rte_port *port;
9458 uint32_t flow_type_mask;
9462 if (res->port_id > nb_ports) {
9463 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9467 port = &ports[res->port_id];
9468 /** Check if the port is not started **/
9469 if (port->port_status != RTE_PORT_STOPPED) {
9470 printf("Please stop port %d first\n", res->port_id);
9474 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9475 ret = parse_flexbytes(res->mask,
9477 RTE_ETH_FDIR_MAX_FLEXLEN);
9479 printf("error: Cannot parse mask input.\n");
9483 memset(&fdir_info, 0, sizeof(fdir_info));
9484 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9485 RTE_ETH_FILTER_INFO, &fdir_info);
9487 printf("Cannot get FDir filter info\n");
9491 if (!strcmp(res->flow_type, "none")) {
9492 /* means don't specify the flow type */
9493 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9494 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9495 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9496 0, sizeof(struct rte_eth_fdir_flex_mask));
9497 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9498 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9500 sizeof(struct rte_eth_fdir_flex_mask));
9501 cmd_reconfig_device_queue(res->port_id, 1, 1);
9504 flow_type_mask = fdir_info.flow_types_mask[0];
9505 if (!strcmp(res->flow_type, "all")) {
9506 if (!flow_type_mask) {
9507 printf("No flow type supported\n");
9510 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9511 if (flow_type_mask & (1 << i)) {
9512 flex_mask.flow_type = i;
9513 fdir_set_flex_mask(res->port_id, &flex_mask);
9516 cmd_reconfig_device_queue(res->port_id, 1, 1);
9519 flex_mask.flow_type = str2flowtype(res->flow_type);
9520 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9521 printf("Flow type %s not supported on port %d\n",
9522 res->flow_type, res->port_id);
9525 fdir_set_flex_mask(res->port_id, &flex_mask);
9526 cmd_reconfig_device_queue(res->port_id, 1, 1);
9529 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9530 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9531 flow_director_flexmask,
9532 "flow_director_flex_mask");
9533 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9534 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9536 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9537 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9539 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9540 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9541 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9542 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9543 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9544 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9547 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9548 .f = cmd_flow_director_flex_mask_parsed,
9550 .help_str = "flow_director_flex_mask ... : "
9551 "Set flow director's flex mask on NIC",
9553 (void *)&cmd_flow_director_flexmask,
9554 (void *)&cmd_flow_director_flexmask_port_id,
9555 (void *)&cmd_flow_director_flexmask_flow,
9556 (void *)&cmd_flow_director_flexmask_flow_type,
9557 (void *)&cmd_flow_director_flexmask_mask,
9562 /* *** deal with flow director flexible payload configuration *** */
9563 struct cmd_flow_director_flexpayload_result {
9564 cmdline_fixed_string_t flow_director_flexpayload;
9566 cmdline_fixed_string_t payload_layer;
9567 cmdline_fixed_string_t payload_cfg;
9571 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9574 const char *p, *p0 = q_arg;
9576 unsigned long int_fld;
9577 char *str_fld[max_num];
9582 p = strchr(p0, '(');
9586 p0 = strchr(p, ')');
9591 if (size >= sizeof(s))
9594 snprintf(s, sizeof(s), "%.*s", size, p);
9595 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9596 if (ret < 0 || ret > max_num)
9598 for (i = 0; i < ret; i++) {
9600 int_fld = strtoul(str_fld[i], &end, 0);
9601 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9603 offsets[i] = (uint16_t)int_fld;
9609 cmd_flow_director_flxpld_parsed(void *parsed_result,
9610 __attribute__((unused)) struct cmdline *cl,
9611 __attribute__((unused)) void *data)
9613 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9614 struct rte_eth_flex_payload_cfg flex_cfg;
9615 struct rte_port *port;
9618 if (res->port_id > nb_ports) {
9619 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9623 port = &ports[res->port_id];
9624 /** Check if the port is not started **/
9625 if (port->port_status != RTE_PORT_STOPPED) {
9626 printf("Please stop port %d first\n", res->port_id);
9630 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9632 if (!strcmp(res->payload_layer, "raw"))
9633 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9634 else if (!strcmp(res->payload_layer, "l2"))
9635 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9636 else if (!strcmp(res->payload_layer, "l3"))
9637 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9638 else if (!strcmp(res->payload_layer, "l4"))
9639 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9641 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9642 RTE_ETH_FDIR_MAX_FLEXLEN);
9644 printf("error: Cannot parse flex payload input.\n");
9648 fdir_set_flex_payload(res->port_id, &flex_cfg);
9649 cmd_reconfig_device_queue(res->port_id, 1, 1);
9652 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9654 flow_director_flexpayload,
9655 "flow_director_flex_payload");
9656 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9657 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9659 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9660 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9661 payload_layer, "raw#l2#l3#l4");
9662 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9663 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9666 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9667 .f = cmd_flow_director_flxpld_parsed,
9669 .help_str = "flow_director_flexpayload ... : "
9670 "Set flow director's flex payload on NIC",
9672 (void *)&cmd_flow_director_flexpayload,
9673 (void *)&cmd_flow_director_flexpayload_port_id,
9674 (void *)&cmd_flow_director_flexpayload_payload_layer,
9675 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9680 /* Generic flow interface command. */
9681 extern cmdline_parse_inst_t cmd_flow;
9683 /* *** Classification Filters Control *** */
9684 /* *** Get symmetric hash enable per port *** */
9685 struct cmd_get_sym_hash_ena_per_port_result {
9686 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9691 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9692 __rte_unused struct cmdline *cl,
9693 __rte_unused void *data)
9695 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9696 struct rte_eth_hash_filter_info info;
9699 if (rte_eth_dev_filter_supported(res->port_id,
9700 RTE_ETH_FILTER_HASH) < 0) {
9701 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9706 memset(&info, 0, sizeof(info));
9707 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9708 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9709 RTE_ETH_FILTER_GET, &info);
9712 printf("Cannot get symmetric hash enable per port "
9713 "on port %u\n", res->port_id);
9717 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9718 "enabled" : "disabled", res->port_id);
9721 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9722 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9723 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9724 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9725 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9728 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9729 .f = cmd_get_sym_hash_per_port_parsed,
9731 .help_str = "get_sym_hash_ena_per_port <port_id>",
9733 (void *)&cmd_get_sym_hash_ena_per_port_all,
9734 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9739 /* *** Set symmetric hash enable per port *** */
9740 struct cmd_set_sym_hash_ena_per_port_result {
9741 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9742 cmdline_fixed_string_t enable;
9747 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9748 __rte_unused struct cmdline *cl,
9749 __rte_unused void *data)
9751 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9752 struct rte_eth_hash_filter_info info;
9755 if (rte_eth_dev_filter_supported(res->port_id,
9756 RTE_ETH_FILTER_HASH) < 0) {
9757 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9762 memset(&info, 0, sizeof(info));
9763 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9764 if (!strcmp(res->enable, "enable"))
9765 info.info.enable = 1;
9766 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9767 RTE_ETH_FILTER_SET, &info);
9769 printf("Cannot set symmetric hash enable per port on "
9770 "port %u\n", res->port_id);
9773 printf("Symmetric hash has been set to %s on port %u\n",
9774 res->enable, res->port_id);
9777 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9778 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9779 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9780 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9781 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9783 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9784 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9785 enable, "enable#disable");
9787 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9788 .f = cmd_set_sym_hash_per_port_parsed,
9790 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9792 (void *)&cmd_set_sym_hash_ena_per_port_all,
9793 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9794 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9799 /* Get global config of hash function */
9800 struct cmd_get_hash_global_config_result {
9801 cmdline_fixed_string_t get_hash_global_config;
9806 flowtype_to_str(uint16_t ftype)
9813 {"ipv4", RTE_ETH_FLOW_IPV4},
9814 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9815 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9816 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9817 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9818 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9819 {"ipv6", RTE_ETH_FLOW_IPV6},
9820 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9821 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9822 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9823 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9824 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9825 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9826 {"port", RTE_ETH_FLOW_PORT},
9827 {"vxlan", RTE_ETH_FLOW_VXLAN},
9828 {"geneve", RTE_ETH_FLOW_GENEVE},
9829 {"nvgre", RTE_ETH_FLOW_NVGRE},
9832 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9833 if (ftype_table[i].ftype == ftype)
9834 return ftype_table[i].str;
9841 cmd_get_hash_global_config_parsed(void *parsed_result,
9842 __rte_unused struct cmdline *cl,
9843 __rte_unused void *data)
9845 struct cmd_get_hash_global_config_result *res = parsed_result;
9846 struct rte_eth_hash_filter_info info;
9847 uint32_t idx, offset;
9852 if (rte_eth_dev_filter_supported(res->port_id,
9853 RTE_ETH_FILTER_HASH) < 0) {
9854 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9859 memset(&info, 0, sizeof(info));
9860 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9861 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9862 RTE_ETH_FILTER_GET, &info);
9864 printf("Cannot get hash global configurations by port %d\n",
9869 switch (info.info.global_conf.hash_func) {
9870 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9871 printf("Hash function is Toeplitz\n");
9873 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9874 printf("Hash function is Simple XOR\n");
9877 printf("Unknown hash function\n");
9881 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9882 idx = i / UINT32_BIT;
9883 offset = i % UINT32_BIT;
9884 if (!(info.info.global_conf.valid_bit_mask[idx] &
9887 str = flowtype_to_str(i);
9890 printf("Symmetric hash is %s globally for flow type %s "
9892 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9893 (1UL << offset)) ? "enabled" : "disabled"), str,
9898 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9899 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9900 get_hash_global_config, "get_hash_global_config");
9901 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9902 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9905 cmdline_parse_inst_t cmd_get_hash_global_config = {
9906 .f = cmd_get_hash_global_config_parsed,
9908 .help_str = "get_hash_global_config <port_id>",
9910 (void *)&cmd_get_hash_global_config_all,
9911 (void *)&cmd_get_hash_global_config_port_id,
9916 /* Set global config of hash function */
9917 struct cmd_set_hash_global_config_result {
9918 cmdline_fixed_string_t set_hash_global_config;
9920 cmdline_fixed_string_t hash_func;
9921 cmdline_fixed_string_t flow_type;
9922 cmdline_fixed_string_t enable;
9926 cmd_set_hash_global_config_parsed(void *parsed_result,
9927 __rte_unused struct cmdline *cl,
9928 __rte_unused void *data)
9930 struct cmd_set_hash_global_config_result *res = parsed_result;
9931 struct rte_eth_hash_filter_info info;
9932 uint32_t ftype, idx, offset;
9935 if (rte_eth_dev_filter_supported(res->port_id,
9936 RTE_ETH_FILTER_HASH) < 0) {
9937 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9941 memset(&info, 0, sizeof(info));
9942 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9943 if (!strcmp(res->hash_func, "toeplitz"))
9944 info.info.global_conf.hash_func =
9945 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9946 else if (!strcmp(res->hash_func, "simple_xor"))
9947 info.info.global_conf.hash_func =
9948 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9949 else if (!strcmp(res->hash_func, "default"))
9950 info.info.global_conf.hash_func =
9951 RTE_ETH_HASH_FUNCTION_DEFAULT;
9953 ftype = str2flowtype(res->flow_type);
9954 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9955 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9956 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9957 if (!strcmp(res->enable, "enable"))
9958 info.info.global_conf.sym_hash_enable_mask[idx] |=
9960 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9961 RTE_ETH_FILTER_SET, &info);
9963 printf("Cannot set global hash configurations by port %d\n",
9966 printf("Global hash configurations have been set "
9967 "succcessfully by port %d\n", res->port_id);
9970 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9971 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9972 set_hash_global_config, "set_hash_global_config");
9973 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9974 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9976 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9977 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9978 hash_func, "toeplitz#simple_xor#default");
9979 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9980 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9982 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9983 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9984 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9985 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9986 enable, "enable#disable");
9988 cmdline_parse_inst_t cmd_set_hash_global_config = {
9989 .f = cmd_set_hash_global_config_parsed,
9991 .help_str = "set_hash_global_config <port_id> "
9992 "toeplitz|simple_xor|default "
9993 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9994 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9995 "l2_payload enable|disable",
9997 (void *)&cmd_set_hash_global_config_all,
9998 (void *)&cmd_set_hash_global_config_port_id,
9999 (void *)&cmd_set_hash_global_config_hash_func,
10000 (void *)&cmd_set_hash_global_config_flow_type,
10001 (void *)&cmd_set_hash_global_config_enable,
10006 /* Set hash input set */
10007 struct cmd_set_hash_input_set_result {
10008 cmdline_fixed_string_t set_hash_input_set;
10010 cmdline_fixed_string_t flow_type;
10011 cmdline_fixed_string_t inset_field;
10012 cmdline_fixed_string_t select;
10015 static enum rte_eth_input_set_field
10016 str2inset(char *string)
10020 static const struct {
10022 enum rte_eth_input_set_field inset;
10023 } inset_table[] = {
10024 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10025 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10026 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10027 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10028 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10029 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10030 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10031 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10032 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10033 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10034 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10035 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10036 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10037 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10038 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10039 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10040 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10041 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10042 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10043 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10044 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10045 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10046 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10047 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10048 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10049 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10050 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10051 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10052 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10053 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10054 {"none", RTE_ETH_INPUT_SET_NONE},
10057 for (i = 0; i < RTE_DIM(inset_table); i++) {
10058 if (!strcmp(string, inset_table[i].str))
10059 return inset_table[i].inset;
10062 return RTE_ETH_INPUT_SET_UNKNOWN;
10066 cmd_set_hash_input_set_parsed(void *parsed_result,
10067 __rte_unused struct cmdline *cl,
10068 __rte_unused void *data)
10070 struct cmd_set_hash_input_set_result *res = parsed_result;
10071 struct rte_eth_hash_filter_info info;
10073 memset(&info, 0, sizeof(info));
10074 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10075 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10076 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10077 info.info.input_set_conf.inset_size = 1;
10078 if (!strcmp(res->select, "select"))
10079 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10080 else if (!strcmp(res->select, "add"))
10081 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10082 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10083 RTE_ETH_FILTER_SET, &info);
10086 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10087 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10088 set_hash_input_set, "set_hash_input_set");
10089 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10090 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10092 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10093 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10095 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10096 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10097 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10098 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10100 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10101 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10102 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10103 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10104 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10106 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10107 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10108 select, "select#add");
10110 cmdline_parse_inst_t cmd_set_hash_input_set = {
10111 .f = cmd_set_hash_input_set_parsed,
10113 .help_str = "set_hash_input_set <port_id> "
10114 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10115 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10116 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10117 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10118 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10119 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10120 "fld-7th|fld-8th|none select|add",
10122 (void *)&cmd_set_hash_input_set_cmd,
10123 (void *)&cmd_set_hash_input_set_port_id,
10124 (void *)&cmd_set_hash_input_set_flow_type,
10125 (void *)&cmd_set_hash_input_set_field,
10126 (void *)&cmd_set_hash_input_set_select,
10131 /* Set flow director input set */
10132 struct cmd_set_fdir_input_set_result {
10133 cmdline_fixed_string_t set_fdir_input_set;
10135 cmdline_fixed_string_t flow_type;
10136 cmdline_fixed_string_t inset_field;
10137 cmdline_fixed_string_t select;
10141 cmd_set_fdir_input_set_parsed(void *parsed_result,
10142 __rte_unused struct cmdline *cl,
10143 __rte_unused void *data)
10145 struct cmd_set_fdir_input_set_result *res = parsed_result;
10146 struct rte_eth_fdir_filter_info info;
10148 memset(&info, 0, sizeof(info));
10149 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10150 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10151 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10152 info.info.input_set_conf.inset_size = 1;
10153 if (!strcmp(res->select, "select"))
10154 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10155 else if (!strcmp(res->select, "add"))
10156 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10157 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10158 RTE_ETH_FILTER_SET, &info);
10161 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10162 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10163 set_fdir_input_set, "set_fdir_input_set");
10164 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10165 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10167 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10168 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10170 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10171 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10172 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10173 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10175 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10176 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10177 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10178 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10179 "sctp-veri-tag#none");
10180 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10181 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10182 select, "select#add");
10184 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10185 .f = cmd_set_fdir_input_set_parsed,
10187 .help_str = "set_fdir_input_set <port_id> "
10188 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10189 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10190 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10191 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10192 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10193 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10194 "sctp-veri-tag|none select|add",
10196 (void *)&cmd_set_fdir_input_set_cmd,
10197 (void *)&cmd_set_fdir_input_set_port_id,
10198 (void *)&cmd_set_fdir_input_set_flow_type,
10199 (void *)&cmd_set_fdir_input_set_field,
10200 (void *)&cmd_set_fdir_input_set_select,
10205 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10206 struct cmd_mcast_addr_result {
10207 cmdline_fixed_string_t mcast_addr_cmd;
10208 cmdline_fixed_string_t what;
10210 struct ether_addr mc_addr;
10213 static void cmd_mcast_addr_parsed(void *parsed_result,
10214 __attribute__((unused)) struct cmdline *cl,
10215 __attribute__((unused)) void *data)
10217 struct cmd_mcast_addr_result *res = parsed_result;
10219 if (!is_multicast_ether_addr(&res->mc_addr)) {
10220 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10221 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10222 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10223 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10226 if (strcmp(res->what, "add") == 0)
10227 mcast_addr_add(res->port_num, &res->mc_addr);
10229 mcast_addr_remove(res->port_num, &res->mc_addr);
10232 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10233 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10234 mcast_addr_cmd, "mcast_addr");
10235 cmdline_parse_token_string_t cmd_mcast_addr_what =
10236 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10238 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10239 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10240 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10241 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10243 cmdline_parse_inst_t cmd_mcast_addr = {
10244 .f = cmd_mcast_addr_parsed,
10246 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10247 "Add/Remove multicast MAC address on port_id",
10249 (void *)&cmd_mcast_addr_cmd,
10250 (void *)&cmd_mcast_addr_what,
10251 (void *)&cmd_mcast_addr_portnum,
10252 (void *)&cmd_mcast_addr_addr,
10257 /* l2 tunnel config
10258 * only support E-tag now.
10261 /* Ether type config */
10262 struct cmd_config_l2_tunnel_eth_type_result {
10263 cmdline_fixed_string_t port;
10264 cmdline_fixed_string_t config;
10265 cmdline_fixed_string_t all;
10267 cmdline_fixed_string_t l2_tunnel;
10268 cmdline_fixed_string_t l2_tunnel_type;
10269 cmdline_fixed_string_t eth_type;
10270 uint16_t eth_type_val;
10273 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10274 TOKEN_STRING_INITIALIZER
10275 (struct cmd_config_l2_tunnel_eth_type_result,
10277 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10278 TOKEN_STRING_INITIALIZER
10279 (struct cmd_config_l2_tunnel_eth_type_result,
10281 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10282 TOKEN_STRING_INITIALIZER
10283 (struct cmd_config_l2_tunnel_eth_type_result,
10285 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10286 TOKEN_NUM_INITIALIZER
10287 (struct cmd_config_l2_tunnel_eth_type_result,
10289 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10290 TOKEN_STRING_INITIALIZER
10291 (struct cmd_config_l2_tunnel_eth_type_result,
10292 l2_tunnel, "l2-tunnel");
10293 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10294 TOKEN_STRING_INITIALIZER
10295 (struct cmd_config_l2_tunnel_eth_type_result,
10296 l2_tunnel_type, "E-tag");
10297 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10298 TOKEN_STRING_INITIALIZER
10299 (struct cmd_config_l2_tunnel_eth_type_result,
10300 eth_type, "ether-type");
10301 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10302 TOKEN_NUM_INITIALIZER
10303 (struct cmd_config_l2_tunnel_eth_type_result,
10304 eth_type_val, UINT16);
10306 static enum rte_eth_tunnel_type
10307 str2fdir_l2_tunnel_type(char *string)
10311 static const struct {
10313 enum rte_eth_tunnel_type type;
10314 } l2_tunnel_type_str[] = {
10315 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10318 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10319 if (!strcmp(l2_tunnel_type_str[i].str, string))
10320 return l2_tunnel_type_str[i].type;
10322 return RTE_TUNNEL_TYPE_NONE;
10325 /* ether type config for all ports */
10327 cmd_config_l2_tunnel_eth_type_all_parsed
10328 (void *parsed_result,
10329 __attribute__((unused)) struct cmdline *cl,
10330 __attribute__((unused)) void *data)
10332 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10333 struct rte_eth_l2_tunnel_conf entry;
10336 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10337 entry.ether_type = res->eth_type_val;
10339 FOREACH_PORT(pid, ports) {
10340 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10344 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10345 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10347 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10349 (void *)&cmd_config_l2_tunnel_eth_type_port,
10350 (void *)&cmd_config_l2_tunnel_eth_type_config,
10351 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10352 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10353 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10354 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10355 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10360 /* ether type config for a specific port */
10362 cmd_config_l2_tunnel_eth_type_specific_parsed(
10363 void *parsed_result,
10364 __attribute__((unused)) struct cmdline *cl,
10365 __attribute__((unused)) void *data)
10367 struct cmd_config_l2_tunnel_eth_type_result *res =
10369 struct rte_eth_l2_tunnel_conf entry;
10371 if (port_id_is_invalid(res->id, ENABLED_WARN))
10374 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10375 entry.ether_type = res->eth_type_val;
10377 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10380 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10381 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10383 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10385 (void *)&cmd_config_l2_tunnel_eth_type_port,
10386 (void *)&cmd_config_l2_tunnel_eth_type_config,
10387 (void *)&cmd_config_l2_tunnel_eth_type_id,
10388 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10389 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10390 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10391 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10396 /* Enable/disable l2 tunnel */
10397 struct cmd_config_l2_tunnel_en_dis_result {
10398 cmdline_fixed_string_t port;
10399 cmdline_fixed_string_t config;
10400 cmdline_fixed_string_t all;
10402 cmdline_fixed_string_t l2_tunnel;
10403 cmdline_fixed_string_t l2_tunnel_type;
10404 cmdline_fixed_string_t en_dis;
10407 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10408 TOKEN_STRING_INITIALIZER
10409 (struct cmd_config_l2_tunnel_en_dis_result,
10411 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10412 TOKEN_STRING_INITIALIZER
10413 (struct cmd_config_l2_tunnel_en_dis_result,
10415 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10416 TOKEN_STRING_INITIALIZER
10417 (struct cmd_config_l2_tunnel_en_dis_result,
10419 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10420 TOKEN_NUM_INITIALIZER
10421 (struct cmd_config_l2_tunnel_en_dis_result,
10423 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10424 TOKEN_STRING_INITIALIZER
10425 (struct cmd_config_l2_tunnel_en_dis_result,
10426 l2_tunnel, "l2-tunnel");
10427 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10428 TOKEN_STRING_INITIALIZER
10429 (struct cmd_config_l2_tunnel_en_dis_result,
10430 l2_tunnel_type, "E-tag");
10431 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10432 TOKEN_STRING_INITIALIZER
10433 (struct cmd_config_l2_tunnel_en_dis_result,
10434 en_dis, "enable#disable");
10436 /* enable/disable l2 tunnel for all ports */
10438 cmd_config_l2_tunnel_en_dis_all_parsed(
10439 void *parsed_result,
10440 __attribute__((unused)) struct cmdline *cl,
10441 __attribute__((unused)) void *data)
10443 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10444 struct rte_eth_l2_tunnel_conf entry;
10448 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10450 if (!strcmp("enable", res->en_dis))
10455 FOREACH_PORT(pid, ports) {
10456 rte_eth_dev_l2_tunnel_offload_set(pid,
10458 ETH_L2_TUNNEL_ENABLE_MASK,
10463 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10464 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10466 .help_str = "port config all l2-tunnel E-tag enable|disable",
10468 (void *)&cmd_config_l2_tunnel_en_dis_port,
10469 (void *)&cmd_config_l2_tunnel_en_dis_config,
10470 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10471 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10472 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10473 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10478 /* enable/disable l2 tunnel for a port */
10480 cmd_config_l2_tunnel_en_dis_specific_parsed(
10481 void *parsed_result,
10482 __attribute__((unused)) struct cmdline *cl,
10483 __attribute__((unused)) void *data)
10485 struct cmd_config_l2_tunnel_en_dis_result *res =
10487 struct rte_eth_l2_tunnel_conf entry;
10489 if (port_id_is_invalid(res->id, ENABLED_WARN))
10492 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10494 if (!strcmp("enable", res->en_dis))
10495 rte_eth_dev_l2_tunnel_offload_set(res->id,
10497 ETH_L2_TUNNEL_ENABLE_MASK,
10500 rte_eth_dev_l2_tunnel_offload_set(res->id,
10502 ETH_L2_TUNNEL_ENABLE_MASK,
10506 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10507 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10509 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10511 (void *)&cmd_config_l2_tunnel_en_dis_port,
10512 (void *)&cmd_config_l2_tunnel_en_dis_config,
10513 (void *)&cmd_config_l2_tunnel_en_dis_id,
10514 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10515 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10516 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10521 /* E-tag configuration */
10523 /* Common result structure for all E-tag configuration */
10524 struct cmd_config_e_tag_result {
10525 cmdline_fixed_string_t e_tag;
10526 cmdline_fixed_string_t set;
10527 cmdline_fixed_string_t insertion;
10528 cmdline_fixed_string_t stripping;
10529 cmdline_fixed_string_t forwarding;
10530 cmdline_fixed_string_t filter;
10531 cmdline_fixed_string_t add;
10532 cmdline_fixed_string_t del;
10533 cmdline_fixed_string_t on;
10534 cmdline_fixed_string_t off;
10535 cmdline_fixed_string_t on_off;
10536 cmdline_fixed_string_t port_tag_id;
10537 uint32_t port_tag_id_val;
10538 cmdline_fixed_string_t e_tag_id;
10539 uint16_t e_tag_id_val;
10540 cmdline_fixed_string_t dst_pool;
10541 uint8_t dst_pool_val;
10542 cmdline_fixed_string_t port;
10544 cmdline_fixed_string_t vf;
10548 /* Common CLI fields for all E-tag configuration */
10549 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10550 TOKEN_STRING_INITIALIZER
10551 (struct cmd_config_e_tag_result,
10553 cmdline_parse_token_string_t cmd_config_e_tag_set =
10554 TOKEN_STRING_INITIALIZER
10555 (struct cmd_config_e_tag_result,
10557 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10558 TOKEN_STRING_INITIALIZER
10559 (struct cmd_config_e_tag_result,
10560 insertion, "insertion");
10561 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10562 TOKEN_STRING_INITIALIZER
10563 (struct cmd_config_e_tag_result,
10564 stripping, "stripping");
10565 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10566 TOKEN_STRING_INITIALIZER
10567 (struct cmd_config_e_tag_result,
10568 forwarding, "forwarding");
10569 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10570 TOKEN_STRING_INITIALIZER
10571 (struct cmd_config_e_tag_result,
10573 cmdline_parse_token_string_t cmd_config_e_tag_add =
10574 TOKEN_STRING_INITIALIZER
10575 (struct cmd_config_e_tag_result,
10577 cmdline_parse_token_string_t cmd_config_e_tag_del =
10578 TOKEN_STRING_INITIALIZER
10579 (struct cmd_config_e_tag_result,
10581 cmdline_parse_token_string_t cmd_config_e_tag_on =
10582 TOKEN_STRING_INITIALIZER
10583 (struct cmd_config_e_tag_result,
10585 cmdline_parse_token_string_t cmd_config_e_tag_off =
10586 TOKEN_STRING_INITIALIZER
10587 (struct cmd_config_e_tag_result,
10589 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10590 TOKEN_STRING_INITIALIZER
10591 (struct cmd_config_e_tag_result,
10593 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10594 TOKEN_STRING_INITIALIZER
10595 (struct cmd_config_e_tag_result,
10596 port_tag_id, "port-tag-id");
10597 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10598 TOKEN_NUM_INITIALIZER
10599 (struct cmd_config_e_tag_result,
10600 port_tag_id_val, UINT32);
10601 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10602 TOKEN_STRING_INITIALIZER
10603 (struct cmd_config_e_tag_result,
10604 e_tag_id, "e-tag-id");
10605 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10606 TOKEN_NUM_INITIALIZER
10607 (struct cmd_config_e_tag_result,
10608 e_tag_id_val, UINT16);
10609 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10610 TOKEN_STRING_INITIALIZER
10611 (struct cmd_config_e_tag_result,
10612 dst_pool, "dst-pool");
10613 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10614 TOKEN_NUM_INITIALIZER
10615 (struct cmd_config_e_tag_result,
10616 dst_pool_val, UINT8);
10617 cmdline_parse_token_string_t cmd_config_e_tag_port =
10618 TOKEN_STRING_INITIALIZER
10619 (struct cmd_config_e_tag_result,
10621 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10622 TOKEN_NUM_INITIALIZER
10623 (struct cmd_config_e_tag_result,
10625 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10626 TOKEN_STRING_INITIALIZER
10627 (struct cmd_config_e_tag_result,
10629 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10630 TOKEN_NUM_INITIALIZER
10631 (struct cmd_config_e_tag_result,
10634 /* E-tag insertion configuration */
10636 cmd_config_e_tag_insertion_en_parsed(
10637 void *parsed_result,
10638 __attribute__((unused)) struct cmdline *cl,
10639 __attribute__((unused)) void *data)
10641 struct cmd_config_e_tag_result *res =
10643 struct rte_eth_l2_tunnel_conf entry;
10645 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10648 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10649 entry.tunnel_id = res->port_tag_id_val;
10650 entry.vf_id = res->vf_id;
10651 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10653 ETH_L2_TUNNEL_INSERTION_MASK,
10658 cmd_config_e_tag_insertion_dis_parsed(
10659 void *parsed_result,
10660 __attribute__((unused)) struct cmdline *cl,
10661 __attribute__((unused)) void *data)
10663 struct cmd_config_e_tag_result *res =
10665 struct rte_eth_l2_tunnel_conf entry;
10667 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10670 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10671 entry.vf_id = res->vf_id;
10673 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10675 ETH_L2_TUNNEL_INSERTION_MASK,
10679 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10680 .f = cmd_config_e_tag_insertion_en_parsed,
10682 .help_str = "E-tag ... : E-tag insertion enable",
10684 (void *)&cmd_config_e_tag_e_tag,
10685 (void *)&cmd_config_e_tag_set,
10686 (void *)&cmd_config_e_tag_insertion,
10687 (void *)&cmd_config_e_tag_on,
10688 (void *)&cmd_config_e_tag_port_tag_id,
10689 (void *)&cmd_config_e_tag_port_tag_id_val,
10690 (void *)&cmd_config_e_tag_port,
10691 (void *)&cmd_config_e_tag_port_id,
10692 (void *)&cmd_config_e_tag_vf,
10693 (void *)&cmd_config_e_tag_vf_id,
10698 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10699 .f = cmd_config_e_tag_insertion_dis_parsed,
10701 .help_str = "E-tag ... : E-tag insertion disable",
10703 (void *)&cmd_config_e_tag_e_tag,
10704 (void *)&cmd_config_e_tag_set,
10705 (void *)&cmd_config_e_tag_insertion,
10706 (void *)&cmd_config_e_tag_off,
10707 (void *)&cmd_config_e_tag_port,
10708 (void *)&cmd_config_e_tag_port_id,
10709 (void *)&cmd_config_e_tag_vf,
10710 (void *)&cmd_config_e_tag_vf_id,
10715 /* E-tag stripping configuration */
10717 cmd_config_e_tag_stripping_parsed(
10718 void *parsed_result,
10719 __attribute__((unused)) struct cmdline *cl,
10720 __attribute__((unused)) void *data)
10722 struct cmd_config_e_tag_result *res =
10724 struct rte_eth_l2_tunnel_conf entry;
10726 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10729 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10731 if (!strcmp(res->on_off, "on"))
10732 rte_eth_dev_l2_tunnel_offload_set
10735 ETH_L2_TUNNEL_STRIPPING_MASK,
10738 rte_eth_dev_l2_tunnel_offload_set
10741 ETH_L2_TUNNEL_STRIPPING_MASK,
10745 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10746 .f = cmd_config_e_tag_stripping_parsed,
10748 .help_str = "E-tag ... : E-tag stripping enable/disable",
10750 (void *)&cmd_config_e_tag_e_tag,
10751 (void *)&cmd_config_e_tag_set,
10752 (void *)&cmd_config_e_tag_stripping,
10753 (void *)&cmd_config_e_tag_on_off,
10754 (void *)&cmd_config_e_tag_port,
10755 (void *)&cmd_config_e_tag_port_id,
10760 /* E-tag forwarding configuration */
10762 cmd_config_e_tag_forwarding_parsed(
10763 void *parsed_result,
10764 __attribute__((unused)) struct cmdline *cl,
10765 __attribute__((unused)) void *data)
10767 struct cmd_config_e_tag_result *res = parsed_result;
10768 struct rte_eth_l2_tunnel_conf entry;
10770 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10773 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10775 if (!strcmp(res->on_off, "on"))
10776 rte_eth_dev_l2_tunnel_offload_set
10779 ETH_L2_TUNNEL_FORWARDING_MASK,
10782 rte_eth_dev_l2_tunnel_offload_set
10785 ETH_L2_TUNNEL_FORWARDING_MASK,
10789 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10790 .f = cmd_config_e_tag_forwarding_parsed,
10792 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10794 (void *)&cmd_config_e_tag_e_tag,
10795 (void *)&cmd_config_e_tag_set,
10796 (void *)&cmd_config_e_tag_forwarding,
10797 (void *)&cmd_config_e_tag_on_off,
10798 (void *)&cmd_config_e_tag_port,
10799 (void *)&cmd_config_e_tag_port_id,
10804 /* E-tag filter configuration */
10806 cmd_config_e_tag_filter_add_parsed(
10807 void *parsed_result,
10808 __attribute__((unused)) struct cmdline *cl,
10809 __attribute__((unused)) void *data)
10811 struct cmd_config_e_tag_result *res = parsed_result;
10812 struct rte_eth_l2_tunnel_conf entry;
10815 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10818 if (res->e_tag_id_val > 0x3fff) {
10819 printf("e-tag-id must be equal or less than 0x3fff.\n");
10823 ret = rte_eth_dev_filter_supported(res->port_id,
10824 RTE_ETH_FILTER_L2_TUNNEL);
10826 printf("E-tag filter is not supported on port %u.\n",
10831 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10832 entry.tunnel_id = res->e_tag_id_val;
10833 entry.pool = res->dst_pool_val;
10835 ret = rte_eth_dev_filter_ctrl(res->port_id,
10836 RTE_ETH_FILTER_L2_TUNNEL,
10837 RTE_ETH_FILTER_ADD,
10840 printf("E-tag filter programming error: (%s)\n",
10844 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10845 .f = cmd_config_e_tag_filter_add_parsed,
10847 .help_str = "E-tag ... : E-tag filter add",
10849 (void *)&cmd_config_e_tag_e_tag,
10850 (void *)&cmd_config_e_tag_set,
10851 (void *)&cmd_config_e_tag_filter,
10852 (void *)&cmd_config_e_tag_add,
10853 (void *)&cmd_config_e_tag_e_tag_id,
10854 (void *)&cmd_config_e_tag_e_tag_id_val,
10855 (void *)&cmd_config_e_tag_dst_pool,
10856 (void *)&cmd_config_e_tag_dst_pool_val,
10857 (void *)&cmd_config_e_tag_port,
10858 (void *)&cmd_config_e_tag_port_id,
10864 cmd_config_e_tag_filter_del_parsed(
10865 void *parsed_result,
10866 __attribute__((unused)) struct cmdline *cl,
10867 __attribute__((unused)) void *data)
10869 struct cmd_config_e_tag_result *res = parsed_result;
10870 struct rte_eth_l2_tunnel_conf entry;
10873 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10876 if (res->e_tag_id_val > 0x3fff) {
10877 printf("e-tag-id must be less than 0x3fff.\n");
10881 ret = rte_eth_dev_filter_supported(res->port_id,
10882 RTE_ETH_FILTER_L2_TUNNEL);
10884 printf("E-tag filter is not supported on port %u.\n",
10889 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10890 entry.tunnel_id = res->e_tag_id_val;
10892 ret = rte_eth_dev_filter_ctrl(res->port_id,
10893 RTE_ETH_FILTER_L2_TUNNEL,
10894 RTE_ETH_FILTER_DELETE,
10897 printf("E-tag filter programming error: (%s)\n",
10901 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10902 .f = cmd_config_e_tag_filter_del_parsed,
10904 .help_str = "E-tag ... : E-tag filter delete",
10906 (void *)&cmd_config_e_tag_e_tag,
10907 (void *)&cmd_config_e_tag_set,
10908 (void *)&cmd_config_e_tag_filter,
10909 (void *)&cmd_config_e_tag_del,
10910 (void *)&cmd_config_e_tag_e_tag_id,
10911 (void *)&cmd_config_e_tag_e_tag_id_val,
10912 (void *)&cmd_config_e_tag_port,
10913 (void *)&cmd_config_e_tag_port_id,
10918 /* vf vlan anti spoof configuration */
10920 /* Common result structure for vf vlan anti spoof */
10921 struct cmd_vf_vlan_anti_spoof_result {
10922 cmdline_fixed_string_t set;
10923 cmdline_fixed_string_t vf;
10924 cmdline_fixed_string_t vlan;
10925 cmdline_fixed_string_t antispoof;
10928 cmdline_fixed_string_t on_off;
10931 /* Common CLI fields for vf vlan anti spoof enable disable */
10932 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10933 TOKEN_STRING_INITIALIZER
10934 (struct cmd_vf_vlan_anti_spoof_result,
10936 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10937 TOKEN_STRING_INITIALIZER
10938 (struct cmd_vf_vlan_anti_spoof_result,
10940 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10941 TOKEN_STRING_INITIALIZER
10942 (struct cmd_vf_vlan_anti_spoof_result,
10944 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10945 TOKEN_STRING_INITIALIZER
10946 (struct cmd_vf_vlan_anti_spoof_result,
10947 antispoof, "antispoof");
10948 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10949 TOKEN_NUM_INITIALIZER
10950 (struct cmd_vf_vlan_anti_spoof_result,
10952 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10953 TOKEN_NUM_INITIALIZER
10954 (struct cmd_vf_vlan_anti_spoof_result,
10956 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10957 TOKEN_STRING_INITIALIZER
10958 (struct cmd_vf_vlan_anti_spoof_result,
10962 cmd_set_vf_vlan_anti_spoof_parsed(
10963 void *parsed_result,
10964 __attribute__((unused)) struct cmdline *cl,
10965 __attribute__((unused)) void *data)
10967 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10968 int ret = -ENOTSUP;
10970 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10972 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10975 #ifdef RTE_LIBRTE_IXGBE_PMD
10976 if (ret == -ENOTSUP)
10977 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10978 res->vf_id, is_on);
10980 #ifdef RTE_LIBRTE_I40E_PMD
10981 if (ret == -ENOTSUP)
10982 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10983 res->vf_id, is_on);
10990 printf("invalid vf_id %d\n", res->vf_id);
10993 printf("invalid port_id %d\n", res->port_id);
10996 printf("function not implemented\n");
10999 printf("programming error: (%s)\n", strerror(-ret));
11003 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11004 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11006 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11008 (void *)&cmd_vf_vlan_anti_spoof_set,
11009 (void *)&cmd_vf_vlan_anti_spoof_vf,
11010 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11011 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11012 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11013 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11014 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11019 /* vf mac anti spoof configuration */
11021 /* Common result structure for vf mac anti spoof */
11022 struct cmd_vf_mac_anti_spoof_result {
11023 cmdline_fixed_string_t set;
11024 cmdline_fixed_string_t vf;
11025 cmdline_fixed_string_t mac;
11026 cmdline_fixed_string_t antispoof;
11029 cmdline_fixed_string_t on_off;
11032 /* Common CLI fields for vf mac anti spoof enable disable */
11033 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11034 TOKEN_STRING_INITIALIZER
11035 (struct cmd_vf_mac_anti_spoof_result,
11037 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11038 TOKEN_STRING_INITIALIZER
11039 (struct cmd_vf_mac_anti_spoof_result,
11041 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11042 TOKEN_STRING_INITIALIZER
11043 (struct cmd_vf_mac_anti_spoof_result,
11045 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11046 TOKEN_STRING_INITIALIZER
11047 (struct cmd_vf_mac_anti_spoof_result,
11048 antispoof, "antispoof");
11049 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11050 TOKEN_NUM_INITIALIZER
11051 (struct cmd_vf_mac_anti_spoof_result,
11053 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11054 TOKEN_NUM_INITIALIZER
11055 (struct cmd_vf_mac_anti_spoof_result,
11057 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11058 TOKEN_STRING_INITIALIZER
11059 (struct cmd_vf_mac_anti_spoof_result,
11063 cmd_set_vf_mac_anti_spoof_parsed(
11064 void *parsed_result,
11065 __attribute__((unused)) struct cmdline *cl,
11066 __attribute__((unused)) void *data)
11068 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11069 int ret = -ENOTSUP;
11071 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11073 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11076 #ifdef RTE_LIBRTE_IXGBE_PMD
11077 if (ret == -ENOTSUP)
11078 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11079 res->vf_id, is_on);
11081 #ifdef RTE_LIBRTE_I40E_PMD
11082 if (ret == -ENOTSUP)
11083 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11084 res->vf_id, is_on);
11091 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11094 printf("invalid port_id %d\n", res->port_id);
11097 printf("function not implemented\n");
11100 printf("programming error: (%s)\n", strerror(-ret));
11104 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11105 .f = cmd_set_vf_mac_anti_spoof_parsed,
11107 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11109 (void *)&cmd_vf_mac_anti_spoof_set,
11110 (void *)&cmd_vf_mac_anti_spoof_vf,
11111 (void *)&cmd_vf_mac_anti_spoof_mac,
11112 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11113 (void *)&cmd_vf_mac_anti_spoof_port_id,
11114 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11115 (void *)&cmd_vf_mac_anti_spoof_on_off,
11120 /* vf vlan strip queue configuration */
11122 /* Common result structure for vf mac anti spoof */
11123 struct cmd_vf_vlan_stripq_result {
11124 cmdline_fixed_string_t set;
11125 cmdline_fixed_string_t vf;
11126 cmdline_fixed_string_t vlan;
11127 cmdline_fixed_string_t stripq;
11130 cmdline_fixed_string_t on_off;
11133 /* Common CLI fields for vf vlan strip enable disable */
11134 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11135 TOKEN_STRING_INITIALIZER
11136 (struct cmd_vf_vlan_stripq_result,
11138 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11139 TOKEN_STRING_INITIALIZER
11140 (struct cmd_vf_vlan_stripq_result,
11142 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11143 TOKEN_STRING_INITIALIZER
11144 (struct cmd_vf_vlan_stripq_result,
11146 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11147 TOKEN_STRING_INITIALIZER
11148 (struct cmd_vf_vlan_stripq_result,
11150 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11151 TOKEN_NUM_INITIALIZER
11152 (struct cmd_vf_vlan_stripq_result,
11154 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11155 TOKEN_NUM_INITIALIZER
11156 (struct cmd_vf_vlan_stripq_result,
11158 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11159 TOKEN_STRING_INITIALIZER
11160 (struct cmd_vf_vlan_stripq_result,
11164 cmd_set_vf_vlan_stripq_parsed(
11165 void *parsed_result,
11166 __attribute__((unused)) struct cmdline *cl,
11167 __attribute__((unused)) void *data)
11169 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11170 int ret = -ENOTSUP;
11172 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11174 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11177 #ifdef RTE_LIBRTE_IXGBE_PMD
11178 if (ret == -ENOTSUP)
11179 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11180 res->vf_id, is_on);
11182 #ifdef RTE_LIBRTE_I40E_PMD
11183 if (ret == -ENOTSUP)
11184 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11185 res->vf_id, is_on);
11192 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11195 printf("invalid port_id %d\n", res->port_id);
11198 printf("function not implemented\n");
11201 printf("programming error: (%s)\n", strerror(-ret));
11205 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11206 .f = cmd_set_vf_vlan_stripq_parsed,
11208 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11210 (void *)&cmd_vf_vlan_stripq_set,
11211 (void *)&cmd_vf_vlan_stripq_vf,
11212 (void *)&cmd_vf_vlan_stripq_vlan,
11213 (void *)&cmd_vf_vlan_stripq_stripq,
11214 (void *)&cmd_vf_vlan_stripq_port_id,
11215 (void *)&cmd_vf_vlan_stripq_vf_id,
11216 (void *)&cmd_vf_vlan_stripq_on_off,
11221 /* vf vlan insert configuration */
11223 /* Common result structure for vf vlan insert */
11224 struct cmd_vf_vlan_insert_result {
11225 cmdline_fixed_string_t set;
11226 cmdline_fixed_string_t vf;
11227 cmdline_fixed_string_t vlan;
11228 cmdline_fixed_string_t insert;
11234 /* Common CLI fields for vf vlan insert enable disable */
11235 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11236 TOKEN_STRING_INITIALIZER
11237 (struct cmd_vf_vlan_insert_result,
11239 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11240 TOKEN_STRING_INITIALIZER
11241 (struct cmd_vf_vlan_insert_result,
11243 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11244 TOKEN_STRING_INITIALIZER
11245 (struct cmd_vf_vlan_insert_result,
11247 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11248 TOKEN_STRING_INITIALIZER
11249 (struct cmd_vf_vlan_insert_result,
11251 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11252 TOKEN_NUM_INITIALIZER
11253 (struct cmd_vf_vlan_insert_result,
11255 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11256 TOKEN_NUM_INITIALIZER
11257 (struct cmd_vf_vlan_insert_result,
11259 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11260 TOKEN_NUM_INITIALIZER
11261 (struct cmd_vf_vlan_insert_result,
11265 cmd_set_vf_vlan_insert_parsed(
11266 void *parsed_result,
11267 __attribute__((unused)) struct cmdline *cl,
11268 __attribute__((unused)) void *data)
11270 struct cmd_vf_vlan_insert_result *res = parsed_result;
11271 int ret = -ENOTSUP;
11273 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11276 #ifdef RTE_LIBRTE_IXGBE_PMD
11277 if (ret == -ENOTSUP)
11278 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11281 #ifdef RTE_LIBRTE_I40E_PMD
11282 if (ret == -ENOTSUP)
11283 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11291 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11294 printf("invalid port_id %d\n", res->port_id);
11297 printf("function not implemented\n");
11300 printf("programming error: (%s)\n", strerror(-ret));
11304 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11305 .f = cmd_set_vf_vlan_insert_parsed,
11307 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11309 (void *)&cmd_vf_vlan_insert_set,
11310 (void *)&cmd_vf_vlan_insert_vf,
11311 (void *)&cmd_vf_vlan_insert_vlan,
11312 (void *)&cmd_vf_vlan_insert_insert,
11313 (void *)&cmd_vf_vlan_insert_port_id,
11314 (void *)&cmd_vf_vlan_insert_vf_id,
11315 (void *)&cmd_vf_vlan_insert_vlan_id,
11320 /* tx loopback configuration */
11322 /* Common result structure for tx loopback */
11323 struct cmd_tx_loopback_result {
11324 cmdline_fixed_string_t set;
11325 cmdline_fixed_string_t tx;
11326 cmdline_fixed_string_t loopback;
11328 cmdline_fixed_string_t on_off;
11331 /* Common CLI fields for tx loopback enable disable */
11332 cmdline_parse_token_string_t cmd_tx_loopback_set =
11333 TOKEN_STRING_INITIALIZER
11334 (struct cmd_tx_loopback_result,
11336 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11337 TOKEN_STRING_INITIALIZER
11338 (struct cmd_tx_loopback_result,
11340 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11341 TOKEN_STRING_INITIALIZER
11342 (struct cmd_tx_loopback_result,
11343 loopback, "loopback");
11344 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11345 TOKEN_NUM_INITIALIZER
11346 (struct cmd_tx_loopback_result,
11348 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11349 TOKEN_STRING_INITIALIZER
11350 (struct cmd_tx_loopback_result,
11354 cmd_set_tx_loopback_parsed(
11355 void *parsed_result,
11356 __attribute__((unused)) struct cmdline *cl,
11357 __attribute__((unused)) void *data)
11359 struct cmd_tx_loopback_result *res = parsed_result;
11360 int ret = -ENOTSUP;
11362 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11364 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11367 #ifdef RTE_LIBRTE_IXGBE_PMD
11368 if (ret == -ENOTSUP)
11369 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11371 #ifdef RTE_LIBRTE_I40E_PMD
11372 if (ret == -ENOTSUP)
11373 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11380 printf("invalid is_on %d\n", is_on);
11383 printf("invalid port_id %d\n", res->port_id);
11386 printf("function not implemented\n");
11389 printf("programming error: (%s)\n", strerror(-ret));
11393 cmdline_parse_inst_t cmd_set_tx_loopback = {
11394 .f = cmd_set_tx_loopback_parsed,
11396 .help_str = "set tx loopback <port_id> on|off",
11398 (void *)&cmd_tx_loopback_set,
11399 (void *)&cmd_tx_loopback_tx,
11400 (void *)&cmd_tx_loopback_loopback,
11401 (void *)&cmd_tx_loopback_port_id,
11402 (void *)&cmd_tx_loopback_on_off,
11407 #ifdef RTE_LIBRTE_IXGBE_PMD
11408 /* all queues drop enable configuration */
11410 /* Common result structure for all queues drop enable */
11411 struct cmd_all_queues_drop_en_result {
11412 cmdline_fixed_string_t set;
11413 cmdline_fixed_string_t all;
11414 cmdline_fixed_string_t queues;
11415 cmdline_fixed_string_t drop;
11417 cmdline_fixed_string_t on_off;
11420 /* Common CLI fields for tx loopback enable disable */
11421 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11422 TOKEN_STRING_INITIALIZER
11423 (struct cmd_all_queues_drop_en_result,
11425 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11426 TOKEN_STRING_INITIALIZER
11427 (struct cmd_all_queues_drop_en_result,
11429 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11430 TOKEN_STRING_INITIALIZER
11431 (struct cmd_all_queues_drop_en_result,
11433 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11434 TOKEN_STRING_INITIALIZER
11435 (struct cmd_all_queues_drop_en_result,
11437 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11438 TOKEN_NUM_INITIALIZER
11439 (struct cmd_all_queues_drop_en_result,
11441 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11442 TOKEN_STRING_INITIALIZER
11443 (struct cmd_all_queues_drop_en_result,
11447 cmd_set_all_queues_drop_en_parsed(
11448 void *parsed_result,
11449 __attribute__((unused)) struct cmdline *cl,
11450 __attribute__((unused)) void *data)
11452 struct cmd_all_queues_drop_en_result *res = parsed_result;
11454 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11456 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11459 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11464 printf("invalid is_on %d\n", is_on);
11467 printf("invalid port_id %d\n", res->port_id);
11470 printf("function not implemented\n");
11473 printf("programming error: (%s)\n", strerror(-ret));
11477 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11478 .f = cmd_set_all_queues_drop_en_parsed,
11480 .help_str = "set all queues drop <port_id> on|off",
11482 (void *)&cmd_all_queues_drop_en_set,
11483 (void *)&cmd_all_queues_drop_en_all,
11484 (void *)&cmd_all_queues_drop_en_queues,
11485 (void *)&cmd_all_queues_drop_en_drop,
11486 (void *)&cmd_all_queues_drop_en_port_id,
11487 (void *)&cmd_all_queues_drop_en_on_off,
11492 /* vf split drop enable configuration */
11494 /* Common result structure for vf split drop enable */
11495 struct cmd_vf_split_drop_en_result {
11496 cmdline_fixed_string_t set;
11497 cmdline_fixed_string_t vf;
11498 cmdline_fixed_string_t split;
11499 cmdline_fixed_string_t drop;
11502 cmdline_fixed_string_t on_off;
11505 /* Common CLI fields for vf split drop enable disable */
11506 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11507 TOKEN_STRING_INITIALIZER
11508 (struct cmd_vf_split_drop_en_result,
11510 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11511 TOKEN_STRING_INITIALIZER
11512 (struct cmd_vf_split_drop_en_result,
11514 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11515 TOKEN_STRING_INITIALIZER
11516 (struct cmd_vf_split_drop_en_result,
11518 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11519 TOKEN_STRING_INITIALIZER
11520 (struct cmd_vf_split_drop_en_result,
11522 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11523 TOKEN_NUM_INITIALIZER
11524 (struct cmd_vf_split_drop_en_result,
11526 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11527 TOKEN_NUM_INITIALIZER
11528 (struct cmd_vf_split_drop_en_result,
11530 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11531 TOKEN_STRING_INITIALIZER
11532 (struct cmd_vf_split_drop_en_result,
11536 cmd_set_vf_split_drop_en_parsed(
11537 void *parsed_result,
11538 __attribute__((unused)) struct cmdline *cl,
11539 __attribute__((unused)) void *data)
11541 struct cmd_vf_split_drop_en_result *res = parsed_result;
11543 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11545 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11548 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11554 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11557 printf("invalid port_id %d\n", res->port_id);
11560 printf("programming error: (%s)\n", strerror(-ret));
11564 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11565 .f = cmd_set_vf_split_drop_en_parsed,
11567 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11569 (void *)&cmd_vf_split_drop_en_set,
11570 (void *)&cmd_vf_split_drop_en_vf,
11571 (void *)&cmd_vf_split_drop_en_split,
11572 (void *)&cmd_vf_split_drop_en_drop,
11573 (void *)&cmd_vf_split_drop_en_port_id,
11574 (void *)&cmd_vf_split_drop_en_vf_id,
11575 (void *)&cmd_vf_split_drop_en_on_off,
11581 /* vf mac address configuration */
11583 /* Common result structure for vf mac address */
11584 struct cmd_set_vf_mac_addr_result {
11585 cmdline_fixed_string_t set;
11586 cmdline_fixed_string_t vf;
11587 cmdline_fixed_string_t mac;
11588 cmdline_fixed_string_t addr;
11591 struct ether_addr mac_addr;
11595 /* Common CLI fields for vf split drop enable disable */
11596 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11597 TOKEN_STRING_INITIALIZER
11598 (struct cmd_set_vf_mac_addr_result,
11600 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11601 TOKEN_STRING_INITIALIZER
11602 (struct cmd_set_vf_mac_addr_result,
11604 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11605 TOKEN_STRING_INITIALIZER
11606 (struct cmd_set_vf_mac_addr_result,
11608 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11609 TOKEN_STRING_INITIALIZER
11610 (struct cmd_set_vf_mac_addr_result,
11612 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11613 TOKEN_NUM_INITIALIZER
11614 (struct cmd_set_vf_mac_addr_result,
11616 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11617 TOKEN_NUM_INITIALIZER
11618 (struct cmd_set_vf_mac_addr_result,
11620 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11621 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11625 cmd_set_vf_mac_addr_parsed(
11626 void *parsed_result,
11627 __attribute__((unused)) struct cmdline *cl,
11628 __attribute__((unused)) void *data)
11630 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11631 int ret = -ENOTSUP;
11633 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11636 #ifdef RTE_LIBRTE_IXGBE_PMD
11637 if (ret == -ENOTSUP)
11638 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11641 #ifdef RTE_LIBRTE_I40E_PMD
11642 if (ret == -ENOTSUP)
11643 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11651 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11654 printf("invalid port_id %d\n", res->port_id);
11657 printf("function not implemented\n");
11660 printf("programming error: (%s)\n", strerror(-ret));
11664 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11665 .f = cmd_set_vf_mac_addr_parsed,
11667 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11669 (void *)&cmd_set_vf_mac_addr_set,
11670 (void *)&cmd_set_vf_mac_addr_vf,
11671 (void *)&cmd_set_vf_mac_addr_mac,
11672 (void *)&cmd_set_vf_mac_addr_addr,
11673 (void *)&cmd_set_vf_mac_addr_port_id,
11674 (void *)&cmd_set_vf_mac_addr_vf_id,
11675 (void *)&cmd_set_vf_mac_addr_mac_addr,
11680 #ifdef RTE_LIBRTE_IXGBE_PMD
11681 /* MACsec configuration */
11683 /* Common result structure for MACsec offload enable */
11684 struct cmd_macsec_offload_on_result {
11685 cmdline_fixed_string_t set;
11686 cmdline_fixed_string_t macsec;
11687 cmdline_fixed_string_t offload;
11689 cmdline_fixed_string_t on;
11690 cmdline_fixed_string_t encrypt;
11691 cmdline_fixed_string_t en_on_off;
11692 cmdline_fixed_string_t replay_protect;
11693 cmdline_fixed_string_t rp_on_off;
11696 /* Common CLI fields for MACsec offload disable */
11697 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11698 TOKEN_STRING_INITIALIZER
11699 (struct cmd_macsec_offload_on_result,
11701 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11702 TOKEN_STRING_INITIALIZER
11703 (struct cmd_macsec_offload_on_result,
11705 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11706 TOKEN_STRING_INITIALIZER
11707 (struct cmd_macsec_offload_on_result,
11708 offload, "offload");
11709 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11710 TOKEN_NUM_INITIALIZER
11711 (struct cmd_macsec_offload_on_result,
11713 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11714 TOKEN_STRING_INITIALIZER
11715 (struct cmd_macsec_offload_on_result,
11717 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11718 TOKEN_STRING_INITIALIZER
11719 (struct cmd_macsec_offload_on_result,
11720 encrypt, "encrypt");
11721 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11722 TOKEN_STRING_INITIALIZER
11723 (struct cmd_macsec_offload_on_result,
11724 en_on_off, "on#off");
11725 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11726 TOKEN_STRING_INITIALIZER
11727 (struct cmd_macsec_offload_on_result,
11728 replay_protect, "replay-protect");
11729 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11730 TOKEN_STRING_INITIALIZER
11731 (struct cmd_macsec_offload_on_result,
11732 rp_on_off, "on#off");
11735 cmd_set_macsec_offload_on_parsed(
11736 void *parsed_result,
11737 __attribute__((unused)) struct cmdline *cl,
11738 __attribute__((unused)) void *data)
11740 struct cmd_macsec_offload_on_result *res = parsed_result;
11742 portid_t port_id = res->port_id;
11743 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11744 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11746 if (port_id_is_invalid(port_id, ENABLED_WARN))
11749 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11750 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11756 printf("invalid port_id %d\n", port_id);
11759 printf("programming error: (%s)\n", strerror(-ret));
11763 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11764 .f = cmd_set_macsec_offload_on_parsed,
11766 .help_str = "set macsec offload <port_id> on "
11767 "encrypt on|off replay-protect on|off",
11769 (void *)&cmd_macsec_offload_on_set,
11770 (void *)&cmd_macsec_offload_on_macsec,
11771 (void *)&cmd_macsec_offload_on_offload,
11772 (void *)&cmd_macsec_offload_on_port_id,
11773 (void *)&cmd_macsec_offload_on_on,
11774 (void *)&cmd_macsec_offload_on_encrypt,
11775 (void *)&cmd_macsec_offload_on_en_on_off,
11776 (void *)&cmd_macsec_offload_on_replay_protect,
11777 (void *)&cmd_macsec_offload_on_rp_on_off,
11782 /* Common result structure for MACsec offload disable */
11783 struct cmd_macsec_offload_off_result {
11784 cmdline_fixed_string_t set;
11785 cmdline_fixed_string_t macsec;
11786 cmdline_fixed_string_t offload;
11788 cmdline_fixed_string_t off;
11791 /* Common CLI fields for MACsec offload disable */
11792 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11793 TOKEN_STRING_INITIALIZER
11794 (struct cmd_macsec_offload_off_result,
11796 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11797 TOKEN_STRING_INITIALIZER
11798 (struct cmd_macsec_offload_off_result,
11800 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11801 TOKEN_STRING_INITIALIZER
11802 (struct cmd_macsec_offload_off_result,
11803 offload, "offload");
11804 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11805 TOKEN_NUM_INITIALIZER
11806 (struct cmd_macsec_offload_off_result,
11808 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11809 TOKEN_STRING_INITIALIZER
11810 (struct cmd_macsec_offload_off_result,
11814 cmd_set_macsec_offload_off_parsed(
11815 void *parsed_result,
11816 __attribute__((unused)) struct cmdline *cl,
11817 __attribute__((unused)) void *data)
11819 struct cmd_macsec_offload_off_result *res = parsed_result;
11821 portid_t port_id = res->port_id;
11823 if (port_id_is_invalid(port_id, ENABLED_WARN))
11826 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11827 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11833 printf("invalid port_id %d\n", port_id);
11836 printf("programming error: (%s)\n", strerror(-ret));
11840 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11841 .f = cmd_set_macsec_offload_off_parsed,
11843 .help_str = "set macsec offload <port_id> off",
11845 (void *)&cmd_macsec_offload_off_set,
11846 (void *)&cmd_macsec_offload_off_macsec,
11847 (void *)&cmd_macsec_offload_off_offload,
11848 (void *)&cmd_macsec_offload_off_port_id,
11849 (void *)&cmd_macsec_offload_off_off,
11854 /* Common result structure for MACsec secure connection configure */
11855 struct cmd_macsec_sc_result {
11856 cmdline_fixed_string_t set;
11857 cmdline_fixed_string_t macsec;
11858 cmdline_fixed_string_t sc;
11859 cmdline_fixed_string_t tx_rx;
11861 struct ether_addr mac;
11865 /* Common CLI fields for MACsec secure connection configure */
11866 cmdline_parse_token_string_t cmd_macsec_sc_set =
11867 TOKEN_STRING_INITIALIZER
11868 (struct cmd_macsec_sc_result,
11870 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11871 TOKEN_STRING_INITIALIZER
11872 (struct cmd_macsec_sc_result,
11874 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11875 TOKEN_STRING_INITIALIZER
11876 (struct cmd_macsec_sc_result,
11878 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11879 TOKEN_STRING_INITIALIZER
11880 (struct cmd_macsec_sc_result,
11882 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11883 TOKEN_NUM_INITIALIZER
11884 (struct cmd_macsec_sc_result,
11886 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11887 TOKEN_ETHERADDR_INITIALIZER
11888 (struct cmd_macsec_sc_result,
11890 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11891 TOKEN_NUM_INITIALIZER
11892 (struct cmd_macsec_sc_result,
11896 cmd_set_macsec_sc_parsed(
11897 void *parsed_result,
11898 __attribute__((unused)) struct cmdline *cl,
11899 __attribute__((unused)) void *data)
11901 struct cmd_macsec_sc_result *res = parsed_result;
11903 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11906 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11907 res->mac.addr_bytes) :
11908 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11909 res->mac.addr_bytes, res->pi);
11914 printf("invalid port_id %d\n", res->port_id);
11917 printf("programming error: (%s)\n", strerror(-ret));
11921 cmdline_parse_inst_t cmd_set_macsec_sc = {
11922 .f = cmd_set_macsec_sc_parsed,
11924 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11926 (void *)&cmd_macsec_sc_set,
11927 (void *)&cmd_macsec_sc_macsec,
11928 (void *)&cmd_macsec_sc_sc,
11929 (void *)&cmd_macsec_sc_tx_rx,
11930 (void *)&cmd_macsec_sc_port_id,
11931 (void *)&cmd_macsec_sc_mac,
11932 (void *)&cmd_macsec_sc_pi,
11937 /* Common result structure for MACsec secure connection configure */
11938 struct cmd_macsec_sa_result {
11939 cmdline_fixed_string_t set;
11940 cmdline_fixed_string_t macsec;
11941 cmdline_fixed_string_t sa;
11942 cmdline_fixed_string_t tx_rx;
11947 cmdline_fixed_string_t key;
11950 /* Common CLI fields for MACsec secure connection configure */
11951 cmdline_parse_token_string_t cmd_macsec_sa_set =
11952 TOKEN_STRING_INITIALIZER
11953 (struct cmd_macsec_sa_result,
11955 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11956 TOKEN_STRING_INITIALIZER
11957 (struct cmd_macsec_sa_result,
11959 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11960 TOKEN_STRING_INITIALIZER
11961 (struct cmd_macsec_sa_result,
11963 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11964 TOKEN_STRING_INITIALIZER
11965 (struct cmd_macsec_sa_result,
11967 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11968 TOKEN_NUM_INITIALIZER
11969 (struct cmd_macsec_sa_result,
11971 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11972 TOKEN_NUM_INITIALIZER
11973 (struct cmd_macsec_sa_result,
11975 cmdline_parse_token_num_t cmd_macsec_sa_an =
11976 TOKEN_NUM_INITIALIZER
11977 (struct cmd_macsec_sa_result,
11979 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11980 TOKEN_NUM_INITIALIZER
11981 (struct cmd_macsec_sa_result,
11983 cmdline_parse_token_string_t cmd_macsec_sa_key =
11984 TOKEN_STRING_INITIALIZER
11985 (struct cmd_macsec_sa_result,
11989 cmd_set_macsec_sa_parsed(
11990 void *parsed_result,
11991 __attribute__((unused)) struct cmdline *cl,
11992 __attribute__((unused)) void *data)
11994 struct cmd_macsec_sa_result *res = parsed_result;
11996 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11997 uint8_t key[16] = { 0 };
12003 key_len = strlen(res->key) / 2;
12007 for (i = 0; i < key_len; i++) {
12008 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12011 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12014 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12018 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12019 res->idx, res->an, res->pn, key) :
12020 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12021 res->idx, res->an, res->pn, key);
12026 printf("invalid idx %d or an %d\n", res->idx, res->an);
12029 printf("invalid port_id %d\n", res->port_id);
12032 printf("programming error: (%s)\n", strerror(-ret));
12036 cmdline_parse_inst_t cmd_set_macsec_sa = {
12037 .f = cmd_set_macsec_sa_parsed,
12039 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12041 (void *)&cmd_macsec_sa_set,
12042 (void *)&cmd_macsec_sa_macsec,
12043 (void *)&cmd_macsec_sa_sa,
12044 (void *)&cmd_macsec_sa_tx_rx,
12045 (void *)&cmd_macsec_sa_port_id,
12046 (void *)&cmd_macsec_sa_idx,
12047 (void *)&cmd_macsec_sa_an,
12048 (void *)&cmd_macsec_sa_pn,
12049 (void *)&cmd_macsec_sa_key,
12055 /* VF unicast promiscuous mode configuration */
12057 /* Common result structure for VF unicast promiscuous mode */
12058 struct cmd_vf_promisc_result {
12059 cmdline_fixed_string_t set;
12060 cmdline_fixed_string_t vf;
12061 cmdline_fixed_string_t promisc;
12064 cmdline_fixed_string_t on_off;
12067 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12068 cmdline_parse_token_string_t cmd_vf_promisc_set =
12069 TOKEN_STRING_INITIALIZER
12070 (struct cmd_vf_promisc_result,
12072 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12073 TOKEN_STRING_INITIALIZER
12074 (struct cmd_vf_promisc_result,
12076 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12077 TOKEN_STRING_INITIALIZER
12078 (struct cmd_vf_promisc_result,
12079 promisc, "promisc");
12080 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12081 TOKEN_NUM_INITIALIZER
12082 (struct cmd_vf_promisc_result,
12084 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12085 TOKEN_NUM_INITIALIZER
12086 (struct cmd_vf_promisc_result,
12088 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12089 TOKEN_STRING_INITIALIZER
12090 (struct cmd_vf_promisc_result,
12094 cmd_set_vf_promisc_parsed(
12095 void *parsed_result,
12096 __attribute__((unused)) struct cmdline *cl,
12097 __attribute__((unused)) void *data)
12099 struct cmd_vf_promisc_result *res = parsed_result;
12100 int ret = -ENOTSUP;
12102 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12104 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12107 #ifdef RTE_LIBRTE_I40E_PMD
12108 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12109 res->vf_id, is_on);
12116 printf("invalid vf_id %d\n", res->vf_id);
12119 printf("invalid port_id %d\n", res->port_id);
12122 printf("function not implemented\n");
12125 printf("programming error: (%s)\n", strerror(-ret));
12129 cmdline_parse_inst_t cmd_set_vf_promisc = {
12130 .f = cmd_set_vf_promisc_parsed,
12132 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12133 "Set unicast promiscuous mode for a VF from the PF",
12135 (void *)&cmd_vf_promisc_set,
12136 (void *)&cmd_vf_promisc_vf,
12137 (void *)&cmd_vf_promisc_promisc,
12138 (void *)&cmd_vf_promisc_port_id,
12139 (void *)&cmd_vf_promisc_vf_id,
12140 (void *)&cmd_vf_promisc_on_off,
12145 /* VF multicast promiscuous mode configuration */
12147 /* Common result structure for VF multicast promiscuous mode */
12148 struct cmd_vf_allmulti_result {
12149 cmdline_fixed_string_t set;
12150 cmdline_fixed_string_t vf;
12151 cmdline_fixed_string_t allmulti;
12154 cmdline_fixed_string_t on_off;
12157 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12158 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12159 TOKEN_STRING_INITIALIZER
12160 (struct cmd_vf_allmulti_result,
12162 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12163 TOKEN_STRING_INITIALIZER
12164 (struct cmd_vf_allmulti_result,
12166 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12167 TOKEN_STRING_INITIALIZER
12168 (struct cmd_vf_allmulti_result,
12169 allmulti, "allmulti");
12170 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12171 TOKEN_NUM_INITIALIZER
12172 (struct cmd_vf_allmulti_result,
12174 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12175 TOKEN_NUM_INITIALIZER
12176 (struct cmd_vf_allmulti_result,
12178 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12179 TOKEN_STRING_INITIALIZER
12180 (struct cmd_vf_allmulti_result,
12184 cmd_set_vf_allmulti_parsed(
12185 void *parsed_result,
12186 __attribute__((unused)) struct cmdline *cl,
12187 __attribute__((unused)) void *data)
12189 struct cmd_vf_allmulti_result *res = parsed_result;
12190 int ret = -ENOTSUP;
12192 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12194 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12197 #ifdef RTE_LIBRTE_I40E_PMD
12198 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12199 res->vf_id, is_on);
12206 printf("invalid vf_id %d\n", res->vf_id);
12209 printf("invalid port_id %d\n", res->port_id);
12212 printf("function not implemented\n");
12215 printf("programming error: (%s)\n", strerror(-ret));
12219 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12220 .f = cmd_set_vf_allmulti_parsed,
12222 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12223 "Set multicast promiscuous mode for a VF from the PF",
12225 (void *)&cmd_vf_allmulti_set,
12226 (void *)&cmd_vf_allmulti_vf,
12227 (void *)&cmd_vf_allmulti_allmulti,
12228 (void *)&cmd_vf_allmulti_port_id,
12229 (void *)&cmd_vf_allmulti_vf_id,
12230 (void *)&cmd_vf_allmulti_on_off,
12235 /* vf broadcast mode configuration */
12237 /* Common result structure for vf broadcast */
12238 struct cmd_set_vf_broadcast_result {
12239 cmdline_fixed_string_t set;
12240 cmdline_fixed_string_t vf;
12241 cmdline_fixed_string_t broadcast;
12244 cmdline_fixed_string_t on_off;
12247 /* Common CLI fields for vf broadcast enable disable */
12248 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12249 TOKEN_STRING_INITIALIZER
12250 (struct cmd_set_vf_broadcast_result,
12252 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12253 TOKEN_STRING_INITIALIZER
12254 (struct cmd_set_vf_broadcast_result,
12256 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12257 TOKEN_STRING_INITIALIZER
12258 (struct cmd_set_vf_broadcast_result,
12259 broadcast, "broadcast");
12260 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12261 TOKEN_NUM_INITIALIZER
12262 (struct cmd_set_vf_broadcast_result,
12264 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12265 TOKEN_NUM_INITIALIZER
12266 (struct cmd_set_vf_broadcast_result,
12268 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12269 TOKEN_STRING_INITIALIZER
12270 (struct cmd_set_vf_broadcast_result,
12274 cmd_set_vf_broadcast_parsed(
12275 void *parsed_result,
12276 __attribute__((unused)) struct cmdline *cl,
12277 __attribute__((unused)) void *data)
12279 struct cmd_set_vf_broadcast_result *res = parsed_result;
12280 int ret = -ENOTSUP;
12282 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12284 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12287 #ifdef RTE_LIBRTE_I40E_PMD
12288 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12289 res->vf_id, is_on);
12296 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12299 printf("invalid port_id %d\n", res->port_id);
12302 printf("function not implemented\n");
12305 printf("programming error: (%s)\n", strerror(-ret));
12309 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12310 .f = cmd_set_vf_broadcast_parsed,
12312 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12314 (void *)&cmd_set_vf_broadcast_set,
12315 (void *)&cmd_set_vf_broadcast_vf,
12316 (void *)&cmd_set_vf_broadcast_broadcast,
12317 (void *)&cmd_set_vf_broadcast_port_id,
12318 (void *)&cmd_set_vf_broadcast_vf_id,
12319 (void *)&cmd_set_vf_broadcast_on_off,
12324 /* vf vlan tag configuration */
12326 /* Common result structure for vf vlan tag */
12327 struct cmd_set_vf_vlan_tag_result {
12328 cmdline_fixed_string_t set;
12329 cmdline_fixed_string_t vf;
12330 cmdline_fixed_string_t vlan;
12331 cmdline_fixed_string_t tag;
12334 cmdline_fixed_string_t on_off;
12337 /* Common CLI fields for vf vlan tag enable disable */
12338 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12339 TOKEN_STRING_INITIALIZER
12340 (struct cmd_set_vf_vlan_tag_result,
12342 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12343 TOKEN_STRING_INITIALIZER
12344 (struct cmd_set_vf_vlan_tag_result,
12346 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12347 TOKEN_STRING_INITIALIZER
12348 (struct cmd_set_vf_vlan_tag_result,
12350 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12351 TOKEN_STRING_INITIALIZER
12352 (struct cmd_set_vf_vlan_tag_result,
12354 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12355 TOKEN_NUM_INITIALIZER
12356 (struct cmd_set_vf_vlan_tag_result,
12358 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12359 TOKEN_NUM_INITIALIZER
12360 (struct cmd_set_vf_vlan_tag_result,
12362 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12363 TOKEN_STRING_INITIALIZER
12364 (struct cmd_set_vf_vlan_tag_result,
12368 cmd_set_vf_vlan_tag_parsed(
12369 void *parsed_result,
12370 __attribute__((unused)) struct cmdline *cl,
12371 __attribute__((unused)) void *data)
12373 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12374 int ret = -ENOTSUP;
12376 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12378 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12381 #ifdef RTE_LIBRTE_I40E_PMD
12382 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12383 res->vf_id, is_on);
12390 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12393 printf("invalid port_id %d\n", res->port_id);
12396 printf("function not implemented\n");
12399 printf("programming error: (%s)\n", strerror(-ret));
12403 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12404 .f = cmd_set_vf_vlan_tag_parsed,
12406 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12408 (void *)&cmd_set_vf_vlan_tag_set,
12409 (void *)&cmd_set_vf_vlan_tag_vf,
12410 (void *)&cmd_set_vf_vlan_tag_vlan,
12411 (void *)&cmd_set_vf_vlan_tag_tag,
12412 (void *)&cmd_set_vf_vlan_tag_port_id,
12413 (void *)&cmd_set_vf_vlan_tag_vf_id,
12414 (void *)&cmd_set_vf_vlan_tag_on_off,
12419 /* Common definition of VF and TC TX bandwidth configuration */
12420 struct cmd_vf_tc_bw_result {
12421 cmdline_fixed_string_t set;
12422 cmdline_fixed_string_t vf;
12423 cmdline_fixed_string_t tc;
12424 cmdline_fixed_string_t tx;
12425 cmdline_fixed_string_t min_bw;
12426 cmdline_fixed_string_t max_bw;
12427 cmdline_fixed_string_t strict_link_prio;
12432 cmdline_fixed_string_t bw_list;
12436 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12437 TOKEN_STRING_INITIALIZER
12438 (struct cmd_vf_tc_bw_result,
12440 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12441 TOKEN_STRING_INITIALIZER
12442 (struct cmd_vf_tc_bw_result,
12444 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12445 TOKEN_STRING_INITIALIZER
12446 (struct cmd_vf_tc_bw_result,
12448 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12449 TOKEN_STRING_INITIALIZER
12450 (struct cmd_vf_tc_bw_result,
12452 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12453 TOKEN_STRING_INITIALIZER
12454 (struct cmd_vf_tc_bw_result,
12455 strict_link_prio, "strict-link-priority");
12456 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12457 TOKEN_STRING_INITIALIZER
12458 (struct cmd_vf_tc_bw_result,
12459 min_bw, "min-bandwidth");
12460 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12461 TOKEN_STRING_INITIALIZER
12462 (struct cmd_vf_tc_bw_result,
12463 max_bw, "max-bandwidth");
12464 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12465 TOKEN_NUM_INITIALIZER
12466 (struct cmd_vf_tc_bw_result,
12468 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12469 TOKEN_NUM_INITIALIZER
12470 (struct cmd_vf_tc_bw_result,
12472 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12473 TOKEN_NUM_INITIALIZER
12474 (struct cmd_vf_tc_bw_result,
12476 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12477 TOKEN_NUM_INITIALIZER
12478 (struct cmd_vf_tc_bw_result,
12480 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12481 TOKEN_STRING_INITIALIZER
12482 (struct cmd_vf_tc_bw_result,
12484 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12485 TOKEN_NUM_INITIALIZER
12486 (struct cmd_vf_tc_bw_result,
12489 /* VF max bandwidth setting */
12491 cmd_vf_max_bw_parsed(
12492 void *parsed_result,
12493 __attribute__((unused)) struct cmdline *cl,
12494 __attribute__((unused)) void *data)
12496 struct cmd_vf_tc_bw_result *res = parsed_result;
12497 int ret = -ENOTSUP;
12499 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12502 #ifdef RTE_LIBRTE_I40E_PMD
12503 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12504 res->vf_id, res->bw);
12511 printf("invalid vf_id %d or bandwidth %d\n",
12512 res->vf_id, res->bw);
12515 printf("invalid port_id %d\n", res->port_id);
12518 printf("function not implemented\n");
12521 printf("programming error: (%s)\n", strerror(-ret));
12525 cmdline_parse_inst_t cmd_vf_max_bw = {
12526 .f = cmd_vf_max_bw_parsed,
12528 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12530 (void *)&cmd_vf_tc_bw_set,
12531 (void *)&cmd_vf_tc_bw_vf,
12532 (void *)&cmd_vf_tc_bw_tx,
12533 (void *)&cmd_vf_tc_bw_max_bw,
12534 (void *)&cmd_vf_tc_bw_port_id,
12535 (void *)&cmd_vf_tc_bw_vf_id,
12536 (void *)&cmd_vf_tc_bw_bw,
12542 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12547 const char *p, *p0 = str;
12554 p = strchr(p0, '(');
12556 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12560 p0 = strchr(p, ')');
12562 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12566 if (size >= sizeof(s)) {
12567 printf("The string size exceeds the internal buffer size\n");
12570 snprintf(s, sizeof(s), "%.*s", size, p);
12571 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12573 printf("Failed to get the bandwidth list. ");
12577 for (i = 0; i < ret; i++)
12578 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12583 /* TC min bandwidth setting */
12585 cmd_vf_tc_min_bw_parsed(
12586 void *parsed_result,
12587 __attribute__((unused)) struct cmdline *cl,
12588 __attribute__((unused)) void *data)
12590 struct cmd_vf_tc_bw_result *res = parsed_result;
12593 int ret = -ENOTSUP;
12595 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12598 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12602 #ifdef RTE_LIBRTE_I40E_PMD
12603 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12611 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12614 printf("invalid port_id %d\n", res->port_id);
12617 printf("function not implemented\n");
12620 printf("programming error: (%s)\n", strerror(-ret));
12624 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12625 .f = cmd_vf_tc_min_bw_parsed,
12627 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12628 " <bw1, bw2, ...>",
12630 (void *)&cmd_vf_tc_bw_set,
12631 (void *)&cmd_vf_tc_bw_vf,
12632 (void *)&cmd_vf_tc_bw_tc,
12633 (void *)&cmd_vf_tc_bw_tx,
12634 (void *)&cmd_vf_tc_bw_min_bw,
12635 (void *)&cmd_vf_tc_bw_port_id,
12636 (void *)&cmd_vf_tc_bw_vf_id,
12637 (void *)&cmd_vf_tc_bw_bw_list,
12642 /* TC max bandwidth setting */
12644 cmd_vf_tc_max_bw_parsed(
12645 void *parsed_result,
12646 __attribute__((unused)) struct cmdline *cl,
12647 __attribute__((unused)) void *data)
12649 struct cmd_vf_tc_bw_result *res = parsed_result;
12650 int ret = -ENOTSUP;
12652 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12655 #ifdef RTE_LIBRTE_I40E_PMD
12656 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12657 res->tc_no, res->bw);
12664 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12665 res->vf_id, res->tc_no, res->bw);
12668 printf("invalid port_id %d\n", res->port_id);
12671 printf("function not implemented\n");
12674 printf("programming error: (%s)\n", strerror(-ret));
12678 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12679 .f = cmd_vf_tc_max_bw_parsed,
12681 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12684 (void *)&cmd_vf_tc_bw_set,
12685 (void *)&cmd_vf_tc_bw_vf,
12686 (void *)&cmd_vf_tc_bw_tc,
12687 (void *)&cmd_vf_tc_bw_tx,
12688 (void *)&cmd_vf_tc_bw_max_bw,
12689 (void *)&cmd_vf_tc_bw_port_id,
12690 (void *)&cmd_vf_tc_bw_vf_id,
12691 (void *)&cmd_vf_tc_bw_tc_no,
12692 (void *)&cmd_vf_tc_bw_bw,
12697 /* Strict link priority scheduling mode setting */
12699 cmd_strict_link_prio_parsed(
12700 void *parsed_result,
12701 __attribute__((unused)) struct cmdline *cl,
12702 __attribute__((unused)) void *data)
12704 struct cmd_vf_tc_bw_result *res = parsed_result;
12705 int ret = -ENOTSUP;
12707 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12710 #ifdef RTE_LIBRTE_I40E_PMD
12711 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12718 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12721 printf("invalid port_id %d\n", res->port_id);
12724 printf("function not implemented\n");
12727 printf("programming error: (%s)\n", strerror(-ret));
12731 cmdline_parse_inst_t cmd_strict_link_prio = {
12732 .f = cmd_strict_link_prio_parsed,
12734 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12736 (void *)&cmd_vf_tc_bw_set,
12737 (void *)&cmd_vf_tc_bw_tx,
12738 (void *)&cmd_vf_tc_bw_strict_link_prio,
12739 (void *)&cmd_vf_tc_bw_port_id,
12740 (void *)&cmd_vf_tc_bw_tc_map,
12745 /* Load dynamic device personalization*/
12746 struct cmd_ddp_add_result {
12747 cmdline_fixed_string_t ddp;
12748 cmdline_fixed_string_t add;
12753 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12754 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12755 cmdline_parse_token_string_t cmd_ddp_add_add =
12756 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12757 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12758 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12759 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12760 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12763 cmd_ddp_add_parsed(
12764 void *parsed_result,
12765 __attribute__((unused)) struct cmdline *cl,
12766 __attribute__((unused)) void *data)
12768 struct cmd_ddp_add_result *res = parsed_result;
12771 int ret = -ENOTSUP;
12773 if (res->port_id > nb_ports) {
12774 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12778 if (!all_ports_stopped()) {
12779 printf("Please stop all ports first\n");
12783 buff = open_ddp_package_file(res->filepath, &size);
12787 #ifdef RTE_LIBRTE_I40E_PMD
12788 if (ret == -ENOTSUP)
12789 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12791 RTE_PMD_I40E_PKG_OP_WR_ADD);
12795 printf("Failed to load profile.\n");
12797 printf("Profile has already existed.\n");
12799 close_ddp_package_file(buff);
12802 cmdline_parse_inst_t cmd_ddp_add = {
12803 .f = cmd_ddp_add_parsed,
12805 .help_str = "ddp add <port_id> <profile_path>",
12807 (void *)&cmd_ddp_add_ddp,
12808 (void *)&cmd_ddp_add_add,
12809 (void *)&cmd_ddp_add_port_id,
12810 (void *)&cmd_ddp_add_filepath,
12815 /* ******************************************************************************** */
12817 /* list of instructions */
12818 cmdline_parse_ctx_t main_ctx[] = {
12819 (cmdline_parse_inst_t *)&cmd_help_brief,
12820 (cmdline_parse_inst_t *)&cmd_help_long,
12821 (cmdline_parse_inst_t *)&cmd_quit,
12822 (cmdline_parse_inst_t *)&cmd_showport,
12823 (cmdline_parse_inst_t *)&cmd_showqueue,
12824 (cmdline_parse_inst_t *)&cmd_showportall,
12825 (cmdline_parse_inst_t *)&cmd_showcfg,
12826 (cmdline_parse_inst_t *)&cmd_start,
12827 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12828 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12829 (cmdline_parse_inst_t *)&cmd_set_link_up,
12830 (cmdline_parse_inst_t *)&cmd_set_link_down,
12831 (cmdline_parse_inst_t *)&cmd_reset,
12832 (cmdline_parse_inst_t *)&cmd_set_numbers,
12833 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12834 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12835 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12836 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12837 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12838 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12839 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12840 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12841 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12842 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12843 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12844 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12845 (cmdline_parse_inst_t *)&cmd_set_link_check,
12846 #ifdef RTE_NIC_BYPASS
12847 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12848 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12849 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12850 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12852 #ifdef RTE_LIBRTE_PMD_BOND
12853 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12854 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12855 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12856 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12857 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12858 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12859 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12860 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12861 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12863 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12864 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12865 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12866 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12867 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12868 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12869 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12870 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12871 (cmdline_parse_inst_t *)&cmd_csum_set,
12872 (cmdline_parse_inst_t *)&cmd_csum_show,
12873 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12874 (cmdline_parse_inst_t *)&cmd_tso_set,
12875 (cmdline_parse_inst_t *)&cmd_tso_show,
12876 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12877 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12878 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12879 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12880 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12881 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12882 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12883 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12884 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12885 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12886 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12887 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12888 (cmdline_parse_inst_t *)&cmd_config_dcb,
12889 (cmdline_parse_inst_t *)&cmd_read_reg,
12890 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12891 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12892 (cmdline_parse_inst_t *)&cmd_write_reg,
12893 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12894 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12895 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12896 (cmdline_parse_inst_t *)&cmd_stop,
12897 (cmdline_parse_inst_t *)&cmd_mac_addr,
12898 (cmdline_parse_inst_t *)&cmd_set_qmap,
12899 (cmdline_parse_inst_t *)&cmd_operate_port,
12900 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12901 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12902 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12903 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12904 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12905 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12906 (cmdline_parse_inst_t *)&cmd_config_mtu,
12907 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12908 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12909 (cmdline_parse_inst_t *)&cmd_config_rss,
12910 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12911 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12912 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12913 (cmdline_parse_inst_t *)&cmd_showport_reta,
12914 (cmdline_parse_inst_t *)&cmd_config_burst,
12915 (cmdline_parse_inst_t *)&cmd_config_thresh,
12916 (cmdline_parse_inst_t *)&cmd_config_threshold,
12917 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12918 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12919 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12920 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12921 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12922 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12923 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12924 (cmdline_parse_inst_t *)&cmd_global_config,
12925 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12926 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12927 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12928 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12929 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12930 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12931 (cmdline_parse_inst_t *)&cmd_dump,
12932 (cmdline_parse_inst_t *)&cmd_dump_one,
12933 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12934 (cmdline_parse_inst_t *)&cmd_syn_filter,
12935 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12936 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12937 (cmdline_parse_inst_t *)&cmd_flex_filter,
12938 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12939 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12940 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12941 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12942 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12943 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12944 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12945 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12946 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12947 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12948 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12949 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12950 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12951 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12952 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12953 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12954 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12955 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12956 (cmdline_parse_inst_t *)&cmd_flow,
12957 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12958 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12959 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12960 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12961 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12962 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12963 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12964 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12965 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12966 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12967 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12968 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12969 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12970 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12971 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12972 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12973 #ifdef RTE_LIBRTE_IXGBE_PMD
12974 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12975 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12976 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12977 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12978 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12979 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12980 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12981 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12982 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12984 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12985 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12986 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
12987 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
12988 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
12989 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
12990 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
12991 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
12992 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
12993 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
12994 (cmdline_parse_inst_t *)&cmd_ddp_add,
12998 /* prompt function, called from main on MASTER lcore */
13002 /* initialize non-constant commands */
13003 cmd_set_fwd_mode_init();
13004 cmd_set_fwd_retry_mode_init();
13006 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13007 if (testpmd_cl == NULL)
13009 cmdline_interact(testpmd_cl);
13010 cmdline_stdin_exit(testpmd_cl);
13016 if (testpmd_cl != NULL)
13017 cmdline_quit(testpmd_cl);
13021 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13023 if (id == (portid_t)RTE_PORT_ALL) {
13026 FOREACH_PORT(pid, ports) {
13027 /* check if need_reconfig has been set to 1 */
13028 if (ports[pid].need_reconfig == 0)
13029 ports[pid].need_reconfig = dev;
13030 /* check if need_reconfig_queues has been set to 1 */
13031 if (ports[pid].need_reconfig_queues == 0)
13032 ports[pid].need_reconfig_queues = queue;
13034 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13035 /* check if need_reconfig has been set to 1 */
13036 if (ports[id].need_reconfig == 0)
13037 ports[id].need_reconfig = dev;
13038 /* check if need_reconfig_queues has been set to 1 */
13039 if (ports[id].need_reconfig_queues == 0)
13040 ports[id].need_reconfig_queues = queue;