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 "add_ethertype_filter (port_id) ethertype (eth_value)"
658 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
659 " add an ethertype filter.\n\n"
661 "remove_ethertype_filter (port_id) index (idx)\n"
662 " remove an ethertype filter.\n\n"
664 "get_ethertype_filter (port_id) index (idx)\n"
665 " get info of a ethertype filter.\n\n"
667 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
668 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
669 " queue (queue_id) index (idx)\n"
670 " add a 2tuple filter.\n\n"
672 "remove_2tuple_filter (port_id) index (idx)\n"
673 " remove a 2tuple filter.\n\n"
675 "get_2tuple_filter (port_id) index (idx)\n"
676 " get info of a 2tuple filter.\n\n"
678 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
679 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
680 " mask (mask_value) flags (flags_value) priority (prio_value)"
681 " queue (queue_id) index (idx)\n"
682 " add a 5tuple filter.\n\n"
684 "remove_5tuple_filter (port_id) index (idx)\n"
685 " remove a 5tuple filter.\n\n"
687 "get_5tuple_filter (port_id) index (idx)\n"
688 " get info of a 5tuple filter.\n\n"
690 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
691 " add syn filter.\n\n"
693 "remove_syn_filter (port_id)"
694 " remove syn filter.\n\n"
696 "get_syn_filter (port_id) "
697 " get syn filter info.\n\n"
699 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
700 " priority (prio_value) queue (queue_id) index (idx)\n"
701 " add a flex filter.\n\n"
703 "remove_flex_filter (port_id) index (idx)\n"
704 " remove a flex filter.\n\n"
706 "get_flex_filter (port_id) index (idx)\n"
707 " get info of a flex filter.\n\n"
709 "flow_director_filter (port_id) (add|del)"
710 " flow (ip4|ip4-frag|ip6|ip6-frag)"
711 " src (src_ip_address) dst (dst_ip_address)"
712 " flexbytes (flexbytes_value)"
713 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
714 " Add/Del an IP type flow director filter.\n\n"
716 "flow_director_filter (port_id) (add|del)"
717 " flow (udp4|tcp4|udp6|tcp6)"
718 " src (src_ip_address) (src_port)"
719 " dst (dst_ip_address) (dst_port)"
720 " flexbytes (flexbytes_value)"
721 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
722 " Add/Del an UDP/TCP type flow director filter.\n\n"
724 "flow_director_filter (port_id) (add|del)"
725 " flow (sctp4|sctp6)"
726 " src (src_ip_address) dst (dst_ip_address)"
727 " tag (verification_tag)"
728 " flexbytes (flexbytes_value) (drop|fwd)"
729 " queue (queue_id) fd_id (fd_id_value)\n"
730 " Add/Del a SCTP type flow director filter.\n\n"
732 "flush_flow_director (port_id)\n"
733 " Flush all flow director entries of a device.\n\n"
735 "flow_director_flex_mask (port_id)"
736 " flow (ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
738 " Configure mask of flex payload.\n\n"
740 "flow_director_flex_payload (port_id)"
741 " (l2|l3|l4) (config)\n"
742 " Configure flex payload selection.\n\n"
747 cmdline_parse_token_string_t cmd_help_long_help =
748 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
750 cmdline_parse_token_string_t cmd_help_long_section =
751 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
752 "all#control#display#config#flowdir#"
753 "ports#registers#filters");
755 cmdline_parse_inst_t cmd_help_long = {
756 .f = cmd_help_long_parsed,
758 .help_str = "show help",
760 (void *)&cmd_help_long_help,
761 (void *)&cmd_help_long_section,
767 /* *** start/stop/close all ports *** */
768 struct cmd_operate_port_result {
769 cmdline_fixed_string_t keyword;
770 cmdline_fixed_string_t name;
771 cmdline_fixed_string_t value;
774 static void cmd_operate_port_parsed(void *parsed_result,
775 __attribute__((unused)) struct cmdline *cl,
776 __attribute__((unused)) void *data)
778 struct cmd_operate_port_result *res = parsed_result;
780 if (!strcmp(res->name, "start"))
781 start_port(RTE_PORT_ALL);
782 else if (!strcmp(res->name, "stop"))
783 stop_port(RTE_PORT_ALL);
784 else if (!strcmp(res->name, "close"))
785 close_port(RTE_PORT_ALL);
787 printf("Unknown parameter\n");
790 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
791 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
793 cmdline_parse_token_string_t cmd_operate_port_all_port =
794 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
796 cmdline_parse_token_string_t cmd_operate_port_all_all =
797 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
799 cmdline_parse_inst_t cmd_operate_port = {
800 .f = cmd_operate_port_parsed,
802 .help_str = "port start|stop|close all: start/stop/close all ports",
804 (void *)&cmd_operate_port_all_cmd,
805 (void *)&cmd_operate_port_all_port,
806 (void *)&cmd_operate_port_all_all,
811 /* *** start/stop/close specific port *** */
812 struct cmd_operate_specific_port_result {
813 cmdline_fixed_string_t keyword;
814 cmdline_fixed_string_t name;
818 static void cmd_operate_specific_port_parsed(void *parsed_result,
819 __attribute__((unused)) struct cmdline *cl,
820 __attribute__((unused)) void *data)
822 struct cmd_operate_specific_port_result *res = parsed_result;
824 if (!strcmp(res->name, "start"))
825 start_port(res->value);
826 else if (!strcmp(res->name, "stop"))
827 stop_port(res->value);
828 else if (!strcmp(res->name, "close"))
829 close_port(res->value);
831 printf("Unknown parameter\n");
834 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
835 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
837 cmdline_parse_token_string_t cmd_operate_specific_port_port =
838 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
839 name, "start#stop#close");
840 cmdline_parse_token_num_t cmd_operate_specific_port_id =
841 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
844 cmdline_parse_inst_t cmd_operate_specific_port = {
845 .f = cmd_operate_specific_port_parsed,
847 .help_str = "port start|stop|close X: start/stop/close port X",
849 (void *)&cmd_operate_specific_port_cmd,
850 (void *)&cmd_operate_specific_port_port,
851 (void *)&cmd_operate_specific_port_id,
856 /* *** configure speed for all ports *** */
857 struct cmd_config_speed_all {
858 cmdline_fixed_string_t port;
859 cmdline_fixed_string_t keyword;
860 cmdline_fixed_string_t all;
861 cmdline_fixed_string_t item1;
862 cmdline_fixed_string_t item2;
863 cmdline_fixed_string_t value1;
864 cmdline_fixed_string_t value2;
868 cmd_config_speed_all_parsed(void *parsed_result,
869 __attribute__((unused)) struct cmdline *cl,
870 __attribute__((unused)) void *data)
872 struct cmd_config_speed_all *res = parsed_result;
873 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
874 uint16_t link_duplex = 0;
877 if (!all_ports_stopped()) {
878 printf("Please stop all ports first\n");
882 if (!strcmp(res->value1, "10"))
883 link_speed = ETH_LINK_SPEED_10;
884 else if (!strcmp(res->value1, "100"))
885 link_speed = ETH_LINK_SPEED_100;
886 else if (!strcmp(res->value1, "1000"))
887 link_speed = ETH_LINK_SPEED_1000;
888 else if (!strcmp(res->value1, "10000"))
889 link_speed = ETH_LINK_SPEED_10G;
890 else if (!strcmp(res->value1, "40000"))
891 link_speed = ETH_LINK_SPEED_40G;
892 else if (!strcmp(res->value1, "auto"))
893 link_speed = ETH_LINK_SPEED_AUTONEG;
895 printf("Unknown parameter\n");
899 if (!strcmp(res->value2, "half"))
900 link_duplex = ETH_LINK_HALF_DUPLEX;
901 else if (!strcmp(res->value2, "full"))
902 link_duplex = ETH_LINK_FULL_DUPLEX;
903 else if (!strcmp(res->value2, "auto"))
904 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
906 printf("Unknown parameter\n");
910 for (pid = 0; pid < nb_ports; pid++) {
911 ports[pid].dev_conf.link_speed = link_speed;
912 ports[pid].dev_conf.link_duplex = link_duplex;
915 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
918 cmdline_parse_token_string_t cmd_config_speed_all_port =
919 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
920 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
921 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
923 cmdline_parse_token_string_t cmd_config_speed_all_all =
924 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
925 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
926 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
927 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
928 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
929 "10#100#1000#10000#40000#auto");
930 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
931 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
932 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
933 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
936 cmdline_parse_inst_t cmd_config_speed_all = {
937 .f = cmd_config_speed_all_parsed,
939 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
942 (void *)&cmd_config_speed_all_port,
943 (void *)&cmd_config_speed_all_keyword,
944 (void *)&cmd_config_speed_all_all,
945 (void *)&cmd_config_speed_all_item1,
946 (void *)&cmd_config_speed_all_value1,
947 (void *)&cmd_config_speed_all_item2,
948 (void *)&cmd_config_speed_all_value2,
953 /* *** configure speed for specific port *** */
954 struct cmd_config_speed_specific {
955 cmdline_fixed_string_t port;
956 cmdline_fixed_string_t keyword;
958 cmdline_fixed_string_t item1;
959 cmdline_fixed_string_t item2;
960 cmdline_fixed_string_t value1;
961 cmdline_fixed_string_t value2;
965 cmd_config_speed_specific_parsed(void *parsed_result,
966 __attribute__((unused)) struct cmdline *cl,
967 __attribute__((unused)) void *data)
969 struct cmd_config_speed_specific *res = parsed_result;
970 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
971 uint16_t link_duplex = 0;
973 if (!all_ports_stopped()) {
974 printf("Please stop all ports first\n");
978 if (res->id >= nb_ports) {
979 printf("Port id %d must be less than %d\n", res->id, nb_ports);
983 if (!strcmp(res->value1, "10"))
984 link_speed = ETH_LINK_SPEED_10;
985 else if (!strcmp(res->value1, "100"))
986 link_speed = ETH_LINK_SPEED_100;
987 else if (!strcmp(res->value1, "1000"))
988 link_speed = ETH_LINK_SPEED_1000;
989 else if (!strcmp(res->value1, "10000"))
990 link_speed = ETH_LINK_SPEED_10000;
991 else if (!strcmp(res->value1, "40000"))
992 link_speed = ETH_LINK_SPEED_40G;
993 else if (!strcmp(res->value1, "auto"))
994 link_speed = ETH_LINK_SPEED_AUTONEG;
996 printf("Unknown parameter\n");
1000 if (!strcmp(res->value2, "half"))
1001 link_duplex = ETH_LINK_HALF_DUPLEX;
1002 else if (!strcmp(res->value2, "full"))
1003 link_duplex = ETH_LINK_FULL_DUPLEX;
1004 else if (!strcmp(res->value2, "auto"))
1005 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1007 printf("Unknown parameter\n");
1011 ports[res->id].dev_conf.link_speed = link_speed;
1012 ports[res->id].dev_conf.link_duplex = link_duplex;
1014 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1018 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1019 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1021 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1022 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1024 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1025 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1026 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1027 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1029 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1030 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1031 "10#100#1000#10000#40000#auto");
1032 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1033 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1035 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1036 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1039 cmdline_parse_inst_t cmd_config_speed_specific = {
1040 .f = cmd_config_speed_specific_parsed,
1042 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1045 (void *)&cmd_config_speed_specific_port,
1046 (void *)&cmd_config_speed_specific_keyword,
1047 (void *)&cmd_config_speed_specific_id,
1048 (void *)&cmd_config_speed_specific_item1,
1049 (void *)&cmd_config_speed_specific_value1,
1050 (void *)&cmd_config_speed_specific_item2,
1051 (void *)&cmd_config_speed_specific_value2,
1056 /* *** configure txq/rxq, txd/rxd *** */
1057 struct cmd_config_rx_tx {
1058 cmdline_fixed_string_t port;
1059 cmdline_fixed_string_t keyword;
1060 cmdline_fixed_string_t all;
1061 cmdline_fixed_string_t name;
1066 cmd_config_rx_tx_parsed(void *parsed_result,
1067 __attribute__((unused)) struct cmdline *cl,
1068 __attribute__((unused)) void *data)
1070 struct cmd_config_rx_tx *res = parsed_result;
1072 if (!all_ports_stopped()) {
1073 printf("Please stop all ports first\n");
1077 if (!strcmp(res->name, "rxq")) {
1078 if (res->value <= 0) {
1079 printf("rxq %d invalid - must be > 0\n", res->value);
1082 nb_rxq = res->value;
1084 else if (!strcmp(res->name, "txq")) {
1085 if (res->value <= 0) {
1086 printf("txq %d invalid - must be > 0\n", res->value);
1089 nb_txq = res->value;
1091 else if (!strcmp(res->name, "rxd")) {
1092 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1093 printf("rxd %d invalid - must be > 0 && <= %d\n",
1094 res->value, RTE_TEST_RX_DESC_MAX);
1097 nb_rxd = res->value;
1098 } else if (!strcmp(res->name, "txd")) {
1099 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1100 printf("txd %d invalid - must be > 0 && <= %d\n",
1101 res->value, RTE_TEST_TX_DESC_MAX);
1104 nb_txd = res->value;
1106 printf("Unknown parameter\n");
1112 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1115 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1116 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1117 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1118 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1119 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1120 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1121 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1122 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1124 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1125 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1127 cmdline_parse_inst_t cmd_config_rx_tx = {
1128 .f = cmd_config_rx_tx_parsed,
1130 .help_str = "port config all rxq|txq|rxd|txd value",
1132 (void *)&cmd_config_rx_tx_port,
1133 (void *)&cmd_config_rx_tx_keyword,
1134 (void *)&cmd_config_rx_tx_all,
1135 (void *)&cmd_config_rx_tx_name,
1136 (void *)&cmd_config_rx_tx_value,
1141 /* *** config max packet length *** */
1142 struct cmd_config_max_pkt_len_result {
1143 cmdline_fixed_string_t port;
1144 cmdline_fixed_string_t keyword;
1145 cmdline_fixed_string_t all;
1146 cmdline_fixed_string_t name;
1151 cmd_config_max_pkt_len_parsed(void *parsed_result,
1152 __attribute__((unused)) struct cmdline *cl,
1153 __attribute__((unused)) void *data)
1155 struct cmd_config_max_pkt_len_result *res = parsed_result;
1157 if (!all_ports_stopped()) {
1158 printf("Please stop all ports first\n");
1162 if (!strcmp(res->name, "max-pkt-len")) {
1163 if (res->value < ETHER_MIN_LEN) {
1164 printf("max-pkt-len can not be less than %d\n",
1168 if (res->value == rx_mode.max_rx_pkt_len)
1171 rx_mode.max_rx_pkt_len = res->value;
1172 if (res->value > ETHER_MAX_LEN)
1173 rx_mode.jumbo_frame = 1;
1175 rx_mode.jumbo_frame = 0;
1177 printf("Unknown parameter\n");
1183 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1186 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1187 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1189 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1190 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1192 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1193 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1195 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1196 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1198 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1199 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1202 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1203 .f = cmd_config_max_pkt_len_parsed,
1205 .help_str = "port config all max-pkt-len value",
1207 (void *)&cmd_config_max_pkt_len_port,
1208 (void *)&cmd_config_max_pkt_len_keyword,
1209 (void *)&cmd_config_max_pkt_len_all,
1210 (void *)&cmd_config_max_pkt_len_name,
1211 (void *)&cmd_config_max_pkt_len_value,
1216 /* *** configure port MTU *** */
1217 struct cmd_config_mtu_result {
1218 cmdline_fixed_string_t port;
1219 cmdline_fixed_string_t keyword;
1220 cmdline_fixed_string_t mtu;
1226 cmd_config_mtu_parsed(void *parsed_result,
1227 __attribute__((unused)) struct cmdline *cl,
1228 __attribute__((unused)) void *data)
1230 struct cmd_config_mtu_result *res = parsed_result;
1232 if (res->value < ETHER_MIN_LEN) {
1233 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1236 port_mtu_set(res->port_id, res->value);
1239 cmdline_parse_token_string_t cmd_config_mtu_port =
1240 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1242 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1243 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1245 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1246 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1248 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1249 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1250 cmdline_parse_token_num_t cmd_config_mtu_value =
1251 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1253 cmdline_parse_inst_t cmd_config_mtu = {
1254 .f = cmd_config_mtu_parsed,
1256 .help_str = "port config mtu value",
1258 (void *)&cmd_config_mtu_port,
1259 (void *)&cmd_config_mtu_keyword,
1260 (void *)&cmd_config_mtu_mtu,
1261 (void *)&cmd_config_mtu_port_id,
1262 (void *)&cmd_config_mtu_value,
1267 /* *** configure rx mode *** */
1268 struct cmd_config_rx_mode_flag {
1269 cmdline_fixed_string_t port;
1270 cmdline_fixed_string_t keyword;
1271 cmdline_fixed_string_t all;
1272 cmdline_fixed_string_t name;
1273 cmdline_fixed_string_t value;
1277 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1278 __attribute__((unused)) struct cmdline *cl,
1279 __attribute__((unused)) void *data)
1281 struct cmd_config_rx_mode_flag *res = parsed_result;
1283 if (!all_ports_stopped()) {
1284 printf("Please stop all ports first\n");
1288 if (!strcmp(res->name, "crc-strip")) {
1289 if (!strcmp(res->value, "on"))
1290 rx_mode.hw_strip_crc = 1;
1291 else if (!strcmp(res->value, "off"))
1292 rx_mode.hw_strip_crc = 0;
1294 printf("Unknown parameter\n");
1297 } else if (!strcmp(res->name, "rx-cksum")) {
1298 if (!strcmp(res->value, "on"))
1299 rx_mode.hw_ip_checksum = 1;
1300 else if (!strcmp(res->value, "off"))
1301 rx_mode.hw_ip_checksum = 0;
1303 printf("Unknown parameter\n");
1306 } else if (!strcmp(res->name, "hw-vlan")) {
1307 if (!strcmp(res->value, "on")) {
1308 rx_mode.hw_vlan_filter = 1;
1309 rx_mode.hw_vlan_strip = 1;
1311 else if (!strcmp(res->value, "off")) {
1312 rx_mode.hw_vlan_filter = 0;
1313 rx_mode.hw_vlan_strip = 0;
1316 printf("Unknown parameter\n");
1319 } else if (!strcmp(res->name, "drop-en")) {
1320 if (!strcmp(res->value, "on"))
1322 else if (!strcmp(res->value, "off"))
1325 printf("Unknown parameter\n");
1329 printf("Unknown parameter\n");
1335 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1338 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1339 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1340 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1341 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1343 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1344 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1345 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1346 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1347 "crc-strip#rx-cksum#hw-vlan");
1348 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1349 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1352 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1353 .f = cmd_config_rx_mode_flag_parsed,
1355 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1357 (void *)&cmd_config_rx_mode_flag_port,
1358 (void *)&cmd_config_rx_mode_flag_keyword,
1359 (void *)&cmd_config_rx_mode_flag_all,
1360 (void *)&cmd_config_rx_mode_flag_name,
1361 (void *)&cmd_config_rx_mode_flag_value,
1366 /* *** configure rss *** */
1367 struct cmd_config_rss {
1368 cmdline_fixed_string_t port;
1369 cmdline_fixed_string_t keyword;
1370 cmdline_fixed_string_t all;
1371 cmdline_fixed_string_t name;
1372 cmdline_fixed_string_t value;
1376 cmd_config_rss_parsed(void *parsed_result,
1377 __attribute__((unused)) struct cmdline *cl,
1378 __attribute__((unused)) void *data)
1380 struct cmd_config_rss *res = parsed_result;
1381 struct rte_eth_rss_conf rss_conf;
1384 if (!strcmp(res->value, "ip"))
1385 rss_conf.rss_hf = ETH_RSS_IP;
1386 else if (!strcmp(res->value, "udp"))
1387 rss_conf.rss_hf = ETH_RSS_UDP;
1388 else if (!strcmp(res->value, "none"))
1389 rss_conf.rss_hf = 0;
1391 printf("Unknown parameter\n");
1394 rss_conf.rss_key = NULL;
1395 for (i = 0; i < rte_eth_dev_count(); i++)
1396 rte_eth_dev_rss_hash_update(i, &rss_conf);
1399 cmdline_parse_token_string_t cmd_config_rss_port =
1400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1401 cmdline_parse_token_string_t cmd_config_rss_keyword =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1403 cmdline_parse_token_string_t cmd_config_rss_all =
1404 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1405 cmdline_parse_token_string_t cmd_config_rss_name =
1406 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1407 cmdline_parse_token_string_t cmd_config_rss_value =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1410 cmdline_parse_inst_t cmd_config_rss = {
1411 .f = cmd_config_rss_parsed,
1413 .help_str = "port config all rss ip|udp|none",
1415 (void *)&cmd_config_rss_port,
1416 (void *)&cmd_config_rss_keyword,
1417 (void *)&cmd_config_rss_all,
1418 (void *)&cmd_config_rss_name,
1419 (void *)&cmd_config_rss_value,
1424 /* *** configure rss hash key *** */
1425 struct cmd_config_rss_hash_key {
1426 cmdline_fixed_string_t port;
1427 cmdline_fixed_string_t config;
1429 cmdline_fixed_string_t rss_hash_key;
1430 cmdline_fixed_string_t key;
1433 #define RSS_HASH_KEY_LENGTH 40
1435 hexa_digit_to_value(char hexa_digit)
1437 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1438 return (uint8_t) (hexa_digit - '0');
1439 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1440 return (uint8_t) ((hexa_digit - 'a') + 10);
1441 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1442 return (uint8_t) ((hexa_digit - 'A') + 10);
1443 /* Invalid hexa digit */
1448 parse_and_check_key_hexa_digit(char *key, int idx)
1452 hexa_v = hexa_digit_to_value(key[idx]);
1454 printf("invalid key: character %c at position %d is not a "
1455 "valid hexa digit\n", key[idx], idx);
1460 cmd_config_rss_hash_key_parsed(void *parsed_result,
1461 __attribute__((unused)) struct cmdline *cl,
1462 __attribute__((unused)) void *data)
1464 struct cmd_config_rss_hash_key *res = parsed_result;
1465 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1470 /* Check the length of the RSS hash key */
1471 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1472 printf("key length: %d invalid - key must be a string of %d"
1473 "hexa-decimal numbers\n", (int) strlen(res->key),
1474 RSS_HASH_KEY_LENGTH * 2);
1477 /* Translate RSS hash key into binary representation */
1478 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1479 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1482 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1485 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1487 port_rss_hash_key_update(res->port_id, hash_key);
1490 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1491 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1492 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1495 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1496 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1497 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1499 rss_hash_key, "rss-hash-key");
1500 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1501 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1503 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1504 .f = cmd_config_rss_hash_key_parsed,
1506 .help_str = "port config X rss-hash-key 80 hexa digits",
1508 (void *)&cmd_config_rss_hash_key_port,
1509 (void *)&cmd_config_rss_hash_key_config,
1510 (void *)&cmd_config_rss_hash_key_port_id,
1511 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1512 (void *)&cmd_config_rss_hash_key_value,
1517 /* *** configure port rxq/txq start/stop *** */
1518 struct cmd_config_rxtx_queue {
1519 cmdline_fixed_string_t port;
1521 cmdline_fixed_string_t rxtxq;
1523 cmdline_fixed_string_t opname;
1527 cmd_config_rxtx_queue_parsed(void *parsed_result,
1528 __attribute__((unused)) struct cmdline *cl,
1529 __attribute__((unused)) void *data)
1531 struct cmd_config_rxtx_queue *res = parsed_result;
1536 if (test_done == 0) {
1537 printf("Please stop forwarding first\n");
1541 if (port_id_is_invalid(res->portid))
1544 if (port_is_started(res->portid) != 1) {
1545 printf("Please start port %u first\n", res->portid);
1549 if (!strcmp(res->rxtxq, "rxq"))
1551 else if (!strcmp(res->rxtxq, "txq"))
1554 printf("Unknown parameter\n");
1558 if (isrx && rx_queue_id_is_invalid(res->qid))
1560 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1563 if (!strcmp(res->opname, "start"))
1565 else if (!strcmp(res->opname, "stop"))
1568 printf("Unknown parameter\n");
1572 if (isstart && isrx)
1573 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1574 else if (!isstart && isrx)
1575 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1576 else if (isstart && !isrx)
1577 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1579 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1581 if (ret == -ENOTSUP)
1582 printf("Function not supported in PMD driver\n");
1585 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1587 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1588 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1589 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1590 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1591 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1592 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1593 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1594 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1597 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1598 .f = cmd_config_rxtx_queue_parsed,
1600 .help_str = "port X rxq|txq ID start|stop",
1602 (void *)&cmd_config_speed_all_port,
1603 (void *)&cmd_config_rxtx_queue_portid,
1604 (void *)&cmd_config_rxtx_queue_rxtxq,
1605 (void *)&cmd_config_rxtx_queue_qid,
1606 (void *)&cmd_config_rxtx_queue_opname,
1611 /* *** Configure RSS RETA *** */
1612 struct cmd_config_rss_reta {
1613 cmdline_fixed_string_t port;
1614 cmdline_fixed_string_t keyword;
1616 cmdline_fixed_string_t name;
1617 cmdline_fixed_string_t list_name;
1618 cmdline_fixed_string_t list_of_items;
1622 parse_reta_config(const char *str,
1623 struct rte_eth_rss_reta_entry64 *reta_conf,
1624 uint16_t nb_entries)
1628 uint16_t hash_index, idx, shift;
1631 const char *p, *p0 = str;
1638 unsigned long int_fld[_NUM_FLD];
1639 char *str_fld[_NUM_FLD];
1641 while ((p = strchr(p0,'(')) != NULL) {
1643 if((p0 = strchr(p,')')) == NULL)
1647 if(size >= sizeof(s))
1650 snprintf(s, sizeof(s), "%.*s", size, p);
1651 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1653 for (i = 0; i < _NUM_FLD; i++) {
1655 int_fld[i] = strtoul(str_fld[i], &end, 0);
1656 if (errno != 0 || end == str_fld[i] ||
1661 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1662 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1664 if (hash_index >= nb_entries) {
1665 printf("Invalid RETA hash index=%d\n", hash_index);
1669 idx = hash_index / RTE_RETA_GROUP_SIZE;
1670 shift = hash_index % RTE_RETA_GROUP_SIZE;
1671 reta_conf[idx].mask |= (1ULL << shift);
1672 reta_conf[idx].reta[shift] = nb_queue;
1679 cmd_set_rss_reta_parsed(void *parsed_result,
1680 __attribute__((unused)) struct cmdline *cl,
1681 __attribute__((unused)) void *data)
1684 struct rte_eth_dev_info dev_info;
1685 struct rte_eth_rss_reta_entry64 reta_conf[8];
1686 struct cmd_config_rss_reta *res = parsed_result;
1688 memset(&dev_info, 0, sizeof(dev_info));
1689 rte_eth_dev_info_get(res->port_id, &dev_info);
1690 if (dev_info.reta_size == 0) {
1691 printf("Redirection table size is 0 which is "
1692 "invalid for RSS\n");
1695 printf("The reta size of port %d is %u\n",
1696 res->port_id, dev_info.reta_size);
1697 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1698 printf("Currently do not support more than %u entries of "
1699 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1703 memset(reta_conf, 0, sizeof(reta_conf));
1704 if (!strcmp(res->list_name, "reta")) {
1705 if (parse_reta_config(res->list_of_items, reta_conf,
1706 dev_info.reta_size)) {
1707 printf("Invalid RSS Redirection Table "
1708 "config entered\n");
1711 ret = rte_eth_dev_rss_reta_update(res->port_id,
1712 reta_conf, dev_info.reta_size);
1714 printf("Bad redirection table parameter, "
1715 "return code = %d \n", ret);
1719 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1721 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1723 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1724 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1725 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1726 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1727 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1728 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1729 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1730 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1732 cmdline_parse_inst_t cmd_config_rss_reta = {
1733 .f = cmd_set_rss_reta_parsed,
1735 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1737 (void *)&cmd_config_rss_reta_port,
1738 (void *)&cmd_config_rss_reta_keyword,
1739 (void *)&cmd_config_rss_reta_port_id,
1740 (void *)&cmd_config_rss_reta_name,
1741 (void *)&cmd_config_rss_reta_list_name,
1742 (void *)&cmd_config_rss_reta_list_of_items,
1747 /* *** SHOW PORT RETA INFO *** */
1748 struct cmd_showport_reta {
1749 cmdline_fixed_string_t show;
1750 cmdline_fixed_string_t port;
1752 cmdline_fixed_string_t rss;
1753 cmdline_fixed_string_t reta;
1755 cmdline_fixed_string_t list_of_items;
1759 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1760 uint16_t nb_entries,
1764 const char *p, *p0 = str;
1768 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1771 p = strchr(p0, '(');
1775 p0 = strchr(p, ')');
1779 if (size >= sizeof(s)) {
1780 printf("The string size exceeds the internal buffer size\n");
1783 snprintf(s, sizeof(s), "%.*s", size, p);
1784 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1785 if (ret <= 0 || ret != num) {
1786 printf("The bits of masks do not match the number of "
1787 "reta entries: %u\n", num);
1790 for (i = 0; i < ret; i++)
1791 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1797 cmd_showport_reta_parsed(void *parsed_result,
1798 __attribute__((unused)) struct cmdline *cl,
1799 __attribute__((unused)) void *data)
1801 struct cmd_showport_reta *res = parsed_result;
1802 struct rte_eth_rss_reta_entry64 reta_conf[8];
1803 struct rte_eth_dev_info dev_info;
1805 memset(&dev_info, 0, sizeof(dev_info));
1806 rte_eth_dev_info_get(res->port_id, &dev_info);
1807 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1808 res->size > ETH_RSS_RETA_SIZE_512) {
1809 printf("Invalid redirection table size: %u\n", res->size);
1813 memset(reta_conf, 0, sizeof(reta_conf));
1814 if (showport_parse_reta_config(reta_conf, res->size,
1815 res->list_of_items) < 0) {
1816 printf("Invalid string: %s for reta masks\n",
1817 res->list_of_items);
1820 port_rss_reta_info(res->port_id, reta_conf, res->size);
1823 cmdline_parse_token_string_t cmd_showport_reta_show =
1824 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1825 cmdline_parse_token_string_t cmd_showport_reta_port =
1826 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1827 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1828 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1829 cmdline_parse_token_string_t cmd_showport_reta_rss =
1830 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1831 cmdline_parse_token_string_t cmd_showport_reta_reta =
1832 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1833 cmdline_parse_token_num_t cmd_showport_reta_size =
1834 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1835 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1836 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1837 list_of_items, NULL);
1839 cmdline_parse_inst_t cmd_showport_reta = {
1840 .f = cmd_showport_reta_parsed,
1842 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1844 (void *)&cmd_showport_reta_show,
1845 (void *)&cmd_showport_reta_port,
1846 (void *)&cmd_showport_reta_port_id,
1847 (void *)&cmd_showport_reta_rss,
1848 (void *)&cmd_showport_reta_reta,
1849 (void *)&cmd_showport_reta_size,
1850 (void *)&cmd_showport_reta_list_of_items,
1855 /* *** Show RSS hash configuration *** */
1856 struct cmd_showport_rss_hash {
1857 cmdline_fixed_string_t show;
1858 cmdline_fixed_string_t port;
1860 cmdline_fixed_string_t rss_hash;
1861 cmdline_fixed_string_t key; /* optional argument */
1864 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1865 __attribute__((unused)) struct cmdline *cl,
1868 struct cmd_showport_rss_hash *res = parsed_result;
1870 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1873 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1874 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1875 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1876 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1877 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1878 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1879 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1880 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1882 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1883 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1885 cmdline_parse_inst_t cmd_showport_rss_hash = {
1886 .f = cmd_showport_rss_hash_parsed,
1888 .help_str = "show port X rss-hash (X = port number)\n",
1890 (void *)&cmd_showport_rss_hash_show,
1891 (void *)&cmd_showport_rss_hash_port,
1892 (void *)&cmd_showport_rss_hash_port_id,
1893 (void *)&cmd_showport_rss_hash_rss_hash,
1898 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1899 .f = cmd_showport_rss_hash_parsed,
1901 .help_str = "show port X rss-hash key (X = port number)\n",
1903 (void *)&cmd_showport_rss_hash_show,
1904 (void *)&cmd_showport_rss_hash_port,
1905 (void *)&cmd_showport_rss_hash_port_id,
1906 (void *)&cmd_showport_rss_hash_rss_hash,
1907 (void *)&cmd_showport_rss_hash_rss_key,
1912 /* *** Configure DCB *** */
1913 struct cmd_config_dcb {
1914 cmdline_fixed_string_t port;
1915 cmdline_fixed_string_t config;
1917 cmdline_fixed_string_t dcb;
1918 cmdline_fixed_string_t vt;
1919 cmdline_fixed_string_t vt_en;
1921 cmdline_fixed_string_t pfc;
1922 cmdline_fixed_string_t pfc_en;
1926 cmd_config_dcb_parsed(void *parsed_result,
1927 __attribute__((unused)) struct cmdline *cl,
1928 __attribute__((unused)) void *data)
1930 struct cmd_config_dcb *res = parsed_result;
1931 struct dcb_config dcb_conf;
1932 portid_t port_id = res->port_id;
1933 struct rte_port *port;
1935 port = &ports[port_id];
1936 /** Check if the port is not started **/
1937 if (port->port_status != RTE_PORT_STOPPED) {
1938 printf("Please stop port %d first\n",port_id);
1942 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1943 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1944 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1948 /* DCB in VT mode */
1949 if (!strncmp(res->vt_en, "on",2))
1950 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1952 dcb_conf.dcb_mode = DCB_ENABLED;
1954 if (!strncmp(res->pfc_en, "on",2)) {
1955 dcb_conf.pfc_en = 1;
1958 dcb_conf.pfc_en = 0;
1960 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1961 printf("Cannot initialize network ports\n");
1965 cmd_reconfig_device_queue(port_id, 1, 1);
1968 cmdline_parse_token_string_t cmd_config_dcb_port =
1969 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1970 cmdline_parse_token_string_t cmd_config_dcb_config =
1971 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1972 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1973 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1974 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1975 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1976 cmdline_parse_token_string_t cmd_config_dcb_vt =
1977 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1978 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1979 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1980 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1981 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1982 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1983 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1984 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1985 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1987 cmdline_parse_inst_t cmd_config_dcb = {
1988 .f = cmd_config_dcb_parsed,
1990 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1992 (void *)&cmd_config_dcb_port,
1993 (void *)&cmd_config_dcb_config,
1994 (void *)&cmd_config_dcb_port_id,
1995 (void *)&cmd_config_dcb_dcb,
1996 (void *)&cmd_config_dcb_vt,
1997 (void *)&cmd_config_dcb_vt_en,
1998 (void *)&cmd_config_dcb_num_tcs,
1999 (void *)&cmd_config_dcb_pfc,
2000 (void *)&cmd_config_dcb_pfc_en,
2005 /* *** configure number of packets per burst *** */
2006 struct cmd_config_burst {
2007 cmdline_fixed_string_t port;
2008 cmdline_fixed_string_t keyword;
2009 cmdline_fixed_string_t all;
2010 cmdline_fixed_string_t name;
2015 cmd_config_burst_parsed(void *parsed_result,
2016 __attribute__((unused)) struct cmdline *cl,
2017 __attribute__((unused)) void *data)
2019 struct cmd_config_burst *res = parsed_result;
2021 if (!all_ports_stopped()) {
2022 printf("Please stop all ports first\n");
2026 if (!strcmp(res->name, "burst")) {
2027 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2028 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2031 nb_pkt_per_burst = res->value;
2033 printf("Unknown parameter\n");
2039 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2042 cmdline_parse_token_string_t cmd_config_burst_port =
2043 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2044 cmdline_parse_token_string_t cmd_config_burst_keyword =
2045 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2046 cmdline_parse_token_string_t cmd_config_burst_all =
2047 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2048 cmdline_parse_token_string_t cmd_config_burst_name =
2049 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2050 cmdline_parse_token_num_t cmd_config_burst_value =
2051 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2053 cmdline_parse_inst_t cmd_config_burst = {
2054 .f = cmd_config_burst_parsed,
2056 .help_str = "port config all burst value",
2058 (void *)&cmd_config_burst_port,
2059 (void *)&cmd_config_burst_keyword,
2060 (void *)&cmd_config_burst_all,
2061 (void *)&cmd_config_burst_name,
2062 (void *)&cmd_config_burst_value,
2067 /* *** configure rx/tx queues *** */
2068 struct cmd_config_thresh {
2069 cmdline_fixed_string_t port;
2070 cmdline_fixed_string_t keyword;
2071 cmdline_fixed_string_t all;
2072 cmdline_fixed_string_t name;
2077 cmd_config_thresh_parsed(void *parsed_result,
2078 __attribute__((unused)) struct cmdline *cl,
2079 __attribute__((unused)) void *data)
2081 struct cmd_config_thresh *res = parsed_result;
2083 if (!all_ports_stopped()) {
2084 printf("Please stop all ports first\n");
2088 if (!strcmp(res->name, "txpt"))
2089 tx_thresh.pthresh = res->value;
2090 else if(!strcmp(res->name, "txht"))
2091 tx_thresh.hthresh = res->value;
2092 else if(!strcmp(res->name, "txwt"))
2093 tx_thresh.wthresh = res->value;
2094 else if(!strcmp(res->name, "rxpt"))
2095 rx_thresh.pthresh = res->value;
2096 else if(!strcmp(res->name, "rxht"))
2097 rx_thresh.hthresh = res->value;
2098 else if(!strcmp(res->name, "rxwt"))
2099 rx_thresh.wthresh = res->value;
2101 printf("Unknown parameter\n");
2107 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2110 cmdline_parse_token_string_t cmd_config_thresh_port =
2111 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2112 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2113 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2114 cmdline_parse_token_string_t cmd_config_thresh_all =
2115 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2116 cmdline_parse_token_string_t cmd_config_thresh_name =
2117 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2118 "txpt#txht#txwt#rxpt#rxht#rxwt");
2119 cmdline_parse_token_num_t cmd_config_thresh_value =
2120 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2122 cmdline_parse_inst_t cmd_config_thresh = {
2123 .f = cmd_config_thresh_parsed,
2125 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2127 (void *)&cmd_config_thresh_port,
2128 (void *)&cmd_config_thresh_keyword,
2129 (void *)&cmd_config_thresh_all,
2130 (void *)&cmd_config_thresh_name,
2131 (void *)&cmd_config_thresh_value,
2136 /* *** configure free/rs threshold *** */
2137 struct cmd_config_threshold {
2138 cmdline_fixed_string_t port;
2139 cmdline_fixed_string_t keyword;
2140 cmdline_fixed_string_t all;
2141 cmdline_fixed_string_t name;
2146 cmd_config_threshold_parsed(void *parsed_result,
2147 __attribute__((unused)) struct cmdline *cl,
2148 __attribute__((unused)) void *data)
2150 struct cmd_config_threshold *res = parsed_result;
2152 if (!all_ports_stopped()) {
2153 printf("Please stop all ports first\n");
2157 if (!strcmp(res->name, "txfreet"))
2158 tx_free_thresh = res->value;
2159 else if (!strcmp(res->name, "txrst"))
2160 tx_rs_thresh = res->value;
2161 else if (!strcmp(res->name, "rxfreet"))
2162 rx_free_thresh = res->value;
2164 printf("Unknown parameter\n");
2170 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2173 cmdline_parse_token_string_t cmd_config_threshold_port =
2174 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2175 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2176 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2178 cmdline_parse_token_string_t cmd_config_threshold_all =
2179 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2180 cmdline_parse_token_string_t cmd_config_threshold_name =
2181 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2182 "txfreet#txrst#rxfreet");
2183 cmdline_parse_token_num_t cmd_config_threshold_value =
2184 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2186 cmdline_parse_inst_t cmd_config_threshold = {
2187 .f = cmd_config_threshold_parsed,
2189 .help_str = "port config all txfreet|txrst|rxfreet value",
2191 (void *)&cmd_config_threshold_port,
2192 (void *)&cmd_config_threshold_keyword,
2193 (void *)&cmd_config_threshold_all,
2194 (void *)&cmd_config_threshold_name,
2195 (void *)&cmd_config_threshold_value,
2201 struct cmd_stop_result {
2202 cmdline_fixed_string_t stop;
2205 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2206 __attribute__((unused)) struct cmdline *cl,
2207 __attribute__((unused)) void *data)
2209 stop_packet_forwarding();
2212 cmdline_parse_token_string_t cmd_stop_stop =
2213 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2215 cmdline_parse_inst_t cmd_stop = {
2216 .f = cmd_stop_parsed,
2218 .help_str = "stop - stop packet forwarding",
2220 (void *)&cmd_stop_stop,
2225 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2228 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2229 unsigned int *parsed_items, int check_unique_values)
2231 unsigned int nb_item;
2239 * First parse all items in the list and store their value.
2244 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2246 if ((c >= '0') && (c <= '9')) {
2247 value = (unsigned int) (value * 10 + (c - '0'));
2252 printf("character %c is not a decimal digit\n", c);
2256 printf("No valid value before comma\n");
2259 if (nb_item < max_items) {
2260 parsed_items[nb_item] = value;
2266 if (nb_item >= max_items) {
2267 printf("Number of %s = %u > %u (maximum items)\n",
2268 item_name, nb_item + 1, max_items);
2271 parsed_items[nb_item++] = value;
2272 if (! check_unique_values)
2276 * Then, check that all values in the list are differents.
2277 * No optimization here...
2279 for (i = 0; i < nb_item; i++) {
2280 for (j = i + 1; j < nb_item; j++) {
2281 if (parsed_items[j] == parsed_items[i]) {
2282 printf("duplicated %s %u at index %u and %u\n",
2283 item_name, parsed_items[i], i, j);
2291 struct cmd_set_list_result {
2292 cmdline_fixed_string_t cmd_keyword;
2293 cmdline_fixed_string_t list_name;
2294 cmdline_fixed_string_t list_of_items;
2297 static void cmd_set_list_parsed(void *parsed_result,
2298 __attribute__((unused)) struct cmdline *cl,
2299 __attribute__((unused)) void *data)
2301 struct cmd_set_list_result *res;
2303 unsigned int lcorelist[RTE_MAX_LCORE];
2304 unsigned int portlist[RTE_MAX_ETHPORTS];
2306 unsigned int nb_item;
2308 res = parsed_result;
2309 if (!strcmp(res->list_name, "corelist")) {
2310 nb_item = parse_item_list(res->list_of_items, "core",
2312 parsed_items.lcorelist, 1);
2314 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2317 if (!strcmp(res->list_name, "portlist")) {
2318 nb_item = parse_item_list(res->list_of_items, "port",
2320 parsed_items.portlist, 1);
2322 set_fwd_ports_list(parsed_items.portlist, nb_item);
2326 cmdline_parse_token_string_t cmd_set_list_keyword =
2327 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2329 cmdline_parse_token_string_t cmd_set_list_name =
2330 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2331 "corelist#portlist");
2332 cmdline_parse_token_string_t cmd_set_list_of_items =
2333 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2336 cmdline_parse_inst_t cmd_set_fwd_list = {
2337 .f = cmd_set_list_parsed,
2339 .help_str = "set corelist|portlist x[,y]*",
2341 (void *)&cmd_set_list_keyword,
2342 (void *)&cmd_set_list_name,
2343 (void *)&cmd_set_list_of_items,
2348 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2350 struct cmd_setmask_result {
2351 cmdline_fixed_string_t set;
2352 cmdline_fixed_string_t mask;
2356 static void cmd_set_mask_parsed(void *parsed_result,
2357 __attribute__((unused)) struct cmdline *cl,
2358 __attribute__((unused)) void *data)
2360 struct cmd_setmask_result *res = parsed_result;
2362 if (!strcmp(res->mask, "coremask"))
2363 set_fwd_lcores_mask(res->hexavalue);
2364 else if (!strcmp(res->mask, "portmask"))
2365 set_fwd_ports_mask(res->hexavalue);
2368 cmdline_parse_token_string_t cmd_setmask_set =
2369 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2370 cmdline_parse_token_string_t cmd_setmask_mask =
2371 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2372 "coremask#portmask");
2373 cmdline_parse_token_num_t cmd_setmask_value =
2374 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2376 cmdline_parse_inst_t cmd_set_fwd_mask = {
2377 .f = cmd_set_mask_parsed,
2379 .help_str = "set coremask|portmask hexadecimal value",
2381 (void *)&cmd_setmask_set,
2382 (void *)&cmd_setmask_mask,
2383 (void *)&cmd_setmask_value,
2389 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2391 struct cmd_set_result {
2392 cmdline_fixed_string_t set;
2393 cmdline_fixed_string_t what;
2397 static void cmd_set_parsed(void *parsed_result,
2398 __attribute__((unused)) struct cmdline *cl,
2399 __attribute__((unused)) void *data)
2401 struct cmd_set_result *res = parsed_result;
2402 if (!strcmp(res->what, "nbport"))
2403 set_fwd_ports_number(res->value);
2404 else if (!strcmp(res->what, "nbcore"))
2405 set_fwd_lcores_number(res->value);
2406 else if (!strcmp(res->what, "burst"))
2407 set_nb_pkt_per_burst(res->value);
2408 else if (!strcmp(res->what, "verbose"))
2409 set_verbose_level(res->value);
2412 cmdline_parse_token_string_t cmd_set_set =
2413 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2414 cmdline_parse_token_string_t cmd_set_what =
2415 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2416 "nbport#nbcore#burst#verbose");
2417 cmdline_parse_token_num_t cmd_set_value =
2418 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2420 cmdline_parse_inst_t cmd_set_numbers = {
2421 .f = cmd_set_parsed,
2423 .help_str = "set nbport|nbcore|burst|verbose value",
2425 (void *)&cmd_set_set,
2426 (void *)&cmd_set_what,
2427 (void *)&cmd_set_value,
2432 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2434 struct cmd_set_txpkts_result {
2435 cmdline_fixed_string_t cmd_keyword;
2436 cmdline_fixed_string_t txpkts;
2437 cmdline_fixed_string_t seg_lengths;
2441 cmd_set_txpkts_parsed(void *parsed_result,
2442 __attribute__((unused)) struct cmdline *cl,
2443 __attribute__((unused)) void *data)
2445 struct cmd_set_txpkts_result *res;
2446 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2447 unsigned int nb_segs;
2449 res = parsed_result;
2450 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2451 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2453 set_tx_pkt_segments(seg_lengths, nb_segs);
2456 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2457 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2458 cmd_keyword, "set");
2459 cmdline_parse_token_string_t cmd_set_txpkts_name =
2460 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2462 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2463 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2466 cmdline_parse_inst_t cmd_set_txpkts = {
2467 .f = cmd_set_txpkts_parsed,
2469 .help_str = "set txpkts x[,y]*",
2471 (void *)&cmd_set_txpkts_keyword,
2472 (void *)&cmd_set_txpkts_name,
2473 (void *)&cmd_set_txpkts_lengths,
2478 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2479 struct cmd_rx_vlan_filter_all_result {
2480 cmdline_fixed_string_t rx_vlan;
2481 cmdline_fixed_string_t what;
2482 cmdline_fixed_string_t all;
2487 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2488 __attribute__((unused)) struct cmdline *cl,
2489 __attribute__((unused)) void *data)
2491 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2493 if (!strcmp(res->what, "add"))
2494 rx_vlan_all_filter_set(res->port_id, 1);
2496 rx_vlan_all_filter_set(res->port_id, 0);
2499 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2500 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2501 rx_vlan, "rx_vlan");
2502 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2503 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2505 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2506 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2508 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2509 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2512 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2513 .f = cmd_rx_vlan_filter_all_parsed,
2515 .help_str = "add/remove all identifiers to/from the set of VLAN "
2516 "Identifiers filtered by a port",
2518 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2519 (void *)&cmd_rx_vlan_filter_all_what,
2520 (void *)&cmd_rx_vlan_filter_all_all,
2521 (void *)&cmd_rx_vlan_filter_all_portid,
2526 /* *** VLAN OFFLOAD SET ON A PORT *** */
2527 struct cmd_vlan_offload_result {
2528 cmdline_fixed_string_t vlan;
2529 cmdline_fixed_string_t set;
2530 cmdline_fixed_string_t what;
2531 cmdline_fixed_string_t on;
2532 cmdline_fixed_string_t port_id;
2536 cmd_vlan_offload_parsed(void *parsed_result,
2537 __attribute__((unused)) struct cmdline *cl,
2538 __attribute__((unused)) void *data)
2541 struct cmd_vlan_offload_result *res = parsed_result;
2544 portid_t port_id = 0;
2548 len = strnlen(str, STR_TOKEN_SIZE);
2550 /* Get port_id first */
2558 tmp = strtoul(str, NULL, 0);
2559 /* If port_id greater that what portid_t can represent, return */
2560 if(tmp >= RTE_MAX_ETHPORTS)
2562 port_id = (portid_t)tmp;
2564 if (!strcmp(res->on, "on"))
2569 if (!strcmp(res->what, "strip"))
2570 rx_vlan_strip_set(port_id, on);
2571 else if(!strcmp(res->what, "stripq")){
2572 uint16_t queue_id = 0;
2574 /* No queue_id, return */
2576 printf("must specify (port,queue_id)\n");
2579 tmp = strtoul(str + i + 1, NULL, 0);
2580 /* If queue_id greater that what 16-bits can represent, return */
2584 queue_id = (uint16_t)tmp;
2585 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2587 else if (!strcmp(res->what, "filter"))
2588 rx_vlan_filter_set(port_id, on);
2590 vlan_extend_set(port_id, on);
2595 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2596 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2598 cmdline_parse_token_string_t cmd_vlan_offload_set =
2599 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2601 cmdline_parse_token_string_t cmd_vlan_offload_what =
2602 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2603 what, "strip#filter#qinq#stripq");
2604 cmdline_parse_token_string_t cmd_vlan_offload_on =
2605 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2607 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2608 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2611 cmdline_parse_inst_t cmd_vlan_offload = {
2612 .f = cmd_vlan_offload_parsed,
2614 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2615 " qinq(extended) for both rx/tx sides ",
2617 (void *)&cmd_vlan_offload_vlan,
2618 (void *)&cmd_vlan_offload_set,
2619 (void *)&cmd_vlan_offload_what,
2620 (void *)&cmd_vlan_offload_on,
2621 (void *)&cmd_vlan_offload_portid,
2626 /* *** VLAN TPID SET ON A PORT *** */
2627 struct cmd_vlan_tpid_result {
2628 cmdline_fixed_string_t vlan;
2629 cmdline_fixed_string_t set;
2630 cmdline_fixed_string_t what;
2636 cmd_vlan_tpid_parsed(void *parsed_result,
2637 __attribute__((unused)) struct cmdline *cl,
2638 __attribute__((unused)) void *data)
2640 struct cmd_vlan_tpid_result *res = parsed_result;
2641 vlan_tpid_set(res->port_id, res->tp_id);
2645 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2646 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2648 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2649 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2651 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2652 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2654 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2655 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2657 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2658 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2661 cmdline_parse_inst_t cmd_vlan_tpid = {
2662 .f = cmd_vlan_tpid_parsed,
2664 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2666 (void *)&cmd_vlan_tpid_vlan,
2667 (void *)&cmd_vlan_tpid_set,
2668 (void *)&cmd_vlan_tpid_what,
2669 (void *)&cmd_vlan_tpid_tpid,
2670 (void *)&cmd_vlan_tpid_portid,
2675 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2676 struct cmd_rx_vlan_filter_result {
2677 cmdline_fixed_string_t rx_vlan;
2678 cmdline_fixed_string_t what;
2684 cmd_rx_vlan_filter_parsed(void *parsed_result,
2685 __attribute__((unused)) struct cmdline *cl,
2686 __attribute__((unused)) void *data)
2688 struct cmd_rx_vlan_filter_result *res = parsed_result;
2690 if (!strcmp(res->what, "add"))
2691 rx_vft_set(res->port_id, res->vlan_id, 1);
2693 rx_vft_set(res->port_id, res->vlan_id, 0);
2696 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2697 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2698 rx_vlan, "rx_vlan");
2699 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2700 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2702 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2703 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2705 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2706 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2709 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2710 .f = cmd_rx_vlan_filter_parsed,
2712 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2713 "Identifiers filtered by a port",
2715 (void *)&cmd_rx_vlan_filter_rx_vlan,
2716 (void *)&cmd_rx_vlan_filter_what,
2717 (void *)&cmd_rx_vlan_filter_vlanid,
2718 (void *)&cmd_rx_vlan_filter_portid,
2723 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2724 struct cmd_tx_vlan_set_result {
2725 cmdline_fixed_string_t tx_vlan;
2726 cmdline_fixed_string_t set;
2732 cmd_tx_vlan_set_parsed(void *parsed_result,
2733 __attribute__((unused)) struct cmdline *cl,
2734 __attribute__((unused)) void *data)
2736 struct cmd_tx_vlan_set_result *res = parsed_result;
2737 tx_vlan_set(res->port_id, res->vlan_id);
2740 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2741 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2742 tx_vlan, "tx_vlan");
2743 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2744 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2746 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2747 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2749 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2750 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2753 cmdline_parse_inst_t cmd_tx_vlan_set = {
2754 .f = cmd_tx_vlan_set_parsed,
2756 .help_str = "enable hardware insertion of a VLAN header with a given "
2757 "TAG Identifier in packets sent on a port",
2759 (void *)&cmd_tx_vlan_set_tx_vlan,
2760 (void *)&cmd_tx_vlan_set_set,
2761 (void *)&cmd_tx_vlan_set_vlanid,
2762 (void *)&cmd_tx_vlan_set_portid,
2767 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2768 struct cmd_tx_vlan_set_pvid_result {
2769 cmdline_fixed_string_t tx_vlan;
2770 cmdline_fixed_string_t set;
2771 cmdline_fixed_string_t pvid;
2774 cmdline_fixed_string_t mode;
2778 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2779 __attribute__((unused)) struct cmdline *cl,
2780 __attribute__((unused)) void *data)
2782 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2784 if (strcmp(res->mode, "on") == 0)
2785 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2787 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2790 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2791 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2792 tx_vlan, "tx_vlan");
2793 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2794 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2796 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2797 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2799 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2800 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2802 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2803 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2805 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2806 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2809 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2810 .f = cmd_tx_vlan_set_pvid_parsed,
2812 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2814 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2815 (void *)&cmd_tx_vlan_set_pvid_set,
2816 (void *)&cmd_tx_vlan_set_pvid_pvid,
2817 (void *)&cmd_tx_vlan_set_pvid_port_id,
2818 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2819 (void *)&cmd_tx_vlan_set_pvid_mode,
2824 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2825 struct cmd_tx_vlan_reset_result {
2826 cmdline_fixed_string_t tx_vlan;
2827 cmdline_fixed_string_t reset;
2832 cmd_tx_vlan_reset_parsed(void *parsed_result,
2833 __attribute__((unused)) struct cmdline *cl,
2834 __attribute__((unused)) void *data)
2836 struct cmd_tx_vlan_reset_result *res = parsed_result;
2838 tx_vlan_reset(res->port_id);
2841 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2842 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2843 tx_vlan, "tx_vlan");
2844 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2845 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2847 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2848 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2851 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2852 .f = cmd_tx_vlan_reset_parsed,
2854 .help_str = "disable hardware insertion of a VLAN header in packets "
2857 (void *)&cmd_tx_vlan_reset_tx_vlan,
2858 (void *)&cmd_tx_vlan_reset_reset,
2859 (void *)&cmd_tx_vlan_reset_portid,
2865 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2866 struct cmd_tx_cksum_result {
2867 cmdline_fixed_string_t tx_cksum;
2868 cmdline_fixed_string_t mode;
2869 cmdline_fixed_string_t proto;
2870 cmdline_fixed_string_t hwsw;
2875 cmd_tx_cksum_parsed(void *parsed_result,
2876 __attribute__((unused)) struct cmdline *cl,
2877 __attribute__((unused)) void *data)
2879 struct cmd_tx_cksum_result *res = parsed_result;
2881 uint16_t ol_flags, mask = 0;
2882 struct rte_eth_dev_info dev_info;
2884 if (port_id_is_invalid(res->port_id)) {
2885 printf("invalid port %d\n", res->port_id);
2889 if (!strcmp(res->mode, "set")) {
2891 if (!strcmp(res->hwsw, "hw"))
2894 if (!strcmp(res->proto, "ip")) {
2895 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2896 } else if (!strcmp(res->proto, "udp")) {
2897 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2898 } else if (!strcmp(res->proto, "tcp")) {
2899 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2900 } else if (!strcmp(res->proto, "sctp")) {
2901 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2902 } else if (!strcmp(res->proto, "vxlan")) {
2903 mask = TESTPMD_TX_OFFLOAD_VXLAN_CKSUM;
2907 ports[res->port_id].tx_ol_flags |= mask;
2909 ports[res->port_id].tx_ol_flags &= (~mask);
2912 ol_flags = ports[res->port_id].tx_ol_flags;
2913 printf("IP checksum offload is %s\n",
2914 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2915 printf("UDP checksum offload is %s\n",
2916 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2917 printf("TCP checksum offload is %s\n",
2918 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2919 printf("SCTP checksum offload is %s\n",
2920 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2921 printf("VxLAN checksum offload is %s\n",
2922 (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw");
2924 /* display warnings if configuration is not supported by the NIC */
2925 rte_eth_dev_info_get(res->port_id, &dev_info);
2926 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2927 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2928 printf("Warning: hardware IP checksum enabled but not "
2929 "supported by port %d\n", res->port_id);
2931 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2932 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2933 printf("Warning: hardware UDP checksum enabled but not "
2934 "supported by port %d\n", res->port_id);
2936 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2937 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2938 printf("Warning: hardware TCP checksum enabled but not "
2939 "supported by port %d\n", res->port_id);
2941 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2942 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2943 printf("Warning: hardware SCTP checksum enabled but not "
2944 "supported by port %d\n", res->port_id);
2948 cmdline_parse_token_string_t cmd_tx_cksum_tx_cksum =
2949 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2950 tx_cksum, "tx_checksum");
2951 cmdline_parse_token_string_t cmd_tx_cksum_mode =
2952 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2954 cmdline_parse_token_string_t cmd_tx_cksum_proto =
2955 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2956 proto, "ip#tcp#udp#sctp#vxlan");
2957 cmdline_parse_token_string_t cmd_tx_cksum_hwsw =
2958 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2960 cmdline_parse_token_num_t cmd_tx_cksum_portid =
2961 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_result,
2964 cmdline_parse_inst_t cmd_tx_cksum_set = {
2965 .f = cmd_tx_cksum_parsed,
2967 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
2968 "using csum forward engine: tx_cksum set ip|tcp|udp|sctp|vxlan hw|sw <port>",
2970 (void *)&cmd_tx_cksum_tx_cksum,
2971 (void *)&cmd_tx_cksum_mode,
2972 (void *)&cmd_tx_cksum_proto,
2973 (void *)&cmd_tx_cksum_hwsw,
2974 (void *)&cmd_tx_cksum_portid,
2979 cmdline_parse_token_string_t cmd_tx_cksum_mode_show =
2980 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2983 cmdline_parse_inst_t cmd_tx_cksum_show = {
2984 .f = cmd_tx_cksum_parsed,
2986 .help_str = "show checksum offload configuration: tx_cksum show <port>",
2988 (void *)&cmd_tx_cksum_tx_cksum,
2989 (void *)&cmd_tx_cksum_mode_show,
2990 (void *)&cmd_tx_cksum_portid,
2995 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
2996 struct cmd_tso_set_result {
2997 cmdline_fixed_string_t tso;
2998 cmdline_fixed_string_t mode;
3004 cmd_tso_set_parsed(void *parsed_result,
3005 __attribute__((unused)) struct cmdline *cl,
3006 __attribute__((unused)) void *data)
3008 struct cmd_tso_set_result *res = parsed_result;
3009 struct rte_eth_dev_info dev_info;
3011 if (port_id_is_invalid(res->port_id))
3014 if (!strcmp(res->mode, "set"))
3015 ports[res->port_id].tso_segsz = res->tso_segsz;
3017 if (ports[res->port_id].tso_segsz == 0)
3018 printf("TSO is disabled\n");
3020 printf("TSO segment size is %d\n",
3021 ports[res->port_id].tso_segsz);
3023 /* display warnings if configuration is not supported by the NIC */
3024 rte_eth_dev_info_get(res->port_id, &dev_info);
3025 if ((ports[res->port_id].tso_segsz != 0) &&
3026 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3027 printf("Warning: TSO enabled but not "
3028 "supported by port %d\n", res->port_id);
3032 cmdline_parse_token_string_t cmd_tso_set_tso =
3033 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3035 cmdline_parse_token_string_t cmd_tso_set_mode =
3036 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3038 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3039 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3041 cmdline_parse_token_num_t cmd_tso_set_portid =
3042 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3045 cmdline_parse_inst_t cmd_tso_set = {
3046 .f = cmd_tso_set_parsed,
3048 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3049 "tso set <tso_segsz> <port>",
3051 (void *)&cmd_tso_set_tso,
3052 (void *)&cmd_tso_set_mode,
3053 (void *)&cmd_tso_set_tso_segsz,
3054 (void *)&cmd_tso_set_portid,
3059 cmdline_parse_token_string_t cmd_tso_show_mode =
3060 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3064 cmdline_parse_inst_t cmd_tso_show = {
3065 .f = cmd_tso_set_parsed,
3067 .help_str = "Show TSO segment size for csum engine: "
3070 (void *)&cmd_tso_set_tso,
3071 (void *)&cmd_tso_show_mode,
3072 (void *)&cmd_tso_set_portid,
3077 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3078 struct cmd_set_flush_rx {
3079 cmdline_fixed_string_t set;
3080 cmdline_fixed_string_t flush_rx;
3081 cmdline_fixed_string_t mode;
3085 cmd_set_flush_rx_parsed(void *parsed_result,
3086 __attribute__((unused)) struct cmdline *cl,
3087 __attribute__((unused)) void *data)
3089 struct cmd_set_flush_rx *res = parsed_result;
3090 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3093 cmdline_parse_token_string_t cmd_setflushrx_set =
3094 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3096 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3097 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3098 flush_rx, "flush_rx");
3099 cmdline_parse_token_string_t cmd_setflushrx_mode =
3100 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3104 cmdline_parse_inst_t cmd_set_flush_rx = {
3105 .f = cmd_set_flush_rx_parsed,
3106 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3109 (void *)&cmd_setflushrx_set,
3110 (void *)&cmd_setflushrx_flush_rx,
3111 (void *)&cmd_setflushrx_mode,
3116 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3117 struct cmd_set_link_check {
3118 cmdline_fixed_string_t set;
3119 cmdline_fixed_string_t link_check;
3120 cmdline_fixed_string_t mode;
3124 cmd_set_link_check_parsed(void *parsed_result,
3125 __attribute__((unused)) struct cmdline *cl,
3126 __attribute__((unused)) void *data)
3128 struct cmd_set_link_check *res = parsed_result;
3129 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3132 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3133 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3135 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3136 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3137 link_check, "link_check");
3138 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3139 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3143 cmdline_parse_inst_t cmd_set_link_check = {
3144 .f = cmd_set_link_check_parsed,
3145 .help_str = "set link_check on|off: enable/disable link status check "
3146 "when starting/stopping a port",
3149 (void *)&cmd_setlinkcheck_set,
3150 (void *)&cmd_setlinkcheck_link_check,
3151 (void *)&cmd_setlinkcheck_mode,
3156 #ifdef RTE_NIC_BYPASS
3157 /* *** SET NIC BYPASS MODE *** */
3158 struct cmd_set_bypass_mode_result {
3159 cmdline_fixed_string_t set;
3160 cmdline_fixed_string_t bypass;
3161 cmdline_fixed_string_t mode;
3162 cmdline_fixed_string_t value;
3167 cmd_set_bypass_mode_parsed(void *parsed_result,
3168 __attribute__((unused)) struct cmdline *cl,
3169 __attribute__((unused)) void *data)
3171 struct cmd_set_bypass_mode_result *res = parsed_result;
3172 portid_t port_id = res->port_id;
3173 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3175 if (!bypass_is_supported(port_id))
3178 if (!strcmp(res->value, "bypass"))
3179 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3180 else if (!strcmp(res->value, "isolate"))
3181 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3183 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3185 /* Set the bypass mode for the relevant port. */
3186 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3187 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3191 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3192 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3194 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3195 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3197 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3198 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3200 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3201 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3202 value, "normal#bypass#isolate");
3203 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3204 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3207 cmdline_parse_inst_t cmd_set_bypass_mode = {
3208 .f = cmd_set_bypass_mode_parsed,
3209 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3210 "Set the NIC bypass mode for port_id",
3213 (void *)&cmd_setbypass_mode_set,
3214 (void *)&cmd_setbypass_mode_bypass,
3215 (void *)&cmd_setbypass_mode_mode,
3216 (void *)&cmd_setbypass_mode_value,
3217 (void *)&cmd_setbypass_mode_port,
3222 /* *** SET NIC BYPASS EVENT *** */
3223 struct cmd_set_bypass_event_result {
3224 cmdline_fixed_string_t set;
3225 cmdline_fixed_string_t bypass;
3226 cmdline_fixed_string_t event;
3227 cmdline_fixed_string_t event_value;
3228 cmdline_fixed_string_t mode;
3229 cmdline_fixed_string_t mode_value;
3234 cmd_set_bypass_event_parsed(void *parsed_result,
3235 __attribute__((unused)) struct cmdline *cl,
3236 __attribute__((unused)) void *data)
3239 struct cmd_set_bypass_event_result *res = parsed_result;
3240 portid_t port_id = res->port_id;
3241 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3242 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3244 if (!bypass_is_supported(port_id))
3247 if (!strcmp(res->event_value, "timeout"))
3248 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3249 else if (!strcmp(res->event_value, "os_on"))
3250 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3251 else if (!strcmp(res->event_value, "os_off"))
3252 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3253 else if (!strcmp(res->event_value, "power_on"))
3254 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3255 else if (!strcmp(res->event_value, "power_off"))
3256 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3258 bypass_event = RTE_BYPASS_EVENT_NONE;
3260 if (!strcmp(res->mode_value, "bypass"))
3261 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3262 else if (!strcmp(res->mode_value, "isolate"))
3263 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3265 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3267 /* Set the watchdog timeout. */
3268 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3271 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3272 (rc = rte_eth_dev_wd_timeout_store(port_id,
3273 bypass_timeout)) != 0) {
3274 printf("Failed to set timeout value %u "
3275 "for port %d, errto code: %d.\n",
3276 bypass_timeout, port_id, rc);
3280 /* Set the bypass event to transition to bypass mode. */
3281 if (0 != rte_eth_dev_bypass_event_store(port_id,
3282 bypass_event, bypass_mode)) {
3283 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3288 cmdline_parse_token_string_t cmd_setbypass_event_set =
3289 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3291 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3292 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3294 cmdline_parse_token_string_t cmd_setbypass_event_event =
3295 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3297 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3298 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3299 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3300 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3301 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3303 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3304 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3305 mode_value, "normal#bypass#isolate");
3306 cmdline_parse_token_num_t cmd_setbypass_event_port =
3307 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3310 cmdline_parse_inst_t cmd_set_bypass_event = {
3311 .f = cmd_set_bypass_event_parsed,
3312 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3313 "mode (normal|bypass|isolate) (port_id): "
3314 "Set the NIC bypass event mode for port_id",
3317 (void *)&cmd_setbypass_event_set,
3318 (void *)&cmd_setbypass_event_bypass,
3319 (void *)&cmd_setbypass_event_event,
3320 (void *)&cmd_setbypass_event_event_value,
3321 (void *)&cmd_setbypass_event_mode,
3322 (void *)&cmd_setbypass_event_mode_value,
3323 (void *)&cmd_setbypass_event_port,
3329 /* *** SET NIC BYPASS TIMEOUT *** */
3330 struct cmd_set_bypass_timeout_result {
3331 cmdline_fixed_string_t set;
3332 cmdline_fixed_string_t bypass;
3333 cmdline_fixed_string_t timeout;
3334 cmdline_fixed_string_t value;
3338 cmd_set_bypass_timeout_parsed(void *parsed_result,
3339 __attribute__((unused)) struct cmdline *cl,
3340 __attribute__((unused)) void *data)
3342 struct cmd_set_bypass_timeout_result *res = parsed_result;
3344 if (!strcmp(res->value, "1.5"))
3345 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3346 else if (!strcmp(res->value, "2"))
3347 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3348 else if (!strcmp(res->value, "3"))
3349 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3350 else if (!strcmp(res->value, "4"))
3351 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3352 else if (!strcmp(res->value, "8"))
3353 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3354 else if (!strcmp(res->value, "16"))
3355 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3356 else if (!strcmp(res->value, "32"))
3357 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3359 bypass_timeout = RTE_BYPASS_TMT_OFF;
3362 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3363 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3365 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3366 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3368 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3369 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3370 timeout, "timeout");
3371 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3372 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3373 value, "0#1.5#2#3#4#8#16#32");
3375 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3376 .f = cmd_set_bypass_timeout_parsed,
3377 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3378 "Set the NIC bypass watchdog timeout",
3381 (void *)&cmd_setbypass_timeout_set,
3382 (void *)&cmd_setbypass_timeout_bypass,
3383 (void *)&cmd_setbypass_timeout_timeout,
3384 (void *)&cmd_setbypass_timeout_value,
3389 /* *** SHOW NIC BYPASS MODE *** */
3390 struct cmd_show_bypass_config_result {
3391 cmdline_fixed_string_t show;
3392 cmdline_fixed_string_t bypass;
3393 cmdline_fixed_string_t config;
3398 cmd_show_bypass_config_parsed(void *parsed_result,
3399 __attribute__((unused)) struct cmdline *cl,
3400 __attribute__((unused)) void *data)
3402 struct cmd_show_bypass_config_result *res = parsed_result;
3403 uint32_t event_mode;
3404 uint32_t bypass_mode;
3405 portid_t port_id = res->port_id;
3406 uint32_t timeout = bypass_timeout;
3409 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3410 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3411 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3412 {"UNKNOWN", "normal", "bypass", "isolate"};
3413 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3420 int num_events = (sizeof events) / (sizeof events[0]);
3422 if (!bypass_is_supported(port_id))
3425 /* Display the bypass mode.*/
3426 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3427 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3431 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3432 bypass_mode = RTE_BYPASS_MODE_NONE;
3434 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3437 /* Display the bypass timeout.*/
3438 if (!RTE_BYPASS_TMT_VALID(timeout))
3439 timeout = RTE_BYPASS_TMT_OFF;
3441 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3443 /* Display the bypass events and associated modes. */
3444 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3446 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3447 printf("\tFailed to get bypass mode for event = %s\n",
3450 if (!RTE_BYPASS_MODE_VALID(event_mode))
3451 event_mode = RTE_BYPASS_MODE_NONE;
3453 printf("\tbypass event: %-16s = %s\n", events[i],
3459 cmdline_parse_token_string_t cmd_showbypass_config_show =
3460 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3462 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3463 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3465 cmdline_parse_token_string_t cmd_showbypass_config_config =
3466 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3468 cmdline_parse_token_num_t cmd_showbypass_config_port =
3469 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3472 cmdline_parse_inst_t cmd_show_bypass_config = {
3473 .f = cmd_show_bypass_config_parsed,
3474 .help_str = "show bypass config (port_id): "
3475 "Show the NIC bypass config for port_id",
3478 (void *)&cmd_showbypass_config_show,
3479 (void *)&cmd_showbypass_config_bypass,
3480 (void *)&cmd_showbypass_config_config,
3481 (void *)&cmd_showbypass_config_port,
3487 #ifdef RTE_LIBRTE_PMD_BOND
3488 /* *** SET BONDING MODE *** */
3489 struct cmd_set_bonding_mode_result {
3490 cmdline_fixed_string_t set;
3491 cmdline_fixed_string_t bonding;
3492 cmdline_fixed_string_t mode;
3497 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3498 __attribute__((unused)) struct cmdline *cl,
3499 __attribute__((unused)) void *data)
3501 struct cmd_set_bonding_mode_result *res = parsed_result;
3502 portid_t port_id = res->port_id;
3504 /* Set the bonding mode for the relevant port. */
3505 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3506 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3509 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3510 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3512 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3513 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3514 bonding, "bonding");
3515 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3516 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3518 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3519 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3521 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3522 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3525 cmdline_parse_inst_t cmd_set_bonding_mode = {
3526 .f = cmd_set_bonding_mode_parsed,
3527 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3530 (void *) &cmd_setbonding_mode_set,
3531 (void *) &cmd_setbonding_mode_bonding,
3532 (void *) &cmd_setbonding_mode_mode,
3533 (void *) &cmd_setbonding_mode_value,
3534 (void *) &cmd_setbonding_mode_port,
3539 /* *** SET BALANCE XMIT POLICY *** */
3540 struct cmd_set_bonding_balance_xmit_policy_result {
3541 cmdline_fixed_string_t set;
3542 cmdline_fixed_string_t bonding;
3543 cmdline_fixed_string_t balance_xmit_policy;
3545 cmdline_fixed_string_t policy;
3548 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3549 __attribute__((unused)) struct cmdline *cl,
3550 __attribute__((unused)) void *data)
3552 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3553 portid_t port_id = res->port_id;
3556 if (!strcmp(res->policy, "l2")) {
3557 policy = BALANCE_XMIT_POLICY_LAYER2;
3558 } else if (!strcmp(res->policy, "l23")) {
3559 policy = BALANCE_XMIT_POLICY_LAYER23;
3560 } else if (!strcmp(res->policy, "l34")) {
3561 policy = BALANCE_XMIT_POLICY_LAYER34;
3563 printf("\t Invalid xmit policy selection");
3567 /* Set the bonding mode for the relevant port. */
3568 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3569 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3574 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3575 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3577 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3578 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3579 bonding, "bonding");
3580 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3581 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3582 balance_xmit_policy, "balance_xmit_policy");
3583 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3584 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3586 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3587 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3588 policy, "l2#l23#l34");
3590 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3591 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3592 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3595 (void *)&cmd_setbonding_balance_xmit_policy_set,
3596 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3597 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3598 (void *)&cmd_setbonding_balance_xmit_policy_port,
3599 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3604 /* *** SHOW NIC BONDING CONFIGURATION *** */
3605 struct cmd_show_bonding_config_result {
3606 cmdline_fixed_string_t show;
3607 cmdline_fixed_string_t bonding;
3608 cmdline_fixed_string_t config;
3612 static void cmd_show_bonding_config_parsed(void *parsed_result,
3613 __attribute__((unused)) struct cmdline *cl,
3614 __attribute__((unused)) void *data)
3616 struct cmd_show_bonding_config_result *res = parsed_result;
3618 uint8_t slaves[RTE_MAX_ETHPORTS];
3619 int num_slaves, num_active_slaves;
3622 portid_t port_id = res->port_id;
3624 /* Display the bonding mode.*/
3625 bonding_mode = rte_eth_bond_mode_get(port_id);
3626 if (bonding_mode < 0) {
3627 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3630 printf("\tBonding mode: %d\n", bonding_mode);
3632 if (bonding_mode == BONDING_MODE_BALANCE) {
3633 int balance_xmit_policy;
3635 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3636 if (balance_xmit_policy < 0) {
3637 printf("\tFailed to get balance xmit policy for port = %d\n",
3641 printf("\tBalance Xmit Policy: ");
3643 switch (balance_xmit_policy) {
3644 case BALANCE_XMIT_POLICY_LAYER2:
3645 printf("BALANCE_XMIT_POLICY_LAYER2");
3647 case BALANCE_XMIT_POLICY_LAYER23:
3648 printf("BALANCE_XMIT_POLICY_LAYER23");
3650 case BALANCE_XMIT_POLICY_LAYER34:
3651 printf("BALANCE_XMIT_POLICY_LAYER34");
3658 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3660 if (num_slaves < 0) {
3661 printf("\tFailed to get slave list for port = %d\n", port_id);
3664 if (num_slaves > 0) {
3665 printf("\tSlaves (%d): [", num_slaves);
3666 for (i = 0; i < num_slaves - 1; i++)
3667 printf("%d ", slaves[i]);
3669 printf("%d]\n", slaves[num_slaves - 1]);
3671 printf("\tSlaves: []\n");
3675 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3678 if (num_active_slaves < 0) {
3679 printf("\tFailed to get active slave list for port = %d\n", port_id);
3682 if (num_active_slaves > 0) {
3683 printf("\tActive Slaves (%d): [", num_active_slaves);
3684 for (i = 0; i < num_active_slaves - 1; i++)
3685 printf("%d ", slaves[i]);
3687 printf("%d]\n", slaves[num_active_slaves - 1]);
3690 printf("\tActive Slaves: []\n");
3694 primary_id = rte_eth_bond_primary_get(port_id);
3695 if (primary_id < 0) {
3696 printf("\tFailed to get primary slave for port = %d\n", port_id);
3699 printf("\tPrimary: [%d]\n", primary_id);
3703 cmdline_parse_token_string_t cmd_showbonding_config_show =
3704 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3706 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3707 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3708 bonding, "bonding");
3709 cmdline_parse_token_string_t cmd_showbonding_config_config =
3710 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3712 cmdline_parse_token_num_t cmd_showbonding_config_port =
3713 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3716 cmdline_parse_inst_t cmd_show_bonding_config = {
3717 .f = cmd_show_bonding_config_parsed,
3718 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3721 (void *)&cmd_showbonding_config_show,
3722 (void *)&cmd_showbonding_config_bonding,
3723 (void *)&cmd_showbonding_config_config,
3724 (void *)&cmd_showbonding_config_port,
3729 /* *** SET BONDING PRIMARY *** */
3730 struct cmd_set_bonding_primary_result {
3731 cmdline_fixed_string_t set;
3732 cmdline_fixed_string_t bonding;
3733 cmdline_fixed_string_t primary;
3738 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3739 __attribute__((unused)) struct cmdline *cl,
3740 __attribute__((unused)) void *data)
3742 struct cmd_set_bonding_primary_result *res = parsed_result;
3743 portid_t master_port_id = res->port_id;
3744 portid_t slave_port_id = res->slave_id;
3746 /* Set the primary slave for a bonded device. */
3747 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3748 printf("\t Failed to set primary slave for port = %d.\n",
3755 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3756 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3758 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3760 bonding, "bonding");
3761 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3762 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3763 primary, "primary");
3764 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3765 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3767 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3768 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3771 cmdline_parse_inst_t cmd_set_bonding_primary = {
3772 .f = cmd_set_bonding_primary_parsed,
3773 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3776 (void *)&cmd_setbonding_primary_set,
3777 (void *)&cmd_setbonding_primary_bonding,
3778 (void *)&cmd_setbonding_primary_primary,
3779 (void *)&cmd_setbonding_primary_slave,
3780 (void *)&cmd_setbonding_primary_port,
3785 /* *** ADD SLAVE *** */
3786 struct cmd_add_bonding_slave_result {
3787 cmdline_fixed_string_t add;
3788 cmdline_fixed_string_t bonding;
3789 cmdline_fixed_string_t slave;
3794 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3795 __attribute__((unused)) struct cmdline *cl,
3796 __attribute__((unused)) void *data)
3798 struct cmd_add_bonding_slave_result *res = parsed_result;
3799 portid_t master_port_id = res->port_id;
3800 portid_t slave_port_id = res->slave_id;
3802 /* Set the primary slave for a bonded device. */
3803 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3804 printf("\t Failed to add slave %d to master port = %d.\n",
3805 slave_port_id, master_port_id);
3811 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3812 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3814 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3815 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3816 bonding, "bonding");
3817 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3818 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3820 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3821 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3823 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3824 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3827 cmdline_parse_inst_t cmd_add_bonding_slave = {
3828 .f = cmd_add_bonding_slave_parsed,
3829 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3832 (void *)&cmd_addbonding_slave_add,
3833 (void *)&cmd_addbonding_slave_bonding,
3834 (void *)&cmd_addbonding_slave_slave,
3835 (void *)&cmd_addbonding_slave_slaveid,
3836 (void *)&cmd_addbonding_slave_port,
3841 /* *** REMOVE SLAVE *** */
3842 struct cmd_remove_bonding_slave_result {
3843 cmdline_fixed_string_t remove;
3844 cmdline_fixed_string_t bonding;
3845 cmdline_fixed_string_t slave;
3850 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3851 __attribute__((unused)) struct cmdline *cl,
3852 __attribute__((unused)) void *data)
3854 struct cmd_remove_bonding_slave_result *res = parsed_result;
3855 portid_t master_port_id = res->port_id;
3856 portid_t slave_port_id = res->slave_id;
3858 /* Set the primary slave for a bonded device. */
3859 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3860 printf("\t Failed to remove slave %d from master port = %d.\n",
3861 slave_port_id, master_port_id);
3867 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3868 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3870 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3871 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3872 bonding, "bonding");
3873 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3874 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3876 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3877 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3879 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3880 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3883 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3884 .f = cmd_remove_bonding_slave_parsed,
3885 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3888 (void *)&cmd_removebonding_slave_remove,
3889 (void *)&cmd_removebonding_slave_bonding,
3890 (void *)&cmd_removebonding_slave_slave,
3891 (void *)&cmd_removebonding_slave_slaveid,
3892 (void *)&cmd_removebonding_slave_port,
3897 /* *** CREATE BONDED DEVICE *** */
3898 struct cmd_create_bonded_device_result {
3899 cmdline_fixed_string_t create;
3900 cmdline_fixed_string_t bonded;
3901 cmdline_fixed_string_t device;
3906 static int bond_dev_num = 0;
3908 static void cmd_create_bonded_device_parsed(void *parsed_result,
3909 __attribute__((unused)) struct cmdline *cl,
3910 __attribute__((unused)) void *data)
3912 struct cmd_create_bonded_device_result *res = parsed_result;
3913 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3916 if (test_done == 0) {
3917 printf("Please stop forwarding first\n");
3921 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3924 /* Create a new bonded device. */
3925 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3927 printf("\t Failed to create bonded device.\n");
3930 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3933 /* Update number of ports */
3934 nb_ports = rte_eth_dev_count();
3935 reconfig(port_id, res->socket);
3936 rte_eth_promiscuous_enable(port_id);
3941 cmdline_parse_token_string_t cmd_createbonded_device_create =
3942 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3944 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3945 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3947 cmdline_parse_token_string_t cmd_createbonded_device_device =
3948 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3950 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3951 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3953 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3954 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3957 cmdline_parse_inst_t cmd_create_bonded_device = {
3958 .f = cmd_create_bonded_device_parsed,
3959 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3962 (void *)&cmd_createbonded_device_create,
3963 (void *)&cmd_createbonded_device_bonded,
3964 (void *)&cmd_createbonded_device_device,
3965 (void *)&cmd_createbonded_device_mode,
3966 (void *)&cmd_createbonded_device_socket,
3971 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3972 struct cmd_set_bond_mac_addr_result {
3973 cmdline_fixed_string_t set;
3974 cmdline_fixed_string_t bonding;
3975 cmdline_fixed_string_t mac_addr;
3977 struct ether_addr address;
3980 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3981 __attribute__((unused)) struct cmdline *cl,
3982 __attribute__((unused)) void *data)
3984 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3987 if (res->port_num >= nb_ports) {
3988 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3992 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3994 /* check the return value and print it if is < 0 */
3996 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3999 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4000 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4001 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4002 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4004 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4005 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4007 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4008 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4009 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4010 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4012 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4013 .f = cmd_set_bond_mac_addr_parsed,
4015 .help_str = "set bonding mac_addr (port_id) (address): ",
4017 (void *)&cmd_set_bond_mac_addr_set,
4018 (void *)&cmd_set_bond_mac_addr_bonding,
4019 (void *)&cmd_set_bond_mac_addr_mac,
4020 (void *)&cmd_set_bond_mac_addr_portnum,
4021 (void *)&cmd_set_bond_mac_addr_addr,
4027 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4028 struct cmd_set_bond_mon_period_result {
4029 cmdline_fixed_string_t set;
4030 cmdline_fixed_string_t bonding;
4031 cmdline_fixed_string_t mon_period;
4036 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4037 __attribute__((unused)) struct cmdline *cl,
4038 __attribute__((unused)) void *data)
4040 struct cmd_set_bond_mon_period_result *res = parsed_result;
4043 if (res->port_num >= nb_ports) {
4044 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4048 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4050 /* check the return value and print it if is < 0 */
4052 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4055 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4056 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4058 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4059 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4060 bonding, "bonding");
4061 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4062 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4063 mon_period, "mon_period");
4064 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4065 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4067 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4068 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4071 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4072 .f = cmd_set_bond_mon_period_parsed,
4074 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4076 (void *)&cmd_set_bond_mon_period_set,
4077 (void *)&cmd_set_bond_mon_period_bonding,
4078 (void *)&cmd_set_bond_mon_period_mon_period,
4079 (void *)&cmd_set_bond_mon_period_portnum,
4080 (void *)&cmd_set_bond_mon_period_period_ms,
4085 #endif /* RTE_LIBRTE_PMD_BOND */
4087 /* *** SET FORWARDING MODE *** */
4088 struct cmd_set_fwd_mode_result {
4089 cmdline_fixed_string_t set;
4090 cmdline_fixed_string_t fwd;
4091 cmdline_fixed_string_t mode;
4094 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4095 __attribute__((unused)) struct cmdline *cl,
4096 __attribute__((unused)) void *data)
4098 struct cmd_set_fwd_mode_result *res = parsed_result;
4100 set_pkt_forwarding_mode(res->mode);
4103 cmdline_parse_token_string_t cmd_setfwd_set =
4104 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4105 cmdline_parse_token_string_t cmd_setfwd_fwd =
4106 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4107 cmdline_parse_token_string_t cmd_setfwd_mode =
4108 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4109 "" /* defined at init */);
4111 cmdline_parse_inst_t cmd_set_fwd_mode = {
4112 .f = cmd_set_fwd_mode_parsed,
4114 .help_str = NULL, /* defined at init */
4116 (void *)&cmd_setfwd_set,
4117 (void *)&cmd_setfwd_fwd,
4118 (void *)&cmd_setfwd_mode,
4123 static void cmd_set_fwd_mode_init(void)
4126 static char token[128];
4127 static char help[256];
4128 cmdline_parse_token_string_t *token_struct;
4130 modes = list_pkt_forwarding_modes();
4131 snprintf(help, sizeof help, "set fwd %s - "
4132 "set packet forwarding mode", modes);
4133 cmd_set_fwd_mode.help_str = help;
4135 /* string token separator is # */
4136 for (c = token; *modes != '\0'; modes++)
4141 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4142 token_struct->string_data.str = token;
4145 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4146 struct cmd_set_burst_tx_retry_result {
4147 cmdline_fixed_string_t set;
4148 cmdline_fixed_string_t burst;
4149 cmdline_fixed_string_t tx;
4150 cmdline_fixed_string_t delay;
4152 cmdline_fixed_string_t retry;
4156 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4157 __attribute__((unused)) struct cmdline *cl,
4158 __attribute__((unused)) void *data)
4160 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4162 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4163 && !strcmp(res->tx, "tx")) {
4164 if (!strcmp(res->delay, "delay"))
4165 burst_tx_delay_time = res->time;
4166 if (!strcmp(res->retry, "retry"))
4167 burst_tx_retry_num = res->retry_num;
4172 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4173 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4174 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4175 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4177 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4178 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4179 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4180 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4181 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4182 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4183 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4184 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4185 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4186 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4188 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4189 .f = cmd_set_burst_tx_retry_parsed,
4190 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4192 (void *)&cmd_set_burst_tx_retry_set,
4193 (void *)&cmd_set_burst_tx_retry_burst,
4194 (void *)&cmd_set_burst_tx_retry_tx,
4195 (void *)&cmd_set_burst_tx_retry_delay,
4196 (void *)&cmd_set_burst_tx_retry_time,
4197 (void *)&cmd_set_burst_tx_retry_retry,
4198 (void *)&cmd_set_burst_tx_retry_retry_num,
4203 /* *** SET PROMISC MODE *** */
4204 struct cmd_set_promisc_mode_result {
4205 cmdline_fixed_string_t set;
4206 cmdline_fixed_string_t promisc;
4207 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4208 uint8_t port_num; /* valid if "allports" argument == 0 */
4209 cmdline_fixed_string_t mode;
4212 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4213 __attribute__((unused)) struct cmdline *cl,
4216 struct cmd_set_promisc_mode_result *res = parsed_result;
4220 if (!strcmp(res->mode, "on"))
4227 for (i = 0; i < nb_ports; i++) {
4229 rte_eth_promiscuous_enable(i);
4231 rte_eth_promiscuous_disable(i);
4236 rte_eth_promiscuous_enable(res->port_num);
4238 rte_eth_promiscuous_disable(res->port_num);
4242 cmdline_parse_token_string_t cmd_setpromisc_set =
4243 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4244 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4245 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4247 cmdline_parse_token_string_t cmd_setpromisc_portall =
4248 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4250 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4251 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4253 cmdline_parse_token_string_t cmd_setpromisc_mode =
4254 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4257 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4258 .f = cmd_set_promisc_mode_parsed,
4260 .help_str = "set promisc all on|off: set promisc mode for all ports",
4262 (void *)&cmd_setpromisc_set,
4263 (void *)&cmd_setpromisc_promisc,
4264 (void *)&cmd_setpromisc_portall,
4265 (void *)&cmd_setpromisc_mode,
4270 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4271 .f = cmd_set_promisc_mode_parsed,
4273 .help_str = "set promisc X on|off: set promisc mode on port X",
4275 (void *)&cmd_setpromisc_set,
4276 (void *)&cmd_setpromisc_promisc,
4277 (void *)&cmd_setpromisc_portnum,
4278 (void *)&cmd_setpromisc_mode,
4283 /* *** SET ALLMULTI MODE *** */
4284 struct cmd_set_allmulti_mode_result {
4285 cmdline_fixed_string_t set;
4286 cmdline_fixed_string_t allmulti;
4287 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4288 uint8_t port_num; /* valid if "allports" argument == 0 */
4289 cmdline_fixed_string_t mode;
4292 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4293 __attribute__((unused)) struct cmdline *cl,
4296 struct cmd_set_allmulti_mode_result *res = parsed_result;
4300 if (!strcmp(res->mode, "on"))
4307 for (i = 0; i < nb_ports; i++) {
4309 rte_eth_allmulticast_enable(i);
4311 rte_eth_allmulticast_disable(i);
4316 rte_eth_allmulticast_enable(res->port_num);
4318 rte_eth_allmulticast_disable(res->port_num);
4322 cmdline_parse_token_string_t cmd_setallmulti_set =
4323 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4324 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4325 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4327 cmdline_parse_token_string_t cmd_setallmulti_portall =
4328 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4330 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4331 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4333 cmdline_parse_token_string_t cmd_setallmulti_mode =
4334 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4337 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4338 .f = cmd_set_allmulti_mode_parsed,
4340 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4342 (void *)&cmd_setallmulti_set,
4343 (void *)&cmd_setallmulti_allmulti,
4344 (void *)&cmd_setallmulti_portall,
4345 (void *)&cmd_setallmulti_mode,
4350 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4351 .f = cmd_set_allmulti_mode_parsed,
4353 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4355 (void *)&cmd_setallmulti_set,
4356 (void *)&cmd_setallmulti_allmulti,
4357 (void *)&cmd_setallmulti_portnum,
4358 (void *)&cmd_setallmulti_mode,
4363 /* *** ADD/REMOVE A PKT FILTER *** */
4364 struct cmd_pkt_filter_result {
4365 cmdline_fixed_string_t pkt_filter;
4367 cmdline_fixed_string_t protocol;
4368 cmdline_fixed_string_t src;
4369 cmdline_ipaddr_t ip_src;
4371 cmdline_fixed_string_t dst;
4372 cmdline_ipaddr_t ip_dst;
4374 cmdline_fixed_string_t flexbytes;
4375 uint16_t flexbytes_value;
4376 cmdline_fixed_string_t vlan;
4378 cmdline_fixed_string_t queue;
4380 cmdline_fixed_string_t soft;
4385 cmd_pkt_filter_parsed(void *parsed_result,
4386 __attribute__((unused)) struct cmdline *cl,
4387 __attribute__((unused)) void *data)
4389 struct rte_fdir_filter fdir_filter;
4390 struct cmd_pkt_filter_result *res = parsed_result;
4392 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4394 if (res->ip_src.family == AF_INET)
4395 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4397 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4398 &(res->ip_src.addr.ipv6),
4399 sizeof(struct in6_addr));
4401 if (res->ip_dst.family == AF_INET)
4402 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4404 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4405 &(res->ip_dst.addr.ipv6),
4406 sizeof(struct in6_addr));
4408 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4409 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4411 if (!strcmp(res->protocol, "udp"))
4412 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4413 else if (!strcmp(res->protocol, "tcp"))
4414 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4415 else if (!strcmp(res->protocol, "sctp"))
4416 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4417 else /* default only IP */
4418 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4420 if (res->ip_dst.family == AF_INET6)
4421 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4423 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4425 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4426 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4428 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4429 fdir_add_signature_filter(res->port_id, res->queue_id,
4431 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4432 fdir_update_signature_filter(res->port_id, res->queue_id,
4434 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4435 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4436 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4437 fdir_add_perfect_filter(res->port_id, res->soft_id,
4439 (uint8_t) (res->queue_id < 0),
4441 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4442 fdir_update_perfect_filter(res->port_id, res->soft_id,
4444 (uint8_t) (res->queue_id < 0),
4446 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4447 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4453 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4454 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4456 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4457 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4458 protocol, "ip#tcp#udp#sctp");
4459 cmdline_parse_token_string_t cmd_pkt_filter_src =
4460 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4462 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4463 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4465 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4466 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4468 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4469 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4471 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4472 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4474 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4475 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4477 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4478 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4479 flexbytes, "flexbytes");
4480 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4481 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4482 flexbytes_value, UINT16);
4483 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4484 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4486 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4487 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4489 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4490 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4492 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4493 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4495 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4496 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4498 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4499 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4503 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4504 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4505 pkt_filter, "add_signature_filter");
4506 cmdline_parse_inst_t cmd_add_signature_filter = {
4507 .f = cmd_pkt_filter_parsed,
4509 .help_str = "add a signature filter",
4511 (void *)&cmd_pkt_filter_add_signature_filter,
4512 (void *)&cmd_pkt_filter_port_id,
4513 (void *)&cmd_pkt_filter_protocol,
4514 (void *)&cmd_pkt_filter_src,
4515 (void *)&cmd_pkt_filter_ip_src,
4516 (void *)&cmd_pkt_filter_port_src,
4517 (void *)&cmd_pkt_filter_dst,
4518 (void *)&cmd_pkt_filter_ip_dst,
4519 (void *)&cmd_pkt_filter_port_dst,
4520 (void *)&cmd_pkt_filter_flexbytes,
4521 (void *)&cmd_pkt_filter_flexbytes_value,
4522 (void *)&cmd_pkt_filter_vlan,
4523 (void *)&cmd_pkt_filter_vlan_id,
4524 (void *)&cmd_pkt_filter_queue,
4525 (void *)&cmd_pkt_filter_queue_id,
4531 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4532 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4533 pkt_filter, "upd_signature_filter");
4534 cmdline_parse_inst_t cmd_upd_signature_filter = {
4535 .f = cmd_pkt_filter_parsed,
4537 .help_str = "update a signature filter",
4539 (void *)&cmd_pkt_filter_upd_signature_filter,
4540 (void *)&cmd_pkt_filter_port_id,
4541 (void *)&cmd_pkt_filter_protocol,
4542 (void *)&cmd_pkt_filter_src,
4543 (void *)&cmd_pkt_filter_ip_src,
4544 (void *)&cmd_pkt_filter_port_src,
4545 (void *)&cmd_pkt_filter_dst,
4546 (void *)&cmd_pkt_filter_ip_dst,
4547 (void *)&cmd_pkt_filter_port_dst,
4548 (void *)&cmd_pkt_filter_flexbytes,
4549 (void *)&cmd_pkt_filter_flexbytes_value,
4550 (void *)&cmd_pkt_filter_vlan,
4551 (void *)&cmd_pkt_filter_vlan_id,
4552 (void *)&cmd_pkt_filter_queue,
4553 (void *)&cmd_pkt_filter_queue_id,
4559 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4560 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4561 pkt_filter, "rm_signature_filter");
4562 cmdline_parse_inst_t cmd_rm_signature_filter = {
4563 .f = cmd_pkt_filter_parsed,
4565 .help_str = "remove a signature filter",
4567 (void *)&cmd_pkt_filter_rm_signature_filter,
4568 (void *)&cmd_pkt_filter_port_id,
4569 (void *)&cmd_pkt_filter_protocol,
4570 (void *)&cmd_pkt_filter_src,
4571 (void *)&cmd_pkt_filter_ip_src,
4572 (void *)&cmd_pkt_filter_port_src,
4573 (void *)&cmd_pkt_filter_dst,
4574 (void *)&cmd_pkt_filter_ip_dst,
4575 (void *)&cmd_pkt_filter_port_dst,
4576 (void *)&cmd_pkt_filter_flexbytes,
4577 (void *)&cmd_pkt_filter_flexbytes_value,
4578 (void *)&cmd_pkt_filter_vlan,
4579 (void *)&cmd_pkt_filter_vlan_id,
4585 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4586 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4587 pkt_filter, "add_perfect_filter");
4588 cmdline_parse_inst_t cmd_add_perfect_filter = {
4589 .f = cmd_pkt_filter_parsed,
4591 .help_str = "add a perfect filter",
4593 (void *)&cmd_pkt_filter_add_perfect_filter,
4594 (void *)&cmd_pkt_filter_port_id,
4595 (void *)&cmd_pkt_filter_protocol,
4596 (void *)&cmd_pkt_filter_src,
4597 (void *)&cmd_pkt_filter_ip_src,
4598 (void *)&cmd_pkt_filter_port_src,
4599 (void *)&cmd_pkt_filter_dst,
4600 (void *)&cmd_pkt_filter_ip_dst,
4601 (void *)&cmd_pkt_filter_port_dst,
4602 (void *)&cmd_pkt_filter_flexbytes,
4603 (void *)&cmd_pkt_filter_flexbytes_value,
4604 (void *)&cmd_pkt_filter_vlan,
4605 (void *)&cmd_pkt_filter_vlan_id,
4606 (void *)&cmd_pkt_filter_queue,
4607 (void *)&cmd_pkt_filter_queue_id,
4608 (void *)&cmd_pkt_filter_soft,
4609 (void *)&cmd_pkt_filter_soft_id,
4615 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4616 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4617 pkt_filter, "upd_perfect_filter");
4618 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4619 .f = cmd_pkt_filter_parsed,
4621 .help_str = "update a perfect filter",
4623 (void *)&cmd_pkt_filter_upd_perfect_filter,
4624 (void *)&cmd_pkt_filter_port_id,
4625 (void *)&cmd_pkt_filter_protocol,
4626 (void *)&cmd_pkt_filter_src,
4627 (void *)&cmd_pkt_filter_ip_src,
4628 (void *)&cmd_pkt_filter_port_src,
4629 (void *)&cmd_pkt_filter_dst,
4630 (void *)&cmd_pkt_filter_ip_dst,
4631 (void *)&cmd_pkt_filter_port_dst,
4632 (void *)&cmd_pkt_filter_flexbytes,
4633 (void *)&cmd_pkt_filter_flexbytes_value,
4634 (void *)&cmd_pkt_filter_vlan,
4635 (void *)&cmd_pkt_filter_vlan_id,
4636 (void *)&cmd_pkt_filter_queue,
4637 (void *)&cmd_pkt_filter_queue_id,
4638 (void *)&cmd_pkt_filter_soft,
4639 (void *)&cmd_pkt_filter_soft_id,
4645 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4646 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4647 pkt_filter, "rm_perfect_filter");
4648 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4649 .f = cmd_pkt_filter_parsed,
4651 .help_str = "remove a perfect filter",
4653 (void *)&cmd_pkt_filter_rm_perfect_filter,
4654 (void *)&cmd_pkt_filter_port_id,
4655 (void *)&cmd_pkt_filter_protocol,
4656 (void *)&cmd_pkt_filter_src,
4657 (void *)&cmd_pkt_filter_ip_src,
4658 (void *)&cmd_pkt_filter_port_src,
4659 (void *)&cmd_pkt_filter_dst,
4660 (void *)&cmd_pkt_filter_ip_dst,
4661 (void *)&cmd_pkt_filter_port_dst,
4662 (void *)&cmd_pkt_filter_flexbytes,
4663 (void *)&cmd_pkt_filter_flexbytes_value,
4664 (void *)&cmd_pkt_filter_vlan,
4665 (void *)&cmd_pkt_filter_vlan_id,
4666 (void *)&cmd_pkt_filter_soft,
4667 (void *)&cmd_pkt_filter_soft_id,
4672 /* *** SETUP MASKS FILTER *** */
4673 struct cmd_pkt_filter_masks_result {
4674 cmdline_fixed_string_t filter_mask;
4676 cmdline_fixed_string_t src_mask;
4677 uint32_t ip_src_mask;
4678 uint16_t ipv6_src_mask;
4679 uint16_t port_src_mask;
4680 cmdline_fixed_string_t dst_mask;
4681 uint32_t ip_dst_mask;
4682 uint16_t ipv6_dst_mask;
4683 uint16_t port_dst_mask;
4684 cmdline_fixed_string_t flexbytes;
4685 uint8_t flexbytes_value;
4686 cmdline_fixed_string_t vlan_id;
4687 uint8_t vlan_id_value;
4688 cmdline_fixed_string_t vlan_prio;
4689 uint8_t vlan_prio_value;
4690 cmdline_fixed_string_t only_ip_flow;
4691 uint8_t only_ip_flow_value;
4692 cmdline_fixed_string_t comp_ipv6_dst;
4693 uint8_t comp_ipv6_dst_value;
4697 cmd_pkt_filter_masks_parsed(void *parsed_result,
4698 __attribute__((unused)) struct cmdline *cl,
4699 __attribute__((unused)) void *data)
4701 struct rte_fdir_masks fdir_masks;
4702 struct cmd_pkt_filter_masks_result *res = parsed_result;
4704 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4706 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4707 fdir_masks.vlan_id = res->vlan_id_value;
4708 fdir_masks.vlan_prio = res->vlan_prio_value;
4709 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4710 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4711 fdir_masks.src_port_mask = res->port_src_mask;
4712 fdir_masks.dst_port_mask = res->port_dst_mask;
4713 fdir_masks.flexbytes = res->flexbytes_value;
4715 fdir_set_masks(res->port_id, &fdir_masks);
4718 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4719 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4720 filter_mask, "set_masks_filter");
4721 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4722 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4724 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4725 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4726 only_ip_flow, "only_ip_flow");
4727 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4728 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4729 only_ip_flow_value, UINT8);
4730 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4731 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4732 src_mask, "src_mask");
4733 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4734 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4735 ip_src_mask, UINT32);
4736 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4737 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4738 port_src_mask, UINT16);
4739 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4740 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4741 dst_mask, "dst_mask");
4742 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4743 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4744 ip_dst_mask, UINT32);
4745 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4746 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4747 port_dst_mask, UINT16);
4748 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4749 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4750 flexbytes, "flexbytes");
4751 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4752 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4753 flexbytes_value, UINT8);
4754 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4755 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4756 vlan_id, "vlan_id");
4757 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4758 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4759 vlan_id_value, UINT8);
4760 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4761 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4762 vlan_prio, "vlan_prio");
4763 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4764 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4765 vlan_prio_value, UINT8);
4767 cmdline_parse_inst_t cmd_set_masks_filter = {
4768 .f = cmd_pkt_filter_masks_parsed,
4770 .help_str = "setup masks filter",
4772 (void *)&cmd_pkt_filter_masks_filter_mask,
4773 (void *)&cmd_pkt_filter_masks_port_id,
4774 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4775 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4776 (void *)&cmd_pkt_filter_masks_src_mask,
4777 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4778 (void *)&cmd_pkt_filter_masks_port_src_mask,
4779 (void *)&cmd_pkt_filter_masks_dst_mask,
4780 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4781 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4782 (void *)&cmd_pkt_filter_masks_flexbytes,
4783 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4784 (void *)&cmd_pkt_filter_masks_vlan_id,
4785 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4786 (void *)&cmd_pkt_filter_masks_vlan_prio,
4787 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4793 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4794 __attribute__((unused)) struct cmdline *cl,
4795 __attribute__((unused)) void *data)
4797 struct rte_fdir_masks fdir_masks;
4798 struct cmd_pkt_filter_masks_result *res = parsed_result;
4800 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4802 fdir_masks.set_ipv6_mask = 1;
4803 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4804 fdir_masks.vlan_id = res->vlan_id_value;
4805 fdir_masks.vlan_prio = res->vlan_prio_value;
4806 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4807 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4808 fdir_masks.src_port_mask = res->port_src_mask;
4809 fdir_masks.dst_port_mask = res->port_dst_mask;
4810 fdir_masks.flexbytes = res->flexbytes_value;
4811 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4813 fdir_set_masks(res->port_id, &fdir_masks);
4816 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4817 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4818 filter_mask, "set_ipv6_masks_filter");
4819 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4820 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4821 ipv6_src_mask, UINT16);
4822 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4823 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4824 ipv6_dst_mask, UINT16);
4826 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4827 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4828 comp_ipv6_dst, "compare_dst");
4829 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4830 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4831 comp_ipv6_dst_value, UINT8);
4833 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4834 .f = cmd_pkt_filter_masks_ipv6_parsed,
4836 .help_str = "setup ipv6 masks filter",
4838 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4839 (void *)&cmd_pkt_filter_masks_port_id,
4840 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4841 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4842 (void *)&cmd_pkt_filter_masks_src_mask,
4843 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4844 (void *)&cmd_pkt_filter_masks_port_src_mask,
4845 (void *)&cmd_pkt_filter_masks_dst_mask,
4846 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4847 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4848 (void *)&cmd_pkt_filter_masks_flexbytes,
4849 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4850 (void *)&cmd_pkt_filter_masks_vlan_id,
4851 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4852 (void *)&cmd_pkt_filter_masks_vlan_prio,
4853 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4854 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4855 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4860 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4861 struct cmd_link_flow_ctrl_set_result {
4862 cmdline_fixed_string_t set;
4863 cmdline_fixed_string_t flow_ctrl;
4864 cmdline_fixed_string_t rx;
4865 cmdline_fixed_string_t rx_lfc_mode;
4866 cmdline_fixed_string_t tx;
4867 cmdline_fixed_string_t tx_lfc_mode;
4868 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4869 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4870 cmdline_fixed_string_t autoneg_str;
4871 cmdline_fixed_string_t autoneg;
4872 cmdline_fixed_string_t hw_str;
4873 uint32_t high_water;
4874 cmdline_fixed_string_t lw_str;
4876 cmdline_fixed_string_t pt_str;
4877 uint16_t pause_time;
4878 cmdline_fixed_string_t xon_str;
4883 cmdline_parse_token_string_t cmd_lfc_set_set =
4884 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4886 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4887 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4888 flow_ctrl, "flow_ctrl");
4889 cmdline_parse_token_string_t cmd_lfc_set_rx =
4890 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4892 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4893 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4894 rx_lfc_mode, "on#off");
4895 cmdline_parse_token_string_t cmd_lfc_set_tx =
4896 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4898 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4899 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4900 tx_lfc_mode, "on#off");
4901 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4902 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4903 hw_str, "high_water");
4904 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4905 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4906 high_water, UINT32);
4907 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4908 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4909 lw_str, "low_water");
4910 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4911 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4913 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4914 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4915 pt_str, "pause_time");
4916 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4917 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4918 pause_time, UINT16);
4919 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4920 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4921 xon_str, "send_xon");
4922 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4923 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4925 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4926 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4927 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4928 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4929 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4930 mac_ctrl_frame_fwd_mode, "on#off");
4931 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4932 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4933 autoneg_str, "autoneg");
4934 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4935 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4937 cmdline_parse_token_num_t cmd_lfc_set_portid =
4938 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4941 /* forward declaration */
4943 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4946 cmdline_parse_inst_t cmd_link_flow_control_set = {
4947 .f = cmd_link_flow_ctrl_set_parsed,
4949 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4950 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4951 autoneg on|off port_id",
4953 (void *)&cmd_lfc_set_set,
4954 (void *)&cmd_lfc_set_flow_ctrl,
4955 (void *)&cmd_lfc_set_rx,
4956 (void *)&cmd_lfc_set_rx_mode,
4957 (void *)&cmd_lfc_set_tx,
4958 (void *)&cmd_lfc_set_tx_mode,
4959 (void *)&cmd_lfc_set_high_water,
4960 (void *)&cmd_lfc_set_low_water,
4961 (void *)&cmd_lfc_set_pause_time,
4962 (void *)&cmd_lfc_set_send_xon,
4963 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4964 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4965 (void *)&cmd_lfc_set_autoneg_str,
4966 (void *)&cmd_lfc_set_autoneg,
4967 (void *)&cmd_lfc_set_portid,
4972 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4973 .f = cmd_link_flow_ctrl_set_parsed,
4974 .data = (void *)&cmd_link_flow_control_set_rx,
4975 .help_str = "Change rx flow control parameter: set flow_ctrl "
4976 "rx on|off port_id",
4978 (void *)&cmd_lfc_set_set,
4979 (void *)&cmd_lfc_set_flow_ctrl,
4980 (void *)&cmd_lfc_set_rx,
4981 (void *)&cmd_lfc_set_rx_mode,
4982 (void *)&cmd_lfc_set_portid,
4987 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4988 .f = cmd_link_flow_ctrl_set_parsed,
4989 .data = (void *)&cmd_link_flow_control_set_tx,
4990 .help_str = "Change tx flow control parameter: set flow_ctrl "
4991 "tx on|off port_id",
4993 (void *)&cmd_lfc_set_set,
4994 (void *)&cmd_lfc_set_flow_ctrl,
4995 (void *)&cmd_lfc_set_tx,
4996 (void *)&cmd_lfc_set_tx_mode,
4997 (void *)&cmd_lfc_set_portid,
5002 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5003 .f = cmd_link_flow_ctrl_set_parsed,
5004 .data = (void *)&cmd_link_flow_control_set_hw,
5005 .help_str = "Change high water flow control parameter: set flow_ctrl "
5006 "high_water value port_id",
5008 (void *)&cmd_lfc_set_set,
5009 (void *)&cmd_lfc_set_flow_ctrl,
5010 (void *)&cmd_lfc_set_high_water_str,
5011 (void *)&cmd_lfc_set_high_water,
5012 (void *)&cmd_lfc_set_portid,
5017 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5018 .f = cmd_link_flow_ctrl_set_parsed,
5019 .data = (void *)&cmd_link_flow_control_set_lw,
5020 .help_str = "Change low water flow control parameter: set flow_ctrl "
5021 "low_water value port_id",
5023 (void *)&cmd_lfc_set_set,
5024 (void *)&cmd_lfc_set_flow_ctrl,
5025 (void *)&cmd_lfc_set_low_water_str,
5026 (void *)&cmd_lfc_set_low_water,
5027 (void *)&cmd_lfc_set_portid,
5032 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5033 .f = cmd_link_flow_ctrl_set_parsed,
5034 .data = (void *)&cmd_link_flow_control_set_pt,
5035 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5036 "pause_time value port_id",
5038 (void *)&cmd_lfc_set_set,
5039 (void *)&cmd_lfc_set_flow_ctrl,
5040 (void *)&cmd_lfc_set_pause_time_str,
5041 (void *)&cmd_lfc_set_pause_time,
5042 (void *)&cmd_lfc_set_portid,
5047 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5048 .f = cmd_link_flow_ctrl_set_parsed,
5049 .data = (void *)&cmd_link_flow_control_set_xon,
5050 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5051 "send_xon value port_id",
5053 (void *)&cmd_lfc_set_set,
5054 (void *)&cmd_lfc_set_flow_ctrl,
5055 (void *)&cmd_lfc_set_send_xon_str,
5056 (void *)&cmd_lfc_set_send_xon,
5057 (void *)&cmd_lfc_set_portid,
5062 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5063 .f = cmd_link_flow_ctrl_set_parsed,
5064 .data = (void *)&cmd_link_flow_control_set_macfwd,
5065 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5066 "mac_ctrl_frame_fwd on|off port_id",
5068 (void *)&cmd_lfc_set_set,
5069 (void *)&cmd_lfc_set_flow_ctrl,
5070 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5071 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5072 (void *)&cmd_lfc_set_portid,
5077 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5078 .f = cmd_link_flow_ctrl_set_parsed,
5079 .data = (void *)&cmd_link_flow_control_set_autoneg,
5080 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5081 "autoneg on|off port_id",
5083 (void *)&cmd_lfc_set_set,
5084 (void *)&cmd_lfc_set_flow_ctrl,
5085 (void *)&cmd_lfc_set_autoneg_str,
5086 (void *)&cmd_lfc_set_autoneg,
5087 (void *)&cmd_lfc_set_portid,
5093 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5094 __attribute__((unused)) struct cmdline *cl,
5097 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5098 cmdline_parse_inst_t *cmd = data;
5099 struct rte_eth_fc_conf fc_conf;
5100 int rx_fc_en, tx_fc_en;
5104 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5105 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5106 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5107 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5109 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5110 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5113 /* Partial command line, retrieve current configuration */
5115 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5117 printf("cannot get current flow ctrl parameters, return"
5118 "code = %d\n", ret);
5122 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5123 (fc_conf.mode == RTE_FC_FULL))
5125 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5126 (fc_conf.mode == RTE_FC_FULL))
5130 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5131 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5133 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5134 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5136 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5138 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5139 fc_conf.high_water = res->high_water;
5141 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5142 fc_conf.low_water = res->low_water;
5144 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5145 fc_conf.pause_time = res->pause_time;
5147 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5148 fc_conf.send_xon = res->send_xon;
5150 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5151 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5152 fc_conf.mac_ctrl_frame_fwd = 1;
5154 fc_conf.mac_ctrl_frame_fwd = 0;
5157 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5158 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5160 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5162 printf("bad flow contrl parameter, return code = %d \n", ret);
5165 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5166 struct cmd_priority_flow_ctrl_set_result {
5167 cmdline_fixed_string_t set;
5168 cmdline_fixed_string_t pfc_ctrl;
5169 cmdline_fixed_string_t rx;
5170 cmdline_fixed_string_t rx_pfc_mode;
5171 cmdline_fixed_string_t tx;
5172 cmdline_fixed_string_t tx_pfc_mode;
5173 uint32_t high_water;
5175 uint16_t pause_time;
5181 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5182 __attribute__((unused)) struct cmdline *cl,
5183 __attribute__((unused)) void *data)
5185 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5186 struct rte_eth_pfc_conf pfc_conf;
5187 int rx_fc_enable, tx_fc_enable;
5191 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5192 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5193 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5194 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5196 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5197 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5200 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5201 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5202 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5203 pfc_conf.fc.high_water = res->high_water;
5204 pfc_conf.fc.low_water = res->low_water;
5205 pfc_conf.fc.pause_time = res->pause_time;
5206 pfc_conf.priority = res->priority;
5208 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5210 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5213 cmdline_parse_token_string_t cmd_pfc_set_set =
5214 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5216 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5217 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5218 pfc_ctrl, "pfc_ctrl");
5219 cmdline_parse_token_string_t cmd_pfc_set_rx =
5220 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5222 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5223 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5224 rx_pfc_mode, "on#off");
5225 cmdline_parse_token_string_t cmd_pfc_set_tx =
5226 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5228 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5229 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5230 tx_pfc_mode, "on#off");
5231 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5232 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5233 high_water, UINT32);
5234 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5235 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5237 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5238 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5239 pause_time, UINT16);
5240 cmdline_parse_token_num_t cmd_pfc_set_priority =
5241 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5243 cmdline_parse_token_num_t cmd_pfc_set_portid =
5244 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5247 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5248 .f = cmd_priority_flow_ctrl_set_parsed,
5250 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5251 tx on|off high_water low_water pause_time priority port_id",
5253 (void *)&cmd_pfc_set_set,
5254 (void *)&cmd_pfc_set_flow_ctrl,
5255 (void *)&cmd_pfc_set_rx,
5256 (void *)&cmd_pfc_set_rx_mode,
5257 (void *)&cmd_pfc_set_tx,
5258 (void *)&cmd_pfc_set_tx_mode,
5259 (void *)&cmd_pfc_set_high_water,
5260 (void *)&cmd_pfc_set_low_water,
5261 (void *)&cmd_pfc_set_pause_time,
5262 (void *)&cmd_pfc_set_priority,
5263 (void *)&cmd_pfc_set_portid,
5268 /* *** RESET CONFIGURATION *** */
5269 struct cmd_reset_result {
5270 cmdline_fixed_string_t reset;
5271 cmdline_fixed_string_t def;
5274 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5276 __attribute__((unused)) void *data)
5278 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5279 set_def_fwd_config();
5282 cmdline_parse_token_string_t cmd_reset_set =
5283 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5284 cmdline_parse_token_string_t cmd_reset_def =
5285 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5288 cmdline_parse_inst_t cmd_reset = {
5289 .f = cmd_reset_parsed,
5291 .help_str = "set default: reset default forwarding configuration",
5293 (void *)&cmd_reset_set,
5294 (void *)&cmd_reset_def,
5299 /* *** START FORWARDING *** */
5300 struct cmd_start_result {
5301 cmdline_fixed_string_t start;
5304 cmdline_parse_token_string_t cmd_start_start =
5305 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5307 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5308 __attribute__((unused)) struct cmdline *cl,
5309 __attribute__((unused)) void *data)
5311 start_packet_forwarding(0);
5314 cmdline_parse_inst_t cmd_start = {
5315 .f = cmd_start_parsed,
5317 .help_str = "start packet forwarding",
5319 (void *)&cmd_start_start,
5324 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5325 struct cmd_start_tx_first_result {
5326 cmdline_fixed_string_t start;
5327 cmdline_fixed_string_t tx_first;
5331 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5332 __attribute__((unused)) struct cmdline *cl,
5333 __attribute__((unused)) void *data)
5335 start_packet_forwarding(1);
5338 cmdline_parse_token_string_t cmd_start_tx_first_start =
5339 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5341 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5342 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5343 tx_first, "tx_first");
5345 cmdline_parse_inst_t cmd_start_tx_first = {
5346 .f = cmd_start_tx_first_parsed,
5348 .help_str = "start packet forwarding, after sending 1 burst of packets",
5350 (void *)&cmd_start_tx_first_start,
5351 (void *)&cmd_start_tx_first_tx_first,
5356 /* *** SET LINK UP *** */
5357 struct cmd_set_link_up_result {
5358 cmdline_fixed_string_t set;
5359 cmdline_fixed_string_t link_up;
5360 cmdline_fixed_string_t port;
5364 cmdline_parse_token_string_t cmd_set_link_up_set =
5365 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5366 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5367 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5369 cmdline_parse_token_string_t cmd_set_link_up_port =
5370 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5371 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5372 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5374 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5375 __attribute__((unused)) struct cmdline *cl,
5376 __attribute__((unused)) void *data)
5378 struct cmd_set_link_up_result *res = parsed_result;
5379 dev_set_link_up(res->port_id);
5382 cmdline_parse_inst_t cmd_set_link_up = {
5383 .f = cmd_set_link_up_parsed,
5385 .help_str = "set link-up port (port id)",
5387 (void *)&cmd_set_link_up_set,
5388 (void *)&cmd_set_link_up_link_up,
5389 (void *)&cmd_set_link_up_port,
5390 (void *)&cmd_set_link_up_port_id,
5395 /* *** SET LINK DOWN *** */
5396 struct cmd_set_link_down_result {
5397 cmdline_fixed_string_t set;
5398 cmdline_fixed_string_t link_down;
5399 cmdline_fixed_string_t port;
5403 cmdline_parse_token_string_t cmd_set_link_down_set =
5404 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5405 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5406 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5408 cmdline_parse_token_string_t cmd_set_link_down_port =
5409 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5410 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5411 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5413 static void cmd_set_link_down_parsed(
5414 __attribute__((unused)) void *parsed_result,
5415 __attribute__((unused)) struct cmdline *cl,
5416 __attribute__((unused)) void *data)
5418 struct cmd_set_link_down_result *res = parsed_result;
5419 dev_set_link_down(res->port_id);
5422 cmdline_parse_inst_t cmd_set_link_down = {
5423 .f = cmd_set_link_down_parsed,
5425 .help_str = "set link-down port (port id)",
5427 (void *)&cmd_set_link_down_set,
5428 (void *)&cmd_set_link_down_link_down,
5429 (void *)&cmd_set_link_down_port,
5430 (void *)&cmd_set_link_down_port_id,
5435 /* *** SHOW CFG *** */
5436 struct cmd_showcfg_result {
5437 cmdline_fixed_string_t show;
5438 cmdline_fixed_string_t cfg;
5439 cmdline_fixed_string_t what;
5442 static void cmd_showcfg_parsed(void *parsed_result,
5443 __attribute__((unused)) struct cmdline *cl,
5444 __attribute__((unused)) void *data)
5446 struct cmd_showcfg_result *res = parsed_result;
5447 if (!strcmp(res->what, "rxtx"))
5448 rxtx_config_display();
5449 else if (!strcmp(res->what, "cores"))
5450 fwd_lcores_config_display();
5451 else if (!strcmp(res->what, "fwd"))
5452 fwd_config_display();
5455 cmdline_parse_token_string_t cmd_showcfg_show =
5456 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5457 cmdline_parse_token_string_t cmd_showcfg_port =
5458 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5459 cmdline_parse_token_string_t cmd_showcfg_what =
5460 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5463 cmdline_parse_inst_t cmd_showcfg = {
5464 .f = cmd_showcfg_parsed,
5466 .help_str = "show config rxtx|cores|fwd",
5468 (void *)&cmd_showcfg_show,
5469 (void *)&cmd_showcfg_port,
5470 (void *)&cmd_showcfg_what,
5475 /* *** SHOW ALL PORT INFO *** */
5476 struct cmd_showportall_result {
5477 cmdline_fixed_string_t show;
5478 cmdline_fixed_string_t port;
5479 cmdline_fixed_string_t what;
5480 cmdline_fixed_string_t all;
5483 static void cmd_showportall_parsed(void *parsed_result,
5484 __attribute__((unused)) struct cmdline *cl,
5485 __attribute__((unused)) void *data)
5489 struct cmd_showportall_result *res = parsed_result;
5490 if (!strcmp(res->show, "clear")) {
5491 if (!strcmp(res->what, "stats"))
5492 for (i = 0; i < nb_ports; i++)
5494 else if (!strcmp(res->what, "xstats"))
5495 for (i = 0; i < nb_ports; i++)
5496 nic_xstats_clear(i);
5497 } else if (!strcmp(res->what, "info"))
5498 for (i = 0; i < nb_ports; i++)
5499 port_infos_display(i);
5500 else if (!strcmp(res->what, "stats"))
5501 for (i = 0; i < nb_ports; i++)
5502 nic_stats_display(i);
5503 else if (!strcmp(res->what, "xstats"))
5504 for (i = 0; i < nb_ports; i++)
5505 nic_xstats_display(i);
5506 else if (!strcmp(res->what, "fdir"))
5507 for (i = 0; i < nb_ports; i++)
5509 else if (!strcmp(res->what, "stat_qmap"))
5510 for (i = 0; i < nb_ports; i++)
5511 nic_stats_mapping_display(i);
5514 cmdline_parse_token_string_t cmd_showportall_show =
5515 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5517 cmdline_parse_token_string_t cmd_showportall_port =
5518 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5519 cmdline_parse_token_string_t cmd_showportall_what =
5520 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5521 "info#stats#xstats#fdir#stat_qmap");
5522 cmdline_parse_token_string_t cmd_showportall_all =
5523 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5524 cmdline_parse_inst_t cmd_showportall = {
5525 .f = cmd_showportall_parsed,
5527 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5529 (void *)&cmd_showportall_show,
5530 (void *)&cmd_showportall_port,
5531 (void *)&cmd_showportall_what,
5532 (void *)&cmd_showportall_all,
5537 /* *** SHOW PORT INFO *** */
5538 struct cmd_showport_result {
5539 cmdline_fixed_string_t show;
5540 cmdline_fixed_string_t port;
5541 cmdline_fixed_string_t what;
5545 static void cmd_showport_parsed(void *parsed_result,
5546 __attribute__((unused)) struct cmdline *cl,
5547 __attribute__((unused)) void *data)
5549 struct cmd_showport_result *res = parsed_result;
5550 if (!strcmp(res->show, "clear")) {
5551 if (!strcmp(res->what, "stats"))
5552 nic_stats_clear(res->portnum);
5553 else if (!strcmp(res->what, "xstats"))
5554 nic_xstats_clear(res->portnum);
5555 } else if (!strcmp(res->what, "info"))
5556 port_infos_display(res->portnum);
5557 else if (!strcmp(res->what, "stats"))
5558 nic_stats_display(res->portnum);
5559 else if (!strcmp(res->what, "xstats"))
5560 nic_xstats_display(res->portnum);
5561 else if (!strcmp(res->what, "fdir"))
5562 fdir_get_infos(res->portnum);
5563 else if (!strcmp(res->what, "stat_qmap"))
5564 nic_stats_mapping_display(res->portnum);
5567 cmdline_parse_token_string_t cmd_showport_show =
5568 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5570 cmdline_parse_token_string_t cmd_showport_port =
5571 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5572 cmdline_parse_token_string_t cmd_showport_what =
5573 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5574 "info#stats#xstats#fdir#stat_qmap");
5575 cmdline_parse_token_num_t cmd_showport_portnum =
5576 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5578 cmdline_parse_inst_t cmd_showport = {
5579 .f = cmd_showport_parsed,
5581 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5583 (void *)&cmd_showport_show,
5584 (void *)&cmd_showport_port,
5585 (void *)&cmd_showport_what,
5586 (void *)&cmd_showport_portnum,
5591 /* *** READ PORT REGISTER *** */
5592 struct cmd_read_reg_result {
5593 cmdline_fixed_string_t read;
5594 cmdline_fixed_string_t reg;
5600 cmd_read_reg_parsed(void *parsed_result,
5601 __attribute__((unused)) struct cmdline *cl,
5602 __attribute__((unused)) void *data)
5604 struct cmd_read_reg_result *res = parsed_result;
5605 port_reg_display(res->port_id, res->reg_off);
5608 cmdline_parse_token_string_t cmd_read_reg_read =
5609 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5610 cmdline_parse_token_string_t cmd_read_reg_reg =
5611 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5612 cmdline_parse_token_num_t cmd_read_reg_port_id =
5613 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5614 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5615 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5617 cmdline_parse_inst_t cmd_read_reg = {
5618 .f = cmd_read_reg_parsed,
5620 .help_str = "read reg port_id reg_off",
5622 (void *)&cmd_read_reg_read,
5623 (void *)&cmd_read_reg_reg,
5624 (void *)&cmd_read_reg_port_id,
5625 (void *)&cmd_read_reg_reg_off,
5630 /* *** READ PORT REGISTER BIT FIELD *** */
5631 struct cmd_read_reg_bit_field_result {
5632 cmdline_fixed_string_t read;
5633 cmdline_fixed_string_t regfield;
5641 cmd_read_reg_bit_field_parsed(void *parsed_result,
5642 __attribute__((unused)) struct cmdline *cl,
5643 __attribute__((unused)) void *data)
5645 struct cmd_read_reg_bit_field_result *res = parsed_result;
5646 port_reg_bit_field_display(res->port_id, res->reg_off,
5647 res->bit1_pos, res->bit2_pos);
5650 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5651 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5653 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5654 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5655 regfield, "regfield");
5656 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5657 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5659 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5660 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5662 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5663 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5665 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5666 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5669 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5670 .f = cmd_read_reg_bit_field_parsed,
5672 .help_str = "read regfield port_id reg_off bit_x bit_y "
5673 "(read register bit field between bit_x and bit_y included)",
5675 (void *)&cmd_read_reg_bit_field_read,
5676 (void *)&cmd_read_reg_bit_field_regfield,
5677 (void *)&cmd_read_reg_bit_field_port_id,
5678 (void *)&cmd_read_reg_bit_field_reg_off,
5679 (void *)&cmd_read_reg_bit_field_bit1_pos,
5680 (void *)&cmd_read_reg_bit_field_bit2_pos,
5685 /* *** READ PORT REGISTER BIT *** */
5686 struct cmd_read_reg_bit_result {
5687 cmdline_fixed_string_t read;
5688 cmdline_fixed_string_t regbit;
5695 cmd_read_reg_bit_parsed(void *parsed_result,
5696 __attribute__((unused)) struct cmdline *cl,
5697 __attribute__((unused)) void *data)
5699 struct cmd_read_reg_bit_result *res = parsed_result;
5700 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5703 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5704 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5705 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5706 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5708 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5709 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5710 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5711 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5712 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5713 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5715 cmdline_parse_inst_t cmd_read_reg_bit = {
5716 .f = cmd_read_reg_bit_parsed,
5718 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5720 (void *)&cmd_read_reg_bit_read,
5721 (void *)&cmd_read_reg_bit_regbit,
5722 (void *)&cmd_read_reg_bit_port_id,
5723 (void *)&cmd_read_reg_bit_reg_off,
5724 (void *)&cmd_read_reg_bit_bit_pos,
5729 /* *** WRITE PORT REGISTER *** */
5730 struct cmd_write_reg_result {
5731 cmdline_fixed_string_t write;
5732 cmdline_fixed_string_t reg;
5739 cmd_write_reg_parsed(void *parsed_result,
5740 __attribute__((unused)) struct cmdline *cl,
5741 __attribute__((unused)) void *data)
5743 struct cmd_write_reg_result *res = parsed_result;
5744 port_reg_set(res->port_id, res->reg_off, res->value);
5747 cmdline_parse_token_string_t cmd_write_reg_write =
5748 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5749 cmdline_parse_token_string_t cmd_write_reg_reg =
5750 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5751 cmdline_parse_token_num_t cmd_write_reg_port_id =
5752 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5753 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5754 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5755 cmdline_parse_token_num_t cmd_write_reg_value =
5756 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5758 cmdline_parse_inst_t cmd_write_reg = {
5759 .f = cmd_write_reg_parsed,
5761 .help_str = "write reg port_id reg_off reg_value",
5763 (void *)&cmd_write_reg_write,
5764 (void *)&cmd_write_reg_reg,
5765 (void *)&cmd_write_reg_port_id,
5766 (void *)&cmd_write_reg_reg_off,
5767 (void *)&cmd_write_reg_value,
5772 /* *** WRITE PORT REGISTER BIT FIELD *** */
5773 struct cmd_write_reg_bit_field_result {
5774 cmdline_fixed_string_t write;
5775 cmdline_fixed_string_t regfield;
5784 cmd_write_reg_bit_field_parsed(void *parsed_result,
5785 __attribute__((unused)) struct cmdline *cl,
5786 __attribute__((unused)) void *data)
5788 struct cmd_write_reg_bit_field_result *res = parsed_result;
5789 port_reg_bit_field_set(res->port_id, res->reg_off,
5790 res->bit1_pos, res->bit2_pos, res->value);
5793 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5794 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5796 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5797 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5798 regfield, "regfield");
5799 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5800 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5802 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5803 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5805 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5806 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5808 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5809 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5811 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5812 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5815 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5816 .f = cmd_write_reg_bit_field_parsed,
5818 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5819 "(set register bit field between bit_x and bit_y included)",
5821 (void *)&cmd_write_reg_bit_field_write,
5822 (void *)&cmd_write_reg_bit_field_regfield,
5823 (void *)&cmd_write_reg_bit_field_port_id,
5824 (void *)&cmd_write_reg_bit_field_reg_off,
5825 (void *)&cmd_write_reg_bit_field_bit1_pos,
5826 (void *)&cmd_write_reg_bit_field_bit2_pos,
5827 (void *)&cmd_write_reg_bit_field_value,
5832 /* *** WRITE PORT REGISTER BIT *** */
5833 struct cmd_write_reg_bit_result {
5834 cmdline_fixed_string_t write;
5835 cmdline_fixed_string_t regbit;
5843 cmd_write_reg_bit_parsed(void *parsed_result,
5844 __attribute__((unused)) struct cmdline *cl,
5845 __attribute__((unused)) void *data)
5847 struct cmd_write_reg_bit_result *res = parsed_result;
5848 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5851 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5852 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5854 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5855 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5857 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5858 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5859 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5860 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5861 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5862 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5863 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5864 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5866 cmdline_parse_inst_t cmd_write_reg_bit = {
5867 .f = cmd_write_reg_bit_parsed,
5869 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5871 (void *)&cmd_write_reg_bit_write,
5872 (void *)&cmd_write_reg_bit_regbit,
5873 (void *)&cmd_write_reg_bit_port_id,
5874 (void *)&cmd_write_reg_bit_reg_off,
5875 (void *)&cmd_write_reg_bit_bit_pos,
5876 (void *)&cmd_write_reg_bit_value,
5881 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5882 struct cmd_read_rxd_txd_result {
5883 cmdline_fixed_string_t read;
5884 cmdline_fixed_string_t rxd_txd;
5891 cmd_read_rxd_txd_parsed(void *parsed_result,
5892 __attribute__((unused)) struct cmdline *cl,
5893 __attribute__((unused)) void *data)
5895 struct cmd_read_rxd_txd_result *res = parsed_result;
5897 if (!strcmp(res->rxd_txd, "rxd"))
5898 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5899 else if (!strcmp(res->rxd_txd, "txd"))
5900 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5903 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5904 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5905 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5906 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5908 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5909 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5910 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5911 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5912 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5913 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5915 cmdline_parse_inst_t cmd_read_rxd_txd = {
5916 .f = cmd_read_rxd_txd_parsed,
5918 .help_str = "read rxd|txd port_id queue_id rxd_id",
5920 (void *)&cmd_read_rxd_txd_read,
5921 (void *)&cmd_read_rxd_txd_rxd_txd,
5922 (void *)&cmd_read_rxd_txd_port_id,
5923 (void *)&cmd_read_rxd_txd_queue_id,
5924 (void *)&cmd_read_rxd_txd_desc_id,
5930 struct cmd_quit_result {
5931 cmdline_fixed_string_t quit;
5934 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5936 __attribute__((unused)) void *data)
5942 cmdline_parse_token_string_t cmd_quit_quit =
5943 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5945 cmdline_parse_inst_t cmd_quit = {
5946 .f = cmd_quit_parsed,
5948 .help_str = "exit application",
5950 (void *)&cmd_quit_quit,
5955 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5956 struct cmd_mac_addr_result {
5957 cmdline_fixed_string_t mac_addr_cmd;
5958 cmdline_fixed_string_t what;
5960 struct ether_addr address;
5963 static void cmd_mac_addr_parsed(void *parsed_result,
5964 __attribute__((unused)) struct cmdline *cl,
5965 __attribute__((unused)) void *data)
5967 struct cmd_mac_addr_result *res = parsed_result;
5970 if (strcmp(res->what, "add") == 0)
5971 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5973 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5975 /* check the return value and print it if is < 0 */
5977 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5981 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5982 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5984 cmdline_parse_token_string_t cmd_mac_addr_what =
5985 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5987 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5988 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5989 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5990 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5992 cmdline_parse_inst_t cmd_mac_addr = {
5993 .f = cmd_mac_addr_parsed,
5995 .help_str = "mac_addr add|remove X <address>: "
5996 "add/remove MAC address on port X",
5998 (void *)&cmd_mac_addr_cmd,
5999 (void *)&cmd_mac_addr_what,
6000 (void *)&cmd_mac_addr_portnum,
6001 (void *)&cmd_mac_addr_addr,
6007 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6008 struct cmd_set_qmap_result {
6009 cmdline_fixed_string_t set;
6010 cmdline_fixed_string_t qmap;
6011 cmdline_fixed_string_t what;
6018 cmd_set_qmap_parsed(void *parsed_result,
6019 __attribute__((unused)) struct cmdline *cl,
6020 __attribute__((unused)) void *data)
6022 struct cmd_set_qmap_result *res = parsed_result;
6023 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6025 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6028 cmdline_parse_token_string_t cmd_setqmap_set =
6029 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6031 cmdline_parse_token_string_t cmd_setqmap_qmap =
6032 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6034 cmdline_parse_token_string_t cmd_setqmap_what =
6035 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6037 cmdline_parse_token_num_t cmd_setqmap_portid =
6038 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6040 cmdline_parse_token_num_t cmd_setqmap_queueid =
6041 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6043 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6044 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6047 cmdline_parse_inst_t cmd_set_qmap = {
6048 .f = cmd_set_qmap_parsed,
6050 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6052 (void *)&cmd_setqmap_set,
6053 (void *)&cmd_setqmap_qmap,
6054 (void *)&cmd_setqmap_what,
6055 (void *)&cmd_setqmap_portid,
6056 (void *)&cmd_setqmap_queueid,
6057 (void *)&cmd_setqmap_mapvalue,
6062 /* *** CONFIGURE UNICAST HASH TABLE *** */
6063 struct cmd_set_uc_hash_table {
6064 cmdline_fixed_string_t set;
6065 cmdline_fixed_string_t port;
6067 cmdline_fixed_string_t what;
6068 struct ether_addr address;
6069 cmdline_fixed_string_t mode;
6073 cmd_set_uc_hash_parsed(void *parsed_result,
6074 __attribute__((unused)) struct cmdline *cl,
6075 __attribute__((unused)) void *data)
6078 struct cmd_set_uc_hash_table *res = parsed_result;
6080 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6082 if (strcmp(res->what, "uta") == 0)
6083 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6084 &res->address,(uint8_t)is_on);
6086 printf("bad unicast hash table parameter, return code = %d \n", ret);
6090 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6091 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6093 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6094 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6096 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6097 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6099 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6100 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6102 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6103 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6105 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6106 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6109 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6110 .f = cmd_set_uc_hash_parsed,
6112 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6114 (void *)&cmd_set_uc_hash_set,
6115 (void *)&cmd_set_uc_hash_port,
6116 (void *)&cmd_set_uc_hash_portid,
6117 (void *)&cmd_set_uc_hash_what,
6118 (void *)&cmd_set_uc_hash_mac,
6119 (void *)&cmd_set_uc_hash_mode,
6124 struct cmd_set_uc_all_hash_table {
6125 cmdline_fixed_string_t set;
6126 cmdline_fixed_string_t port;
6128 cmdline_fixed_string_t what;
6129 cmdline_fixed_string_t value;
6130 cmdline_fixed_string_t mode;
6134 cmd_set_uc_all_hash_parsed(void *parsed_result,
6135 __attribute__((unused)) struct cmdline *cl,
6136 __attribute__((unused)) void *data)
6139 struct cmd_set_uc_all_hash_table *res = parsed_result;
6141 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6143 if ((strcmp(res->what, "uta") == 0) &&
6144 (strcmp(res->value, "all") == 0))
6145 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6147 printf("bad unicast hash table parameter,"
6148 "return code = %d \n", ret);
6151 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6152 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6154 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6155 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6157 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6158 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6160 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6161 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6163 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6164 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6166 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6167 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6170 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6171 .f = cmd_set_uc_all_hash_parsed,
6173 .help_str = "set port X uta all on|off (X = port number)",
6175 (void *)&cmd_set_uc_all_hash_set,
6176 (void *)&cmd_set_uc_all_hash_port,
6177 (void *)&cmd_set_uc_all_hash_portid,
6178 (void *)&cmd_set_uc_all_hash_what,
6179 (void *)&cmd_set_uc_all_hash_value,
6180 (void *)&cmd_set_uc_all_hash_mode,
6185 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6186 struct cmd_set_vf_macvlan_filter {
6187 cmdline_fixed_string_t set;
6188 cmdline_fixed_string_t port;
6190 cmdline_fixed_string_t vf;
6192 struct ether_addr address;
6193 cmdline_fixed_string_t filter_type;
6194 cmdline_fixed_string_t mode;
6198 cmd_set_vf_macvlan_parsed(void *parsed_result,
6199 __attribute__((unused)) struct cmdline *cl,
6200 __attribute__((unused)) void *data)
6203 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6204 struct rte_eth_mac_filter filter;
6206 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6208 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6210 /* set VF MAC filter */
6214 filter.dst_id = res->vf_id;
6216 if (!strcmp(res->filter_type, "exact-mac"))
6217 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6218 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6219 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6220 else if (!strcmp(res->filter_type, "hashmac"))
6221 filter.filter_type = RTE_MAC_HASH_MATCH;
6222 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6223 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6225 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6228 ret = rte_eth_dev_filter_ctrl(res->port_id,
6229 RTE_ETH_FILTER_MACVLAN,
6233 ret = rte_eth_dev_filter_ctrl(res->port_id,
6234 RTE_ETH_FILTER_MACVLAN,
6235 RTE_ETH_FILTER_DELETE,
6239 printf("bad set MAC hash parameter, return code = %d\n", ret);
6243 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6244 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6246 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6247 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6249 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6250 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6252 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6253 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6255 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6256 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6258 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6259 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6261 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6262 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6263 filter_type, "exact-mac#exact-mac-vlan"
6264 "#hashmac#hashmac-vlan");
6265 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6266 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6269 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6270 .f = cmd_set_vf_macvlan_parsed,
6272 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6273 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6275 "exact match rule:exact match of MAC or MAC and VLAN; "
6276 "hash match rule: hash match of MAC and exact match "
6279 (void *)&cmd_set_vf_macvlan_set,
6280 (void *)&cmd_set_vf_macvlan_port,
6281 (void *)&cmd_set_vf_macvlan_portid,
6282 (void *)&cmd_set_vf_macvlan_vf,
6283 (void *)&cmd_set_vf_macvlan_vf_id,
6284 (void *)&cmd_set_vf_macvlan_mac,
6285 (void *)&cmd_set_vf_macvlan_filter_type,
6286 (void *)&cmd_set_vf_macvlan_mode,
6291 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6292 struct cmd_set_vf_traffic {
6293 cmdline_fixed_string_t set;
6294 cmdline_fixed_string_t port;
6296 cmdline_fixed_string_t vf;
6298 cmdline_fixed_string_t what;
6299 cmdline_fixed_string_t mode;
6303 cmd_set_vf_traffic_parsed(void *parsed_result,
6304 __attribute__((unused)) struct cmdline *cl,
6305 __attribute__((unused)) void *data)
6307 struct cmd_set_vf_traffic *res = parsed_result;
6308 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6309 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6311 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6314 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6315 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6317 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6318 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6320 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6321 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6323 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6324 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6326 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6327 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6329 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6330 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6332 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6333 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6336 cmdline_parse_inst_t cmd_set_vf_traffic = {
6337 .f = cmd_set_vf_traffic_parsed,
6339 .help_str = "set port X vf Y rx|tx on|off"
6340 "(X = port number,Y = vf id)",
6342 (void *)&cmd_setvf_traffic_set,
6343 (void *)&cmd_setvf_traffic_port,
6344 (void *)&cmd_setvf_traffic_portid,
6345 (void *)&cmd_setvf_traffic_vf,
6346 (void *)&cmd_setvf_traffic_vfid,
6347 (void *)&cmd_setvf_traffic_what,
6348 (void *)&cmd_setvf_traffic_mode,
6353 /* *** CONFIGURE VF RECEIVE MODE *** */
6354 struct cmd_set_vf_rxmode {
6355 cmdline_fixed_string_t set;
6356 cmdline_fixed_string_t port;
6358 cmdline_fixed_string_t vf;
6360 cmdline_fixed_string_t what;
6361 cmdline_fixed_string_t mode;
6362 cmdline_fixed_string_t on;
6366 cmd_set_vf_rxmode_parsed(void *parsed_result,
6367 __attribute__((unused)) struct cmdline *cl,
6368 __attribute__((unused)) void *data)
6371 uint16_t rx_mode = 0;
6372 struct cmd_set_vf_rxmode *res = parsed_result;
6374 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6375 if (!strcmp(res->what,"rxmode")) {
6376 if (!strcmp(res->mode, "AUPE"))
6377 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6378 else if (!strcmp(res->mode, "ROPE"))
6379 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6380 else if (!strcmp(res->mode, "BAM"))
6381 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6382 else if (!strncmp(res->mode, "MPE",3))
6383 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6386 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6388 printf("bad VF receive mode parameter, return code = %d \n",
6392 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6393 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6395 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6396 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6398 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6399 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6401 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6402 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6404 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6405 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6407 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6408 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6410 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6411 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6412 mode, "AUPE#ROPE#BAM#MPE");
6413 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6414 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6417 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6418 .f = cmd_set_vf_rxmode_parsed,
6420 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6422 (void *)&cmd_set_vf_rxmode_set,
6423 (void *)&cmd_set_vf_rxmode_port,
6424 (void *)&cmd_set_vf_rxmode_portid,
6425 (void *)&cmd_set_vf_rxmode_vf,
6426 (void *)&cmd_set_vf_rxmode_vfid,
6427 (void *)&cmd_set_vf_rxmode_what,
6428 (void *)&cmd_set_vf_rxmode_mode,
6429 (void *)&cmd_set_vf_rxmode_on,
6434 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6435 struct cmd_vf_mac_addr_result {
6436 cmdline_fixed_string_t mac_addr_cmd;
6437 cmdline_fixed_string_t what;
6438 cmdline_fixed_string_t port;
6440 cmdline_fixed_string_t vf;
6442 struct ether_addr address;
6445 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6446 __attribute__((unused)) struct cmdline *cl,
6447 __attribute__((unused)) void *data)
6449 struct cmd_vf_mac_addr_result *res = parsed_result;
6452 if (strcmp(res->what, "add") == 0)
6453 ret = rte_eth_dev_mac_addr_add(res->port_num,
6454 &res->address, res->vf_num);
6456 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6460 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6461 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6462 mac_addr_cmd,"mac_addr");
6463 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6464 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6466 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6467 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6469 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6470 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6472 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6473 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6475 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6476 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6478 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6479 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6482 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6483 .f = cmd_vf_mac_addr_parsed,
6485 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6486 "Y = VF number)add MAC address filtering for a VF on port X",
6488 (void *)&cmd_vf_mac_addr_cmd,
6489 (void *)&cmd_vf_mac_addr_what,
6490 (void *)&cmd_vf_mac_addr_port,
6491 (void *)&cmd_vf_mac_addr_portnum,
6492 (void *)&cmd_vf_mac_addr_vf,
6493 (void *)&cmd_vf_mac_addr_vfnum,
6494 (void *)&cmd_vf_mac_addr_addr,
6499 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6500 struct cmd_vf_rx_vlan_filter {
6501 cmdline_fixed_string_t rx_vlan;
6502 cmdline_fixed_string_t what;
6504 cmdline_fixed_string_t port;
6506 cmdline_fixed_string_t vf;
6511 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6512 __attribute__((unused)) struct cmdline *cl,
6513 __attribute__((unused)) void *data)
6515 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6517 if (!strcmp(res->what, "add"))
6518 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6520 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6523 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6524 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6525 rx_vlan, "rx_vlan");
6526 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6527 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6529 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6530 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6532 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6533 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6535 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6536 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6538 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6539 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6541 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6542 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6545 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6546 .f = cmd_vf_rx_vlan_filter_parsed,
6548 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6549 "Y = port number,Z = hexadecimal VF mask)",
6551 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6552 (void *)&cmd_vf_rx_vlan_filter_what,
6553 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6554 (void *)&cmd_vf_rx_vlan_filter_port,
6555 (void *)&cmd_vf_rx_vlan_filter_portid,
6556 (void *)&cmd_vf_rx_vlan_filter_vf,
6557 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6562 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6563 struct cmd_queue_rate_limit_result {
6564 cmdline_fixed_string_t set;
6565 cmdline_fixed_string_t port;
6567 cmdline_fixed_string_t queue;
6569 cmdline_fixed_string_t rate;
6573 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6574 __attribute__((unused)) struct cmdline *cl,
6575 __attribute__((unused)) void *data)
6577 struct cmd_queue_rate_limit_result *res = parsed_result;
6580 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6581 && (strcmp(res->queue, "queue") == 0)
6582 && (strcmp(res->rate, "rate") == 0))
6583 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6586 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6590 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6591 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6593 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6594 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6596 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6597 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6599 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6600 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6602 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6603 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6605 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6606 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6608 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6609 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6612 cmdline_parse_inst_t cmd_queue_rate_limit = {
6613 .f = cmd_queue_rate_limit_parsed,
6615 .help_str = "set port X queue Y rate Z:(X = port number,"
6616 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6618 (void *)&cmd_queue_rate_limit_set,
6619 (void *)&cmd_queue_rate_limit_port,
6620 (void *)&cmd_queue_rate_limit_portnum,
6621 (void *)&cmd_queue_rate_limit_queue,
6622 (void *)&cmd_queue_rate_limit_queuenum,
6623 (void *)&cmd_queue_rate_limit_rate,
6624 (void *)&cmd_queue_rate_limit_ratenum,
6629 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6630 struct cmd_vf_rate_limit_result {
6631 cmdline_fixed_string_t set;
6632 cmdline_fixed_string_t port;
6634 cmdline_fixed_string_t vf;
6636 cmdline_fixed_string_t rate;
6638 cmdline_fixed_string_t q_msk;
6642 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6643 __attribute__((unused)) struct cmdline *cl,
6644 __attribute__((unused)) void *data)
6646 struct cmd_vf_rate_limit_result *res = parsed_result;
6649 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6650 && (strcmp(res->vf, "vf") == 0)
6651 && (strcmp(res->rate, "rate") == 0)
6652 && (strcmp(res->q_msk, "queue_mask") == 0))
6653 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6654 res->rate_num, res->q_msk_val);
6656 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6660 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6661 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6663 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6664 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6666 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6667 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6669 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6670 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6672 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6673 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6675 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6676 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6678 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6679 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6681 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6682 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6683 q_msk, "queue_mask");
6684 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6685 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6688 cmdline_parse_inst_t cmd_vf_rate_limit = {
6689 .f = cmd_vf_rate_limit_parsed,
6691 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6692 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6693 "for queues of VF on port X",
6695 (void *)&cmd_vf_rate_limit_set,
6696 (void *)&cmd_vf_rate_limit_port,
6697 (void *)&cmd_vf_rate_limit_portnum,
6698 (void *)&cmd_vf_rate_limit_vf,
6699 (void *)&cmd_vf_rate_limit_vfnum,
6700 (void *)&cmd_vf_rate_limit_rate,
6701 (void *)&cmd_vf_rate_limit_ratenum,
6702 (void *)&cmd_vf_rate_limit_q_msk,
6703 (void *)&cmd_vf_rate_limit_q_msk_val,
6708 /* *** ADD TUNNEL FILTER OF A PORT *** */
6709 struct cmd_tunnel_filter_result {
6710 cmdline_fixed_string_t cmd;
6711 cmdline_fixed_string_t what;
6713 struct ether_addr outer_mac;
6714 struct ether_addr inner_mac;
6715 cmdline_ipaddr_t ip_value;
6716 uint16_t inner_vlan;
6717 cmdline_fixed_string_t tunnel_type;
6718 cmdline_fixed_string_t filter_type;
6724 cmd_tunnel_filter_parsed(void *parsed_result,
6725 __attribute__((unused)) struct cmdline *cl,
6726 __attribute__((unused)) void *data)
6728 struct cmd_tunnel_filter_result *res = parsed_result;
6729 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6732 tunnel_filter_conf.outer_mac = &res->outer_mac;
6733 tunnel_filter_conf.inner_mac = &res->inner_mac;
6734 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6736 if (res->ip_value.family == AF_INET) {
6737 tunnel_filter_conf.ip_addr.ipv4_addr =
6738 res->ip_value.addr.ipv4.s_addr;
6739 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6741 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6742 &(res->ip_value.addr.ipv6),
6743 sizeof(struct in6_addr));
6744 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6747 if (!strcmp(res->filter_type, "imac-ivlan"))
6748 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6749 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6750 tunnel_filter_conf.filter_type =
6751 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6752 else if (!strcmp(res->filter_type, "imac-tenid"))
6753 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6754 else if (!strcmp(res->filter_type, "imac"))
6755 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6756 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6757 tunnel_filter_conf.filter_type =
6758 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6760 printf("The filter type is not supported");
6764 if (!strcmp(res->tunnel_type, "vxlan"))
6765 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6767 printf("Only VXLAN is supported now.\n");
6771 tunnel_filter_conf.tenant_id = res->tenant_id;
6772 tunnel_filter_conf.queue_id = res->queue_num;
6773 if (!strcmp(res->what, "add"))
6774 ret = rte_eth_dev_filter_ctrl(res->port_id,
6775 RTE_ETH_FILTER_TUNNEL,
6777 &tunnel_filter_conf);
6779 ret = rte_eth_dev_filter_ctrl(res->port_id,
6780 RTE_ETH_FILTER_TUNNEL,
6781 RTE_ETH_FILTER_DELETE,
6782 &tunnel_filter_conf);
6784 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6788 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6789 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6790 cmd, "tunnel_filter");
6791 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6792 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6794 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6795 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6797 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6798 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6800 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6801 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6803 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6804 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6805 inner_vlan, UINT16);
6806 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6807 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6809 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6810 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6811 tunnel_type, "vxlan");
6813 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6814 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6815 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6816 "imac#omac-imac-tenid");
6817 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6818 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6820 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6821 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6824 cmdline_parse_inst_t cmd_tunnel_filter = {
6825 .f = cmd_tunnel_filter_parsed,
6827 .help_str = "add/rm tunnel filter of a port: "
6828 "tunnel_filter add port_id outer_mac inner_mac ip "
6829 "inner_vlan tunnel_type(vxlan) filter_type "
6830 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6831 "imac|omac-imac-tenid) "
6832 "tenant_id queue_num",
6834 (void *)&cmd_tunnel_filter_cmd,
6835 (void *)&cmd_tunnel_filter_what,
6836 (void *)&cmd_tunnel_filter_port_id,
6837 (void *)&cmd_tunnel_filter_outer_mac,
6838 (void *)&cmd_tunnel_filter_inner_mac,
6839 (void *)&cmd_tunnel_filter_ip_value,
6840 (void *)&cmd_tunnel_filter_innner_vlan,
6841 (void *)&cmd_tunnel_filter_tunnel_type,
6842 (void *)&cmd_tunnel_filter_filter_type,
6843 (void *)&cmd_tunnel_filter_tenant_id,
6844 (void *)&cmd_tunnel_filter_queue_num,
6849 /* *** CONFIGURE TUNNEL UDP PORT *** */
6850 struct cmd_tunnel_udp_config {
6851 cmdline_fixed_string_t cmd;
6852 cmdline_fixed_string_t what;
6858 cmd_tunnel_udp_config_parsed(void *parsed_result,
6859 __attribute__((unused)) struct cmdline *cl,
6860 __attribute__((unused)) void *data)
6862 struct cmd_tunnel_udp_config *res = parsed_result;
6863 struct rte_eth_udp_tunnel tunnel_udp;
6866 tunnel_udp.udp_port = res->udp_port;
6868 if (!strcmp(res->cmd, "rx_vxlan_port"))
6869 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6871 if (!strcmp(res->what, "add"))
6872 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6874 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6877 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6880 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6881 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6882 cmd, "rx_vxlan_port");
6883 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6884 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6886 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6887 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6889 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6890 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6893 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6894 .f = cmd_tunnel_udp_config_parsed,
6896 .help_str = "add/rm an tunneling UDP port filter: "
6897 "rx_vxlan_port add udp_port port_id",
6899 (void *)&cmd_tunnel_udp_config_cmd,
6900 (void *)&cmd_tunnel_udp_config_what,
6901 (void *)&cmd_tunnel_udp_config_udp_port,
6902 (void *)&cmd_tunnel_udp_config_port_id,
6907 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6908 struct cmd_set_mirror_mask_result {
6909 cmdline_fixed_string_t set;
6910 cmdline_fixed_string_t port;
6912 cmdline_fixed_string_t mirror;
6914 cmdline_fixed_string_t what;
6915 cmdline_fixed_string_t value;
6916 cmdline_fixed_string_t dstpool;
6918 cmdline_fixed_string_t on;
6921 cmdline_parse_token_string_t cmd_mirror_mask_set =
6922 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6924 cmdline_parse_token_string_t cmd_mirror_mask_port =
6925 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6927 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6928 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6930 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6931 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6932 mirror, "mirror-rule");
6933 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6934 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6936 cmdline_parse_token_string_t cmd_mirror_mask_what =
6937 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6938 what, "pool-mirror#vlan-mirror");
6939 cmdline_parse_token_string_t cmd_mirror_mask_value =
6940 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6942 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6943 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6944 dstpool, "dst-pool");
6945 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6946 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6948 cmdline_parse_token_string_t cmd_mirror_mask_on =
6949 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6953 cmd_set_mirror_mask_parsed(void *parsed_result,
6954 __attribute__((unused)) struct cmdline *cl,
6955 __attribute__((unused)) void *data)
6958 struct cmd_set_mirror_mask_result *res = parsed_result;
6959 struct rte_eth_vmdq_mirror_conf mr_conf;
6961 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6963 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6965 mr_conf.dst_pool = res->dstpool_id;
6967 if (!strcmp(res->what, "pool-mirror")) {
6968 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6969 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6970 } else if(!strcmp(res->what, "vlan-mirror")) {
6971 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6972 nb_item = parse_item_list(res->value, "core",
6973 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6977 for(i=0; i < nb_item; i++) {
6978 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6979 printf("Invalid vlan_id: must be < 4096\n");
6983 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6984 mr_conf.vlan.vlan_mask |= 1ULL << i;
6988 if(!strcmp(res->on, "on"))
6989 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6992 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6995 printf("mirror rule add error: (%s)\n", strerror(-ret));
6998 cmdline_parse_inst_t cmd_set_mirror_mask = {
6999 .f = cmd_set_mirror_mask_parsed,
7001 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
7002 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7004 (void *)&cmd_mirror_mask_set,
7005 (void *)&cmd_mirror_mask_port,
7006 (void *)&cmd_mirror_mask_portid,
7007 (void *)&cmd_mirror_mask_mirror,
7008 (void *)&cmd_mirror_mask_ruleid,
7009 (void *)&cmd_mirror_mask_what,
7010 (void *)&cmd_mirror_mask_value,
7011 (void *)&cmd_mirror_mask_dstpool,
7012 (void *)&cmd_mirror_mask_poolid,
7013 (void *)&cmd_mirror_mask_on,
7018 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7019 struct cmd_set_mirror_link_result {
7020 cmdline_fixed_string_t set;
7021 cmdline_fixed_string_t port;
7023 cmdline_fixed_string_t mirror;
7025 cmdline_fixed_string_t what;
7026 cmdline_fixed_string_t dstpool;
7028 cmdline_fixed_string_t on;
7031 cmdline_parse_token_string_t cmd_mirror_link_set =
7032 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7034 cmdline_parse_token_string_t cmd_mirror_link_port =
7035 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7037 cmdline_parse_token_num_t cmd_mirror_link_portid =
7038 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7040 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7041 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7042 mirror, "mirror-rule");
7043 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7044 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7046 cmdline_parse_token_string_t cmd_mirror_link_what =
7047 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7048 what, "uplink-mirror#downlink-mirror");
7049 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7050 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7051 dstpool, "dst-pool");
7052 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7053 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7055 cmdline_parse_token_string_t cmd_mirror_link_on =
7056 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7060 cmd_set_mirror_link_parsed(void *parsed_result,
7061 __attribute__((unused)) struct cmdline *cl,
7062 __attribute__((unused)) void *data)
7065 struct cmd_set_mirror_link_result *res = parsed_result;
7066 struct rte_eth_vmdq_mirror_conf mr_conf;
7068 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
7069 if(!strcmp(res->what, "uplink-mirror")) {
7070 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
7071 }else if(!strcmp(res->what, "downlink-mirror"))
7072 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
7074 mr_conf.dst_pool = res->dstpool_id;
7076 if(!strcmp(res->on, "on"))
7077 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7080 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7083 /* check the return value and print it if is < 0 */
7085 printf("mirror rule add error: (%s)\n", strerror(-ret));
7089 cmdline_parse_inst_t cmd_set_mirror_link = {
7090 .f = cmd_set_mirror_link_parsed,
7092 .help_str = "set port X mirror-rule Y uplink-mirror|"
7093 "downlink-mirror dst-pool Z on|off",
7095 (void *)&cmd_mirror_link_set,
7096 (void *)&cmd_mirror_link_port,
7097 (void *)&cmd_mirror_link_portid,
7098 (void *)&cmd_mirror_link_mirror,
7099 (void *)&cmd_mirror_link_ruleid,
7100 (void *)&cmd_mirror_link_what,
7101 (void *)&cmd_mirror_link_dstpool,
7102 (void *)&cmd_mirror_link_poolid,
7103 (void *)&cmd_mirror_link_on,
7108 /* *** RESET VM MIRROR RULE *** */
7109 struct cmd_rm_mirror_rule_result {
7110 cmdline_fixed_string_t reset;
7111 cmdline_fixed_string_t port;
7113 cmdline_fixed_string_t mirror;
7117 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7118 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7120 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7121 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7123 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7124 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7126 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7127 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7128 mirror, "mirror-rule");
7129 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7130 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7134 cmd_reset_mirror_rule_parsed(void *parsed_result,
7135 __attribute__((unused)) struct cmdline *cl,
7136 __attribute__((unused)) void *data)
7139 struct cmd_set_mirror_link_result *res = parsed_result;
7141 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7143 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7146 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7147 .f = cmd_reset_mirror_rule_parsed,
7149 .help_str = "reset port X mirror-rule Y",
7151 (void *)&cmd_rm_mirror_rule_reset,
7152 (void *)&cmd_rm_mirror_rule_port,
7153 (void *)&cmd_rm_mirror_rule_portid,
7154 (void *)&cmd_rm_mirror_rule_mirror,
7155 (void *)&cmd_rm_mirror_rule_ruleid,
7160 /* ******************************************************************************** */
7162 struct cmd_dump_result {
7163 cmdline_fixed_string_t dump;
7167 dump_struct_sizes(void)
7169 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7170 DUMP_SIZE(struct rte_mbuf);
7171 DUMP_SIZE(struct rte_mempool);
7172 DUMP_SIZE(struct rte_ring);
7176 static void cmd_dump_parsed(void *parsed_result,
7177 __attribute__((unused)) struct cmdline *cl,
7178 __attribute__((unused)) void *data)
7180 struct cmd_dump_result *res = parsed_result;
7182 if (!strcmp(res->dump, "dump_physmem"))
7183 rte_dump_physmem_layout(stdout);
7184 else if (!strcmp(res->dump, "dump_memzone"))
7185 rte_memzone_dump(stdout);
7186 else if (!strcmp(res->dump, "dump_log_history"))
7187 rte_log_dump_history(stdout);
7188 else if (!strcmp(res->dump, "dump_struct_sizes"))
7189 dump_struct_sizes();
7190 else if (!strcmp(res->dump, "dump_ring"))
7191 rte_ring_list_dump(stdout);
7192 else if (!strcmp(res->dump, "dump_mempool"))
7193 rte_mempool_list_dump(stdout);
7194 else if (!strcmp(res->dump, "dump_devargs"))
7195 rte_eal_devargs_dump(stdout);
7198 cmdline_parse_token_string_t cmd_dump_dump =
7199 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7203 "dump_struct_sizes#"
7208 cmdline_parse_inst_t cmd_dump = {
7209 .f = cmd_dump_parsed, /* function to call */
7210 .data = NULL, /* 2nd arg of func */
7211 .help_str = "dump status",
7212 .tokens = { /* token list, NULL terminated */
7213 (void *)&cmd_dump_dump,
7218 /* ******************************************************************************** */
7220 struct cmd_dump_one_result {
7221 cmdline_fixed_string_t dump;
7222 cmdline_fixed_string_t name;
7225 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7226 __attribute__((unused)) void *data)
7228 struct cmd_dump_one_result *res = parsed_result;
7230 if (!strcmp(res->dump, "dump_ring")) {
7232 r = rte_ring_lookup(res->name);
7234 cmdline_printf(cl, "Cannot find ring\n");
7237 rte_ring_dump(stdout, r);
7238 } else if (!strcmp(res->dump, "dump_mempool")) {
7239 struct rte_mempool *mp;
7240 mp = rte_mempool_lookup(res->name);
7242 cmdline_printf(cl, "Cannot find mempool\n");
7245 rte_mempool_dump(stdout, mp);
7249 cmdline_parse_token_string_t cmd_dump_one_dump =
7250 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7251 "dump_ring#dump_mempool");
7253 cmdline_parse_token_string_t cmd_dump_one_name =
7254 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7256 cmdline_parse_inst_t cmd_dump_one = {
7257 .f = cmd_dump_one_parsed, /* function to call */
7258 .data = NULL, /* 2nd arg of func */
7259 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7260 .tokens = { /* token list, NULL terminated */
7261 (void *)&cmd_dump_one_dump,
7262 (void *)&cmd_dump_one_name,
7267 /* *** ADD/REMOVE an ethertype FILTER *** */
7268 struct cmd_ethertype_filter_result {
7269 cmdline_fixed_string_t filter;
7271 cmdline_fixed_string_t ethertype;
7272 uint16_t ethertype_value;
7273 cmdline_fixed_string_t priority;
7274 cmdline_fixed_string_t priority_en;
7275 uint8_t priority_value;
7276 cmdline_fixed_string_t queue;
7278 cmdline_fixed_string_t index;
7279 uint16_t index_value;
7283 cmd_ethertype_filter_parsed(void *parsed_result,
7284 __attribute__((unused)) struct cmdline *cl,
7285 __attribute__((unused)) void *data)
7288 struct cmd_ethertype_filter_result *res = parsed_result;
7289 struct rte_ethertype_filter filter;
7291 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
7292 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
7293 filter.priority = res->priority_value;
7295 if (!strcmp(res->priority_en, "enable"))
7296 filter.priority_en = 1;
7297 if (!strcmp(res->filter, "add_ethertype_filter"))
7298 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
7300 &filter, res->queue_id);
7301 else if (!strcmp(res->filter, "remove_ethertype_filter"))
7302 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
7304 else if (!strcmp(res->filter, "get_ethertype_filter"))
7305 get_ethertype_filter(res->port_id, res->index_value);
7308 printf("ethertype filter setting error: (%s)\n",
7312 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7313 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7315 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7316 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7317 ethertype, "ethertype");
7318 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
7319 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7320 ethertype_value, UINT16);
7321 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
7322 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7323 priority, "priority");
7324 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
7325 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7326 priority_en, "enable#disable");
7327 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
7328 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7329 priority_value, UINT8);
7330 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7331 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7333 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7334 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7336 cmdline_parse_token_string_t cmd_ethertype_filter_index =
7337 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7339 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
7340 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7341 index_value, UINT16);
7342 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
7343 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7344 filter, "add_ethertype_filter");
7345 cmdline_parse_inst_t cmd_add_ethertype_filter = {
7346 .f = cmd_ethertype_filter_parsed,
7348 .help_str = "add an ethertype filter",
7350 (void *)&cmd_ethertype_filter_add_filter,
7351 (void *)&cmd_ethertype_filter_port_id,
7352 (void *)&cmd_ethertype_filter_ethertype,
7353 (void *)&cmd_ethertype_filter_ethertype_value,
7354 (void *)&cmd_ethertype_filter_priority,
7355 (void *)&cmd_ethertype_filter_priority_en,
7356 (void *)&cmd_ethertype_filter_priority_value,
7357 (void *)&cmd_ethertype_filter_queue,
7358 (void *)&cmd_ethertype_filter_queue_id,
7359 (void *)&cmd_ethertype_filter_index,
7360 (void *)&cmd_ethertype_filter_index_value,
7365 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
7366 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7367 filter, "remove_ethertype_filter");
7368 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
7369 .f = cmd_ethertype_filter_parsed,
7371 .help_str = "remove an ethertype filter",
7373 (void *)&cmd_ethertype_filter_remove_filter,
7374 (void *)&cmd_ethertype_filter_port_id,
7375 (void *)&cmd_ethertype_filter_index,
7376 (void *)&cmd_ethertype_filter_index_value,
7380 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
7381 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7382 filter, "get_ethertype_filter");
7383 cmdline_parse_inst_t cmd_get_ethertype_filter = {
7384 .f = cmd_ethertype_filter_parsed,
7386 .help_str = "get an ethertype filter",
7388 (void *)&cmd_ethertype_filter_get_filter,
7389 (void *)&cmd_ethertype_filter_port_id,
7390 (void *)&cmd_ethertype_filter_index,
7391 (void *)&cmd_ethertype_filter_index_value,
7396 /* *** set SYN filter *** */
7397 struct cmd_set_syn_filter_result {
7398 cmdline_fixed_string_t filter;
7400 cmdline_fixed_string_t priority;
7401 cmdline_fixed_string_t high;
7402 cmdline_fixed_string_t queue;
7407 cmd_set_syn_filter_parsed(void *parsed_result,
7408 __attribute__((unused)) struct cmdline *cl,
7409 __attribute__((unused)) void *data)
7412 struct cmd_set_syn_filter_result *res = parsed_result;
7413 struct rte_syn_filter filter;
7415 if (!strcmp(res->filter, "add_syn_filter")) {
7416 if (!strcmp(res->high, "high"))
7420 ret = rte_eth_dev_add_syn_filter(res->port_id,
7421 &filter, res->queue_id);
7422 } else if (!strcmp(res->filter, "remove_syn_filter"))
7423 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7424 else if (!strcmp(res->filter, "get_syn_filter"))
7425 get_syn_filter(res->port_id);
7427 printf("syn filter setting error: (%s)\n", strerror(-ret));
7430 cmdline_parse_token_num_t cmd_syn_filter_portid =
7431 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7433 cmdline_parse_token_string_t cmd_syn_filter_priority =
7434 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7435 priority, "priority");
7436 cmdline_parse_token_string_t cmd_syn_filter_high =
7437 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7439 cmdline_parse_token_string_t cmd_syn_filter_queue =
7440 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7442 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7443 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7445 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7446 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7447 filter, "add_syn_filter");
7448 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7449 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7450 filter, "remove_syn_filter");
7451 cmdline_parse_inst_t cmd_add_syn_filter = {
7452 .f = cmd_set_syn_filter_parsed,
7454 .help_str = "add syn filter",
7456 (void *)&cmd_syn_filter_add_filter,
7457 (void *)&cmd_syn_filter_portid,
7458 (void *)&cmd_syn_filter_priority,
7459 (void *)&cmd_syn_filter_high,
7460 (void *)&cmd_syn_filter_queue,
7461 (void *)&cmd_syn_filter_queue_id,
7465 cmdline_parse_inst_t cmd_remove_syn_filter = {
7466 .f = cmd_set_syn_filter_parsed,
7468 .help_str = "remove syn filter",
7470 (void *)&cmd_syn_filter_remove_filter,
7471 (void *)&cmd_syn_filter_portid,
7476 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7477 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7478 filter, "get_syn_filter");
7480 cmdline_parse_inst_t cmd_get_syn_filter = {
7481 .f = cmd_set_syn_filter_parsed,
7483 .help_str = "get syn filter",
7485 (void *)&cmd_syn_filter_get_filter,
7486 (void *)&cmd_syn_filter_portid,
7491 /* *** ADD/REMOVE A 2tuple FILTER *** */
7492 struct cmd_2tuple_filter_result {
7493 cmdline_fixed_string_t filter;
7495 cmdline_fixed_string_t protocol;
7496 uint8_t protocol_value;
7497 uint8_t protocol_mask;
7498 cmdline_fixed_string_t dst_port;
7499 uint16_t dst_port_value;
7500 uint16_t dst_port_mask;
7501 cmdline_fixed_string_t flags;
7502 uint8_t flags_value;
7503 cmdline_fixed_string_t priority;
7504 uint8_t priority_value;
7505 cmdline_fixed_string_t queue;
7507 cmdline_fixed_string_t index;
7508 uint16_t index_value;
7512 cmd_2tuple_filter_parsed(void *parsed_result,
7513 __attribute__((unused)) struct cmdline *cl,
7514 __attribute__((unused)) void *data)
7517 struct rte_2tuple_filter filter;
7518 struct cmd_2tuple_filter_result *res = parsed_result;
7520 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7522 if (!strcmp(res->filter, "add_2tuple_filter")) {
7523 /* need convert to big endian. */
7524 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7525 filter.protocol = res->protocol_value;
7526 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7527 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7528 filter.priority = res->priority_value;
7529 filter.tcp_flags = res->flags_value;
7530 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7531 res->index_value, &filter, res->queue_id);
7532 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7533 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7535 else if (!strcmp(res->filter, "get_2tuple_filter"))
7536 get_2tuple_filter(res->port_id, res->index_value);
7539 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7542 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7543 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7545 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7546 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7547 protocol, "protocol");
7548 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7549 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7550 protocol_value, UINT8);
7551 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7552 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7553 protocol_mask, UINT8);
7554 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7555 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7556 dst_port, "dst_port");
7557 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7558 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7559 dst_port_value, UINT16);
7560 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7561 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7562 dst_port_mask, UINT16);
7563 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7564 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7566 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7567 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7568 flags_value, UINT8);
7569 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7570 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7571 priority, "priority");
7572 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7573 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7574 priority_value, UINT8);
7575 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7576 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7578 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7579 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7581 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7582 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7584 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7585 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7586 index_value, UINT16);
7587 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7588 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7589 filter, "add_2tuple_filter");
7590 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7591 .f = cmd_2tuple_filter_parsed,
7593 .help_str = "add a 2tuple filter",
7595 (void *)&cmd_2tuple_filter_add_filter,
7596 (void *)&cmd_2tuple_filter_port_id,
7597 (void *)&cmd_2tuple_filter_protocol,
7598 (void *)&cmd_2tuple_filter_protocol_value,
7599 (void *)&cmd_2tuple_filter_protocol_mask,
7600 (void *)&cmd_2tuple_filter_dst_port,
7601 (void *)&cmd_2tuple_filter_dst_port_value,
7602 (void *)&cmd_2tuple_filter_dst_port_mask,
7603 (void *)&cmd_2tuple_filter_flags,
7604 (void *)&cmd_2tuple_filter_flags_value,
7605 (void *)&cmd_2tuple_filter_priority,
7606 (void *)&cmd_2tuple_filter_priority_value,
7607 (void *)&cmd_2tuple_filter_queue,
7608 (void *)&cmd_2tuple_filter_queue_id,
7609 (void *)&cmd_2tuple_filter_index,
7610 (void *)&cmd_2tuple_filter_index_value,
7615 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7616 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7617 filter, "remove_2tuple_filter");
7618 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7619 .f = cmd_2tuple_filter_parsed,
7621 .help_str = "remove a 2tuple filter",
7623 (void *)&cmd_2tuple_filter_remove_filter,
7624 (void *)&cmd_2tuple_filter_port_id,
7625 (void *)&cmd_2tuple_filter_index,
7626 (void *)&cmd_2tuple_filter_index_value,
7630 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7631 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7632 filter, "get_2tuple_filter");
7633 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7634 .f = cmd_2tuple_filter_parsed,
7636 .help_str = "get a 2tuple filter",
7638 (void *)&cmd_2tuple_filter_get_filter,
7639 (void *)&cmd_2tuple_filter_port_id,
7640 (void *)&cmd_2tuple_filter_index,
7641 (void *)&cmd_2tuple_filter_index_value,
7646 /* *** ADD/REMOVE A 5tuple FILTER *** */
7647 struct cmd_5tuple_filter_result {
7648 cmdline_fixed_string_t filter;
7650 cmdline_fixed_string_t dst_ip;
7651 cmdline_ipaddr_t dst_ip_value;
7652 cmdline_fixed_string_t src_ip;
7653 cmdline_ipaddr_t src_ip_value;
7654 cmdline_fixed_string_t dst_port;
7655 uint16_t dst_port_value;
7656 cmdline_fixed_string_t src_port;
7657 uint16_t src_port_value;
7658 cmdline_fixed_string_t protocol;
7659 uint8_t protocol_value;
7660 cmdline_fixed_string_t mask;
7662 cmdline_fixed_string_t flags;
7663 uint8_t flags_value;
7664 cmdline_fixed_string_t priority;
7665 uint8_t priority_value;
7666 cmdline_fixed_string_t queue;
7668 cmdline_fixed_string_t index;
7669 uint16_t index_value;
7673 cmd_5tuple_filter_parsed(void *parsed_result,
7674 __attribute__((unused)) struct cmdline *cl,
7675 __attribute__((unused)) void *data)
7678 struct rte_5tuple_filter filter;
7679 struct cmd_5tuple_filter_result *res = parsed_result;
7681 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7683 if (!strcmp(res->filter, "add_5tuple_filter")) {
7684 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7685 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7686 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7687 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7688 filter.protocol = res->protocol_value;
7689 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7690 filter.priority = res->priority_value;
7691 filter.tcp_flags = res->flags_value;
7693 if (res->dst_ip_value.family == AF_INET)
7694 /* no need to convert, already big endian. */
7695 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7697 if (filter.dst_ip_mask == 0) {
7698 printf("can not support ipv6 involved compare.\n");
7704 if (res->src_ip_value.family == AF_INET)
7705 /* no need to convert, already big endian. */
7706 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7708 if (filter.src_ip_mask == 0) {
7709 printf("can not support ipv6 involved compare.\n");
7714 /* need convert to big endian. */
7715 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7716 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7718 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7719 res->index_value, &filter, res->queue_id);
7720 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7721 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7723 else if (!strcmp(res->filter, "get_5tuple_filter"))
7724 get_5tuple_filter(res->port_id, res->index_value);
7726 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7730 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7731 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7733 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7734 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7736 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7737 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7739 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7740 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7742 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7743 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7745 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7746 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7747 dst_port, "dst_port");
7748 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7749 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7750 dst_port_value, UINT16);
7751 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7752 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7753 src_port, "src_port");
7754 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7755 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7756 src_port_value, UINT16);
7757 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7758 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7759 protocol, "protocol");
7760 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7761 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7762 protocol_value, UINT8);
7763 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7764 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7766 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7767 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7769 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7770 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7772 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7773 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7774 flags_value, UINT8);
7775 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7776 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7777 priority, "priority");
7778 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7779 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7780 priority_value, UINT8);
7781 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7782 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7784 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7785 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7787 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7788 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7790 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7791 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7792 index_value, UINT16);
7794 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7795 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7796 filter, "add_5tuple_filter");
7797 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7798 .f = cmd_5tuple_filter_parsed,
7800 .help_str = "add a 5tuple filter",
7802 (void *)&cmd_5tuple_filter_add_filter,
7803 (void *)&cmd_5tuple_filter_port_id,
7804 (void *)&cmd_5tuple_filter_dst_ip,
7805 (void *)&cmd_5tuple_filter_dst_ip_value,
7806 (void *)&cmd_5tuple_filter_src_ip,
7807 (void *)&cmd_5tuple_filter_src_ip_value,
7808 (void *)&cmd_5tuple_filter_dst_port,
7809 (void *)&cmd_5tuple_filter_dst_port_value,
7810 (void *)&cmd_5tuple_filter_src_port,
7811 (void *)&cmd_5tuple_filter_src_port_value,
7812 (void *)&cmd_5tuple_filter_protocol,
7813 (void *)&cmd_5tuple_filter_protocol_value,
7814 (void *)&cmd_5tuple_filter_mask,
7815 (void *)&cmd_5tuple_filter_mask_value,
7816 (void *)&cmd_5tuple_filter_flags,
7817 (void *)&cmd_5tuple_filter_flags_value,
7818 (void *)&cmd_5tuple_filter_priority,
7819 (void *)&cmd_5tuple_filter_priority_value,
7820 (void *)&cmd_5tuple_filter_queue,
7821 (void *)&cmd_5tuple_filter_queue_id,
7822 (void *)&cmd_5tuple_filter_index,
7823 (void *)&cmd_5tuple_filter_index_value,
7828 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7829 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7830 filter, "remove_5tuple_filter");
7831 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7832 .f = cmd_5tuple_filter_parsed,
7834 .help_str = "remove a 5tuple filter",
7836 (void *)&cmd_5tuple_filter_remove_filter,
7837 (void *)&cmd_5tuple_filter_port_id,
7838 (void *)&cmd_5tuple_filter_index,
7839 (void *)&cmd_5tuple_filter_index_value,
7844 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7845 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7846 filter, "get_5tuple_filter");
7847 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7848 .f = cmd_5tuple_filter_parsed,
7850 .help_str = "get a 5tuple filter",
7852 (void *)&cmd_5tuple_filter_get_filter,
7853 (void *)&cmd_5tuple_filter_port_id,
7854 (void *)&cmd_5tuple_filter_index,
7855 (void *)&cmd_5tuple_filter_index_value,
7860 /* *** ADD/REMOVE A flex FILTER *** */
7861 struct cmd_flex_filter_result {
7862 cmdline_fixed_string_t filter;
7864 cmdline_fixed_string_t len;
7866 cmdline_fixed_string_t bytes;
7867 cmdline_fixed_string_t bytes_value;
7868 cmdline_fixed_string_t mask;
7869 cmdline_fixed_string_t mask_value;
7870 cmdline_fixed_string_t priority;
7871 uint8_t priority_value;
7872 cmdline_fixed_string_t queue;
7874 cmdline_fixed_string_t index;
7875 uint16_t index_value;
7878 static int xdigit2val(unsigned char c)
7883 else if (isupper(c))
7891 cmd_flex_filter_parsed(void *parsed_result,
7892 __attribute__((unused)) struct cmdline *cl,
7893 __attribute__((unused)) void *data)
7896 struct rte_flex_filter filter;
7897 struct cmd_flex_filter_result *res = parsed_result;
7898 char *bytes_ptr, *mask_ptr;
7906 if (!strcmp(res->filter, "add_flex_filter")) {
7907 if (res->len_value > 128) {
7908 printf("the len exceed the max length 128\n");
7911 memset(&filter, 0, sizeof(struct rte_flex_filter));
7912 filter.len = res->len_value;
7913 filter.priority = res->priority_value;
7914 bytes_ptr = res->bytes_value;
7915 mask_ptr = res->mask_value;
7918 /* translate bytes string to uint_32 array. */
7919 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7920 (bytes_ptr[1] == 'X')))
7922 len = strnlen(bytes_ptr, res->len_value * 2);
7923 if (len == 0 || (len % 8 != 0)) {
7924 printf("please check len and bytes input\n");
7927 for (i = 0; i < len; i++) {
7929 if (isxdigit(c) == 0) {
7930 /* invalid characters. */
7931 printf("invalid input\n");
7934 val = xdigit2val(c);
7938 dword |= byte << (4 * mod - 4);
7943 filter.dwords[j] = dword;
7944 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7950 /* translate mask string to uint8_t array. */
7952 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7953 (mask_ptr[1] == 'X')))
7955 len = strnlen(mask_ptr, (res->len_value+3)/4);
7957 printf("invalid input\n");
7960 for (i = 0; i < len; i++) {
7962 if (isxdigit(c) == 0) {
7963 /* invalid characters. */
7964 printf("invalid input\n");
7967 val = xdigit2val(c);
7968 hex |= (uint8_t)(val & 0x8) >> 3;
7969 hex |= (uint8_t)(val & 0x4) >> 1;
7970 hex |= (uint8_t)(val & 0x2) << 1;
7971 hex |= (uint8_t)(val & 0x1) << 3;
7974 filter.mask[j] = byte;
7975 printf("mask[%d]:%02x ", j, filter.mask[j]);
7983 printf("call function rte_eth_dev_add_flex_filter: "
7984 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7985 res->index_value, res->queue_id,
7986 filter.len, filter.priority);
7987 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7988 &filter, res->queue_id);
7990 } else if (!strcmp(res->filter, "remove_flex_filter"))
7991 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7993 else if (!strcmp(res->filter, "get_flex_filter"))
7994 get_flex_filter(res->port_id, res->index_value);
7997 printf("flex filter setting error: (%s)\n", strerror(-ret));
8000 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8001 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8003 cmdline_parse_token_string_t cmd_flex_filter_len =
8004 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8006 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8007 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8009 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8010 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8012 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8013 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8015 cmdline_parse_token_string_t cmd_flex_filter_mask =
8016 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8018 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8019 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8021 cmdline_parse_token_string_t cmd_flex_filter_priority =
8022 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8023 priority, "priority");
8024 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8025 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8026 priority_value, UINT8);
8027 cmdline_parse_token_string_t cmd_flex_filter_queue =
8028 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8030 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8031 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8033 cmdline_parse_token_string_t cmd_flex_filter_index =
8034 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8036 cmdline_parse_token_num_t cmd_flex_filter_index_value =
8037 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8038 index_value, UINT16);
8039 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
8040 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8041 filter, "add_flex_filter");
8042 cmdline_parse_inst_t cmd_add_flex_filter = {
8043 .f = cmd_flex_filter_parsed,
8045 .help_str = "add a flex filter",
8047 (void *)&cmd_flex_filter_add_filter,
8048 (void *)&cmd_flex_filter_port_id,
8049 (void *)&cmd_flex_filter_len,
8050 (void *)&cmd_flex_filter_len_value,
8051 (void *)&cmd_flex_filter_bytes,
8052 (void *)&cmd_flex_filter_bytes_value,
8053 (void *)&cmd_flex_filter_mask,
8054 (void *)&cmd_flex_filter_mask_value,
8055 (void *)&cmd_flex_filter_priority,
8056 (void *)&cmd_flex_filter_priority_value,
8057 (void *)&cmd_flex_filter_queue,
8058 (void *)&cmd_flex_filter_queue_id,
8059 (void *)&cmd_flex_filter_index,
8060 (void *)&cmd_flex_filter_index_value,
8065 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
8066 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8067 filter, "remove_flex_filter");
8068 cmdline_parse_inst_t cmd_remove_flex_filter = {
8069 .f = cmd_flex_filter_parsed,
8071 .help_str = "remove a flex filter",
8073 (void *)&cmd_flex_filter_remove_filter,
8074 (void *)&cmd_flex_filter_port_id,
8075 (void *)&cmd_flex_filter_index,
8076 (void *)&cmd_flex_filter_index_value,
8081 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
8082 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8083 filter, "get_flex_filter");
8084 cmdline_parse_inst_t cmd_get_flex_filter = {
8085 .f = cmd_flex_filter_parsed,
8087 .help_str = "get a flex filter",
8089 (void *)&cmd_flex_filter_get_filter,
8090 (void *)&cmd_flex_filter_port_id,
8091 (void *)&cmd_flex_filter_index,
8092 (void *)&cmd_flex_filter_index_value,
8097 /* *** Filters Control *** */
8099 /* *** deal with flow director filter *** */
8100 struct cmd_flow_director_result {
8101 cmdline_fixed_string_t flow_director_filter;
8103 cmdline_fixed_string_t ops;
8104 cmdline_fixed_string_t flow;
8105 cmdline_fixed_string_t flow_type;
8106 cmdline_fixed_string_t src;
8107 cmdline_ipaddr_t ip_src;
8109 cmdline_fixed_string_t dst;
8110 cmdline_ipaddr_t ip_dst;
8112 cmdline_fixed_string_t verify_tag;
8113 uint32_t verify_tag_value;
8114 cmdline_fixed_string_t flexbytes;
8115 cmdline_fixed_string_t flexbytes_value;
8116 cmdline_fixed_string_t drop;
8117 cmdline_fixed_string_t queue;
8119 cmdline_fixed_string_t fd_id;
8120 uint32_t fd_id_value;
8124 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8127 const char *p, *p0 = q_arg;
8129 unsigned long int_fld;
8130 char *str_fld[max_num];
8135 p = strchr(p0, '(');
8139 p0 = strchr(p, ')');
8144 if (size >= sizeof(s))
8147 snprintf(s, sizeof(s), "%.*s", size, p);
8148 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8149 if (ret < 0 || ret > max_num)
8151 for (i = 0; i < ret; i++) {
8153 int_fld = strtoul(str_fld[i], &end, 0);
8154 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8156 flexbytes[i] = (uint8_t)int_fld;
8161 static enum rte_eth_flow_type
8162 str2flowtype(char *string)
8165 static const struct {
8167 enum rte_eth_flow_type type;
8168 } flowtype_str[] = {
8169 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8170 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8171 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8172 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8173 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8174 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8175 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8176 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8177 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8178 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8181 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8182 if (!strcmp(flowtype_str[i].str, string))
8183 return flowtype_str[i].type;
8185 return RTE_ETH_FLOW_TYPE_NONE;
8188 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8190 if ((ip_addr).family == AF_INET) \
8191 (ip) = (ip_addr).addr.ipv4.s_addr; \
8193 printf("invalid parameter.\n"); \
8198 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8200 if ((ip_addr).family == AF_INET6) \
8201 (void)rte_memcpy(&(ip), \
8202 &((ip_addr).addr.ipv6), \
8203 sizeof(struct in6_addr)); \
8205 printf("invalid parameter.\n"); \
8211 cmd_flow_director_filter_parsed(void *parsed_result,
8212 __attribute__((unused)) struct cmdline *cl,
8213 __attribute__((unused)) void *data)
8215 struct cmd_flow_director_result *res = parsed_result;
8216 struct rte_eth_fdir_filter entry;
8217 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8220 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8222 printf("flow director is not supported on port %u.\n",
8226 memset(flexbytes, 0, sizeof(flexbytes));
8227 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8228 ret = parse_flexbytes(res->flexbytes_value,
8230 RTE_ETH_FDIR_MAX_FLEXLEN);
8232 printf("error: Cannot parse flexbytes input.\n");
8236 entry.input.flow_type = str2flowtype(res->flow_type);
8237 switch (entry.input.flow_type) {
8238 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
8239 case RTE_ETH_FLOW_TYPE_UDPV4:
8240 case RTE_ETH_FLOW_TYPE_TCPV4:
8241 IPV4_ADDR_TO_UINT(res->ip_dst,
8242 entry.input.flow.ip4_flow.dst_ip);
8243 IPV4_ADDR_TO_UINT(res->ip_src,
8244 entry.input.flow.ip4_flow.src_ip);
8245 /* need convert to big endian. */
8246 entry.input.flow.udp4_flow.dst_port =
8247 rte_cpu_to_be_16(res->port_dst);
8248 entry.input.flow.udp4_flow.src_port =
8249 rte_cpu_to_be_16(res->port_src);
8251 case RTE_ETH_FLOW_TYPE_SCTPV4:
8252 IPV4_ADDR_TO_UINT(res->ip_dst,
8253 entry.input.flow.sctp4_flow.ip.dst_ip);
8254 IPV4_ADDR_TO_UINT(res->ip_src,
8255 entry.input.flow.sctp4_flow.ip.src_ip);
8256 /* need convert to big endian. */
8257 entry.input.flow.sctp4_flow.verify_tag =
8258 rte_cpu_to_be_32(res->verify_tag_value);
8260 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
8261 case RTE_ETH_FLOW_TYPE_UDPV6:
8262 case RTE_ETH_FLOW_TYPE_TCPV6:
8263 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8264 entry.input.flow.ip6_flow.dst_ip);
8265 IPV6_ADDR_TO_ARRAY(res->ip_src,
8266 entry.input.flow.ip6_flow.src_ip);
8267 /* need convert to big endian. */
8268 entry.input.flow.udp6_flow.dst_port =
8269 rte_cpu_to_be_16(res->port_dst);
8270 entry.input.flow.udp6_flow.src_port =
8271 rte_cpu_to_be_16(res->port_src);
8273 case RTE_ETH_FLOW_TYPE_SCTPV6:
8274 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8275 entry.input.flow.sctp6_flow.ip.dst_ip);
8276 IPV6_ADDR_TO_ARRAY(res->ip_src,
8277 entry.input.flow.sctp6_flow.ip.src_ip);
8278 /* need convert to big endian. */
8279 entry.input.flow.sctp6_flow.verify_tag =
8280 rte_cpu_to_be_32(res->verify_tag_value);
8283 printf("invalid parameter.\n");
8286 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8288 RTE_ETH_FDIR_MAX_FLEXLEN);
8290 entry.action.flex_off = 0; /*use 0 by default */
8291 if (!strcmp(res->drop, "drop"))
8292 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8294 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8295 /* set to report FD ID by default */
8296 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8297 entry.action.rx_queue = res->queue_id;
8298 entry.soft_id = res->fd_id_value;
8299 if (!strcmp(res->ops, "add"))
8300 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8301 RTE_ETH_FILTER_ADD, &entry);
8303 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8304 RTE_ETH_FILTER_DELETE, &entry);
8306 printf("flow director programming error: (%s)\n",
8310 cmdline_parse_token_string_t cmd_flow_director_filter =
8311 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8312 flow_director_filter, "flow_director_filter");
8313 cmdline_parse_token_num_t cmd_flow_director_port_id =
8314 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8316 cmdline_parse_token_string_t cmd_flow_director_ops =
8317 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8319 cmdline_parse_token_string_t cmd_flow_director_flow =
8320 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8322 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8323 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8325 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8326 "ip6#ip6-frag#tcp6#udp6#sctp6");
8327 cmdline_parse_token_string_t cmd_flow_director_src =
8328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8330 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8331 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8333 cmdline_parse_token_num_t cmd_flow_director_port_src =
8334 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8336 cmdline_parse_token_string_t cmd_flow_director_dst =
8337 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8339 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8340 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8342 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8343 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8345 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8346 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8347 verify_tag, "verify_tag");
8348 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8349 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8350 verify_tag_value, UINT32);
8351 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8353 flexbytes, "flexbytes");
8354 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8355 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8356 flexbytes_value, NULL);
8357 cmdline_parse_token_string_t cmd_flow_director_drop =
8358 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8360 cmdline_parse_token_string_t cmd_flow_director_queue =
8361 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8363 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8364 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8366 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8369 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8370 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8371 fd_id_value, UINT32);
8373 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8374 .f = cmd_flow_director_filter_parsed,
8376 .help_str = "add or delete an ip flow director entry on NIC",
8378 (void *)&cmd_flow_director_filter,
8379 (void *)&cmd_flow_director_port_id,
8380 (void *)&cmd_flow_director_ops,
8381 (void *)&cmd_flow_director_flow,
8382 (void *)&cmd_flow_director_flow_type,
8383 (void *)&cmd_flow_director_src,
8384 (void *)&cmd_flow_director_ip_src,
8385 (void *)&cmd_flow_director_dst,
8386 (void *)&cmd_flow_director_ip_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_udp_flow_director = {
8399 .f = cmd_flow_director_filter_parsed,
8401 .help_str = "add or delete an udp/tcp 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_port_src,
8411 (void *)&cmd_flow_director_dst,
8412 (void *)&cmd_flow_director_ip_dst,
8413 (void *)&cmd_flow_director_port_dst,
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 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8426 .f = cmd_flow_director_filter_parsed,
8428 .help_str = "add or delete a sctp flow director entry on NIC",
8430 (void *)&cmd_flow_director_filter,
8431 (void *)&cmd_flow_director_port_id,
8432 (void *)&cmd_flow_director_ops,
8433 (void *)&cmd_flow_director_flow,
8434 (void *)&cmd_flow_director_flow_type,
8435 (void *)&cmd_flow_director_src,
8436 (void *)&cmd_flow_director_ip_src,
8437 (void *)&cmd_flow_director_dst,
8438 (void *)&cmd_flow_director_ip_dst,
8439 (void *)&cmd_flow_director_verify_tag,
8440 (void *)&cmd_flow_director_verify_tag_value,
8441 (void *)&cmd_flow_director_flexbytes,
8442 (void *)&cmd_flow_director_flexbytes_value,
8443 (void *)&cmd_flow_director_drop,
8444 (void *)&cmd_flow_director_queue,
8445 (void *)&cmd_flow_director_queue_id,
8446 (void *)&cmd_flow_director_fd_id,
8447 (void *)&cmd_flow_director_fd_id_value,
8452 struct cmd_flush_flow_director_result {
8453 cmdline_fixed_string_t flush_flow_director;
8457 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8458 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8459 flush_flow_director, "flush_flow_director");
8460 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8461 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8465 cmd_flush_flow_director_parsed(void *parsed_result,
8466 __attribute__((unused)) struct cmdline *cl,
8467 __attribute__((unused)) void *data)
8469 struct cmd_flow_director_result *res = parsed_result;
8472 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8474 printf("flow director is not supported on port %u.\n",
8479 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8480 RTE_ETH_FILTER_FLUSH, NULL);
8482 printf("flow director table flushing error: (%s)\n",
8486 cmdline_parse_inst_t cmd_flush_flow_director = {
8487 .f = cmd_flush_flow_director_parsed,
8489 .help_str = "flush all flow director entries of a device on NIC",
8491 (void *)&cmd_flush_flow_director_flush,
8492 (void *)&cmd_flush_flow_director_port_id,
8497 /* *** deal with flow director mask on flexible payload *** */
8498 struct cmd_flow_director_flex_mask_result {
8499 cmdline_fixed_string_t flow_director_flexmask;
8501 cmdline_fixed_string_t flow;
8502 cmdline_fixed_string_t flow_type;
8503 cmdline_fixed_string_t mask;
8507 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8508 __attribute__((unused)) struct cmdline *cl,
8509 __attribute__((unused)) void *data)
8511 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8512 struct rte_eth_fdir_flex_mask flex_mask;
8513 struct rte_port *port;
8514 enum rte_eth_flow_type i;
8517 if (res->port_id > nb_ports) {
8518 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8522 port = &ports[res->port_id];
8523 /** Check if the port is not started **/
8524 if (port->port_status != RTE_PORT_STOPPED) {
8525 printf("Please stop port %d first\n", res->port_id);
8529 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8530 ret = parse_flexbytes(res->mask,
8532 RTE_ETH_FDIR_MAX_FLEXLEN);
8534 printf("error: Cannot parse mask input.\n");
8537 if (!strcmp(res->flow_type, "all")) {
8538 for (i = RTE_ETH_FLOW_TYPE_UDPV4;
8539 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8541 flex_mask.flow_type = i;
8542 fdir_set_flex_mask(res->port_id, &flex_mask);
8544 cmd_reconfig_device_queue(res->port_id, 1, 0);
8547 flex_mask.flow_type = str2flowtype(res->flow_type);
8548 fdir_set_flex_mask(res->port_id, &flex_mask);
8549 cmd_reconfig_device_queue(res->port_id, 1, 1);
8552 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8553 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8554 flow_director_flexmask,
8555 "flow_director_flex_mask");
8556 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8557 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8559 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8560 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8562 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8565 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8566 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8567 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8568 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8571 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8572 .f = cmd_flow_director_flex_mask_parsed,
8574 .help_str = "set flow director's flex mask on NIC",
8576 (void *)&cmd_flow_director_flexmask,
8577 (void *)&cmd_flow_director_flexmask_port_id,
8578 (void *)&cmd_flow_director_flexmask_flow,
8579 (void *)&cmd_flow_director_flexmask_flow_type,
8580 (void *)&cmd_flow_director_flexmask_mask,
8585 /* *** deal with flow director flexible payload configuration *** */
8586 struct cmd_flow_director_flexpayload_result {
8587 cmdline_fixed_string_t flow_director_flexpayload;
8589 cmdline_fixed_string_t payload_layer;
8590 cmdline_fixed_string_t payload_cfg;
8594 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8597 const char *p, *p0 = q_arg;
8599 unsigned long int_fld;
8600 char *str_fld[max_num];
8605 p = strchr(p0, '(');
8609 p0 = strchr(p, ')');
8614 if (size >= sizeof(s))
8617 snprintf(s, sizeof(s), "%.*s", size, p);
8618 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8619 if (ret < 0 || ret > max_num)
8621 for (i = 0; i < ret; i++) {
8623 int_fld = strtoul(str_fld[i], &end, 0);
8624 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8626 offsets[i] = (uint16_t)int_fld;
8632 cmd_flow_director_flxpld_parsed(void *parsed_result,
8633 __attribute__((unused)) struct cmdline *cl,
8634 __attribute__((unused)) void *data)
8636 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8637 struct rte_eth_flex_payload_cfg flex_cfg;
8638 struct rte_port *port;
8641 if (res->port_id > nb_ports) {
8642 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8646 port = &ports[res->port_id];
8647 /** Check if the port is not started **/
8648 if (port->port_status != RTE_PORT_STOPPED) {
8649 printf("Please stop port %d first\n", res->port_id);
8653 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8655 if (!strcmp(res->payload_layer, "l2"))
8656 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8657 else if (!strcmp(res->payload_layer, "l3"))
8658 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8659 else if (!strcmp(res->payload_layer, "l4"))
8660 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8662 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8663 RTE_ETH_FDIR_MAX_FLEXLEN);
8665 printf("error: Cannot parse flex payload input.\n");
8669 fdir_set_flex_payload(res->port_id, &flex_cfg);
8670 cmd_reconfig_device_queue(res->port_id, 1, 1);
8673 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8674 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8675 flow_director_flexpayload,
8676 "flow_director_flex_payload");
8677 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8678 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8680 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8681 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8682 payload_layer, "l2#l3#l4");
8683 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8687 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8688 .f = cmd_flow_director_flxpld_parsed,
8690 .help_str = "set flow director's flex payload on NIC",
8692 (void *)&cmd_flow_director_flexpayload,
8693 (void *)&cmd_flow_director_flexpayload_port_id,
8694 (void *)&cmd_flow_director_flexpayload_payload_layer,
8695 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8700 /* ******************************************************************************** */
8702 /* list of instructions */
8703 cmdline_parse_ctx_t main_ctx[] = {
8704 (cmdline_parse_inst_t *)&cmd_help_brief,
8705 (cmdline_parse_inst_t *)&cmd_help_long,
8706 (cmdline_parse_inst_t *)&cmd_quit,
8707 (cmdline_parse_inst_t *)&cmd_showport,
8708 (cmdline_parse_inst_t *)&cmd_showportall,
8709 (cmdline_parse_inst_t *)&cmd_showcfg,
8710 (cmdline_parse_inst_t *)&cmd_start,
8711 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8712 (cmdline_parse_inst_t *)&cmd_set_link_up,
8713 (cmdline_parse_inst_t *)&cmd_set_link_down,
8714 (cmdline_parse_inst_t *)&cmd_reset,
8715 (cmdline_parse_inst_t *)&cmd_set_numbers,
8716 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8717 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8718 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8719 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8720 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8721 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8722 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8723 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8724 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8725 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8726 (cmdline_parse_inst_t *)&cmd_set_link_check,
8727 #ifdef RTE_NIC_BYPASS
8728 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8729 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8730 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8731 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8733 #ifdef RTE_LIBRTE_PMD_BOND
8734 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8735 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8736 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8737 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8738 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8739 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8740 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8741 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8742 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8744 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8745 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8746 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8747 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8748 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8749 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8750 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8751 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
8752 (cmdline_parse_inst_t *)&cmd_tx_cksum_show,
8753 (cmdline_parse_inst_t *)&cmd_tso_set,
8754 (cmdline_parse_inst_t *)&cmd_tso_show,
8755 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8756 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8757 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8758 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8759 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8760 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8761 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8762 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8763 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8764 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8765 (cmdline_parse_inst_t *)&cmd_config_dcb,
8766 (cmdline_parse_inst_t *)&cmd_read_reg,
8767 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8768 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8769 (cmdline_parse_inst_t *)&cmd_write_reg,
8770 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8771 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8772 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8773 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
8774 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
8775 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
8776 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
8777 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
8778 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
8779 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
8780 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
8781 (cmdline_parse_inst_t *)&cmd_stop,
8782 (cmdline_parse_inst_t *)&cmd_mac_addr,
8783 (cmdline_parse_inst_t *)&cmd_set_qmap,
8784 (cmdline_parse_inst_t *)&cmd_operate_port,
8785 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8786 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8787 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8788 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8789 (cmdline_parse_inst_t *)&cmd_config_mtu,
8790 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8791 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8792 (cmdline_parse_inst_t *)&cmd_config_rss,
8793 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8794 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8795 (cmdline_parse_inst_t *)&cmd_showport_reta,
8796 (cmdline_parse_inst_t *)&cmd_config_burst,
8797 (cmdline_parse_inst_t *)&cmd_config_thresh,
8798 (cmdline_parse_inst_t *)&cmd_config_threshold,
8799 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8800 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8801 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8802 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8803 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8804 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8805 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8806 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8807 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8808 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8809 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8810 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8811 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8812 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8813 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8814 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8815 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8816 (cmdline_parse_inst_t *)&cmd_dump,
8817 (cmdline_parse_inst_t *)&cmd_dump_one,
8818 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
8819 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
8820 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
8821 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
8822 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
8823 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
8824 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
8825 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
8826 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
8827 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
8828 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
8829 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
8830 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
8831 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
8832 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
8833 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8834 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8835 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8836 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8837 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8838 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
8842 /* prompt function, called from main on MASTER lcore */
8848 /* initialize non-constant commands */
8849 cmd_set_fwd_mode_init();
8851 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8855 cmdline_interact(cl);
8856 cmdline_stdin_exit(cl);
8860 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8862 if (id < nb_ports) {
8863 /* check if need_reconfig has been set to 1 */
8864 if (ports[id].need_reconfig == 0)
8865 ports[id].need_reconfig = dev;
8866 /* check if need_reconfig_queues has been set to 1 */
8867 if (ports[id].need_reconfig_queues == 0)
8868 ports[id].need_reconfig_queues = queue;
8872 for (pid = 0; pid < nb_ports; pid++) {
8873 /* check if need_reconfig has been set to 1 */
8874 if (ports[pid].need_reconfig == 0)
8875 ports[pid].need_reconfig = dev;
8876 /* check if need_reconfig_queues has been set to 1 */
8877 if (ports[pid].need_reconfig_queues == 0)
8878 ports[pid].need_reconfig_queues = queue;
8883 #ifdef RTE_NIC_BYPASS
8885 bypass_is_supported(portid_t port_id)
8887 struct rte_port *port;
8888 struct rte_pci_id *pci_id;
8890 if (port_id >= nb_ports) {
8891 printf("\tPort id must be less than %d.\n", nb_ports);
8895 /* Get the device id. */
8896 port = &ports[port_id];
8897 pci_id = &port->dev_info.pci_dev->id;
8899 /* Check if NIC supports bypass. */
8900 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8904 printf("\tBypass not supported for port_id = %d.\n", port_id);