4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_malloc.h>
63 #include <rte_launch.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
77 #include <rte_eth_ctrl.h>
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 #ifdef RTE_LIBRTE_PMD_BOND
88 #include <rte_eth_bond.h>
93 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
96 uint8_t bypass_is_supported(portid_t port_id);
99 /* *** Help command with introduction. *** */
100 struct cmd_help_brief_result {
101 cmdline_fixed_string_t help;
104 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
106 __attribute__((unused)) void *data)
111 "Help is available for the following sections:\n\n"
112 " help control : Start and stop forwarding.\n"
113 " help display : Displaying port, stats and config "
115 " help config : Configuration information.\n"
116 " help ports : Configuring ports.\n"
117 " help registers : Reading and setting port registers.\n"
118 " help filters : Filters configuration help.\n"
119 " help all : All of the above sections.\n\n"
124 cmdline_parse_token_string_t cmd_help_brief_help =
125 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
127 cmdline_parse_inst_t cmd_help_brief = {
128 .f = cmd_help_brief_parsed,
130 .help_str = "show help",
132 (void *)&cmd_help_brief_help,
137 /* *** Help command with help sections. *** */
138 struct cmd_help_long_result {
139 cmdline_fixed_string_t help;
140 cmdline_fixed_string_t section;
143 static void cmd_help_long_parsed(void *parsed_result,
145 __attribute__((unused)) void *data)
148 struct cmd_help_long_result *res = parsed_result;
150 if (!strcmp(res->section, "all"))
153 if (show_all || !strcmp(res->section, "control")) {
158 "Control forwarding:\n"
159 "-------------------\n\n"
162 " Start packet forwarding with current configuration.\n\n"
165 " Start packet forwarding with current config"
166 " after sending one burst of packets.\n\n"
169 " Stop packet forwarding, and display accumulated"
173 " Quit to prompt.\n\n"
177 if (show_all || !strcmp(res->section, "display")) {
185 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
186 " Display information for port_id, or all.\n\n"
188 "show port X rss reta (size) (mask0,mask1,...)\n"
189 " Display the rss redirection table entry indicated"
190 " by masks on port X. size is used to indicate the"
191 " hardware supported reta size\n\n"
193 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
194 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
195 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [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) (vxlan|nvgre) (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) (vxlan|nvgre) (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 (port_id) vlan_id[, vlan_id_outer]\n"
309 " Set hardware insertion of VLAN IDs (single or double VLAN "
310 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
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 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
320 " Select hardware or software calculation of the"
321 " checksum when transmitting a packet using the"
322 " csum forward engine.\n"
323 " ip|udp|tcp|sctp always concern the inner layer.\n"
324 " outer-ip concerns the outer IP layer in"
325 " case the packet is recognized as a tunnel packet by"
326 " the forward engine (vxlan, gre and ipip are supported)\n"
327 " Please check the NIC datasheet for HW limits.\n\n"
329 "csum parse-tunnel (on|off) (tx_port_id)\n"
330 " If disabled, treat tunnel packets as non-tunneled"
331 " packets (treat inner headers as payload). The port\n"
332 " argument is the port used for TX in csum forward"
335 "csum show (port_id)\n"
336 " Display tx checksum offload configuration\n\n"
338 "tso set (segsize) (portid)\n"
339 " Enable TCP Segmentation Offload in csum forward"
341 " Please check the NIC datasheet for HW limits.\n\n"
344 " Display the status of TCP Segmentation Offload.\n\n"
347 " Set packet forwarding mode.\n\n"
349 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
350 " Add a MAC address on port_id.\n\n"
352 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
353 " Remove a MAC address from port_id.\n\n"
355 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
356 " Add a MAC address for a VF on the port.\n\n"
358 "set port (port_id) uta (mac_address|all) (on|off)\n"
359 " Add/Remove a or all unicast hash filter(s)"
362 "set promisc (port_id|all) (on|off)\n"
363 " Set the promiscuous mode on port_id, or all.\n\n"
365 "set allmulti (port_id|all) (on|off)\n"
366 " Set the allmulti mode on port_id, or all.\n\n"
368 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
369 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
370 " (on|off) autoneg (on|off) (port_id)\n"
371 "set flow_ctrl rx (on|off) (portid)\n"
372 "set flow_ctrl tx (on|off) (portid)\n"
373 "set flow_ctrl high_water (high_water) (portid)\n"
374 "set flow_ctrl low_water (low_water) (portid)\n"
375 "set flow_ctrl pause_time (pause_time) (portid)\n"
376 "set flow_ctrl send_xon (send_xon) (portid)\n"
377 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
378 "set flow_ctrl autoneg (on|off) (port_id)\n"
379 " Set the link flow control parameter on a port.\n\n"
381 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
382 " (low_water) (pause_time) (priority) (port_id)\n"
383 " Set the priority flow control parameter on a"
386 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
387 " Set statistics mapping (qmapping 0..15) for RX/TX"
389 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
390 " on port 0 to mapping 5.\n\n"
392 "set port (port_id) vf (vf_id) rx|tx on|off\n"
393 " Enable/Disable a VF receive/tranmit from a port\n\n"
395 "set port (port_id) vf (vf_id) (mac_addr)"
396 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
397 " Add/Remove unicast or multicast MAC addr filter"
400 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
402 " AUPE:accepts untagged VLAN;"
403 "ROPE:accept unicast hash\n\n"
404 " BAM:accepts broadcast packets;"
405 "MPE:accepts all multicast packets\n\n"
406 " Enable/Disable a VF receive mode of a port\n\n"
408 "set port (port_id) queue (queue_id) rate (rate_num)\n"
409 " Set rate limit for a queue of a port\n\n"
411 "set port (port_id) vf (vf_id) rate (rate_num) "
412 "queue_mask (queue_mask_value)\n"
413 " Set rate limit for queues in VF of a port\n\n"
415 "set port (port_id) mirror-rule (rule_id)"
416 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
417 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
418 " Set pool or vlan type mirror rule on a port.\n"
419 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
420 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
423 "set port (port_id) mirror-rule (rule_id)"
424 " (uplink-mirror|downlink-mirror) dst-pool"
425 " (pool_id) (on|off)\n"
426 " Set uplink or downlink type mirror rule on a port.\n"
427 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
428 " 0 on' enable mirror income traffic to pool 0.\n\n"
430 "reset port (port_id) mirror-rule (rule_id)\n"
431 " Reset a mirror rule.\n\n"
433 "set flush_rx (on|off)\n"
434 " Flush (default) or don't flush RX streams before"
435 " forwarding. Mainly used with PCAP drivers.\n\n"
437 #ifdef RTE_NIC_BYPASS
438 "set bypass mode (normal|bypass|isolate) (port_id)\n"
439 " Set the bypass mode for the lowest port on bypass enabled"
442 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
443 "mode (normal|bypass|isolate) (port_id)\n"
444 " Set the event required to initiate specified bypass mode for"
445 " the lowest port on a bypass enabled NIC where:\n"
446 " timeout = enable bypass after watchdog timeout.\n"
447 " os_on = enable bypass when OS/board is powered on.\n"
448 " os_off = enable bypass when OS/board is powered off.\n"
449 " power_on = enable bypass when power supply is turned on.\n"
450 " power_off = enable bypass when power supply is turned off."
453 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
454 " Set the bypass watchdog timeout to 'n' seconds"
455 " where 0 = instant.\n\n"
457 "show bypass config (port_id)\n"
458 " Show the bypass configuration for a bypass enabled NIC"
459 " using the lowest port on the NIC.\n\n"
461 #ifdef RTE_LIBRTE_PMD_BOND
462 "create bonded device (mode) (socket)\n"
463 " Create a new bonded device with specific bonding mode and socket.\n\n"
465 "add bonding slave (slave_id) (port_id)\n"
466 " Add a slave device to a bonded device.\n\n"
468 "remove bonding slave (slave_id) (port_id)\n"
469 " Remove a slave device from a bonded device.\n\n"
471 "set bonding mode (value) (port_id)\n"
472 " Set the bonding mode on a bonded device.\n\n"
474 "set bonding primary (slave_id) (port_id)\n"
475 " Set the primary slave for a bonded device.\n\n"
477 "show bonding config (port_id)\n"
478 " Show the bonding config for port_id.\n\n"
480 "set bonding mac_addr (port_id) (address)\n"
481 " Set the MAC address of a bonded device.\n\n"
483 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
484 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
486 "set bonding mon_period (port_id) (value)\n"
487 " Set the bonding link status monitoring polling period in ms.\n\n"
489 "set link-up port (port_id)\n"
490 " Set link up for a port.\n\n"
492 "set link-down port (port_id)\n"
493 " Set link down for a port.\n\n"
495 , list_pkt_forwarding_modes()
499 if (show_all || !strcmp(res->section, "ports")) {
505 "----------------\n\n"
507 "port start (port_id|all)\n"
508 " Start all ports or port_id.\n\n"
510 "port stop (port_id|all)\n"
511 " Stop all ports or port_id.\n\n"
513 "port close (port_id|all)\n"
514 " Close all ports or port_id.\n\n"
516 "port attach (ident)\n"
517 " Attach physical or virtual dev by pci address or virtual device name\n\n"
519 "port detach (port_id)\n"
520 " Detach physical or virtual dev by port_id\n\n"
522 "port config (port_id|all)"
523 " speed (10|100|1000|10000|40000|auto)"
524 " duplex (half|full|auto)\n"
525 " Set speed and duplex for all ports or port_id\n\n"
527 "port config all (rxq|txq|rxd|txd) (value)\n"
528 " Set number for rxq/txq/rxd/txd.\n\n"
530 "port config all max-pkt-len (value)\n"
531 " Set the max packet length.\n\n"
533 "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
534 "hw-vlan-strip|hw-vlan-extend|drop-en)"
536 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
539 "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
540 " Set the RSS mode.\n\n"
542 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
543 " Set the RSS redirection table.\n\n"
545 "port config (port_id) dcb vt (on|off) (traffic_class)"
547 " Set the DCB mode.\n\n"
549 "port config all burst (value)\n"
550 " Set the number of packets per burst.\n\n"
552 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
554 " Set the ring prefetch/host/writeback threshold"
555 " for tx/rx queue.\n\n"
557 "port config all (txfreet|txrst|rxfreet) (value)\n"
558 " Set free threshold for rx/tx, or set"
559 " tx rs bit threshold.\n\n"
560 "port config mtu X value\n"
561 " Set the MTU of port X to a given value\n\n"
563 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
564 " Start/stop a rx/tx queue of port X. Only take effect"
565 " when port X is started\n"
569 if (show_all || !strcmp(res->section, "registers")) {
577 "read reg (port_id) (address)\n"
578 " Display value of a port register.\n\n"
580 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
581 " Display a port register bit field.\n\n"
583 "read regbit (port_id) (address) (bit_x)\n"
584 " Display a single port register bit.\n\n"
586 "write reg (port_id) (address) (value)\n"
587 " Set value of a port register.\n\n"
589 "write regfield (port_id) (address) (bit_x) (bit_y)"
591 " Set bit field of a port register.\n\n"
593 "write regbit (port_id) (address) (bit_x) (value)\n"
594 " Set single bit value of a port register.\n\n"
597 if (show_all || !strcmp(res->section, "filters")) {
605 "ethertype_filter (port_id) (add|del)"
606 " (mac_addr|mac_ignr) (mac_address) ethertype"
607 " (ether_type) (drop|fwd) queue (queue_id)\n"
608 " Add/Del an ethertype filter.\n\n"
610 "2tuple_filter (port_id) (add|del)"
611 " dst_port (dst_port_value) protocol (protocol_value)"
612 " mask (mask_value) tcp_flags (tcp_flags_value)"
613 " priority (prio_value) queue (queue_id)\n"
614 " Add/Del a 2tuple filter.\n\n"
616 "5tuple_filter (port_id) (add|del)"
617 " dst_ip (dst_address) src_ip (src_address)"
618 " dst_port (dst_port_value) src_port (src_port_value)"
619 " protocol (protocol_value)"
620 " mask (mask_value) tcp_flags (tcp_flags_value)"
621 " priority (prio_value) queue (queue_id)\n"
622 " Add/Del a 5tuple filter.\n\n"
624 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
625 " Add/Del syn filter.\n\n"
627 "flex_filter (port_id) (add|del) len (len_value)"
628 " bytes (bytes_value) mask (mask_value)"
629 " priority (prio_value) queue (queue_id)\n"
630 " Add/Del a flex filter.\n\n"
632 "flow_director_filter (port_id) (add|del|update)"
633 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
634 " src (src_ip_address) dst (dst_ip_address)"
635 " vlan (vlan_value) flexbytes (flexbytes_value)"
636 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
637 " fd_id (fd_id_value)\n"
638 " Add/Del an IP type flow director filter.\n\n"
640 "flow_director_filter (port_id) (add|del|update)"
641 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
642 " src (src_ip_address) (src_port)"
643 " dst (dst_ip_address) (dst_port)"
644 " vlan (vlan_value) flexbytes (flexbytes_value)"
645 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
646 " fd_id (fd_id_value)\n"
647 " Add/Del an UDP/TCP type flow director filter.\n\n"
649 "flow_director_filter (port_id) (add|del|update)"
650 " flow (ipv4-sctp|ipv6-sctp)"
651 " src (src_ip_address) (src_port)"
652 " dst (dst_ip_address) (dst_port)"
653 " tag (verification_tag) vlan (vlan_value)"
654 " flexbytes (flexbytes_value) (drop|fwd)"
655 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
656 " Add/Del a SCTP type flow director filter.\n\n"
658 "flow_director_filter (port_id) (add|del|update)"
659 " flow l2_payload ether (ethertype)"
660 " flexbytes (flexbytes_value) (drop|fwd)"
661 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
662 " Add/Del a l2 payload type flow director filter.\n\n"
664 "flush_flow_director (port_id)\n"
665 " Flush all flow director entries of a device.\n\n"
667 "flow_director_mask (port_id) vlan (vlan_value)"
668 " src_mask (ipv4_src) (ipv6_src) (src_port)"
669 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
670 " Set flow director mask.\n\n"
672 "flow_director_flex_mask (port_id)"
673 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
674 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
676 " Configure mask of flex payload.\n\n"
678 "flow_director_flex_payload (port_id)"
679 " (raw|l2|l3|l4) (config)\n"
680 " Configure flex payload selection.\n\n"
682 "get_sym_hash_ena_per_port (port_id)\n"
683 " get symmetric hash enable configuration per port.\n\n"
685 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
686 " set symmetric hash enable configuration per port"
687 " to enable or disable.\n\n"
689 "get_hash_global_config (port_id)\n"
690 " Get the global configurations of hash filters.\n\n"
692 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
693 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
694 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
695 " (enable|disable)\n"
696 " Set the global configurations of hash filters.\n\n"
698 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
699 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
700 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
701 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
702 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
703 "ipv6-next-header|udp-src-port|udp-dst-port|"
704 "tcp-src-port|tcp-dst-port|sctp-src-port|"
705 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
706 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
707 "fld-8th|none) (select|add)\n"
708 " Set the input set for hash.\n\n"
710 "set_fdir_input_set (port_id) (ipv4|ipv4-frag|"
711 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
712 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
713 "l2_payload) (src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
714 "udp-src-port|udp-dst-port|tcp-src-port|tcp-dst-port|"
715 "sctp-src-port|sctp-dst-port|sctp-veri-tag|fld-1st|"
716 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
717 "fld-8th|none) (select|add)\n"
718 " Set the input set for FDir.\n\n"
723 cmdline_parse_token_string_t cmd_help_long_help =
724 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
726 cmdline_parse_token_string_t cmd_help_long_section =
727 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
728 "all#control#display#config#"
729 "ports#registers#filters");
731 cmdline_parse_inst_t cmd_help_long = {
732 .f = cmd_help_long_parsed,
734 .help_str = "show help",
736 (void *)&cmd_help_long_help,
737 (void *)&cmd_help_long_section,
743 /* *** start/stop/close all ports *** */
744 struct cmd_operate_port_result {
745 cmdline_fixed_string_t keyword;
746 cmdline_fixed_string_t name;
747 cmdline_fixed_string_t value;
750 static void cmd_operate_port_parsed(void *parsed_result,
751 __attribute__((unused)) struct cmdline *cl,
752 __attribute__((unused)) void *data)
754 struct cmd_operate_port_result *res = parsed_result;
756 if (!strcmp(res->name, "start"))
757 start_port(RTE_PORT_ALL);
758 else if (!strcmp(res->name, "stop"))
759 stop_port(RTE_PORT_ALL);
760 else if (!strcmp(res->name, "close"))
761 close_port(RTE_PORT_ALL);
763 printf("Unknown parameter\n");
766 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
767 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
769 cmdline_parse_token_string_t cmd_operate_port_all_port =
770 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
772 cmdline_parse_token_string_t cmd_operate_port_all_all =
773 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
775 cmdline_parse_inst_t cmd_operate_port = {
776 .f = cmd_operate_port_parsed,
778 .help_str = "port start|stop|close all: start/stop/close all ports",
780 (void *)&cmd_operate_port_all_cmd,
781 (void *)&cmd_operate_port_all_port,
782 (void *)&cmd_operate_port_all_all,
787 /* *** start/stop/close specific port *** */
788 struct cmd_operate_specific_port_result {
789 cmdline_fixed_string_t keyword;
790 cmdline_fixed_string_t name;
794 static void cmd_operate_specific_port_parsed(void *parsed_result,
795 __attribute__((unused)) struct cmdline *cl,
796 __attribute__((unused)) void *data)
798 struct cmd_operate_specific_port_result *res = parsed_result;
800 if (!strcmp(res->name, "start"))
801 start_port(res->value);
802 else if (!strcmp(res->name, "stop"))
803 stop_port(res->value);
804 else if (!strcmp(res->name, "close"))
805 close_port(res->value);
807 printf("Unknown parameter\n");
810 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
811 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
813 cmdline_parse_token_string_t cmd_operate_specific_port_port =
814 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
815 name, "start#stop#close");
816 cmdline_parse_token_num_t cmd_operate_specific_port_id =
817 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
820 cmdline_parse_inst_t cmd_operate_specific_port = {
821 .f = cmd_operate_specific_port_parsed,
823 .help_str = "port start|stop|close X: start/stop/close port X",
825 (void *)&cmd_operate_specific_port_cmd,
826 (void *)&cmd_operate_specific_port_port,
827 (void *)&cmd_operate_specific_port_id,
832 /* *** attach a specified port *** */
833 struct cmd_operate_attach_port_result {
834 cmdline_fixed_string_t port;
835 cmdline_fixed_string_t keyword;
836 cmdline_fixed_string_t identifier;
839 static void cmd_operate_attach_port_parsed(void *parsed_result,
840 __attribute__((unused)) struct cmdline *cl,
841 __attribute__((unused)) void *data)
843 struct cmd_operate_attach_port_result *res = parsed_result;
845 if (!strcmp(res->keyword, "attach"))
846 attach_port(res->identifier);
848 printf("Unknown parameter\n");
851 cmdline_parse_token_string_t cmd_operate_attach_port_port =
852 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
854 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
855 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
857 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
858 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
861 cmdline_parse_inst_t cmd_operate_attach_port = {
862 .f = cmd_operate_attach_port_parsed,
864 .help_str = "port attach identifier, "
865 "identifier: pci address or virtual dev name",
867 (void *)&cmd_operate_attach_port_port,
868 (void *)&cmd_operate_attach_port_keyword,
869 (void *)&cmd_operate_attach_port_identifier,
874 /* *** detach a specified port *** */
875 struct cmd_operate_detach_port_result {
876 cmdline_fixed_string_t port;
877 cmdline_fixed_string_t keyword;
881 static void cmd_operate_detach_port_parsed(void *parsed_result,
882 __attribute__((unused)) struct cmdline *cl,
883 __attribute__((unused)) void *data)
885 struct cmd_operate_detach_port_result *res = parsed_result;
887 if (!strcmp(res->keyword, "detach"))
888 detach_port(res->port_id);
890 printf("Unknown parameter\n");
893 cmdline_parse_token_string_t cmd_operate_detach_port_port =
894 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
896 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
897 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
899 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
900 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
903 cmdline_parse_inst_t cmd_operate_detach_port = {
904 .f = cmd_operate_detach_port_parsed,
906 .help_str = "port detach port_id",
908 (void *)&cmd_operate_detach_port_port,
909 (void *)&cmd_operate_detach_port_keyword,
910 (void *)&cmd_operate_detach_port_port_id,
915 /* *** configure speed for all ports *** */
916 struct cmd_config_speed_all {
917 cmdline_fixed_string_t port;
918 cmdline_fixed_string_t keyword;
919 cmdline_fixed_string_t all;
920 cmdline_fixed_string_t item1;
921 cmdline_fixed_string_t item2;
922 cmdline_fixed_string_t value1;
923 cmdline_fixed_string_t value2;
927 cmd_config_speed_all_parsed(void *parsed_result,
928 __attribute__((unused)) struct cmdline *cl,
929 __attribute__((unused)) void *data)
931 struct cmd_config_speed_all *res = parsed_result;
932 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
933 uint16_t link_duplex = 0;
936 if (!all_ports_stopped()) {
937 printf("Please stop all ports first\n");
941 if (!strcmp(res->value1, "10"))
942 link_speed = ETH_LINK_SPEED_10;
943 else if (!strcmp(res->value1, "100"))
944 link_speed = ETH_LINK_SPEED_100;
945 else if (!strcmp(res->value1, "1000"))
946 link_speed = ETH_LINK_SPEED_1000;
947 else if (!strcmp(res->value1, "10000"))
948 link_speed = ETH_LINK_SPEED_10G;
949 else if (!strcmp(res->value1, "40000"))
950 link_speed = ETH_LINK_SPEED_40G;
951 else if (!strcmp(res->value1, "auto"))
952 link_speed = ETH_LINK_SPEED_AUTONEG;
954 printf("Unknown parameter\n");
958 if (!strcmp(res->value2, "half"))
959 link_duplex = ETH_LINK_HALF_DUPLEX;
960 else if (!strcmp(res->value2, "full"))
961 link_duplex = ETH_LINK_FULL_DUPLEX;
962 else if (!strcmp(res->value2, "auto"))
963 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
965 printf("Unknown parameter\n");
969 FOREACH_PORT(pid, ports) {
970 ports[pid].dev_conf.link_speed = link_speed;
971 ports[pid].dev_conf.link_duplex = link_duplex;
974 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
977 cmdline_parse_token_string_t cmd_config_speed_all_port =
978 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
979 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
980 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
982 cmdline_parse_token_string_t cmd_config_speed_all_all =
983 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
984 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
985 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
986 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
987 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
988 "10#100#1000#10000#40000#auto");
989 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
990 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
991 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
992 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
995 cmdline_parse_inst_t cmd_config_speed_all = {
996 .f = cmd_config_speed_all_parsed,
998 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
1001 (void *)&cmd_config_speed_all_port,
1002 (void *)&cmd_config_speed_all_keyword,
1003 (void *)&cmd_config_speed_all_all,
1004 (void *)&cmd_config_speed_all_item1,
1005 (void *)&cmd_config_speed_all_value1,
1006 (void *)&cmd_config_speed_all_item2,
1007 (void *)&cmd_config_speed_all_value2,
1012 /* *** configure speed for specific port *** */
1013 struct cmd_config_speed_specific {
1014 cmdline_fixed_string_t port;
1015 cmdline_fixed_string_t keyword;
1017 cmdline_fixed_string_t item1;
1018 cmdline_fixed_string_t item2;
1019 cmdline_fixed_string_t value1;
1020 cmdline_fixed_string_t value2;
1024 cmd_config_speed_specific_parsed(void *parsed_result,
1025 __attribute__((unused)) struct cmdline *cl,
1026 __attribute__((unused)) void *data)
1028 struct cmd_config_speed_specific *res = parsed_result;
1029 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1030 uint16_t link_duplex = 0;
1032 if (!all_ports_stopped()) {
1033 printf("Please stop all ports first\n");
1037 if (port_id_is_invalid(res->id, ENABLED_WARN))
1040 if (!strcmp(res->value1, "10"))
1041 link_speed = ETH_LINK_SPEED_10;
1042 else if (!strcmp(res->value1, "100"))
1043 link_speed = ETH_LINK_SPEED_100;
1044 else if (!strcmp(res->value1, "1000"))
1045 link_speed = ETH_LINK_SPEED_1000;
1046 else if (!strcmp(res->value1, "10000"))
1047 link_speed = ETH_LINK_SPEED_10000;
1048 else if (!strcmp(res->value1, "40000"))
1049 link_speed = ETH_LINK_SPEED_40G;
1050 else if (!strcmp(res->value1, "auto"))
1051 link_speed = ETH_LINK_SPEED_AUTONEG;
1053 printf("Unknown parameter\n");
1057 if (!strcmp(res->value2, "half"))
1058 link_duplex = ETH_LINK_HALF_DUPLEX;
1059 else if (!strcmp(res->value2, "full"))
1060 link_duplex = ETH_LINK_FULL_DUPLEX;
1061 else if (!strcmp(res->value2, "auto"))
1062 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1064 printf("Unknown parameter\n");
1068 ports[res->id].dev_conf.link_speed = link_speed;
1069 ports[res->id].dev_conf.link_duplex = link_duplex;
1071 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1075 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1076 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1078 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1079 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1081 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1082 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1083 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1084 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1086 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1087 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1088 "10#100#1000#10000#40000#auto");
1089 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1090 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1092 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1093 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1096 cmdline_parse_inst_t cmd_config_speed_specific = {
1097 .f = cmd_config_speed_specific_parsed,
1099 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1102 (void *)&cmd_config_speed_specific_port,
1103 (void *)&cmd_config_speed_specific_keyword,
1104 (void *)&cmd_config_speed_specific_id,
1105 (void *)&cmd_config_speed_specific_item1,
1106 (void *)&cmd_config_speed_specific_value1,
1107 (void *)&cmd_config_speed_specific_item2,
1108 (void *)&cmd_config_speed_specific_value2,
1113 /* *** configure txq/rxq, txd/rxd *** */
1114 struct cmd_config_rx_tx {
1115 cmdline_fixed_string_t port;
1116 cmdline_fixed_string_t keyword;
1117 cmdline_fixed_string_t all;
1118 cmdline_fixed_string_t name;
1123 cmd_config_rx_tx_parsed(void *parsed_result,
1124 __attribute__((unused)) struct cmdline *cl,
1125 __attribute__((unused)) void *data)
1127 struct cmd_config_rx_tx *res = parsed_result;
1129 if (!all_ports_stopped()) {
1130 printf("Please stop all ports first\n");
1134 if (!strcmp(res->name, "rxq")) {
1135 if (res->value <= 0) {
1136 printf("rxq %d invalid - must be > 0\n", res->value);
1139 nb_rxq = res->value;
1141 else if (!strcmp(res->name, "txq")) {
1142 if (res->value <= 0) {
1143 printf("txq %d invalid - must be > 0\n", res->value);
1146 nb_txq = res->value;
1148 else if (!strcmp(res->name, "rxd")) {
1149 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1150 printf("rxd %d invalid - must be > 0 && <= %d\n",
1151 res->value, RTE_TEST_RX_DESC_MAX);
1154 nb_rxd = res->value;
1155 } else if (!strcmp(res->name, "txd")) {
1156 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1157 printf("txd %d invalid - must be > 0 && <= %d\n",
1158 res->value, RTE_TEST_TX_DESC_MAX);
1161 nb_txd = res->value;
1163 printf("Unknown parameter\n");
1169 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1172 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1173 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1174 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1175 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1176 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1177 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1178 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1179 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1181 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1182 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1184 cmdline_parse_inst_t cmd_config_rx_tx = {
1185 .f = cmd_config_rx_tx_parsed,
1187 .help_str = "port config all rxq|txq|rxd|txd value",
1189 (void *)&cmd_config_rx_tx_port,
1190 (void *)&cmd_config_rx_tx_keyword,
1191 (void *)&cmd_config_rx_tx_all,
1192 (void *)&cmd_config_rx_tx_name,
1193 (void *)&cmd_config_rx_tx_value,
1198 /* *** config max packet length *** */
1199 struct cmd_config_max_pkt_len_result {
1200 cmdline_fixed_string_t port;
1201 cmdline_fixed_string_t keyword;
1202 cmdline_fixed_string_t all;
1203 cmdline_fixed_string_t name;
1208 cmd_config_max_pkt_len_parsed(void *parsed_result,
1209 __attribute__((unused)) struct cmdline *cl,
1210 __attribute__((unused)) void *data)
1212 struct cmd_config_max_pkt_len_result *res = parsed_result;
1214 if (!all_ports_stopped()) {
1215 printf("Please stop all ports first\n");
1219 if (!strcmp(res->name, "max-pkt-len")) {
1220 if (res->value < ETHER_MIN_LEN) {
1221 printf("max-pkt-len can not be less than %d\n",
1225 if (res->value == rx_mode.max_rx_pkt_len)
1228 rx_mode.max_rx_pkt_len = res->value;
1229 if (res->value > ETHER_MAX_LEN)
1230 rx_mode.jumbo_frame = 1;
1232 rx_mode.jumbo_frame = 0;
1234 printf("Unknown parameter\n");
1240 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1243 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1244 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1246 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1247 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1249 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1250 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1252 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1253 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1255 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1256 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1259 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1260 .f = cmd_config_max_pkt_len_parsed,
1262 .help_str = "port config all max-pkt-len value",
1264 (void *)&cmd_config_max_pkt_len_port,
1265 (void *)&cmd_config_max_pkt_len_keyword,
1266 (void *)&cmd_config_max_pkt_len_all,
1267 (void *)&cmd_config_max_pkt_len_name,
1268 (void *)&cmd_config_max_pkt_len_value,
1273 /* *** configure port MTU *** */
1274 struct cmd_config_mtu_result {
1275 cmdline_fixed_string_t port;
1276 cmdline_fixed_string_t keyword;
1277 cmdline_fixed_string_t mtu;
1283 cmd_config_mtu_parsed(void *parsed_result,
1284 __attribute__((unused)) struct cmdline *cl,
1285 __attribute__((unused)) void *data)
1287 struct cmd_config_mtu_result *res = parsed_result;
1289 if (res->value < ETHER_MIN_LEN) {
1290 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1293 port_mtu_set(res->port_id, res->value);
1296 cmdline_parse_token_string_t cmd_config_mtu_port =
1297 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1299 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1300 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1302 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1303 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1305 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1306 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1307 cmdline_parse_token_num_t cmd_config_mtu_value =
1308 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1310 cmdline_parse_inst_t cmd_config_mtu = {
1311 .f = cmd_config_mtu_parsed,
1313 .help_str = "port config mtu value",
1315 (void *)&cmd_config_mtu_port,
1316 (void *)&cmd_config_mtu_keyword,
1317 (void *)&cmd_config_mtu_mtu,
1318 (void *)&cmd_config_mtu_port_id,
1319 (void *)&cmd_config_mtu_value,
1324 /* *** configure rx mode *** */
1325 struct cmd_config_rx_mode_flag {
1326 cmdline_fixed_string_t port;
1327 cmdline_fixed_string_t keyword;
1328 cmdline_fixed_string_t all;
1329 cmdline_fixed_string_t name;
1330 cmdline_fixed_string_t value;
1334 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1335 __attribute__((unused)) struct cmdline *cl,
1336 __attribute__((unused)) void *data)
1338 struct cmd_config_rx_mode_flag *res = parsed_result;
1340 if (!all_ports_stopped()) {
1341 printf("Please stop all ports first\n");
1345 if (!strcmp(res->name, "crc-strip")) {
1346 if (!strcmp(res->value, "on"))
1347 rx_mode.hw_strip_crc = 1;
1348 else if (!strcmp(res->value, "off"))
1349 rx_mode.hw_strip_crc = 0;
1351 printf("Unknown parameter\n");
1354 } else if (!strcmp(res->name, "rx-cksum")) {
1355 if (!strcmp(res->value, "on"))
1356 rx_mode.hw_ip_checksum = 1;
1357 else if (!strcmp(res->value, "off"))
1358 rx_mode.hw_ip_checksum = 0;
1360 printf("Unknown parameter\n");
1363 } else if (!strcmp(res->name, "hw-vlan")) {
1364 if (!strcmp(res->value, "on")) {
1365 rx_mode.hw_vlan_filter = 1;
1366 rx_mode.hw_vlan_strip = 1;
1368 else if (!strcmp(res->value, "off")) {
1369 rx_mode.hw_vlan_filter = 0;
1370 rx_mode.hw_vlan_strip = 0;
1373 printf("Unknown parameter\n");
1376 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1377 if (!strcmp(res->value, "on"))
1378 rx_mode.hw_vlan_filter = 1;
1379 else if (!strcmp(res->value, "off"))
1380 rx_mode.hw_vlan_filter = 0;
1382 printf("Unknown parameter\n");
1385 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1386 if (!strcmp(res->value, "on"))
1387 rx_mode.hw_vlan_strip = 1;
1388 else if (!strcmp(res->value, "off"))
1389 rx_mode.hw_vlan_strip = 0;
1391 printf("Unknown parameter\n");
1394 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1395 if (!strcmp(res->value, "on"))
1396 rx_mode.hw_vlan_extend = 1;
1397 else if (!strcmp(res->value, "off"))
1398 rx_mode.hw_vlan_extend = 0;
1400 printf("Unknown parameter\n");
1403 } else if (!strcmp(res->name, "drop-en")) {
1404 if (!strcmp(res->value, "on"))
1406 else if (!strcmp(res->value, "off"))
1409 printf("Unknown parameter\n");
1413 printf("Unknown parameter\n");
1419 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1422 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1424 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1425 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1427 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1428 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1429 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1430 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1431 "crc-strip#rx-cksum#hw-vlan#"
1432 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1433 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1434 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1437 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1438 .f = cmd_config_rx_mode_flag_parsed,
1440 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1441 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1443 (void *)&cmd_config_rx_mode_flag_port,
1444 (void *)&cmd_config_rx_mode_flag_keyword,
1445 (void *)&cmd_config_rx_mode_flag_all,
1446 (void *)&cmd_config_rx_mode_flag_name,
1447 (void *)&cmd_config_rx_mode_flag_value,
1452 /* *** configure rss *** */
1453 struct cmd_config_rss {
1454 cmdline_fixed_string_t port;
1455 cmdline_fixed_string_t keyword;
1456 cmdline_fixed_string_t all;
1457 cmdline_fixed_string_t name;
1458 cmdline_fixed_string_t value;
1462 cmd_config_rss_parsed(void *parsed_result,
1463 __attribute__((unused)) struct cmdline *cl,
1464 __attribute__((unused)) void *data)
1466 struct cmd_config_rss *res = parsed_result;
1467 struct rte_eth_rss_conf rss_conf;
1470 if (!strcmp(res->value, "all"))
1471 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1472 ETH_RSS_UDP | ETH_RSS_SCTP |
1474 else if (!strcmp(res->value, "ip"))
1475 rss_conf.rss_hf = ETH_RSS_IP;
1476 else if (!strcmp(res->value, "udp"))
1477 rss_conf.rss_hf = ETH_RSS_UDP;
1478 else if (!strcmp(res->value, "tcp"))
1479 rss_conf.rss_hf = ETH_RSS_TCP;
1480 else if (!strcmp(res->value, "sctp"))
1481 rss_conf.rss_hf = ETH_RSS_SCTP;
1482 else if (!strcmp(res->value, "ether"))
1483 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1484 else if (!strcmp(res->value, "none"))
1485 rss_conf.rss_hf = 0;
1487 printf("Unknown parameter\n");
1490 rss_conf.rss_key = NULL;
1491 for (i = 0; i < rte_eth_dev_count(); i++)
1492 rte_eth_dev_rss_hash_update(i, &rss_conf);
1495 cmdline_parse_token_string_t cmd_config_rss_port =
1496 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1497 cmdline_parse_token_string_t cmd_config_rss_keyword =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1499 cmdline_parse_token_string_t cmd_config_rss_all =
1500 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1501 cmdline_parse_token_string_t cmd_config_rss_name =
1502 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1503 cmdline_parse_token_string_t cmd_config_rss_value =
1504 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1505 "all#ip#tcp#udp#sctp#ether#none");
1507 cmdline_parse_inst_t cmd_config_rss = {
1508 .f = cmd_config_rss_parsed,
1510 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1512 (void *)&cmd_config_rss_port,
1513 (void *)&cmd_config_rss_keyword,
1514 (void *)&cmd_config_rss_all,
1515 (void *)&cmd_config_rss_name,
1516 (void *)&cmd_config_rss_value,
1521 /* *** configure rss hash key *** */
1522 struct cmd_config_rss_hash_key {
1523 cmdline_fixed_string_t port;
1524 cmdline_fixed_string_t config;
1526 cmdline_fixed_string_t rss_hash_key;
1527 cmdline_fixed_string_t rss_type;
1528 cmdline_fixed_string_t key;
1531 #define RSS_HASH_KEY_LENGTH 40
1533 hexa_digit_to_value(char hexa_digit)
1535 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1536 return (uint8_t) (hexa_digit - '0');
1537 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1538 return (uint8_t) ((hexa_digit - 'a') + 10);
1539 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1540 return (uint8_t) ((hexa_digit - 'A') + 10);
1541 /* Invalid hexa digit */
1546 parse_and_check_key_hexa_digit(char *key, int idx)
1550 hexa_v = hexa_digit_to_value(key[idx]);
1552 printf("invalid key: character %c at position %d is not a "
1553 "valid hexa digit\n", key[idx], idx);
1558 cmd_config_rss_hash_key_parsed(void *parsed_result,
1559 __attribute__((unused)) struct cmdline *cl,
1560 __attribute__((unused)) void *data)
1562 struct cmd_config_rss_hash_key *res = parsed_result;
1563 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1568 /* Check the length of the RSS hash key */
1569 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1570 printf("key length: %d invalid - key must be a string of %d"
1571 "hexa-decimal numbers\n", (int) strlen(res->key),
1572 RSS_HASH_KEY_LENGTH * 2);
1575 /* Translate RSS hash key into binary representation */
1576 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1577 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1580 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1583 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1585 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1586 RSS_HASH_KEY_LENGTH);
1589 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1590 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1591 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1592 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1594 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1595 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1596 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1597 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1598 rss_hash_key, "rss-hash-key");
1599 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1600 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1601 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1602 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1603 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1604 "ipv6-tcp-ex#ipv6-udp-ex");
1605 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1606 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1608 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1609 .f = cmd_config_rss_hash_key_parsed,
1612 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1613 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1614 "ipv6-sctp|ipv6-other|l2-payload|"
1615 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1617 (void *)&cmd_config_rss_hash_key_port,
1618 (void *)&cmd_config_rss_hash_key_config,
1619 (void *)&cmd_config_rss_hash_key_port_id,
1620 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1621 (void *)&cmd_config_rss_hash_key_rss_type,
1622 (void *)&cmd_config_rss_hash_key_value,
1627 /* *** configure port rxq/txq start/stop *** */
1628 struct cmd_config_rxtx_queue {
1629 cmdline_fixed_string_t port;
1631 cmdline_fixed_string_t rxtxq;
1633 cmdline_fixed_string_t opname;
1637 cmd_config_rxtx_queue_parsed(void *parsed_result,
1638 __attribute__((unused)) struct cmdline *cl,
1639 __attribute__((unused)) void *data)
1641 struct cmd_config_rxtx_queue *res = parsed_result;
1646 if (test_done == 0) {
1647 printf("Please stop forwarding first\n");
1651 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1654 if (port_is_started(res->portid) != 1) {
1655 printf("Please start port %u first\n", res->portid);
1659 if (!strcmp(res->rxtxq, "rxq"))
1661 else if (!strcmp(res->rxtxq, "txq"))
1664 printf("Unknown parameter\n");
1668 if (isrx && rx_queue_id_is_invalid(res->qid))
1670 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1673 if (!strcmp(res->opname, "start"))
1675 else if (!strcmp(res->opname, "stop"))
1678 printf("Unknown parameter\n");
1682 if (isstart && isrx)
1683 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1684 else if (!isstart && isrx)
1685 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1686 else if (isstart && !isrx)
1687 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1689 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1691 if (ret == -ENOTSUP)
1692 printf("Function not supported in PMD driver\n");
1695 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1696 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1697 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1698 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1699 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1700 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1701 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1702 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1703 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1704 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1707 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1708 .f = cmd_config_rxtx_queue_parsed,
1710 .help_str = "port X rxq|txq ID start|stop",
1712 (void *)&cmd_config_speed_all_port,
1713 (void *)&cmd_config_rxtx_queue_portid,
1714 (void *)&cmd_config_rxtx_queue_rxtxq,
1715 (void *)&cmd_config_rxtx_queue_qid,
1716 (void *)&cmd_config_rxtx_queue_opname,
1721 /* *** Configure RSS RETA *** */
1722 struct cmd_config_rss_reta {
1723 cmdline_fixed_string_t port;
1724 cmdline_fixed_string_t keyword;
1726 cmdline_fixed_string_t name;
1727 cmdline_fixed_string_t list_name;
1728 cmdline_fixed_string_t list_of_items;
1732 parse_reta_config(const char *str,
1733 struct rte_eth_rss_reta_entry64 *reta_conf,
1734 uint16_t nb_entries)
1738 uint16_t hash_index, idx, shift;
1741 const char *p, *p0 = str;
1748 unsigned long int_fld[_NUM_FLD];
1749 char *str_fld[_NUM_FLD];
1751 while ((p = strchr(p0,'(')) != NULL) {
1753 if((p0 = strchr(p,')')) == NULL)
1757 if(size >= sizeof(s))
1760 snprintf(s, sizeof(s), "%.*s", size, p);
1761 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1763 for (i = 0; i < _NUM_FLD; i++) {
1765 int_fld[i] = strtoul(str_fld[i], &end, 0);
1766 if (errno != 0 || end == str_fld[i] ||
1771 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1772 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1774 if (hash_index >= nb_entries) {
1775 printf("Invalid RETA hash index=%d\n", hash_index);
1779 idx = hash_index / RTE_RETA_GROUP_SIZE;
1780 shift = hash_index % RTE_RETA_GROUP_SIZE;
1781 reta_conf[idx].mask |= (1ULL << shift);
1782 reta_conf[idx].reta[shift] = nb_queue;
1789 cmd_set_rss_reta_parsed(void *parsed_result,
1790 __attribute__((unused)) struct cmdline *cl,
1791 __attribute__((unused)) void *data)
1794 struct rte_eth_dev_info dev_info;
1795 struct rte_eth_rss_reta_entry64 reta_conf[8];
1796 struct cmd_config_rss_reta *res = parsed_result;
1798 memset(&dev_info, 0, sizeof(dev_info));
1799 rte_eth_dev_info_get(res->port_id, &dev_info);
1800 if (dev_info.reta_size == 0) {
1801 printf("Redirection table size is 0 which is "
1802 "invalid for RSS\n");
1805 printf("The reta size of port %d is %u\n",
1806 res->port_id, dev_info.reta_size);
1807 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1808 printf("Currently do not support more than %u entries of "
1809 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1813 memset(reta_conf, 0, sizeof(reta_conf));
1814 if (!strcmp(res->list_name, "reta")) {
1815 if (parse_reta_config(res->list_of_items, reta_conf,
1816 dev_info.reta_size)) {
1817 printf("Invalid RSS Redirection Table "
1818 "config entered\n");
1821 ret = rte_eth_dev_rss_reta_update(res->port_id,
1822 reta_conf, dev_info.reta_size);
1824 printf("Bad redirection table parameter, "
1825 "return code = %d \n", ret);
1829 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1830 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1831 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1833 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1834 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1835 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1836 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1837 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1838 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1839 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1840 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1842 cmdline_parse_inst_t cmd_config_rss_reta = {
1843 .f = cmd_set_rss_reta_parsed,
1845 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1847 (void *)&cmd_config_rss_reta_port,
1848 (void *)&cmd_config_rss_reta_keyword,
1849 (void *)&cmd_config_rss_reta_port_id,
1850 (void *)&cmd_config_rss_reta_name,
1851 (void *)&cmd_config_rss_reta_list_name,
1852 (void *)&cmd_config_rss_reta_list_of_items,
1857 /* *** SHOW PORT RETA INFO *** */
1858 struct cmd_showport_reta {
1859 cmdline_fixed_string_t show;
1860 cmdline_fixed_string_t port;
1862 cmdline_fixed_string_t rss;
1863 cmdline_fixed_string_t reta;
1865 cmdline_fixed_string_t list_of_items;
1869 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1870 uint16_t nb_entries,
1874 const char *p, *p0 = str;
1878 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1881 p = strchr(p0, '(');
1885 p0 = strchr(p, ')');
1889 if (size >= sizeof(s)) {
1890 printf("The string size exceeds the internal buffer size\n");
1893 snprintf(s, sizeof(s), "%.*s", size, p);
1894 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1895 if (ret <= 0 || ret != num) {
1896 printf("The bits of masks do not match the number of "
1897 "reta entries: %u\n", num);
1900 for (i = 0; i < ret; i++)
1901 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1907 cmd_showport_reta_parsed(void *parsed_result,
1908 __attribute__((unused)) struct cmdline *cl,
1909 __attribute__((unused)) void *data)
1911 struct cmd_showport_reta *res = parsed_result;
1912 struct rte_eth_rss_reta_entry64 reta_conf[8];
1913 struct rte_eth_dev_info dev_info;
1915 memset(&dev_info, 0, sizeof(dev_info));
1916 rte_eth_dev_info_get(res->port_id, &dev_info);
1917 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1918 res->size > ETH_RSS_RETA_SIZE_512) {
1919 printf("Invalid redirection table size: %u\n", res->size);
1923 memset(reta_conf, 0, sizeof(reta_conf));
1924 if (showport_parse_reta_config(reta_conf, res->size,
1925 res->list_of_items) < 0) {
1926 printf("Invalid string: %s for reta masks\n",
1927 res->list_of_items);
1930 port_rss_reta_info(res->port_id, reta_conf, res->size);
1933 cmdline_parse_token_string_t cmd_showport_reta_show =
1934 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1935 cmdline_parse_token_string_t cmd_showport_reta_port =
1936 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1937 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1938 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1939 cmdline_parse_token_string_t cmd_showport_reta_rss =
1940 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1941 cmdline_parse_token_string_t cmd_showport_reta_reta =
1942 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1943 cmdline_parse_token_num_t cmd_showport_reta_size =
1944 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1945 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1946 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1947 list_of_items, NULL);
1949 cmdline_parse_inst_t cmd_showport_reta = {
1950 .f = cmd_showport_reta_parsed,
1952 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1954 (void *)&cmd_showport_reta_show,
1955 (void *)&cmd_showport_reta_port,
1956 (void *)&cmd_showport_reta_port_id,
1957 (void *)&cmd_showport_reta_rss,
1958 (void *)&cmd_showport_reta_reta,
1959 (void *)&cmd_showport_reta_size,
1960 (void *)&cmd_showport_reta_list_of_items,
1965 /* *** Show RSS hash configuration *** */
1966 struct cmd_showport_rss_hash {
1967 cmdline_fixed_string_t show;
1968 cmdline_fixed_string_t port;
1970 cmdline_fixed_string_t rss_hash;
1971 cmdline_fixed_string_t rss_type;
1972 cmdline_fixed_string_t key; /* optional argument */
1975 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1976 __attribute__((unused)) struct cmdline *cl,
1979 struct cmd_showport_rss_hash *res = parsed_result;
1981 port_rss_hash_conf_show(res->port_id, res->rss_type,
1982 show_rss_key != NULL);
1985 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1986 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1987 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1988 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1989 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1990 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1991 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1992 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1994 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
1995 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
1996 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1997 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1998 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1999 "ipv6-tcp-ex#ipv6-udp-ex");
2000 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2001 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2003 cmdline_parse_inst_t cmd_showport_rss_hash = {
2004 .f = cmd_showport_rss_hash_parsed,
2007 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2008 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2009 "ipv6-sctp|ipv6-other|l2-payload|"
2010 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2012 (void *)&cmd_showport_rss_hash_show,
2013 (void *)&cmd_showport_rss_hash_port,
2014 (void *)&cmd_showport_rss_hash_port_id,
2015 (void *)&cmd_showport_rss_hash_rss_hash,
2016 (void *)&cmd_showport_rss_hash_rss_hash_info,
2021 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2022 .f = cmd_showport_rss_hash_parsed,
2025 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2026 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2027 "ipv6-sctp|ipv6-other|l2-payload|"
2028 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2030 (void *)&cmd_showport_rss_hash_show,
2031 (void *)&cmd_showport_rss_hash_port,
2032 (void *)&cmd_showport_rss_hash_port_id,
2033 (void *)&cmd_showport_rss_hash_rss_hash,
2034 (void *)&cmd_showport_rss_hash_rss_hash_info,
2035 (void *)&cmd_showport_rss_hash_rss_key,
2040 /* *** Configure DCB *** */
2041 struct cmd_config_dcb {
2042 cmdline_fixed_string_t port;
2043 cmdline_fixed_string_t config;
2045 cmdline_fixed_string_t dcb;
2046 cmdline_fixed_string_t vt;
2047 cmdline_fixed_string_t vt_en;
2049 cmdline_fixed_string_t pfc;
2050 cmdline_fixed_string_t pfc_en;
2054 cmd_config_dcb_parsed(void *parsed_result,
2055 __attribute__((unused)) struct cmdline *cl,
2056 __attribute__((unused)) void *data)
2058 struct cmd_config_dcb *res = parsed_result;
2059 portid_t port_id = res->port_id;
2060 struct rte_port *port;
2064 port = &ports[port_id];
2065 /** Check if the port is not started **/
2066 if (port->port_status != RTE_PORT_STOPPED) {
2067 printf("Please stop port %d first\n", port_id);
2071 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2072 printf("The invalid number of traffic class,"
2073 " only 4 or 8 allowed.\n");
2077 if (nb_fwd_lcores < res->num_tcs) {
2078 printf("nb_cores shouldn't be less than number of TCs.\n");
2081 if (!strncmp(res->pfc_en, "on", 2))
2086 /* DCB in VT mode */
2087 if (!strncmp(res->vt_en, "on", 2))
2088 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2089 (enum rte_eth_nb_tcs)res->num_tcs,
2092 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2093 (enum rte_eth_nb_tcs)res->num_tcs,
2098 printf("Cannot initialize network ports.\n");
2102 cmd_reconfig_device_queue(port_id, 1, 1);
2105 cmdline_parse_token_string_t cmd_config_dcb_port =
2106 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2107 cmdline_parse_token_string_t cmd_config_dcb_config =
2108 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2109 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2110 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2111 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2112 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2113 cmdline_parse_token_string_t cmd_config_dcb_vt =
2114 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2115 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2116 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2117 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2118 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2119 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2120 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2121 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2122 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2124 cmdline_parse_inst_t cmd_config_dcb = {
2125 .f = cmd_config_dcb_parsed,
2127 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2129 (void *)&cmd_config_dcb_port,
2130 (void *)&cmd_config_dcb_config,
2131 (void *)&cmd_config_dcb_port_id,
2132 (void *)&cmd_config_dcb_dcb,
2133 (void *)&cmd_config_dcb_vt,
2134 (void *)&cmd_config_dcb_vt_en,
2135 (void *)&cmd_config_dcb_num_tcs,
2136 (void *)&cmd_config_dcb_pfc,
2137 (void *)&cmd_config_dcb_pfc_en,
2142 /* *** configure number of packets per burst *** */
2143 struct cmd_config_burst {
2144 cmdline_fixed_string_t port;
2145 cmdline_fixed_string_t keyword;
2146 cmdline_fixed_string_t all;
2147 cmdline_fixed_string_t name;
2152 cmd_config_burst_parsed(void *parsed_result,
2153 __attribute__((unused)) struct cmdline *cl,
2154 __attribute__((unused)) void *data)
2156 struct cmd_config_burst *res = parsed_result;
2158 if (!all_ports_stopped()) {
2159 printf("Please stop all ports first\n");
2163 if (!strcmp(res->name, "burst")) {
2164 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2165 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2168 nb_pkt_per_burst = res->value;
2170 printf("Unknown parameter\n");
2176 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2179 cmdline_parse_token_string_t cmd_config_burst_port =
2180 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2181 cmdline_parse_token_string_t cmd_config_burst_keyword =
2182 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2183 cmdline_parse_token_string_t cmd_config_burst_all =
2184 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2185 cmdline_parse_token_string_t cmd_config_burst_name =
2186 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2187 cmdline_parse_token_num_t cmd_config_burst_value =
2188 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2190 cmdline_parse_inst_t cmd_config_burst = {
2191 .f = cmd_config_burst_parsed,
2193 .help_str = "port config all burst value",
2195 (void *)&cmd_config_burst_port,
2196 (void *)&cmd_config_burst_keyword,
2197 (void *)&cmd_config_burst_all,
2198 (void *)&cmd_config_burst_name,
2199 (void *)&cmd_config_burst_value,
2204 /* *** configure rx/tx queues *** */
2205 struct cmd_config_thresh {
2206 cmdline_fixed_string_t port;
2207 cmdline_fixed_string_t keyword;
2208 cmdline_fixed_string_t all;
2209 cmdline_fixed_string_t name;
2214 cmd_config_thresh_parsed(void *parsed_result,
2215 __attribute__((unused)) struct cmdline *cl,
2216 __attribute__((unused)) void *data)
2218 struct cmd_config_thresh *res = parsed_result;
2220 if (!all_ports_stopped()) {
2221 printf("Please stop all ports first\n");
2225 if (!strcmp(res->name, "txpt"))
2226 tx_pthresh = res->value;
2227 else if(!strcmp(res->name, "txht"))
2228 tx_hthresh = res->value;
2229 else if(!strcmp(res->name, "txwt"))
2230 tx_wthresh = res->value;
2231 else if(!strcmp(res->name, "rxpt"))
2232 rx_pthresh = res->value;
2233 else if(!strcmp(res->name, "rxht"))
2234 rx_hthresh = res->value;
2235 else if(!strcmp(res->name, "rxwt"))
2236 rx_wthresh = res->value;
2238 printf("Unknown parameter\n");
2244 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2247 cmdline_parse_token_string_t cmd_config_thresh_port =
2248 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2249 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2251 cmdline_parse_token_string_t cmd_config_thresh_all =
2252 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2253 cmdline_parse_token_string_t cmd_config_thresh_name =
2254 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2255 "txpt#txht#txwt#rxpt#rxht#rxwt");
2256 cmdline_parse_token_num_t cmd_config_thresh_value =
2257 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2259 cmdline_parse_inst_t cmd_config_thresh = {
2260 .f = cmd_config_thresh_parsed,
2262 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2264 (void *)&cmd_config_thresh_port,
2265 (void *)&cmd_config_thresh_keyword,
2266 (void *)&cmd_config_thresh_all,
2267 (void *)&cmd_config_thresh_name,
2268 (void *)&cmd_config_thresh_value,
2273 /* *** configure free/rs threshold *** */
2274 struct cmd_config_threshold {
2275 cmdline_fixed_string_t port;
2276 cmdline_fixed_string_t keyword;
2277 cmdline_fixed_string_t all;
2278 cmdline_fixed_string_t name;
2283 cmd_config_threshold_parsed(void *parsed_result,
2284 __attribute__((unused)) struct cmdline *cl,
2285 __attribute__((unused)) void *data)
2287 struct cmd_config_threshold *res = parsed_result;
2289 if (!all_ports_stopped()) {
2290 printf("Please stop all ports first\n");
2294 if (!strcmp(res->name, "txfreet"))
2295 tx_free_thresh = res->value;
2296 else if (!strcmp(res->name, "txrst"))
2297 tx_rs_thresh = res->value;
2298 else if (!strcmp(res->name, "rxfreet"))
2299 rx_free_thresh = res->value;
2301 printf("Unknown parameter\n");
2307 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2310 cmdline_parse_token_string_t cmd_config_threshold_port =
2311 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2312 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2313 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2315 cmdline_parse_token_string_t cmd_config_threshold_all =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2317 cmdline_parse_token_string_t cmd_config_threshold_name =
2318 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2319 "txfreet#txrst#rxfreet");
2320 cmdline_parse_token_num_t cmd_config_threshold_value =
2321 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2323 cmdline_parse_inst_t cmd_config_threshold = {
2324 .f = cmd_config_threshold_parsed,
2326 .help_str = "port config all txfreet|txrst|rxfreet value",
2328 (void *)&cmd_config_threshold_port,
2329 (void *)&cmd_config_threshold_keyword,
2330 (void *)&cmd_config_threshold_all,
2331 (void *)&cmd_config_threshold_name,
2332 (void *)&cmd_config_threshold_value,
2338 struct cmd_stop_result {
2339 cmdline_fixed_string_t stop;
2342 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2343 __attribute__((unused)) struct cmdline *cl,
2344 __attribute__((unused)) void *data)
2346 stop_packet_forwarding();
2349 cmdline_parse_token_string_t cmd_stop_stop =
2350 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2352 cmdline_parse_inst_t cmd_stop = {
2353 .f = cmd_stop_parsed,
2355 .help_str = "stop - stop packet forwarding",
2357 (void *)&cmd_stop_stop,
2362 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2365 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2366 unsigned int *parsed_items, int check_unique_values)
2368 unsigned int nb_item;
2376 * First parse all items in the list and store their value.
2381 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2383 if ((c >= '0') && (c <= '9')) {
2384 value = (unsigned int) (value * 10 + (c - '0'));
2389 printf("character %c is not a decimal digit\n", c);
2393 printf("No valid value before comma\n");
2396 if (nb_item < max_items) {
2397 parsed_items[nb_item] = value;
2403 if (nb_item >= max_items) {
2404 printf("Number of %s = %u > %u (maximum items)\n",
2405 item_name, nb_item + 1, max_items);
2408 parsed_items[nb_item++] = value;
2409 if (! check_unique_values)
2413 * Then, check that all values in the list are differents.
2414 * No optimization here...
2416 for (i = 0; i < nb_item; i++) {
2417 for (j = i + 1; j < nb_item; j++) {
2418 if (parsed_items[j] == parsed_items[i]) {
2419 printf("duplicated %s %u at index %u and %u\n",
2420 item_name, parsed_items[i], i, j);
2428 struct cmd_set_list_result {
2429 cmdline_fixed_string_t cmd_keyword;
2430 cmdline_fixed_string_t list_name;
2431 cmdline_fixed_string_t list_of_items;
2434 static void cmd_set_list_parsed(void *parsed_result,
2435 __attribute__((unused)) struct cmdline *cl,
2436 __attribute__((unused)) void *data)
2438 struct cmd_set_list_result *res;
2440 unsigned int lcorelist[RTE_MAX_LCORE];
2441 unsigned int portlist[RTE_MAX_ETHPORTS];
2443 unsigned int nb_item;
2445 if (test_done == 0) {
2446 printf("Please stop forwarding first\n");
2450 res = parsed_result;
2451 if (!strcmp(res->list_name, "corelist")) {
2452 nb_item = parse_item_list(res->list_of_items, "core",
2454 parsed_items.lcorelist, 1);
2456 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2459 if (!strcmp(res->list_name, "portlist")) {
2460 nb_item = parse_item_list(res->list_of_items, "port",
2462 parsed_items.portlist, 1);
2464 set_fwd_ports_list(parsed_items.portlist, nb_item);
2468 cmdline_parse_token_string_t cmd_set_list_keyword =
2469 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2471 cmdline_parse_token_string_t cmd_set_list_name =
2472 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2473 "corelist#portlist");
2474 cmdline_parse_token_string_t cmd_set_list_of_items =
2475 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2478 cmdline_parse_inst_t cmd_set_fwd_list = {
2479 .f = cmd_set_list_parsed,
2481 .help_str = "set corelist|portlist x[,y]*",
2483 (void *)&cmd_set_list_keyword,
2484 (void *)&cmd_set_list_name,
2485 (void *)&cmd_set_list_of_items,
2490 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2492 struct cmd_setmask_result {
2493 cmdline_fixed_string_t set;
2494 cmdline_fixed_string_t mask;
2498 static void cmd_set_mask_parsed(void *parsed_result,
2499 __attribute__((unused)) struct cmdline *cl,
2500 __attribute__((unused)) void *data)
2502 struct cmd_setmask_result *res = parsed_result;
2504 if (test_done == 0) {
2505 printf("Please stop forwarding first\n");
2508 if (!strcmp(res->mask, "coremask"))
2509 set_fwd_lcores_mask(res->hexavalue);
2510 else if (!strcmp(res->mask, "portmask"))
2511 set_fwd_ports_mask(res->hexavalue);
2514 cmdline_parse_token_string_t cmd_setmask_set =
2515 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2516 cmdline_parse_token_string_t cmd_setmask_mask =
2517 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2518 "coremask#portmask");
2519 cmdline_parse_token_num_t cmd_setmask_value =
2520 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2522 cmdline_parse_inst_t cmd_set_fwd_mask = {
2523 .f = cmd_set_mask_parsed,
2525 .help_str = "set coremask|portmask hexadecimal value",
2527 (void *)&cmd_setmask_set,
2528 (void *)&cmd_setmask_mask,
2529 (void *)&cmd_setmask_value,
2535 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2537 struct cmd_set_result {
2538 cmdline_fixed_string_t set;
2539 cmdline_fixed_string_t what;
2543 static void cmd_set_parsed(void *parsed_result,
2544 __attribute__((unused)) struct cmdline *cl,
2545 __attribute__((unused)) void *data)
2547 struct cmd_set_result *res = parsed_result;
2548 if (!strcmp(res->what, "nbport"))
2549 set_fwd_ports_number(res->value);
2550 else if (!strcmp(res->what, "nbcore"))
2551 set_fwd_lcores_number(res->value);
2552 else if (!strcmp(res->what, "burst"))
2553 set_nb_pkt_per_burst(res->value);
2554 else if (!strcmp(res->what, "verbose"))
2555 set_verbose_level(res->value);
2558 cmdline_parse_token_string_t cmd_set_set =
2559 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2560 cmdline_parse_token_string_t cmd_set_what =
2561 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2562 "nbport#nbcore#burst#verbose");
2563 cmdline_parse_token_num_t cmd_set_value =
2564 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2566 cmdline_parse_inst_t cmd_set_numbers = {
2567 .f = cmd_set_parsed,
2569 .help_str = "set nbport|nbcore|burst|verbose value",
2571 (void *)&cmd_set_set,
2572 (void *)&cmd_set_what,
2573 (void *)&cmd_set_value,
2578 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2580 struct cmd_set_txpkts_result {
2581 cmdline_fixed_string_t cmd_keyword;
2582 cmdline_fixed_string_t txpkts;
2583 cmdline_fixed_string_t seg_lengths;
2587 cmd_set_txpkts_parsed(void *parsed_result,
2588 __attribute__((unused)) struct cmdline *cl,
2589 __attribute__((unused)) void *data)
2591 struct cmd_set_txpkts_result *res;
2592 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2593 unsigned int nb_segs;
2595 res = parsed_result;
2596 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2597 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2599 set_tx_pkt_segments(seg_lengths, nb_segs);
2602 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2603 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2604 cmd_keyword, "set");
2605 cmdline_parse_token_string_t cmd_set_txpkts_name =
2606 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2608 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2609 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2612 cmdline_parse_inst_t cmd_set_txpkts = {
2613 .f = cmd_set_txpkts_parsed,
2615 .help_str = "set txpkts x[,y]*",
2617 (void *)&cmd_set_txpkts_keyword,
2618 (void *)&cmd_set_txpkts_name,
2619 (void *)&cmd_set_txpkts_lengths,
2624 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2625 struct cmd_rx_vlan_filter_all_result {
2626 cmdline_fixed_string_t rx_vlan;
2627 cmdline_fixed_string_t what;
2628 cmdline_fixed_string_t all;
2633 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2634 __attribute__((unused)) struct cmdline *cl,
2635 __attribute__((unused)) void *data)
2637 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2639 if (!strcmp(res->what, "add"))
2640 rx_vlan_all_filter_set(res->port_id, 1);
2642 rx_vlan_all_filter_set(res->port_id, 0);
2645 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2646 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2647 rx_vlan, "rx_vlan");
2648 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2649 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2651 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2652 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2654 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2655 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2658 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2659 .f = cmd_rx_vlan_filter_all_parsed,
2661 .help_str = "add/remove all identifiers to/from the set of VLAN "
2662 "Identifiers filtered by a port",
2664 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2665 (void *)&cmd_rx_vlan_filter_all_what,
2666 (void *)&cmd_rx_vlan_filter_all_all,
2667 (void *)&cmd_rx_vlan_filter_all_portid,
2672 /* *** VLAN OFFLOAD SET ON A PORT *** */
2673 struct cmd_vlan_offload_result {
2674 cmdline_fixed_string_t vlan;
2675 cmdline_fixed_string_t set;
2676 cmdline_fixed_string_t what;
2677 cmdline_fixed_string_t on;
2678 cmdline_fixed_string_t port_id;
2682 cmd_vlan_offload_parsed(void *parsed_result,
2683 __attribute__((unused)) struct cmdline *cl,
2684 __attribute__((unused)) void *data)
2687 struct cmd_vlan_offload_result *res = parsed_result;
2690 portid_t port_id = 0;
2694 len = strnlen(str, STR_TOKEN_SIZE);
2696 /* Get port_id first */
2704 tmp = strtoul(str, NULL, 0);
2705 /* If port_id greater that what portid_t can represent, return */
2706 if(tmp >= RTE_MAX_ETHPORTS)
2708 port_id = (portid_t)tmp;
2710 if (!strcmp(res->on, "on"))
2715 if (!strcmp(res->what, "strip"))
2716 rx_vlan_strip_set(port_id, on);
2717 else if(!strcmp(res->what, "stripq")){
2718 uint16_t queue_id = 0;
2720 /* No queue_id, return */
2722 printf("must specify (port,queue_id)\n");
2725 tmp = strtoul(str + i + 1, NULL, 0);
2726 /* If queue_id greater that what 16-bits can represent, return */
2730 queue_id = (uint16_t)tmp;
2731 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2733 else if (!strcmp(res->what, "filter"))
2734 rx_vlan_filter_set(port_id, on);
2736 vlan_extend_set(port_id, on);
2741 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2742 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2744 cmdline_parse_token_string_t cmd_vlan_offload_set =
2745 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2747 cmdline_parse_token_string_t cmd_vlan_offload_what =
2748 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2749 what, "strip#filter#qinq#stripq");
2750 cmdline_parse_token_string_t cmd_vlan_offload_on =
2751 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2753 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2754 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2757 cmdline_parse_inst_t cmd_vlan_offload = {
2758 .f = cmd_vlan_offload_parsed,
2760 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2761 " qinq(extended) for both rx/tx sides ",
2763 (void *)&cmd_vlan_offload_vlan,
2764 (void *)&cmd_vlan_offload_set,
2765 (void *)&cmd_vlan_offload_what,
2766 (void *)&cmd_vlan_offload_on,
2767 (void *)&cmd_vlan_offload_portid,
2772 /* *** VLAN TPID SET ON A PORT *** */
2773 struct cmd_vlan_tpid_result {
2774 cmdline_fixed_string_t vlan;
2775 cmdline_fixed_string_t set;
2776 cmdline_fixed_string_t what;
2782 cmd_vlan_tpid_parsed(void *parsed_result,
2783 __attribute__((unused)) struct cmdline *cl,
2784 __attribute__((unused)) void *data)
2786 struct cmd_vlan_tpid_result *res = parsed_result;
2787 vlan_tpid_set(res->port_id, res->tp_id);
2791 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2792 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2794 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2795 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2797 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2798 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2800 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2801 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2803 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2804 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2807 cmdline_parse_inst_t cmd_vlan_tpid = {
2808 .f = cmd_vlan_tpid_parsed,
2810 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2812 (void *)&cmd_vlan_tpid_vlan,
2813 (void *)&cmd_vlan_tpid_set,
2814 (void *)&cmd_vlan_tpid_what,
2815 (void *)&cmd_vlan_tpid_tpid,
2816 (void *)&cmd_vlan_tpid_portid,
2821 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2822 struct cmd_rx_vlan_filter_result {
2823 cmdline_fixed_string_t rx_vlan;
2824 cmdline_fixed_string_t what;
2830 cmd_rx_vlan_filter_parsed(void *parsed_result,
2831 __attribute__((unused)) struct cmdline *cl,
2832 __attribute__((unused)) void *data)
2834 struct cmd_rx_vlan_filter_result *res = parsed_result;
2836 if (!strcmp(res->what, "add"))
2837 rx_vft_set(res->port_id, res->vlan_id, 1);
2839 rx_vft_set(res->port_id, res->vlan_id, 0);
2842 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2843 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2844 rx_vlan, "rx_vlan");
2845 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2846 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2848 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2849 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2851 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2852 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2855 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2856 .f = cmd_rx_vlan_filter_parsed,
2858 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2859 "Identifiers filtered by a port",
2861 (void *)&cmd_rx_vlan_filter_rx_vlan,
2862 (void *)&cmd_rx_vlan_filter_what,
2863 (void *)&cmd_rx_vlan_filter_vlanid,
2864 (void *)&cmd_rx_vlan_filter_portid,
2869 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2870 struct cmd_tx_vlan_set_result {
2871 cmdline_fixed_string_t tx_vlan;
2872 cmdline_fixed_string_t set;
2878 cmd_tx_vlan_set_parsed(void *parsed_result,
2879 __attribute__((unused)) struct cmdline *cl,
2880 __attribute__((unused)) void *data)
2882 struct cmd_tx_vlan_set_result *res = parsed_result;
2883 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2885 if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD) {
2886 printf("Error, as QinQ has been enabled.\n");
2890 tx_vlan_set(res->port_id, res->vlan_id);
2893 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2894 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2895 tx_vlan, "tx_vlan");
2896 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2897 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2899 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2900 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2902 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2903 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2906 cmdline_parse_inst_t cmd_tx_vlan_set = {
2907 .f = cmd_tx_vlan_set_parsed,
2909 .help_str = "enable hardware insertion of a single VLAN header "
2910 "with a given TAG Identifier in packets sent on a port",
2912 (void *)&cmd_tx_vlan_set_tx_vlan,
2913 (void *)&cmd_tx_vlan_set_set,
2914 (void *)&cmd_tx_vlan_set_portid,
2915 (void *)&cmd_tx_vlan_set_vlanid,
2920 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
2921 struct cmd_tx_vlan_set_qinq_result {
2922 cmdline_fixed_string_t tx_vlan;
2923 cmdline_fixed_string_t set;
2926 uint16_t vlan_id_outer;
2930 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
2931 __attribute__((unused)) struct cmdline *cl,
2932 __attribute__((unused)) void *data)
2934 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
2935 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2937 if (!(vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)) {
2938 printf("Error, as QinQ hasn't been enabled.\n");
2942 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
2945 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
2946 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2947 tx_vlan, "tx_vlan");
2948 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
2949 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2951 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
2952 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2954 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
2955 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2957 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
2958 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2959 vlan_id_outer, UINT16);
2961 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
2962 .f = cmd_tx_vlan_set_qinq_parsed,
2964 .help_str = "enable hardware insertion of double VLAN header "
2965 "with given TAG Identifiers in packets sent on a port",
2967 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
2968 (void *)&cmd_tx_vlan_set_qinq_set,
2969 (void *)&cmd_tx_vlan_set_qinq_portid,
2970 (void *)&cmd_tx_vlan_set_qinq_vlanid,
2971 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
2976 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2977 struct cmd_tx_vlan_set_pvid_result {
2978 cmdline_fixed_string_t tx_vlan;
2979 cmdline_fixed_string_t set;
2980 cmdline_fixed_string_t pvid;
2983 cmdline_fixed_string_t mode;
2987 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2988 __attribute__((unused)) struct cmdline *cl,
2989 __attribute__((unused)) void *data)
2991 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2993 if (strcmp(res->mode, "on") == 0)
2994 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2996 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2999 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3000 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3001 tx_vlan, "tx_vlan");
3002 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3003 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3005 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3006 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3008 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3009 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3011 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3012 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3014 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3015 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3018 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3019 .f = cmd_tx_vlan_set_pvid_parsed,
3021 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3023 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3024 (void *)&cmd_tx_vlan_set_pvid_set,
3025 (void *)&cmd_tx_vlan_set_pvid_pvid,
3026 (void *)&cmd_tx_vlan_set_pvid_port_id,
3027 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3028 (void *)&cmd_tx_vlan_set_pvid_mode,
3033 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3034 struct cmd_tx_vlan_reset_result {
3035 cmdline_fixed_string_t tx_vlan;
3036 cmdline_fixed_string_t reset;
3041 cmd_tx_vlan_reset_parsed(void *parsed_result,
3042 __attribute__((unused)) struct cmdline *cl,
3043 __attribute__((unused)) void *data)
3045 struct cmd_tx_vlan_reset_result *res = parsed_result;
3047 tx_vlan_reset(res->port_id);
3050 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3051 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3052 tx_vlan, "tx_vlan");
3053 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3054 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3056 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3057 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3060 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3061 .f = cmd_tx_vlan_reset_parsed,
3063 .help_str = "disable hardware insertion of a VLAN header in packets "
3066 (void *)&cmd_tx_vlan_reset_tx_vlan,
3067 (void *)&cmd_tx_vlan_reset_reset,
3068 (void *)&cmd_tx_vlan_reset_portid,
3074 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3075 struct cmd_csum_result {
3076 cmdline_fixed_string_t csum;
3077 cmdline_fixed_string_t mode;
3078 cmdline_fixed_string_t proto;
3079 cmdline_fixed_string_t hwsw;
3084 csum_show(int port_id)
3086 struct rte_eth_dev_info dev_info;
3089 ol_flags = ports[port_id].tx_ol_flags;
3090 printf("Parse tunnel is %s\n",
3091 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3092 printf("IP checksum offload is %s\n",
3093 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3094 printf("UDP checksum offload is %s\n",
3095 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3096 printf("TCP checksum offload is %s\n",
3097 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3098 printf("SCTP checksum offload is %s\n",
3099 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3100 printf("Outer-Ip checksum offload is %s\n",
3101 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3103 /* display warnings if configuration is not supported by the NIC */
3104 rte_eth_dev_info_get(port_id, &dev_info);
3105 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3106 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3107 printf("Warning: hardware IP checksum enabled but not "
3108 "supported by port %d\n", port_id);
3110 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3111 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3112 printf("Warning: hardware UDP checksum enabled but not "
3113 "supported by port %d\n", port_id);
3115 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3116 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3117 printf("Warning: hardware TCP checksum enabled but not "
3118 "supported by port %d\n", port_id);
3120 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3121 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3122 printf("Warning: hardware SCTP checksum enabled but not "
3123 "supported by port %d\n", port_id);
3125 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3126 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3127 printf("Warning: hardware outer IP checksum enabled but not "
3128 "supported by port %d\n", port_id);
3133 cmd_csum_parsed(void *parsed_result,
3134 __attribute__((unused)) struct cmdline *cl,
3135 __attribute__((unused)) void *data)
3137 struct cmd_csum_result *res = parsed_result;
3141 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3142 printf("invalid port %d\n", res->port_id);
3146 if (!strcmp(res->mode, "set")) {
3148 if (!strcmp(res->hwsw, "hw"))
3151 if (!strcmp(res->proto, "ip")) {
3152 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3153 } else if (!strcmp(res->proto, "udp")) {
3154 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3155 } else if (!strcmp(res->proto, "tcp")) {
3156 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3157 } else if (!strcmp(res->proto, "sctp")) {
3158 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3159 } else if (!strcmp(res->proto, "outer-ip")) {
3160 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3164 ports[res->port_id].tx_ol_flags |= mask;
3166 ports[res->port_id].tx_ol_flags &= (~mask);
3168 csum_show(res->port_id);
3171 cmdline_parse_token_string_t cmd_csum_csum =
3172 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3174 cmdline_parse_token_string_t cmd_csum_mode =
3175 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3177 cmdline_parse_token_string_t cmd_csum_proto =
3178 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3179 proto, "ip#tcp#udp#sctp#outer-ip");
3180 cmdline_parse_token_string_t cmd_csum_hwsw =
3181 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3183 cmdline_parse_token_num_t cmd_csum_portid =
3184 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3187 cmdline_parse_inst_t cmd_csum_set = {
3188 .f = cmd_csum_parsed,
3190 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3191 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3193 (void *)&cmd_csum_csum,
3194 (void *)&cmd_csum_mode,
3195 (void *)&cmd_csum_proto,
3196 (void *)&cmd_csum_hwsw,
3197 (void *)&cmd_csum_portid,
3202 cmdline_parse_token_string_t cmd_csum_mode_show =
3203 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3206 cmdline_parse_inst_t cmd_csum_show = {
3207 .f = cmd_csum_parsed,
3209 .help_str = "show checksum offload configuration: csum show <port>",
3211 (void *)&cmd_csum_csum,
3212 (void *)&cmd_csum_mode_show,
3213 (void *)&cmd_csum_portid,
3218 /* Enable/disable tunnel parsing */
3219 struct cmd_csum_tunnel_result {
3220 cmdline_fixed_string_t csum;
3221 cmdline_fixed_string_t parse;
3222 cmdline_fixed_string_t onoff;
3227 cmd_csum_tunnel_parsed(void *parsed_result,
3228 __attribute__((unused)) struct cmdline *cl,
3229 __attribute__((unused)) void *data)
3231 struct cmd_csum_tunnel_result *res = parsed_result;
3233 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3236 if (!strcmp(res->onoff, "on"))
3237 ports[res->port_id].tx_ol_flags |=
3238 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3240 ports[res->port_id].tx_ol_flags &=
3241 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3243 csum_show(res->port_id);
3246 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3247 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3249 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3250 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3251 parse, "parse_tunnel");
3252 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3253 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3255 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3256 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3259 cmdline_parse_inst_t cmd_csum_tunnel = {
3260 .f = cmd_csum_tunnel_parsed,
3262 .help_str = "enable/disable parsing of tunnels for csum engine: "
3263 "csum parse_tunnel on|off <tx-port>",
3265 (void *)&cmd_csum_tunnel_csum,
3266 (void *)&cmd_csum_tunnel_parse,
3267 (void *)&cmd_csum_tunnel_onoff,
3268 (void *)&cmd_csum_tunnel_portid,
3273 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3274 struct cmd_tso_set_result {
3275 cmdline_fixed_string_t tso;
3276 cmdline_fixed_string_t mode;
3282 cmd_tso_set_parsed(void *parsed_result,
3283 __attribute__((unused)) struct cmdline *cl,
3284 __attribute__((unused)) void *data)
3286 struct cmd_tso_set_result *res = parsed_result;
3287 struct rte_eth_dev_info dev_info;
3289 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3292 if (!strcmp(res->mode, "set"))
3293 ports[res->port_id].tso_segsz = res->tso_segsz;
3295 if (ports[res->port_id].tso_segsz == 0)
3296 printf("TSO is disabled\n");
3298 printf("TSO segment size is %d\n",
3299 ports[res->port_id].tso_segsz);
3301 /* display warnings if configuration is not supported by the NIC */
3302 rte_eth_dev_info_get(res->port_id, &dev_info);
3303 if ((ports[res->port_id].tso_segsz != 0) &&
3304 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3305 printf("Warning: TSO enabled but not "
3306 "supported by port %d\n", res->port_id);
3310 cmdline_parse_token_string_t cmd_tso_set_tso =
3311 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3313 cmdline_parse_token_string_t cmd_tso_set_mode =
3314 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3316 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3317 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3319 cmdline_parse_token_num_t cmd_tso_set_portid =
3320 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3323 cmdline_parse_inst_t cmd_tso_set = {
3324 .f = cmd_tso_set_parsed,
3326 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3327 "tso set <tso_segsz> <port>",
3329 (void *)&cmd_tso_set_tso,
3330 (void *)&cmd_tso_set_mode,
3331 (void *)&cmd_tso_set_tso_segsz,
3332 (void *)&cmd_tso_set_portid,
3337 cmdline_parse_token_string_t cmd_tso_show_mode =
3338 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3342 cmdline_parse_inst_t cmd_tso_show = {
3343 .f = cmd_tso_set_parsed,
3345 .help_str = "Show TSO segment size for csum engine: "
3348 (void *)&cmd_tso_set_tso,
3349 (void *)&cmd_tso_show_mode,
3350 (void *)&cmd_tso_set_portid,
3355 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3356 struct cmd_set_flush_rx {
3357 cmdline_fixed_string_t set;
3358 cmdline_fixed_string_t flush_rx;
3359 cmdline_fixed_string_t mode;
3363 cmd_set_flush_rx_parsed(void *parsed_result,
3364 __attribute__((unused)) struct cmdline *cl,
3365 __attribute__((unused)) void *data)
3367 struct cmd_set_flush_rx *res = parsed_result;
3368 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3371 cmdline_parse_token_string_t cmd_setflushrx_set =
3372 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3374 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3375 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3376 flush_rx, "flush_rx");
3377 cmdline_parse_token_string_t cmd_setflushrx_mode =
3378 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3382 cmdline_parse_inst_t cmd_set_flush_rx = {
3383 .f = cmd_set_flush_rx_parsed,
3384 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3387 (void *)&cmd_setflushrx_set,
3388 (void *)&cmd_setflushrx_flush_rx,
3389 (void *)&cmd_setflushrx_mode,
3394 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3395 struct cmd_set_link_check {
3396 cmdline_fixed_string_t set;
3397 cmdline_fixed_string_t link_check;
3398 cmdline_fixed_string_t mode;
3402 cmd_set_link_check_parsed(void *parsed_result,
3403 __attribute__((unused)) struct cmdline *cl,
3404 __attribute__((unused)) void *data)
3406 struct cmd_set_link_check *res = parsed_result;
3407 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3410 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3411 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3413 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3414 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3415 link_check, "link_check");
3416 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3417 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3421 cmdline_parse_inst_t cmd_set_link_check = {
3422 .f = cmd_set_link_check_parsed,
3423 .help_str = "set link_check on|off: enable/disable link status check "
3424 "when starting/stopping a port",
3427 (void *)&cmd_setlinkcheck_set,
3428 (void *)&cmd_setlinkcheck_link_check,
3429 (void *)&cmd_setlinkcheck_mode,
3434 #ifdef RTE_NIC_BYPASS
3435 /* *** SET NIC BYPASS MODE *** */
3436 struct cmd_set_bypass_mode_result {
3437 cmdline_fixed_string_t set;
3438 cmdline_fixed_string_t bypass;
3439 cmdline_fixed_string_t mode;
3440 cmdline_fixed_string_t value;
3445 cmd_set_bypass_mode_parsed(void *parsed_result,
3446 __attribute__((unused)) struct cmdline *cl,
3447 __attribute__((unused)) void *data)
3449 struct cmd_set_bypass_mode_result *res = parsed_result;
3450 portid_t port_id = res->port_id;
3451 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3453 if (!bypass_is_supported(port_id))
3456 if (!strcmp(res->value, "bypass"))
3457 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3458 else if (!strcmp(res->value, "isolate"))
3459 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3461 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3463 /* Set the bypass mode for the relevant port. */
3464 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3465 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3469 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3470 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3472 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3473 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3475 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3476 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3478 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3479 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3480 value, "normal#bypass#isolate");
3481 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3482 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3485 cmdline_parse_inst_t cmd_set_bypass_mode = {
3486 .f = cmd_set_bypass_mode_parsed,
3487 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3488 "Set the NIC bypass mode for port_id",
3491 (void *)&cmd_setbypass_mode_set,
3492 (void *)&cmd_setbypass_mode_bypass,
3493 (void *)&cmd_setbypass_mode_mode,
3494 (void *)&cmd_setbypass_mode_value,
3495 (void *)&cmd_setbypass_mode_port,
3500 /* *** SET NIC BYPASS EVENT *** */
3501 struct cmd_set_bypass_event_result {
3502 cmdline_fixed_string_t set;
3503 cmdline_fixed_string_t bypass;
3504 cmdline_fixed_string_t event;
3505 cmdline_fixed_string_t event_value;
3506 cmdline_fixed_string_t mode;
3507 cmdline_fixed_string_t mode_value;
3512 cmd_set_bypass_event_parsed(void *parsed_result,
3513 __attribute__((unused)) struct cmdline *cl,
3514 __attribute__((unused)) void *data)
3517 struct cmd_set_bypass_event_result *res = parsed_result;
3518 portid_t port_id = res->port_id;
3519 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3520 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3522 if (!bypass_is_supported(port_id))
3525 if (!strcmp(res->event_value, "timeout"))
3526 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3527 else if (!strcmp(res->event_value, "os_on"))
3528 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3529 else if (!strcmp(res->event_value, "os_off"))
3530 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3531 else if (!strcmp(res->event_value, "power_on"))
3532 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3533 else if (!strcmp(res->event_value, "power_off"))
3534 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3536 bypass_event = RTE_BYPASS_EVENT_NONE;
3538 if (!strcmp(res->mode_value, "bypass"))
3539 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3540 else if (!strcmp(res->mode_value, "isolate"))
3541 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3543 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3545 /* Set the watchdog timeout. */
3546 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3549 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3550 (rc = rte_eth_dev_wd_timeout_store(port_id,
3551 bypass_timeout)) != 0) {
3552 printf("Failed to set timeout value %u "
3553 "for port %d, errto code: %d.\n",
3554 bypass_timeout, port_id, rc);
3558 /* Set the bypass event to transition to bypass mode. */
3559 if (0 != rte_eth_dev_bypass_event_store(port_id,
3560 bypass_event, bypass_mode)) {
3561 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3566 cmdline_parse_token_string_t cmd_setbypass_event_set =
3567 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3569 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3570 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3572 cmdline_parse_token_string_t cmd_setbypass_event_event =
3573 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3575 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3576 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3577 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3578 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3579 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3581 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3582 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3583 mode_value, "normal#bypass#isolate");
3584 cmdline_parse_token_num_t cmd_setbypass_event_port =
3585 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3588 cmdline_parse_inst_t cmd_set_bypass_event = {
3589 .f = cmd_set_bypass_event_parsed,
3590 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3591 "mode (normal|bypass|isolate) (port_id): "
3592 "Set the NIC bypass event mode for port_id",
3595 (void *)&cmd_setbypass_event_set,
3596 (void *)&cmd_setbypass_event_bypass,
3597 (void *)&cmd_setbypass_event_event,
3598 (void *)&cmd_setbypass_event_event_value,
3599 (void *)&cmd_setbypass_event_mode,
3600 (void *)&cmd_setbypass_event_mode_value,
3601 (void *)&cmd_setbypass_event_port,
3607 /* *** SET NIC BYPASS TIMEOUT *** */
3608 struct cmd_set_bypass_timeout_result {
3609 cmdline_fixed_string_t set;
3610 cmdline_fixed_string_t bypass;
3611 cmdline_fixed_string_t timeout;
3612 cmdline_fixed_string_t value;
3616 cmd_set_bypass_timeout_parsed(void *parsed_result,
3617 __attribute__((unused)) struct cmdline *cl,
3618 __attribute__((unused)) void *data)
3620 struct cmd_set_bypass_timeout_result *res = parsed_result;
3622 if (!strcmp(res->value, "1.5"))
3623 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3624 else if (!strcmp(res->value, "2"))
3625 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3626 else if (!strcmp(res->value, "3"))
3627 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3628 else if (!strcmp(res->value, "4"))
3629 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3630 else if (!strcmp(res->value, "8"))
3631 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3632 else if (!strcmp(res->value, "16"))
3633 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3634 else if (!strcmp(res->value, "32"))
3635 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3637 bypass_timeout = RTE_BYPASS_TMT_OFF;
3640 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3641 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3643 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3644 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3646 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3647 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3648 timeout, "timeout");
3649 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3650 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3651 value, "0#1.5#2#3#4#8#16#32");
3653 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3654 .f = cmd_set_bypass_timeout_parsed,
3655 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3656 "Set the NIC bypass watchdog timeout",
3659 (void *)&cmd_setbypass_timeout_set,
3660 (void *)&cmd_setbypass_timeout_bypass,
3661 (void *)&cmd_setbypass_timeout_timeout,
3662 (void *)&cmd_setbypass_timeout_value,
3667 /* *** SHOW NIC BYPASS MODE *** */
3668 struct cmd_show_bypass_config_result {
3669 cmdline_fixed_string_t show;
3670 cmdline_fixed_string_t bypass;
3671 cmdline_fixed_string_t config;
3676 cmd_show_bypass_config_parsed(void *parsed_result,
3677 __attribute__((unused)) struct cmdline *cl,
3678 __attribute__((unused)) void *data)
3680 struct cmd_show_bypass_config_result *res = parsed_result;
3681 uint32_t event_mode;
3682 uint32_t bypass_mode;
3683 portid_t port_id = res->port_id;
3684 uint32_t timeout = bypass_timeout;
3687 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3688 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3689 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3690 {"UNKNOWN", "normal", "bypass", "isolate"};
3691 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3698 int num_events = (sizeof events) / (sizeof events[0]);
3700 if (!bypass_is_supported(port_id))
3703 /* Display the bypass mode.*/
3704 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3705 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3709 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3710 bypass_mode = RTE_BYPASS_MODE_NONE;
3712 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3715 /* Display the bypass timeout.*/
3716 if (!RTE_BYPASS_TMT_VALID(timeout))
3717 timeout = RTE_BYPASS_TMT_OFF;
3719 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3721 /* Display the bypass events and associated modes. */
3722 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3724 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3725 printf("\tFailed to get bypass mode for event = %s\n",
3728 if (!RTE_BYPASS_MODE_VALID(event_mode))
3729 event_mode = RTE_BYPASS_MODE_NONE;
3731 printf("\tbypass event: %-16s = %s\n", events[i],
3737 cmdline_parse_token_string_t cmd_showbypass_config_show =
3738 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3740 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3741 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3743 cmdline_parse_token_string_t cmd_showbypass_config_config =
3744 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3746 cmdline_parse_token_num_t cmd_showbypass_config_port =
3747 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3750 cmdline_parse_inst_t cmd_show_bypass_config = {
3751 .f = cmd_show_bypass_config_parsed,
3752 .help_str = "show bypass config (port_id): "
3753 "Show the NIC bypass config for port_id",
3756 (void *)&cmd_showbypass_config_show,
3757 (void *)&cmd_showbypass_config_bypass,
3758 (void *)&cmd_showbypass_config_config,
3759 (void *)&cmd_showbypass_config_port,
3765 #ifdef RTE_LIBRTE_PMD_BOND
3766 /* *** SET BONDING MODE *** */
3767 struct cmd_set_bonding_mode_result {
3768 cmdline_fixed_string_t set;
3769 cmdline_fixed_string_t bonding;
3770 cmdline_fixed_string_t mode;
3775 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3776 __attribute__((unused)) struct cmdline *cl,
3777 __attribute__((unused)) void *data)
3779 struct cmd_set_bonding_mode_result *res = parsed_result;
3780 portid_t port_id = res->port_id;
3782 /* Set the bonding mode for the relevant port. */
3783 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3784 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3787 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3788 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3790 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3791 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3792 bonding, "bonding");
3793 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3794 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3796 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3797 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3799 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3800 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3803 cmdline_parse_inst_t cmd_set_bonding_mode = {
3804 .f = cmd_set_bonding_mode_parsed,
3805 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3808 (void *) &cmd_setbonding_mode_set,
3809 (void *) &cmd_setbonding_mode_bonding,
3810 (void *) &cmd_setbonding_mode_mode,
3811 (void *) &cmd_setbonding_mode_value,
3812 (void *) &cmd_setbonding_mode_port,
3817 /* *** SET BALANCE XMIT POLICY *** */
3818 struct cmd_set_bonding_balance_xmit_policy_result {
3819 cmdline_fixed_string_t set;
3820 cmdline_fixed_string_t bonding;
3821 cmdline_fixed_string_t balance_xmit_policy;
3823 cmdline_fixed_string_t policy;
3826 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3827 __attribute__((unused)) struct cmdline *cl,
3828 __attribute__((unused)) void *data)
3830 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3831 portid_t port_id = res->port_id;
3834 if (!strcmp(res->policy, "l2")) {
3835 policy = BALANCE_XMIT_POLICY_LAYER2;
3836 } else if (!strcmp(res->policy, "l23")) {
3837 policy = BALANCE_XMIT_POLICY_LAYER23;
3838 } else if (!strcmp(res->policy, "l34")) {
3839 policy = BALANCE_XMIT_POLICY_LAYER34;
3841 printf("\t Invalid xmit policy selection");
3845 /* Set the bonding mode for the relevant port. */
3846 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3847 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3852 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3853 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3855 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3856 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3857 bonding, "bonding");
3858 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3859 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3860 balance_xmit_policy, "balance_xmit_policy");
3861 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3862 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3864 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3865 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3866 policy, "l2#l23#l34");
3868 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3869 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3870 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3873 (void *)&cmd_setbonding_balance_xmit_policy_set,
3874 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3875 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3876 (void *)&cmd_setbonding_balance_xmit_policy_port,
3877 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3882 /* *** SHOW NIC BONDING CONFIGURATION *** */
3883 struct cmd_show_bonding_config_result {
3884 cmdline_fixed_string_t show;
3885 cmdline_fixed_string_t bonding;
3886 cmdline_fixed_string_t config;
3890 static void cmd_show_bonding_config_parsed(void *parsed_result,
3891 __attribute__((unused)) struct cmdline *cl,
3892 __attribute__((unused)) void *data)
3894 struct cmd_show_bonding_config_result *res = parsed_result;
3896 uint8_t slaves[RTE_MAX_ETHPORTS];
3897 int num_slaves, num_active_slaves;
3900 portid_t port_id = res->port_id;
3902 /* Display the bonding mode.*/
3903 bonding_mode = rte_eth_bond_mode_get(port_id);
3904 if (bonding_mode < 0) {
3905 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3908 printf("\tBonding mode: %d\n", bonding_mode);
3910 if (bonding_mode == BONDING_MODE_BALANCE) {
3911 int balance_xmit_policy;
3913 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3914 if (balance_xmit_policy < 0) {
3915 printf("\tFailed to get balance xmit policy for port = %d\n",
3919 printf("\tBalance Xmit Policy: ");
3921 switch (balance_xmit_policy) {
3922 case BALANCE_XMIT_POLICY_LAYER2:
3923 printf("BALANCE_XMIT_POLICY_LAYER2");
3925 case BALANCE_XMIT_POLICY_LAYER23:
3926 printf("BALANCE_XMIT_POLICY_LAYER23");
3928 case BALANCE_XMIT_POLICY_LAYER34:
3929 printf("BALANCE_XMIT_POLICY_LAYER34");
3936 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3938 if (num_slaves < 0) {
3939 printf("\tFailed to get slave list for port = %d\n", port_id);
3942 if (num_slaves > 0) {
3943 printf("\tSlaves (%d): [", num_slaves);
3944 for (i = 0; i < num_slaves - 1; i++)
3945 printf("%d ", slaves[i]);
3947 printf("%d]\n", slaves[num_slaves - 1]);
3949 printf("\tSlaves: []\n");
3953 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3956 if (num_active_slaves < 0) {
3957 printf("\tFailed to get active slave list for port = %d\n", port_id);
3960 if (num_active_slaves > 0) {
3961 printf("\tActive Slaves (%d): [", num_active_slaves);
3962 for (i = 0; i < num_active_slaves - 1; i++)
3963 printf("%d ", slaves[i]);
3965 printf("%d]\n", slaves[num_active_slaves - 1]);
3968 printf("\tActive Slaves: []\n");
3972 primary_id = rte_eth_bond_primary_get(port_id);
3973 if (primary_id < 0) {
3974 printf("\tFailed to get primary slave for port = %d\n", port_id);
3977 printf("\tPrimary: [%d]\n", primary_id);
3981 cmdline_parse_token_string_t cmd_showbonding_config_show =
3982 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3984 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3985 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3986 bonding, "bonding");
3987 cmdline_parse_token_string_t cmd_showbonding_config_config =
3988 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3990 cmdline_parse_token_num_t cmd_showbonding_config_port =
3991 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3994 cmdline_parse_inst_t cmd_show_bonding_config = {
3995 .f = cmd_show_bonding_config_parsed,
3996 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3999 (void *)&cmd_showbonding_config_show,
4000 (void *)&cmd_showbonding_config_bonding,
4001 (void *)&cmd_showbonding_config_config,
4002 (void *)&cmd_showbonding_config_port,
4007 /* *** SET BONDING PRIMARY *** */
4008 struct cmd_set_bonding_primary_result {
4009 cmdline_fixed_string_t set;
4010 cmdline_fixed_string_t bonding;
4011 cmdline_fixed_string_t primary;
4016 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4017 __attribute__((unused)) struct cmdline *cl,
4018 __attribute__((unused)) void *data)
4020 struct cmd_set_bonding_primary_result *res = parsed_result;
4021 portid_t master_port_id = res->port_id;
4022 portid_t slave_port_id = res->slave_id;
4024 /* Set the primary slave for a bonded device. */
4025 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4026 printf("\t Failed to set primary slave for port = %d.\n",
4033 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4034 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4036 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4037 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4038 bonding, "bonding");
4039 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4040 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4041 primary, "primary");
4042 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4043 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4045 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4046 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4049 cmdline_parse_inst_t cmd_set_bonding_primary = {
4050 .f = cmd_set_bonding_primary_parsed,
4051 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4054 (void *)&cmd_setbonding_primary_set,
4055 (void *)&cmd_setbonding_primary_bonding,
4056 (void *)&cmd_setbonding_primary_primary,
4057 (void *)&cmd_setbonding_primary_slave,
4058 (void *)&cmd_setbonding_primary_port,
4063 /* *** ADD SLAVE *** */
4064 struct cmd_add_bonding_slave_result {
4065 cmdline_fixed_string_t add;
4066 cmdline_fixed_string_t bonding;
4067 cmdline_fixed_string_t slave;
4072 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4073 __attribute__((unused)) struct cmdline *cl,
4074 __attribute__((unused)) void *data)
4076 struct cmd_add_bonding_slave_result *res = parsed_result;
4077 portid_t master_port_id = res->port_id;
4078 portid_t slave_port_id = res->slave_id;
4080 /* Set the primary slave for a bonded device. */
4081 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4082 printf("\t Failed to add slave %d to master port = %d.\n",
4083 slave_port_id, master_port_id);
4087 set_port_slave_flag(slave_port_id);
4090 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4091 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4093 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4094 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4095 bonding, "bonding");
4096 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4097 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4099 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4100 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4102 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4103 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4106 cmdline_parse_inst_t cmd_add_bonding_slave = {
4107 .f = cmd_add_bonding_slave_parsed,
4108 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4111 (void *)&cmd_addbonding_slave_add,
4112 (void *)&cmd_addbonding_slave_bonding,
4113 (void *)&cmd_addbonding_slave_slave,
4114 (void *)&cmd_addbonding_slave_slaveid,
4115 (void *)&cmd_addbonding_slave_port,
4120 /* *** REMOVE SLAVE *** */
4121 struct cmd_remove_bonding_slave_result {
4122 cmdline_fixed_string_t remove;
4123 cmdline_fixed_string_t bonding;
4124 cmdline_fixed_string_t slave;
4129 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4130 __attribute__((unused)) struct cmdline *cl,
4131 __attribute__((unused)) void *data)
4133 struct cmd_remove_bonding_slave_result *res = parsed_result;
4134 portid_t master_port_id = res->port_id;
4135 portid_t slave_port_id = res->slave_id;
4137 /* Set the primary slave for a bonded device. */
4138 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4139 printf("\t Failed to remove slave %d from master port = %d.\n",
4140 slave_port_id, master_port_id);
4144 clear_port_slave_flag(slave_port_id);
4147 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4148 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4150 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4151 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4152 bonding, "bonding");
4153 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4154 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4156 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4157 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4159 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4160 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4163 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4164 .f = cmd_remove_bonding_slave_parsed,
4165 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4168 (void *)&cmd_removebonding_slave_remove,
4169 (void *)&cmd_removebonding_slave_bonding,
4170 (void *)&cmd_removebonding_slave_slave,
4171 (void *)&cmd_removebonding_slave_slaveid,
4172 (void *)&cmd_removebonding_slave_port,
4177 /* *** CREATE BONDED DEVICE *** */
4178 struct cmd_create_bonded_device_result {
4179 cmdline_fixed_string_t create;
4180 cmdline_fixed_string_t bonded;
4181 cmdline_fixed_string_t device;
4186 static int bond_dev_num = 0;
4188 static void cmd_create_bonded_device_parsed(void *parsed_result,
4189 __attribute__((unused)) struct cmdline *cl,
4190 __attribute__((unused)) void *data)
4192 struct cmd_create_bonded_device_result *res = parsed_result;
4193 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4196 if (test_done == 0) {
4197 printf("Please stop forwarding first\n");
4201 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4204 /* Create a new bonded device. */
4205 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4207 printf("\t Failed to create bonded device.\n");
4210 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4213 /* Update number of ports */
4214 nb_ports = rte_eth_dev_count();
4215 reconfig(port_id, res->socket);
4216 rte_eth_promiscuous_enable(port_id);
4217 ports[port_id].enabled = 1;
4222 cmdline_parse_token_string_t cmd_createbonded_device_create =
4223 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4225 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4226 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4228 cmdline_parse_token_string_t cmd_createbonded_device_device =
4229 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4231 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4232 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4234 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4235 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4238 cmdline_parse_inst_t cmd_create_bonded_device = {
4239 .f = cmd_create_bonded_device_parsed,
4240 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4243 (void *)&cmd_createbonded_device_create,
4244 (void *)&cmd_createbonded_device_bonded,
4245 (void *)&cmd_createbonded_device_device,
4246 (void *)&cmd_createbonded_device_mode,
4247 (void *)&cmd_createbonded_device_socket,
4252 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4253 struct cmd_set_bond_mac_addr_result {
4254 cmdline_fixed_string_t set;
4255 cmdline_fixed_string_t bonding;
4256 cmdline_fixed_string_t mac_addr;
4258 struct ether_addr address;
4261 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4262 __attribute__((unused)) struct cmdline *cl,
4263 __attribute__((unused)) void *data)
4265 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4268 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4271 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4273 /* check the return value and print it if is < 0 */
4275 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4278 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4279 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4280 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4281 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4283 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4284 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4286 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4287 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4288 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4289 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4291 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4292 .f = cmd_set_bond_mac_addr_parsed,
4294 .help_str = "set bonding mac_addr (port_id) (address): ",
4296 (void *)&cmd_set_bond_mac_addr_set,
4297 (void *)&cmd_set_bond_mac_addr_bonding,
4298 (void *)&cmd_set_bond_mac_addr_mac,
4299 (void *)&cmd_set_bond_mac_addr_portnum,
4300 (void *)&cmd_set_bond_mac_addr_addr,
4306 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4307 struct cmd_set_bond_mon_period_result {
4308 cmdline_fixed_string_t set;
4309 cmdline_fixed_string_t bonding;
4310 cmdline_fixed_string_t mon_period;
4315 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4316 __attribute__((unused)) struct cmdline *cl,
4317 __attribute__((unused)) void *data)
4319 struct cmd_set_bond_mon_period_result *res = parsed_result;
4322 if (res->port_num >= nb_ports) {
4323 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4327 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4329 /* check the return value and print it if is < 0 */
4331 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4334 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4335 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4337 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4338 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4339 bonding, "bonding");
4340 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4341 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4342 mon_period, "mon_period");
4343 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4344 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4346 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4347 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4350 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4351 .f = cmd_set_bond_mon_period_parsed,
4353 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4355 (void *)&cmd_set_bond_mon_period_set,
4356 (void *)&cmd_set_bond_mon_period_bonding,
4357 (void *)&cmd_set_bond_mon_period_mon_period,
4358 (void *)&cmd_set_bond_mon_period_portnum,
4359 (void *)&cmd_set_bond_mon_period_period_ms,
4364 #endif /* RTE_LIBRTE_PMD_BOND */
4366 /* *** SET FORWARDING MODE *** */
4367 struct cmd_set_fwd_mode_result {
4368 cmdline_fixed_string_t set;
4369 cmdline_fixed_string_t fwd;
4370 cmdline_fixed_string_t mode;
4373 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4374 __attribute__((unused)) struct cmdline *cl,
4375 __attribute__((unused)) void *data)
4377 struct cmd_set_fwd_mode_result *res = parsed_result;
4379 set_pkt_forwarding_mode(res->mode);
4382 cmdline_parse_token_string_t cmd_setfwd_set =
4383 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4384 cmdline_parse_token_string_t cmd_setfwd_fwd =
4385 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4386 cmdline_parse_token_string_t cmd_setfwd_mode =
4387 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4388 "" /* defined at init */);
4390 cmdline_parse_inst_t cmd_set_fwd_mode = {
4391 .f = cmd_set_fwd_mode_parsed,
4393 .help_str = NULL, /* defined at init */
4395 (void *)&cmd_setfwd_set,
4396 (void *)&cmd_setfwd_fwd,
4397 (void *)&cmd_setfwd_mode,
4402 static void cmd_set_fwd_mode_init(void)
4405 static char token[128];
4406 static char help[256];
4407 cmdline_parse_token_string_t *token_struct;
4409 modes = list_pkt_forwarding_modes();
4410 snprintf(help, sizeof help, "set fwd %s - "
4411 "set packet forwarding mode", modes);
4412 cmd_set_fwd_mode.help_str = help;
4414 /* string token separator is # */
4415 for (c = token; *modes != '\0'; modes++)
4420 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4421 token_struct->string_data.str = token;
4424 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4425 struct cmd_set_burst_tx_retry_result {
4426 cmdline_fixed_string_t set;
4427 cmdline_fixed_string_t burst;
4428 cmdline_fixed_string_t tx;
4429 cmdline_fixed_string_t delay;
4431 cmdline_fixed_string_t retry;
4435 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4436 __attribute__((unused)) struct cmdline *cl,
4437 __attribute__((unused)) void *data)
4439 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4441 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4442 && !strcmp(res->tx, "tx")) {
4443 if (!strcmp(res->delay, "delay"))
4444 burst_tx_delay_time = res->time;
4445 if (!strcmp(res->retry, "retry"))
4446 burst_tx_retry_num = res->retry_num;
4451 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4452 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4453 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4454 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4456 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4457 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4458 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4459 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4460 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4461 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4462 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4463 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4464 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4465 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4467 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4468 .f = cmd_set_burst_tx_retry_parsed,
4469 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4471 (void *)&cmd_set_burst_tx_retry_set,
4472 (void *)&cmd_set_burst_tx_retry_burst,
4473 (void *)&cmd_set_burst_tx_retry_tx,
4474 (void *)&cmd_set_burst_tx_retry_delay,
4475 (void *)&cmd_set_burst_tx_retry_time,
4476 (void *)&cmd_set_burst_tx_retry_retry,
4477 (void *)&cmd_set_burst_tx_retry_retry_num,
4482 /* *** SET PROMISC MODE *** */
4483 struct cmd_set_promisc_mode_result {
4484 cmdline_fixed_string_t set;
4485 cmdline_fixed_string_t promisc;
4486 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4487 uint8_t port_num; /* valid if "allports" argument == 0 */
4488 cmdline_fixed_string_t mode;
4491 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4492 __attribute__((unused)) struct cmdline *cl,
4495 struct cmd_set_promisc_mode_result *res = parsed_result;
4499 if (!strcmp(res->mode, "on"))
4506 FOREACH_PORT(i, ports) {
4508 rte_eth_promiscuous_enable(i);
4510 rte_eth_promiscuous_disable(i);
4515 rte_eth_promiscuous_enable(res->port_num);
4517 rte_eth_promiscuous_disable(res->port_num);
4521 cmdline_parse_token_string_t cmd_setpromisc_set =
4522 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4523 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4524 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4526 cmdline_parse_token_string_t cmd_setpromisc_portall =
4527 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4529 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4530 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4532 cmdline_parse_token_string_t cmd_setpromisc_mode =
4533 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4536 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4537 .f = cmd_set_promisc_mode_parsed,
4539 .help_str = "set promisc all on|off: set promisc mode for all ports",
4541 (void *)&cmd_setpromisc_set,
4542 (void *)&cmd_setpromisc_promisc,
4543 (void *)&cmd_setpromisc_portall,
4544 (void *)&cmd_setpromisc_mode,
4549 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4550 .f = cmd_set_promisc_mode_parsed,
4552 .help_str = "set promisc X on|off: set promisc mode on port X",
4554 (void *)&cmd_setpromisc_set,
4555 (void *)&cmd_setpromisc_promisc,
4556 (void *)&cmd_setpromisc_portnum,
4557 (void *)&cmd_setpromisc_mode,
4562 /* *** SET ALLMULTI MODE *** */
4563 struct cmd_set_allmulti_mode_result {
4564 cmdline_fixed_string_t set;
4565 cmdline_fixed_string_t allmulti;
4566 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4567 uint8_t port_num; /* valid if "allports" argument == 0 */
4568 cmdline_fixed_string_t mode;
4571 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4572 __attribute__((unused)) struct cmdline *cl,
4575 struct cmd_set_allmulti_mode_result *res = parsed_result;
4579 if (!strcmp(res->mode, "on"))
4586 FOREACH_PORT(i, ports) {
4588 rte_eth_allmulticast_enable(i);
4590 rte_eth_allmulticast_disable(i);
4595 rte_eth_allmulticast_enable(res->port_num);
4597 rte_eth_allmulticast_disable(res->port_num);
4601 cmdline_parse_token_string_t cmd_setallmulti_set =
4602 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4603 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4604 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4606 cmdline_parse_token_string_t cmd_setallmulti_portall =
4607 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4609 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4610 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4612 cmdline_parse_token_string_t cmd_setallmulti_mode =
4613 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4616 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4617 .f = cmd_set_allmulti_mode_parsed,
4619 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4621 (void *)&cmd_setallmulti_set,
4622 (void *)&cmd_setallmulti_allmulti,
4623 (void *)&cmd_setallmulti_portall,
4624 (void *)&cmd_setallmulti_mode,
4629 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4630 .f = cmd_set_allmulti_mode_parsed,
4632 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4634 (void *)&cmd_setallmulti_set,
4635 (void *)&cmd_setallmulti_allmulti,
4636 (void *)&cmd_setallmulti_portnum,
4637 (void *)&cmd_setallmulti_mode,
4642 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4643 struct cmd_link_flow_ctrl_set_result {
4644 cmdline_fixed_string_t set;
4645 cmdline_fixed_string_t flow_ctrl;
4646 cmdline_fixed_string_t rx;
4647 cmdline_fixed_string_t rx_lfc_mode;
4648 cmdline_fixed_string_t tx;
4649 cmdline_fixed_string_t tx_lfc_mode;
4650 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4651 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4652 cmdline_fixed_string_t autoneg_str;
4653 cmdline_fixed_string_t autoneg;
4654 cmdline_fixed_string_t hw_str;
4655 uint32_t high_water;
4656 cmdline_fixed_string_t lw_str;
4658 cmdline_fixed_string_t pt_str;
4659 uint16_t pause_time;
4660 cmdline_fixed_string_t xon_str;
4665 cmdline_parse_token_string_t cmd_lfc_set_set =
4666 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4668 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4669 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4670 flow_ctrl, "flow_ctrl");
4671 cmdline_parse_token_string_t cmd_lfc_set_rx =
4672 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4674 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4675 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4676 rx_lfc_mode, "on#off");
4677 cmdline_parse_token_string_t cmd_lfc_set_tx =
4678 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4680 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4681 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4682 tx_lfc_mode, "on#off");
4683 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4684 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4685 hw_str, "high_water");
4686 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4687 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4688 high_water, UINT32);
4689 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4690 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4691 lw_str, "low_water");
4692 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4693 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4695 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4696 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4697 pt_str, "pause_time");
4698 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4699 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4700 pause_time, UINT16);
4701 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4702 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4703 xon_str, "send_xon");
4704 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4705 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4707 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4708 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4709 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4710 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4711 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4712 mac_ctrl_frame_fwd_mode, "on#off");
4713 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4714 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4715 autoneg_str, "autoneg");
4716 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4717 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4719 cmdline_parse_token_num_t cmd_lfc_set_portid =
4720 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4723 /* forward declaration */
4725 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4728 cmdline_parse_inst_t cmd_link_flow_control_set = {
4729 .f = cmd_link_flow_ctrl_set_parsed,
4731 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4732 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4733 autoneg on|off port_id",
4735 (void *)&cmd_lfc_set_set,
4736 (void *)&cmd_lfc_set_flow_ctrl,
4737 (void *)&cmd_lfc_set_rx,
4738 (void *)&cmd_lfc_set_rx_mode,
4739 (void *)&cmd_lfc_set_tx,
4740 (void *)&cmd_lfc_set_tx_mode,
4741 (void *)&cmd_lfc_set_high_water,
4742 (void *)&cmd_lfc_set_low_water,
4743 (void *)&cmd_lfc_set_pause_time,
4744 (void *)&cmd_lfc_set_send_xon,
4745 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4746 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4747 (void *)&cmd_lfc_set_autoneg_str,
4748 (void *)&cmd_lfc_set_autoneg,
4749 (void *)&cmd_lfc_set_portid,
4754 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4755 .f = cmd_link_flow_ctrl_set_parsed,
4756 .data = (void *)&cmd_link_flow_control_set_rx,
4757 .help_str = "Change rx flow control parameter: set flow_ctrl "
4758 "rx on|off port_id",
4760 (void *)&cmd_lfc_set_set,
4761 (void *)&cmd_lfc_set_flow_ctrl,
4762 (void *)&cmd_lfc_set_rx,
4763 (void *)&cmd_lfc_set_rx_mode,
4764 (void *)&cmd_lfc_set_portid,
4769 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4770 .f = cmd_link_flow_ctrl_set_parsed,
4771 .data = (void *)&cmd_link_flow_control_set_tx,
4772 .help_str = "Change tx flow control parameter: set flow_ctrl "
4773 "tx on|off port_id",
4775 (void *)&cmd_lfc_set_set,
4776 (void *)&cmd_lfc_set_flow_ctrl,
4777 (void *)&cmd_lfc_set_tx,
4778 (void *)&cmd_lfc_set_tx_mode,
4779 (void *)&cmd_lfc_set_portid,
4784 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4785 .f = cmd_link_flow_ctrl_set_parsed,
4786 .data = (void *)&cmd_link_flow_control_set_hw,
4787 .help_str = "Change high water flow control parameter: set flow_ctrl "
4788 "high_water value port_id",
4790 (void *)&cmd_lfc_set_set,
4791 (void *)&cmd_lfc_set_flow_ctrl,
4792 (void *)&cmd_lfc_set_high_water_str,
4793 (void *)&cmd_lfc_set_high_water,
4794 (void *)&cmd_lfc_set_portid,
4799 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4800 .f = cmd_link_flow_ctrl_set_parsed,
4801 .data = (void *)&cmd_link_flow_control_set_lw,
4802 .help_str = "Change low water flow control parameter: set flow_ctrl "
4803 "low_water value port_id",
4805 (void *)&cmd_lfc_set_set,
4806 (void *)&cmd_lfc_set_flow_ctrl,
4807 (void *)&cmd_lfc_set_low_water_str,
4808 (void *)&cmd_lfc_set_low_water,
4809 (void *)&cmd_lfc_set_portid,
4814 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4815 .f = cmd_link_flow_ctrl_set_parsed,
4816 .data = (void *)&cmd_link_flow_control_set_pt,
4817 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4818 "pause_time value port_id",
4820 (void *)&cmd_lfc_set_set,
4821 (void *)&cmd_lfc_set_flow_ctrl,
4822 (void *)&cmd_lfc_set_pause_time_str,
4823 (void *)&cmd_lfc_set_pause_time,
4824 (void *)&cmd_lfc_set_portid,
4829 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4830 .f = cmd_link_flow_ctrl_set_parsed,
4831 .data = (void *)&cmd_link_flow_control_set_xon,
4832 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4833 "send_xon value port_id",
4835 (void *)&cmd_lfc_set_set,
4836 (void *)&cmd_lfc_set_flow_ctrl,
4837 (void *)&cmd_lfc_set_send_xon_str,
4838 (void *)&cmd_lfc_set_send_xon,
4839 (void *)&cmd_lfc_set_portid,
4844 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4845 .f = cmd_link_flow_ctrl_set_parsed,
4846 .data = (void *)&cmd_link_flow_control_set_macfwd,
4847 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4848 "mac_ctrl_frame_fwd on|off port_id",
4850 (void *)&cmd_lfc_set_set,
4851 (void *)&cmd_lfc_set_flow_ctrl,
4852 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4853 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4854 (void *)&cmd_lfc_set_portid,
4859 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4860 .f = cmd_link_flow_ctrl_set_parsed,
4861 .data = (void *)&cmd_link_flow_control_set_autoneg,
4862 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4863 "autoneg on|off port_id",
4865 (void *)&cmd_lfc_set_set,
4866 (void *)&cmd_lfc_set_flow_ctrl,
4867 (void *)&cmd_lfc_set_autoneg_str,
4868 (void *)&cmd_lfc_set_autoneg,
4869 (void *)&cmd_lfc_set_portid,
4875 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4876 __attribute__((unused)) struct cmdline *cl,
4879 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4880 cmdline_parse_inst_t *cmd = data;
4881 struct rte_eth_fc_conf fc_conf;
4887 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4888 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4889 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4890 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4892 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4893 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4896 /* Partial command line, retrieve current configuration */
4898 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4900 printf("cannot get current flow ctrl parameters, return"
4901 "code = %d\n", ret);
4905 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4906 (fc_conf.mode == RTE_FC_FULL))
4908 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4909 (fc_conf.mode == RTE_FC_FULL))
4913 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4914 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4916 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4917 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4919 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4921 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4922 fc_conf.high_water = res->high_water;
4924 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4925 fc_conf.low_water = res->low_water;
4927 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4928 fc_conf.pause_time = res->pause_time;
4930 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4931 fc_conf.send_xon = res->send_xon;
4933 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4934 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4935 fc_conf.mac_ctrl_frame_fwd = 1;
4937 fc_conf.mac_ctrl_frame_fwd = 0;
4940 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4941 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4943 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4945 printf("bad flow contrl parameter, return code = %d \n", ret);
4948 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4949 struct cmd_priority_flow_ctrl_set_result {
4950 cmdline_fixed_string_t set;
4951 cmdline_fixed_string_t pfc_ctrl;
4952 cmdline_fixed_string_t rx;
4953 cmdline_fixed_string_t rx_pfc_mode;
4954 cmdline_fixed_string_t tx;
4955 cmdline_fixed_string_t tx_pfc_mode;
4956 uint32_t high_water;
4958 uint16_t pause_time;
4964 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4965 __attribute__((unused)) struct cmdline *cl,
4966 __attribute__((unused)) void *data)
4968 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4969 struct rte_eth_pfc_conf pfc_conf;
4970 int rx_fc_enable, tx_fc_enable;
4974 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4975 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4976 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4977 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4979 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4980 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4983 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4984 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4985 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4986 pfc_conf.fc.high_water = res->high_water;
4987 pfc_conf.fc.low_water = res->low_water;
4988 pfc_conf.fc.pause_time = res->pause_time;
4989 pfc_conf.priority = res->priority;
4991 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4993 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4996 cmdline_parse_token_string_t cmd_pfc_set_set =
4997 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4999 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5000 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5001 pfc_ctrl, "pfc_ctrl");
5002 cmdline_parse_token_string_t cmd_pfc_set_rx =
5003 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5005 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5006 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5007 rx_pfc_mode, "on#off");
5008 cmdline_parse_token_string_t cmd_pfc_set_tx =
5009 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5011 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5012 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5013 tx_pfc_mode, "on#off");
5014 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5015 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5016 high_water, UINT32);
5017 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5018 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5020 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5021 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5022 pause_time, UINT16);
5023 cmdline_parse_token_num_t cmd_pfc_set_priority =
5024 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5026 cmdline_parse_token_num_t cmd_pfc_set_portid =
5027 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5030 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5031 .f = cmd_priority_flow_ctrl_set_parsed,
5033 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5034 tx on|off high_water low_water pause_time priority port_id",
5036 (void *)&cmd_pfc_set_set,
5037 (void *)&cmd_pfc_set_flow_ctrl,
5038 (void *)&cmd_pfc_set_rx,
5039 (void *)&cmd_pfc_set_rx_mode,
5040 (void *)&cmd_pfc_set_tx,
5041 (void *)&cmd_pfc_set_tx_mode,
5042 (void *)&cmd_pfc_set_high_water,
5043 (void *)&cmd_pfc_set_low_water,
5044 (void *)&cmd_pfc_set_pause_time,
5045 (void *)&cmd_pfc_set_priority,
5046 (void *)&cmd_pfc_set_portid,
5051 /* *** RESET CONFIGURATION *** */
5052 struct cmd_reset_result {
5053 cmdline_fixed_string_t reset;
5054 cmdline_fixed_string_t def;
5057 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5059 __attribute__((unused)) void *data)
5061 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5062 set_def_fwd_config();
5065 cmdline_parse_token_string_t cmd_reset_set =
5066 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5067 cmdline_parse_token_string_t cmd_reset_def =
5068 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5071 cmdline_parse_inst_t cmd_reset = {
5072 .f = cmd_reset_parsed,
5074 .help_str = "set default: reset default forwarding configuration",
5076 (void *)&cmd_reset_set,
5077 (void *)&cmd_reset_def,
5082 /* *** START FORWARDING *** */
5083 struct cmd_start_result {
5084 cmdline_fixed_string_t start;
5087 cmdline_parse_token_string_t cmd_start_start =
5088 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5090 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5091 __attribute__((unused)) struct cmdline *cl,
5092 __attribute__((unused)) void *data)
5094 start_packet_forwarding(0);
5097 cmdline_parse_inst_t cmd_start = {
5098 .f = cmd_start_parsed,
5100 .help_str = "start packet forwarding",
5102 (void *)&cmd_start_start,
5107 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5108 struct cmd_start_tx_first_result {
5109 cmdline_fixed_string_t start;
5110 cmdline_fixed_string_t tx_first;
5114 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5115 __attribute__((unused)) struct cmdline *cl,
5116 __attribute__((unused)) void *data)
5118 start_packet_forwarding(1);
5121 cmdline_parse_token_string_t cmd_start_tx_first_start =
5122 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5124 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5125 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5126 tx_first, "tx_first");
5128 cmdline_parse_inst_t cmd_start_tx_first = {
5129 .f = cmd_start_tx_first_parsed,
5131 .help_str = "start packet forwarding, after sending 1 burst of packets",
5133 (void *)&cmd_start_tx_first_start,
5134 (void *)&cmd_start_tx_first_tx_first,
5139 /* *** SET LINK UP *** */
5140 struct cmd_set_link_up_result {
5141 cmdline_fixed_string_t set;
5142 cmdline_fixed_string_t link_up;
5143 cmdline_fixed_string_t port;
5147 cmdline_parse_token_string_t cmd_set_link_up_set =
5148 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5149 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5150 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5152 cmdline_parse_token_string_t cmd_set_link_up_port =
5153 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5154 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5155 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5157 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5158 __attribute__((unused)) struct cmdline *cl,
5159 __attribute__((unused)) void *data)
5161 struct cmd_set_link_up_result *res = parsed_result;
5162 dev_set_link_up(res->port_id);
5165 cmdline_parse_inst_t cmd_set_link_up = {
5166 .f = cmd_set_link_up_parsed,
5168 .help_str = "set link-up port (port id)",
5170 (void *)&cmd_set_link_up_set,
5171 (void *)&cmd_set_link_up_link_up,
5172 (void *)&cmd_set_link_up_port,
5173 (void *)&cmd_set_link_up_port_id,
5178 /* *** SET LINK DOWN *** */
5179 struct cmd_set_link_down_result {
5180 cmdline_fixed_string_t set;
5181 cmdline_fixed_string_t link_down;
5182 cmdline_fixed_string_t port;
5186 cmdline_parse_token_string_t cmd_set_link_down_set =
5187 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5188 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5189 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5191 cmdline_parse_token_string_t cmd_set_link_down_port =
5192 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5193 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5194 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5196 static void cmd_set_link_down_parsed(
5197 __attribute__((unused)) void *parsed_result,
5198 __attribute__((unused)) struct cmdline *cl,
5199 __attribute__((unused)) void *data)
5201 struct cmd_set_link_down_result *res = parsed_result;
5202 dev_set_link_down(res->port_id);
5205 cmdline_parse_inst_t cmd_set_link_down = {
5206 .f = cmd_set_link_down_parsed,
5208 .help_str = "set link-down port (port id)",
5210 (void *)&cmd_set_link_down_set,
5211 (void *)&cmd_set_link_down_link_down,
5212 (void *)&cmd_set_link_down_port,
5213 (void *)&cmd_set_link_down_port_id,
5218 /* *** SHOW CFG *** */
5219 struct cmd_showcfg_result {
5220 cmdline_fixed_string_t show;
5221 cmdline_fixed_string_t cfg;
5222 cmdline_fixed_string_t what;
5225 static void cmd_showcfg_parsed(void *parsed_result,
5226 __attribute__((unused)) struct cmdline *cl,
5227 __attribute__((unused)) void *data)
5229 struct cmd_showcfg_result *res = parsed_result;
5230 if (!strcmp(res->what, "rxtx"))
5231 rxtx_config_display();
5232 else if (!strcmp(res->what, "cores"))
5233 fwd_lcores_config_display();
5234 else if (!strcmp(res->what, "fwd"))
5235 fwd_config_display();
5238 cmdline_parse_token_string_t cmd_showcfg_show =
5239 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5240 cmdline_parse_token_string_t cmd_showcfg_port =
5241 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5242 cmdline_parse_token_string_t cmd_showcfg_what =
5243 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5246 cmdline_parse_inst_t cmd_showcfg = {
5247 .f = cmd_showcfg_parsed,
5249 .help_str = "show config rxtx|cores|fwd",
5251 (void *)&cmd_showcfg_show,
5252 (void *)&cmd_showcfg_port,
5253 (void *)&cmd_showcfg_what,
5258 /* *** SHOW ALL PORT INFO *** */
5259 struct cmd_showportall_result {
5260 cmdline_fixed_string_t show;
5261 cmdline_fixed_string_t port;
5262 cmdline_fixed_string_t what;
5263 cmdline_fixed_string_t all;
5266 static void cmd_showportall_parsed(void *parsed_result,
5267 __attribute__((unused)) struct cmdline *cl,
5268 __attribute__((unused)) void *data)
5272 struct cmd_showportall_result *res = parsed_result;
5273 if (!strcmp(res->show, "clear")) {
5274 if (!strcmp(res->what, "stats"))
5275 FOREACH_PORT(i, ports)
5277 else if (!strcmp(res->what, "xstats"))
5278 FOREACH_PORT(i, ports)
5279 nic_xstats_clear(i);
5280 } else if (!strcmp(res->what, "info"))
5281 FOREACH_PORT(i, ports)
5282 port_infos_display(i);
5283 else if (!strcmp(res->what, "stats"))
5284 FOREACH_PORT(i, ports)
5285 nic_stats_display(i);
5286 else if (!strcmp(res->what, "xstats"))
5287 FOREACH_PORT(i, ports)
5288 nic_xstats_display(i);
5289 else if (!strcmp(res->what, "fdir"))
5290 FOREACH_PORT(i, ports)
5292 else if (!strcmp(res->what, "stat_qmap"))
5293 FOREACH_PORT(i, ports)
5294 nic_stats_mapping_display(i);
5295 else if (!strcmp(res->what, "dcb_tc"))
5296 FOREACH_PORT(i, ports)
5297 port_dcb_info_display(i);
5300 cmdline_parse_token_string_t cmd_showportall_show =
5301 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5303 cmdline_parse_token_string_t cmd_showportall_port =
5304 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5305 cmdline_parse_token_string_t cmd_showportall_what =
5306 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5307 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5308 cmdline_parse_token_string_t cmd_showportall_all =
5309 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5310 cmdline_parse_inst_t cmd_showportall = {
5311 .f = cmd_showportall_parsed,
5313 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5315 (void *)&cmd_showportall_show,
5316 (void *)&cmd_showportall_port,
5317 (void *)&cmd_showportall_what,
5318 (void *)&cmd_showportall_all,
5323 /* *** SHOW PORT INFO *** */
5324 struct cmd_showport_result {
5325 cmdline_fixed_string_t show;
5326 cmdline_fixed_string_t port;
5327 cmdline_fixed_string_t what;
5331 static void cmd_showport_parsed(void *parsed_result,
5332 __attribute__((unused)) struct cmdline *cl,
5333 __attribute__((unused)) void *data)
5335 struct cmd_showport_result *res = parsed_result;
5336 if (!strcmp(res->show, "clear")) {
5337 if (!strcmp(res->what, "stats"))
5338 nic_stats_clear(res->portnum);
5339 else if (!strcmp(res->what, "xstats"))
5340 nic_xstats_clear(res->portnum);
5341 } else if (!strcmp(res->what, "info"))
5342 port_infos_display(res->portnum);
5343 else if (!strcmp(res->what, "stats"))
5344 nic_stats_display(res->portnum);
5345 else if (!strcmp(res->what, "xstats"))
5346 nic_xstats_display(res->portnum);
5347 else if (!strcmp(res->what, "fdir"))
5348 fdir_get_infos(res->portnum);
5349 else if (!strcmp(res->what, "stat_qmap"))
5350 nic_stats_mapping_display(res->portnum);
5351 else if (!strcmp(res->what, "dcb_tc"))
5352 port_dcb_info_display(res->portnum);
5355 cmdline_parse_token_string_t cmd_showport_show =
5356 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5358 cmdline_parse_token_string_t cmd_showport_port =
5359 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5360 cmdline_parse_token_string_t cmd_showport_what =
5361 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5362 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5363 cmdline_parse_token_num_t cmd_showport_portnum =
5364 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5366 cmdline_parse_inst_t cmd_showport = {
5367 .f = cmd_showport_parsed,
5369 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5371 (void *)&cmd_showport_show,
5372 (void *)&cmd_showport_port,
5373 (void *)&cmd_showport_what,
5374 (void *)&cmd_showport_portnum,
5379 /* *** SHOW QUEUE INFO *** */
5380 struct cmd_showqueue_result {
5381 cmdline_fixed_string_t show;
5382 cmdline_fixed_string_t type;
5383 cmdline_fixed_string_t what;
5389 cmd_showqueue_parsed(void *parsed_result,
5390 __attribute__((unused)) struct cmdline *cl,
5391 __attribute__((unused)) void *data)
5393 struct cmd_showqueue_result *res = parsed_result;
5395 if (!strcmp(res->type, "rxq"))
5396 rx_queue_infos_display(res->portnum, res->queuenum);
5397 else if (!strcmp(res->type, "txq"))
5398 tx_queue_infos_display(res->portnum, res->queuenum);
5401 cmdline_parse_token_string_t cmd_showqueue_show =
5402 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5403 cmdline_parse_token_string_t cmd_showqueue_type =
5404 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5405 cmdline_parse_token_string_t cmd_showqueue_what =
5406 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5407 cmdline_parse_token_num_t cmd_showqueue_portnum =
5408 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5409 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5410 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5412 cmdline_parse_inst_t cmd_showqueue = {
5413 .f = cmd_showqueue_parsed,
5415 .help_str = "show rxq|txq info <port number> <queue_number>",
5417 (void *)&cmd_showqueue_show,
5418 (void *)&cmd_showqueue_type,
5419 (void *)&cmd_showqueue_what,
5420 (void *)&cmd_showqueue_portnum,
5421 (void *)&cmd_showqueue_queuenum,
5426 /* *** READ PORT REGISTER *** */
5427 struct cmd_read_reg_result {
5428 cmdline_fixed_string_t read;
5429 cmdline_fixed_string_t reg;
5435 cmd_read_reg_parsed(void *parsed_result,
5436 __attribute__((unused)) struct cmdline *cl,
5437 __attribute__((unused)) void *data)
5439 struct cmd_read_reg_result *res = parsed_result;
5440 port_reg_display(res->port_id, res->reg_off);
5443 cmdline_parse_token_string_t cmd_read_reg_read =
5444 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5445 cmdline_parse_token_string_t cmd_read_reg_reg =
5446 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5447 cmdline_parse_token_num_t cmd_read_reg_port_id =
5448 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5449 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5450 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5452 cmdline_parse_inst_t cmd_read_reg = {
5453 .f = cmd_read_reg_parsed,
5455 .help_str = "read reg port_id reg_off",
5457 (void *)&cmd_read_reg_read,
5458 (void *)&cmd_read_reg_reg,
5459 (void *)&cmd_read_reg_port_id,
5460 (void *)&cmd_read_reg_reg_off,
5465 /* *** READ PORT REGISTER BIT FIELD *** */
5466 struct cmd_read_reg_bit_field_result {
5467 cmdline_fixed_string_t read;
5468 cmdline_fixed_string_t regfield;
5476 cmd_read_reg_bit_field_parsed(void *parsed_result,
5477 __attribute__((unused)) struct cmdline *cl,
5478 __attribute__((unused)) void *data)
5480 struct cmd_read_reg_bit_field_result *res = parsed_result;
5481 port_reg_bit_field_display(res->port_id, res->reg_off,
5482 res->bit1_pos, res->bit2_pos);
5485 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5486 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5488 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5489 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5490 regfield, "regfield");
5491 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5492 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5494 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5495 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5497 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5498 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5500 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5501 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5504 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5505 .f = cmd_read_reg_bit_field_parsed,
5507 .help_str = "read regfield port_id reg_off bit_x bit_y "
5508 "(read register bit field between bit_x and bit_y included)",
5510 (void *)&cmd_read_reg_bit_field_read,
5511 (void *)&cmd_read_reg_bit_field_regfield,
5512 (void *)&cmd_read_reg_bit_field_port_id,
5513 (void *)&cmd_read_reg_bit_field_reg_off,
5514 (void *)&cmd_read_reg_bit_field_bit1_pos,
5515 (void *)&cmd_read_reg_bit_field_bit2_pos,
5520 /* *** READ PORT REGISTER BIT *** */
5521 struct cmd_read_reg_bit_result {
5522 cmdline_fixed_string_t read;
5523 cmdline_fixed_string_t regbit;
5530 cmd_read_reg_bit_parsed(void *parsed_result,
5531 __attribute__((unused)) struct cmdline *cl,
5532 __attribute__((unused)) void *data)
5534 struct cmd_read_reg_bit_result *res = parsed_result;
5535 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5538 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5539 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5540 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5541 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5543 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5544 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5545 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5546 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5547 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5548 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5550 cmdline_parse_inst_t cmd_read_reg_bit = {
5551 .f = cmd_read_reg_bit_parsed,
5553 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5555 (void *)&cmd_read_reg_bit_read,
5556 (void *)&cmd_read_reg_bit_regbit,
5557 (void *)&cmd_read_reg_bit_port_id,
5558 (void *)&cmd_read_reg_bit_reg_off,
5559 (void *)&cmd_read_reg_bit_bit_pos,
5564 /* *** WRITE PORT REGISTER *** */
5565 struct cmd_write_reg_result {
5566 cmdline_fixed_string_t write;
5567 cmdline_fixed_string_t reg;
5574 cmd_write_reg_parsed(void *parsed_result,
5575 __attribute__((unused)) struct cmdline *cl,
5576 __attribute__((unused)) void *data)
5578 struct cmd_write_reg_result *res = parsed_result;
5579 port_reg_set(res->port_id, res->reg_off, res->value);
5582 cmdline_parse_token_string_t cmd_write_reg_write =
5583 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5584 cmdline_parse_token_string_t cmd_write_reg_reg =
5585 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5586 cmdline_parse_token_num_t cmd_write_reg_port_id =
5587 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5588 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5589 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5590 cmdline_parse_token_num_t cmd_write_reg_value =
5591 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5593 cmdline_parse_inst_t cmd_write_reg = {
5594 .f = cmd_write_reg_parsed,
5596 .help_str = "write reg port_id reg_off reg_value",
5598 (void *)&cmd_write_reg_write,
5599 (void *)&cmd_write_reg_reg,
5600 (void *)&cmd_write_reg_port_id,
5601 (void *)&cmd_write_reg_reg_off,
5602 (void *)&cmd_write_reg_value,
5607 /* *** WRITE PORT REGISTER BIT FIELD *** */
5608 struct cmd_write_reg_bit_field_result {
5609 cmdline_fixed_string_t write;
5610 cmdline_fixed_string_t regfield;
5619 cmd_write_reg_bit_field_parsed(void *parsed_result,
5620 __attribute__((unused)) struct cmdline *cl,
5621 __attribute__((unused)) void *data)
5623 struct cmd_write_reg_bit_field_result *res = parsed_result;
5624 port_reg_bit_field_set(res->port_id, res->reg_off,
5625 res->bit1_pos, res->bit2_pos, res->value);
5628 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5629 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5631 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5632 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5633 regfield, "regfield");
5634 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5635 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5637 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5638 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5640 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5641 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5643 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5644 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5646 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5647 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5650 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5651 .f = cmd_write_reg_bit_field_parsed,
5653 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5654 "(set register bit field between bit_x and bit_y included)",
5656 (void *)&cmd_write_reg_bit_field_write,
5657 (void *)&cmd_write_reg_bit_field_regfield,
5658 (void *)&cmd_write_reg_bit_field_port_id,
5659 (void *)&cmd_write_reg_bit_field_reg_off,
5660 (void *)&cmd_write_reg_bit_field_bit1_pos,
5661 (void *)&cmd_write_reg_bit_field_bit2_pos,
5662 (void *)&cmd_write_reg_bit_field_value,
5667 /* *** WRITE PORT REGISTER BIT *** */
5668 struct cmd_write_reg_bit_result {
5669 cmdline_fixed_string_t write;
5670 cmdline_fixed_string_t regbit;
5678 cmd_write_reg_bit_parsed(void *parsed_result,
5679 __attribute__((unused)) struct cmdline *cl,
5680 __attribute__((unused)) void *data)
5682 struct cmd_write_reg_bit_result *res = parsed_result;
5683 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5686 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5687 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5689 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5690 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5692 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5693 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5694 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5695 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5696 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5697 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5698 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5699 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5701 cmdline_parse_inst_t cmd_write_reg_bit = {
5702 .f = cmd_write_reg_bit_parsed,
5704 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5706 (void *)&cmd_write_reg_bit_write,
5707 (void *)&cmd_write_reg_bit_regbit,
5708 (void *)&cmd_write_reg_bit_port_id,
5709 (void *)&cmd_write_reg_bit_reg_off,
5710 (void *)&cmd_write_reg_bit_bit_pos,
5711 (void *)&cmd_write_reg_bit_value,
5716 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5717 struct cmd_read_rxd_txd_result {
5718 cmdline_fixed_string_t read;
5719 cmdline_fixed_string_t rxd_txd;
5726 cmd_read_rxd_txd_parsed(void *parsed_result,
5727 __attribute__((unused)) struct cmdline *cl,
5728 __attribute__((unused)) void *data)
5730 struct cmd_read_rxd_txd_result *res = parsed_result;
5732 if (!strcmp(res->rxd_txd, "rxd"))
5733 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5734 else if (!strcmp(res->rxd_txd, "txd"))
5735 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5738 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5739 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5740 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5741 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5743 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5744 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5745 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5746 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5747 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5748 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5750 cmdline_parse_inst_t cmd_read_rxd_txd = {
5751 .f = cmd_read_rxd_txd_parsed,
5753 .help_str = "read rxd|txd port_id queue_id rxd_id",
5755 (void *)&cmd_read_rxd_txd_read,
5756 (void *)&cmd_read_rxd_txd_rxd_txd,
5757 (void *)&cmd_read_rxd_txd_port_id,
5758 (void *)&cmd_read_rxd_txd_queue_id,
5759 (void *)&cmd_read_rxd_txd_desc_id,
5765 struct cmd_quit_result {
5766 cmdline_fixed_string_t quit;
5769 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5771 __attribute__((unused)) void *data)
5777 cmdline_parse_token_string_t cmd_quit_quit =
5778 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5780 cmdline_parse_inst_t cmd_quit = {
5781 .f = cmd_quit_parsed,
5783 .help_str = "exit application",
5785 (void *)&cmd_quit_quit,
5790 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5791 struct cmd_mac_addr_result {
5792 cmdline_fixed_string_t mac_addr_cmd;
5793 cmdline_fixed_string_t what;
5795 struct ether_addr address;
5798 static void cmd_mac_addr_parsed(void *parsed_result,
5799 __attribute__((unused)) struct cmdline *cl,
5800 __attribute__((unused)) void *data)
5802 struct cmd_mac_addr_result *res = parsed_result;
5805 if (strcmp(res->what, "add") == 0)
5806 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5808 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5810 /* check the return value and print it if is < 0 */
5812 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5816 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5817 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5819 cmdline_parse_token_string_t cmd_mac_addr_what =
5820 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5822 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5823 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5824 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5825 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5827 cmdline_parse_inst_t cmd_mac_addr = {
5828 .f = cmd_mac_addr_parsed,
5830 .help_str = "mac_addr add|remove X <address>: "
5831 "add/remove MAC address on port X",
5833 (void *)&cmd_mac_addr_cmd,
5834 (void *)&cmd_mac_addr_what,
5835 (void *)&cmd_mac_addr_portnum,
5836 (void *)&cmd_mac_addr_addr,
5842 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5843 struct cmd_set_qmap_result {
5844 cmdline_fixed_string_t set;
5845 cmdline_fixed_string_t qmap;
5846 cmdline_fixed_string_t what;
5853 cmd_set_qmap_parsed(void *parsed_result,
5854 __attribute__((unused)) struct cmdline *cl,
5855 __attribute__((unused)) void *data)
5857 struct cmd_set_qmap_result *res = parsed_result;
5858 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5860 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5863 cmdline_parse_token_string_t cmd_setqmap_set =
5864 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5866 cmdline_parse_token_string_t cmd_setqmap_qmap =
5867 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5869 cmdline_parse_token_string_t cmd_setqmap_what =
5870 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5872 cmdline_parse_token_num_t cmd_setqmap_portid =
5873 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5875 cmdline_parse_token_num_t cmd_setqmap_queueid =
5876 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5878 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5879 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5882 cmdline_parse_inst_t cmd_set_qmap = {
5883 .f = cmd_set_qmap_parsed,
5885 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5887 (void *)&cmd_setqmap_set,
5888 (void *)&cmd_setqmap_qmap,
5889 (void *)&cmd_setqmap_what,
5890 (void *)&cmd_setqmap_portid,
5891 (void *)&cmd_setqmap_queueid,
5892 (void *)&cmd_setqmap_mapvalue,
5897 /* *** CONFIGURE UNICAST HASH TABLE *** */
5898 struct cmd_set_uc_hash_table {
5899 cmdline_fixed_string_t set;
5900 cmdline_fixed_string_t port;
5902 cmdline_fixed_string_t what;
5903 struct ether_addr address;
5904 cmdline_fixed_string_t mode;
5908 cmd_set_uc_hash_parsed(void *parsed_result,
5909 __attribute__((unused)) struct cmdline *cl,
5910 __attribute__((unused)) void *data)
5913 struct cmd_set_uc_hash_table *res = parsed_result;
5915 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5917 if (strcmp(res->what, "uta") == 0)
5918 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5919 &res->address,(uint8_t)is_on);
5921 printf("bad unicast hash table parameter, return code = %d \n", ret);
5925 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5926 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5928 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5929 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5931 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5932 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5934 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5935 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5937 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5938 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5940 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5941 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5944 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5945 .f = cmd_set_uc_hash_parsed,
5947 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5949 (void *)&cmd_set_uc_hash_set,
5950 (void *)&cmd_set_uc_hash_port,
5951 (void *)&cmd_set_uc_hash_portid,
5952 (void *)&cmd_set_uc_hash_what,
5953 (void *)&cmd_set_uc_hash_mac,
5954 (void *)&cmd_set_uc_hash_mode,
5959 struct cmd_set_uc_all_hash_table {
5960 cmdline_fixed_string_t set;
5961 cmdline_fixed_string_t port;
5963 cmdline_fixed_string_t what;
5964 cmdline_fixed_string_t value;
5965 cmdline_fixed_string_t mode;
5969 cmd_set_uc_all_hash_parsed(void *parsed_result,
5970 __attribute__((unused)) struct cmdline *cl,
5971 __attribute__((unused)) void *data)
5974 struct cmd_set_uc_all_hash_table *res = parsed_result;
5976 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5978 if ((strcmp(res->what, "uta") == 0) &&
5979 (strcmp(res->value, "all") == 0))
5980 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5982 printf("bad unicast hash table parameter,"
5983 "return code = %d \n", ret);
5986 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5987 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5989 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5990 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5992 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5993 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5995 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5996 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5998 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5999 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6001 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6002 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6005 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6006 .f = cmd_set_uc_all_hash_parsed,
6008 .help_str = "set port X uta all on|off (X = port number)",
6010 (void *)&cmd_set_uc_all_hash_set,
6011 (void *)&cmd_set_uc_all_hash_port,
6012 (void *)&cmd_set_uc_all_hash_portid,
6013 (void *)&cmd_set_uc_all_hash_what,
6014 (void *)&cmd_set_uc_all_hash_value,
6015 (void *)&cmd_set_uc_all_hash_mode,
6020 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6021 struct cmd_set_vf_macvlan_filter {
6022 cmdline_fixed_string_t set;
6023 cmdline_fixed_string_t port;
6025 cmdline_fixed_string_t vf;
6027 struct ether_addr address;
6028 cmdline_fixed_string_t filter_type;
6029 cmdline_fixed_string_t mode;
6033 cmd_set_vf_macvlan_parsed(void *parsed_result,
6034 __attribute__((unused)) struct cmdline *cl,
6035 __attribute__((unused)) void *data)
6038 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6039 struct rte_eth_mac_filter filter;
6041 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6043 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6045 /* set VF MAC filter */
6049 filter.dst_id = res->vf_id;
6051 if (!strcmp(res->filter_type, "exact-mac"))
6052 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6053 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6054 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6055 else if (!strcmp(res->filter_type, "hashmac"))
6056 filter.filter_type = RTE_MAC_HASH_MATCH;
6057 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6058 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6060 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6063 ret = rte_eth_dev_filter_ctrl(res->port_id,
6064 RTE_ETH_FILTER_MACVLAN,
6068 ret = rte_eth_dev_filter_ctrl(res->port_id,
6069 RTE_ETH_FILTER_MACVLAN,
6070 RTE_ETH_FILTER_DELETE,
6074 printf("bad set MAC hash parameter, return code = %d\n", ret);
6078 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6079 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6081 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6082 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6084 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6085 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6087 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6088 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6090 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6091 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6093 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6094 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6096 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6097 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6098 filter_type, "exact-mac#exact-mac-vlan"
6099 "#hashmac#hashmac-vlan");
6100 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6101 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6104 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6105 .f = cmd_set_vf_macvlan_parsed,
6107 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6108 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6110 "exact match rule:exact match of MAC or MAC and VLAN; "
6111 "hash match rule: hash match of MAC and exact match "
6114 (void *)&cmd_set_vf_macvlan_set,
6115 (void *)&cmd_set_vf_macvlan_port,
6116 (void *)&cmd_set_vf_macvlan_portid,
6117 (void *)&cmd_set_vf_macvlan_vf,
6118 (void *)&cmd_set_vf_macvlan_vf_id,
6119 (void *)&cmd_set_vf_macvlan_mac,
6120 (void *)&cmd_set_vf_macvlan_filter_type,
6121 (void *)&cmd_set_vf_macvlan_mode,
6126 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6127 struct cmd_set_vf_traffic {
6128 cmdline_fixed_string_t set;
6129 cmdline_fixed_string_t port;
6131 cmdline_fixed_string_t vf;
6133 cmdline_fixed_string_t what;
6134 cmdline_fixed_string_t mode;
6138 cmd_set_vf_traffic_parsed(void *parsed_result,
6139 __attribute__((unused)) struct cmdline *cl,
6140 __attribute__((unused)) void *data)
6142 struct cmd_set_vf_traffic *res = parsed_result;
6143 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6144 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6146 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6149 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6150 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6152 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6153 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6155 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6156 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6158 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6159 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6161 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6162 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6164 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6165 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6167 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6168 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6171 cmdline_parse_inst_t cmd_set_vf_traffic = {
6172 .f = cmd_set_vf_traffic_parsed,
6174 .help_str = "set port X vf Y rx|tx on|off"
6175 "(X = port number,Y = vf id)",
6177 (void *)&cmd_setvf_traffic_set,
6178 (void *)&cmd_setvf_traffic_port,
6179 (void *)&cmd_setvf_traffic_portid,
6180 (void *)&cmd_setvf_traffic_vf,
6181 (void *)&cmd_setvf_traffic_vfid,
6182 (void *)&cmd_setvf_traffic_what,
6183 (void *)&cmd_setvf_traffic_mode,
6188 /* *** CONFIGURE VF RECEIVE MODE *** */
6189 struct cmd_set_vf_rxmode {
6190 cmdline_fixed_string_t set;
6191 cmdline_fixed_string_t port;
6193 cmdline_fixed_string_t vf;
6195 cmdline_fixed_string_t what;
6196 cmdline_fixed_string_t mode;
6197 cmdline_fixed_string_t on;
6201 cmd_set_vf_rxmode_parsed(void *parsed_result,
6202 __attribute__((unused)) struct cmdline *cl,
6203 __attribute__((unused)) void *data)
6206 uint16_t rx_mode = 0;
6207 struct cmd_set_vf_rxmode *res = parsed_result;
6209 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6210 if (!strcmp(res->what,"rxmode")) {
6211 if (!strcmp(res->mode, "AUPE"))
6212 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6213 else if (!strcmp(res->mode, "ROPE"))
6214 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6215 else if (!strcmp(res->mode, "BAM"))
6216 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6217 else if (!strncmp(res->mode, "MPE",3))
6218 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6221 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6223 printf("bad VF receive mode parameter, return code = %d \n",
6227 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6228 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6230 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6231 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6233 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6234 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6236 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6237 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6239 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6240 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6242 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6243 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6245 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6246 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6247 mode, "AUPE#ROPE#BAM#MPE");
6248 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6249 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6252 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6253 .f = cmd_set_vf_rxmode_parsed,
6255 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6257 (void *)&cmd_set_vf_rxmode_set,
6258 (void *)&cmd_set_vf_rxmode_port,
6259 (void *)&cmd_set_vf_rxmode_portid,
6260 (void *)&cmd_set_vf_rxmode_vf,
6261 (void *)&cmd_set_vf_rxmode_vfid,
6262 (void *)&cmd_set_vf_rxmode_what,
6263 (void *)&cmd_set_vf_rxmode_mode,
6264 (void *)&cmd_set_vf_rxmode_on,
6269 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6270 struct cmd_vf_mac_addr_result {
6271 cmdline_fixed_string_t mac_addr_cmd;
6272 cmdline_fixed_string_t what;
6273 cmdline_fixed_string_t port;
6275 cmdline_fixed_string_t vf;
6277 struct ether_addr address;
6280 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6281 __attribute__((unused)) struct cmdline *cl,
6282 __attribute__((unused)) void *data)
6284 struct cmd_vf_mac_addr_result *res = parsed_result;
6287 if (strcmp(res->what, "add") == 0)
6288 ret = rte_eth_dev_mac_addr_add(res->port_num,
6289 &res->address, res->vf_num);
6291 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6295 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6296 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6297 mac_addr_cmd,"mac_addr");
6298 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6299 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6301 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6302 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6304 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6305 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6307 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6308 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6310 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6311 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6313 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6314 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6317 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6318 .f = cmd_vf_mac_addr_parsed,
6320 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6321 "Y = VF number)add MAC address filtering for a VF on port X",
6323 (void *)&cmd_vf_mac_addr_cmd,
6324 (void *)&cmd_vf_mac_addr_what,
6325 (void *)&cmd_vf_mac_addr_port,
6326 (void *)&cmd_vf_mac_addr_portnum,
6327 (void *)&cmd_vf_mac_addr_vf,
6328 (void *)&cmd_vf_mac_addr_vfnum,
6329 (void *)&cmd_vf_mac_addr_addr,
6334 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6335 struct cmd_vf_rx_vlan_filter {
6336 cmdline_fixed_string_t rx_vlan;
6337 cmdline_fixed_string_t what;
6339 cmdline_fixed_string_t port;
6341 cmdline_fixed_string_t vf;
6346 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6347 __attribute__((unused)) struct cmdline *cl,
6348 __attribute__((unused)) void *data)
6350 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6352 if (!strcmp(res->what, "add"))
6353 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6355 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6358 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6359 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6360 rx_vlan, "rx_vlan");
6361 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6362 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6364 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6365 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6367 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6368 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6370 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6371 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6373 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6374 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6376 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6377 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6380 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6381 .f = cmd_vf_rx_vlan_filter_parsed,
6383 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6384 "Y = port number,Z = hexadecimal VF mask)",
6386 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6387 (void *)&cmd_vf_rx_vlan_filter_what,
6388 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6389 (void *)&cmd_vf_rx_vlan_filter_port,
6390 (void *)&cmd_vf_rx_vlan_filter_portid,
6391 (void *)&cmd_vf_rx_vlan_filter_vf,
6392 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6397 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6398 struct cmd_queue_rate_limit_result {
6399 cmdline_fixed_string_t set;
6400 cmdline_fixed_string_t port;
6402 cmdline_fixed_string_t queue;
6404 cmdline_fixed_string_t rate;
6408 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6409 __attribute__((unused)) struct cmdline *cl,
6410 __attribute__((unused)) void *data)
6412 struct cmd_queue_rate_limit_result *res = parsed_result;
6415 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6416 && (strcmp(res->queue, "queue") == 0)
6417 && (strcmp(res->rate, "rate") == 0))
6418 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6421 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6425 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6426 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6428 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6429 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6431 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6432 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6434 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6435 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6437 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6438 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6440 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6441 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6443 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6444 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6447 cmdline_parse_inst_t cmd_queue_rate_limit = {
6448 .f = cmd_queue_rate_limit_parsed,
6450 .help_str = "set port X queue Y rate Z:(X = port number,"
6451 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6453 (void *)&cmd_queue_rate_limit_set,
6454 (void *)&cmd_queue_rate_limit_port,
6455 (void *)&cmd_queue_rate_limit_portnum,
6456 (void *)&cmd_queue_rate_limit_queue,
6457 (void *)&cmd_queue_rate_limit_queuenum,
6458 (void *)&cmd_queue_rate_limit_rate,
6459 (void *)&cmd_queue_rate_limit_ratenum,
6464 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6465 struct cmd_vf_rate_limit_result {
6466 cmdline_fixed_string_t set;
6467 cmdline_fixed_string_t port;
6469 cmdline_fixed_string_t vf;
6471 cmdline_fixed_string_t rate;
6473 cmdline_fixed_string_t q_msk;
6477 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6478 __attribute__((unused)) struct cmdline *cl,
6479 __attribute__((unused)) void *data)
6481 struct cmd_vf_rate_limit_result *res = parsed_result;
6484 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6485 && (strcmp(res->vf, "vf") == 0)
6486 && (strcmp(res->rate, "rate") == 0)
6487 && (strcmp(res->q_msk, "queue_mask") == 0))
6488 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6489 res->rate_num, res->q_msk_val);
6491 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6495 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6496 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6498 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6499 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6501 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6502 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6504 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6505 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6507 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6508 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6510 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6511 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6513 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6514 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6516 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6517 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6518 q_msk, "queue_mask");
6519 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6520 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6523 cmdline_parse_inst_t cmd_vf_rate_limit = {
6524 .f = cmd_vf_rate_limit_parsed,
6526 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6527 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6528 "for queues of VF on port X",
6530 (void *)&cmd_vf_rate_limit_set,
6531 (void *)&cmd_vf_rate_limit_port,
6532 (void *)&cmd_vf_rate_limit_portnum,
6533 (void *)&cmd_vf_rate_limit_vf,
6534 (void *)&cmd_vf_rate_limit_vfnum,
6535 (void *)&cmd_vf_rate_limit_rate,
6536 (void *)&cmd_vf_rate_limit_ratenum,
6537 (void *)&cmd_vf_rate_limit_q_msk,
6538 (void *)&cmd_vf_rate_limit_q_msk_val,
6543 /* *** ADD TUNNEL FILTER OF A PORT *** */
6544 struct cmd_tunnel_filter_result {
6545 cmdline_fixed_string_t cmd;
6546 cmdline_fixed_string_t what;
6548 struct ether_addr outer_mac;
6549 struct ether_addr inner_mac;
6550 cmdline_ipaddr_t ip_value;
6551 uint16_t inner_vlan;
6552 cmdline_fixed_string_t tunnel_type;
6553 cmdline_fixed_string_t filter_type;
6559 cmd_tunnel_filter_parsed(void *parsed_result,
6560 __attribute__((unused)) struct cmdline *cl,
6561 __attribute__((unused)) void *data)
6563 struct cmd_tunnel_filter_result *res = parsed_result;
6564 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6567 tunnel_filter_conf.outer_mac = &res->outer_mac;
6568 tunnel_filter_conf.inner_mac = &res->inner_mac;
6569 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6571 if (res->ip_value.family == AF_INET) {
6572 tunnel_filter_conf.ip_addr.ipv4_addr =
6573 res->ip_value.addr.ipv4.s_addr;
6574 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6576 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6577 &(res->ip_value.addr.ipv6),
6578 sizeof(struct in6_addr));
6579 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6582 if (!strcmp(res->filter_type, "imac-ivlan"))
6583 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6584 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6585 tunnel_filter_conf.filter_type =
6586 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6587 else if (!strcmp(res->filter_type, "imac-tenid"))
6588 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6589 else if (!strcmp(res->filter_type, "imac"))
6590 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6591 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6592 tunnel_filter_conf.filter_type =
6593 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6595 printf("The filter type is not supported");
6599 if (!strcmp(res->tunnel_type, "vxlan"))
6600 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6601 else if (!strcmp(res->tunnel_type, "nvgre"))
6602 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6604 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6608 tunnel_filter_conf.tenant_id = res->tenant_id;
6609 tunnel_filter_conf.queue_id = res->queue_num;
6610 if (!strcmp(res->what, "add"))
6611 ret = rte_eth_dev_filter_ctrl(res->port_id,
6612 RTE_ETH_FILTER_TUNNEL,
6614 &tunnel_filter_conf);
6616 ret = rte_eth_dev_filter_ctrl(res->port_id,
6617 RTE_ETH_FILTER_TUNNEL,
6618 RTE_ETH_FILTER_DELETE,
6619 &tunnel_filter_conf);
6621 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6625 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6626 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6627 cmd, "tunnel_filter");
6628 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6629 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6631 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6632 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6634 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6635 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6637 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6638 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6640 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6641 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6642 inner_vlan, UINT16);
6643 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6644 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6646 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6647 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6648 tunnel_type, "vxlan#nvgre");
6650 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6651 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6652 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6653 "imac#omac-imac-tenid");
6654 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6655 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6657 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6658 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6661 cmdline_parse_inst_t cmd_tunnel_filter = {
6662 .f = cmd_tunnel_filter_parsed,
6664 .help_str = "add/rm tunnel filter of a port: "
6665 "tunnel_filter add port_id outer_mac inner_mac ip "
6666 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6667 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6668 "imac|omac-imac-tenid) "
6669 "tenant_id queue_num",
6671 (void *)&cmd_tunnel_filter_cmd,
6672 (void *)&cmd_tunnel_filter_what,
6673 (void *)&cmd_tunnel_filter_port_id,
6674 (void *)&cmd_tunnel_filter_outer_mac,
6675 (void *)&cmd_tunnel_filter_inner_mac,
6676 (void *)&cmd_tunnel_filter_ip_value,
6677 (void *)&cmd_tunnel_filter_innner_vlan,
6678 (void *)&cmd_tunnel_filter_tunnel_type,
6679 (void *)&cmd_tunnel_filter_filter_type,
6680 (void *)&cmd_tunnel_filter_tenant_id,
6681 (void *)&cmd_tunnel_filter_queue_num,
6686 /* *** CONFIGURE TUNNEL UDP PORT *** */
6687 struct cmd_tunnel_udp_config {
6688 cmdline_fixed_string_t cmd;
6689 cmdline_fixed_string_t what;
6695 cmd_tunnel_udp_config_parsed(void *parsed_result,
6696 __attribute__((unused)) struct cmdline *cl,
6697 __attribute__((unused)) void *data)
6699 struct cmd_tunnel_udp_config *res = parsed_result;
6700 struct rte_eth_udp_tunnel tunnel_udp;
6703 tunnel_udp.udp_port = res->udp_port;
6705 if (!strcmp(res->cmd, "rx_vxlan_port"))
6706 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6708 if (!strcmp(res->what, "add"))
6709 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6711 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6714 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6717 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6718 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6719 cmd, "rx_vxlan_port");
6720 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6721 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6723 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6724 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6726 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6727 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6730 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6731 .f = cmd_tunnel_udp_config_parsed,
6733 .help_str = "add/rm an tunneling UDP port filter: "
6734 "rx_vxlan_port add udp_port port_id",
6736 (void *)&cmd_tunnel_udp_config_cmd,
6737 (void *)&cmd_tunnel_udp_config_what,
6738 (void *)&cmd_tunnel_udp_config_udp_port,
6739 (void *)&cmd_tunnel_udp_config_port_id,
6744 /* *** GLOBAL CONFIG *** */
6745 struct cmd_global_config_result {
6746 cmdline_fixed_string_t cmd;
6748 cmdline_fixed_string_t cfg_type;
6753 cmd_global_config_parsed(void *parsed_result,
6754 __attribute__((unused)) struct cmdline *cl,
6755 __attribute__((unused)) void *data)
6757 struct cmd_global_config_result *res = parsed_result;
6758 struct rte_eth_global_cfg conf;
6761 memset(&conf, 0, sizeof(conf));
6762 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6763 conf.cfg.gre_key_len = res->len;
6764 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6765 RTE_ETH_FILTER_SET, &conf);
6767 printf("Global config error\n");
6770 cmdline_parse_token_string_t cmd_global_config_cmd =
6771 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6773 cmdline_parse_token_num_t cmd_global_config_port_id =
6774 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6775 cmdline_parse_token_string_t cmd_global_config_type =
6776 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6777 cfg_type, "gre-key-len");
6778 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6779 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6782 cmdline_parse_inst_t cmd_global_config = {
6783 .f = cmd_global_config_parsed,
6784 .data = (void *)NULL,
6785 .help_str = "global_config <port_id> gre-key-len <number>",
6787 (void *)&cmd_global_config_cmd,
6788 (void *)&cmd_global_config_port_id,
6789 (void *)&cmd_global_config_type,
6790 (void *)&cmd_global_config_gre_key_len,
6795 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6796 struct cmd_set_mirror_mask_result {
6797 cmdline_fixed_string_t set;
6798 cmdline_fixed_string_t port;
6800 cmdline_fixed_string_t mirror;
6802 cmdline_fixed_string_t what;
6803 cmdline_fixed_string_t value;
6804 cmdline_fixed_string_t dstpool;
6806 cmdline_fixed_string_t on;
6809 cmdline_parse_token_string_t cmd_mirror_mask_set =
6810 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6812 cmdline_parse_token_string_t cmd_mirror_mask_port =
6813 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6815 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6816 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6818 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6819 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6820 mirror, "mirror-rule");
6821 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6822 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6824 cmdline_parse_token_string_t cmd_mirror_mask_what =
6825 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6826 what, "pool-mirror-up#pool-mirror-down"
6828 cmdline_parse_token_string_t cmd_mirror_mask_value =
6829 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6831 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6832 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6833 dstpool, "dst-pool");
6834 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6835 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6837 cmdline_parse_token_string_t cmd_mirror_mask_on =
6838 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6842 cmd_set_mirror_mask_parsed(void *parsed_result,
6843 __attribute__((unused)) struct cmdline *cl,
6844 __attribute__((unused)) void *data)
6847 struct cmd_set_mirror_mask_result *res = parsed_result;
6848 struct rte_eth_mirror_conf mr_conf;
6850 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6852 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6854 mr_conf.dst_pool = res->dstpool_id;
6856 if (!strcmp(res->what, "pool-mirror-up")) {
6857 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6858 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6859 } else if (!strcmp(res->what, "pool-mirror-down")) {
6860 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6861 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6862 } else if (!strcmp(res->what, "vlan-mirror")) {
6863 mr_conf.rule_type = ETH_MIRROR_VLAN;
6864 nb_item = parse_item_list(res->value, "vlan",
6865 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6869 for (i = 0; i < nb_item; i++) {
6870 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6871 printf("Invalid vlan_id: must be < 4096\n");
6875 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6876 mr_conf.vlan.vlan_mask |= 1ULL << i;
6880 if (!strcmp(res->on, "on"))
6881 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6884 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6887 printf("mirror rule add error: (%s)\n", strerror(-ret));
6890 cmdline_parse_inst_t cmd_set_mirror_mask = {
6891 .f = cmd_set_mirror_mask_parsed,
6893 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
6894 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6896 (void *)&cmd_mirror_mask_set,
6897 (void *)&cmd_mirror_mask_port,
6898 (void *)&cmd_mirror_mask_portid,
6899 (void *)&cmd_mirror_mask_mirror,
6900 (void *)&cmd_mirror_mask_ruleid,
6901 (void *)&cmd_mirror_mask_what,
6902 (void *)&cmd_mirror_mask_value,
6903 (void *)&cmd_mirror_mask_dstpool,
6904 (void *)&cmd_mirror_mask_poolid,
6905 (void *)&cmd_mirror_mask_on,
6910 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6911 struct cmd_set_mirror_link_result {
6912 cmdline_fixed_string_t set;
6913 cmdline_fixed_string_t port;
6915 cmdline_fixed_string_t mirror;
6917 cmdline_fixed_string_t what;
6918 cmdline_fixed_string_t dstpool;
6920 cmdline_fixed_string_t on;
6923 cmdline_parse_token_string_t cmd_mirror_link_set =
6924 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6926 cmdline_parse_token_string_t cmd_mirror_link_port =
6927 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6929 cmdline_parse_token_num_t cmd_mirror_link_portid =
6930 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6932 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6933 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6934 mirror, "mirror-rule");
6935 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6936 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6938 cmdline_parse_token_string_t cmd_mirror_link_what =
6939 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6940 what, "uplink-mirror#downlink-mirror");
6941 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6942 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6943 dstpool, "dst-pool");
6944 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6945 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6947 cmdline_parse_token_string_t cmd_mirror_link_on =
6948 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6952 cmd_set_mirror_link_parsed(void *parsed_result,
6953 __attribute__((unused)) struct cmdline *cl,
6954 __attribute__((unused)) void *data)
6957 struct cmd_set_mirror_link_result *res = parsed_result;
6958 struct rte_eth_mirror_conf mr_conf;
6960 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6961 if (!strcmp(res->what, "uplink-mirror"))
6962 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
6964 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
6966 mr_conf.dst_pool = res->dstpool_id;
6968 if (!strcmp(res->on, "on"))
6969 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6972 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6975 /* check the return value and print it if is < 0 */
6977 printf("mirror rule add error: (%s)\n", strerror(-ret));
6981 cmdline_parse_inst_t cmd_set_mirror_link = {
6982 .f = cmd_set_mirror_link_parsed,
6984 .help_str = "set port X mirror-rule Y uplink-mirror|"
6985 "downlink-mirror dst-pool Z on|off",
6987 (void *)&cmd_mirror_link_set,
6988 (void *)&cmd_mirror_link_port,
6989 (void *)&cmd_mirror_link_portid,
6990 (void *)&cmd_mirror_link_mirror,
6991 (void *)&cmd_mirror_link_ruleid,
6992 (void *)&cmd_mirror_link_what,
6993 (void *)&cmd_mirror_link_dstpool,
6994 (void *)&cmd_mirror_link_poolid,
6995 (void *)&cmd_mirror_link_on,
7000 /* *** RESET VM MIRROR RULE *** */
7001 struct cmd_rm_mirror_rule_result {
7002 cmdline_fixed_string_t reset;
7003 cmdline_fixed_string_t port;
7005 cmdline_fixed_string_t mirror;
7009 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7010 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7012 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7013 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7015 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7016 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7018 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7019 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7020 mirror, "mirror-rule");
7021 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7022 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7026 cmd_reset_mirror_rule_parsed(void *parsed_result,
7027 __attribute__((unused)) struct cmdline *cl,
7028 __attribute__((unused)) void *data)
7031 struct cmd_set_mirror_link_result *res = parsed_result;
7033 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7035 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7038 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7039 .f = cmd_reset_mirror_rule_parsed,
7041 .help_str = "reset port X mirror-rule Y",
7043 (void *)&cmd_rm_mirror_rule_reset,
7044 (void *)&cmd_rm_mirror_rule_port,
7045 (void *)&cmd_rm_mirror_rule_portid,
7046 (void *)&cmd_rm_mirror_rule_mirror,
7047 (void *)&cmd_rm_mirror_rule_ruleid,
7052 /* ******************************************************************************** */
7054 struct cmd_dump_result {
7055 cmdline_fixed_string_t dump;
7059 dump_struct_sizes(void)
7061 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7062 DUMP_SIZE(struct rte_mbuf);
7063 DUMP_SIZE(struct rte_mempool);
7064 DUMP_SIZE(struct rte_ring);
7068 static void cmd_dump_parsed(void *parsed_result,
7069 __attribute__((unused)) struct cmdline *cl,
7070 __attribute__((unused)) void *data)
7072 struct cmd_dump_result *res = parsed_result;
7074 if (!strcmp(res->dump, "dump_physmem"))
7075 rte_dump_physmem_layout(stdout);
7076 else if (!strcmp(res->dump, "dump_memzone"))
7077 rte_memzone_dump(stdout);
7078 else if (!strcmp(res->dump, "dump_log_history"))
7079 rte_log_dump_history(stdout);
7080 else if (!strcmp(res->dump, "dump_struct_sizes"))
7081 dump_struct_sizes();
7082 else if (!strcmp(res->dump, "dump_ring"))
7083 rte_ring_list_dump(stdout);
7084 else if (!strcmp(res->dump, "dump_mempool"))
7085 rte_mempool_list_dump(stdout);
7086 else if (!strcmp(res->dump, "dump_devargs"))
7087 rte_eal_devargs_dump(stdout);
7090 cmdline_parse_token_string_t cmd_dump_dump =
7091 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7095 "dump_struct_sizes#"
7100 cmdline_parse_inst_t cmd_dump = {
7101 .f = cmd_dump_parsed, /* function to call */
7102 .data = NULL, /* 2nd arg of func */
7103 .help_str = "dump status",
7104 .tokens = { /* token list, NULL terminated */
7105 (void *)&cmd_dump_dump,
7110 /* ******************************************************************************** */
7112 struct cmd_dump_one_result {
7113 cmdline_fixed_string_t dump;
7114 cmdline_fixed_string_t name;
7117 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7118 __attribute__((unused)) void *data)
7120 struct cmd_dump_one_result *res = parsed_result;
7122 if (!strcmp(res->dump, "dump_ring")) {
7124 r = rte_ring_lookup(res->name);
7126 cmdline_printf(cl, "Cannot find ring\n");
7129 rte_ring_dump(stdout, r);
7130 } else if (!strcmp(res->dump, "dump_mempool")) {
7131 struct rte_mempool *mp;
7132 mp = rte_mempool_lookup(res->name);
7134 cmdline_printf(cl, "Cannot find mempool\n");
7137 rte_mempool_dump(stdout, mp);
7141 cmdline_parse_token_string_t cmd_dump_one_dump =
7142 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7143 "dump_ring#dump_mempool");
7145 cmdline_parse_token_string_t cmd_dump_one_name =
7146 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7148 cmdline_parse_inst_t cmd_dump_one = {
7149 .f = cmd_dump_one_parsed, /* function to call */
7150 .data = NULL, /* 2nd arg of func */
7151 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7152 .tokens = { /* token list, NULL terminated */
7153 (void *)&cmd_dump_one_dump,
7154 (void *)&cmd_dump_one_name,
7159 /* *** Add/Del syn filter *** */
7160 struct cmd_syn_filter_result {
7161 cmdline_fixed_string_t filter;
7163 cmdline_fixed_string_t ops;
7164 cmdline_fixed_string_t priority;
7165 cmdline_fixed_string_t high;
7166 cmdline_fixed_string_t queue;
7171 cmd_syn_filter_parsed(void *parsed_result,
7172 __attribute__((unused)) struct cmdline *cl,
7173 __attribute__((unused)) void *data)
7175 struct cmd_syn_filter_result *res = parsed_result;
7176 struct rte_eth_syn_filter syn_filter;
7179 ret = rte_eth_dev_filter_supported(res->port_id,
7180 RTE_ETH_FILTER_SYN);
7182 printf("syn filter is not supported on port %u.\n",
7187 memset(&syn_filter, 0, sizeof(syn_filter));
7189 if (!strcmp(res->ops, "add")) {
7190 if (!strcmp(res->high, "high"))
7191 syn_filter.hig_pri = 1;
7193 syn_filter.hig_pri = 0;
7195 syn_filter.queue = res->queue_id;
7196 ret = rte_eth_dev_filter_ctrl(res->port_id,
7201 ret = rte_eth_dev_filter_ctrl(res->port_id,
7203 RTE_ETH_FILTER_DELETE,
7207 printf("syn filter programming error: (%s)\n",
7211 cmdline_parse_token_string_t cmd_syn_filter_filter =
7212 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7213 filter, "syn_filter");
7214 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7215 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7217 cmdline_parse_token_string_t cmd_syn_filter_ops =
7218 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7220 cmdline_parse_token_string_t cmd_syn_filter_priority =
7221 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7222 priority, "priority");
7223 cmdline_parse_token_string_t cmd_syn_filter_high =
7224 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7226 cmdline_parse_token_string_t cmd_syn_filter_queue =
7227 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7229 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7230 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7233 cmdline_parse_inst_t cmd_syn_filter = {
7234 .f = cmd_syn_filter_parsed,
7236 .help_str = "add/delete syn filter",
7238 (void *)&cmd_syn_filter_filter,
7239 (void *)&cmd_syn_filter_port_id,
7240 (void *)&cmd_syn_filter_ops,
7241 (void *)&cmd_syn_filter_priority,
7242 (void *)&cmd_syn_filter_high,
7243 (void *)&cmd_syn_filter_queue,
7244 (void *)&cmd_syn_filter_queue_id,
7249 /* *** ADD/REMOVE A 2tuple FILTER *** */
7250 struct cmd_2tuple_filter_result {
7251 cmdline_fixed_string_t filter;
7253 cmdline_fixed_string_t ops;
7254 cmdline_fixed_string_t dst_port;
7255 uint16_t dst_port_value;
7256 cmdline_fixed_string_t protocol;
7257 uint8_t protocol_value;
7258 cmdline_fixed_string_t mask;
7260 cmdline_fixed_string_t tcp_flags;
7261 uint8_t tcp_flags_value;
7262 cmdline_fixed_string_t priority;
7263 uint8_t priority_value;
7264 cmdline_fixed_string_t queue;
7269 cmd_2tuple_filter_parsed(void *parsed_result,
7270 __attribute__((unused)) struct cmdline *cl,
7271 __attribute__((unused)) void *data)
7273 struct rte_eth_ntuple_filter filter;
7274 struct cmd_2tuple_filter_result *res = parsed_result;
7277 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7279 printf("ntuple filter is not supported on port %u.\n",
7284 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7286 filter.flags = RTE_2TUPLE_FLAGS;
7287 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7288 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7289 filter.proto = res->protocol_value;
7290 filter.priority = res->priority_value;
7291 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7292 printf("nonzero tcp_flags is only meaningful"
7293 " when protocol is TCP.\n");
7296 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7297 printf("invalid TCP flags.\n");
7301 if (res->tcp_flags_value != 0) {
7302 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7303 filter.tcp_flags = res->tcp_flags_value;
7306 /* need convert to big endian. */
7307 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7308 filter.queue = res->queue_id;
7310 if (!strcmp(res->ops, "add"))
7311 ret = rte_eth_dev_filter_ctrl(res->port_id,
7312 RTE_ETH_FILTER_NTUPLE,
7316 ret = rte_eth_dev_filter_ctrl(res->port_id,
7317 RTE_ETH_FILTER_NTUPLE,
7318 RTE_ETH_FILTER_DELETE,
7321 printf("2tuple filter programming error: (%s)\n",
7326 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7327 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7328 filter, "2tuple_filter");
7329 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7330 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7332 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7333 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7335 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7336 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7337 dst_port, "dst_port");
7338 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7339 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7340 dst_port_value, UINT16);
7341 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7342 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7343 protocol, "protocol");
7344 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7345 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7346 protocol_value, UINT8);
7347 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7348 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7350 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7351 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7353 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7354 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7355 tcp_flags, "tcp_flags");
7356 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7357 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7358 tcp_flags_value, UINT8);
7359 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7360 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7361 priority, "priority");
7362 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7363 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7364 priority_value, UINT8);
7365 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7366 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7368 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7369 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7372 cmdline_parse_inst_t cmd_2tuple_filter = {
7373 .f = cmd_2tuple_filter_parsed,
7375 .help_str = "add a 2tuple filter",
7377 (void *)&cmd_2tuple_filter_filter,
7378 (void *)&cmd_2tuple_filter_port_id,
7379 (void *)&cmd_2tuple_filter_ops,
7380 (void *)&cmd_2tuple_filter_dst_port,
7381 (void *)&cmd_2tuple_filter_dst_port_value,
7382 (void *)&cmd_2tuple_filter_protocol,
7383 (void *)&cmd_2tuple_filter_protocol_value,
7384 (void *)&cmd_2tuple_filter_mask,
7385 (void *)&cmd_2tuple_filter_mask_value,
7386 (void *)&cmd_2tuple_filter_tcp_flags,
7387 (void *)&cmd_2tuple_filter_tcp_flags_value,
7388 (void *)&cmd_2tuple_filter_priority,
7389 (void *)&cmd_2tuple_filter_priority_value,
7390 (void *)&cmd_2tuple_filter_queue,
7391 (void *)&cmd_2tuple_filter_queue_id,
7396 /* *** ADD/REMOVE A 5tuple FILTER *** */
7397 struct cmd_5tuple_filter_result {
7398 cmdline_fixed_string_t filter;
7400 cmdline_fixed_string_t ops;
7401 cmdline_fixed_string_t dst_ip;
7402 cmdline_ipaddr_t dst_ip_value;
7403 cmdline_fixed_string_t src_ip;
7404 cmdline_ipaddr_t src_ip_value;
7405 cmdline_fixed_string_t dst_port;
7406 uint16_t dst_port_value;
7407 cmdline_fixed_string_t src_port;
7408 uint16_t src_port_value;
7409 cmdline_fixed_string_t protocol;
7410 uint8_t protocol_value;
7411 cmdline_fixed_string_t mask;
7413 cmdline_fixed_string_t tcp_flags;
7414 uint8_t tcp_flags_value;
7415 cmdline_fixed_string_t priority;
7416 uint8_t priority_value;
7417 cmdline_fixed_string_t queue;
7422 cmd_5tuple_filter_parsed(void *parsed_result,
7423 __attribute__((unused)) struct cmdline *cl,
7424 __attribute__((unused)) void *data)
7426 struct rte_eth_ntuple_filter filter;
7427 struct cmd_5tuple_filter_result *res = parsed_result;
7430 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7432 printf("ntuple filter is not supported on port %u.\n",
7437 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7439 filter.flags = RTE_5TUPLE_FLAGS;
7440 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7441 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7442 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7443 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7444 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7445 filter.proto = res->protocol_value;
7446 filter.priority = res->priority_value;
7447 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7448 printf("nonzero tcp_flags is only meaningful"
7449 " when protocol is TCP.\n");
7452 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7453 printf("invalid TCP flags.\n");
7457 if (res->tcp_flags_value != 0) {
7458 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7459 filter.tcp_flags = res->tcp_flags_value;
7462 if (res->dst_ip_value.family == AF_INET)
7463 /* no need to convert, already big endian. */
7464 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7466 if (filter.dst_ip_mask == 0) {
7467 printf("can not support ipv6 involved compare.\n");
7473 if (res->src_ip_value.family == AF_INET)
7474 /* no need to convert, already big endian. */
7475 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7477 if (filter.src_ip_mask == 0) {
7478 printf("can not support ipv6 involved compare.\n");
7483 /* need convert to big endian. */
7484 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7485 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7486 filter.queue = res->queue_id;
7488 if (!strcmp(res->ops, "add"))
7489 ret = rte_eth_dev_filter_ctrl(res->port_id,
7490 RTE_ETH_FILTER_NTUPLE,
7494 ret = rte_eth_dev_filter_ctrl(res->port_id,
7495 RTE_ETH_FILTER_NTUPLE,
7496 RTE_ETH_FILTER_DELETE,
7499 printf("5tuple filter programming error: (%s)\n",
7503 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7504 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7505 filter, "5tuple_filter");
7506 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7507 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7509 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7510 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7512 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7513 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7515 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7516 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7518 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7519 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7521 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7522 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7524 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7525 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7526 dst_port, "dst_port");
7527 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7528 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7529 dst_port_value, UINT16);
7530 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7531 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7532 src_port, "src_port");
7533 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7534 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7535 src_port_value, UINT16);
7536 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7537 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7538 protocol, "protocol");
7539 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7540 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7541 protocol_value, UINT8);
7542 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7543 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7545 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7546 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7548 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7549 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7550 tcp_flags, "tcp_flags");
7551 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7552 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7553 tcp_flags_value, UINT8);
7554 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7555 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7556 priority, "priority");
7557 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7558 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7559 priority_value, UINT8);
7560 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7561 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7563 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7564 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7567 cmdline_parse_inst_t cmd_5tuple_filter = {
7568 .f = cmd_5tuple_filter_parsed,
7570 .help_str = "add/del a 5tuple filter",
7572 (void *)&cmd_5tuple_filter_filter,
7573 (void *)&cmd_5tuple_filter_port_id,
7574 (void *)&cmd_5tuple_filter_ops,
7575 (void *)&cmd_5tuple_filter_dst_ip,
7576 (void *)&cmd_5tuple_filter_dst_ip_value,
7577 (void *)&cmd_5tuple_filter_src_ip,
7578 (void *)&cmd_5tuple_filter_src_ip_value,
7579 (void *)&cmd_5tuple_filter_dst_port,
7580 (void *)&cmd_5tuple_filter_dst_port_value,
7581 (void *)&cmd_5tuple_filter_src_port,
7582 (void *)&cmd_5tuple_filter_src_port_value,
7583 (void *)&cmd_5tuple_filter_protocol,
7584 (void *)&cmd_5tuple_filter_protocol_value,
7585 (void *)&cmd_5tuple_filter_mask,
7586 (void *)&cmd_5tuple_filter_mask_value,
7587 (void *)&cmd_5tuple_filter_tcp_flags,
7588 (void *)&cmd_5tuple_filter_tcp_flags_value,
7589 (void *)&cmd_5tuple_filter_priority,
7590 (void *)&cmd_5tuple_filter_priority_value,
7591 (void *)&cmd_5tuple_filter_queue,
7592 (void *)&cmd_5tuple_filter_queue_id,
7597 /* *** ADD/REMOVE A flex FILTER *** */
7598 struct cmd_flex_filter_result {
7599 cmdline_fixed_string_t filter;
7600 cmdline_fixed_string_t ops;
7602 cmdline_fixed_string_t len;
7604 cmdline_fixed_string_t bytes;
7605 cmdline_fixed_string_t bytes_value;
7606 cmdline_fixed_string_t mask;
7607 cmdline_fixed_string_t mask_value;
7608 cmdline_fixed_string_t priority;
7609 uint8_t priority_value;
7610 cmdline_fixed_string_t queue;
7614 static int xdigit2val(unsigned char c)
7619 else if (isupper(c))
7627 cmd_flex_filter_parsed(void *parsed_result,
7628 __attribute__((unused)) struct cmdline *cl,
7629 __attribute__((unused)) void *data)
7632 struct rte_eth_flex_filter filter;
7633 struct cmd_flex_filter_result *res = parsed_result;
7634 char *bytes_ptr, *mask_ptr;
7635 uint16_t len, i, j = 0;
7640 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7641 printf("the len exceed the max length 128\n");
7644 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7645 filter.len = res->len_value;
7646 filter.priority = res->priority_value;
7647 filter.queue = res->queue_id;
7648 bytes_ptr = res->bytes_value;
7649 mask_ptr = res->mask_value;
7651 /* translate bytes string to array. */
7652 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7653 (bytes_ptr[1] == 'X')))
7655 len = strnlen(bytes_ptr, res->len_value * 2);
7656 if (len == 0 || (len % 8 != 0)) {
7657 printf("please check len and bytes input\n");
7660 for (i = 0; i < len; i++) {
7662 if (isxdigit(c) == 0) {
7663 /* invalid characters. */
7664 printf("invalid input\n");
7667 val = xdigit2val(c);
7670 filter.bytes[j] = byte;
7671 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7678 /* translate mask string to uint8_t array. */
7679 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7680 (mask_ptr[1] == 'X')))
7682 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7684 printf("invalid input\n");
7689 for (i = 0; i < len; i++) {
7691 if (isxdigit(c) == 0) {
7692 /* invalid characters. */
7693 printf("invalid input\n");
7696 val = xdigit2val(c);
7699 filter.mask[j] = byte;
7700 printf("mask[%d]:%02x ", j, filter.mask[j]);
7708 if (!strcmp(res->ops, "add"))
7709 ret = rte_eth_dev_filter_ctrl(res->port_id,
7710 RTE_ETH_FILTER_FLEXIBLE,
7714 ret = rte_eth_dev_filter_ctrl(res->port_id,
7715 RTE_ETH_FILTER_FLEXIBLE,
7716 RTE_ETH_FILTER_DELETE,
7720 printf("flex filter setting error: (%s)\n", strerror(-ret));
7723 cmdline_parse_token_string_t cmd_flex_filter_filter =
7724 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7725 filter, "flex_filter");
7726 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7727 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7729 cmdline_parse_token_string_t cmd_flex_filter_ops =
7730 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7732 cmdline_parse_token_string_t cmd_flex_filter_len =
7733 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7735 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7736 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7738 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7739 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7741 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7742 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7744 cmdline_parse_token_string_t cmd_flex_filter_mask =
7745 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7747 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7748 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7750 cmdline_parse_token_string_t cmd_flex_filter_priority =
7751 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7752 priority, "priority");
7753 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7754 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7755 priority_value, UINT8);
7756 cmdline_parse_token_string_t cmd_flex_filter_queue =
7757 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7759 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7760 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7762 cmdline_parse_inst_t cmd_flex_filter = {
7763 .f = cmd_flex_filter_parsed,
7765 .help_str = "add/del a flex filter",
7767 (void *)&cmd_flex_filter_filter,
7768 (void *)&cmd_flex_filter_port_id,
7769 (void *)&cmd_flex_filter_ops,
7770 (void *)&cmd_flex_filter_len,
7771 (void *)&cmd_flex_filter_len_value,
7772 (void *)&cmd_flex_filter_bytes,
7773 (void *)&cmd_flex_filter_bytes_value,
7774 (void *)&cmd_flex_filter_mask,
7775 (void *)&cmd_flex_filter_mask_value,
7776 (void *)&cmd_flex_filter_priority,
7777 (void *)&cmd_flex_filter_priority_value,
7778 (void *)&cmd_flex_filter_queue,
7779 (void *)&cmd_flex_filter_queue_id,
7784 /* *** Filters Control *** */
7786 /* *** deal with ethertype filter *** */
7787 struct cmd_ethertype_filter_result {
7788 cmdline_fixed_string_t filter;
7790 cmdline_fixed_string_t ops;
7791 cmdline_fixed_string_t mac;
7792 struct ether_addr mac_addr;
7793 cmdline_fixed_string_t ethertype;
7794 uint16_t ethertype_value;
7795 cmdline_fixed_string_t drop;
7796 cmdline_fixed_string_t queue;
7800 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7801 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7802 filter, "ethertype_filter");
7803 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7804 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7806 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7807 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7809 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7810 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7811 mac, "mac_addr#mac_ignr");
7812 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7813 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7815 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7816 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7817 ethertype, "ethertype");
7818 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7819 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7820 ethertype_value, UINT16);
7821 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7822 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7824 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7825 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7827 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7828 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7832 cmd_ethertype_filter_parsed(void *parsed_result,
7833 __attribute__((unused)) struct cmdline *cl,
7834 __attribute__((unused)) void *data)
7836 struct cmd_ethertype_filter_result *res = parsed_result;
7837 struct rte_eth_ethertype_filter filter;
7840 ret = rte_eth_dev_filter_supported(res->port_id,
7841 RTE_ETH_FILTER_ETHERTYPE);
7843 printf("ethertype filter is not supported on port %u.\n",
7848 memset(&filter, 0, sizeof(filter));
7849 if (!strcmp(res->mac, "mac_addr")) {
7850 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7851 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7852 sizeof(struct ether_addr));
7854 if (!strcmp(res->drop, "drop"))
7855 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7856 filter.ether_type = res->ethertype_value;
7857 filter.queue = res->queue_id;
7859 if (!strcmp(res->ops, "add"))
7860 ret = rte_eth_dev_filter_ctrl(res->port_id,
7861 RTE_ETH_FILTER_ETHERTYPE,
7865 ret = rte_eth_dev_filter_ctrl(res->port_id,
7866 RTE_ETH_FILTER_ETHERTYPE,
7867 RTE_ETH_FILTER_DELETE,
7870 printf("ethertype filter programming error: (%s)\n",
7874 cmdline_parse_inst_t cmd_ethertype_filter = {
7875 .f = cmd_ethertype_filter_parsed,
7877 .help_str = "add or delete an ethertype filter entry",
7879 (void *)&cmd_ethertype_filter_filter,
7880 (void *)&cmd_ethertype_filter_port_id,
7881 (void *)&cmd_ethertype_filter_ops,
7882 (void *)&cmd_ethertype_filter_mac,
7883 (void *)&cmd_ethertype_filter_mac_addr,
7884 (void *)&cmd_ethertype_filter_ethertype,
7885 (void *)&cmd_ethertype_filter_ethertype_value,
7886 (void *)&cmd_ethertype_filter_drop,
7887 (void *)&cmd_ethertype_filter_queue,
7888 (void *)&cmd_ethertype_filter_queue_id,
7893 /* *** deal with flow director filter *** */
7894 struct cmd_flow_director_result {
7895 cmdline_fixed_string_t flow_director_filter;
7897 cmdline_fixed_string_t mode;
7898 cmdline_fixed_string_t mode_value;
7899 cmdline_fixed_string_t ops;
7900 cmdline_fixed_string_t flow;
7901 cmdline_fixed_string_t flow_type;
7902 cmdline_fixed_string_t ether;
7903 uint16_t ether_type;
7904 cmdline_fixed_string_t src;
7905 cmdline_ipaddr_t ip_src;
7907 cmdline_fixed_string_t dst;
7908 cmdline_ipaddr_t ip_dst;
7910 cmdline_fixed_string_t verify_tag;
7911 uint32_t verify_tag_value;
7912 cmdline_fixed_string_t vlan;
7913 uint16_t vlan_value;
7914 cmdline_fixed_string_t flexbytes;
7915 cmdline_fixed_string_t flexbytes_value;
7916 cmdline_fixed_string_t pf_vf;
7917 cmdline_fixed_string_t drop;
7918 cmdline_fixed_string_t queue;
7920 cmdline_fixed_string_t fd_id;
7921 uint32_t fd_id_value;
7922 cmdline_fixed_string_t mac;
7923 struct ether_addr mac_addr;
7924 cmdline_fixed_string_t tunnel;
7925 cmdline_fixed_string_t tunnel_type;
7926 cmdline_fixed_string_t tunnel_id;
7927 uint32_t tunnel_id_value;
7931 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7934 const char *p, *p0 = q_arg;
7936 unsigned long int_fld;
7937 char *str_fld[max_num];
7942 p = strchr(p0, '(');
7946 p0 = strchr(p, ')');
7951 if (size >= sizeof(s))
7954 snprintf(s, sizeof(s), "%.*s", size, p);
7955 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7956 if (ret < 0 || ret > max_num)
7958 for (i = 0; i < ret; i++) {
7960 int_fld = strtoul(str_fld[i], &end, 0);
7961 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7963 flexbytes[i] = (uint8_t)int_fld;
7969 str2flowtype(char *string)
7972 static const struct {
7975 } flowtype_str[] = {
7976 {"raw", RTE_ETH_FLOW_RAW},
7977 {"ipv4", RTE_ETH_FLOW_IPV4},
7978 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
7979 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
7980 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
7981 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
7982 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
7983 {"ipv6", RTE_ETH_FLOW_IPV6},
7984 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
7985 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
7986 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
7987 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
7988 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
7989 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
7992 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7993 if (!strcmp(flowtype_str[i].str, string))
7994 return flowtype_str[i].type;
7996 return RTE_ETH_FLOW_UNKNOWN;
8000 str2fdir_tunneltype(char *string)
8004 static const struct {
8007 } tunneltype_str[] = {
8008 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8009 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8012 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8013 if (!strcmp(tunneltype_str[i].str, string))
8014 return tunneltype_str[i].type;
8016 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8019 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8021 if ((ip_addr).family == AF_INET) \
8022 (ip) = (ip_addr).addr.ipv4.s_addr; \
8024 printf("invalid parameter.\n"); \
8029 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8031 if ((ip_addr).family == AF_INET6) \
8032 (void)rte_memcpy(&(ip), \
8033 &((ip_addr).addr.ipv6), \
8034 sizeof(struct in6_addr)); \
8036 printf("invalid parameter.\n"); \
8042 cmd_flow_director_filter_parsed(void *parsed_result,
8043 __attribute__((unused)) struct cmdline *cl,
8044 __attribute__((unused)) void *data)
8046 struct cmd_flow_director_result *res = parsed_result;
8047 struct rte_eth_fdir_filter entry;
8048 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8050 unsigned long vf_id;
8053 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8055 printf("flow director is not supported on port %u.\n",
8059 memset(flexbytes, 0, sizeof(flexbytes));
8060 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8062 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8063 if (strcmp(res->mode_value, "MAC-VLAN")) {
8064 printf("Please set mode to MAC-VLAN.\n");
8067 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8068 if (strcmp(res->mode_value, "Tunnel")) {
8069 printf("Please set mode to Tunnel.\n");
8073 if (strcmp(res->mode_value, "IP")) {
8074 printf("Please set mode to IP.\n");
8077 entry.input.flow_type = str2flowtype(res->flow_type);
8080 ret = parse_flexbytes(res->flexbytes_value,
8082 RTE_ETH_FDIR_MAX_FLEXLEN);
8084 printf("error: Cannot parse flexbytes input.\n");
8088 switch (entry.input.flow_type) {
8089 case RTE_ETH_FLOW_FRAG_IPV4:
8090 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8091 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8092 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8093 IPV4_ADDR_TO_UINT(res->ip_dst,
8094 entry.input.flow.ip4_flow.dst_ip);
8095 IPV4_ADDR_TO_UINT(res->ip_src,
8096 entry.input.flow.ip4_flow.src_ip);
8097 /* need convert to big endian. */
8098 entry.input.flow.udp4_flow.dst_port =
8099 rte_cpu_to_be_16(res->port_dst);
8100 entry.input.flow.udp4_flow.src_port =
8101 rte_cpu_to_be_16(res->port_src);
8103 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8104 IPV4_ADDR_TO_UINT(res->ip_dst,
8105 entry.input.flow.sctp4_flow.ip.dst_ip);
8106 IPV4_ADDR_TO_UINT(res->ip_src,
8107 entry.input.flow.sctp4_flow.ip.src_ip);
8108 /* need convert to big endian. */
8109 entry.input.flow.sctp4_flow.dst_port =
8110 rte_cpu_to_be_16(res->port_dst);
8111 entry.input.flow.sctp4_flow.src_port =
8112 rte_cpu_to_be_16(res->port_src);
8113 entry.input.flow.sctp4_flow.verify_tag =
8114 rte_cpu_to_be_32(res->verify_tag_value);
8116 case RTE_ETH_FLOW_FRAG_IPV6:
8117 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8118 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8119 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8120 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8121 entry.input.flow.ipv6_flow.dst_ip);
8122 IPV6_ADDR_TO_ARRAY(res->ip_src,
8123 entry.input.flow.ipv6_flow.src_ip);
8124 /* need convert to big endian. */
8125 entry.input.flow.udp6_flow.dst_port =
8126 rte_cpu_to_be_16(res->port_dst);
8127 entry.input.flow.udp6_flow.src_port =
8128 rte_cpu_to_be_16(res->port_src);
8130 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8131 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8132 entry.input.flow.sctp6_flow.ip.dst_ip);
8133 IPV6_ADDR_TO_ARRAY(res->ip_src,
8134 entry.input.flow.sctp6_flow.ip.src_ip);
8135 /* need convert to big endian. */
8136 entry.input.flow.sctp6_flow.dst_port =
8137 rte_cpu_to_be_16(res->port_dst);
8138 entry.input.flow.sctp6_flow.src_port =
8139 rte_cpu_to_be_16(res->port_src);
8140 entry.input.flow.sctp6_flow.verify_tag =
8141 rte_cpu_to_be_32(res->verify_tag_value);
8143 case RTE_ETH_FLOW_L2_PAYLOAD:
8144 entry.input.flow.l2_flow.ether_type =
8145 rte_cpu_to_be_16(res->ether_type);
8151 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8152 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8154 sizeof(struct ether_addr));
8156 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8157 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8159 sizeof(struct ether_addr));
8160 entry.input.flow.tunnel_flow.tunnel_type =
8161 str2fdir_tunneltype(res->tunnel_type);
8162 entry.input.flow.tunnel_flow.tunnel_id =
8163 rte_cpu_to_be_32(res->tunnel_id_value);
8166 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8168 RTE_ETH_FDIR_MAX_FLEXLEN);
8170 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8172 entry.action.flex_off = 0; /*use 0 by default */
8173 if (!strcmp(res->drop, "drop"))
8174 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8176 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8178 if (!strcmp(res->pf_vf, "pf"))
8179 entry.input.flow_ext.is_vf = 0;
8180 else if (!strncmp(res->pf_vf, "vf", 2)) {
8181 struct rte_eth_dev_info dev_info;
8183 memset(&dev_info, 0, sizeof(dev_info));
8184 rte_eth_dev_info_get(res->port_id, &dev_info);
8186 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8187 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8188 printf("invalid parameter %s.\n", res->pf_vf);
8191 entry.input.flow_ext.is_vf = 1;
8192 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8194 printf("invalid parameter %s.\n", res->pf_vf);
8198 /* set to report FD ID by default */
8199 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8200 entry.action.rx_queue = res->queue_id;
8201 entry.soft_id = res->fd_id_value;
8202 if (!strcmp(res->ops, "add"))
8203 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8204 RTE_ETH_FILTER_ADD, &entry);
8205 else if (!strcmp(res->ops, "del"))
8206 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8207 RTE_ETH_FILTER_DELETE, &entry);
8209 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8210 RTE_ETH_FILTER_UPDATE, &entry);
8212 printf("flow director programming error: (%s)\n",
8216 cmdline_parse_token_string_t cmd_flow_director_filter =
8217 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8218 flow_director_filter, "flow_director_filter");
8219 cmdline_parse_token_num_t cmd_flow_director_port_id =
8220 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8222 cmdline_parse_token_string_t cmd_flow_director_ops =
8223 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8224 ops, "add#del#update");
8225 cmdline_parse_token_string_t cmd_flow_director_flow =
8226 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8228 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8229 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8230 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8231 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8232 cmdline_parse_token_string_t cmd_flow_director_ether =
8233 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8235 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8236 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8237 ether_type, UINT16);
8238 cmdline_parse_token_string_t cmd_flow_director_src =
8239 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8241 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8242 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8244 cmdline_parse_token_num_t cmd_flow_director_port_src =
8245 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8247 cmdline_parse_token_string_t cmd_flow_director_dst =
8248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8250 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8251 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8253 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8254 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8256 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8257 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8258 verify_tag, "verify_tag");
8259 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8260 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8261 verify_tag_value, UINT32);
8262 cmdline_parse_token_string_t cmd_flow_director_vlan =
8263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8265 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8266 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8267 vlan_value, UINT16);
8268 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8270 flexbytes, "flexbytes");
8271 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8273 flexbytes_value, NULL);
8274 cmdline_parse_token_string_t cmd_flow_director_drop =
8275 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8277 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8278 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8280 cmdline_parse_token_string_t cmd_flow_director_queue =
8281 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8283 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8284 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8286 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8287 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8289 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8290 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8291 fd_id_value, UINT32);
8293 cmdline_parse_token_string_t cmd_flow_director_mode =
8294 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8296 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8299 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8300 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8301 mode_value, "MAC-VLAN");
8302 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8303 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8304 mode_value, "Tunnel");
8305 cmdline_parse_token_string_t cmd_flow_director_mac =
8306 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8308 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8309 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8311 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8312 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8314 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8315 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8316 tunnel_type, "NVGRE#VxLAN");
8317 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8318 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8319 tunnel_id, "tunnel-id");
8320 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8321 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8322 tunnel_id_value, UINT32);
8324 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8325 .f = cmd_flow_director_filter_parsed,
8327 .help_str = "add or delete an ip flow director entry on NIC",
8329 (void *)&cmd_flow_director_filter,
8330 (void *)&cmd_flow_director_port_id,
8331 (void *)&cmd_flow_director_mode,
8332 (void *)&cmd_flow_director_mode_ip,
8333 (void *)&cmd_flow_director_ops,
8334 (void *)&cmd_flow_director_flow,
8335 (void *)&cmd_flow_director_flow_type,
8336 (void *)&cmd_flow_director_src,
8337 (void *)&cmd_flow_director_ip_src,
8338 (void *)&cmd_flow_director_dst,
8339 (void *)&cmd_flow_director_ip_dst,
8340 (void *)&cmd_flow_director_vlan,
8341 (void *)&cmd_flow_director_vlan_value,
8342 (void *)&cmd_flow_director_flexbytes,
8343 (void *)&cmd_flow_director_flexbytes_value,
8344 (void *)&cmd_flow_director_drop,
8345 (void *)&cmd_flow_director_pf_vf,
8346 (void *)&cmd_flow_director_queue,
8347 (void *)&cmd_flow_director_queue_id,
8348 (void *)&cmd_flow_director_fd_id,
8349 (void *)&cmd_flow_director_fd_id_value,
8354 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8355 .f = cmd_flow_director_filter_parsed,
8357 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8359 (void *)&cmd_flow_director_filter,
8360 (void *)&cmd_flow_director_port_id,
8361 (void *)&cmd_flow_director_mode,
8362 (void *)&cmd_flow_director_mode_ip,
8363 (void *)&cmd_flow_director_ops,
8364 (void *)&cmd_flow_director_flow,
8365 (void *)&cmd_flow_director_flow_type,
8366 (void *)&cmd_flow_director_src,
8367 (void *)&cmd_flow_director_ip_src,
8368 (void *)&cmd_flow_director_port_src,
8369 (void *)&cmd_flow_director_dst,
8370 (void *)&cmd_flow_director_ip_dst,
8371 (void *)&cmd_flow_director_port_dst,
8372 (void *)&cmd_flow_director_vlan,
8373 (void *)&cmd_flow_director_vlan_value,
8374 (void *)&cmd_flow_director_flexbytes,
8375 (void *)&cmd_flow_director_flexbytes_value,
8376 (void *)&cmd_flow_director_drop,
8377 (void *)&cmd_flow_director_pf_vf,
8378 (void *)&cmd_flow_director_queue,
8379 (void *)&cmd_flow_director_queue_id,
8380 (void *)&cmd_flow_director_fd_id,
8381 (void *)&cmd_flow_director_fd_id_value,
8386 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8387 .f = cmd_flow_director_filter_parsed,
8389 .help_str = "add or delete a sctp flow director entry on NIC",
8391 (void *)&cmd_flow_director_filter,
8392 (void *)&cmd_flow_director_port_id,
8393 (void *)&cmd_flow_director_mode,
8394 (void *)&cmd_flow_director_mode_ip,
8395 (void *)&cmd_flow_director_ops,
8396 (void *)&cmd_flow_director_flow,
8397 (void *)&cmd_flow_director_flow_type,
8398 (void *)&cmd_flow_director_src,
8399 (void *)&cmd_flow_director_ip_src,
8400 (void *)&cmd_flow_director_port_dst,
8401 (void *)&cmd_flow_director_dst,
8402 (void *)&cmd_flow_director_ip_dst,
8403 (void *)&cmd_flow_director_port_dst,
8404 (void *)&cmd_flow_director_verify_tag,
8405 (void *)&cmd_flow_director_verify_tag_value,
8406 (void *)&cmd_flow_director_vlan,
8407 (void *)&cmd_flow_director_vlan_value,
8408 (void *)&cmd_flow_director_flexbytes,
8409 (void *)&cmd_flow_director_flexbytes_value,
8410 (void *)&cmd_flow_director_drop,
8411 (void *)&cmd_flow_director_pf_vf,
8412 (void *)&cmd_flow_director_queue,
8413 (void *)&cmd_flow_director_queue_id,
8414 (void *)&cmd_flow_director_fd_id,
8415 (void *)&cmd_flow_director_fd_id_value,
8420 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8421 .f = cmd_flow_director_filter_parsed,
8423 .help_str = "add or delete a L2 flow director entry on NIC",
8425 (void *)&cmd_flow_director_filter,
8426 (void *)&cmd_flow_director_port_id,
8427 (void *)&cmd_flow_director_mode,
8428 (void *)&cmd_flow_director_mode_ip,
8429 (void *)&cmd_flow_director_ops,
8430 (void *)&cmd_flow_director_flow,
8431 (void *)&cmd_flow_director_flow_type,
8432 (void *)&cmd_flow_director_ether,
8433 (void *)&cmd_flow_director_ether_type,
8434 (void *)&cmd_flow_director_flexbytes,
8435 (void *)&cmd_flow_director_flexbytes_value,
8436 (void *)&cmd_flow_director_drop,
8437 (void *)&cmd_flow_director_pf_vf,
8438 (void *)&cmd_flow_director_queue,
8439 (void *)&cmd_flow_director_queue_id,
8440 (void *)&cmd_flow_director_fd_id,
8441 (void *)&cmd_flow_director_fd_id_value,
8446 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8447 .f = cmd_flow_director_filter_parsed,
8449 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8451 (void *)&cmd_flow_director_filter,
8452 (void *)&cmd_flow_director_port_id,
8453 (void *)&cmd_flow_director_mode,
8454 (void *)&cmd_flow_director_mode_mac_vlan,
8455 (void *)&cmd_flow_director_ops,
8456 (void *)&cmd_flow_director_mac,
8457 (void *)&cmd_flow_director_mac_addr,
8458 (void *)&cmd_flow_director_vlan,
8459 (void *)&cmd_flow_director_vlan_value,
8460 (void *)&cmd_flow_director_flexbytes,
8461 (void *)&cmd_flow_director_flexbytes_value,
8462 (void *)&cmd_flow_director_drop,
8463 (void *)&cmd_flow_director_queue,
8464 (void *)&cmd_flow_director_queue_id,
8465 (void *)&cmd_flow_director_fd_id,
8466 (void *)&cmd_flow_director_fd_id_value,
8471 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8472 .f = cmd_flow_director_filter_parsed,
8474 .help_str = "add or delete a tunnel flow director entry on NIC",
8476 (void *)&cmd_flow_director_filter,
8477 (void *)&cmd_flow_director_port_id,
8478 (void *)&cmd_flow_director_mode,
8479 (void *)&cmd_flow_director_mode_tunnel,
8480 (void *)&cmd_flow_director_ops,
8481 (void *)&cmd_flow_director_mac,
8482 (void *)&cmd_flow_director_mac_addr,
8483 (void *)&cmd_flow_director_vlan,
8484 (void *)&cmd_flow_director_vlan_value,
8485 (void *)&cmd_flow_director_tunnel,
8486 (void *)&cmd_flow_director_tunnel_type,
8487 (void *)&cmd_flow_director_tunnel_id,
8488 (void *)&cmd_flow_director_tunnel_id_value,
8489 (void *)&cmd_flow_director_flexbytes,
8490 (void *)&cmd_flow_director_flexbytes_value,
8491 (void *)&cmd_flow_director_drop,
8492 (void *)&cmd_flow_director_queue,
8493 (void *)&cmd_flow_director_queue_id,
8494 (void *)&cmd_flow_director_fd_id,
8495 (void *)&cmd_flow_director_fd_id_value,
8500 struct cmd_flush_flow_director_result {
8501 cmdline_fixed_string_t flush_flow_director;
8505 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8506 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8507 flush_flow_director, "flush_flow_director");
8508 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8509 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8513 cmd_flush_flow_director_parsed(void *parsed_result,
8514 __attribute__((unused)) struct cmdline *cl,
8515 __attribute__((unused)) void *data)
8517 struct cmd_flow_director_result *res = parsed_result;
8520 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8522 printf("flow director is not supported on port %u.\n",
8527 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8528 RTE_ETH_FILTER_FLUSH, NULL);
8530 printf("flow director table flushing error: (%s)\n",
8534 cmdline_parse_inst_t cmd_flush_flow_director = {
8535 .f = cmd_flush_flow_director_parsed,
8537 .help_str = "flush all flow director entries of a device on NIC",
8539 (void *)&cmd_flush_flow_director_flush,
8540 (void *)&cmd_flush_flow_director_port_id,
8545 /* *** deal with flow director mask *** */
8546 struct cmd_flow_director_mask_result {
8547 cmdline_fixed_string_t flow_director_mask;
8549 cmdline_fixed_string_t mode;
8550 cmdline_fixed_string_t mode_value;
8551 cmdline_fixed_string_t vlan;
8553 cmdline_fixed_string_t src_mask;
8554 cmdline_ipaddr_t ipv4_src;
8555 cmdline_ipaddr_t ipv6_src;
8557 cmdline_fixed_string_t dst_mask;
8558 cmdline_ipaddr_t ipv4_dst;
8559 cmdline_ipaddr_t ipv6_dst;
8561 cmdline_fixed_string_t mac;
8562 uint8_t mac_addr_byte_mask;
8563 cmdline_fixed_string_t tunnel_id;
8564 uint32_t tunnel_id_mask;
8565 cmdline_fixed_string_t tunnel_type;
8566 uint8_t tunnel_type_mask;
8570 cmd_flow_director_mask_parsed(void *parsed_result,
8571 __attribute__((unused)) struct cmdline *cl,
8572 __attribute__((unused)) void *data)
8574 struct cmd_flow_director_mask_result *res = parsed_result;
8575 struct rte_eth_fdir_masks *mask;
8576 struct rte_port *port;
8578 if (res->port_id > nb_ports) {
8579 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8583 port = &ports[res->port_id];
8584 /** Check if the port is not started **/
8585 if (port->port_status != RTE_PORT_STOPPED) {
8586 printf("Please stop port %d first\n", res->port_id);
8590 mask = &port->dev_conf.fdir_conf.mask;
8592 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8593 if (strcmp(res->mode_value, "MAC-VLAN")) {
8594 printf("Please set mode to MAC-VLAN.\n");
8598 mask->vlan_tci_mask = res->vlan_mask;
8599 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8600 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8601 if (strcmp(res->mode_value, "Tunnel")) {
8602 printf("Please set mode to Tunnel.\n");
8606 mask->vlan_tci_mask = res->vlan_mask;
8607 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8608 mask->tunnel_id_mask = res->tunnel_id_mask;
8609 mask->tunnel_type_mask = res->tunnel_type_mask;
8611 if (strcmp(res->mode_value, "IP")) {
8612 printf("Please set mode to IP.\n");
8616 mask->vlan_tci_mask = res->vlan_mask;
8617 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8618 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8619 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8620 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8621 mask->src_port_mask = res->port_src;
8622 mask->dst_port_mask = res->port_dst;
8625 cmd_reconfig_device_queue(res->port_id, 1, 1);
8628 cmdline_parse_token_string_t cmd_flow_director_mask =
8629 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8630 flow_director_mask, "flow_director_mask");
8631 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8632 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8634 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8635 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8637 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8638 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8640 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8641 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8642 src_mask, "src_mask");
8643 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8644 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8646 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8647 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8649 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8650 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8652 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8654 dst_mask, "dst_mask");
8655 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8656 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8658 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8659 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8661 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8662 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8665 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8666 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8668 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8669 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8671 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8672 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8673 mode_value, "MAC-VLAN");
8674 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8675 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8676 mode_value, "Tunnel");
8677 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8678 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8680 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8681 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8682 mac_addr_byte_mask, UINT8);
8683 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8685 tunnel_type, "tunnel-type");
8686 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8687 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8688 tunnel_type_mask, UINT8);
8689 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8691 tunnel_id, "tunnel-id");
8692 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8693 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8694 tunnel_id_mask, UINT32);
8696 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8697 .f = cmd_flow_director_mask_parsed,
8699 .help_str = "set IP mode flow director's mask on NIC",
8701 (void *)&cmd_flow_director_mask,
8702 (void *)&cmd_flow_director_mask_port_id,
8703 (void *)&cmd_flow_director_mask_mode,
8704 (void *)&cmd_flow_director_mask_mode_ip,
8705 (void *)&cmd_flow_director_mask_vlan,
8706 (void *)&cmd_flow_director_mask_vlan_value,
8707 (void *)&cmd_flow_director_mask_src,
8708 (void *)&cmd_flow_director_mask_ipv4_src,
8709 (void *)&cmd_flow_director_mask_ipv6_src,
8710 (void *)&cmd_flow_director_mask_port_src,
8711 (void *)&cmd_flow_director_mask_dst,
8712 (void *)&cmd_flow_director_mask_ipv4_dst,
8713 (void *)&cmd_flow_director_mask_ipv6_dst,
8714 (void *)&cmd_flow_director_mask_port_dst,
8719 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8720 .f = cmd_flow_director_mask_parsed,
8722 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8724 (void *)&cmd_flow_director_mask,
8725 (void *)&cmd_flow_director_mask_port_id,
8726 (void *)&cmd_flow_director_mask_mode,
8727 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8728 (void *)&cmd_flow_director_mask_vlan,
8729 (void *)&cmd_flow_director_mask_vlan_value,
8730 (void *)&cmd_flow_director_mask_mac,
8731 (void *)&cmd_flow_director_mask_mac_value,
8736 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8737 .f = cmd_flow_director_mask_parsed,
8739 .help_str = "set tunnel mode flow director's mask on NIC",
8741 (void *)&cmd_flow_director_mask,
8742 (void *)&cmd_flow_director_mask_port_id,
8743 (void *)&cmd_flow_director_mask_mode,
8744 (void *)&cmd_flow_director_mask_mode_tunnel,
8745 (void *)&cmd_flow_director_mask_vlan,
8746 (void *)&cmd_flow_director_mask_vlan_value,
8747 (void *)&cmd_flow_director_mask_mac,
8748 (void *)&cmd_flow_director_mask_mac_value,
8749 (void *)&cmd_flow_director_mask_tunnel_type,
8750 (void *)&cmd_flow_director_mask_tunnel_type_value,
8751 (void *)&cmd_flow_director_mask_tunnel_id,
8752 (void *)&cmd_flow_director_mask_tunnel_id_value,
8757 /* *** deal with flow director mask on flexible payload *** */
8758 struct cmd_flow_director_flex_mask_result {
8759 cmdline_fixed_string_t flow_director_flexmask;
8761 cmdline_fixed_string_t flow;
8762 cmdline_fixed_string_t flow_type;
8763 cmdline_fixed_string_t mask;
8767 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8768 __attribute__((unused)) struct cmdline *cl,
8769 __attribute__((unused)) void *data)
8771 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8772 struct rte_eth_fdir_info fdir_info;
8773 struct rte_eth_fdir_flex_mask flex_mask;
8774 struct rte_port *port;
8775 uint32_t flow_type_mask;
8779 if (res->port_id > nb_ports) {
8780 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8784 port = &ports[res->port_id];
8785 /** Check if the port is not started **/
8786 if (port->port_status != RTE_PORT_STOPPED) {
8787 printf("Please stop port %d first\n", res->port_id);
8791 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8792 ret = parse_flexbytes(res->mask,
8794 RTE_ETH_FDIR_MAX_FLEXLEN);
8796 printf("error: Cannot parse mask input.\n");
8800 memset(&fdir_info, 0, sizeof(fdir_info));
8801 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8802 RTE_ETH_FILTER_INFO, &fdir_info);
8804 printf("Cannot get FDir filter info\n");
8808 if (!strcmp(res->flow_type, "none")) {
8809 /* means don't specify the flow type */
8810 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8811 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8812 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8813 0, sizeof(struct rte_eth_fdir_flex_mask));
8814 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8815 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8817 sizeof(struct rte_eth_fdir_flex_mask));
8818 cmd_reconfig_device_queue(res->port_id, 1, 1);
8821 flow_type_mask = fdir_info.flow_types_mask[0];
8822 if (!strcmp(res->flow_type, "all")) {
8823 if (!flow_type_mask) {
8824 printf("No flow type supported\n");
8827 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8828 if (flow_type_mask & (1 << i)) {
8829 flex_mask.flow_type = i;
8830 fdir_set_flex_mask(res->port_id, &flex_mask);
8833 cmd_reconfig_device_queue(res->port_id, 1, 1);
8836 flex_mask.flow_type = str2flowtype(res->flow_type);
8837 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8838 printf("Flow type %s not supported on port %d\n",
8839 res->flow_type, res->port_id);
8842 fdir_set_flex_mask(res->port_id, &flex_mask);
8843 cmd_reconfig_device_queue(res->port_id, 1, 1);
8846 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8847 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8848 flow_director_flexmask,
8849 "flow_director_flex_mask");
8850 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8851 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8853 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8854 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8856 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8857 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8858 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8859 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8860 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8864 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8865 .f = cmd_flow_director_flex_mask_parsed,
8867 .help_str = "set flow director's flex mask on NIC",
8869 (void *)&cmd_flow_director_flexmask,
8870 (void *)&cmd_flow_director_flexmask_port_id,
8871 (void *)&cmd_flow_director_flexmask_flow,
8872 (void *)&cmd_flow_director_flexmask_flow_type,
8873 (void *)&cmd_flow_director_flexmask_mask,
8878 /* *** deal with flow director flexible payload configuration *** */
8879 struct cmd_flow_director_flexpayload_result {
8880 cmdline_fixed_string_t flow_director_flexpayload;
8882 cmdline_fixed_string_t payload_layer;
8883 cmdline_fixed_string_t payload_cfg;
8887 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8890 const char *p, *p0 = q_arg;
8892 unsigned long int_fld;
8893 char *str_fld[max_num];
8898 p = strchr(p0, '(');
8902 p0 = strchr(p, ')');
8907 if (size >= sizeof(s))
8910 snprintf(s, sizeof(s), "%.*s", size, p);
8911 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8912 if (ret < 0 || ret > max_num)
8914 for (i = 0; i < ret; i++) {
8916 int_fld = strtoul(str_fld[i], &end, 0);
8917 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8919 offsets[i] = (uint16_t)int_fld;
8925 cmd_flow_director_flxpld_parsed(void *parsed_result,
8926 __attribute__((unused)) struct cmdline *cl,
8927 __attribute__((unused)) void *data)
8929 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8930 struct rte_eth_flex_payload_cfg flex_cfg;
8931 struct rte_port *port;
8934 if (res->port_id > nb_ports) {
8935 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8939 port = &ports[res->port_id];
8940 /** Check if the port is not started **/
8941 if (port->port_status != RTE_PORT_STOPPED) {
8942 printf("Please stop port %d first\n", res->port_id);
8946 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8948 if (!strcmp(res->payload_layer, "raw"))
8949 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8950 else if (!strcmp(res->payload_layer, "l2"))
8951 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8952 else if (!strcmp(res->payload_layer, "l3"))
8953 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8954 else if (!strcmp(res->payload_layer, "l4"))
8955 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8957 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8958 RTE_ETH_FDIR_MAX_FLEXLEN);
8960 printf("error: Cannot parse flex payload input.\n");
8964 fdir_set_flex_payload(res->port_id, &flex_cfg);
8965 cmd_reconfig_device_queue(res->port_id, 1, 1);
8968 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8969 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8970 flow_director_flexpayload,
8971 "flow_director_flex_payload");
8972 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8973 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8975 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8976 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8977 payload_layer, "raw#l2#l3#l4");
8978 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8979 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8982 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8983 .f = cmd_flow_director_flxpld_parsed,
8985 .help_str = "set flow director's flex payload on NIC",
8987 (void *)&cmd_flow_director_flexpayload,
8988 (void *)&cmd_flow_director_flexpayload_port_id,
8989 (void *)&cmd_flow_director_flexpayload_payload_layer,
8990 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8995 /* *** Classification Filters Control *** */
8996 /* *** Get symmetric hash enable per port *** */
8997 struct cmd_get_sym_hash_ena_per_port_result {
8998 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9003 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9004 __rte_unused struct cmdline *cl,
9005 __rte_unused void *data)
9007 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9008 struct rte_eth_hash_filter_info info;
9011 if (rte_eth_dev_filter_supported(res->port_id,
9012 RTE_ETH_FILTER_HASH) < 0) {
9013 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9018 memset(&info, 0, sizeof(info));
9019 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9020 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9021 RTE_ETH_FILTER_GET, &info);
9024 printf("Cannot get symmetric hash enable per port "
9025 "on port %u\n", res->port_id);
9029 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9030 "enabled" : "disabled", res->port_id);
9033 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9034 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9035 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9036 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9037 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9040 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9041 .f = cmd_get_sym_hash_per_port_parsed,
9043 .help_str = "get_sym_hash_ena_per_port port_id",
9045 (void *)&cmd_get_sym_hash_ena_per_port_all,
9046 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9051 /* *** Set symmetric hash enable per port *** */
9052 struct cmd_set_sym_hash_ena_per_port_result {
9053 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9054 cmdline_fixed_string_t enable;
9059 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9060 __rte_unused struct cmdline *cl,
9061 __rte_unused void *data)
9063 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9064 struct rte_eth_hash_filter_info info;
9067 if (rte_eth_dev_filter_supported(res->port_id,
9068 RTE_ETH_FILTER_HASH) < 0) {
9069 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9074 memset(&info, 0, sizeof(info));
9075 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9076 if (!strcmp(res->enable, "enable"))
9077 info.info.enable = 1;
9078 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9079 RTE_ETH_FILTER_SET, &info);
9081 printf("Cannot set symmetric hash enable per port on "
9082 "port %u\n", res->port_id);
9085 printf("Symmetric hash has been set to %s on port %u\n",
9086 res->enable, res->port_id);
9089 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9090 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9091 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9092 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9093 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9095 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9096 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9097 enable, "enable#disable");
9099 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9100 .f = cmd_set_sym_hash_per_port_parsed,
9102 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9104 (void *)&cmd_set_sym_hash_ena_per_port_all,
9105 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9106 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9111 /* Get global config of hash function */
9112 struct cmd_get_hash_global_config_result {
9113 cmdline_fixed_string_t get_hash_global_config;
9118 flowtype_to_str(uint16_t ftype)
9125 {"ipv4", RTE_ETH_FLOW_IPV4},
9126 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9127 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9128 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9129 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9130 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9131 {"ipv6", RTE_ETH_FLOW_IPV6},
9132 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9133 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9134 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9135 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9136 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9137 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9140 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9141 if (ftype_table[i].ftype == ftype)
9142 return ftype_table[i].str;
9149 cmd_get_hash_global_config_parsed(void *parsed_result,
9150 __rte_unused struct cmdline *cl,
9151 __rte_unused void *data)
9153 struct cmd_get_hash_global_config_result *res = parsed_result;
9154 struct rte_eth_hash_filter_info info;
9155 uint32_t idx, offset;
9160 if (rte_eth_dev_filter_supported(res->port_id,
9161 RTE_ETH_FILTER_HASH) < 0) {
9162 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9167 memset(&info, 0, sizeof(info));
9168 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9169 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9170 RTE_ETH_FILTER_GET, &info);
9172 printf("Cannot get hash global configurations by port %d\n",
9177 switch (info.info.global_conf.hash_func) {
9178 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9179 printf("Hash function is Toeplitz\n");
9181 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9182 printf("Hash function is Simple XOR\n");
9185 printf("Unknown hash function\n");
9189 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9190 idx = i / UINT32_BIT;
9191 offset = i % UINT32_BIT;
9192 if (!(info.info.global_conf.valid_bit_mask[idx] &
9195 str = flowtype_to_str(i);
9198 printf("Symmetric hash is %s globally for flow type %s "
9200 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9201 (1UL << offset)) ? "enabled" : "disabled"), str,
9206 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9207 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9208 get_hash_global_config, "get_hash_global_config");
9209 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9210 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9213 cmdline_parse_inst_t cmd_get_hash_global_config = {
9214 .f = cmd_get_hash_global_config_parsed,
9216 .help_str = "get_hash_global_config port_id",
9218 (void *)&cmd_get_hash_global_config_all,
9219 (void *)&cmd_get_hash_global_config_port_id,
9224 /* Set global config of hash function */
9225 struct cmd_set_hash_global_config_result {
9226 cmdline_fixed_string_t set_hash_global_config;
9228 cmdline_fixed_string_t hash_func;
9229 cmdline_fixed_string_t flow_type;
9230 cmdline_fixed_string_t enable;
9234 cmd_set_hash_global_config_parsed(void *parsed_result,
9235 __rte_unused struct cmdline *cl,
9236 __rte_unused void *data)
9238 struct cmd_set_hash_global_config_result *res = parsed_result;
9239 struct rte_eth_hash_filter_info info;
9240 uint32_t ftype, idx, offset;
9243 if (rte_eth_dev_filter_supported(res->port_id,
9244 RTE_ETH_FILTER_HASH) < 0) {
9245 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9249 memset(&info, 0, sizeof(info));
9250 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9251 if (!strcmp(res->hash_func, "toeplitz"))
9252 info.info.global_conf.hash_func =
9253 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9254 else if (!strcmp(res->hash_func, "simple_xor"))
9255 info.info.global_conf.hash_func =
9256 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9257 else if (!strcmp(res->hash_func, "default"))
9258 info.info.global_conf.hash_func =
9259 RTE_ETH_HASH_FUNCTION_DEFAULT;
9261 ftype = str2flowtype(res->flow_type);
9262 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9263 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9264 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9265 if (!strcmp(res->enable, "enable"))
9266 info.info.global_conf.sym_hash_enable_mask[idx] |=
9268 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9269 RTE_ETH_FILTER_SET, &info);
9271 printf("Cannot set global hash configurations by port %d\n",
9274 printf("Global hash configurations have been set "
9275 "succcessfully by port %d\n", res->port_id);
9278 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9279 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9280 set_hash_global_config, "set_hash_global_config");
9281 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9282 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9284 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9285 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9286 hash_func, "toeplitz#simple_xor#default");
9287 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9288 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9290 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9291 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9292 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9293 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9294 enable, "enable#disable");
9296 cmdline_parse_inst_t cmd_set_hash_global_config = {
9297 .f = cmd_set_hash_global_config_parsed,
9299 .help_str = "set_hash_global_config port_id "
9300 "toeplitz|simple_xor|default "
9301 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9302 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9305 (void *)&cmd_set_hash_global_config_all,
9306 (void *)&cmd_set_hash_global_config_port_id,
9307 (void *)&cmd_set_hash_global_config_hash_func,
9308 (void *)&cmd_set_hash_global_config_flow_type,
9309 (void *)&cmd_set_hash_global_config_enable,
9314 /* Set hash input set */
9315 struct cmd_set_hash_input_set_result {
9316 cmdline_fixed_string_t set_hash_input_set;
9318 cmdline_fixed_string_t flow_type;
9319 cmdline_fixed_string_t inset_field;
9320 cmdline_fixed_string_t select;
9323 static enum rte_eth_input_set_field
9324 str2inset(char *string)
9328 static const struct {
9330 enum rte_eth_input_set_field inset;
9332 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9333 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9334 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9335 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9336 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9337 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9338 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9339 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9340 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9341 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9342 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9343 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9344 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9345 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9346 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9347 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9348 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9349 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9350 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9351 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9352 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9353 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9354 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9355 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9356 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9357 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9358 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9359 {"none", RTE_ETH_INPUT_SET_NONE},
9362 for (i = 0; i < RTE_DIM(inset_table); i++) {
9363 if (!strcmp(string, inset_table[i].str))
9364 return inset_table[i].inset;
9367 return RTE_ETH_INPUT_SET_UNKNOWN;
9371 cmd_set_hash_input_set_parsed(void *parsed_result,
9372 __rte_unused struct cmdline *cl,
9373 __rte_unused void *data)
9375 struct cmd_set_hash_input_set_result *res = parsed_result;
9376 struct rte_eth_hash_filter_info info;
9378 memset(&info, 0, sizeof(info));
9379 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9380 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9381 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9382 info.info.input_set_conf.inset_size = 1;
9383 if (!strcmp(res->select, "select"))
9384 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9385 else if (!strcmp(res->select, "add"))
9386 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9387 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9388 RTE_ETH_FILTER_SET, &info);
9391 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9392 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9393 set_hash_input_set, "set_hash_input_set");
9394 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9395 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9397 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9398 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9400 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9401 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9402 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9403 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9405 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9406 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9407 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9408 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9409 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9411 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9412 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9413 select, "select#add");
9415 cmdline_parse_inst_t cmd_set_hash_input_set = {
9416 .f = cmd_set_hash_input_set_parsed,
9418 .help_str = "set_hash_input_set <port_id> "
9419 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9420 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9421 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9422 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9423 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9424 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9425 "fld-7th|fld-8th|none select|add",
9427 (void *)&cmd_set_hash_input_set_cmd,
9428 (void *)&cmd_set_hash_input_set_port_id,
9429 (void *)&cmd_set_hash_input_set_flow_type,
9430 (void *)&cmd_set_hash_input_set_field,
9431 (void *)&cmd_set_hash_input_set_select,
9436 /* Set flow director input set */
9437 struct cmd_set_fdir_input_set_result {
9438 cmdline_fixed_string_t set_fdir_input_set;
9440 cmdline_fixed_string_t flow_type;
9441 cmdline_fixed_string_t inset_field;
9442 cmdline_fixed_string_t select;
9446 cmd_set_fdir_input_set_parsed(void *parsed_result,
9447 __rte_unused struct cmdline *cl,
9448 __rte_unused void *data)
9450 struct cmd_set_fdir_input_set_result *res = parsed_result;
9451 struct rte_eth_fdir_filter_info info;
9453 memset(&info, 0, sizeof(info));
9454 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9455 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9456 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9457 info.info.input_set_conf.inset_size = 1;
9458 if (!strcmp(res->select, "select"))
9459 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9460 else if (!strcmp(res->select, "add"))
9461 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9462 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9463 RTE_ETH_FILTER_SET, &info);
9466 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9467 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9468 set_fdir_input_set, "set_fdir_input_set");
9469 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9470 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9472 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9473 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9475 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9476 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9477 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9478 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9480 "src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#udp-src-port#udp-dst-port#"
9481 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9482 "sctp-veri-tag#fld-1st#fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#"
9483 "fld-7th#fld-8th#none");
9484 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9485 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9486 select, "select#add");
9488 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9489 .f = cmd_set_fdir_input_set_parsed,
9491 .help_str = "set_fdir_input_set <port_id> "
9492 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9493 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9494 "src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|udp-src-port|udp-dst-port|"
9495 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|"
9496 "fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9497 "fld-7th|fld-8th|none select|add",
9499 (void *)&cmd_set_fdir_input_set_cmd,
9500 (void *)&cmd_set_fdir_input_set_port_id,
9501 (void *)&cmd_set_fdir_input_set_flow_type,
9502 (void *)&cmd_set_fdir_input_set_field,
9503 (void *)&cmd_set_fdir_input_set_select,
9508 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9509 struct cmd_mcast_addr_result {
9510 cmdline_fixed_string_t mcast_addr_cmd;
9511 cmdline_fixed_string_t what;
9513 struct ether_addr mc_addr;
9516 static void cmd_mcast_addr_parsed(void *parsed_result,
9517 __attribute__((unused)) struct cmdline *cl,
9518 __attribute__((unused)) void *data)
9520 struct cmd_mcast_addr_result *res = parsed_result;
9522 if (!is_multicast_ether_addr(&res->mc_addr)) {
9523 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9524 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9525 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9526 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9529 if (strcmp(res->what, "add") == 0)
9530 mcast_addr_add(res->port_num, &res->mc_addr);
9532 mcast_addr_remove(res->port_num, &res->mc_addr);
9535 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9536 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9537 mcast_addr_cmd, "mcast_addr");
9538 cmdline_parse_token_string_t cmd_mcast_addr_what =
9539 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9541 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9542 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9543 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9544 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9546 cmdline_parse_inst_t cmd_mcast_addr = {
9547 .f = cmd_mcast_addr_parsed,
9549 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9551 (void *)&cmd_mcast_addr_cmd,
9552 (void *)&cmd_mcast_addr_what,
9553 (void *)&cmd_mcast_addr_portnum,
9554 (void *)&cmd_mcast_addr_addr,
9559 /* ******************************************************************************** */
9561 /* list of instructions */
9562 cmdline_parse_ctx_t main_ctx[] = {
9563 (cmdline_parse_inst_t *)&cmd_help_brief,
9564 (cmdline_parse_inst_t *)&cmd_help_long,
9565 (cmdline_parse_inst_t *)&cmd_quit,
9566 (cmdline_parse_inst_t *)&cmd_showport,
9567 (cmdline_parse_inst_t *)&cmd_showqueue,
9568 (cmdline_parse_inst_t *)&cmd_showportall,
9569 (cmdline_parse_inst_t *)&cmd_showcfg,
9570 (cmdline_parse_inst_t *)&cmd_start,
9571 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9572 (cmdline_parse_inst_t *)&cmd_set_link_up,
9573 (cmdline_parse_inst_t *)&cmd_set_link_down,
9574 (cmdline_parse_inst_t *)&cmd_reset,
9575 (cmdline_parse_inst_t *)&cmd_set_numbers,
9576 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9577 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9578 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9579 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9580 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9581 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9582 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9583 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9584 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9585 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9586 (cmdline_parse_inst_t *)&cmd_set_link_check,
9587 #ifdef RTE_NIC_BYPASS
9588 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9589 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9590 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9591 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9593 #ifdef RTE_LIBRTE_PMD_BOND
9594 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9595 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9596 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9597 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9598 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9599 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9600 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9601 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9602 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9604 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9605 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9606 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9607 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9608 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9609 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
9610 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9611 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9612 (cmdline_parse_inst_t *)&cmd_csum_set,
9613 (cmdline_parse_inst_t *)&cmd_csum_show,
9614 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
9615 (cmdline_parse_inst_t *)&cmd_tso_set,
9616 (cmdline_parse_inst_t *)&cmd_tso_show,
9617 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9618 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9619 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9620 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9621 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9622 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9623 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9624 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9625 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9626 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9627 (cmdline_parse_inst_t *)&cmd_config_dcb,
9628 (cmdline_parse_inst_t *)&cmd_read_reg,
9629 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9630 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9631 (cmdline_parse_inst_t *)&cmd_write_reg,
9632 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9633 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9634 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9635 (cmdline_parse_inst_t *)&cmd_stop,
9636 (cmdline_parse_inst_t *)&cmd_mac_addr,
9637 (cmdline_parse_inst_t *)&cmd_set_qmap,
9638 (cmdline_parse_inst_t *)&cmd_operate_port,
9639 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9640 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
9641 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
9642 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9643 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9644 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9645 (cmdline_parse_inst_t *)&cmd_config_mtu,
9646 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9647 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9648 (cmdline_parse_inst_t *)&cmd_config_rss,
9649 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9650 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9651 (cmdline_parse_inst_t *)&cmd_showport_reta,
9652 (cmdline_parse_inst_t *)&cmd_config_burst,
9653 (cmdline_parse_inst_t *)&cmd_config_thresh,
9654 (cmdline_parse_inst_t *)&cmd_config_threshold,
9655 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9656 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9657 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9658 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9659 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9660 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9661 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9662 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9663 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9664 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9665 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9666 (cmdline_parse_inst_t *)&cmd_global_config,
9667 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9668 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9669 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9670 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9671 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9672 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9673 (cmdline_parse_inst_t *)&cmd_dump,
9674 (cmdline_parse_inst_t *)&cmd_dump_one,
9675 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9676 (cmdline_parse_inst_t *)&cmd_syn_filter,
9677 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
9678 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
9679 (cmdline_parse_inst_t *)&cmd_flex_filter,
9680 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9681 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9682 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9683 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
9684 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
9685 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
9686 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9687 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
9688 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
9689 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
9690 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9691 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9692 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9693 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9694 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9695 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9696 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
9697 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
9698 (cmdline_parse_inst_t *)&cmd_mcast_addr,
9702 /* prompt function, called from main on MASTER lcore */
9708 /* initialize non-constant commands */
9709 cmd_set_fwd_mode_init();
9711 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9715 cmdline_interact(cl);
9716 cmdline_stdin_exit(cl);
9720 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9722 if (id == (portid_t)RTE_PORT_ALL) {
9725 FOREACH_PORT(pid, ports) {
9726 /* check if need_reconfig has been set to 1 */
9727 if (ports[pid].need_reconfig == 0)
9728 ports[pid].need_reconfig = dev;
9729 /* check if need_reconfig_queues has been set to 1 */
9730 if (ports[pid].need_reconfig_queues == 0)
9731 ports[pid].need_reconfig_queues = queue;
9733 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
9734 /* check if need_reconfig has been set to 1 */
9735 if (ports[id].need_reconfig == 0)
9736 ports[id].need_reconfig = dev;
9737 /* check if need_reconfig_queues has been set to 1 */
9738 if (ports[id].need_reconfig_queues == 0)
9739 ports[id].need_reconfig_queues = queue;
9743 #ifdef RTE_NIC_BYPASS
9744 #include <rte_pci_dev_ids.h>
9746 bypass_is_supported(portid_t port_id)
9748 struct rte_port *port;
9749 struct rte_pci_id *pci_id;
9751 if (port_id_is_invalid(port_id, ENABLED_WARN))
9754 /* Get the device id. */
9755 port = &ports[port_id];
9756 pci_id = &port->dev_info.pci_dev->id;
9758 /* Check if NIC supports bypass. */
9759 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9763 printf("\tBypass not supported for port_id = %d.\n", port_id);