4 * Copyright(c) 2010-2014 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>
64 #include <rte_tailq.h>
66 #include <rte_per_lcore.h>
67 #include <rte_lcore.h>
68 #include <rte_atomic.h>
69 #include <rte_branch_prediction.h>
71 #include <rte_mempool.h>
72 #include <rte_interrupts.h>
74 #include <rte_ether.h>
75 #include <rte_ethdev.h>
76 #include <rte_string_fns.h>
77 #include <rte_devargs.h>
79 #include <cmdline_rdline.h>
80 #include <cmdline_parse.h>
81 #include <cmdline_parse_num.h>
82 #include <cmdline_parse_string.h>
83 #include <cmdline_parse_ipaddr.h>
84 #include <cmdline_parse_etheraddr.h>
85 #include <cmdline_socket.h>
87 #include <rte_pci_dev_ids.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
94 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
97 uint8_t bypass_is_supported(portid_t port_id);
100 /* *** Help command with introduction. *** */
101 struct cmd_help_brief_result {
102 cmdline_fixed_string_t help;
105 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
107 __attribute__((unused)) void *data)
112 "Help is available for the following sections:\n\n"
113 " help control : Start and stop forwarding.\n"
114 " help display : Displaying port, stats and config "
116 " help config : Configuration information.\n"
117 " help ports : Configuring ports.\n"
118 " help flowdir : Flow Director filter help.\n"
119 " help registers : Reading and setting port registers.\n"
120 " help filters : Filters configuration help.\n"
121 " help all : All of the above sections.\n\n"
126 cmdline_parse_token_string_t cmd_help_brief_help =
127 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
129 cmdline_parse_inst_t cmd_help_brief = {
130 .f = cmd_help_brief_parsed,
132 .help_str = "show help",
134 (void *)&cmd_help_brief_help,
139 /* *** Help command with help sections. *** */
140 struct cmd_help_long_result {
141 cmdline_fixed_string_t help;
142 cmdline_fixed_string_t section;
145 static void cmd_help_long_parsed(void *parsed_result,
147 __attribute__((unused)) void *data)
150 struct cmd_help_long_result *res = parsed_result;
152 if (!strcmp(res->section, "all"))
155 if (show_all || !strcmp(res->section, "control")) {
160 "Control forwarding:\n"
161 "-------------------\n\n"
164 " Start packet forwarding with current configuration.\n\n"
167 " Start packet forwarding with current config"
168 " after sending one burst of packets.\n\n"
171 " Stop packet forwarding, and display accumulated"
175 " Quit to prompt.\n\n"
179 if (show_all || !strcmp(res->section, "display")) {
187 "show port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
188 " Display information for port_id, or all.\n\n"
190 "show port X rss reta (size) (mask0,mask1,...)\n"
191 " Display the rss redirection table entry indicated"
192 " by masks on port X. size is used to indicate the"
193 " hardware supported reta size\n\n"
195 "show port rss-hash [key]\n"
196 " Display the RSS hash functions and RSS hash key"
199 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
200 " Clear information for port_id, or all.\n\n"
202 "show config (rxtx|cores|fwd)\n"
203 " Display the given configuration.\n\n"
205 "read rxd (port_id) (queue_id) (rxd_id)\n"
206 " Display an RX descriptor of a port RX queue.\n\n"
208 "read txd (port_id) (queue_id) (txd_id)\n"
209 " Display a TX descriptor of a port TX queue.\n\n"
213 if (show_all || !strcmp(res->section, "config")) {
219 "Configuration changes only become active when"
220 " forwarding is started/restarted.\n\n"
223 " Reset forwarding to the default configuration.\n\n"
225 "set verbose (level)\n"
226 " Set the debug verbosity level X.\n\n"
229 " Set number of ports.\n\n"
232 " Set number of cores.\n\n"
234 "set coremask (mask)\n"
235 " Set the forwarding cores hexadecimal mask.\n\n"
237 "set portmask (mask)\n"
238 " Set the forwarding ports hexadecimal mask.\n\n"
241 " Set number of packets per burst.\n\n"
243 "set burst tx delay (microseconds) retry (num)\n"
244 " Set the transmit delay time and number of retries"
245 " in mac_retry forwarding mode.\n\n"
247 "set txpkts (x[,y]*)\n"
248 " Set the length of each segment of TXONLY"
251 "set corelist (x[,y]*)\n"
252 " Set the list of forwarding cores.\n\n"
254 "set portlist (x[,y]*)\n"
255 " Set the list of forwarding ports.\n\n"
257 "vlan set strip (on|off) (port_id)\n"
258 " Set the VLAN strip on a port.\n\n"
260 "vlan set stripq (on|off) (port_id,queue_id)\n"
261 " Set the VLAN strip for a queue on a port.\n\n"
263 "vlan set filter (on|off) (port_id)\n"
264 " Set the VLAN filter on a port.\n\n"
266 "vlan set qinq (on|off) (port_id)\n"
267 " Set the VLAN QinQ (extended queue in queue)"
270 "vlan set tpid (value) (port_id)\n"
271 " Set the outer VLAN TPID for Packet Filtering on"
274 "rx_vlan add (vlan_id|all) (port_id)\n"
275 " Add a vlan_id, or all identifiers, to the set"
276 " of VLAN identifiers filtered by port_id.\n\n"
278 "rx_vlan rm (vlan_id|all) (port_id)\n"
279 " Remove a vlan_id, or all identifiers, from the set"
280 " of VLAN identifiers filtered by port_id.\n\n"
282 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
283 " Add a vlan_id, to the set of VLAN identifiers"
284 "filtered for VF(s) from port_id.\n\n"
286 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
287 " Remove a vlan_id, to the set of VLAN identifiers"
288 "filtered for VF(s) from port_id.\n\n"
290 "rx_vlan set tpid (value) (port_id)\n"
291 " Set the outer VLAN TPID for Packet Filtering on"
294 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
295 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
296 " add a tunnel filter of a port.\n\n"
298 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
299 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
300 " remove a tunnel filter of a port.\n\n"
302 "rx_vxlan_port add (udp_port) (port_id)\n"
303 " Add an UDP port for VXLAN packet filter on a port\n\n"
305 "rx_vxlan_port rm (udp_port) (port_id)\n"
306 " Remove an UDP port for VXLAN packet filter on a port\n\n"
308 "tx_vlan set vlan_id (port_id)\n"
309 " Set hardware insertion of VLAN ID in packets sent"
312 "tx_vlan set pvid port_id vlan_id (on|off)\n"
313 " Set port based TX VLAN insertion.\n\n"
315 "tx_vlan reset (port_id)\n"
316 " Disable hardware insertion of a VLAN header in"
317 " packets sent on a port.\n\n"
319 "tx_cksum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n"
320 " Select hardware or software calculation of the"
321 " checksum with when transmitting a packet using the"
322 " csum forward engine.\n"
323 " ip|udp|tcp|sctp always concern the inner layer.\n"
324 " vxlan concerns the outer IP and UDP layer (in"
325 " case the packet is recognized as a vxlan packet by"
326 " the forward engine)\n"
327 " Please check the NIC datasheet for HW limits.\n\n"
329 "tx_checksum show (port_id)\n"
330 " Display tx checksum offload configuration\n\n"
332 "tso set (segsize) (portid)\n"
333 " Enable TCP Segmentation Offload in csum forward"
335 " Please check the NIC datasheet for HW limits.\n\n"
338 " Display the status of TCP Segmentation Offload.\n\n"
341 " Set packet forwarding mode.\n\n"
343 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
344 " Add a MAC address on port_id.\n\n"
346 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
347 " Remove a MAC address from port_id.\n\n"
349 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
350 " Add a MAC address for a VF on the port.\n\n"
352 "set port (port_id) uta (mac_address|all) (on|off)\n"
353 " Add/Remove a or all unicast hash filter(s)"
356 "set promisc (port_id|all) (on|off)\n"
357 " Set the promiscuous mode on port_id, or all.\n\n"
359 "set allmulti (port_id|all) (on|off)\n"
360 " Set the allmulti mode on port_id, or all.\n\n"
362 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
363 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
364 " (on|off) autoneg (on|off) (port_id)\n"
365 "set flow_ctrl rx (on|off) (portid)\n"
366 "set flow_ctrl tx (on|off) (portid)\n"
367 "set flow_ctrl high_water (high_water) (portid)\n"
368 "set flow_ctrl low_water (low_water) (portid)\n"
369 "set flow_ctrl pause_time (pause_time) (portid)\n"
370 "set flow_ctrl send_xon (send_xon) (portid)\n"
371 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
372 "set flow_ctrl autoneg (on|off) (port_id)\n"
373 " Set the link flow control parameter on a port.\n\n"
375 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
376 " (low_water) (pause_time) (priority) (port_id)\n"
377 " Set the priority flow control parameter on a"
380 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
381 " Set statistics mapping (qmapping 0..15) for RX/TX"
383 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
384 " on port 0 to mapping 5.\n\n"
386 "set port (port_id) vf (vf_id) rx|tx on|off\n"
387 " Enable/Disable a VF receive/tranmit from a port\n\n"
389 "set port (port_id) vf (vf_id) (mac_addr)"
390 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
391 " Add/Remove unicast or multicast MAC addr filter"
394 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
396 " AUPE:accepts untagged VLAN;"
397 "ROPE:accept unicast hash\n\n"
398 " BAM:accepts broadcast packets;"
399 "MPE:accepts all multicast packets\n\n"
400 " Enable/Disable a VF receive mode of a port\n\n"
402 "set port (port_id) queue (queue_id) rate (rate_num)\n"
403 " Set rate limit for a queue of a port\n\n"
405 "set port (port_id) vf (vf_id) rate (rate_num) "
406 "queue_mask (queue_mask_value)\n"
407 " Set rate limit for queues in VF of a port\n\n"
409 "set port (port_id) mirror-rule (rule_id)"
410 "(pool-mirror|vlan-mirror)\n"
411 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
412 " Set pool or vlan type mirror rule on a port.\n"
413 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
414 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
417 "set port (port_id) mirror-rule (rule_id)"
418 " (uplink-mirror|downlink-mirror) dst-pool"
419 " (pool_id) (on|off)\n"
420 " Set uplink or downlink type mirror rule on a port.\n"
421 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
422 " 0 on' enable mirror income traffic to pool 0.\n\n"
424 "reset port (port_id) mirror-rule (rule_id)\n"
425 " Reset a mirror rule.\n\n"
427 "set flush_rx (on|off)\n"
428 " Flush (default) or don't flush RX streams before"
429 " forwarding. Mainly used with PCAP drivers.\n\n"
431 #ifdef RTE_NIC_BYPASS
432 "set bypass mode (normal|bypass|isolate) (port_id)\n"
433 " Set the bypass mode for the lowest port on bypass enabled"
436 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
437 "mode (normal|bypass|isolate) (port_id)\n"
438 " Set the event required to initiate specified bypass mode for"
439 " the lowest port on a bypass enabled NIC where:\n"
440 " timeout = enable bypass after watchdog timeout.\n"
441 " os_on = enable bypass when OS/board is powered on.\n"
442 " os_off = enable bypass when OS/board is powered off.\n"
443 " power_on = enable bypass when power supply is turned on.\n"
444 " power_off = enable bypass when power supply is turned off."
447 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
448 " Set the bypass watchdog timeout to 'n' seconds"
449 " where 0 = instant.\n\n"
451 "show bypass config (port_id)\n"
452 " Show the bypass configuration for a bypass enabled NIC"
453 " using the lowest port on the NIC.\n\n"
455 #ifdef RTE_LIBRTE_PMD_BOND
456 "create bonded device (mode) (socket)\n"
457 " Create a new bonded device with specific bonding mode and socket.\n\n"
459 "add bonding slave (slave_id) (port_id)\n"
460 " Add a slave device to a bonded device.\n\n"
462 "remove bonding slave (slave_id) (port_id)\n"
463 " Remove a slave device from a bonded device.\n\n"
465 "set bonding mode (value) (port_id)\n"
466 " Set the bonding mode on a bonded device.\n\n"
468 "set bonding primary (slave_id) (port_id)\n"
469 " Set the primary slave for a bonded device.\n\n"
471 "show bonding config (port_id)\n"
472 " Show the bonding config for port_id.\n\n"
474 "set bonding mac_addr (port_id) (address)\n"
475 " Set the MAC address of a bonded device.\n\n"
477 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
478 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
480 "set bonding mon_period (port_id) (value)\n"
481 " Set the bonding link status monitoring polling period in ms.\n\n"
483 "set link-up port (port_id)\n"
484 " Set link up for a port.\n\n"
486 "set link-down port (port_id)\n"
487 " Set link down for a port.\n\n"
489 , list_pkt_forwarding_modes()
494 if (show_all || !strcmp(res->section, "flowdir")) {
499 "Flow director mode:\n"
500 "-------------------\n\n"
502 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
503 " src (src_ip_address) (src_port)"
504 " dst (dst_ip_address) (dst_port)"
505 " flexbytes (flexbytes_values) vlan (vlan_id)"
506 " queue (queue_id)\n"
507 " Add a signature filter.\n\n"
509 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
510 " src (src_ip_address) (src_port)"
511 " dst (dst_ip_address) (dst_port)"
512 " flexbytes (flexbytes_values) vlan (vlan_id)"
513 " queue (queue_id)\n"
514 " Update a signature filter.\n\n"
516 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
517 " src (src_ip_address) (src_port)"
518 " dst (dst_ip_address) (dst_port)"
519 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
520 " Remove a signature filter.\n\n"
522 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
523 " src (src_ip_address) (src_port)"
524 " dst (dst_ip_address) (dst_port)"
525 " flexbytes (flexbytes_values) vlan (vlan_id)"
526 " queue (queue_id) soft (soft_id)\n"
527 " Add a perfect filter.\n\n"
529 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
530 " src (src_ip_address) (src_port)"
531 " dst (dst_ip_address) (dst_port)"
532 " flexbytes (flexbytes_values) vlan (vlan_id)"
533 " queue (queue_id)\n"
534 " Update a perfect filter.\n\n"
536 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
537 " src (src_ip_address) (src_port)"
538 " dst (dst_ip_address) (dst_port)"
539 " flexbytes (flexbytes_values) vlan (vlan_id)"
541 " Remove a perfect filter.\n\n"
543 "set_masks_filter (port_id) only_ip_flow (0|1)"
544 " src_mask (ip_src_mask) (src_port_mask)"
545 " dst_mask (ip_dst_mask) (dst_port_mask)"
546 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
547 " Set IPv4 filter masks.\n\n"
549 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
550 " src_mask (ip_src_mask) (src_port_mask)"
551 " dst_mask (ip_dst_mask) (dst_port_mask)"
552 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
553 " compare_dst (0|1)\n"
554 " Set IPv6 filter masks.\n\n"
558 if (show_all || !strcmp(res->section, "ports")) {
564 "----------------\n\n"
566 "port start (port_id|all)\n"
567 " Start all ports or port_id.\n\n"
569 "port stop (port_id|all)\n"
570 " Stop all ports or port_id.\n\n"
572 "port close (port_id|all)\n"
573 " Close all ports or port_id.\n\n"
575 "port config (port_id|all)"
576 " speed (10|100|1000|10000|40000|auto)"
577 " duplex (half|full|auto)\n"
578 " Set speed and duplex for all ports or port_id\n\n"
580 "port config all (rxq|txq|rxd|txd) (value)\n"
581 " Set number for rxq/txq/rxd/txd.\n\n"
583 "port config all max-pkt-len (value)\n"
584 " Set the max packet length.\n\n"
586 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
588 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
591 "port config all rss (ip|udp|none)\n"
592 " Set the RSS mode.\n\n"
594 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
595 " Set the RSS redirection table.\n\n"
597 "port config (port_id) dcb vt (on|off) (traffic_class)"
599 " Set the DCB mode.\n\n"
601 "port config all burst (value)\n"
602 " Set the number of packets per burst.\n\n"
604 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
606 " Set the ring prefetch/host/writeback threshold"
607 " for tx/rx queue.\n\n"
609 "port config all (txfreet|txrst|rxfreet) (value)\n"
610 " Set free threshold for rx/tx, or set"
611 " tx rs bit threshold.\n\n"
612 "port config mtu X value\n"
613 " Set the MTU of port X to a given value\n\n"
615 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
616 " Start/stop a rx/tx queue of port X. Only take effect"
617 " when port X is started\n"
621 if (show_all || !strcmp(res->section, "registers")) {
629 "read reg (port_id) (address)\n"
630 " Display value of a port register.\n\n"
632 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
633 " Display a port register bit field.\n\n"
635 "read regbit (port_id) (address) (bit_x)\n"
636 " Display a single port register bit.\n\n"
638 "write reg (port_id) (address) (value)\n"
639 " Set value of a port register.\n\n"
641 "write regfield (port_id) (address) (bit_x) (bit_y)"
643 " Set bit field of a port register.\n\n"
645 "write regbit (port_id) (address) (bit_x) (value)\n"
646 " Set single bit value of a port register.\n\n"
649 if (show_all || !strcmp(res->section, "filters")) {
657 "ethertype_filter (port_id) (add|del)"
658 " (mac_addr|mac_ignr) (mac_address) ethertype"
659 " (ether_type) (drop|fwd) queue (queue_id)\n"
660 " Add/Del an ethertype filter.\n\n"
662 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
663 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
664 " queue (queue_id) index (idx)\n"
665 " add a 2tuple filter.\n\n"
667 "remove_2tuple_filter (port_id) index (idx)\n"
668 " remove a 2tuple filter.\n\n"
670 "get_2tuple_filter (port_id) index (idx)\n"
671 " get info of a 2tuple filter.\n\n"
673 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
674 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
675 " mask (mask_value) flags (flags_value) priority (prio_value)"
676 " queue (queue_id) index (idx)\n"
677 " add a 5tuple filter.\n\n"
679 "remove_5tuple_filter (port_id) index (idx)\n"
680 " remove a 5tuple filter.\n\n"
682 "get_5tuple_filter (port_id) index (idx)\n"
683 " get info of a 5tuple filter.\n\n"
685 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
686 " add syn filter.\n\n"
688 "remove_syn_filter (port_id)"
689 " remove syn filter.\n\n"
691 "get_syn_filter (port_id) "
692 " get syn filter info.\n\n"
694 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
695 " priority (prio_value) queue (queue_id) index (idx)\n"
696 " add a flex filter.\n\n"
698 "remove_flex_filter (port_id) index (idx)\n"
699 " remove a flex filter.\n\n"
701 "get_flex_filter (port_id) index (idx)\n"
702 " get info of a flex filter.\n\n"
704 "flow_director_filter (port_id) (add|del)"
705 " flow (ip4|ip4-frag|ip6|ip6-frag)"
706 " src (src_ip_address) dst (dst_ip_address)"
707 " flexbytes (flexbytes_value)"
708 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
709 " Add/Del an IP type flow director filter.\n\n"
711 "flow_director_filter (port_id) (add|del)"
712 " flow (udp4|tcp4|udp6|tcp6)"
713 " src (src_ip_address) (src_port)"
714 " dst (dst_ip_address) (dst_port)"
715 " flexbytes (flexbytes_value)"
716 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
717 " Add/Del an UDP/TCP type flow director filter.\n\n"
719 "flow_director_filter (port_id) (add|del)"
720 " flow (sctp4|sctp6)"
721 " src (src_ip_address) dst (dst_ip_address)"
722 " tag (verification_tag)"
723 " flexbytes (flexbytes_value) (drop|fwd)"
724 " queue (queue_id) fd_id (fd_id_value)\n"
725 " Add/Del a SCTP type flow director filter.\n\n"
727 "flush_flow_director (port_id)\n"
728 " Flush all flow director entries of a device.\n\n"
730 "flow_director_flex_mask (port_id)"
731 " flow (ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
733 " Configure mask of flex payload.\n\n"
735 "flow_director_flex_payload (port_id)"
736 " (l2|l3|l4) (config)\n"
737 " Configure flex payload selection.\n\n"
742 cmdline_parse_token_string_t cmd_help_long_help =
743 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
745 cmdline_parse_token_string_t cmd_help_long_section =
746 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
747 "all#control#display#config#flowdir#"
748 "ports#registers#filters");
750 cmdline_parse_inst_t cmd_help_long = {
751 .f = cmd_help_long_parsed,
753 .help_str = "show help",
755 (void *)&cmd_help_long_help,
756 (void *)&cmd_help_long_section,
762 /* *** start/stop/close all ports *** */
763 struct cmd_operate_port_result {
764 cmdline_fixed_string_t keyword;
765 cmdline_fixed_string_t name;
766 cmdline_fixed_string_t value;
769 static void cmd_operate_port_parsed(void *parsed_result,
770 __attribute__((unused)) struct cmdline *cl,
771 __attribute__((unused)) void *data)
773 struct cmd_operate_port_result *res = parsed_result;
775 if (!strcmp(res->name, "start"))
776 start_port(RTE_PORT_ALL);
777 else if (!strcmp(res->name, "stop"))
778 stop_port(RTE_PORT_ALL);
779 else if (!strcmp(res->name, "close"))
780 close_port(RTE_PORT_ALL);
782 printf("Unknown parameter\n");
785 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
786 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
788 cmdline_parse_token_string_t cmd_operate_port_all_port =
789 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
791 cmdline_parse_token_string_t cmd_operate_port_all_all =
792 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
794 cmdline_parse_inst_t cmd_operate_port = {
795 .f = cmd_operate_port_parsed,
797 .help_str = "port start|stop|close all: start/stop/close all ports",
799 (void *)&cmd_operate_port_all_cmd,
800 (void *)&cmd_operate_port_all_port,
801 (void *)&cmd_operate_port_all_all,
806 /* *** start/stop/close specific port *** */
807 struct cmd_operate_specific_port_result {
808 cmdline_fixed_string_t keyword;
809 cmdline_fixed_string_t name;
813 static void cmd_operate_specific_port_parsed(void *parsed_result,
814 __attribute__((unused)) struct cmdline *cl,
815 __attribute__((unused)) void *data)
817 struct cmd_operate_specific_port_result *res = parsed_result;
819 if (!strcmp(res->name, "start"))
820 start_port(res->value);
821 else if (!strcmp(res->name, "stop"))
822 stop_port(res->value);
823 else if (!strcmp(res->name, "close"))
824 close_port(res->value);
826 printf("Unknown parameter\n");
829 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
830 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
832 cmdline_parse_token_string_t cmd_operate_specific_port_port =
833 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
834 name, "start#stop#close");
835 cmdline_parse_token_num_t cmd_operate_specific_port_id =
836 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
839 cmdline_parse_inst_t cmd_operate_specific_port = {
840 .f = cmd_operate_specific_port_parsed,
842 .help_str = "port start|stop|close X: start/stop/close port X",
844 (void *)&cmd_operate_specific_port_cmd,
845 (void *)&cmd_operate_specific_port_port,
846 (void *)&cmd_operate_specific_port_id,
851 /* *** configure speed for all ports *** */
852 struct cmd_config_speed_all {
853 cmdline_fixed_string_t port;
854 cmdline_fixed_string_t keyword;
855 cmdline_fixed_string_t all;
856 cmdline_fixed_string_t item1;
857 cmdline_fixed_string_t item2;
858 cmdline_fixed_string_t value1;
859 cmdline_fixed_string_t value2;
863 cmd_config_speed_all_parsed(void *parsed_result,
864 __attribute__((unused)) struct cmdline *cl,
865 __attribute__((unused)) void *data)
867 struct cmd_config_speed_all *res = parsed_result;
868 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
869 uint16_t link_duplex = 0;
872 if (!all_ports_stopped()) {
873 printf("Please stop all ports first\n");
877 if (!strcmp(res->value1, "10"))
878 link_speed = ETH_LINK_SPEED_10;
879 else if (!strcmp(res->value1, "100"))
880 link_speed = ETH_LINK_SPEED_100;
881 else if (!strcmp(res->value1, "1000"))
882 link_speed = ETH_LINK_SPEED_1000;
883 else if (!strcmp(res->value1, "10000"))
884 link_speed = ETH_LINK_SPEED_10G;
885 else if (!strcmp(res->value1, "40000"))
886 link_speed = ETH_LINK_SPEED_40G;
887 else if (!strcmp(res->value1, "auto"))
888 link_speed = ETH_LINK_SPEED_AUTONEG;
890 printf("Unknown parameter\n");
894 if (!strcmp(res->value2, "half"))
895 link_duplex = ETH_LINK_HALF_DUPLEX;
896 else if (!strcmp(res->value2, "full"))
897 link_duplex = ETH_LINK_FULL_DUPLEX;
898 else if (!strcmp(res->value2, "auto"))
899 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
901 printf("Unknown parameter\n");
905 for (pid = 0; pid < nb_ports; pid++) {
906 ports[pid].dev_conf.link_speed = link_speed;
907 ports[pid].dev_conf.link_duplex = link_duplex;
910 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
913 cmdline_parse_token_string_t cmd_config_speed_all_port =
914 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
915 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
916 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
918 cmdline_parse_token_string_t cmd_config_speed_all_all =
919 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
920 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
921 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
922 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
923 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
924 "10#100#1000#10000#40000#auto");
925 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
926 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
927 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
928 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
931 cmdline_parse_inst_t cmd_config_speed_all = {
932 .f = cmd_config_speed_all_parsed,
934 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
937 (void *)&cmd_config_speed_all_port,
938 (void *)&cmd_config_speed_all_keyword,
939 (void *)&cmd_config_speed_all_all,
940 (void *)&cmd_config_speed_all_item1,
941 (void *)&cmd_config_speed_all_value1,
942 (void *)&cmd_config_speed_all_item2,
943 (void *)&cmd_config_speed_all_value2,
948 /* *** configure speed for specific port *** */
949 struct cmd_config_speed_specific {
950 cmdline_fixed_string_t port;
951 cmdline_fixed_string_t keyword;
953 cmdline_fixed_string_t item1;
954 cmdline_fixed_string_t item2;
955 cmdline_fixed_string_t value1;
956 cmdline_fixed_string_t value2;
960 cmd_config_speed_specific_parsed(void *parsed_result,
961 __attribute__((unused)) struct cmdline *cl,
962 __attribute__((unused)) void *data)
964 struct cmd_config_speed_specific *res = parsed_result;
965 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
966 uint16_t link_duplex = 0;
968 if (!all_ports_stopped()) {
969 printf("Please stop all ports first\n");
973 if (res->id >= nb_ports) {
974 printf("Port id %d must be less than %d\n", res->id, nb_ports);
978 if (!strcmp(res->value1, "10"))
979 link_speed = ETH_LINK_SPEED_10;
980 else if (!strcmp(res->value1, "100"))
981 link_speed = ETH_LINK_SPEED_100;
982 else if (!strcmp(res->value1, "1000"))
983 link_speed = ETH_LINK_SPEED_1000;
984 else if (!strcmp(res->value1, "10000"))
985 link_speed = ETH_LINK_SPEED_10000;
986 else if (!strcmp(res->value1, "40000"))
987 link_speed = ETH_LINK_SPEED_40G;
988 else if (!strcmp(res->value1, "auto"))
989 link_speed = ETH_LINK_SPEED_AUTONEG;
991 printf("Unknown parameter\n");
995 if (!strcmp(res->value2, "half"))
996 link_duplex = ETH_LINK_HALF_DUPLEX;
997 else if (!strcmp(res->value2, "full"))
998 link_duplex = ETH_LINK_FULL_DUPLEX;
999 else if (!strcmp(res->value2, "auto"))
1000 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1002 printf("Unknown parameter\n");
1006 ports[res->id].dev_conf.link_speed = link_speed;
1007 ports[res->id].dev_conf.link_duplex = link_duplex;
1009 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1013 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1014 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1016 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1017 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1019 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1020 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1021 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1022 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1024 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1025 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1026 "10#100#1000#10000#40000#auto");
1027 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1028 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1030 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1031 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1034 cmdline_parse_inst_t cmd_config_speed_specific = {
1035 .f = cmd_config_speed_specific_parsed,
1037 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1040 (void *)&cmd_config_speed_specific_port,
1041 (void *)&cmd_config_speed_specific_keyword,
1042 (void *)&cmd_config_speed_specific_id,
1043 (void *)&cmd_config_speed_specific_item1,
1044 (void *)&cmd_config_speed_specific_value1,
1045 (void *)&cmd_config_speed_specific_item2,
1046 (void *)&cmd_config_speed_specific_value2,
1051 /* *** configure txq/rxq, txd/rxd *** */
1052 struct cmd_config_rx_tx {
1053 cmdline_fixed_string_t port;
1054 cmdline_fixed_string_t keyword;
1055 cmdline_fixed_string_t all;
1056 cmdline_fixed_string_t name;
1061 cmd_config_rx_tx_parsed(void *parsed_result,
1062 __attribute__((unused)) struct cmdline *cl,
1063 __attribute__((unused)) void *data)
1065 struct cmd_config_rx_tx *res = parsed_result;
1067 if (!all_ports_stopped()) {
1068 printf("Please stop all ports first\n");
1072 if (!strcmp(res->name, "rxq")) {
1073 if (res->value <= 0) {
1074 printf("rxq %d invalid - must be > 0\n", res->value);
1077 nb_rxq = res->value;
1079 else if (!strcmp(res->name, "txq")) {
1080 if (res->value <= 0) {
1081 printf("txq %d invalid - must be > 0\n", res->value);
1084 nb_txq = res->value;
1086 else if (!strcmp(res->name, "rxd")) {
1087 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1088 printf("rxd %d invalid - must be > 0 && <= %d\n",
1089 res->value, RTE_TEST_RX_DESC_MAX);
1092 nb_rxd = res->value;
1093 } else if (!strcmp(res->name, "txd")) {
1094 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1095 printf("txd %d invalid - must be > 0 && <= %d\n",
1096 res->value, RTE_TEST_TX_DESC_MAX);
1099 nb_txd = res->value;
1101 printf("Unknown parameter\n");
1107 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1110 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1111 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1112 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1113 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1114 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1115 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1116 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1117 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1119 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1120 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1122 cmdline_parse_inst_t cmd_config_rx_tx = {
1123 .f = cmd_config_rx_tx_parsed,
1125 .help_str = "port config all rxq|txq|rxd|txd value",
1127 (void *)&cmd_config_rx_tx_port,
1128 (void *)&cmd_config_rx_tx_keyword,
1129 (void *)&cmd_config_rx_tx_all,
1130 (void *)&cmd_config_rx_tx_name,
1131 (void *)&cmd_config_rx_tx_value,
1136 /* *** config max packet length *** */
1137 struct cmd_config_max_pkt_len_result {
1138 cmdline_fixed_string_t port;
1139 cmdline_fixed_string_t keyword;
1140 cmdline_fixed_string_t all;
1141 cmdline_fixed_string_t name;
1146 cmd_config_max_pkt_len_parsed(void *parsed_result,
1147 __attribute__((unused)) struct cmdline *cl,
1148 __attribute__((unused)) void *data)
1150 struct cmd_config_max_pkt_len_result *res = parsed_result;
1152 if (!all_ports_stopped()) {
1153 printf("Please stop all ports first\n");
1157 if (!strcmp(res->name, "max-pkt-len")) {
1158 if (res->value < ETHER_MIN_LEN) {
1159 printf("max-pkt-len can not be less than %d\n",
1163 if (res->value == rx_mode.max_rx_pkt_len)
1166 rx_mode.max_rx_pkt_len = res->value;
1167 if (res->value > ETHER_MAX_LEN)
1168 rx_mode.jumbo_frame = 1;
1170 rx_mode.jumbo_frame = 0;
1172 printf("Unknown parameter\n");
1178 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1181 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1182 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1184 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1185 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1187 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1188 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1190 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1191 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1193 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1194 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1197 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1198 .f = cmd_config_max_pkt_len_parsed,
1200 .help_str = "port config all max-pkt-len value",
1202 (void *)&cmd_config_max_pkt_len_port,
1203 (void *)&cmd_config_max_pkt_len_keyword,
1204 (void *)&cmd_config_max_pkt_len_all,
1205 (void *)&cmd_config_max_pkt_len_name,
1206 (void *)&cmd_config_max_pkt_len_value,
1211 /* *** configure port MTU *** */
1212 struct cmd_config_mtu_result {
1213 cmdline_fixed_string_t port;
1214 cmdline_fixed_string_t keyword;
1215 cmdline_fixed_string_t mtu;
1221 cmd_config_mtu_parsed(void *parsed_result,
1222 __attribute__((unused)) struct cmdline *cl,
1223 __attribute__((unused)) void *data)
1225 struct cmd_config_mtu_result *res = parsed_result;
1227 if (res->value < ETHER_MIN_LEN) {
1228 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1231 port_mtu_set(res->port_id, res->value);
1234 cmdline_parse_token_string_t cmd_config_mtu_port =
1235 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1237 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1238 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1240 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1241 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1243 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1244 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1245 cmdline_parse_token_num_t cmd_config_mtu_value =
1246 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1248 cmdline_parse_inst_t cmd_config_mtu = {
1249 .f = cmd_config_mtu_parsed,
1251 .help_str = "port config mtu value",
1253 (void *)&cmd_config_mtu_port,
1254 (void *)&cmd_config_mtu_keyword,
1255 (void *)&cmd_config_mtu_mtu,
1256 (void *)&cmd_config_mtu_port_id,
1257 (void *)&cmd_config_mtu_value,
1262 /* *** configure rx mode *** */
1263 struct cmd_config_rx_mode_flag {
1264 cmdline_fixed_string_t port;
1265 cmdline_fixed_string_t keyword;
1266 cmdline_fixed_string_t all;
1267 cmdline_fixed_string_t name;
1268 cmdline_fixed_string_t value;
1272 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1273 __attribute__((unused)) struct cmdline *cl,
1274 __attribute__((unused)) void *data)
1276 struct cmd_config_rx_mode_flag *res = parsed_result;
1278 if (!all_ports_stopped()) {
1279 printf("Please stop all ports first\n");
1283 if (!strcmp(res->name, "crc-strip")) {
1284 if (!strcmp(res->value, "on"))
1285 rx_mode.hw_strip_crc = 1;
1286 else if (!strcmp(res->value, "off"))
1287 rx_mode.hw_strip_crc = 0;
1289 printf("Unknown parameter\n");
1292 } else if (!strcmp(res->name, "rx-cksum")) {
1293 if (!strcmp(res->value, "on"))
1294 rx_mode.hw_ip_checksum = 1;
1295 else if (!strcmp(res->value, "off"))
1296 rx_mode.hw_ip_checksum = 0;
1298 printf("Unknown parameter\n");
1301 } else if (!strcmp(res->name, "hw-vlan")) {
1302 if (!strcmp(res->value, "on")) {
1303 rx_mode.hw_vlan_filter = 1;
1304 rx_mode.hw_vlan_strip = 1;
1306 else if (!strcmp(res->value, "off")) {
1307 rx_mode.hw_vlan_filter = 0;
1308 rx_mode.hw_vlan_strip = 0;
1311 printf("Unknown parameter\n");
1314 } else if (!strcmp(res->name, "drop-en")) {
1315 if (!strcmp(res->value, "on"))
1317 else if (!strcmp(res->value, "off"))
1320 printf("Unknown parameter\n");
1324 printf("Unknown parameter\n");
1330 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1333 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1334 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1335 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1336 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1338 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1339 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1340 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1341 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1342 "crc-strip#rx-cksum#hw-vlan");
1343 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1344 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1347 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1348 .f = cmd_config_rx_mode_flag_parsed,
1350 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1352 (void *)&cmd_config_rx_mode_flag_port,
1353 (void *)&cmd_config_rx_mode_flag_keyword,
1354 (void *)&cmd_config_rx_mode_flag_all,
1355 (void *)&cmd_config_rx_mode_flag_name,
1356 (void *)&cmd_config_rx_mode_flag_value,
1361 /* *** configure rss *** */
1362 struct cmd_config_rss {
1363 cmdline_fixed_string_t port;
1364 cmdline_fixed_string_t keyword;
1365 cmdline_fixed_string_t all;
1366 cmdline_fixed_string_t name;
1367 cmdline_fixed_string_t value;
1371 cmd_config_rss_parsed(void *parsed_result,
1372 __attribute__((unused)) struct cmdline *cl,
1373 __attribute__((unused)) void *data)
1375 struct cmd_config_rss *res = parsed_result;
1376 struct rte_eth_rss_conf rss_conf;
1379 if (!strcmp(res->value, "ip"))
1380 rss_conf.rss_hf = ETH_RSS_IP;
1381 else if (!strcmp(res->value, "udp"))
1382 rss_conf.rss_hf = ETH_RSS_UDP;
1383 else if (!strcmp(res->value, "none"))
1384 rss_conf.rss_hf = 0;
1386 printf("Unknown parameter\n");
1389 rss_conf.rss_key = NULL;
1390 for (i = 0; i < rte_eth_dev_count(); i++)
1391 rte_eth_dev_rss_hash_update(i, &rss_conf);
1394 cmdline_parse_token_string_t cmd_config_rss_port =
1395 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1396 cmdline_parse_token_string_t cmd_config_rss_keyword =
1397 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1398 cmdline_parse_token_string_t cmd_config_rss_all =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1400 cmdline_parse_token_string_t cmd_config_rss_name =
1401 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1402 cmdline_parse_token_string_t cmd_config_rss_value =
1403 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1405 cmdline_parse_inst_t cmd_config_rss = {
1406 .f = cmd_config_rss_parsed,
1408 .help_str = "port config all rss ip|udp|none",
1410 (void *)&cmd_config_rss_port,
1411 (void *)&cmd_config_rss_keyword,
1412 (void *)&cmd_config_rss_all,
1413 (void *)&cmd_config_rss_name,
1414 (void *)&cmd_config_rss_value,
1419 /* *** configure rss hash key *** */
1420 struct cmd_config_rss_hash_key {
1421 cmdline_fixed_string_t port;
1422 cmdline_fixed_string_t config;
1424 cmdline_fixed_string_t rss_hash_key;
1425 cmdline_fixed_string_t key;
1428 #define RSS_HASH_KEY_LENGTH 40
1430 hexa_digit_to_value(char hexa_digit)
1432 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1433 return (uint8_t) (hexa_digit - '0');
1434 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1435 return (uint8_t) ((hexa_digit - 'a') + 10);
1436 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1437 return (uint8_t) ((hexa_digit - 'A') + 10);
1438 /* Invalid hexa digit */
1443 parse_and_check_key_hexa_digit(char *key, int idx)
1447 hexa_v = hexa_digit_to_value(key[idx]);
1449 printf("invalid key: character %c at position %d is not a "
1450 "valid hexa digit\n", key[idx], idx);
1455 cmd_config_rss_hash_key_parsed(void *parsed_result,
1456 __attribute__((unused)) struct cmdline *cl,
1457 __attribute__((unused)) void *data)
1459 struct cmd_config_rss_hash_key *res = parsed_result;
1460 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1465 /* Check the length of the RSS hash key */
1466 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1467 printf("key length: %d invalid - key must be a string of %d"
1468 "hexa-decimal numbers\n", (int) strlen(res->key),
1469 RSS_HASH_KEY_LENGTH * 2);
1472 /* Translate RSS hash key into binary representation */
1473 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1474 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1477 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1480 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1482 port_rss_hash_key_update(res->port_id, hash_key);
1485 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1486 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1487 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1488 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1490 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1491 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1492 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1494 rss_hash_key, "rss-hash-key");
1495 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1496 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1498 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1499 .f = cmd_config_rss_hash_key_parsed,
1501 .help_str = "port config X rss-hash-key 80 hexa digits",
1503 (void *)&cmd_config_rss_hash_key_port,
1504 (void *)&cmd_config_rss_hash_key_config,
1505 (void *)&cmd_config_rss_hash_key_port_id,
1506 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1507 (void *)&cmd_config_rss_hash_key_value,
1512 /* *** configure port rxq/txq start/stop *** */
1513 struct cmd_config_rxtx_queue {
1514 cmdline_fixed_string_t port;
1516 cmdline_fixed_string_t rxtxq;
1518 cmdline_fixed_string_t opname;
1522 cmd_config_rxtx_queue_parsed(void *parsed_result,
1523 __attribute__((unused)) struct cmdline *cl,
1524 __attribute__((unused)) void *data)
1526 struct cmd_config_rxtx_queue *res = parsed_result;
1531 if (test_done == 0) {
1532 printf("Please stop forwarding first\n");
1536 if (port_id_is_invalid(res->portid))
1539 if (port_is_started(res->portid) != 1) {
1540 printf("Please start port %u first\n", res->portid);
1544 if (!strcmp(res->rxtxq, "rxq"))
1546 else if (!strcmp(res->rxtxq, "txq"))
1549 printf("Unknown parameter\n");
1553 if (isrx && rx_queue_id_is_invalid(res->qid))
1555 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1558 if (!strcmp(res->opname, "start"))
1560 else if (!strcmp(res->opname, "stop"))
1563 printf("Unknown parameter\n");
1567 if (isstart && isrx)
1568 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1569 else if (!isstart && isrx)
1570 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1571 else if (isstart && !isrx)
1572 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1574 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1576 if (ret == -ENOTSUP)
1577 printf("Function not supported in PMD driver\n");
1580 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1581 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1582 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1583 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1584 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1585 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1586 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1587 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1588 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1589 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1592 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1593 .f = cmd_config_rxtx_queue_parsed,
1595 .help_str = "port X rxq|txq ID start|stop",
1597 (void *)&cmd_config_speed_all_port,
1598 (void *)&cmd_config_rxtx_queue_portid,
1599 (void *)&cmd_config_rxtx_queue_rxtxq,
1600 (void *)&cmd_config_rxtx_queue_qid,
1601 (void *)&cmd_config_rxtx_queue_opname,
1606 /* *** Configure RSS RETA *** */
1607 struct cmd_config_rss_reta {
1608 cmdline_fixed_string_t port;
1609 cmdline_fixed_string_t keyword;
1611 cmdline_fixed_string_t name;
1612 cmdline_fixed_string_t list_name;
1613 cmdline_fixed_string_t list_of_items;
1617 parse_reta_config(const char *str,
1618 struct rte_eth_rss_reta_entry64 *reta_conf,
1619 uint16_t nb_entries)
1623 uint16_t hash_index, idx, shift;
1626 const char *p, *p0 = str;
1633 unsigned long int_fld[_NUM_FLD];
1634 char *str_fld[_NUM_FLD];
1636 while ((p = strchr(p0,'(')) != NULL) {
1638 if((p0 = strchr(p,')')) == NULL)
1642 if(size >= sizeof(s))
1645 snprintf(s, sizeof(s), "%.*s", size, p);
1646 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1648 for (i = 0; i < _NUM_FLD; i++) {
1650 int_fld[i] = strtoul(str_fld[i], &end, 0);
1651 if (errno != 0 || end == str_fld[i] ||
1656 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1657 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1659 if (hash_index >= nb_entries) {
1660 printf("Invalid RETA hash index=%d\n", hash_index);
1664 idx = hash_index / RTE_RETA_GROUP_SIZE;
1665 shift = hash_index % RTE_RETA_GROUP_SIZE;
1666 reta_conf[idx].mask |= (1ULL << shift);
1667 reta_conf[idx].reta[shift] = nb_queue;
1674 cmd_set_rss_reta_parsed(void *parsed_result,
1675 __attribute__((unused)) struct cmdline *cl,
1676 __attribute__((unused)) void *data)
1679 struct rte_eth_dev_info dev_info;
1680 struct rte_eth_rss_reta_entry64 reta_conf[8];
1681 struct cmd_config_rss_reta *res = parsed_result;
1683 memset(&dev_info, 0, sizeof(dev_info));
1684 rte_eth_dev_info_get(res->port_id, &dev_info);
1685 if (dev_info.reta_size == 0) {
1686 printf("Redirection table size is 0 which is "
1687 "invalid for RSS\n");
1690 printf("The reta size of port %d is %u\n",
1691 res->port_id, dev_info.reta_size);
1692 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1693 printf("Currently do not support more than %u entries of "
1694 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1698 memset(reta_conf, 0, sizeof(reta_conf));
1699 if (!strcmp(res->list_name, "reta")) {
1700 if (parse_reta_config(res->list_of_items, reta_conf,
1701 dev_info.reta_size)) {
1702 printf("Invalid RSS Redirection Table "
1703 "config entered\n");
1706 ret = rte_eth_dev_rss_reta_update(res->port_id,
1707 reta_conf, dev_info.reta_size);
1709 printf("Bad redirection table parameter, "
1710 "return code = %d \n", ret);
1714 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1716 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1718 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1719 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1720 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1721 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1722 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1723 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1724 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1725 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1727 cmdline_parse_inst_t cmd_config_rss_reta = {
1728 .f = cmd_set_rss_reta_parsed,
1730 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1732 (void *)&cmd_config_rss_reta_port,
1733 (void *)&cmd_config_rss_reta_keyword,
1734 (void *)&cmd_config_rss_reta_port_id,
1735 (void *)&cmd_config_rss_reta_name,
1736 (void *)&cmd_config_rss_reta_list_name,
1737 (void *)&cmd_config_rss_reta_list_of_items,
1742 /* *** SHOW PORT RETA INFO *** */
1743 struct cmd_showport_reta {
1744 cmdline_fixed_string_t show;
1745 cmdline_fixed_string_t port;
1747 cmdline_fixed_string_t rss;
1748 cmdline_fixed_string_t reta;
1750 cmdline_fixed_string_t list_of_items;
1754 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1755 uint16_t nb_entries,
1759 const char *p, *p0 = str;
1763 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1766 p = strchr(p0, '(');
1770 p0 = strchr(p, ')');
1774 if (size >= sizeof(s)) {
1775 printf("The string size exceeds the internal buffer size\n");
1778 snprintf(s, sizeof(s), "%.*s", size, p);
1779 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1780 if (ret <= 0 || ret != num) {
1781 printf("The bits of masks do not match the number of "
1782 "reta entries: %u\n", num);
1785 for (i = 0; i < ret; i++)
1786 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1792 cmd_showport_reta_parsed(void *parsed_result,
1793 __attribute__((unused)) struct cmdline *cl,
1794 __attribute__((unused)) void *data)
1796 struct cmd_showport_reta *res = parsed_result;
1797 struct rte_eth_rss_reta_entry64 reta_conf[8];
1798 struct rte_eth_dev_info dev_info;
1800 memset(&dev_info, 0, sizeof(dev_info));
1801 rte_eth_dev_info_get(res->port_id, &dev_info);
1802 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1803 res->size > ETH_RSS_RETA_SIZE_512) {
1804 printf("Invalid redirection table size: %u\n", res->size);
1808 memset(reta_conf, 0, sizeof(reta_conf));
1809 if (showport_parse_reta_config(reta_conf, res->size,
1810 res->list_of_items) < 0) {
1811 printf("Invalid string: %s for reta masks\n",
1812 res->list_of_items);
1815 port_rss_reta_info(res->port_id, reta_conf, res->size);
1818 cmdline_parse_token_string_t cmd_showport_reta_show =
1819 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1820 cmdline_parse_token_string_t cmd_showport_reta_port =
1821 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1822 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1823 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1824 cmdline_parse_token_string_t cmd_showport_reta_rss =
1825 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1826 cmdline_parse_token_string_t cmd_showport_reta_reta =
1827 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1828 cmdline_parse_token_num_t cmd_showport_reta_size =
1829 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1830 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1831 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1832 list_of_items, NULL);
1834 cmdline_parse_inst_t cmd_showport_reta = {
1835 .f = cmd_showport_reta_parsed,
1837 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1839 (void *)&cmd_showport_reta_show,
1840 (void *)&cmd_showport_reta_port,
1841 (void *)&cmd_showport_reta_port_id,
1842 (void *)&cmd_showport_reta_rss,
1843 (void *)&cmd_showport_reta_reta,
1844 (void *)&cmd_showport_reta_size,
1845 (void *)&cmd_showport_reta_list_of_items,
1850 /* *** Show RSS hash configuration *** */
1851 struct cmd_showport_rss_hash {
1852 cmdline_fixed_string_t show;
1853 cmdline_fixed_string_t port;
1855 cmdline_fixed_string_t rss_hash;
1856 cmdline_fixed_string_t key; /* optional argument */
1859 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1860 __attribute__((unused)) struct cmdline *cl,
1863 struct cmd_showport_rss_hash *res = parsed_result;
1865 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1868 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1869 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1870 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1871 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1872 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1873 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1874 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1875 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1877 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1878 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1880 cmdline_parse_inst_t cmd_showport_rss_hash = {
1881 .f = cmd_showport_rss_hash_parsed,
1883 .help_str = "show port X rss-hash (X = port number)\n",
1885 (void *)&cmd_showport_rss_hash_show,
1886 (void *)&cmd_showport_rss_hash_port,
1887 (void *)&cmd_showport_rss_hash_port_id,
1888 (void *)&cmd_showport_rss_hash_rss_hash,
1893 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1894 .f = cmd_showport_rss_hash_parsed,
1896 .help_str = "show port X rss-hash key (X = port number)\n",
1898 (void *)&cmd_showport_rss_hash_show,
1899 (void *)&cmd_showport_rss_hash_port,
1900 (void *)&cmd_showport_rss_hash_port_id,
1901 (void *)&cmd_showport_rss_hash_rss_hash,
1902 (void *)&cmd_showport_rss_hash_rss_key,
1907 /* *** Configure DCB *** */
1908 struct cmd_config_dcb {
1909 cmdline_fixed_string_t port;
1910 cmdline_fixed_string_t config;
1912 cmdline_fixed_string_t dcb;
1913 cmdline_fixed_string_t vt;
1914 cmdline_fixed_string_t vt_en;
1916 cmdline_fixed_string_t pfc;
1917 cmdline_fixed_string_t pfc_en;
1921 cmd_config_dcb_parsed(void *parsed_result,
1922 __attribute__((unused)) struct cmdline *cl,
1923 __attribute__((unused)) void *data)
1925 struct cmd_config_dcb *res = parsed_result;
1926 struct dcb_config dcb_conf;
1927 portid_t port_id = res->port_id;
1928 struct rte_port *port;
1930 port = &ports[port_id];
1931 /** Check if the port is not started **/
1932 if (port->port_status != RTE_PORT_STOPPED) {
1933 printf("Please stop port %d first\n",port_id);
1937 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1938 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1939 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1943 /* DCB in VT mode */
1944 if (!strncmp(res->vt_en, "on",2))
1945 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1947 dcb_conf.dcb_mode = DCB_ENABLED;
1949 if (!strncmp(res->pfc_en, "on",2)) {
1950 dcb_conf.pfc_en = 1;
1953 dcb_conf.pfc_en = 0;
1955 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1956 printf("Cannot initialize network ports\n");
1960 cmd_reconfig_device_queue(port_id, 1, 1);
1963 cmdline_parse_token_string_t cmd_config_dcb_port =
1964 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1965 cmdline_parse_token_string_t cmd_config_dcb_config =
1966 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1967 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1968 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1969 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1970 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1971 cmdline_parse_token_string_t cmd_config_dcb_vt =
1972 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1973 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1974 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1975 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1976 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1977 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1978 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1979 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1980 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1982 cmdline_parse_inst_t cmd_config_dcb = {
1983 .f = cmd_config_dcb_parsed,
1985 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1987 (void *)&cmd_config_dcb_port,
1988 (void *)&cmd_config_dcb_config,
1989 (void *)&cmd_config_dcb_port_id,
1990 (void *)&cmd_config_dcb_dcb,
1991 (void *)&cmd_config_dcb_vt,
1992 (void *)&cmd_config_dcb_vt_en,
1993 (void *)&cmd_config_dcb_num_tcs,
1994 (void *)&cmd_config_dcb_pfc,
1995 (void *)&cmd_config_dcb_pfc_en,
2000 /* *** configure number of packets per burst *** */
2001 struct cmd_config_burst {
2002 cmdline_fixed_string_t port;
2003 cmdline_fixed_string_t keyword;
2004 cmdline_fixed_string_t all;
2005 cmdline_fixed_string_t name;
2010 cmd_config_burst_parsed(void *parsed_result,
2011 __attribute__((unused)) struct cmdline *cl,
2012 __attribute__((unused)) void *data)
2014 struct cmd_config_burst *res = parsed_result;
2016 if (!all_ports_stopped()) {
2017 printf("Please stop all ports first\n");
2021 if (!strcmp(res->name, "burst")) {
2022 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2023 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2026 nb_pkt_per_burst = res->value;
2028 printf("Unknown parameter\n");
2034 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2037 cmdline_parse_token_string_t cmd_config_burst_port =
2038 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2039 cmdline_parse_token_string_t cmd_config_burst_keyword =
2040 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2041 cmdline_parse_token_string_t cmd_config_burst_all =
2042 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2043 cmdline_parse_token_string_t cmd_config_burst_name =
2044 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2045 cmdline_parse_token_num_t cmd_config_burst_value =
2046 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2048 cmdline_parse_inst_t cmd_config_burst = {
2049 .f = cmd_config_burst_parsed,
2051 .help_str = "port config all burst value",
2053 (void *)&cmd_config_burst_port,
2054 (void *)&cmd_config_burst_keyword,
2055 (void *)&cmd_config_burst_all,
2056 (void *)&cmd_config_burst_name,
2057 (void *)&cmd_config_burst_value,
2062 /* *** configure rx/tx queues *** */
2063 struct cmd_config_thresh {
2064 cmdline_fixed_string_t port;
2065 cmdline_fixed_string_t keyword;
2066 cmdline_fixed_string_t all;
2067 cmdline_fixed_string_t name;
2072 cmd_config_thresh_parsed(void *parsed_result,
2073 __attribute__((unused)) struct cmdline *cl,
2074 __attribute__((unused)) void *data)
2076 struct cmd_config_thresh *res = parsed_result;
2078 if (!all_ports_stopped()) {
2079 printf("Please stop all ports first\n");
2083 if (!strcmp(res->name, "txpt"))
2084 tx_thresh.pthresh = res->value;
2085 else if(!strcmp(res->name, "txht"))
2086 tx_thresh.hthresh = res->value;
2087 else if(!strcmp(res->name, "txwt"))
2088 tx_thresh.wthresh = res->value;
2089 else if(!strcmp(res->name, "rxpt"))
2090 rx_thresh.pthresh = res->value;
2091 else if(!strcmp(res->name, "rxht"))
2092 rx_thresh.hthresh = res->value;
2093 else if(!strcmp(res->name, "rxwt"))
2094 rx_thresh.wthresh = res->value;
2096 printf("Unknown parameter\n");
2102 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2105 cmdline_parse_token_string_t cmd_config_thresh_port =
2106 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2107 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2108 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2109 cmdline_parse_token_string_t cmd_config_thresh_all =
2110 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2111 cmdline_parse_token_string_t cmd_config_thresh_name =
2112 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2113 "txpt#txht#txwt#rxpt#rxht#rxwt");
2114 cmdline_parse_token_num_t cmd_config_thresh_value =
2115 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2117 cmdline_parse_inst_t cmd_config_thresh = {
2118 .f = cmd_config_thresh_parsed,
2120 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2122 (void *)&cmd_config_thresh_port,
2123 (void *)&cmd_config_thresh_keyword,
2124 (void *)&cmd_config_thresh_all,
2125 (void *)&cmd_config_thresh_name,
2126 (void *)&cmd_config_thresh_value,
2131 /* *** configure free/rs threshold *** */
2132 struct cmd_config_threshold {
2133 cmdline_fixed_string_t port;
2134 cmdline_fixed_string_t keyword;
2135 cmdline_fixed_string_t all;
2136 cmdline_fixed_string_t name;
2141 cmd_config_threshold_parsed(void *parsed_result,
2142 __attribute__((unused)) struct cmdline *cl,
2143 __attribute__((unused)) void *data)
2145 struct cmd_config_threshold *res = parsed_result;
2147 if (!all_ports_stopped()) {
2148 printf("Please stop all ports first\n");
2152 if (!strcmp(res->name, "txfreet"))
2153 tx_free_thresh = res->value;
2154 else if (!strcmp(res->name, "txrst"))
2155 tx_rs_thresh = res->value;
2156 else if (!strcmp(res->name, "rxfreet"))
2157 rx_free_thresh = res->value;
2159 printf("Unknown parameter\n");
2165 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2168 cmdline_parse_token_string_t cmd_config_threshold_port =
2169 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2170 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2171 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2173 cmdline_parse_token_string_t cmd_config_threshold_all =
2174 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2175 cmdline_parse_token_string_t cmd_config_threshold_name =
2176 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2177 "txfreet#txrst#rxfreet");
2178 cmdline_parse_token_num_t cmd_config_threshold_value =
2179 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2181 cmdline_parse_inst_t cmd_config_threshold = {
2182 .f = cmd_config_threshold_parsed,
2184 .help_str = "port config all txfreet|txrst|rxfreet value",
2186 (void *)&cmd_config_threshold_port,
2187 (void *)&cmd_config_threshold_keyword,
2188 (void *)&cmd_config_threshold_all,
2189 (void *)&cmd_config_threshold_name,
2190 (void *)&cmd_config_threshold_value,
2196 struct cmd_stop_result {
2197 cmdline_fixed_string_t stop;
2200 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2201 __attribute__((unused)) struct cmdline *cl,
2202 __attribute__((unused)) void *data)
2204 stop_packet_forwarding();
2207 cmdline_parse_token_string_t cmd_stop_stop =
2208 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2210 cmdline_parse_inst_t cmd_stop = {
2211 .f = cmd_stop_parsed,
2213 .help_str = "stop - stop packet forwarding",
2215 (void *)&cmd_stop_stop,
2220 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2223 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2224 unsigned int *parsed_items, int check_unique_values)
2226 unsigned int nb_item;
2234 * First parse all items in the list and store their value.
2239 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2241 if ((c >= '0') && (c <= '9')) {
2242 value = (unsigned int) (value * 10 + (c - '0'));
2247 printf("character %c is not a decimal digit\n", c);
2251 printf("No valid value before comma\n");
2254 if (nb_item < max_items) {
2255 parsed_items[nb_item] = value;
2261 if (nb_item >= max_items) {
2262 printf("Number of %s = %u > %u (maximum items)\n",
2263 item_name, nb_item + 1, max_items);
2266 parsed_items[nb_item++] = value;
2267 if (! check_unique_values)
2271 * Then, check that all values in the list are differents.
2272 * No optimization here...
2274 for (i = 0; i < nb_item; i++) {
2275 for (j = i + 1; j < nb_item; j++) {
2276 if (parsed_items[j] == parsed_items[i]) {
2277 printf("duplicated %s %u at index %u and %u\n",
2278 item_name, parsed_items[i], i, j);
2286 struct cmd_set_list_result {
2287 cmdline_fixed_string_t cmd_keyword;
2288 cmdline_fixed_string_t list_name;
2289 cmdline_fixed_string_t list_of_items;
2292 static void cmd_set_list_parsed(void *parsed_result,
2293 __attribute__((unused)) struct cmdline *cl,
2294 __attribute__((unused)) void *data)
2296 struct cmd_set_list_result *res;
2298 unsigned int lcorelist[RTE_MAX_LCORE];
2299 unsigned int portlist[RTE_MAX_ETHPORTS];
2301 unsigned int nb_item;
2303 res = parsed_result;
2304 if (!strcmp(res->list_name, "corelist")) {
2305 nb_item = parse_item_list(res->list_of_items, "core",
2307 parsed_items.lcorelist, 1);
2309 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2312 if (!strcmp(res->list_name, "portlist")) {
2313 nb_item = parse_item_list(res->list_of_items, "port",
2315 parsed_items.portlist, 1);
2317 set_fwd_ports_list(parsed_items.portlist, nb_item);
2321 cmdline_parse_token_string_t cmd_set_list_keyword =
2322 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2324 cmdline_parse_token_string_t cmd_set_list_name =
2325 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2326 "corelist#portlist");
2327 cmdline_parse_token_string_t cmd_set_list_of_items =
2328 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2331 cmdline_parse_inst_t cmd_set_fwd_list = {
2332 .f = cmd_set_list_parsed,
2334 .help_str = "set corelist|portlist x[,y]*",
2336 (void *)&cmd_set_list_keyword,
2337 (void *)&cmd_set_list_name,
2338 (void *)&cmd_set_list_of_items,
2343 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2345 struct cmd_setmask_result {
2346 cmdline_fixed_string_t set;
2347 cmdline_fixed_string_t mask;
2351 static void cmd_set_mask_parsed(void *parsed_result,
2352 __attribute__((unused)) struct cmdline *cl,
2353 __attribute__((unused)) void *data)
2355 struct cmd_setmask_result *res = parsed_result;
2357 if (!strcmp(res->mask, "coremask"))
2358 set_fwd_lcores_mask(res->hexavalue);
2359 else if (!strcmp(res->mask, "portmask"))
2360 set_fwd_ports_mask(res->hexavalue);
2363 cmdline_parse_token_string_t cmd_setmask_set =
2364 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2365 cmdline_parse_token_string_t cmd_setmask_mask =
2366 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2367 "coremask#portmask");
2368 cmdline_parse_token_num_t cmd_setmask_value =
2369 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2371 cmdline_parse_inst_t cmd_set_fwd_mask = {
2372 .f = cmd_set_mask_parsed,
2374 .help_str = "set coremask|portmask hexadecimal value",
2376 (void *)&cmd_setmask_set,
2377 (void *)&cmd_setmask_mask,
2378 (void *)&cmd_setmask_value,
2384 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2386 struct cmd_set_result {
2387 cmdline_fixed_string_t set;
2388 cmdline_fixed_string_t what;
2392 static void cmd_set_parsed(void *parsed_result,
2393 __attribute__((unused)) struct cmdline *cl,
2394 __attribute__((unused)) void *data)
2396 struct cmd_set_result *res = parsed_result;
2397 if (!strcmp(res->what, "nbport"))
2398 set_fwd_ports_number(res->value);
2399 else if (!strcmp(res->what, "nbcore"))
2400 set_fwd_lcores_number(res->value);
2401 else if (!strcmp(res->what, "burst"))
2402 set_nb_pkt_per_burst(res->value);
2403 else if (!strcmp(res->what, "verbose"))
2404 set_verbose_level(res->value);
2407 cmdline_parse_token_string_t cmd_set_set =
2408 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2409 cmdline_parse_token_string_t cmd_set_what =
2410 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2411 "nbport#nbcore#burst#verbose");
2412 cmdline_parse_token_num_t cmd_set_value =
2413 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2415 cmdline_parse_inst_t cmd_set_numbers = {
2416 .f = cmd_set_parsed,
2418 .help_str = "set nbport|nbcore|burst|verbose value",
2420 (void *)&cmd_set_set,
2421 (void *)&cmd_set_what,
2422 (void *)&cmd_set_value,
2427 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2429 struct cmd_set_txpkts_result {
2430 cmdline_fixed_string_t cmd_keyword;
2431 cmdline_fixed_string_t txpkts;
2432 cmdline_fixed_string_t seg_lengths;
2436 cmd_set_txpkts_parsed(void *parsed_result,
2437 __attribute__((unused)) struct cmdline *cl,
2438 __attribute__((unused)) void *data)
2440 struct cmd_set_txpkts_result *res;
2441 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2442 unsigned int nb_segs;
2444 res = parsed_result;
2445 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2446 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2448 set_tx_pkt_segments(seg_lengths, nb_segs);
2451 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2452 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2453 cmd_keyword, "set");
2454 cmdline_parse_token_string_t cmd_set_txpkts_name =
2455 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2457 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2458 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2461 cmdline_parse_inst_t cmd_set_txpkts = {
2462 .f = cmd_set_txpkts_parsed,
2464 .help_str = "set txpkts x[,y]*",
2466 (void *)&cmd_set_txpkts_keyword,
2467 (void *)&cmd_set_txpkts_name,
2468 (void *)&cmd_set_txpkts_lengths,
2473 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2474 struct cmd_rx_vlan_filter_all_result {
2475 cmdline_fixed_string_t rx_vlan;
2476 cmdline_fixed_string_t what;
2477 cmdline_fixed_string_t all;
2482 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2483 __attribute__((unused)) struct cmdline *cl,
2484 __attribute__((unused)) void *data)
2486 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2488 if (!strcmp(res->what, "add"))
2489 rx_vlan_all_filter_set(res->port_id, 1);
2491 rx_vlan_all_filter_set(res->port_id, 0);
2494 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2495 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2496 rx_vlan, "rx_vlan");
2497 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2498 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2500 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2501 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2503 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2504 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2507 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2508 .f = cmd_rx_vlan_filter_all_parsed,
2510 .help_str = "add/remove all identifiers to/from the set of VLAN "
2511 "Identifiers filtered by a port",
2513 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2514 (void *)&cmd_rx_vlan_filter_all_what,
2515 (void *)&cmd_rx_vlan_filter_all_all,
2516 (void *)&cmd_rx_vlan_filter_all_portid,
2521 /* *** VLAN OFFLOAD SET ON A PORT *** */
2522 struct cmd_vlan_offload_result {
2523 cmdline_fixed_string_t vlan;
2524 cmdline_fixed_string_t set;
2525 cmdline_fixed_string_t what;
2526 cmdline_fixed_string_t on;
2527 cmdline_fixed_string_t port_id;
2531 cmd_vlan_offload_parsed(void *parsed_result,
2532 __attribute__((unused)) struct cmdline *cl,
2533 __attribute__((unused)) void *data)
2536 struct cmd_vlan_offload_result *res = parsed_result;
2539 portid_t port_id = 0;
2543 len = strnlen(str, STR_TOKEN_SIZE);
2545 /* Get port_id first */
2553 tmp = strtoul(str, NULL, 0);
2554 /* If port_id greater that what portid_t can represent, return */
2555 if(tmp >= RTE_MAX_ETHPORTS)
2557 port_id = (portid_t)tmp;
2559 if (!strcmp(res->on, "on"))
2564 if (!strcmp(res->what, "strip"))
2565 rx_vlan_strip_set(port_id, on);
2566 else if(!strcmp(res->what, "stripq")){
2567 uint16_t queue_id = 0;
2569 /* No queue_id, return */
2571 printf("must specify (port,queue_id)\n");
2574 tmp = strtoul(str + i + 1, NULL, 0);
2575 /* If queue_id greater that what 16-bits can represent, return */
2579 queue_id = (uint16_t)tmp;
2580 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2582 else if (!strcmp(res->what, "filter"))
2583 rx_vlan_filter_set(port_id, on);
2585 vlan_extend_set(port_id, on);
2590 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2591 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2593 cmdline_parse_token_string_t cmd_vlan_offload_set =
2594 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2596 cmdline_parse_token_string_t cmd_vlan_offload_what =
2597 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2598 what, "strip#filter#qinq#stripq");
2599 cmdline_parse_token_string_t cmd_vlan_offload_on =
2600 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2602 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2603 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2606 cmdline_parse_inst_t cmd_vlan_offload = {
2607 .f = cmd_vlan_offload_parsed,
2609 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2610 " qinq(extended) for both rx/tx sides ",
2612 (void *)&cmd_vlan_offload_vlan,
2613 (void *)&cmd_vlan_offload_set,
2614 (void *)&cmd_vlan_offload_what,
2615 (void *)&cmd_vlan_offload_on,
2616 (void *)&cmd_vlan_offload_portid,
2621 /* *** VLAN TPID SET ON A PORT *** */
2622 struct cmd_vlan_tpid_result {
2623 cmdline_fixed_string_t vlan;
2624 cmdline_fixed_string_t set;
2625 cmdline_fixed_string_t what;
2631 cmd_vlan_tpid_parsed(void *parsed_result,
2632 __attribute__((unused)) struct cmdline *cl,
2633 __attribute__((unused)) void *data)
2635 struct cmd_vlan_tpid_result *res = parsed_result;
2636 vlan_tpid_set(res->port_id, res->tp_id);
2640 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2641 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2643 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2644 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2646 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2647 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2649 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2650 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2652 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2653 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2656 cmdline_parse_inst_t cmd_vlan_tpid = {
2657 .f = cmd_vlan_tpid_parsed,
2659 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2661 (void *)&cmd_vlan_tpid_vlan,
2662 (void *)&cmd_vlan_tpid_set,
2663 (void *)&cmd_vlan_tpid_what,
2664 (void *)&cmd_vlan_tpid_tpid,
2665 (void *)&cmd_vlan_tpid_portid,
2670 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2671 struct cmd_rx_vlan_filter_result {
2672 cmdline_fixed_string_t rx_vlan;
2673 cmdline_fixed_string_t what;
2679 cmd_rx_vlan_filter_parsed(void *parsed_result,
2680 __attribute__((unused)) struct cmdline *cl,
2681 __attribute__((unused)) void *data)
2683 struct cmd_rx_vlan_filter_result *res = parsed_result;
2685 if (!strcmp(res->what, "add"))
2686 rx_vft_set(res->port_id, res->vlan_id, 1);
2688 rx_vft_set(res->port_id, res->vlan_id, 0);
2691 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2692 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2693 rx_vlan, "rx_vlan");
2694 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2695 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2697 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2698 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2700 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2701 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2704 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2705 .f = cmd_rx_vlan_filter_parsed,
2707 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2708 "Identifiers filtered by a port",
2710 (void *)&cmd_rx_vlan_filter_rx_vlan,
2711 (void *)&cmd_rx_vlan_filter_what,
2712 (void *)&cmd_rx_vlan_filter_vlanid,
2713 (void *)&cmd_rx_vlan_filter_portid,
2718 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2719 struct cmd_tx_vlan_set_result {
2720 cmdline_fixed_string_t tx_vlan;
2721 cmdline_fixed_string_t set;
2727 cmd_tx_vlan_set_parsed(void *parsed_result,
2728 __attribute__((unused)) struct cmdline *cl,
2729 __attribute__((unused)) void *data)
2731 struct cmd_tx_vlan_set_result *res = parsed_result;
2732 tx_vlan_set(res->port_id, res->vlan_id);
2735 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2736 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2737 tx_vlan, "tx_vlan");
2738 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2739 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2741 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2742 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2744 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2745 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2748 cmdline_parse_inst_t cmd_tx_vlan_set = {
2749 .f = cmd_tx_vlan_set_parsed,
2751 .help_str = "enable hardware insertion of a VLAN header with a given "
2752 "TAG Identifier in packets sent on a port",
2754 (void *)&cmd_tx_vlan_set_tx_vlan,
2755 (void *)&cmd_tx_vlan_set_set,
2756 (void *)&cmd_tx_vlan_set_vlanid,
2757 (void *)&cmd_tx_vlan_set_portid,
2762 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2763 struct cmd_tx_vlan_set_pvid_result {
2764 cmdline_fixed_string_t tx_vlan;
2765 cmdline_fixed_string_t set;
2766 cmdline_fixed_string_t pvid;
2769 cmdline_fixed_string_t mode;
2773 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2774 __attribute__((unused)) struct cmdline *cl,
2775 __attribute__((unused)) void *data)
2777 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2779 if (strcmp(res->mode, "on") == 0)
2780 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2782 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2785 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2786 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2787 tx_vlan, "tx_vlan");
2788 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2789 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2791 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2792 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2794 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2795 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2797 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2798 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2800 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2801 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2804 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2805 .f = cmd_tx_vlan_set_pvid_parsed,
2807 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2809 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2810 (void *)&cmd_tx_vlan_set_pvid_set,
2811 (void *)&cmd_tx_vlan_set_pvid_pvid,
2812 (void *)&cmd_tx_vlan_set_pvid_port_id,
2813 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2814 (void *)&cmd_tx_vlan_set_pvid_mode,
2819 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2820 struct cmd_tx_vlan_reset_result {
2821 cmdline_fixed_string_t tx_vlan;
2822 cmdline_fixed_string_t reset;
2827 cmd_tx_vlan_reset_parsed(void *parsed_result,
2828 __attribute__((unused)) struct cmdline *cl,
2829 __attribute__((unused)) void *data)
2831 struct cmd_tx_vlan_reset_result *res = parsed_result;
2833 tx_vlan_reset(res->port_id);
2836 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2837 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2838 tx_vlan, "tx_vlan");
2839 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2840 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2842 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2843 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2846 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2847 .f = cmd_tx_vlan_reset_parsed,
2849 .help_str = "disable hardware insertion of a VLAN header in packets "
2852 (void *)&cmd_tx_vlan_reset_tx_vlan,
2853 (void *)&cmd_tx_vlan_reset_reset,
2854 (void *)&cmd_tx_vlan_reset_portid,
2860 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2861 struct cmd_tx_cksum_result {
2862 cmdline_fixed_string_t tx_cksum;
2863 cmdline_fixed_string_t mode;
2864 cmdline_fixed_string_t proto;
2865 cmdline_fixed_string_t hwsw;
2870 cmd_tx_cksum_parsed(void *parsed_result,
2871 __attribute__((unused)) struct cmdline *cl,
2872 __attribute__((unused)) void *data)
2874 struct cmd_tx_cksum_result *res = parsed_result;
2876 uint16_t ol_flags, mask = 0;
2877 struct rte_eth_dev_info dev_info;
2879 if (port_id_is_invalid(res->port_id)) {
2880 printf("invalid port %d\n", res->port_id);
2884 if (!strcmp(res->mode, "set")) {
2886 if (!strcmp(res->hwsw, "hw"))
2889 if (!strcmp(res->proto, "ip")) {
2890 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2891 } else if (!strcmp(res->proto, "udp")) {
2892 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2893 } else if (!strcmp(res->proto, "tcp")) {
2894 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2895 } else if (!strcmp(res->proto, "sctp")) {
2896 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2897 } else if (!strcmp(res->proto, "vxlan")) {
2898 mask = TESTPMD_TX_OFFLOAD_VXLAN_CKSUM;
2902 ports[res->port_id].tx_ol_flags |= mask;
2904 ports[res->port_id].tx_ol_flags &= (~mask);
2907 ol_flags = ports[res->port_id].tx_ol_flags;
2908 printf("IP checksum offload is %s\n",
2909 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2910 printf("UDP checksum offload is %s\n",
2911 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2912 printf("TCP checksum offload is %s\n",
2913 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2914 printf("SCTP checksum offload is %s\n",
2915 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2916 printf("VxLAN checksum offload is %s\n",
2917 (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw");
2919 /* display warnings if configuration is not supported by the NIC */
2920 rte_eth_dev_info_get(res->port_id, &dev_info);
2921 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2922 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2923 printf("Warning: hardware IP checksum enabled but not "
2924 "supported by port %d\n", res->port_id);
2926 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2927 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2928 printf("Warning: hardware UDP checksum enabled but not "
2929 "supported by port %d\n", res->port_id);
2931 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2932 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2933 printf("Warning: hardware TCP checksum enabled but not "
2934 "supported by port %d\n", res->port_id);
2936 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2937 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2938 printf("Warning: hardware SCTP checksum enabled but not "
2939 "supported by port %d\n", res->port_id);
2943 cmdline_parse_token_string_t cmd_tx_cksum_tx_cksum =
2944 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2945 tx_cksum, "tx_checksum");
2946 cmdline_parse_token_string_t cmd_tx_cksum_mode =
2947 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2949 cmdline_parse_token_string_t cmd_tx_cksum_proto =
2950 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2951 proto, "ip#tcp#udp#sctp#vxlan");
2952 cmdline_parse_token_string_t cmd_tx_cksum_hwsw =
2953 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2955 cmdline_parse_token_num_t cmd_tx_cksum_portid =
2956 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_result,
2959 cmdline_parse_inst_t cmd_tx_cksum_set = {
2960 .f = cmd_tx_cksum_parsed,
2962 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
2963 "using csum forward engine: tx_cksum set ip|tcp|udp|sctp|vxlan hw|sw <port>",
2965 (void *)&cmd_tx_cksum_tx_cksum,
2966 (void *)&cmd_tx_cksum_mode,
2967 (void *)&cmd_tx_cksum_proto,
2968 (void *)&cmd_tx_cksum_hwsw,
2969 (void *)&cmd_tx_cksum_portid,
2974 cmdline_parse_token_string_t cmd_tx_cksum_mode_show =
2975 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2978 cmdline_parse_inst_t cmd_tx_cksum_show = {
2979 .f = cmd_tx_cksum_parsed,
2981 .help_str = "show checksum offload configuration: tx_cksum show <port>",
2983 (void *)&cmd_tx_cksum_tx_cksum,
2984 (void *)&cmd_tx_cksum_mode_show,
2985 (void *)&cmd_tx_cksum_portid,
2990 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
2991 struct cmd_tso_set_result {
2992 cmdline_fixed_string_t tso;
2993 cmdline_fixed_string_t mode;
2999 cmd_tso_set_parsed(void *parsed_result,
3000 __attribute__((unused)) struct cmdline *cl,
3001 __attribute__((unused)) void *data)
3003 struct cmd_tso_set_result *res = parsed_result;
3004 struct rte_eth_dev_info dev_info;
3006 if (port_id_is_invalid(res->port_id))
3009 if (!strcmp(res->mode, "set"))
3010 ports[res->port_id].tso_segsz = res->tso_segsz;
3012 if (ports[res->port_id].tso_segsz == 0)
3013 printf("TSO is disabled\n");
3015 printf("TSO segment size is %d\n",
3016 ports[res->port_id].tso_segsz);
3018 /* display warnings if configuration is not supported by the NIC */
3019 rte_eth_dev_info_get(res->port_id, &dev_info);
3020 if ((ports[res->port_id].tso_segsz != 0) &&
3021 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3022 printf("Warning: TSO enabled but not "
3023 "supported by port %d\n", res->port_id);
3027 cmdline_parse_token_string_t cmd_tso_set_tso =
3028 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3030 cmdline_parse_token_string_t cmd_tso_set_mode =
3031 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3033 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3034 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3036 cmdline_parse_token_num_t cmd_tso_set_portid =
3037 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3040 cmdline_parse_inst_t cmd_tso_set = {
3041 .f = cmd_tso_set_parsed,
3043 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3044 "tso set <tso_segsz> <port>",
3046 (void *)&cmd_tso_set_tso,
3047 (void *)&cmd_tso_set_mode,
3048 (void *)&cmd_tso_set_tso_segsz,
3049 (void *)&cmd_tso_set_portid,
3054 cmdline_parse_token_string_t cmd_tso_show_mode =
3055 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3059 cmdline_parse_inst_t cmd_tso_show = {
3060 .f = cmd_tso_set_parsed,
3062 .help_str = "Show TSO segment size for csum engine: "
3065 (void *)&cmd_tso_set_tso,
3066 (void *)&cmd_tso_show_mode,
3067 (void *)&cmd_tso_set_portid,
3072 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3073 struct cmd_set_flush_rx {
3074 cmdline_fixed_string_t set;
3075 cmdline_fixed_string_t flush_rx;
3076 cmdline_fixed_string_t mode;
3080 cmd_set_flush_rx_parsed(void *parsed_result,
3081 __attribute__((unused)) struct cmdline *cl,
3082 __attribute__((unused)) void *data)
3084 struct cmd_set_flush_rx *res = parsed_result;
3085 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3088 cmdline_parse_token_string_t cmd_setflushrx_set =
3089 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3091 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3092 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3093 flush_rx, "flush_rx");
3094 cmdline_parse_token_string_t cmd_setflushrx_mode =
3095 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3099 cmdline_parse_inst_t cmd_set_flush_rx = {
3100 .f = cmd_set_flush_rx_parsed,
3101 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3104 (void *)&cmd_setflushrx_set,
3105 (void *)&cmd_setflushrx_flush_rx,
3106 (void *)&cmd_setflushrx_mode,
3111 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3112 struct cmd_set_link_check {
3113 cmdline_fixed_string_t set;
3114 cmdline_fixed_string_t link_check;
3115 cmdline_fixed_string_t mode;
3119 cmd_set_link_check_parsed(void *parsed_result,
3120 __attribute__((unused)) struct cmdline *cl,
3121 __attribute__((unused)) void *data)
3123 struct cmd_set_link_check *res = parsed_result;
3124 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3127 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3128 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3130 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3131 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3132 link_check, "link_check");
3133 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3134 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3138 cmdline_parse_inst_t cmd_set_link_check = {
3139 .f = cmd_set_link_check_parsed,
3140 .help_str = "set link_check on|off: enable/disable link status check "
3141 "when starting/stopping a port",
3144 (void *)&cmd_setlinkcheck_set,
3145 (void *)&cmd_setlinkcheck_link_check,
3146 (void *)&cmd_setlinkcheck_mode,
3151 #ifdef RTE_NIC_BYPASS
3152 /* *** SET NIC BYPASS MODE *** */
3153 struct cmd_set_bypass_mode_result {
3154 cmdline_fixed_string_t set;
3155 cmdline_fixed_string_t bypass;
3156 cmdline_fixed_string_t mode;
3157 cmdline_fixed_string_t value;
3162 cmd_set_bypass_mode_parsed(void *parsed_result,
3163 __attribute__((unused)) struct cmdline *cl,
3164 __attribute__((unused)) void *data)
3166 struct cmd_set_bypass_mode_result *res = parsed_result;
3167 portid_t port_id = res->port_id;
3168 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3170 if (!bypass_is_supported(port_id))
3173 if (!strcmp(res->value, "bypass"))
3174 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3175 else if (!strcmp(res->value, "isolate"))
3176 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3178 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3180 /* Set the bypass mode for the relevant port. */
3181 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3182 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3186 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3187 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3189 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3190 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3192 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3193 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3195 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3196 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3197 value, "normal#bypass#isolate");
3198 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3199 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3202 cmdline_parse_inst_t cmd_set_bypass_mode = {
3203 .f = cmd_set_bypass_mode_parsed,
3204 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3205 "Set the NIC bypass mode for port_id",
3208 (void *)&cmd_setbypass_mode_set,
3209 (void *)&cmd_setbypass_mode_bypass,
3210 (void *)&cmd_setbypass_mode_mode,
3211 (void *)&cmd_setbypass_mode_value,
3212 (void *)&cmd_setbypass_mode_port,
3217 /* *** SET NIC BYPASS EVENT *** */
3218 struct cmd_set_bypass_event_result {
3219 cmdline_fixed_string_t set;
3220 cmdline_fixed_string_t bypass;
3221 cmdline_fixed_string_t event;
3222 cmdline_fixed_string_t event_value;
3223 cmdline_fixed_string_t mode;
3224 cmdline_fixed_string_t mode_value;
3229 cmd_set_bypass_event_parsed(void *parsed_result,
3230 __attribute__((unused)) struct cmdline *cl,
3231 __attribute__((unused)) void *data)
3234 struct cmd_set_bypass_event_result *res = parsed_result;
3235 portid_t port_id = res->port_id;
3236 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3237 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3239 if (!bypass_is_supported(port_id))
3242 if (!strcmp(res->event_value, "timeout"))
3243 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3244 else if (!strcmp(res->event_value, "os_on"))
3245 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3246 else if (!strcmp(res->event_value, "os_off"))
3247 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3248 else if (!strcmp(res->event_value, "power_on"))
3249 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3250 else if (!strcmp(res->event_value, "power_off"))
3251 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3253 bypass_event = RTE_BYPASS_EVENT_NONE;
3255 if (!strcmp(res->mode_value, "bypass"))
3256 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3257 else if (!strcmp(res->mode_value, "isolate"))
3258 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3260 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3262 /* Set the watchdog timeout. */
3263 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3266 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3267 (rc = rte_eth_dev_wd_timeout_store(port_id,
3268 bypass_timeout)) != 0) {
3269 printf("Failed to set timeout value %u "
3270 "for port %d, errto code: %d.\n",
3271 bypass_timeout, port_id, rc);
3275 /* Set the bypass event to transition to bypass mode. */
3276 if (0 != rte_eth_dev_bypass_event_store(port_id,
3277 bypass_event, bypass_mode)) {
3278 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3283 cmdline_parse_token_string_t cmd_setbypass_event_set =
3284 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3286 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3287 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3289 cmdline_parse_token_string_t cmd_setbypass_event_event =
3290 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3292 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3293 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3294 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3295 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3296 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3298 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3299 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3300 mode_value, "normal#bypass#isolate");
3301 cmdline_parse_token_num_t cmd_setbypass_event_port =
3302 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3305 cmdline_parse_inst_t cmd_set_bypass_event = {
3306 .f = cmd_set_bypass_event_parsed,
3307 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3308 "mode (normal|bypass|isolate) (port_id): "
3309 "Set the NIC bypass event mode for port_id",
3312 (void *)&cmd_setbypass_event_set,
3313 (void *)&cmd_setbypass_event_bypass,
3314 (void *)&cmd_setbypass_event_event,
3315 (void *)&cmd_setbypass_event_event_value,
3316 (void *)&cmd_setbypass_event_mode,
3317 (void *)&cmd_setbypass_event_mode_value,
3318 (void *)&cmd_setbypass_event_port,
3324 /* *** SET NIC BYPASS TIMEOUT *** */
3325 struct cmd_set_bypass_timeout_result {
3326 cmdline_fixed_string_t set;
3327 cmdline_fixed_string_t bypass;
3328 cmdline_fixed_string_t timeout;
3329 cmdline_fixed_string_t value;
3333 cmd_set_bypass_timeout_parsed(void *parsed_result,
3334 __attribute__((unused)) struct cmdline *cl,
3335 __attribute__((unused)) void *data)
3337 struct cmd_set_bypass_timeout_result *res = parsed_result;
3339 if (!strcmp(res->value, "1.5"))
3340 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3341 else if (!strcmp(res->value, "2"))
3342 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3343 else if (!strcmp(res->value, "3"))
3344 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3345 else if (!strcmp(res->value, "4"))
3346 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3347 else if (!strcmp(res->value, "8"))
3348 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3349 else if (!strcmp(res->value, "16"))
3350 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3351 else if (!strcmp(res->value, "32"))
3352 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3354 bypass_timeout = RTE_BYPASS_TMT_OFF;
3357 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3358 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3360 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3361 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3363 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3364 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3365 timeout, "timeout");
3366 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3367 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3368 value, "0#1.5#2#3#4#8#16#32");
3370 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3371 .f = cmd_set_bypass_timeout_parsed,
3372 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3373 "Set the NIC bypass watchdog timeout",
3376 (void *)&cmd_setbypass_timeout_set,
3377 (void *)&cmd_setbypass_timeout_bypass,
3378 (void *)&cmd_setbypass_timeout_timeout,
3379 (void *)&cmd_setbypass_timeout_value,
3384 /* *** SHOW NIC BYPASS MODE *** */
3385 struct cmd_show_bypass_config_result {
3386 cmdline_fixed_string_t show;
3387 cmdline_fixed_string_t bypass;
3388 cmdline_fixed_string_t config;
3393 cmd_show_bypass_config_parsed(void *parsed_result,
3394 __attribute__((unused)) struct cmdline *cl,
3395 __attribute__((unused)) void *data)
3397 struct cmd_show_bypass_config_result *res = parsed_result;
3398 uint32_t event_mode;
3399 uint32_t bypass_mode;
3400 portid_t port_id = res->port_id;
3401 uint32_t timeout = bypass_timeout;
3404 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3405 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3406 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3407 {"UNKNOWN", "normal", "bypass", "isolate"};
3408 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3415 int num_events = (sizeof events) / (sizeof events[0]);
3417 if (!bypass_is_supported(port_id))
3420 /* Display the bypass mode.*/
3421 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3422 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3426 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3427 bypass_mode = RTE_BYPASS_MODE_NONE;
3429 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3432 /* Display the bypass timeout.*/
3433 if (!RTE_BYPASS_TMT_VALID(timeout))
3434 timeout = RTE_BYPASS_TMT_OFF;
3436 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3438 /* Display the bypass events and associated modes. */
3439 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3441 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3442 printf("\tFailed to get bypass mode for event = %s\n",
3445 if (!RTE_BYPASS_MODE_VALID(event_mode))
3446 event_mode = RTE_BYPASS_MODE_NONE;
3448 printf("\tbypass event: %-16s = %s\n", events[i],
3454 cmdline_parse_token_string_t cmd_showbypass_config_show =
3455 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3457 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3458 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3460 cmdline_parse_token_string_t cmd_showbypass_config_config =
3461 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3463 cmdline_parse_token_num_t cmd_showbypass_config_port =
3464 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3467 cmdline_parse_inst_t cmd_show_bypass_config = {
3468 .f = cmd_show_bypass_config_parsed,
3469 .help_str = "show bypass config (port_id): "
3470 "Show the NIC bypass config for port_id",
3473 (void *)&cmd_showbypass_config_show,
3474 (void *)&cmd_showbypass_config_bypass,
3475 (void *)&cmd_showbypass_config_config,
3476 (void *)&cmd_showbypass_config_port,
3482 #ifdef RTE_LIBRTE_PMD_BOND
3483 /* *** SET BONDING MODE *** */
3484 struct cmd_set_bonding_mode_result {
3485 cmdline_fixed_string_t set;
3486 cmdline_fixed_string_t bonding;
3487 cmdline_fixed_string_t mode;
3492 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3493 __attribute__((unused)) struct cmdline *cl,
3494 __attribute__((unused)) void *data)
3496 struct cmd_set_bonding_mode_result *res = parsed_result;
3497 portid_t port_id = res->port_id;
3499 /* Set the bonding mode for the relevant port. */
3500 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3501 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3504 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3505 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3507 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3508 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3509 bonding, "bonding");
3510 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3511 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3513 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3514 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3516 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3517 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3520 cmdline_parse_inst_t cmd_set_bonding_mode = {
3521 .f = cmd_set_bonding_mode_parsed,
3522 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3525 (void *) &cmd_setbonding_mode_set,
3526 (void *) &cmd_setbonding_mode_bonding,
3527 (void *) &cmd_setbonding_mode_mode,
3528 (void *) &cmd_setbonding_mode_value,
3529 (void *) &cmd_setbonding_mode_port,
3534 /* *** SET BALANCE XMIT POLICY *** */
3535 struct cmd_set_bonding_balance_xmit_policy_result {
3536 cmdline_fixed_string_t set;
3537 cmdline_fixed_string_t bonding;
3538 cmdline_fixed_string_t balance_xmit_policy;
3540 cmdline_fixed_string_t policy;
3543 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3544 __attribute__((unused)) struct cmdline *cl,
3545 __attribute__((unused)) void *data)
3547 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3548 portid_t port_id = res->port_id;
3551 if (!strcmp(res->policy, "l2")) {
3552 policy = BALANCE_XMIT_POLICY_LAYER2;
3553 } else if (!strcmp(res->policy, "l23")) {
3554 policy = BALANCE_XMIT_POLICY_LAYER23;
3555 } else if (!strcmp(res->policy, "l34")) {
3556 policy = BALANCE_XMIT_POLICY_LAYER34;
3558 printf("\t Invalid xmit policy selection");
3562 /* Set the bonding mode for the relevant port. */
3563 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3564 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3569 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3570 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3572 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3573 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3574 bonding, "bonding");
3575 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3576 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3577 balance_xmit_policy, "balance_xmit_policy");
3578 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3579 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3581 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3582 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3583 policy, "l2#l23#l34");
3585 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3586 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3587 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3590 (void *)&cmd_setbonding_balance_xmit_policy_set,
3591 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3592 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3593 (void *)&cmd_setbonding_balance_xmit_policy_port,
3594 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3599 /* *** SHOW NIC BONDING CONFIGURATION *** */
3600 struct cmd_show_bonding_config_result {
3601 cmdline_fixed_string_t show;
3602 cmdline_fixed_string_t bonding;
3603 cmdline_fixed_string_t config;
3607 static void cmd_show_bonding_config_parsed(void *parsed_result,
3608 __attribute__((unused)) struct cmdline *cl,
3609 __attribute__((unused)) void *data)
3611 struct cmd_show_bonding_config_result *res = parsed_result;
3613 uint8_t slaves[RTE_MAX_ETHPORTS];
3614 int num_slaves, num_active_slaves;
3617 portid_t port_id = res->port_id;
3619 /* Display the bonding mode.*/
3620 bonding_mode = rte_eth_bond_mode_get(port_id);
3621 if (bonding_mode < 0) {
3622 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3625 printf("\tBonding mode: %d\n", bonding_mode);
3627 if (bonding_mode == BONDING_MODE_BALANCE) {
3628 int balance_xmit_policy;
3630 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3631 if (balance_xmit_policy < 0) {
3632 printf("\tFailed to get balance xmit policy for port = %d\n",
3636 printf("\tBalance Xmit Policy: ");
3638 switch (balance_xmit_policy) {
3639 case BALANCE_XMIT_POLICY_LAYER2:
3640 printf("BALANCE_XMIT_POLICY_LAYER2");
3642 case BALANCE_XMIT_POLICY_LAYER23:
3643 printf("BALANCE_XMIT_POLICY_LAYER23");
3645 case BALANCE_XMIT_POLICY_LAYER34:
3646 printf("BALANCE_XMIT_POLICY_LAYER34");
3653 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3655 if (num_slaves < 0) {
3656 printf("\tFailed to get slave list for port = %d\n", port_id);
3659 if (num_slaves > 0) {
3660 printf("\tSlaves (%d): [", num_slaves);
3661 for (i = 0; i < num_slaves - 1; i++)
3662 printf("%d ", slaves[i]);
3664 printf("%d]\n", slaves[num_slaves - 1]);
3666 printf("\tSlaves: []\n");
3670 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3673 if (num_active_slaves < 0) {
3674 printf("\tFailed to get active slave list for port = %d\n", port_id);
3677 if (num_active_slaves > 0) {
3678 printf("\tActive Slaves (%d): [", num_active_slaves);
3679 for (i = 0; i < num_active_slaves - 1; i++)
3680 printf("%d ", slaves[i]);
3682 printf("%d]\n", slaves[num_active_slaves - 1]);
3685 printf("\tActive Slaves: []\n");
3689 primary_id = rte_eth_bond_primary_get(port_id);
3690 if (primary_id < 0) {
3691 printf("\tFailed to get primary slave for port = %d\n", port_id);
3694 printf("\tPrimary: [%d]\n", primary_id);
3698 cmdline_parse_token_string_t cmd_showbonding_config_show =
3699 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3701 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3702 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3703 bonding, "bonding");
3704 cmdline_parse_token_string_t cmd_showbonding_config_config =
3705 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3707 cmdline_parse_token_num_t cmd_showbonding_config_port =
3708 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3711 cmdline_parse_inst_t cmd_show_bonding_config = {
3712 .f = cmd_show_bonding_config_parsed,
3713 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3716 (void *)&cmd_showbonding_config_show,
3717 (void *)&cmd_showbonding_config_bonding,
3718 (void *)&cmd_showbonding_config_config,
3719 (void *)&cmd_showbonding_config_port,
3724 /* *** SET BONDING PRIMARY *** */
3725 struct cmd_set_bonding_primary_result {
3726 cmdline_fixed_string_t set;
3727 cmdline_fixed_string_t bonding;
3728 cmdline_fixed_string_t primary;
3733 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3734 __attribute__((unused)) struct cmdline *cl,
3735 __attribute__((unused)) void *data)
3737 struct cmd_set_bonding_primary_result *res = parsed_result;
3738 portid_t master_port_id = res->port_id;
3739 portid_t slave_port_id = res->slave_id;
3741 /* Set the primary slave for a bonded device. */
3742 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3743 printf("\t Failed to set primary slave for port = %d.\n",
3750 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3751 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3753 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3754 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3755 bonding, "bonding");
3756 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3757 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3758 primary, "primary");
3759 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3760 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3762 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3763 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3766 cmdline_parse_inst_t cmd_set_bonding_primary = {
3767 .f = cmd_set_bonding_primary_parsed,
3768 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3771 (void *)&cmd_setbonding_primary_set,
3772 (void *)&cmd_setbonding_primary_bonding,
3773 (void *)&cmd_setbonding_primary_primary,
3774 (void *)&cmd_setbonding_primary_slave,
3775 (void *)&cmd_setbonding_primary_port,
3780 /* *** ADD SLAVE *** */
3781 struct cmd_add_bonding_slave_result {
3782 cmdline_fixed_string_t add;
3783 cmdline_fixed_string_t bonding;
3784 cmdline_fixed_string_t slave;
3789 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3790 __attribute__((unused)) struct cmdline *cl,
3791 __attribute__((unused)) void *data)
3793 struct cmd_add_bonding_slave_result *res = parsed_result;
3794 portid_t master_port_id = res->port_id;
3795 portid_t slave_port_id = res->slave_id;
3797 /* Set the primary slave for a bonded device. */
3798 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3799 printf("\t Failed to add slave %d to master port = %d.\n",
3800 slave_port_id, master_port_id);
3806 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3807 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3809 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3810 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3811 bonding, "bonding");
3812 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3813 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3815 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3816 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3818 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3819 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3822 cmdline_parse_inst_t cmd_add_bonding_slave = {
3823 .f = cmd_add_bonding_slave_parsed,
3824 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3827 (void *)&cmd_addbonding_slave_add,
3828 (void *)&cmd_addbonding_slave_bonding,
3829 (void *)&cmd_addbonding_slave_slave,
3830 (void *)&cmd_addbonding_slave_slaveid,
3831 (void *)&cmd_addbonding_slave_port,
3836 /* *** REMOVE SLAVE *** */
3837 struct cmd_remove_bonding_slave_result {
3838 cmdline_fixed_string_t remove;
3839 cmdline_fixed_string_t bonding;
3840 cmdline_fixed_string_t slave;
3845 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3846 __attribute__((unused)) struct cmdline *cl,
3847 __attribute__((unused)) void *data)
3849 struct cmd_remove_bonding_slave_result *res = parsed_result;
3850 portid_t master_port_id = res->port_id;
3851 portid_t slave_port_id = res->slave_id;
3853 /* Set the primary slave for a bonded device. */
3854 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3855 printf("\t Failed to remove slave %d from master port = %d.\n",
3856 slave_port_id, master_port_id);
3862 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3863 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3865 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3866 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3867 bonding, "bonding");
3868 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3869 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3871 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3872 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3874 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3875 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3878 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3879 .f = cmd_remove_bonding_slave_parsed,
3880 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3883 (void *)&cmd_removebonding_slave_remove,
3884 (void *)&cmd_removebonding_slave_bonding,
3885 (void *)&cmd_removebonding_slave_slave,
3886 (void *)&cmd_removebonding_slave_slaveid,
3887 (void *)&cmd_removebonding_slave_port,
3892 /* *** CREATE BONDED DEVICE *** */
3893 struct cmd_create_bonded_device_result {
3894 cmdline_fixed_string_t create;
3895 cmdline_fixed_string_t bonded;
3896 cmdline_fixed_string_t device;
3901 static int bond_dev_num = 0;
3903 static void cmd_create_bonded_device_parsed(void *parsed_result,
3904 __attribute__((unused)) struct cmdline *cl,
3905 __attribute__((unused)) void *data)
3907 struct cmd_create_bonded_device_result *res = parsed_result;
3908 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3911 if (test_done == 0) {
3912 printf("Please stop forwarding first\n");
3916 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3919 /* Create a new bonded device. */
3920 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3922 printf("\t Failed to create bonded device.\n");
3925 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3928 /* Update number of ports */
3929 nb_ports = rte_eth_dev_count();
3930 reconfig(port_id, res->socket);
3931 rte_eth_promiscuous_enable(port_id);
3936 cmdline_parse_token_string_t cmd_createbonded_device_create =
3937 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3939 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3940 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3942 cmdline_parse_token_string_t cmd_createbonded_device_device =
3943 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3945 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3946 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3948 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3949 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3952 cmdline_parse_inst_t cmd_create_bonded_device = {
3953 .f = cmd_create_bonded_device_parsed,
3954 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3957 (void *)&cmd_createbonded_device_create,
3958 (void *)&cmd_createbonded_device_bonded,
3959 (void *)&cmd_createbonded_device_device,
3960 (void *)&cmd_createbonded_device_mode,
3961 (void *)&cmd_createbonded_device_socket,
3966 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3967 struct cmd_set_bond_mac_addr_result {
3968 cmdline_fixed_string_t set;
3969 cmdline_fixed_string_t bonding;
3970 cmdline_fixed_string_t mac_addr;
3972 struct ether_addr address;
3975 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3976 __attribute__((unused)) struct cmdline *cl,
3977 __attribute__((unused)) void *data)
3979 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3982 if (res->port_num >= nb_ports) {
3983 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3987 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3989 /* check the return value and print it if is < 0 */
3991 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3994 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3995 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3996 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3997 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3999 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4000 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4002 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4003 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4004 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4005 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4007 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4008 .f = cmd_set_bond_mac_addr_parsed,
4010 .help_str = "set bonding mac_addr (port_id) (address): ",
4012 (void *)&cmd_set_bond_mac_addr_set,
4013 (void *)&cmd_set_bond_mac_addr_bonding,
4014 (void *)&cmd_set_bond_mac_addr_mac,
4015 (void *)&cmd_set_bond_mac_addr_portnum,
4016 (void *)&cmd_set_bond_mac_addr_addr,
4022 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4023 struct cmd_set_bond_mon_period_result {
4024 cmdline_fixed_string_t set;
4025 cmdline_fixed_string_t bonding;
4026 cmdline_fixed_string_t mon_period;
4031 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4032 __attribute__((unused)) struct cmdline *cl,
4033 __attribute__((unused)) void *data)
4035 struct cmd_set_bond_mon_period_result *res = parsed_result;
4038 if (res->port_num >= nb_ports) {
4039 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4043 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4045 /* check the return value and print it if is < 0 */
4047 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4050 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4051 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4053 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4054 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4055 bonding, "bonding");
4056 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4057 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4058 mon_period, "mon_period");
4059 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4060 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4062 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4063 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4066 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4067 .f = cmd_set_bond_mon_period_parsed,
4069 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4071 (void *)&cmd_set_bond_mon_period_set,
4072 (void *)&cmd_set_bond_mon_period_bonding,
4073 (void *)&cmd_set_bond_mon_period_mon_period,
4074 (void *)&cmd_set_bond_mon_period_portnum,
4075 (void *)&cmd_set_bond_mon_period_period_ms,
4080 #endif /* RTE_LIBRTE_PMD_BOND */
4082 /* *** SET FORWARDING MODE *** */
4083 struct cmd_set_fwd_mode_result {
4084 cmdline_fixed_string_t set;
4085 cmdline_fixed_string_t fwd;
4086 cmdline_fixed_string_t mode;
4089 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4090 __attribute__((unused)) struct cmdline *cl,
4091 __attribute__((unused)) void *data)
4093 struct cmd_set_fwd_mode_result *res = parsed_result;
4095 set_pkt_forwarding_mode(res->mode);
4098 cmdline_parse_token_string_t cmd_setfwd_set =
4099 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4100 cmdline_parse_token_string_t cmd_setfwd_fwd =
4101 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4102 cmdline_parse_token_string_t cmd_setfwd_mode =
4103 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4104 "" /* defined at init */);
4106 cmdline_parse_inst_t cmd_set_fwd_mode = {
4107 .f = cmd_set_fwd_mode_parsed,
4109 .help_str = NULL, /* defined at init */
4111 (void *)&cmd_setfwd_set,
4112 (void *)&cmd_setfwd_fwd,
4113 (void *)&cmd_setfwd_mode,
4118 static void cmd_set_fwd_mode_init(void)
4121 static char token[128];
4122 static char help[256];
4123 cmdline_parse_token_string_t *token_struct;
4125 modes = list_pkt_forwarding_modes();
4126 snprintf(help, sizeof help, "set fwd %s - "
4127 "set packet forwarding mode", modes);
4128 cmd_set_fwd_mode.help_str = help;
4130 /* string token separator is # */
4131 for (c = token; *modes != '\0'; modes++)
4136 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4137 token_struct->string_data.str = token;
4140 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4141 struct cmd_set_burst_tx_retry_result {
4142 cmdline_fixed_string_t set;
4143 cmdline_fixed_string_t burst;
4144 cmdline_fixed_string_t tx;
4145 cmdline_fixed_string_t delay;
4147 cmdline_fixed_string_t retry;
4151 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4152 __attribute__((unused)) struct cmdline *cl,
4153 __attribute__((unused)) void *data)
4155 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4157 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4158 && !strcmp(res->tx, "tx")) {
4159 if (!strcmp(res->delay, "delay"))
4160 burst_tx_delay_time = res->time;
4161 if (!strcmp(res->retry, "retry"))
4162 burst_tx_retry_num = res->retry_num;
4167 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4168 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4169 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4170 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4172 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4173 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4174 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4175 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4176 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4177 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4178 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4179 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4180 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4181 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4183 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4184 .f = cmd_set_burst_tx_retry_parsed,
4185 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4187 (void *)&cmd_set_burst_tx_retry_set,
4188 (void *)&cmd_set_burst_tx_retry_burst,
4189 (void *)&cmd_set_burst_tx_retry_tx,
4190 (void *)&cmd_set_burst_tx_retry_delay,
4191 (void *)&cmd_set_burst_tx_retry_time,
4192 (void *)&cmd_set_burst_tx_retry_retry,
4193 (void *)&cmd_set_burst_tx_retry_retry_num,
4198 /* *** SET PROMISC MODE *** */
4199 struct cmd_set_promisc_mode_result {
4200 cmdline_fixed_string_t set;
4201 cmdline_fixed_string_t promisc;
4202 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4203 uint8_t port_num; /* valid if "allports" argument == 0 */
4204 cmdline_fixed_string_t mode;
4207 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4208 __attribute__((unused)) struct cmdline *cl,
4211 struct cmd_set_promisc_mode_result *res = parsed_result;
4215 if (!strcmp(res->mode, "on"))
4222 for (i = 0; i < nb_ports; i++) {
4224 rte_eth_promiscuous_enable(i);
4226 rte_eth_promiscuous_disable(i);
4231 rte_eth_promiscuous_enable(res->port_num);
4233 rte_eth_promiscuous_disable(res->port_num);
4237 cmdline_parse_token_string_t cmd_setpromisc_set =
4238 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4239 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4240 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4242 cmdline_parse_token_string_t cmd_setpromisc_portall =
4243 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4245 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4246 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4248 cmdline_parse_token_string_t cmd_setpromisc_mode =
4249 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4252 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4253 .f = cmd_set_promisc_mode_parsed,
4255 .help_str = "set promisc all on|off: set promisc mode for all ports",
4257 (void *)&cmd_setpromisc_set,
4258 (void *)&cmd_setpromisc_promisc,
4259 (void *)&cmd_setpromisc_portall,
4260 (void *)&cmd_setpromisc_mode,
4265 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4266 .f = cmd_set_promisc_mode_parsed,
4268 .help_str = "set promisc X on|off: set promisc mode on port X",
4270 (void *)&cmd_setpromisc_set,
4271 (void *)&cmd_setpromisc_promisc,
4272 (void *)&cmd_setpromisc_portnum,
4273 (void *)&cmd_setpromisc_mode,
4278 /* *** SET ALLMULTI MODE *** */
4279 struct cmd_set_allmulti_mode_result {
4280 cmdline_fixed_string_t set;
4281 cmdline_fixed_string_t allmulti;
4282 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4283 uint8_t port_num; /* valid if "allports" argument == 0 */
4284 cmdline_fixed_string_t mode;
4287 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4288 __attribute__((unused)) struct cmdline *cl,
4291 struct cmd_set_allmulti_mode_result *res = parsed_result;
4295 if (!strcmp(res->mode, "on"))
4302 for (i = 0; i < nb_ports; i++) {
4304 rte_eth_allmulticast_enable(i);
4306 rte_eth_allmulticast_disable(i);
4311 rte_eth_allmulticast_enable(res->port_num);
4313 rte_eth_allmulticast_disable(res->port_num);
4317 cmdline_parse_token_string_t cmd_setallmulti_set =
4318 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4319 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4320 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4322 cmdline_parse_token_string_t cmd_setallmulti_portall =
4323 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4325 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4326 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4328 cmdline_parse_token_string_t cmd_setallmulti_mode =
4329 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4332 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4333 .f = cmd_set_allmulti_mode_parsed,
4335 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4337 (void *)&cmd_setallmulti_set,
4338 (void *)&cmd_setallmulti_allmulti,
4339 (void *)&cmd_setallmulti_portall,
4340 (void *)&cmd_setallmulti_mode,
4345 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4346 .f = cmd_set_allmulti_mode_parsed,
4348 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4350 (void *)&cmd_setallmulti_set,
4351 (void *)&cmd_setallmulti_allmulti,
4352 (void *)&cmd_setallmulti_portnum,
4353 (void *)&cmd_setallmulti_mode,
4358 /* *** ADD/REMOVE A PKT FILTER *** */
4359 struct cmd_pkt_filter_result {
4360 cmdline_fixed_string_t pkt_filter;
4362 cmdline_fixed_string_t protocol;
4363 cmdline_fixed_string_t src;
4364 cmdline_ipaddr_t ip_src;
4366 cmdline_fixed_string_t dst;
4367 cmdline_ipaddr_t ip_dst;
4369 cmdline_fixed_string_t flexbytes;
4370 uint16_t flexbytes_value;
4371 cmdline_fixed_string_t vlan;
4373 cmdline_fixed_string_t queue;
4375 cmdline_fixed_string_t soft;
4380 cmd_pkt_filter_parsed(void *parsed_result,
4381 __attribute__((unused)) struct cmdline *cl,
4382 __attribute__((unused)) void *data)
4384 struct rte_fdir_filter fdir_filter;
4385 struct cmd_pkt_filter_result *res = parsed_result;
4387 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4389 if (res->ip_src.family == AF_INET)
4390 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4392 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4393 &(res->ip_src.addr.ipv6),
4394 sizeof(struct in6_addr));
4396 if (res->ip_dst.family == AF_INET)
4397 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4399 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4400 &(res->ip_dst.addr.ipv6),
4401 sizeof(struct in6_addr));
4403 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4404 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4406 if (!strcmp(res->protocol, "udp"))
4407 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4408 else if (!strcmp(res->protocol, "tcp"))
4409 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4410 else if (!strcmp(res->protocol, "sctp"))
4411 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4412 else /* default only IP */
4413 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4415 if (res->ip_dst.family == AF_INET6)
4416 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4418 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4420 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4421 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4423 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4424 fdir_add_signature_filter(res->port_id, res->queue_id,
4426 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4427 fdir_update_signature_filter(res->port_id, res->queue_id,
4429 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4430 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4431 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4432 fdir_add_perfect_filter(res->port_id, res->soft_id,
4434 (uint8_t) (res->queue_id < 0),
4436 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4437 fdir_update_perfect_filter(res->port_id, res->soft_id,
4439 (uint8_t) (res->queue_id < 0),
4441 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4442 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4448 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4449 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4451 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4452 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4453 protocol, "ip#tcp#udp#sctp");
4454 cmdline_parse_token_string_t cmd_pkt_filter_src =
4455 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4457 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4458 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4460 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4461 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4463 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4464 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4466 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4467 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4469 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4470 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4472 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4473 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4474 flexbytes, "flexbytes");
4475 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4476 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4477 flexbytes_value, UINT16);
4478 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4479 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4481 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4482 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4484 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4485 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4487 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4488 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4490 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4491 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4493 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4494 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4498 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4499 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4500 pkt_filter, "add_signature_filter");
4501 cmdline_parse_inst_t cmd_add_signature_filter = {
4502 .f = cmd_pkt_filter_parsed,
4504 .help_str = "add a signature filter",
4506 (void *)&cmd_pkt_filter_add_signature_filter,
4507 (void *)&cmd_pkt_filter_port_id,
4508 (void *)&cmd_pkt_filter_protocol,
4509 (void *)&cmd_pkt_filter_src,
4510 (void *)&cmd_pkt_filter_ip_src,
4511 (void *)&cmd_pkt_filter_port_src,
4512 (void *)&cmd_pkt_filter_dst,
4513 (void *)&cmd_pkt_filter_ip_dst,
4514 (void *)&cmd_pkt_filter_port_dst,
4515 (void *)&cmd_pkt_filter_flexbytes,
4516 (void *)&cmd_pkt_filter_flexbytes_value,
4517 (void *)&cmd_pkt_filter_vlan,
4518 (void *)&cmd_pkt_filter_vlan_id,
4519 (void *)&cmd_pkt_filter_queue,
4520 (void *)&cmd_pkt_filter_queue_id,
4526 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4527 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4528 pkt_filter, "upd_signature_filter");
4529 cmdline_parse_inst_t cmd_upd_signature_filter = {
4530 .f = cmd_pkt_filter_parsed,
4532 .help_str = "update a signature filter",
4534 (void *)&cmd_pkt_filter_upd_signature_filter,
4535 (void *)&cmd_pkt_filter_port_id,
4536 (void *)&cmd_pkt_filter_protocol,
4537 (void *)&cmd_pkt_filter_src,
4538 (void *)&cmd_pkt_filter_ip_src,
4539 (void *)&cmd_pkt_filter_port_src,
4540 (void *)&cmd_pkt_filter_dst,
4541 (void *)&cmd_pkt_filter_ip_dst,
4542 (void *)&cmd_pkt_filter_port_dst,
4543 (void *)&cmd_pkt_filter_flexbytes,
4544 (void *)&cmd_pkt_filter_flexbytes_value,
4545 (void *)&cmd_pkt_filter_vlan,
4546 (void *)&cmd_pkt_filter_vlan_id,
4547 (void *)&cmd_pkt_filter_queue,
4548 (void *)&cmd_pkt_filter_queue_id,
4554 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4555 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4556 pkt_filter, "rm_signature_filter");
4557 cmdline_parse_inst_t cmd_rm_signature_filter = {
4558 .f = cmd_pkt_filter_parsed,
4560 .help_str = "remove a signature filter",
4562 (void *)&cmd_pkt_filter_rm_signature_filter,
4563 (void *)&cmd_pkt_filter_port_id,
4564 (void *)&cmd_pkt_filter_protocol,
4565 (void *)&cmd_pkt_filter_src,
4566 (void *)&cmd_pkt_filter_ip_src,
4567 (void *)&cmd_pkt_filter_port_src,
4568 (void *)&cmd_pkt_filter_dst,
4569 (void *)&cmd_pkt_filter_ip_dst,
4570 (void *)&cmd_pkt_filter_port_dst,
4571 (void *)&cmd_pkt_filter_flexbytes,
4572 (void *)&cmd_pkt_filter_flexbytes_value,
4573 (void *)&cmd_pkt_filter_vlan,
4574 (void *)&cmd_pkt_filter_vlan_id,
4580 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4581 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4582 pkt_filter, "add_perfect_filter");
4583 cmdline_parse_inst_t cmd_add_perfect_filter = {
4584 .f = cmd_pkt_filter_parsed,
4586 .help_str = "add a perfect filter",
4588 (void *)&cmd_pkt_filter_add_perfect_filter,
4589 (void *)&cmd_pkt_filter_port_id,
4590 (void *)&cmd_pkt_filter_protocol,
4591 (void *)&cmd_pkt_filter_src,
4592 (void *)&cmd_pkt_filter_ip_src,
4593 (void *)&cmd_pkt_filter_port_src,
4594 (void *)&cmd_pkt_filter_dst,
4595 (void *)&cmd_pkt_filter_ip_dst,
4596 (void *)&cmd_pkt_filter_port_dst,
4597 (void *)&cmd_pkt_filter_flexbytes,
4598 (void *)&cmd_pkt_filter_flexbytes_value,
4599 (void *)&cmd_pkt_filter_vlan,
4600 (void *)&cmd_pkt_filter_vlan_id,
4601 (void *)&cmd_pkt_filter_queue,
4602 (void *)&cmd_pkt_filter_queue_id,
4603 (void *)&cmd_pkt_filter_soft,
4604 (void *)&cmd_pkt_filter_soft_id,
4610 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4611 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4612 pkt_filter, "upd_perfect_filter");
4613 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4614 .f = cmd_pkt_filter_parsed,
4616 .help_str = "update a perfect filter",
4618 (void *)&cmd_pkt_filter_upd_perfect_filter,
4619 (void *)&cmd_pkt_filter_port_id,
4620 (void *)&cmd_pkt_filter_protocol,
4621 (void *)&cmd_pkt_filter_src,
4622 (void *)&cmd_pkt_filter_ip_src,
4623 (void *)&cmd_pkt_filter_port_src,
4624 (void *)&cmd_pkt_filter_dst,
4625 (void *)&cmd_pkt_filter_ip_dst,
4626 (void *)&cmd_pkt_filter_port_dst,
4627 (void *)&cmd_pkt_filter_flexbytes,
4628 (void *)&cmd_pkt_filter_flexbytes_value,
4629 (void *)&cmd_pkt_filter_vlan,
4630 (void *)&cmd_pkt_filter_vlan_id,
4631 (void *)&cmd_pkt_filter_queue,
4632 (void *)&cmd_pkt_filter_queue_id,
4633 (void *)&cmd_pkt_filter_soft,
4634 (void *)&cmd_pkt_filter_soft_id,
4640 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4641 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4642 pkt_filter, "rm_perfect_filter");
4643 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4644 .f = cmd_pkt_filter_parsed,
4646 .help_str = "remove a perfect filter",
4648 (void *)&cmd_pkt_filter_rm_perfect_filter,
4649 (void *)&cmd_pkt_filter_port_id,
4650 (void *)&cmd_pkt_filter_protocol,
4651 (void *)&cmd_pkt_filter_src,
4652 (void *)&cmd_pkt_filter_ip_src,
4653 (void *)&cmd_pkt_filter_port_src,
4654 (void *)&cmd_pkt_filter_dst,
4655 (void *)&cmd_pkt_filter_ip_dst,
4656 (void *)&cmd_pkt_filter_port_dst,
4657 (void *)&cmd_pkt_filter_flexbytes,
4658 (void *)&cmd_pkt_filter_flexbytes_value,
4659 (void *)&cmd_pkt_filter_vlan,
4660 (void *)&cmd_pkt_filter_vlan_id,
4661 (void *)&cmd_pkt_filter_soft,
4662 (void *)&cmd_pkt_filter_soft_id,
4667 /* *** SETUP MASKS FILTER *** */
4668 struct cmd_pkt_filter_masks_result {
4669 cmdline_fixed_string_t filter_mask;
4671 cmdline_fixed_string_t src_mask;
4672 uint32_t ip_src_mask;
4673 uint16_t ipv6_src_mask;
4674 uint16_t port_src_mask;
4675 cmdline_fixed_string_t dst_mask;
4676 uint32_t ip_dst_mask;
4677 uint16_t ipv6_dst_mask;
4678 uint16_t port_dst_mask;
4679 cmdline_fixed_string_t flexbytes;
4680 uint8_t flexbytes_value;
4681 cmdline_fixed_string_t vlan_id;
4682 uint8_t vlan_id_value;
4683 cmdline_fixed_string_t vlan_prio;
4684 uint8_t vlan_prio_value;
4685 cmdline_fixed_string_t only_ip_flow;
4686 uint8_t only_ip_flow_value;
4687 cmdline_fixed_string_t comp_ipv6_dst;
4688 uint8_t comp_ipv6_dst_value;
4692 cmd_pkt_filter_masks_parsed(void *parsed_result,
4693 __attribute__((unused)) struct cmdline *cl,
4694 __attribute__((unused)) void *data)
4696 struct rte_fdir_masks fdir_masks;
4697 struct cmd_pkt_filter_masks_result *res = parsed_result;
4699 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4701 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4702 fdir_masks.vlan_id = res->vlan_id_value;
4703 fdir_masks.vlan_prio = res->vlan_prio_value;
4704 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4705 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4706 fdir_masks.src_port_mask = res->port_src_mask;
4707 fdir_masks.dst_port_mask = res->port_dst_mask;
4708 fdir_masks.flexbytes = res->flexbytes_value;
4710 fdir_set_masks(res->port_id, &fdir_masks);
4713 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4714 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4715 filter_mask, "set_masks_filter");
4716 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4717 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4719 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4720 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4721 only_ip_flow, "only_ip_flow");
4722 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4723 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4724 only_ip_flow_value, UINT8);
4725 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4726 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4727 src_mask, "src_mask");
4728 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4729 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4730 ip_src_mask, UINT32);
4731 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4732 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4733 port_src_mask, UINT16);
4734 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4735 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4736 dst_mask, "dst_mask");
4737 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4738 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4739 ip_dst_mask, UINT32);
4740 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4741 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4742 port_dst_mask, UINT16);
4743 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4744 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4745 flexbytes, "flexbytes");
4746 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4747 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4748 flexbytes_value, UINT8);
4749 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4750 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4751 vlan_id, "vlan_id");
4752 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4753 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4754 vlan_id_value, UINT8);
4755 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4756 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4757 vlan_prio, "vlan_prio");
4758 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4759 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4760 vlan_prio_value, UINT8);
4762 cmdline_parse_inst_t cmd_set_masks_filter = {
4763 .f = cmd_pkt_filter_masks_parsed,
4765 .help_str = "setup masks filter",
4767 (void *)&cmd_pkt_filter_masks_filter_mask,
4768 (void *)&cmd_pkt_filter_masks_port_id,
4769 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4770 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4771 (void *)&cmd_pkt_filter_masks_src_mask,
4772 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4773 (void *)&cmd_pkt_filter_masks_port_src_mask,
4774 (void *)&cmd_pkt_filter_masks_dst_mask,
4775 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4776 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4777 (void *)&cmd_pkt_filter_masks_flexbytes,
4778 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4779 (void *)&cmd_pkt_filter_masks_vlan_id,
4780 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4781 (void *)&cmd_pkt_filter_masks_vlan_prio,
4782 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4788 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4789 __attribute__((unused)) struct cmdline *cl,
4790 __attribute__((unused)) void *data)
4792 struct rte_fdir_masks fdir_masks;
4793 struct cmd_pkt_filter_masks_result *res = parsed_result;
4795 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4797 fdir_masks.set_ipv6_mask = 1;
4798 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4799 fdir_masks.vlan_id = res->vlan_id_value;
4800 fdir_masks.vlan_prio = res->vlan_prio_value;
4801 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4802 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4803 fdir_masks.src_port_mask = res->port_src_mask;
4804 fdir_masks.dst_port_mask = res->port_dst_mask;
4805 fdir_masks.flexbytes = res->flexbytes_value;
4806 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4808 fdir_set_masks(res->port_id, &fdir_masks);
4811 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4812 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4813 filter_mask, "set_ipv6_masks_filter");
4814 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4815 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4816 ipv6_src_mask, UINT16);
4817 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4818 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4819 ipv6_dst_mask, UINT16);
4821 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4822 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4823 comp_ipv6_dst, "compare_dst");
4824 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4825 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4826 comp_ipv6_dst_value, UINT8);
4828 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4829 .f = cmd_pkt_filter_masks_ipv6_parsed,
4831 .help_str = "setup ipv6 masks filter",
4833 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4834 (void *)&cmd_pkt_filter_masks_port_id,
4835 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4836 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4837 (void *)&cmd_pkt_filter_masks_src_mask,
4838 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4839 (void *)&cmd_pkt_filter_masks_port_src_mask,
4840 (void *)&cmd_pkt_filter_masks_dst_mask,
4841 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4842 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4843 (void *)&cmd_pkt_filter_masks_flexbytes,
4844 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4845 (void *)&cmd_pkt_filter_masks_vlan_id,
4846 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4847 (void *)&cmd_pkt_filter_masks_vlan_prio,
4848 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4849 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4850 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4855 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4856 struct cmd_link_flow_ctrl_set_result {
4857 cmdline_fixed_string_t set;
4858 cmdline_fixed_string_t flow_ctrl;
4859 cmdline_fixed_string_t rx;
4860 cmdline_fixed_string_t rx_lfc_mode;
4861 cmdline_fixed_string_t tx;
4862 cmdline_fixed_string_t tx_lfc_mode;
4863 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4864 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4865 cmdline_fixed_string_t autoneg_str;
4866 cmdline_fixed_string_t autoneg;
4867 cmdline_fixed_string_t hw_str;
4868 uint32_t high_water;
4869 cmdline_fixed_string_t lw_str;
4871 cmdline_fixed_string_t pt_str;
4872 uint16_t pause_time;
4873 cmdline_fixed_string_t xon_str;
4878 cmdline_parse_token_string_t cmd_lfc_set_set =
4879 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4881 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4882 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4883 flow_ctrl, "flow_ctrl");
4884 cmdline_parse_token_string_t cmd_lfc_set_rx =
4885 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4887 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4888 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4889 rx_lfc_mode, "on#off");
4890 cmdline_parse_token_string_t cmd_lfc_set_tx =
4891 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4893 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4894 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4895 tx_lfc_mode, "on#off");
4896 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4897 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4898 hw_str, "high_water");
4899 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4900 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4901 high_water, UINT32);
4902 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4903 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4904 lw_str, "low_water");
4905 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4906 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4908 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4909 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4910 pt_str, "pause_time");
4911 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4912 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4913 pause_time, UINT16);
4914 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4915 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4916 xon_str, "send_xon");
4917 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4918 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4920 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4921 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4922 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4923 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4924 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4925 mac_ctrl_frame_fwd_mode, "on#off");
4926 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4927 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4928 autoneg_str, "autoneg");
4929 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4930 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4932 cmdline_parse_token_num_t cmd_lfc_set_portid =
4933 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4936 /* forward declaration */
4938 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4941 cmdline_parse_inst_t cmd_link_flow_control_set = {
4942 .f = cmd_link_flow_ctrl_set_parsed,
4944 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4945 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4946 autoneg on|off port_id",
4948 (void *)&cmd_lfc_set_set,
4949 (void *)&cmd_lfc_set_flow_ctrl,
4950 (void *)&cmd_lfc_set_rx,
4951 (void *)&cmd_lfc_set_rx_mode,
4952 (void *)&cmd_lfc_set_tx,
4953 (void *)&cmd_lfc_set_tx_mode,
4954 (void *)&cmd_lfc_set_high_water,
4955 (void *)&cmd_lfc_set_low_water,
4956 (void *)&cmd_lfc_set_pause_time,
4957 (void *)&cmd_lfc_set_send_xon,
4958 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4959 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4960 (void *)&cmd_lfc_set_autoneg_str,
4961 (void *)&cmd_lfc_set_autoneg,
4962 (void *)&cmd_lfc_set_portid,
4967 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4968 .f = cmd_link_flow_ctrl_set_parsed,
4969 .data = (void *)&cmd_link_flow_control_set_rx,
4970 .help_str = "Change rx flow control parameter: set flow_ctrl "
4971 "rx on|off port_id",
4973 (void *)&cmd_lfc_set_set,
4974 (void *)&cmd_lfc_set_flow_ctrl,
4975 (void *)&cmd_lfc_set_rx,
4976 (void *)&cmd_lfc_set_rx_mode,
4977 (void *)&cmd_lfc_set_portid,
4982 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4983 .f = cmd_link_flow_ctrl_set_parsed,
4984 .data = (void *)&cmd_link_flow_control_set_tx,
4985 .help_str = "Change tx flow control parameter: set flow_ctrl "
4986 "tx on|off port_id",
4988 (void *)&cmd_lfc_set_set,
4989 (void *)&cmd_lfc_set_flow_ctrl,
4990 (void *)&cmd_lfc_set_tx,
4991 (void *)&cmd_lfc_set_tx_mode,
4992 (void *)&cmd_lfc_set_portid,
4997 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4998 .f = cmd_link_flow_ctrl_set_parsed,
4999 .data = (void *)&cmd_link_flow_control_set_hw,
5000 .help_str = "Change high water flow control parameter: set flow_ctrl "
5001 "high_water value port_id",
5003 (void *)&cmd_lfc_set_set,
5004 (void *)&cmd_lfc_set_flow_ctrl,
5005 (void *)&cmd_lfc_set_high_water_str,
5006 (void *)&cmd_lfc_set_high_water,
5007 (void *)&cmd_lfc_set_portid,
5012 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5013 .f = cmd_link_flow_ctrl_set_parsed,
5014 .data = (void *)&cmd_link_flow_control_set_lw,
5015 .help_str = "Change low water flow control parameter: set flow_ctrl "
5016 "low_water value port_id",
5018 (void *)&cmd_lfc_set_set,
5019 (void *)&cmd_lfc_set_flow_ctrl,
5020 (void *)&cmd_lfc_set_low_water_str,
5021 (void *)&cmd_lfc_set_low_water,
5022 (void *)&cmd_lfc_set_portid,
5027 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5028 .f = cmd_link_flow_ctrl_set_parsed,
5029 .data = (void *)&cmd_link_flow_control_set_pt,
5030 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5031 "pause_time value port_id",
5033 (void *)&cmd_lfc_set_set,
5034 (void *)&cmd_lfc_set_flow_ctrl,
5035 (void *)&cmd_lfc_set_pause_time_str,
5036 (void *)&cmd_lfc_set_pause_time,
5037 (void *)&cmd_lfc_set_portid,
5042 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5043 .f = cmd_link_flow_ctrl_set_parsed,
5044 .data = (void *)&cmd_link_flow_control_set_xon,
5045 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5046 "send_xon value port_id",
5048 (void *)&cmd_lfc_set_set,
5049 (void *)&cmd_lfc_set_flow_ctrl,
5050 (void *)&cmd_lfc_set_send_xon_str,
5051 (void *)&cmd_lfc_set_send_xon,
5052 (void *)&cmd_lfc_set_portid,
5057 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5058 .f = cmd_link_flow_ctrl_set_parsed,
5059 .data = (void *)&cmd_link_flow_control_set_macfwd,
5060 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5061 "mac_ctrl_frame_fwd on|off port_id",
5063 (void *)&cmd_lfc_set_set,
5064 (void *)&cmd_lfc_set_flow_ctrl,
5065 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5066 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5067 (void *)&cmd_lfc_set_portid,
5072 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5073 .f = cmd_link_flow_ctrl_set_parsed,
5074 .data = (void *)&cmd_link_flow_control_set_autoneg,
5075 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5076 "autoneg on|off port_id",
5078 (void *)&cmd_lfc_set_set,
5079 (void *)&cmd_lfc_set_flow_ctrl,
5080 (void *)&cmd_lfc_set_autoneg_str,
5081 (void *)&cmd_lfc_set_autoneg,
5082 (void *)&cmd_lfc_set_portid,
5088 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5089 __attribute__((unused)) struct cmdline *cl,
5092 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5093 cmdline_parse_inst_t *cmd = data;
5094 struct rte_eth_fc_conf fc_conf;
5095 int rx_fc_en, tx_fc_en;
5099 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5100 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5101 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5102 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5104 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5105 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5108 /* Partial command line, retrieve current configuration */
5110 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5112 printf("cannot get current flow ctrl parameters, return"
5113 "code = %d\n", ret);
5117 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5118 (fc_conf.mode == RTE_FC_FULL))
5120 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5121 (fc_conf.mode == RTE_FC_FULL))
5125 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5126 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5128 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5129 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5131 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5133 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5134 fc_conf.high_water = res->high_water;
5136 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5137 fc_conf.low_water = res->low_water;
5139 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5140 fc_conf.pause_time = res->pause_time;
5142 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5143 fc_conf.send_xon = res->send_xon;
5145 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5146 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5147 fc_conf.mac_ctrl_frame_fwd = 1;
5149 fc_conf.mac_ctrl_frame_fwd = 0;
5152 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5153 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5155 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5157 printf("bad flow contrl parameter, return code = %d \n", ret);
5160 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5161 struct cmd_priority_flow_ctrl_set_result {
5162 cmdline_fixed_string_t set;
5163 cmdline_fixed_string_t pfc_ctrl;
5164 cmdline_fixed_string_t rx;
5165 cmdline_fixed_string_t rx_pfc_mode;
5166 cmdline_fixed_string_t tx;
5167 cmdline_fixed_string_t tx_pfc_mode;
5168 uint32_t high_water;
5170 uint16_t pause_time;
5176 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5177 __attribute__((unused)) struct cmdline *cl,
5178 __attribute__((unused)) void *data)
5180 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5181 struct rte_eth_pfc_conf pfc_conf;
5182 int rx_fc_enable, tx_fc_enable;
5186 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5187 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5188 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5189 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5191 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5192 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5195 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5196 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5197 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5198 pfc_conf.fc.high_water = res->high_water;
5199 pfc_conf.fc.low_water = res->low_water;
5200 pfc_conf.fc.pause_time = res->pause_time;
5201 pfc_conf.priority = res->priority;
5203 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5205 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5208 cmdline_parse_token_string_t cmd_pfc_set_set =
5209 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5211 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5212 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5213 pfc_ctrl, "pfc_ctrl");
5214 cmdline_parse_token_string_t cmd_pfc_set_rx =
5215 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5217 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5218 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5219 rx_pfc_mode, "on#off");
5220 cmdline_parse_token_string_t cmd_pfc_set_tx =
5221 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5223 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5224 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5225 tx_pfc_mode, "on#off");
5226 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5227 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5228 high_water, UINT32);
5229 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5230 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5232 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5233 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5234 pause_time, UINT16);
5235 cmdline_parse_token_num_t cmd_pfc_set_priority =
5236 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5238 cmdline_parse_token_num_t cmd_pfc_set_portid =
5239 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5242 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5243 .f = cmd_priority_flow_ctrl_set_parsed,
5245 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5246 tx on|off high_water low_water pause_time priority port_id",
5248 (void *)&cmd_pfc_set_set,
5249 (void *)&cmd_pfc_set_flow_ctrl,
5250 (void *)&cmd_pfc_set_rx,
5251 (void *)&cmd_pfc_set_rx_mode,
5252 (void *)&cmd_pfc_set_tx,
5253 (void *)&cmd_pfc_set_tx_mode,
5254 (void *)&cmd_pfc_set_high_water,
5255 (void *)&cmd_pfc_set_low_water,
5256 (void *)&cmd_pfc_set_pause_time,
5257 (void *)&cmd_pfc_set_priority,
5258 (void *)&cmd_pfc_set_portid,
5263 /* *** RESET CONFIGURATION *** */
5264 struct cmd_reset_result {
5265 cmdline_fixed_string_t reset;
5266 cmdline_fixed_string_t def;
5269 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5271 __attribute__((unused)) void *data)
5273 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5274 set_def_fwd_config();
5277 cmdline_parse_token_string_t cmd_reset_set =
5278 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5279 cmdline_parse_token_string_t cmd_reset_def =
5280 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5283 cmdline_parse_inst_t cmd_reset = {
5284 .f = cmd_reset_parsed,
5286 .help_str = "set default: reset default forwarding configuration",
5288 (void *)&cmd_reset_set,
5289 (void *)&cmd_reset_def,
5294 /* *** START FORWARDING *** */
5295 struct cmd_start_result {
5296 cmdline_fixed_string_t start;
5299 cmdline_parse_token_string_t cmd_start_start =
5300 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5302 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5303 __attribute__((unused)) struct cmdline *cl,
5304 __attribute__((unused)) void *data)
5306 start_packet_forwarding(0);
5309 cmdline_parse_inst_t cmd_start = {
5310 .f = cmd_start_parsed,
5312 .help_str = "start packet forwarding",
5314 (void *)&cmd_start_start,
5319 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5320 struct cmd_start_tx_first_result {
5321 cmdline_fixed_string_t start;
5322 cmdline_fixed_string_t tx_first;
5326 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5327 __attribute__((unused)) struct cmdline *cl,
5328 __attribute__((unused)) void *data)
5330 start_packet_forwarding(1);
5333 cmdline_parse_token_string_t cmd_start_tx_first_start =
5334 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5336 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5337 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5338 tx_first, "tx_first");
5340 cmdline_parse_inst_t cmd_start_tx_first = {
5341 .f = cmd_start_tx_first_parsed,
5343 .help_str = "start packet forwarding, after sending 1 burst of packets",
5345 (void *)&cmd_start_tx_first_start,
5346 (void *)&cmd_start_tx_first_tx_first,
5351 /* *** SET LINK UP *** */
5352 struct cmd_set_link_up_result {
5353 cmdline_fixed_string_t set;
5354 cmdline_fixed_string_t link_up;
5355 cmdline_fixed_string_t port;
5359 cmdline_parse_token_string_t cmd_set_link_up_set =
5360 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5361 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5362 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5364 cmdline_parse_token_string_t cmd_set_link_up_port =
5365 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5366 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5367 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5369 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5370 __attribute__((unused)) struct cmdline *cl,
5371 __attribute__((unused)) void *data)
5373 struct cmd_set_link_up_result *res = parsed_result;
5374 dev_set_link_up(res->port_id);
5377 cmdline_parse_inst_t cmd_set_link_up = {
5378 .f = cmd_set_link_up_parsed,
5380 .help_str = "set link-up port (port id)",
5382 (void *)&cmd_set_link_up_set,
5383 (void *)&cmd_set_link_up_link_up,
5384 (void *)&cmd_set_link_up_port,
5385 (void *)&cmd_set_link_up_port_id,
5390 /* *** SET LINK DOWN *** */
5391 struct cmd_set_link_down_result {
5392 cmdline_fixed_string_t set;
5393 cmdline_fixed_string_t link_down;
5394 cmdline_fixed_string_t port;
5398 cmdline_parse_token_string_t cmd_set_link_down_set =
5399 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5400 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5401 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5403 cmdline_parse_token_string_t cmd_set_link_down_port =
5404 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5405 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5406 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5408 static void cmd_set_link_down_parsed(
5409 __attribute__((unused)) void *parsed_result,
5410 __attribute__((unused)) struct cmdline *cl,
5411 __attribute__((unused)) void *data)
5413 struct cmd_set_link_down_result *res = parsed_result;
5414 dev_set_link_down(res->port_id);
5417 cmdline_parse_inst_t cmd_set_link_down = {
5418 .f = cmd_set_link_down_parsed,
5420 .help_str = "set link-down port (port id)",
5422 (void *)&cmd_set_link_down_set,
5423 (void *)&cmd_set_link_down_link_down,
5424 (void *)&cmd_set_link_down_port,
5425 (void *)&cmd_set_link_down_port_id,
5430 /* *** SHOW CFG *** */
5431 struct cmd_showcfg_result {
5432 cmdline_fixed_string_t show;
5433 cmdline_fixed_string_t cfg;
5434 cmdline_fixed_string_t what;
5437 static void cmd_showcfg_parsed(void *parsed_result,
5438 __attribute__((unused)) struct cmdline *cl,
5439 __attribute__((unused)) void *data)
5441 struct cmd_showcfg_result *res = parsed_result;
5442 if (!strcmp(res->what, "rxtx"))
5443 rxtx_config_display();
5444 else if (!strcmp(res->what, "cores"))
5445 fwd_lcores_config_display();
5446 else if (!strcmp(res->what, "fwd"))
5447 fwd_config_display();
5450 cmdline_parse_token_string_t cmd_showcfg_show =
5451 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5452 cmdline_parse_token_string_t cmd_showcfg_port =
5453 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5454 cmdline_parse_token_string_t cmd_showcfg_what =
5455 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5458 cmdline_parse_inst_t cmd_showcfg = {
5459 .f = cmd_showcfg_parsed,
5461 .help_str = "show config rxtx|cores|fwd",
5463 (void *)&cmd_showcfg_show,
5464 (void *)&cmd_showcfg_port,
5465 (void *)&cmd_showcfg_what,
5470 /* *** SHOW ALL PORT INFO *** */
5471 struct cmd_showportall_result {
5472 cmdline_fixed_string_t show;
5473 cmdline_fixed_string_t port;
5474 cmdline_fixed_string_t what;
5475 cmdline_fixed_string_t all;
5478 static void cmd_showportall_parsed(void *parsed_result,
5479 __attribute__((unused)) struct cmdline *cl,
5480 __attribute__((unused)) void *data)
5484 struct cmd_showportall_result *res = parsed_result;
5485 if (!strcmp(res->show, "clear")) {
5486 if (!strcmp(res->what, "stats"))
5487 for (i = 0; i < nb_ports; i++)
5489 else if (!strcmp(res->what, "xstats"))
5490 for (i = 0; i < nb_ports; i++)
5491 nic_xstats_clear(i);
5492 } else if (!strcmp(res->what, "info"))
5493 for (i = 0; i < nb_ports; i++)
5494 port_infos_display(i);
5495 else if (!strcmp(res->what, "stats"))
5496 for (i = 0; i < nb_ports; i++)
5497 nic_stats_display(i);
5498 else if (!strcmp(res->what, "xstats"))
5499 for (i = 0; i < nb_ports; i++)
5500 nic_xstats_display(i);
5501 else if (!strcmp(res->what, "fdir"))
5502 for (i = 0; i < nb_ports; i++)
5504 else if (!strcmp(res->what, "stat_qmap"))
5505 for (i = 0; i < nb_ports; i++)
5506 nic_stats_mapping_display(i);
5509 cmdline_parse_token_string_t cmd_showportall_show =
5510 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5512 cmdline_parse_token_string_t cmd_showportall_port =
5513 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5514 cmdline_parse_token_string_t cmd_showportall_what =
5515 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5516 "info#stats#xstats#fdir#stat_qmap");
5517 cmdline_parse_token_string_t cmd_showportall_all =
5518 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5519 cmdline_parse_inst_t cmd_showportall = {
5520 .f = cmd_showportall_parsed,
5522 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5524 (void *)&cmd_showportall_show,
5525 (void *)&cmd_showportall_port,
5526 (void *)&cmd_showportall_what,
5527 (void *)&cmd_showportall_all,
5532 /* *** SHOW PORT INFO *** */
5533 struct cmd_showport_result {
5534 cmdline_fixed_string_t show;
5535 cmdline_fixed_string_t port;
5536 cmdline_fixed_string_t what;
5540 static void cmd_showport_parsed(void *parsed_result,
5541 __attribute__((unused)) struct cmdline *cl,
5542 __attribute__((unused)) void *data)
5544 struct cmd_showport_result *res = parsed_result;
5545 if (!strcmp(res->show, "clear")) {
5546 if (!strcmp(res->what, "stats"))
5547 nic_stats_clear(res->portnum);
5548 else if (!strcmp(res->what, "xstats"))
5549 nic_xstats_clear(res->portnum);
5550 } else if (!strcmp(res->what, "info"))
5551 port_infos_display(res->portnum);
5552 else if (!strcmp(res->what, "stats"))
5553 nic_stats_display(res->portnum);
5554 else if (!strcmp(res->what, "xstats"))
5555 nic_xstats_display(res->portnum);
5556 else if (!strcmp(res->what, "fdir"))
5557 fdir_get_infos(res->portnum);
5558 else if (!strcmp(res->what, "stat_qmap"))
5559 nic_stats_mapping_display(res->portnum);
5562 cmdline_parse_token_string_t cmd_showport_show =
5563 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5565 cmdline_parse_token_string_t cmd_showport_port =
5566 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5567 cmdline_parse_token_string_t cmd_showport_what =
5568 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5569 "info#stats#xstats#fdir#stat_qmap");
5570 cmdline_parse_token_num_t cmd_showport_portnum =
5571 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5573 cmdline_parse_inst_t cmd_showport = {
5574 .f = cmd_showport_parsed,
5576 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5578 (void *)&cmd_showport_show,
5579 (void *)&cmd_showport_port,
5580 (void *)&cmd_showport_what,
5581 (void *)&cmd_showport_portnum,
5586 /* *** READ PORT REGISTER *** */
5587 struct cmd_read_reg_result {
5588 cmdline_fixed_string_t read;
5589 cmdline_fixed_string_t reg;
5595 cmd_read_reg_parsed(void *parsed_result,
5596 __attribute__((unused)) struct cmdline *cl,
5597 __attribute__((unused)) void *data)
5599 struct cmd_read_reg_result *res = parsed_result;
5600 port_reg_display(res->port_id, res->reg_off);
5603 cmdline_parse_token_string_t cmd_read_reg_read =
5604 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5605 cmdline_parse_token_string_t cmd_read_reg_reg =
5606 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5607 cmdline_parse_token_num_t cmd_read_reg_port_id =
5608 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5609 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5610 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5612 cmdline_parse_inst_t cmd_read_reg = {
5613 .f = cmd_read_reg_parsed,
5615 .help_str = "read reg port_id reg_off",
5617 (void *)&cmd_read_reg_read,
5618 (void *)&cmd_read_reg_reg,
5619 (void *)&cmd_read_reg_port_id,
5620 (void *)&cmd_read_reg_reg_off,
5625 /* *** READ PORT REGISTER BIT FIELD *** */
5626 struct cmd_read_reg_bit_field_result {
5627 cmdline_fixed_string_t read;
5628 cmdline_fixed_string_t regfield;
5636 cmd_read_reg_bit_field_parsed(void *parsed_result,
5637 __attribute__((unused)) struct cmdline *cl,
5638 __attribute__((unused)) void *data)
5640 struct cmd_read_reg_bit_field_result *res = parsed_result;
5641 port_reg_bit_field_display(res->port_id, res->reg_off,
5642 res->bit1_pos, res->bit2_pos);
5645 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5646 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5648 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5649 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5650 regfield, "regfield");
5651 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5652 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5654 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5655 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5657 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5658 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5660 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5661 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5664 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5665 .f = cmd_read_reg_bit_field_parsed,
5667 .help_str = "read regfield port_id reg_off bit_x bit_y "
5668 "(read register bit field between bit_x and bit_y included)",
5670 (void *)&cmd_read_reg_bit_field_read,
5671 (void *)&cmd_read_reg_bit_field_regfield,
5672 (void *)&cmd_read_reg_bit_field_port_id,
5673 (void *)&cmd_read_reg_bit_field_reg_off,
5674 (void *)&cmd_read_reg_bit_field_bit1_pos,
5675 (void *)&cmd_read_reg_bit_field_bit2_pos,
5680 /* *** READ PORT REGISTER BIT *** */
5681 struct cmd_read_reg_bit_result {
5682 cmdline_fixed_string_t read;
5683 cmdline_fixed_string_t regbit;
5690 cmd_read_reg_bit_parsed(void *parsed_result,
5691 __attribute__((unused)) struct cmdline *cl,
5692 __attribute__((unused)) void *data)
5694 struct cmd_read_reg_bit_result *res = parsed_result;
5695 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5698 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5699 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5700 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5701 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5703 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5704 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5705 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5706 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5707 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5708 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5710 cmdline_parse_inst_t cmd_read_reg_bit = {
5711 .f = cmd_read_reg_bit_parsed,
5713 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5715 (void *)&cmd_read_reg_bit_read,
5716 (void *)&cmd_read_reg_bit_regbit,
5717 (void *)&cmd_read_reg_bit_port_id,
5718 (void *)&cmd_read_reg_bit_reg_off,
5719 (void *)&cmd_read_reg_bit_bit_pos,
5724 /* *** WRITE PORT REGISTER *** */
5725 struct cmd_write_reg_result {
5726 cmdline_fixed_string_t write;
5727 cmdline_fixed_string_t reg;
5734 cmd_write_reg_parsed(void *parsed_result,
5735 __attribute__((unused)) struct cmdline *cl,
5736 __attribute__((unused)) void *data)
5738 struct cmd_write_reg_result *res = parsed_result;
5739 port_reg_set(res->port_id, res->reg_off, res->value);
5742 cmdline_parse_token_string_t cmd_write_reg_write =
5743 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5744 cmdline_parse_token_string_t cmd_write_reg_reg =
5745 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5746 cmdline_parse_token_num_t cmd_write_reg_port_id =
5747 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5748 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5749 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5750 cmdline_parse_token_num_t cmd_write_reg_value =
5751 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5753 cmdline_parse_inst_t cmd_write_reg = {
5754 .f = cmd_write_reg_parsed,
5756 .help_str = "write reg port_id reg_off reg_value",
5758 (void *)&cmd_write_reg_write,
5759 (void *)&cmd_write_reg_reg,
5760 (void *)&cmd_write_reg_port_id,
5761 (void *)&cmd_write_reg_reg_off,
5762 (void *)&cmd_write_reg_value,
5767 /* *** WRITE PORT REGISTER BIT FIELD *** */
5768 struct cmd_write_reg_bit_field_result {
5769 cmdline_fixed_string_t write;
5770 cmdline_fixed_string_t regfield;
5779 cmd_write_reg_bit_field_parsed(void *parsed_result,
5780 __attribute__((unused)) struct cmdline *cl,
5781 __attribute__((unused)) void *data)
5783 struct cmd_write_reg_bit_field_result *res = parsed_result;
5784 port_reg_bit_field_set(res->port_id, res->reg_off,
5785 res->bit1_pos, res->bit2_pos, res->value);
5788 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5789 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5791 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5792 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5793 regfield, "regfield");
5794 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5795 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5797 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5798 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5800 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5801 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5803 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5804 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5806 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5807 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5810 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5811 .f = cmd_write_reg_bit_field_parsed,
5813 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5814 "(set register bit field between bit_x and bit_y included)",
5816 (void *)&cmd_write_reg_bit_field_write,
5817 (void *)&cmd_write_reg_bit_field_regfield,
5818 (void *)&cmd_write_reg_bit_field_port_id,
5819 (void *)&cmd_write_reg_bit_field_reg_off,
5820 (void *)&cmd_write_reg_bit_field_bit1_pos,
5821 (void *)&cmd_write_reg_bit_field_bit2_pos,
5822 (void *)&cmd_write_reg_bit_field_value,
5827 /* *** WRITE PORT REGISTER BIT *** */
5828 struct cmd_write_reg_bit_result {
5829 cmdline_fixed_string_t write;
5830 cmdline_fixed_string_t regbit;
5838 cmd_write_reg_bit_parsed(void *parsed_result,
5839 __attribute__((unused)) struct cmdline *cl,
5840 __attribute__((unused)) void *data)
5842 struct cmd_write_reg_bit_result *res = parsed_result;
5843 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5846 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5847 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5849 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5850 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5852 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5853 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5854 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5855 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5856 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5857 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5858 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5859 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5861 cmdline_parse_inst_t cmd_write_reg_bit = {
5862 .f = cmd_write_reg_bit_parsed,
5864 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5866 (void *)&cmd_write_reg_bit_write,
5867 (void *)&cmd_write_reg_bit_regbit,
5868 (void *)&cmd_write_reg_bit_port_id,
5869 (void *)&cmd_write_reg_bit_reg_off,
5870 (void *)&cmd_write_reg_bit_bit_pos,
5871 (void *)&cmd_write_reg_bit_value,
5876 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5877 struct cmd_read_rxd_txd_result {
5878 cmdline_fixed_string_t read;
5879 cmdline_fixed_string_t rxd_txd;
5886 cmd_read_rxd_txd_parsed(void *parsed_result,
5887 __attribute__((unused)) struct cmdline *cl,
5888 __attribute__((unused)) void *data)
5890 struct cmd_read_rxd_txd_result *res = parsed_result;
5892 if (!strcmp(res->rxd_txd, "rxd"))
5893 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5894 else if (!strcmp(res->rxd_txd, "txd"))
5895 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5898 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5899 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5900 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5901 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5903 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5904 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5905 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5906 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5907 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5908 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5910 cmdline_parse_inst_t cmd_read_rxd_txd = {
5911 .f = cmd_read_rxd_txd_parsed,
5913 .help_str = "read rxd|txd port_id queue_id rxd_id",
5915 (void *)&cmd_read_rxd_txd_read,
5916 (void *)&cmd_read_rxd_txd_rxd_txd,
5917 (void *)&cmd_read_rxd_txd_port_id,
5918 (void *)&cmd_read_rxd_txd_queue_id,
5919 (void *)&cmd_read_rxd_txd_desc_id,
5925 struct cmd_quit_result {
5926 cmdline_fixed_string_t quit;
5929 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5931 __attribute__((unused)) void *data)
5937 cmdline_parse_token_string_t cmd_quit_quit =
5938 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5940 cmdline_parse_inst_t cmd_quit = {
5941 .f = cmd_quit_parsed,
5943 .help_str = "exit application",
5945 (void *)&cmd_quit_quit,
5950 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5951 struct cmd_mac_addr_result {
5952 cmdline_fixed_string_t mac_addr_cmd;
5953 cmdline_fixed_string_t what;
5955 struct ether_addr address;
5958 static void cmd_mac_addr_parsed(void *parsed_result,
5959 __attribute__((unused)) struct cmdline *cl,
5960 __attribute__((unused)) void *data)
5962 struct cmd_mac_addr_result *res = parsed_result;
5965 if (strcmp(res->what, "add") == 0)
5966 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5968 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5970 /* check the return value and print it if is < 0 */
5972 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5976 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5977 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5979 cmdline_parse_token_string_t cmd_mac_addr_what =
5980 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5982 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5983 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5984 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5985 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5987 cmdline_parse_inst_t cmd_mac_addr = {
5988 .f = cmd_mac_addr_parsed,
5990 .help_str = "mac_addr add|remove X <address>: "
5991 "add/remove MAC address on port X",
5993 (void *)&cmd_mac_addr_cmd,
5994 (void *)&cmd_mac_addr_what,
5995 (void *)&cmd_mac_addr_portnum,
5996 (void *)&cmd_mac_addr_addr,
6002 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6003 struct cmd_set_qmap_result {
6004 cmdline_fixed_string_t set;
6005 cmdline_fixed_string_t qmap;
6006 cmdline_fixed_string_t what;
6013 cmd_set_qmap_parsed(void *parsed_result,
6014 __attribute__((unused)) struct cmdline *cl,
6015 __attribute__((unused)) void *data)
6017 struct cmd_set_qmap_result *res = parsed_result;
6018 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6020 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6023 cmdline_parse_token_string_t cmd_setqmap_set =
6024 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6026 cmdline_parse_token_string_t cmd_setqmap_qmap =
6027 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6029 cmdline_parse_token_string_t cmd_setqmap_what =
6030 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6032 cmdline_parse_token_num_t cmd_setqmap_portid =
6033 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6035 cmdline_parse_token_num_t cmd_setqmap_queueid =
6036 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6038 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6039 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6042 cmdline_parse_inst_t cmd_set_qmap = {
6043 .f = cmd_set_qmap_parsed,
6045 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6047 (void *)&cmd_setqmap_set,
6048 (void *)&cmd_setqmap_qmap,
6049 (void *)&cmd_setqmap_what,
6050 (void *)&cmd_setqmap_portid,
6051 (void *)&cmd_setqmap_queueid,
6052 (void *)&cmd_setqmap_mapvalue,
6057 /* *** CONFIGURE UNICAST HASH TABLE *** */
6058 struct cmd_set_uc_hash_table {
6059 cmdline_fixed_string_t set;
6060 cmdline_fixed_string_t port;
6062 cmdline_fixed_string_t what;
6063 struct ether_addr address;
6064 cmdline_fixed_string_t mode;
6068 cmd_set_uc_hash_parsed(void *parsed_result,
6069 __attribute__((unused)) struct cmdline *cl,
6070 __attribute__((unused)) void *data)
6073 struct cmd_set_uc_hash_table *res = parsed_result;
6075 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6077 if (strcmp(res->what, "uta") == 0)
6078 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6079 &res->address,(uint8_t)is_on);
6081 printf("bad unicast hash table parameter, return code = %d \n", ret);
6085 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6086 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6088 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6089 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6091 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6092 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6094 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6095 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6097 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6098 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6100 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6101 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6104 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6105 .f = cmd_set_uc_hash_parsed,
6107 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6109 (void *)&cmd_set_uc_hash_set,
6110 (void *)&cmd_set_uc_hash_port,
6111 (void *)&cmd_set_uc_hash_portid,
6112 (void *)&cmd_set_uc_hash_what,
6113 (void *)&cmd_set_uc_hash_mac,
6114 (void *)&cmd_set_uc_hash_mode,
6119 struct cmd_set_uc_all_hash_table {
6120 cmdline_fixed_string_t set;
6121 cmdline_fixed_string_t port;
6123 cmdline_fixed_string_t what;
6124 cmdline_fixed_string_t value;
6125 cmdline_fixed_string_t mode;
6129 cmd_set_uc_all_hash_parsed(void *parsed_result,
6130 __attribute__((unused)) struct cmdline *cl,
6131 __attribute__((unused)) void *data)
6134 struct cmd_set_uc_all_hash_table *res = parsed_result;
6136 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6138 if ((strcmp(res->what, "uta") == 0) &&
6139 (strcmp(res->value, "all") == 0))
6140 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6142 printf("bad unicast hash table parameter,"
6143 "return code = %d \n", ret);
6146 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6147 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6149 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6150 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6152 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6153 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6155 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6156 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6158 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6159 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6161 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6162 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6165 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6166 .f = cmd_set_uc_all_hash_parsed,
6168 .help_str = "set port X uta all on|off (X = port number)",
6170 (void *)&cmd_set_uc_all_hash_set,
6171 (void *)&cmd_set_uc_all_hash_port,
6172 (void *)&cmd_set_uc_all_hash_portid,
6173 (void *)&cmd_set_uc_all_hash_what,
6174 (void *)&cmd_set_uc_all_hash_value,
6175 (void *)&cmd_set_uc_all_hash_mode,
6180 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6181 struct cmd_set_vf_macvlan_filter {
6182 cmdline_fixed_string_t set;
6183 cmdline_fixed_string_t port;
6185 cmdline_fixed_string_t vf;
6187 struct ether_addr address;
6188 cmdline_fixed_string_t filter_type;
6189 cmdline_fixed_string_t mode;
6193 cmd_set_vf_macvlan_parsed(void *parsed_result,
6194 __attribute__((unused)) struct cmdline *cl,
6195 __attribute__((unused)) void *data)
6198 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6199 struct rte_eth_mac_filter filter;
6201 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6203 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6205 /* set VF MAC filter */
6209 filter.dst_id = res->vf_id;
6211 if (!strcmp(res->filter_type, "exact-mac"))
6212 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6213 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6214 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6215 else if (!strcmp(res->filter_type, "hashmac"))
6216 filter.filter_type = RTE_MAC_HASH_MATCH;
6217 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6218 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6220 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6223 ret = rte_eth_dev_filter_ctrl(res->port_id,
6224 RTE_ETH_FILTER_MACVLAN,
6228 ret = rte_eth_dev_filter_ctrl(res->port_id,
6229 RTE_ETH_FILTER_MACVLAN,
6230 RTE_ETH_FILTER_DELETE,
6234 printf("bad set MAC hash parameter, return code = %d\n", ret);
6238 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6239 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6241 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6242 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6244 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6245 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6247 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6248 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6250 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6251 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6253 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6254 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6256 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6257 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6258 filter_type, "exact-mac#exact-mac-vlan"
6259 "#hashmac#hashmac-vlan");
6260 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6261 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6264 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6265 .f = cmd_set_vf_macvlan_parsed,
6267 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6268 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6270 "exact match rule:exact match of MAC or MAC and VLAN; "
6271 "hash match rule: hash match of MAC and exact match "
6274 (void *)&cmd_set_vf_macvlan_set,
6275 (void *)&cmd_set_vf_macvlan_port,
6276 (void *)&cmd_set_vf_macvlan_portid,
6277 (void *)&cmd_set_vf_macvlan_vf,
6278 (void *)&cmd_set_vf_macvlan_vf_id,
6279 (void *)&cmd_set_vf_macvlan_mac,
6280 (void *)&cmd_set_vf_macvlan_filter_type,
6281 (void *)&cmd_set_vf_macvlan_mode,
6286 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6287 struct cmd_set_vf_traffic {
6288 cmdline_fixed_string_t set;
6289 cmdline_fixed_string_t port;
6291 cmdline_fixed_string_t vf;
6293 cmdline_fixed_string_t what;
6294 cmdline_fixed_string_t mode;
6298 cmd_set_vf_traffic_parsed(void *parsed_result,
6299 __attribute__((unused)) struct cmdline *cl,
6300 __attribute__((unused)) void *data)
6302 struct cmd_set_vf_traffic *res = parsed_result;
6303 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6304 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6306 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6309 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6310 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6312 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6313 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6315 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6316 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6318 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6319 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6321 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6322 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6324 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6325 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6327 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6328 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6331 cmdline_parse_inst_t cmd_set_vf_traffic = {
6332 .f = cmd_set_vf_traffic_parsed,
6334 .help_str = "set port X vf Y rx|tx on|off"
6335 "(X = port number,Y = vf id)",
6337 (void *)&cmd_setvf_traffic_set,
6338 (void *)&cmd_setvf_traffic_port,
6339 (void *)&cmd_setvf_traffic_portid,
6340 (void *)&cmd_setvf_traffic_vf,
6341 (void *)&cmd_setvf_traffic_vfid,
6342 (void *)&cmd_setvf_traffic_what,
6343 (void *)&cmd_setvf_traffic_mode,
6348 /* *** CONFIGURE VF RECEIVE MODE *** */
6349 struct cmd_set_vf_rxmode {
6350 cmdline_fixed_string_t set;
6351 cmdline_fixed_string_t port;
6353 cmdline_fixed_string_t vf;
6355 cmdline_fixed_string_t what;
6356 cmdline_fixed_string_t mode;
6357 cmdline_fixed_string_t on;
6361 cmd_set_vf_rxmode_parsed(void *parsed_result,
6362 __attribute__((unused)) struct cmdline *cl,
6363 __attribute__((unused)) void *data)
6366 uint16_t rx_mode = 0;
6367 struct cmd_set_vf_rxmode *res = parsed_result;
6369 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6370 if (!strcmp(res->what,"rxmode")) {
6371 if (!strcmp(res->mode, "AUPE"))
6372 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6373 else if (!strcmp(res->mode, "ROPE"))
6374 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6375 else if (!strcmp(res->mode, "BAM"))
6376 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6377 else if (!strncmp(res->mode, "MPE",3))
6378 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6381 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6383 printf("bad VF receive mode parameter, return code = %d \n",
6387 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6388 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6390 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6391 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6393 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6394 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6396 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6397 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6399 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6400 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6402 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6403 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6405 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6406 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6407 mode, "AUPE#ROPE#BAM#MPE");
6408 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6409 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6412 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6413 .f = cmd_set_vf_rxmode_parsed,
6415 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6417 (void *)&cmd_set_vf_rxmode_set,
6418 (void *)&cmd_set_vf_rxmode_port,
6419 (void *)&cmd_set_vf_rxmode_portid,
6420 (void *)&cmd_set_vf_rxmode_vf,
6421 (void *)&cmd_set_vf_rxmode_vfid,
6422 (void *)&cmd_set_vf_rxmode_what,
6423 (void *)&cmd_set_vf_rxmode_mode,
6424 (void *)&cmd_set_vf_rxmode_on,
6429 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6430 struct cmd_vf_mac_addr_result {
6431 cmdline_fixed_string_t mac_addr_cmd;
6432 cmdline_fixed_string_t what;
6433 cmdline_fixed_string_t port;
6435 cmdline_fixed_string_t vf;
6437 struct ether_addr address;
6440 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6441 __attribute__((unused)) struct cmdline *cl,
6442 __attribute__((unused)) void *data)
6444 struct cmd_vf_mac_addr_result *res = parsed_result;
6447 if (strcmp(res->what, "add") == 0)
6448 ret = rte_eth_dev_mac_addr_add(res->port_num,
6449 &res->address, res->vf_num);
6451 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6455 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6456 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6457 mac_addr_cmd,"mac_addr");
6458 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6459 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6461 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6462 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6464 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6465 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6467 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6468 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6470 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6471 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6473 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6474 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6477 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6478 .f = cmd_vf_mac_addr_parsed,
6480 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6481 "Y = VF number)add MAC address filtering for a VF on port X",
6483 (void *)&cmd_vf_mac_addr_cmd,
6484 (void *)&cmd_vf_mac_addr_what,
6485 (void *)&cmd_vf_mac_addr_port,
6486 (void *)&cmd_vf_mac_addr_portnum,
6487 (void *)&cmd_vf_mac_addr_vf,
6488 (void *)&cmd_vf_mac_addr_vfnum,
6489 (void *)&cmd_vf_mac_addr_addr,
6494 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6495 struct cmd_vf_rx_vlan_filter {
6496 cmdline_fixed_string_t rx_vlan;
6497 cmdline_fixed_string_t what;
6499 cmdline_fixed_string_t port;
6501 cmdline_fixed_string_t vf;
6506 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6507 __attribute__((unused)) struct cmdline *cl,
6508 __attribute__((unused)) void *data)
6510 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6512 if (!strcmp(res->what, "add"))
6513 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6515 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6518 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6519 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6520 rx_vlan, "rx_vlan");
6521 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6522 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6524 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6525 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6527 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6528 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6530 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6531 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6533 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6534 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6536 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6537 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6540 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6541 .f = cmd_vf_rx_vlan_filter_parsed,
6543 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6544 "Y = port number,Z = hexadecimal VF mask)",
6546 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6547 (void *)&cmd_vf_rx_vlan_filter_what,
6548 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6549 (void *)&cmd_vf_rx_vlan_filter_port,
6550 (void *)&cmd_vf_rx_vlan_filter_portid,
6551 (void *)&cmd_vf_rx_vlan_filter_vf,
6552 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6557 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6558 struct cmd_queue_rate_limit_result {
6559 cmdline_fixed_string_t set;
6560 cmdline_fixed_string_t port;
6562 cmdline_fixed_string_t queue;
6564 cmdline_fixed_string_t rate;
6568 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6569 __attribute__((unused)) struct cmdline *cl,
6570 __attribute__((unused)) void *data)
6572 struct cmd_queue_rate_limit_result *res = parsed_result;
6575 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6576 && (strcmp(res->queue, "queue") == 0)
6577 && (strcmp(res->rate, "rate") == 0))
6578 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6581 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6585 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6586 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6588 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6589 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6591 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6592 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6594 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6595 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6597 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6598 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6600 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6601 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6603 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6604 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6607 cmdline_parse_inst_t cmd_queue_rate_limit = {
6608 .f = cmd_queue_rate_limit_parsed,
6610 .help_str = "set port X queue Y rate Z:(X = port number,"
6611 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6613 (void *)&cmd_queue_rate_limit_set,
6614 (void *)&cmd_queue_rate_limit_port,
6615 (void *)&cmd_queue_rate_limit_portnum,
6616 (void *)&cmd_queue_rate_limit_queue,
6617 (void *)&cmd_queue_rate_limit_queuenum,
6618 (void *)&cmd_queue_rate_limit_rate,
6619 (void *)&cmd_queue_rate_limit_ratenum,
6624 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6625 struct cmd_vf_rate_limit_result {
6626 cmdline_fixed_string_t set;
6627 cmdline_fixed_string_t port;
6629 cmdline_fixed_string_t vf;
6631 cmdline_fixed_string_t rate;
6633 cmdline_fixed_string_t q_msk;
6637 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6638 __attribute__((unused)) struct cmdline *cl,
6639 __attribute__((unused)) void *data)
6641 struct cmd_vf_rate_limit_result *res = parsed_result;
6644 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6645 && (strcmp(res->vf, "vf") == 0)
6646 && (strcmp(res->rate, "rate") == 0)
6647 && (strcmp(res->q_msk, "queue_mask") == 0))
6648 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6649 res->rate_num, res->q_msk_val);
6651 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6655 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6656 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6658 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6659 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6661 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6662 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6664 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6665 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6667 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6668 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6670 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6671 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6673 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6674 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6676 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6677 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6678 q_msk, "queue_mask");
6679 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6680 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6683 cmdline_parse_inst_t cmd_vf_rate_limit = {
6684 .f = cmd_vf_rate_limit_parsed,
6686 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6687 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6688 "for queues of VF on port X",
6690 (void *)&cmd_vf_rate_limit_set,
6691 (void *)&cmd_vf_rate_limit_port,
6692 (void *)&cmd_vf_rate_limit_portnum,
6693 (void *)&cmd_vf_rate_limit_vf,
6694 (void *)&cmd_vf_rate_limit_vfnum,
6695 (void *)&cmd_vf_rate_limit_rate,
6696 (void *)&cmd_vf_rate_limit_ratenum,
6697 (void *)&cmd_vf_rate_limit_q_msk,
6698 (void *)&cmd_vf_rate_limit_q_msk_val,
6703 /* *** ADD TUNNEL FILTER OF A PORT *** */
6704 struct cmd_tunnel_filter_result {
6705 cmdline_fixed_string_t cmd;
6706 cmdline_fixed_string_t what;
6708 struct ether_addr outer_mac;
6709 struct ether_addr inner_mac;
6710 cmdline_ipaddr_t ip_value;
6711 uint16_t inner_vlan;
6712 cmdline_fixed_string_t tunnel_type;
6713 cmdline_fixed_string_t filter_type;
6719 cmd_tunnel_filter_parsed(void *parsed_result,
6720 __attribute__((unused)) struct cmdline *cl,
6721 __attribute__((unused)) void *data)
6723 struct cmd_tunnel_filter_result *res = parsed_result;
6724 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6727 tunnel_filter_conf.outer_mac = &res->outer_mac;
6728 tunnel_filter_conf.inner_mac = &res->inner_mac;
6729 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6731 if (res->ip_value.family == AF_INET) {
6732 tunnel_filter_conf.ip_addr.ipv4_addr =
6733 res->ip_value.addr.ipv4.s_addr;
6734 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6736 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6737 &(res->ip_value.addr.ipv6),
6738 sizeof(struct in6_addr));
6739 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6742 if (!strcmp(res->filter_type, "imac-ivlan"))
6743 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6744 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6745 tunnel_filter_conf.filter_type =
6746 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6747 else if (!strcmp(res->filter_type, "imac-tenid"))
6748 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6749 else if (!strcmp(res->filter_type, "imac"))
6750 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6751 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6752 tunnel_filter_conf.filter_type =
6753 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6755 printf("The filter type is not supported");
6759 if (!strcmp(res->tunnel_type, "vxlan"))
6760 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6762 printf("Only VXLAN is supported now.\n");
6766 tunnel_filter_conf.tenant_id = res->tenant_id;
6767 tunnel_filter_conf.queue_id = res->queue_num;
6768 if (!strcmp(res->what, "add"))
6769 ret = rte_eth_dev_filter_ctrl(res->port_id,
6770 RTE_ETH_FILTER_TUNNEL,
6772 &tunnel_filter_conf);
6774 ret = rte_eth_dev_filter_ctrl(res->port_id,
6775 RTE_ETH_FILTER_TUNNEL,
6776 RTE_ETH_FILTER_DELETE,
6777 &tunnel_filter_conf);
6779 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6783 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6784 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6785 cmd, "tunnel_filter");
6786 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6787 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6789 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6790 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6792 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6793 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6795 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6796 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6798 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6799 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6800 inner_vlan, UINT16);
6801 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6802 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6804 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6805 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6806 tunnel_type, "vxlan");
6808 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6809 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6810 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6811 "imac#omac-imac-tenid");
6812 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6813 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6815 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6816 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6819 cmdline_parse_inst_t cmd_tunnel_filter = {
6820 .f = cmd_tunnel_filter_parsed,
6822 .help_str = "add/rm tunnel filter of a port: "
6823 "tunnel_filter add port_id outer_mac inner_mac ip "
6824 "inner_vlan tunnel_type(vxlan) filter_type "
6825 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6826 "imac|omac-imac-tenid) "
6827 "tenant_id queue_num",
6829 (void *)&cmd_tunnel_filter_cmd,
6830 (void *)&cmd_tunnel_filter_what,
6831 (void *)&cmd_tunnel_filter_port_id,
6832 (void *)&cmd_tunnel_filter_outer_mac,
6833 (void *)&cmd_tunnel_filter_inner_mac,
6834 (void *)&cmd_tunnel_filter_ip_value,
6835 (void *)&cmd_tunnel_filter_innner_vlan,
6836 (void *)&cmd_tunnel_filter_tunnel_type,
6837 (void *)&cmd_tunnel_filter_filter_type,
6838 (void *)&cmd_tunnel_filter_tenant_id,
6839 (void *)&cmd_tunnel_filter_queue_num,
6844 /* *** CONFIGURE TUNNEL UDP PORT *** */
6845 struct cmd_tunnel_udp_config {
6846 cmdline_fixed_string_t cmd;
6847 cmdline_fixed_string_t what;
6853 cmd_tunnel_udp_config_parsed(void *parsed_result,
6854 __attribute__((unused)) struct cmdline *cl,
6855 __attribute__((unused)) void *data)
6857 struct cmd_tunnel_udp_config *res = parsed_result;
6858 struct rte_eth_udp_tunnel tunnel_udp;
6861 tunnel_udp.udp_port = res->udp_port;
6863 if (!strcmp(res->cmd, "rx_vxlan_port"))
6864 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6866 if (!strcmp(res->what, "add"))
6867 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6869 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6872 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6875 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6876 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6877 cmd, "rx_vxlan_port");
6878 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6879 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6881 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6882 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6884 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6885 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6888 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6889 .f = cmd_tunnel_udp_config_parsed,
6891 .help_str = "add/rm an tunneling UDP port filter: "
6892 "rx_vxlan_port add udp_port port_id",
6894 (void *)&cmd_tunnel_udp_config_cmd,
6895 (void *)&cmd_tunnel_udp_config_what,
6896 (void *)&cmd_tunnel_udp_config_udp_port,
6897 (void *)&cmd_tunnel_udp_config_port_id,
6902 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6903 struct cmd_set_mirror_mask_result {
6904 cmdline_fixed_string_t set;
6905 cmdline_fixed_string_t port;
6907 cmdline_fixed_string_t mirror;
6909 cmdline_fixed_string_t what;
6910 cmdline_fixed_string_t value;
6911 cmdline_fixed_string_t dstpool;
6913 cmdline_fixed_string_t on;
6916 cmdline_parse_token_string_t cmd_mirror_mask_set =
6917 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6919 cmdline_parse_token_string_t cmd_mirror_mask_port =
6920 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6922 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6923 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6925 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6926 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6927 mirror, "mirror-rule");
6928 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6929 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6931 cmdline_parse_token_string_t cmd_mirror_mask_what =
6932 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6933 what, "pool-mirror#vlan-mirror");
6934 cmdline_parse_token_string_t cmd_mirror_mask_value =
6935 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6937 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6938 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6939 dstpool, "dst-pool");
6940 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6941 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6943 cmdline_parse_token_string_t cmd_mirror_mask_on =
6944 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6948 cmd_set_mirror_mask_parsed(void *parsed_result,
6949 __attribute__((unused)) struct cmdline *cl,
6950 __attribute__((unused)) void *data)
6953 struct cmd_set_mirror_mask_result *res = parsed_result;
6954 struct rte_eth_vmdq_mirror_conf mr_conf;
6956 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6958 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6960 mr_conf.dst_pool = res->dstpool_id;
6962 if (!strcmp(res->what, "pool-mirror")) {
6963 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6964 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6965 } else if(!strcmp(res->what, "vlan-mirror")) {
6966 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6967 nb_item = parse_item_list(res->value, "core",
6968 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6972 for(i=0; i < nb_item; i++) {
6973 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6974 printf("Invalid vlan_id: must be < 4096\n");
6978 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6979 mr_conf.vlan.vlan_mask |= 1ULL << i;
6983 if(!strcmp(res->on, "on"))
6984 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6987 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6990 printf("mirror rule add error: (%s)\n", strerror(-ret));
6993 cmdline_parse_inst_t cmd_set_mirror_mask = {
6994 .f = cmd_set_mirror_mask_parsed,
6996 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6997 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6999 (void *)&cmd_mirror_mask_set,
7000 (void *)&cmd_mirror_mask_port,
7001 (void *)&cmd_mirror_mask_portid,
7002 (void *)&cmd_mirror_mask_mirror,
7003 (void *)&cmd_mirror_mask_ruleid,
7004 (void *)&cmd_mirror_mask_what,
7005 (void *)&cmd_mirror_mask_value,
7006 (void *)&cmd_mirror_mask_dstpool,
7007 (void *)&cmd_mirror_mask_poolid,
7008 (void *)&cmd_mirror_mask_on,
7013 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7014 struct cmd_set_mirror_link_result {
7015 cmdline_fixed_string_t set;
7016 cmdline_fixed_string_t port;
7018 cmdline_fixed_string_t mirror;
7020 cmdline_fixed_string_t what;
7021 cmdline_fixed_string_t dstpool;
7023 cmdline_fixed_string_t on;
7026 cmdline_parse_token_string_t cmd_mirror_link_set =
7027 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7029 cmdline_parse_token_string_t cmd_mirror_link_port =
7030 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7032 cmdline_parse_token_num_t cmd_mirror_link_portid =
7033 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7035 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7036 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7037 mirror, "mirror-rule");
7038 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7039 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7041 cmdline_parse_token_string_t cmd_mirror_link_what =
7042 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7043 what, "uplink-mirror#downlink-mirror");
7044 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7045 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7046 dstpool, "dst-pool");
7047 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7048 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7050 cmdline_parse_token_string_t cmd_mirror_link_on =
7051 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7055 cmd_set_mirror_link_parsed(void *parsed_result,
7056 __attribute__((unused)) struct cmdline *cl,
7057 __attribute__((unused)) void *data)
7060 struct cmd_set_mirror_link_result *res = parsed_result;
7061 struct rte_eth_vmdq_mirror_conf mr_conf;
7063 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
7064 if(!strcmp(res->what, "uplink-mirror")) {
7065 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
7066 }else if(!strcmp(res->what, "downlink-mirror"))
7067 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
7069 mr_conf.dst_pool = res->dstpool_id;
7071 if(!strcmp(res->on, "on"))
7072 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7075 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7078 /* check the return value and print it if is < 0 */
7080 printf("mirror rule add error: (%s)\n", strerror(-ret));
7084 cmdline_parse_inst_t cmd_set_mirror_link = {
7085 .f = cmd_set_mirror_link_parsed,
7087 .help_str = "set port X mirror-rule Y uplink-mirror|"
7088 "downlink-mirror dst-pool Z on|off",
7090 (void *)&cmd_mirror_link_set,
7091 (void *)&cmd_mirror_link_port,
7092 (void *)&cmd_mirror_link_portid,
7093 (void *)&cmd_mirror_link_mirror,
7094 (void *)&cmd_mirror_link_ruleid,
7095 (void *)&cmd_mirror_link_what,
7096 (void *)&cmd_mirror_link_dstpool,
7097 (void *)&cmd_mirror_link_poolid,
7098 (void *)&cmd_mirror_link_on,
7103 /* *** RESET VM MIRROR RULE *** */
7104 struct cmd_rm_mirror_rule_result {
7105 cmdline_fixed_string_t reset;
7106 cmdline_fixed_string_t port;
7108 cmdline_fixed_string_t mirror;
7112 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7113 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7115 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7116 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7118 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7119 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7121 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7122 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7123 mirror, "mirror-rule");
7124 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7125 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7129 cmd_reset_mirror_rule_parsed(void *parsed_result,
7130 __attribute__((unused)) struct cmdline *cl,
7131 __attribute__((unused)) void *data)
7134 struct cmd_set_mirror_link_result *res = parsed_result;
7136 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7138 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7141 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7142 .f = cmd_reset_mirror_rule_parsed,
7144 .help_str = "reset port X mirror-rule Y",
7146 (void *)&cmd_rm_mirror_rule_reset,
7147 (void *)&cmd_rm_mirror_rule_port,
7148 (void *)&cmd_rm_mirror_rule_portid,
7149 (void *)&cmd_rm_mirror_rule_mirror,
7150 (void *)&cmd_rm_mirror_rule_ruleid,
7155 /* ******************************************************************************** */
7157 struct cmd_dump_result {
7158 cmdline_fixed_string_t dump;
7162 dump_struct_sizes(void)
7164 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7165 DUMP_SIZE(struct rte_mbuf);
7166 DUMP_SIZE(struct rte_mempool);
7167 DUMP_SIZE(struct rte_ring);
7171 static void cmd_dump_parsed(void *parsed_result,
7172 __attribute__((unused)) struct cmdline *cl,
7173 __attribute__((unused)) void *data)
7175 struct cmd_dump_result *res = parsed_result;
7177 if (!strcmp(res->dump, "dump_physmem"))
7178 rte_dump_physmem_layout(stdout);
7179 else if (!strcmp(res->dump, "dump_memzone"))
7180 rte_memzone_dump(stdout);
7181 else if (!strcmp(res->dump, "dump_log_history"))
7182 rte_log_dump_history(stdout);
7183 else if (!strcmp(res->dump, "dump_struct_sizes"))
7184 dump_struct_sizes();
7185 else if (!strcmp(res->dump, "dump_ring"))
7186 rte_ring_list_dump(stdout);
7187 else if (!strcmp(res->dump, "dump_mempool"))
7188 rte_mempool_list_dump(stdout);
7189 else if (!strcmp(res->dump, "dump_devargs"))
7190 rte_eal_devargs_dump(stdout);
7193 cmdline_parse_token_string_t cmd_dump_dump =
7194 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7198 "dump_struct_sizes#"
7203 cmdline_parse_inst_t cmd_dump = {
7204 .f = cmd_dump_parsed, /* function to call */
7205 .data = NULL, /* 2nd arg of func */
7206 .help_str = "dump status",
7207 .tokens = { /* token list, NULL terminated */
7208 (void *)&cmd_dump_dump,
7213 /* ******************************************************************************** */
7215 struct cmd_dump_one_result {
7216 cmdline_fixed_string_t dump;
7217 cmdline_fixed_string_t name;
7220 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7221 __attribute__((unused)) void *data)
7223 struct cmd_dump_one_result *res = parsed_result;
7225 if (!strcmp(res->dump, "dump_ring")) {
7227 r = rte_ring_lookup(res->name);
7229 cmdline_printf(cl, "Cannot find ring\n");
7232 rte_ring_dump(stdout, r);
7233 } else if (!strcmp(res->dump, "dump_mempool")) {
7234 struct rte_mempool *mp;
7235 mp = rte_mempool_lookup(res->name);
7237 cmdline_printf(cl, "Cannot find mempool\n");
7240 rte_mempool_dump(stdout, mp);
7244 cmdline_parse_token_string_t cmd_dump_one_dump =
7245 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7246 "dump_ring#dump_mempool");
7248 cmdline_parse_token_string_t cmd_dump_one_name =
7249 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7251 cmdline_parse_inst_t cmd_dump_one = {
7252 .f = cmd_dump_one_parsed, /* function to call */
7253 .data = NULL, /* 2nd arg of func */
7254 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7255 .tokens = { /* token list, NULL terminated */
7256 (void *)&cmd_dump_one_dump,
7257 (void *)&cmd_dump_one_name,
7262 /* *** set SYN filter *** */
7263 struct cmd_set_syn_filter_result {
7264 cmdline_fixed_string_t filter;
7266 cmdline_fixed_string_t priority;
7267 cmdline_fixed_string_t high;
7268 cmdline_fixed_string_t queue;
7273 cmd_set_syn_filter_parsed(void *parsed_result,
7274 __attribute__((unused)) struct cmdline *cl,
7275 __attribute__((unused)) void *data)
7278 struct cmd_set_syn_filter_result *res = parsed_result;
7279 struct rte_syn_filter filter;
7281 if (!strcmp(res->filter, "add_syn_filter")) {
7282 if (!strcmp(res->high, "high"))
7286 ret = rte_eth_dev_add_syn_filter(res->port_id,
7287 &filter, res->queue_id);
7288 } else if (!strcmp(res->filter, "remove_syn_filter"))
7289 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7290 else if (!strcmp(res->filter, "get_syn_filter"))
7291 get_syn_filter(res->port_id);
7293 printf("syn filter setting error: (%s)\n", strerror(-ret));
7296 cmdline_parse_token_num_t cmd_syn_filter_portid =
7297 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7299 cmdline_parse_token_string_t cmd_syn_filter_priority =
7300 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7301 priority, "priority");
7302 cmdline_parse_token_string_t cmd_syn_filter_high =
7303 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7305 cmdline_parse_token_string_t cmd_syn_filter_queue =
7306 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7308 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7309 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7311 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7312 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7313 filter, "add_syn_filter");
7314 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7315 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7316 filter, "remove_syn_filter");
7317 cmdline_parse_inst_t cmd_add_syn_filter = {
7318 .f = cmd_set_syn_filter_parsed,
7320 .help_str = "add syn filter",
7322 (void *)&cmd_syn_filter_add_filter,
7323 (void *)&cmd_syn_filter_portid,
7324 (void *)&cmd_syn_filter_priority,
7325 (void *)&cmd_syn_filter_high,
7326 (void *)&cmd_syn_filter_queue,
7327 (void *)&cmd_syn_filter_queue_id,
7331 cmdline_parse_inst_t cmd_remove_syn_filter = {
7332 .f = cmd_set_syn_filter_parsed,
7334 .help_str = "remove syn filter",
7336 (void *)&cmd_syn_filter_remove_filter,
7337 (void *)&cmd_syn_filter_portid,
7342 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7343 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7344 filter, "get_syn_filter");
7346 cmdline_parse_inst_t cmd_get_syn_filter = {
7347 .f = cmd_set_syn_filter_parsed,
7349 .help_str = "get syn filter",
7351 (void *)&cmd_syn_filter_get_filter,
7352 (void *)&cmd_syn_filter_portid,
7357 /* *** ADD/REMOVE A 2tuple FILTER *** */
7358 struct cmd_2tuple_filter_result {
7359 cmdline_fixed_string_t filter;
7361 cmdline_fixed_string_t protocol;
7362 uint8_t protocol_value;
7363 uint8_t protocol_mask;
7364 cmdline_fixed_string_t dst_port;
7365 uint16_t dst_port_value;
7366 uint16_t dst_port_mask;
7367 cmdline_fixed_string_t flags;
7368 uint8_t flags_value;
7369 cmdline_fixed_string_t priority;
7370 uint8_t priority_value;
7371 cmdline_fixed_string_t queue;
7373 cmdline_fixed_string_t index;
7374 uint16_t index_value;
7378 cmd_2tuple_filter_parsed(void *parsed_result,
7379 __attribute__((unused)) struct cmdline *cl,
7380 __attribute__((unused)) void *data)
7383 struct rte_2tuple_filter filter;
7384 struct cmd_2tuple_filter_result *res = parsed_result;
7386 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7388 if (!strcmp(res->filter, "add_2tuple_filter")) {
7389 /* need convert to big endian. */
7390 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7391 filter.protocol = res->protocol_value;
7392 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7393 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7394 filter.priority = res->priority_value;
7395 filter.tcp_flags = res->flags_value;
7396 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7397 res->index_value, &filter, res->queue_id);
7398 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7399 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7401 else if (!strcmp(res->filter, "get_2tuple_filter"))
7402 get_2tuple_filter(res->port_id, res->index_value);
7405 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7408 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7409 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7411 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7412 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7413 protocol, "protocol");
7414 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7415 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7416 protocol_value, UINT8);
7417 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7418 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7419 protocol_mask, UINT8);
7420 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7421 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7422 dst_port, "dst_port");
7423 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7424 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7425 dst_port_value, UINT16);
7426 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7427 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7428 dst_port_mask, UINT16);
7429 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7430 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7432 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7433 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7434 flags_value, UINT8);
7435 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7436 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7437 priority, "priority");
7438 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7439 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7440 priority_value, UINT8);
7441 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7442 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7444 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7445 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7447 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7448 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7450 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7451 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7452 index_value, UINT16);
7453 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7454 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7455 filter, "add_2tuple_filter");
7456 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7457 .f = cmd_2tuple_filter_parsed,
7459 .help_str = "add a 2tuple filter",
7461 (void *)&cmd_2tuple_filter_add_filter,
7462 (void *)&cmd_2tuple_filter_port_id,
7463 (void *)&cmd_2tuple_filter_protocol,
7464 (void *)&cmd_2tuple_filter_protocol_value,
7465 (void *)&cmd_2tuple_filter_protocol_mask,
7466 (void *)&cmd_2tuple_filter_dst_port,
7467 (void *)&cmd_2tuple_filter_dst_port_value,
7468 (void *)&cmd_2tuple_filter_dst_port_mask,
7469 (void *)&cmd_2tuple_filter_flags,
7470 (void *)&cmd_2tuple_filter_flags_value,
7471 (void *)&cmd_2tuple_filter_priority,
7472 (void *)&cmd_2tuple_filter_priority_value,
7473 (void *)&cmd_2tuple_filter_queue,
7474 (void *)&cmd_2tuple_filter_queue_id,
7475 (void *)&cmd_2tuple_filter_index,
7476 (void *)&cmd_2tuple_filter_index_value,
7481 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7482 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7483 filter, "remove_2tuple_filter");
7484 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7485 .f = cmd_2tuple_filter_parsed,
7487 .help_str = "remove a 2tuple filter",
7489 (void *)&cmd_2tuple_filter_remove_filter,
7490 (void *)&cmd_2tuple_filter_port_id,
7491 (void *)&cmd_2tuple_filter_index,
7492 (void *)&cmd_2tuple_filter_index_value,
7496 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7497 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7498 filter, "get_2tuple_filter");
7499 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7500 .f = cmd_2tuple_filter_parsed,
7502 .help_str = "get a 2tuple filter",
7504 (void *)&cmd_2tuple_filter_get_filter,
7505 (void *)&cmd_2tuple_filter_port_id,
7506 (void *)&cmd_2tuple_filter_index,
7507 (void *)&cmd_2tuple_filter_index_value,
7512 /* *** ADD/REMOVE A 5tuple FILTER *** */
7513 struct cmd_5tuple_filter_result {
7514 cmdline_fixed_string_t filter;
7516 cmdline_fixed_string_t dst_ip;
7517 cmdline_ipaddr_t dst_ip_value;
7518 cmdline_fixed_string_t src_ip;
7519 cmdline_ipaddr_t src_ip_value;
7520 cmdline_fixed_string_t dst_port;
7521 uint16_t dst_port_value;
7522 cmdline_fixed_string_t src_port;
7523 uint16_t src_port_value;
7524 cmdline_fixed_string_t protocol;
7525 uint8_t protocol_value;
7526 cmdline_fixed_string_t mask;
7528 cmdline_fixed_string_t flags;
7529 uint8_t flags_value;
7530 cmdline_fixed_string_t priority;
7531 uint8_t priority_value;
7532 cmdline_fixed_string_t queue;
7534 cmdline_fixed_string_t index;
7535 uint16_t index_value;
7539 cmd_5tuple_filter_parsed(void *parsed_result,
7540 __attribute__((unused)) struct cmdline *cl,
7541 __attribute__((unused)) void *data)
7544 struct rte_5tuple_filter filter;
7545 struct cmd_5tuple_filter_result *res = parsed_result;
7547 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7549 if (!strcmp(res->filter, "add_5tuple_filter")) {
7550 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7551 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7552 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7553 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7554 filter.protocol = res->protocol_value;
7555 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7556 filter.priority = res->priority_value;
7557 filter.tcp_flags = res->flags_value;
7559 if (res->dst_ip_value.family == AF_INET)
7560 /* no need to convert, already big endian. */
7561 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7563 if (filter.dst_ip_mask == 0) {
7564 printf("can not support ipv6 involved compare.\n");
7570 if (res->src_ip_value.family == AF_INET)
7571 /* no need to convert, already big endian. */
7572 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7574 if (filter.src_ip_mask == 0) {
7575 printf("can not support ipv6 involved compare.\n");
7580 /* need convert to big endian. */
7581 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7582 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7584 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7585 res->index_value, &filter, res->queue_id);
7586 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7587 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7589 else if (!strcmp(res->filter, "get_5tuple_filter"))
7590 get_5tuple_filter(res->port_id, res->index_value);
7592 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7596 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7597 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7599 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7600 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7602 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7603 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7605 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7606 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7608 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7609 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7611 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7612 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7613 dst_port, "dst_port");
7614 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7615 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7616 dst_port_value, UINT16);
7617 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7618 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7619 src_port, "src_port");
7620 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7621 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7622 src_port_value, UINT16);
7623 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7624 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7625 protocol, "protocol");
7626 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7627 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7628 protocol_value, UINT8);
7629 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7630 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7632 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7633 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7635 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7636 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7638 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7639 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7640 flags_value, UINT8);
7641 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7642 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7643 priority, "priority");
7644 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7645 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7646 priority_value, UINT8);
7647 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7648 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7650 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7651 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7653 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7654 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7656 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7657 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7658 index_value, UINT16);
7660 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7661 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7662 filter, "add_5tuple_filter");
7663 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7664 .f = cmd_5tuple_filter_parsed,
7666 .help_str = "add a 5tuple filter",
7668 (void *)&cmd_5tuple_filter_add_filter,
7669 (void *)&cmd_5tuple_filter_port_id,
7670 (void *)&cmd_5tuple_filter_dst_ip,
7671 (void *)&cmd_5tuple_filter_dst_ip_value,
7672 (void *)&cmd_5tuple_filter_src_ip,
7673 (void *)&cmd_5tuple_filter_src_ip_value,
7674 (void *)&cmd_5tuple_filter_dst_port,
7675 (void *)&cmd_5tuple_filter_dst_port_value,
7676 (void *)&cmd_5tuple_filter_src_port,
7677 (void *)&cmd_5tuple_filter_src_port_value,
7678 (void *)&cmd_5tuple_filter_protocol,
7679 (void *)&cmd_5tuple_filter_protocol_value,
7680 (void *)&cmd_5tuple_filter_mask,
7681 (void *)&cmd_5tuple_filter_mask_value,
7682 (void *)&cmd_5tuple_filter_flags,
7683 (void *)&cmd_5tuple_filter_flags_value,
7684 (void *)&cmd_5tuple_filter_priority,
7685 (void *)&cmd_5tuple_filter_priority_value,
7686 (void *)&cmd_5tuple_filter_queue,
7687 (void *)&cmd_5tuple_filter_queue_id,
7688 (void *)&cmd_5tuple_filter_index,
7689 (void *)&cmd_5tuple_filter_index_value,
7694 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7695 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7696 filter, "remove_5tuple_filter");
7697 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7698 .f = cmd_5tuple_filter_parsed,
7700 .help_str = "remove a 5tuple filter",
7702 (void *)&cmd_5tuple_filter_remove_filter,
7703 (void *)&cmd_5tuple_filter_port_id,
7704 (void *)&cmd_5tuple_filter_index,
7705 (void *)&cmd_5tuple_filter_index_value,
7710 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7711 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7712 filter, "get_5tuple_filter");
7713 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7714 .f = cmd_5tuple_filter_parsed,
7716 .help_str = "get a 5tuple filter",
7718 (void *)&cmd_5tuple_filter_get_filter,
7719 (void *)&cmd_5tuple_filter_port_id,
7720 (void *)&cmd_5tuple_filter_index,
7721 (void *)&cmd_5tuple_filter_index_value,
7726 /* *** ADD/REMOVE A flex FILTER *** */
7727 struct cmd_flex_filter_result {
7728 cmdline_fixed_string_t filter;
7730 cmdline_fixed_string_t len;
7732 cmdline_fixed_string_t bytes;
7733 cmdline_fixed_string_t bytes_value;
7734 cmdline_fixed_string_t mask;
7735 cmdline_fixed_string_t mask_value;
7736 cmdline_fixed_string_t priority;
7737 uint8_t priority_value;
7738 cmdline_fixed_string_t queue;
7740 cmdline_fixed_string_t index;
7741 uint16_t index_value;
7744 static int xdigit2val(unsigned char c)
7749 else if (isupper(c))
7757 cmd_flex_filter_parsed(void *parsed_result,
7758 __attribute__((unused)) struct cmdline *cl,
7759 __attribute__((unused)) void *data)
7762 struct rte_flex_filter filter;
7763 struct cmd_flex_filter_result *res = parsed_result;
7764 char *bytes_ptr, *mask_ptr;
7772 if (!strcmp(res->filter, "add_flex_filter")) {
7773 if (res->len_value > 128) {
7774 printf("the len exceed the max length 128\n");
7777 memset(&filter, 0, sizeof(struct rte_flex_filter));
7778 filter.len = res->len_value;
7779 filter.priority = res->priority_value;
7780 bytes_ptr = res->bytes_value;
7781 mask_ptr = res->mask_value;
7784 /* translate bytes string to uint_32 array. */
7785 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7786 (bytes_ptr[1] == 'X')))
7788 len = strnlen(bytes_ptr, res->len_value * 2);
7789 if (len == 0 || (len % 8 != 0)) {
7790 printf("please check len and bytes input\n");
7793 for (i = 0; i < len; i++) {
7795 if (isxdigit(c) == 0) {
7796 /* invalid characters. */
7797 printf("invalid input\n");
7800 val = xdigit2val(c);
7804 dword |= byte << (4 * mod - 4);
7809 filter.dwords[j] = dword;
7810 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7816 /* translate mask string to uint8_t array. */
7818 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7819 (mask_ptr[1] == 'X')))
7821 len = strnlen(mask_ptr, (res->len_value+3)/4);
7823 printf("invalid input\n");
7826 for (i = 0; i < len; i++) {
7828 if (isxdigit(c) == 0) {
7829 /* invalid characters. */
7830 printf("invalid input\n");
7833 val = xdigit2val(c);
7834 hex |= (uint8_t)(val & 0x8) >> 3;
7835 hex |= (uint8_t)(val & 0x4) >> 1;
7836 hex |= (uint8_t)(val & 0x2) << 1;
7837 hex |= (uint8_t)(val & 0x1) << 3;
7840 filter.mask[j] = byte;
7841 printf("mask[%d]:%02x ", j, filter.mask[j]);
7849 printf("call function rte_eth_dev_add_flex_filter: "
7850 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7851 res->index_value, res->queue_id,
7852 filter.len, filter.priority);
7853 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7854 &filter, res->queue_id);
7856 } else if (!strcmp(res->filter, "remove_flex_filter"))
7857 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7859 else if (!strcmp(res->filter, "get_flex_filter"))
7860 get_flex_filter(res->port_id, res->index_value);
7863 printf("flex filter setting error: (%s)\n", strerror(-ret));
7866 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7867 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7869 cmdline_parse_token_string_t cmd_flex_filter_len =
7870 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7872 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7873 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7875 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7876 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7878 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7879 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7881 cmdline_parse_token_string_t cmd_flex_filter_mask =
7882 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7884 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7885 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7887 cmdline_parse_token_string_t cmd_flex_filter_priority =
7888 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7889 priority, "priority");
7890 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7891 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7892 priority_value, UINT8);
7893 cmdline_parse_token_string_t cmd_flex_filter_queue =
7894 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7896 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7897 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7899 cmdline_parse_token_string_t cmd_flex_filter_index =
7900 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7902 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7903 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7904 index_value, UINT16);
7905 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7906 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7907 filter, "add_flex_filter");
7908 cmdline_parse_inst_t cmd_add_flex_filter = {
7909 .f = cmd_flex_filter_parsed,
7911 .help_str = "add a flex filter",
7913 (void *)&cmd_flex_filter_add_filter,
7914 (void *)&cmd_flex_filter_port_id,
7915 (void *)&cmd_flex_filter_len,
7916 (void *)&cmd_flex_filter_len_value,
7917 (void *)&cmd_flex_filter_bytes,
7918 (void *)&cmd_flex_filter_bytes_value,
7919 (void *)&cmd_flex_filter_mask,
7920 (void *)&cmd_flex_filter_mask_value,
7921 (void *)&cmd_flex_filter_priority,
7922 (void *)&cmd_flex_filter_priority_value,
7923 (void *)&cmd_flex_filter_queue,
7924 (void *)&cmd_flex_filter_queue_id,
7925 (void *)&cmd_flex_filter_index,
7926 (void *)&cmd_flex_filter_index_value,
7931 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7932 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7933 filter, "remove_flex_filter");
7934 cmdline_parse_inst_t cmd_remove_flex_filter = {
7935 .f = cmd_flex_filter_parsed,
7937 .help_str = "remove a flex filter",
7939 (void *)&cmd_flex_filter_remove_filter,
7940 (void *)&cmd_flex_filter_port_id,
7941 (void *)&cmd_flex_filter_index,
7942 (void *)&cmd_flex_filter_index_value,
7947 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7948 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7949 filter, "get_flex_filter");
7950 cmdline_parse_inst_t cmd_get_flex_filter = {
7951 .f = cmd_flex_filter_parsed,
7953 .help_str = "get a flex filter",
7955 (void *)&cmd_flex_filter_get_filter,
7956 (void *)&cmd_flex_filter_port_id,
7957 (void *)&cmd_flex_filter_index,
7958 (void *)&cmd_flex_filter_index_value,
7963 /* *** Filters Control *** */
7965 /* *** deal with ethertype filter *** */
7966 struct cmd_ethertype_filter_result {
7967 cmdline_fixed_string_t filter;
7969 cmdline_fixed_string_t ops;
7970 cmdline_fixed_string_t mac;
7971 struct ether_addr mac_addr;
7972 cmdline_fixed_string_t ethertype;
7973 uint16_t ethertype_value;
7974 cmdline_fixed_string_t drop;
7975 cmdline_fixed_string_t queue;
7979 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7980 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7981 filter, "ethertype_filter");
7982 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7983 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7985 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7986 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7988 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7989 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7990 mac, "mac_addr#mac_ignr");
7991 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7992 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7994 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7995 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7996 ethertype, "ethertype");
7997 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7998 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7999 ethertype_value, UINT16);
8000 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8001 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8003 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8004 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8006 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8007 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8011 cmd_ethertype_filter_parsed(void *parsed_result,
8012 __attribute__((unused)) struct cmdline *cl,
8013 __attribute__((unused)) void *data)
8015 struct cmd_ethertype_filter_result *res = parsed_result;
8016 struct rte_eth_ethertype_filter filter;
8019 ret = rte_eth_dev_filter_supported(res->port_id,
8020 RTE_ETH_FILTER_ETHERTYPE);
8022 printf("ethertype filter is not supported on port %u.\n",
8027 memset(&filter, 0, sizeof(filter));
8028 if (!strcmp(res->mac, "mac_addr")) {
8029 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8030 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8031 sizeof(struct ether_addr));
8033 if (!strcmp(res->drop, "drop"))
8034 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8035 filter.ether_type = res->ethertype_value;
8036 filter.queue = res->queue_id;
8038 if (!strcmp(res->ops, "add"))
8039 ret = rte_eth_dev_filter_ctrl(res->port_id,
8040 RTE_ETH_FILTER_ETHERTYPE,
8044 ret = rte_eth_dev_filter_ctrl(res->port_id,
8045 RTE_ETH_FILTER_ETHERTYPE,
8046 RTE_ETH_FILTER_DELETE,
8049 printf("ethertype filter programming error: (%s)\n",
8053 cmdline_parse_inst_t cmd_ethertype_filter = {
8054 .f = cmd_ethertype_filter_parsed,
8056 .help_str = "add or delete an ethertype filter entry",
8058 (void *)&cmd_ethertype_filter_filter,
8059 (void *)&cmd_ethertype_filter_port_id,
8060 (void *)&cmd_ethertype_filter_ops,
8061 (void *)&cmd_ethertype_filter_mac,
8062 (void *)&cmd_ethertype_filter_mac_addr,
8063 (void *)&cmd_ethertype_filter_ethertype,
8064 (void *)&cmd_ethertype_filter_ethertype_value,
8065 (void *)&cmd_ethertype_filter_drop,
8066 (void *)&cmd_ethertype_filter_queue,
8067 (void *)&cmd_ethertype_filter_queue_id,
8072 /* *** deal with flow director filter *** */
8073 struct cmd_flow_director_result {
8074 cmdline_fixed_string_t flow_director_filter;
8076 cmdline_fixed_string_t ops;
8077 cmdline_fixed_string_t flow;
8078 cmdline_fixed_string_t flow_type;
8079 cmdline_fixed_string_t src;
8080 cmdline_ipaddr_t ip_src;
8082 cmdline_fixed_string_t dst;
8083 cmdline_ipaddr_t ip_dst;
8085 cmdline_fixed_string_t verify_tag;
8086 uint32_t verify_tag_value;
8087 cmdline_fixed_string_t flexbytes;
8088 cmdline_fixed_string_t flexbytes_value;
8089 cmdline_fixed_string_t drop;
8090 cmdline_fixed_string_t queue;
8092 cmdline_fixed_string_t fd_id;
8093 uint32_t fd_id_value;
8097 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8100 const char *p, *p0 = q_arg;
8102 unsigned long int_fld;
8103 char *str_fld[max_num];
8108 p = strchr(p0, '(');
8112 p0 = strchr(p, ')');
8117 if (size >= sizeof(s))
8120 snprintf(s, sizeof(s), "%.*s", size, p);
8121 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8122 if (ret < 0 || ret > max_num)
8124 for (i = 0; i < ret; i++) {
8126 int_fld = strtoul(str_fld[i], &end, 0);
8127 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8129 flexbytes[i] = (uint8_t)int_fld;
8134 static enum rte_eth_flow_type
8135 str2flowtype(char *string)
8138 static const struct {
8140 enum rte_eth_flow_type type;
8141 } flowtype_str[] = {
8142 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8143 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8144 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8145 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8146 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8147 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8148 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8149 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8150 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8151 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8154 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8155 if (!strcmp(flowtype_str[i].str, string))
8156 return flowtype_str[i].type;
8158 return RTE_ETH_FLOW_TYPE_NONE;
8161 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8163 if ((ip_addr).family == AF_INET) \
8164 (ip) = (ip_addr).addr.ipv4.s_addr; \
8166 printf("invalid parameter.\n"); \
8171 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8173 if ((ip_addr).family == AF_INET6) \
8174 (void)rte_memcpy(&(ip), \
8175 &((ip_addr).addr.ipv6), \
8176 sizeof(struct in6_addr)); \
8178 printf("invalid parameter.\n"); \
8184 cmd_flow_director_filter_parsed(void *parsed_result,
8185 __attribute__((unused)) struct cmdline *cl,
8186 __attribute__((unused)) void *data)
8188 struct cmd_flow_director_result *res = parsed_result;
8189 struct rte_eth_fdir_filter entry;
8190 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8193 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8195 printf("flow director is not supported on port %u.\n",
8199 memset(flexbytes, 0, sizeof(flexbytes));
8200 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8201 ret = parse_flexbytes(res->flexbytes_value,
8203 RTE_ETH_FDIR_MAX_FLEXLEN);
8205 printf("error: Cannot parse flexbytes input.\n");
8209 entry.input.flow_type = str2flowtype(res->flow_type);
8210 switch (entry.input.flow_type) {
8211 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
8212 case RTE_ETH_FLOW_TYPE_UDPV4:
8213 case RTE_ETH_FLOW_TYPE_TCPV4:
8214 IPV4_ADDR_TO_UINT(res->ip_dst,
8215 entry.input.flow.ip4_flow.dst_ip);
8216 IPV4_ADDR_TO_UINT(res->ip_src,
8217 entry.input.flow.ip4_flow.src_ip);
8218 /* need convert to big endian. */
8219 entry.input.flow.udp4_flow.dst_port =
8220 rte_cpu_to_be_16(res->port_dst);
8221 entry.input.flow.udp4_flow.src_port =
8222 rte_cpu_to_be_16(res->port_src);
8224 case RTE_ETH_FLOW_TYPE_SCTPV4:
8225 IPV4_ADDR_TO_UINT(res->ip_dst,
8226 entry.input.flow.sctp4_flow.ip.dst_ip);
8227 IPV4_ADDR_TO_UINT(res->ip_src,
8228 entry.input.flow.sctp4_flow.ip.src_ip);
8229 /* need convert to big endian. */
8230 entry.input.flow.sctp4_flow.verify_tag =
8231 rte_cpu_to_be_32(res->verify_tag_value);
8233 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
8234 case RTE_ETH_FLOW_TYPE_UDPV6:
8235 case RTE_ETH_FLOW_TYPE_TCPV6:
8236 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8237 entry.input.flow.ipv6_flow.dst_ip);
8238 IPV6_ADDR_TO_ARRAY(res->ip_src,
8239 entry.input.flow.ipv6_flow.src_ip);
8240 /* need convert to big endian. */
8241 entry.input.flow.udp6_flow.dst_port =
8242 rte_cpu_to_be_16(res->port_dst);
8243 entry.input.flow.udp6_flow.src_port =
8244 rte_cpu_to_be_16(res->port_src);
8246 case RTE_ETH_FLOW_TYPE_SCTPV6:
8247 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8248 entry.input.flow.sctp6_flow.ip.dst_ip);
8249 IPV6_ADDR_TO_ARRAY(res->ip_src,
8250 entry.input.flow.sctp6_flow.ip.src_ip);
8251 /* need convert to big endian. */
8252 entry.input.flow.sctp6_flow.verify_tag =
8253 rte_cpu_to_be_32(res->verify_tag_value);
8256 printf("invalid parameter.\n");
8259 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8261 RTE_ETH_FDIR_MAX_FLEXLEN);
8263 entry.action.flex_off = 0; /*use 0 by default */
8264 if (!strcmp(res->drop, "drop"))
8265 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8267 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8268 /* set to report FD ID by default */
8269 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8270 entry.action.rx_queue = res->queue_id;
8271 entry.soft_id = res->fd_id_value;
8272 if (!strcmp(res->ops, "add"))
8273 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8274 RTE_ETH_FILTER_ADD, &entry);
8276 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8277 RTE_ETH_FILTER_DELETE, &entry);
8279 printf("flow director programming error: (%s)\n",
8283 cmdline_parse_token_string_t cmd_flow_director_filter =
8284 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8285 flow_director_filter, "flow_director_filter");
8286 cmdline_parse_token_num_t cmd_flow_director_port_id =
8287 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8289 cmdline_parse_token_string_t cmd_flow_director_ops =
8290 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8292 cmdline_parse_token_string_t cmd_flow_director_flow =
8293 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8295 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8296 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8298 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8299 "ip6#ip6-frag#tcp6#udp6#sctp6");
8300 cmdline_parse_token_string_t cmd_flow_director_src =
8301 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8303 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8304 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8306 cmdline_parse_token_num_t cmd_flow_director_port_src =
8307 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8309 cmdline_parse_token_string_t cmd_flow_director_dst =
8310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8312 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8313 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8315 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8316 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8318 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8320 verify_tag, "verify_tag");
8321 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8322 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8323 verify_tag_value, UINT32);
8324 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8325 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8326 flexbytes, "flexbytes");
8327 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8329 flexbytes_value, NULL);
8330 cmdline_parse_token_string_t cmd_flow_director_drop =
8331 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8333 cmdline_parse_token_string_t cmd_flow_director_queue =
8334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8336 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8337 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8339 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8340 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8342 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8343 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8344 fd_id_value, UINT32);
8346 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8347 .f = cmd_flow_director_filter_parsed,
8349 .help_str = "add or delete an ip flow director entry on NIC",
8351 (void *)&cmd_flow_director_filter,
8352 (void *)&cmd_flow_director_port_id,
8353 (void *)&cmd_flow_director_ops,
8354 (void *)&cmd_flow_director_flow,
8355 (void *)&cmd_flow_director_flow_type,
8356 (void *)&cmd_flow_director_src,
8357 (void *)&cmd_flow_director_ip_src,
8358 (void *)&cmd_flow_director_dst,
8359 (void *)&cmd_flow_director_ip_dst,
8360 (void *)&cmd_flow_director_flexbytes,
8361 (void *)&cmd_flow_director_flexbytes_value,
8362 (void *)&cmd_flow_director_drop,
8363 (void *)&cmd_flow_director_queue,
8364 (void *)&cmd_flow_director_queue_id,
8365 (void *)&cmd_flow_director_fd_id,
8366 (void *)&cmd_flow_director_fd_id_value,
8371 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8372 .f = cmd_flow_director_filter_parsed,
8374 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8376 (void *)&cmd_flow_director_filter,
8377 (void *)&cmd_flow_director_port_id,
8378 (void *)&cmd_flow_director_ops,
8379 (void *)&cmd_flow_director_flow,
8380 (void *)&cmd_flow_director_flow_type,
8381 (void *)&cmd_flow_director_src,
8382 (void *)&cmd_flow_director_ip_src,
8383 (void *)&cmd_flow_director_port_src,
8384 (void *)&cmd_flow_director_dst,
8385 (void *)&cmd_flow_director_ip_dst,
8386 (void *)&cmd_flow_director_port_dst,
8387 (void *)&cmd_flow_director_flexbytes,
8388 (void *)&cmd_flow_director_flexbytes_value,
8389 (void *)&cmd_flow_director_drop,
8390 (void *)&cmd_flow_director_queue,
8391 (void *)&cmd_flow_director_queue_id,
8392 (void *)&cmd_flow_director_fd_id,
8393 (void *)&cmd_flow_director_fd_id_value,
8398 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8399 .f = cmd_flow_director_filter_parsed,
8401 .help_str = "add or delete a sctp flow director entry on NIC",
8403 (void *)&cmd_flow_director_filter,
8404 (void *)&cmd_flow_director_port_id,
8405 (void *)&cmd_flow_director_ops,
8406 (void *)&cmd_flow_director_flow,
8407 (void *)&cmd_flow_director_flow_type,
8408 (void *)&cmd_flow_director_src,
8409 (void *)&cmd_flow_director_ip_src,
8410 (void *)&cmd_flow_director_dst,
8411 (void *)&cmd_flow_director_ip_dst,
8412 (void *)&cmd_flow_director_verify_tag,
8413 (void *)&cmd_flow_director_verify_tag_value,
8414 (void *)&cmd_flow_director_flexbytes,
8415 (void *)&cmd_flow_director_flexbytes_value,
8416 (void *)&cmd_flow_director_drop,
8417 (void *)&cmd_flow_director_queue,
8418 (void *)&cmd_flow_director_queue_id,
8419 (void *)&cmd_flow_director_fd_id,
8420 (void *)&cmd_flow_director_fd_id_value,
8425 struct cmd_flush_flow_director_result {
8426 cmdline_fixed_string_t flush_flow_director;
8430 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8431 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8432 flush_flow_director, "flush_flow_director");
8433 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8434 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8438 cmd_flush_flow_director_parsed(void *parsed_result,
8439 __attribute__((unused)) struct cmdline *cl,
8440 __attribute__((unused)) void *data)
8442 struct cmd_flow_director_result *res = parsed_result;
8445 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8447 printf("flow director is not supported on port %u.\n",
8452 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8453 RTE_ETH_FILTER_FLUSH, NULL);
8455 printf("flow director table flushing error: (%s)\n",
8459 cmdline_parse_inst_t cmd_flush_flow_director = {
8460 .f = cmd_flush_flow_director_parsed,
8462 .help_str = "flush all flow director entries of a device on NIC",
8464 (void *)&cmd_flush_flow_director_flush,
8465 (void *)&cmd_flush_flow_director_port_id,
8470 /* *** deal with flow director mask on flexible payload *** */
8471 struct cmd_flow_director_flex_mask_result {
8472 cmdline_fixed_string_t flow_director_flexmask;
8474 cmdline_fixed_string_t flow;
8475 cmdline_fixed_string_t flow_type;
8476 cmdline_fixed_string_t mask;
8480 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8481 __attribute__((unused)) struct cmdline *cl,
8482 __attribute__((unused)) void *data)
8484 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8485 struct rte_eth_fdir_flex_mask flex_mask;
8486 struct rte_port *port;
8487 enum rte_eth_flow_type i;
8490 if (res->port_id > nb_ports) {
8491 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8495 port = &ports[res->port_id];
8496 /** Check if the port is not started **/
8497 if (port->port_status != RTE_PORT_STOPPED) {
8498 printf("Please stop port %d first\n", res->port_id);
8502 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8503 ret = parse_flexbytes(res->mask,
8505 RTE_ETH_FDIR_MAX_FLEXLEN);
8507 printf("error: Cannot parse mask input.\n");
8510 if (!strcmp(res->flow_type, "all")) {
8511 for (i = RTE_ETH_FLOW_TYPE_UDPV4;
8512 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8514 flex_mask.flow_type = i;
8515 fdir_set_flex_mask(res->port_id, &flex_mask);
8517 cmd_reconfig_device_queue(res->port_id, 1, 0);
8520 flex_mask.flow_type = str2flowtype(res->flow_type);
8521 fdir_set_flex_mask(res->port_id, &flex_mask);
8522 cmd_reconfig_device_queue(res->port_id, 1, 1);
8525 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8526 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8527 flow_director_flexmask,
8528 "flow_director_flex_mask");
8529 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8530 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8532 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8533 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8535 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8536 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8538 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8539 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8540 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8541 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8544 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8545 .f = cmd_flow_director_flex_mask_parsed,
8547 .help_str = "set flow director's flex mask on NIC",
8549 (void *)&cmd_flow_director_flexmask,
8550 (void *)&cmd_flow_director_flexmask_port_id,
8551 (void *)&cmd_flow_director_flexmask_flow,
8552 (void *)&cmd_flow_director_flexmask_flow_type,
8553 (void *)&cmd_flow_director_flexmask_mask,
8558 /* *** deal with flow director flexible payload configuration *** */
8559 struct cmd_flow_director_flexpayload_result {
8560 cmdline_fixed_string_t flow_director_flexpayload;
8562 cmdline_fixed_string_t payload_layer;
8563 cmdline_fixed_string_t payload_cfg;
8567 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8570 const char *p, *p0 = q_arg;
8572 unsigned long int_fld;
8573 char *str_fld[max_num];
8578 p = strchr(p0, '(');
8582 p0 = strchr(p, ')');
8587 if (size >= sizeof(s))
8590 snprintf(s, sizeof(s), "%.*s", size, p);
8591 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8592 if (ret < 0 || ret > max_num)
8594 for (i = 0; i < ret; i++) {
8596 int_fld = strtoul(str_fld[i], &end, 0);
8597 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8599 offsets[i] = (uint16_t)int_fld;
8605 cmd_flow_director_flxpld_parsed(void *parsed_result,
8606 __attribute__((unused)) struct cmdline *cl,
8607 __attribute__((unused)) void *data)
8609 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8610 struct rte_eth_flex_payload_cfg flex_cfg;
8611 struct rte_port *port;
8614 if (res->port_id > nb_ports) {
8615 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8619 port = &ports[res->port_id];
8620 /** Check if the port is not started **/
8621 if (port->port_status != RTE_PORT_STOPPED) {
8622 printf("Please stop port %d first\n", res->port_id);
8626 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8628 if (!strcmp(res->payload_layer, "l2"))
8629 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8630 else if (!strcmp(res->payload_layer, "l3"))
8631 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8632 else if (!strcmp(res->payload_layer, "l4"))
8633 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8635 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8636 RTE_ETH_FDIR_MAX_FLEXLEN);
8638 printf("error: Cannot parse flex payload input.\n");
8642 fdir_set_flex_payload(res->port_id, &flex_cfg);
8643 cmd_reconfig_device_queue(res->port_id, 1, 1);
8646 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8647 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8648 flow_director_flexpayload,
8649 "flow_director_flex_payload");
8650 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8651 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8653 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8654 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8655 payload_layer, "l2#l3#l4");
8656 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8657 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8660 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8661 .f = cmd_flow_director_flxpld_parsed,
8663 .help_str = "set flow director's flex payload on NIC",
8665 (void *)&cmd_flow_director_flexpayload,
8666 (void *)&cmd_flow_director_flexpayload_port_id,
8667 (void *)&cmd_flow_director_flexpayload_payload_layer,
8668 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8673 /* ******************************************************************************** */
8675 /* list of instructions */
8676 cmdline_parse_ctx_t main_ctx[] = {
8677 (cmdline_parse_inst_t *)&cmd_help_brief,
8678 (cmdline_parse_inst_t *)&cmd_help_long,
8679 (cmdline_parse_inst_t *)&cmd_quit,
8680 (cmdline_parse_inst_t *)&cmd_showport,
8681 (cmdline_parse_inst_t *)&cmd_showportall,
8682 (cmdline_parse_inst_t *)&cmd_showcfg,
8683 (cmdline_parse_inst_t *)&cmd_start,
8684 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8685 (cmdline_parse_inst_t *)&cmd_set_link_up,
8686 (cmdline_parse_inst_t *)&cmd_set_link_down,
8687 (cmdline_parse_inst_t *)&cmd_reset,
8688 (cmdline_parse_inst_t *)&cmd_set_numbers,
8689 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8690 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8691 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8692 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8693 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8694 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8695 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8696 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8697 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8698 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8699 (cmdline_parse_inst_t *)&cmd_set_link_check,
8700 #ifdef RTE_NIC_BYPASS
8701 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8702 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8703 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8704 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8706 #ifdef RTE_LIBRTE_PMD_BOND
8707 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8708 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8709 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8710 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8711 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8712 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8713 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8714 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8715 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8717 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8718 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8719 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8720 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8721 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8722 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8723 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8724 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
8725 (cmdline_parse_inst_t *)&cmd_tx_cksum_show,
8726 (cmdline_parse_inst_t *)&cmd_tso_set,
8727 (cmdline_parse_inst_t *)&cmd_tso_show,
8728 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8729 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8730 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8731 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8732 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8733 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8734 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8735 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8736 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8737 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8738 (cmdline_parse_inst_t *)&cmd_config_dcb,
8739 (cmdline_parse_inst_t *)&cmd_read_reg,
8740 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8741 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8742 (cmdline_parse_inst_t *)&cmd_write_reg,
8743 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8744 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8745 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8746 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
8747 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
8748 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
8749 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
8750 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
8751 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
8752 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
8753 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
8754 (cmdline_parse_inst_t *)&cmd_stop,
8755 (cmdline_parse_inst_t *)&cmd_mac_addr,
8756 (cmdline_parse_inst_t *)&cmd_set_qmap,
8757 (cmdline_parse_inst_t *)&cmd_operate_port,
8758 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8759 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8760 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8761 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8762 (cmdline_parse_inst_t *)&cmd_config_mtu,
8763 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8764 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8765 (cmdline_parse_inst_t *)&cmd_config_rss,
8766 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8767 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8768 (cmdline_parse_inst_t *)&cmd_showport_reta,
8769 (cmdline_parse_inst_t *)&cmd_config_burst,
8770 (cmdline_parse_inst_t *)&cmd_config_thresh,
8771 (cmdline_parse_inst_t *)&cmd_config_threshold,
8772 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8773 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8774 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8775 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8776 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8777 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8778 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8779 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8780 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8781 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8782 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8783 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8784 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8785 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8786 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8787 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8788 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8789 (cmdline_parse_inst_t *)&cmd_dump,
8790 (cmdline_parse_inst_t *)&cmd_dump_one,
8791 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
8792 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
8793 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
8794 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
8795 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
8796 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
8797 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
8798 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
8799 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
8800 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
8801 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
8802 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
8803 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
8804 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8805 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8806 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8807 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8808 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8809 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
8813 /* prompt function, called from main on MASTER lcore */
8819 /* initialize non-constant commands */
8820 cmd_set_fwd_mode_init();
8822 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8826 cmdline_interact(cl);
8827 cmdline_stdin_exit(cl);
8831 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8833 if (id < nb_ports) {
8834 /* check if need_reconfig has been set to 1 */
8835 if (ports[id].need_reconfig == 0)
8836 ports[id].need_reconfig = dev;
8837 /* check if need_reconfig_queues has been set to 1 */
8838 if (ports[id].need_reconfig_queues == 0)
8839 ports[id].need_reconfig_queues = queue;
8843 for (pid = 0; pid < nb_ports; pid++) {
8844 /* check if need_reconfig has been set to 1 */
8845 if (ports[pid].need_reconfig == 0)
8846 ports[pid].need_reconfig = dev;
8847 /* check if need_reconfig_queues has been set to 1 */
8848 if (ports[pid].need_reconfig_queues == 0)
8849 ports[pid].need_reconfig_queues = queue;
8854 #ifdef RTE_NIC_BYPASS
8856 bypass_is_supported(portid_t port_id)
8858 struct rte_port *port;
8859 struct rte_pci_id *pci_id;
8861 if (port_id >= nb_ports) {
8862 printf("\tPort id must be less than %d.\n", nb_ports);
8866 /* Get the device id. */
8867 port = &ports[port_id];
8868 pci_id = &port->dev_info.pci_dev->id;
8870 /* Check if NIC supports bypass. */
8871 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8875 printf("\tBypass not supported for port_id = %d.\n", port_id);