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) (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) queue (queue_id) fd_id (fd_id_value)\n"
637 " Add/Del an IP type flow director filter.\n\n"
639 "flow_director_filter (port_id) (add|del|update)"
640 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
641 " src (src_ip_address) (src_port)"
642 " dst (dst_ip_address) (dst_port)"
643 " vlan (vlan_value) flexbytes (flexbytes_value)"
644 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
645 " Add/Del an UDP/TCP type flow director filter.\n\n"
647 "flow_director_filter (port_id) (add|del|update)"
648 " flow (ipv4-sctp|ipv6-sctp)"
649 " src (src_ip_address) (src_port)"
650 " dst (dst_ip_address) (dst_port)"
651 " tag (verification_tag) vlan (vlan_value)"
652 " flexbytes (flexbytes_value) (drop|fwd)"
653 " queue (queue_id) fd_id (fd_id_value)\n"
654 " Add/Del a SCTP type flow director filter.\n\n"
656 "flow_director_filter (port_id) (add|del|update)"
657 " flow l2_payload ether (ethertype)"
658 " flexbytes (flexbytes_value) (drop|fwd)"
659 " queue (queue_id) fd_id (fd_id_value)\n"
660 " Add/Del a l2 payload type flow director filter.\n\n"
662 "flush_flow_director (port_id)\n"
663 " Flush all flow director entries of a device.\n\n"
665 "flow_director_mask (port_id) vlan (vlan_value)"
666 " src_mask (ipv4_src) (ipv6_src) (src_port)"
667 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
668 " Set flow director mask.\n\n"
670 "flow_director_flex_mask (port_id)"
671 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
672 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
674 " Configure mask of flex payload.\n\n"
676 "flow_director_flex_payload (port_id)"
677 " (raw|l2|l3|l4) (config)\n"
678 " Configure flex payload selection.\n\n"
680 "get_sym_hash_ena_per_port (port_id)\n"
681 " get symmetric hash enable configuration per port.\n\n"
683 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
684 " set symmetric hash enable configuration per port"
685 " to enable or disable.\n\n"
687 "get_hash_global_config (port_id)\n"
688 " Get the global configurations of hash filters.\n\n"
690 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
691 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
692 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
693 " (enable|disable)\n"
694 " Set the global configurations of hash filters.\n\n"
699 cmdline_parse_token_string_t cmd_help_long_help =
700 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
702 cmdline_parse_token_string_t cmd_help_long_section =
703 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
704 "all#control#display#config#"
705 "ports#registers#filters");
707 cmdline_parse_inst_t cmd_help_long = {
708 .f = cmd_help_long_parsed,
710 .help_str = "show help",
712 (void *)&cmd_help_long_help,
713 (void *)&cmd_help_long_section,
719 /* *** start/stop/close all ports *** */
720 struct cmd_operate_port_result {
721 cmdline_fixed_string_t keyword;
722 cmdline_fixed_string_t name;
723 cmdline_fixed_string_t value;
726 static void cmd_operate_port_parsed(void *parsed_result,
727 __attribute__((unused)) struct cmdline *cl,
728 __attribute__((unused)) void *data)
730 struct cmd_operate_port_result *res = parsed_result;
732 if (!strcmp(res->name, "start"))
733 start_port(RTE_PORT_ALL);
734 else if (!strcmp(res->name, "stop"))
735 stop_port(RTE_PORT_ALL);
736 else if (!strcmp(res->name, "close"))
737 close_port(RTE_PORT_ALL);
739 printf("Unknown parameter\n");
742 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
743 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
745 cmdline_parse_token_string_t cmd_operate_port_all_port =
746 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
748 cmdline_parse_token_string_t cmd_operate_port_all_all =
749 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
751 cmdline_parse_inst_t cmd_operate_port = {
752 .f = cmd_operate_port_parsed,
754 .help_str = "port start|stop|close all: start/stop/close all ports",
756 (void *)&cmd_operate_port_all_cmd,
757 (void *)&cmd_operate_port_all_port,
758 (void *)&cmd_operate_port_all_all,
763 /* *** start/stop/close specific port *** */
764 struct cmd_operate_specific_port_result {
765 cmdline_fixed_string_t keyword;
766 cmdline_fixed_string_t name;
770 static void cmd_operate_specific_port_parsed(void *parsed_result,
771 __attribute__((unused)) struct cmdline *cl,
772 __attribute__((unused)) void *data)
774 struct cmd_operate_specific_port_result *res = parsed_result;
776 if (!strcmp(res->name, "start"))
777 start_port(res->value);
778 else if (!strcmp(res->name, "stop"))
779 stop_port(res->value);
780 else if (!strcmp(res->name, "close"))
781 close_port(res->value);
783 printf("Unknown parameter\n");
786 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
787 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
789 cmdline_parse_token_string_t cmd_operate_specific_port_port =
790 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
791 name, "start#stop#close");
792 cmdline_parse_token_num_t cmd_operate_specific_port_id =
793 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
796 cmdline_parse_inst_t cmd_operate_specific_port = {
797 .f = cmd_operate_specific_port_parsed,
799 .help_str = "port start|stop|close X: start/stop/close port X",
801 (void *)&cmd_operate_specific_port_cmd,
802 (void *)&cmd_operate_specific_port_port,
803 (void *)&cmd_operate_specific_port_id,
808 /* *** attach a specified port *** */
809 struct cmd_operate_attach_port_result {
810 cmdline_fixed_string_t port;
811 cmdline_fixed_string_t keyword;
812 cmdline_fixed_string_t identifier;
815 static void cmd_operate_attach_port_parsed(void *parsed_result,
816 __attribute__((unused)) struct cmdline *cl,
817 __attribute__((unused)) void *data)
819 struct cmd_operate_attach_port_result *res = parsed_result;
821 if (!strcmp(res->keyword, "attach"))
822 attach_port(res->identifier);
824 printf("Unknown parameter\n");
827 cmdline_parse_token_string_t cmd_operate_attach_port_port =
828 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
830 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
831 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
833 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
834 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
837 cmdline_parse_inst_t cmd_operate_attach_port = {
838 .f = cmd_operate_attach_port_parsed,
840 .help_str = "port attach identifier, "
841 "identifier: pci address or virtual dev name",
843 (void *)&cmd_operate_attach_port_port,
844 (void *)&cmd_operate_attach_port_keyword,
845 (void *)&cmd_operate_attach_port_identifier,
850 /* *** detach a specified port *** */
851 struct cmd_operate_detach_port_result {
852 cmdline_fixed_string_t port;
853 cmdline_fixed_string_t keyword;
857 static void cmd_operate_detach_port_parsed(void *parsed_result,
858 __attribute__((unused)) struct cmdline *cl,
859 __attribute__((unused)) void *data)
861 struct cmd_operate_detach_port_result *res = parsed_result;
863 if (!strcmp(res->keyword, "detach"))
864 detach_port(res->port_id);
866 printf("Unknown parameter\n");
869 cmdline_parse_token_string_t cmd_operate_detach_port_port =
870 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
872 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
873 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
875 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
876 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
879 cmdline_parse_inst_t cmd_operate_detach_port = {
880 .f = cmd_operate_detach_port_parsed,
882 .help_str = "port detach port_id",
884 (void *)&cmd_operate_detach_port_port,
885 (void *)&cmd_operate_detach_port_keyword,
886 (void *)&cmd_operate_detach_port_port_id,
891 /* *** configure speed for all ports *** */
892 struct cmd_config_speed_all {
893 cmdline_fixed_string_t port;
894 cmdline_fixed_string_t keyword;
895 cmdline_fixed_string_t all;
896 cmdline_fixed_string_t item1;
897 cmdline_fixed_string_t item2;
898 cmdline_fixed_string_t value1;
899 cmdline_fixed_string_t value2;
903 cmd_config_speed_all_parsed(void *parsed_result,
904 __attribute__((unused)) struct cmdline *cl,
905 __attribute__((unused)) void *data)
907 struct cmd_config_speed_all *res = parsed_result;
908 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
909 uint16_t link_duplex = 0;
912 if (!all_ports_stopped()) {
913 printf("Please stop all ports first\n");
917 if (!strcmp(res->value1, "10"))
918 link_speed = ETH_LINK_SPEED_10;
919 else if (!strcmp(res->value1, "100"))
920 link_speed = ETH_LINK_SPEED_100;
921 else if (!strcmp(res->value1, "1000"))
922 link_speed = ETH_LINK_SPEED_1000;
923 else if (!strcmp(res->value1, "10000"))
924 link_speed = ETH_LINK_SPEED_10G;
925 else if (!strcmp(res->value1, "40000"))
926 link_speed = ETH_LINK_SPEED_40G;
927 else if (!strcmp(res->value1, "auto"))
928 link_speed = ETH_LINK_SPEED_AUTONEG;
930 printf("Unknown parameter\n");
934 if (!strcmp(res->value2, "half"))
935 link_duplex = ETH_LINK_HALF_DUPLEX;
936 else if (!strcmp(res->value2, "full"))
937 link_duplex = ETH_LINK_FULL_DUPLEX;
938 else if (!strcmp(res->value2, "auto"))
939 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
941 printf("Unknown parameter\n");
945 FOREACH_PORT(pid, ports) {
946 ports[pid].dev_conf.link_speed = link_speed;
947 ports[pid].dev_conf.link_duplex = link_duplex;
950 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
953 cmdline_parse_token_string_t cmd_config_speed_all_port =
954 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
955 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
956 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
958 cmdline_parse_token_string_t cmd_config_speed_all_all =
959 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
960 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
961 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
962 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
963 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
964 "10#100#1000#10000#40000#auto");
965 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
966 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
967 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
968 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
971 cmdline_parse_inst_t cmd_config_speed_all = {
972 .f = cmd_config_speed_all_parsed,
974 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
977 (void *)&cmd_config_speed_all_port,
978 (void *)&cmd_config_speed_all_keyword,
979 (void *)&cmd_config_speed_all_all,
980 (void *)&cmd_config_speed_all_item1,
981 (void *)&cmd_config_speed_all_value1,
982 (void *)&cmd_config_speed_all_item2,
983 (void *)&cmd_config_speed_all_value2,
988 /* *** configure speed for specific port *** */
989 struct cmd_config_speed_specific {
990 cmdline_fixed_string_t port;
991 cmdline_fixed_string_t keyword;
993 cmdline_fixed_string_t item1;
994 cmdline_fixed_string_t item2;
995 cmdline_fixed_string_t value1;
996 cmdline_fixed_string_t value2;
1000 cmd_config_speed_specific_parsed(void *parsed_result,
1001 __attribute__((unused)) struct cmdline *cl,
1002 __attribute__((unused)) void *data)
1004 struct cmd_config_speed_specific *res = parsed_result;
1005 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1006 uint16_t link_duplex = 0;
1008 if (!all_ports_stopped()) {
1009 printf("Please stop all ports first\n");
1013 if (port_id_is_invalid(res->id, ENABLED_WARN))
1016 if (!strcmp(res->value1, "10"))
1017 link_speed = ETH_LINK_SPEED_10;
1018 else if (!strcmp(res->value1, "100"))
1019 link_speed = ETH_LINK_SPEED_100;
1020 else if (!strcmp(res->value1, "1000"))
1021 link_speed = ETH_LINK_SPEED_1000;
1022 else if (!strcmp(res->value1, "10000"))
1023 link_speed = ETH_LINK_SPEED_10000;
1024 else if (!strcmp(res->value1, "40000"))
1025 link_speed = ETH_LINK_SPEED_40G;
1026 else if (!strcmp(res->value1, "auto"))
1027 link_speed = ETH_LINK_SPEED_AUTONEG;
1029 printf("Unknown parameter\n");
1033 if (!strcmp(res->value2, "half"))
1034 link_duplex = ETH_LINK_HALF_DUPLEX;
1035 else if (!strcmp(res->value2, "full"))
1036 link_duplex = ETH_LINK_FULL_DUPLEX;
1037 else if (!strcmp(res->value2, "auto"))
1038 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1040 printf("Unknown parameter\n");
1044 ports[res->id].dev_conf.link_speed = link_speed;
1045 ports[res->id].dev_conf.link_duplex = link_duplex;
1047 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1051 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1052 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1054 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1055 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1057 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1058 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1059 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1060 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1062 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1063 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1064 "10#100#1000#10000#40000#auto");
1065 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1066 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1068 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1069 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1072 cmdline_parse_inst_t cmd_config_speed_specific = {
1073 .f = cmd_config_speed_specific_parsed,
1075 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1078 (void *)&cmd_config_speed_specific_port,
1079 (void *)&cmd_config_speed_specific_keyword,
1080 (void *)&cmd_config_speed_specific_id,
1081 (void *)&cmd_config_speed_specific_item1,
1082 (void *)&cmd_config_speed_specific_value1,
1083 (void *)&cmd_config_speed_specific_item2,
1084 (void *)&cmd_config_speed_specific_value2,
1089 /* *** configure txq/rxq, txd/rxd *** */
1090 struct cmd_config_rx_tx {
1091 cmdline_fixed_string_t port;
1092 cmdline_fixed_string_t keyword;
1093 cmdline_fixed_string_t all;
1094 cmdline_fixed_string_t name;
1099 cmd_config_rx_tx_parsed(void *parsed_result,
1100 __attribute__((unused)) struct cmdline *cl,
1101 __attribute__((unused)) void *data)
1103 struct cmd_config_rx_tx *res = parsed_result;
1105 if (!all_ports_stopped()) {
1106 printf("Please stop all ports first\n");
1110 if (!strcmp(res->name, "rxq")) {
1111 if (res->value <= 0) {
1112 printf("rxq %d invalid - must be > 0\n", res->value);
1115 nb_rxq = res->value;
1117 else if (!strcmp(res->name, "txq")) {
1118 if (res->value <= 0) {
1119 printf("txq %d invalid - must be > 0\n", res->value);
1122 nb_txq = res->value;
1124 else if (!strcmp(res->name, "rxd")) {
1125 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1126 printf("rxd %d invalid - must be > 0 && <= %d\n",
1127 res->value, RTE_TEST_RX_DESC_MAX);
1130 nb_rxd = res->value;
1131 } else if (!strcmp(res->name, "txd")) {
1132 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1133 printf("txd %d invalid - must be > 0 && <= %d\n",
1134 res->value, RTE_TEST_TX_DESC_MAX);
1137 nb_txd = res->value;
1139 printf("Unknown parameter\n");
1145 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1148 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1149 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1150 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1151 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1152 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1154 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1155 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1157 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1158 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1160 cmdline_parse_inst_t cmd_config_rx_tx = {
1161 .f = cmd_config_rx_tx_parsed,
1163 .help_str = "port config all rxq|txq|rxd|txd value",
1165 (void *)&cmd_config_rx_tx_port,
1166 (void *)&cmd_config_rx_tx_keyword,
1167 (void *)&cmd_config_rx_tx_all,
1168 (void *)&cmd_config_rx_tx_name,
1169 (void *)&cmd_config_rx_tx_value,
1174 /* *** config max packet length *** */
1175 struct cmd_config_max_pkt_len_result {
1176 cmdline_fixed_string_t port;
1177 cmdline_fixed_string_t keyword;
1178 cmdline_fixed_string_t all;
1179 cmdline_fixed_string_t name;
1184 cmd_config_max_pkt_len_parsed(void *parsed_result,
1185 __attribute__((unused)) struct cmdline *cl,
1186 __attribute__((unused)) void *data)
1188 struct cmd_config_max_pkt_len_result *res = parsed_result;
1190 if (!all_ports_stopped()) {
1191 printf("Please stop all ports first\n");
1195 if (!strcmp(res->name, "max-pkt-len")) {
1196 if (res->value < ETHER_MIN_LEN) {
1197 printf("max-pkt-len can not be less than %d\n",
1201 if (res->value == rx_mode.max_rx_pkt_len)
1204 rx_mode.max_rx_pkt_len = res->value;
1205 if (res->value > ETHER_MAX_LEN)
1206 rx_mode.jumbo_frame = 1;
1208 rx_mode.jumbo_frame = 0;
1210 printf("Unknown parameter\n");
1216 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1219 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1220 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1222 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1223 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1225 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1226 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1228 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1229 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1231 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1232 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1235 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1236 .f = cmd_config_max_pkt_len_parsed,
1238 .help_str = "port config all max-pkt-len value",
1240 (void *)&cmd_config_max_pkt_len_port,
1241 (void *)&cmd_config_max_pkt_len_keyword,
1242 (void *)&cmd_config_max_pkt_len_all,
1243 (void *)&cmd_config_max_pkt_len_name,
1244 (void *)&cmd_config_max_pkt_len_value,
1249 /* *** configure port MTU *** */
1250 struct cmd_config_mtu_result {
1251 cmdline_fixed_string_t port;
1252 cmdline_fixed_string_t keyword;
1253 cmdline_fixed_string_t mtu;
1259 cmd_config_mtu_parsed(void *parsed_result,
1260 __attribute__((unused)) struct cmdline *cl,
1261 __attribute__((unused)) void *data)
1263 struct cmd_config_mtu_result *res = parsed_result;
1265 if (res->value < ETHER_MIN_LEN) {
1266 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1269 port_mtu_set(res->port_id, res->value);
1272 cmdline_parse_token_string_t cmd_config_mtu_port =
1273 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1275 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1276 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1278 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1279 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1281 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1282 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1283 cmdline_parse_token_num_t cmd_config_mtu_value =
1284 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1286 cmdline_parse_inst_t cmd_config_mtu = {
1287 .f = cmd_config_mtu_parsed,
1289 .help_str = "port config mtu value",
1291 (void *)&cmd_config_mtu_port,
1292 (void *)&cmd_config_mtu_keyword,
1293 (void *)&cmd_config_mtu_mtu,
1294 (void *)&cmd_config_mtu_port_id,
1295 (void *)&cmd_config_mtu_value,
1300 /* *** configure rx mode *** */
1301 struct cmd_config_rx_mode_flag {
1302 cmdline_fixed_string_t port;
1303 cmdline_fixed_string_t keyword;
1304 cmdline_fixed_string_t all;
1305 cmdline_fixed_string_t name;
1306 cmdline_fixed_string_t value;
1310 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1311 __attribute__((unused)) struct cmdline *cl,
1312 __attribute__((unused)) void *data)
1314 struct cmd_config_rx_mode_flag *res = parsed_result;
1316 if (!all_ports_stopped()) {
1317 printf("Please stop all ports first\n");
1321 if (!strcmp(res->name, "crc-strip")) {
1322 if (!strcmp(res->value, "on"))
1323 rx_mode.hw_strip_crc = 1;
1324 else if (!strcmp(res->value, "off"))
1325 rx_mode.hw_strip_crc = 0;
1327 printf("Unknown parameter\n");
1330 } else if (!strcmp(res->name, "rx-cksum")) {
1331 if (!strcmp(res->value, "on"))
1332 rx_mode.hw_ip_checksum = 1;
1333 else if (!strcmp(res->value, "off"))
1334 rx_mode.hw_ip_checksum = 0;
1336 printf("Unknown parameter\n");
1339 } else if (!strcmp(res->name, "hw-vlan")) {
1340 if (!strcmp(res->value, "on")) {
1341 rx_mode.hw_vlan_filter = 1;
1342 rx_mode.hw_vlan_strip = 1;
1344 else if (!strcmp(res->value, "off")) {
1345 rx_mode.hw_vlan_filter = 0;
1346 rx_mode.hw_vlan_strip = 0;
1349 printf("Unknown parameter\n");
1352 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1353 if (!strcmp(res->value, "on"))
1354 rx_mode.hw_vlan_filter = 1;
1355 else if (!strcmp(res->value, "off"))
1356 rx_mode.hw_vlan_filter = 0;
1358 printf("Unknown parameter\n");
1361 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1362 if (!strcmp(res->value, "on"))
1363 rx_mode.hw_vlan_strip = 1;
1364 else if (!strcmp(res->value, "off"))
1365 rx_mode.hw_vlan_strip = 0;
1367 printf("Unknown parameter\n");
1370 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1371 if (!strcmp(res->value, "on"))
1372 rx_mode.hw_vlan_extend = 1;
1373 else if (!strcmp(res->value, "off"))
1374 rx_mode.hw_vlan_extend = 0;
1376 printf("Unknown parameter\n");
1379 } else if (!strcmp(res->name, "drop-en")) {
1380 if (!strcmp(res->value, "on"))
1382 else if (!strcmp(res->value, "off"))
1385 printf("Unknown parameter\n");
1389 printf("Unknown parameter\n");
1395 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1398 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1400 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1401 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1403 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1404 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1405 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1406 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1407 "crc-strip#rx-cksum#hw-vlan#"
1408 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1409 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1410 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1413 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1414 .f = cmd_config_rx_mode_flag_parsed,
1416 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1417 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1419 (void *)&cmd_config_rx_mode_flag_port,
1420 (void *)&cmd_config_rx_mode_flag_keyword,
1421 (void *)&cmd_config_rx_mode_flag_all,
1422 (void *)&cmd_config_rx_mode_flag_name,
1423 (void *)&cmd_config_rx_mode_flag_value,
1428 /* *** configure rss *** */
1429 struct cmd_config_rss {
1430 cmdline_fixed_string_t port;
1431 cmdline_fixed_string_t keyword;
1432 cmdline_fixed_string_t all;
1433 cmdline_fixed_string_t name;
1434 cmdline_fixed_string_t value;
1438 cmd_config_rss_parsed(void *parsed_result,
1439 __attribute__((unused)) struct cmdline *cl,
1440 __attribute__((unused)) void *data)
1442 struct cmd_config_rss *res = parsed_result;
1443 struct rte_eth_rss_conf rss_conf;
1446 if (!strcmp(res->value, "all"))
1447 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1448 ETH_RSS_UDP | ETH_RSS_SCTP |
1450 else if (!strcmp(res->value, "ip"))
1451 rss_conf.rss_hf = ETH_RSS_IP;
1452 else if (!strcmp(res->value, "udp"))
1453 rss_conf.rss_hf = ETH_RSS_UDP;
1454 else if (!strcmp(res->value, "tcp"))
1455 rss_conf.rss_hf = ETH_RSS_TCP;
1456 else if (!strcmp(res->value, "sctp"))
1457 rss_conf.rss_hf = ETH_RSS_SCTP;
1458 else if (!strcmp(res->value, "ether"))
1459 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1460 else if (!strcmp(res->value, "none"))
1461 rss_conf.rss_hf = 0;
1463 printf("Unknown parameter\n");
1466 rss_conf.rss_key = NULL;
1467 for (i = 0; i < rte_eth_dev_count(); i++)
1468 rte_eth_dev_rss_hash_update(i, &rss_conf);
1471 cmdline_parse_token_string_t cmd_config_rss_port =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1473 cmdline_parse_token_string_t cmd_config_rss_keyword =
1474 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1475 cmdline_parse_token_string_t cmd_config_rss_all =
1476 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1477 cmdline_parse_token_string_t cmd_config_rss_name =
1478 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1479 cmdline_parse_token_string_t cmd_config_rss_value =
1480 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1481 "all#ip#tcp#udp#sctp#ether#none");
1483 cmdline_parse_inst_t cmd_config_rss = {
1484 .f = cmd_config_rss_parsed,
1486 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1488 (void *)&cmd_config_rss_port,
1489 (void *)&cmd_config_rss_keyword,
1490 (void *)&cmd_config_rss_all,
1491 (void *)&cmd_config_rss_name,
1492 (void *)&cmd_config_rss_value,
1497 /* *** configure rss hash key *** */
1498 struct cmd_config_rss_hash_key {
1499 cmdline_fixed_string_t port;
1500 cmdline_fixed_string_t config;
1502 cmdline_fixed_string_t rss_hash_key;
1503 cmdline_fixed_string_t rss_type;
1504 cmdline_fixed_string_t key;
1507 #define RSS_HASH_KEY_LENGTH 40
1509 hexa_digit_to_value(char hexa_digit)
1511 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1512 return (uint8_t) (hexa_digit - '0');
1513 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1514 return (uint8_t) ((hexa_digit - 'a') + 10);
1515 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1516 return (uint8_t) ((hexa_digit - 'A') + 10);
1517 /* Invalid hexa digit */
1522 parse_and_check_key_hexa_digit(char *key, int idx)
1526 hexa_v = hexa_digit_to_value(key[idx]);
1528 printf("invalid key: character %c at position %d is not a "
1529 "valid hexa digit\n", key[idx], idx);
1534 cmd_config_rss_hash_key_parsed(void *parsed_result,
1535 __attribute__((unused)) struct cmdline *cl,
1536 __attribute__((unused)) void *data)
1538 struct cmd_config_rss_hash_key *res = parsed_result;
1539 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1544 /* Check the length of the RSS hash key */
1545 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1546 printf("key length: %d invalid - key must be a string of %d"
1547 "hexa-decimal numbers\n", (int) strlen(res->key),
1548 RSS_HASH_KEY_LENGTH * 2);
1551 /* Translate RSS hash key into binary representation */
1552 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1553 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1556 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1559 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1561 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1562 RSS_HASH_KEY_LENGTH);
1565 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1567 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1570 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1571 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1572 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1573 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1574 rss_hash_key, "rss-hash-key");
1575 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1576 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1577 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1578 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1579 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1580 "ipv6-tcp-ex#ipv6-udp-ex");
1581 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1582 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1584 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1585 .f = cmd_config_rss_hash_key_parsed,
1588 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1589 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1590 "ipv6-sctp|ipv6-other|l2-payload|"
1591 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1593 (void *)&cmd_config_rss_hash_key_port,
1594 (void *)&cmd_config_rss_hash_key_config,
1595 (void *)&cmd_config_rss_hash_key_port_id,
1596 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1597 (void *)&cmd_config_rss_hash_key_rss_type,
1598 (void *)&cmd_config_rss_hash_key_value,
1603 /* *** configure port rxq/txq start/stop *** */
1604 struct cmd_config_rxtx_queue {
1605 cmdline_fixed_string_t port;
1607 cmdline_fixed_string_t rxtxq;
1609 cmdline_fixed_string_t opname;
1613 cmd_config_rxtx_queue_parsed(void *parsed_result,
1614 __attribute__((unused)) struct cmdline *cl,
1615 __attribute__((unused)) void *data)
1617 struct cmd_config_rxtx_queue *res = parsed_result;
1622 if (test_done == 0) {
1623 printf("Please stop forwarding first\n");
1627 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1630 if (port_is_started(res->portid) != 1) {
1631 printf("Please start port %u first\n", res->portid);
1635 if (!strcmp(res->rxtxq, "rxq"))
1637 else if (!strcmp(res->rxtxq, "txq"))
1640 printf("Unknown parameter\n");
1644 if (isrx && rx_queue_id_is_invalid(res->qid))
1646 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1649 if (!strcmp(res->opname, "start"))
1651 else if (!strcmp(res->opname, "stop"))
1654 printf("Unknown parameter\n");
1658 if (isstart && isrx)
1659 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1660 else if (!isstart && isrx)
1661 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1662 else if (isstart && !isrx)
1663 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1665 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1667 if (ret == -ENOTSUP)
1668 printf("Function not supported in PMD driver\n");
1671 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1673 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1674 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1675 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1677 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1678 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1679 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1680 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1683 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1684 .f = cmd_config_rxtx_queue_parsed,
1686 .help_str = "port X rxq|txq ID start|stop",
1688 (void *)&cmd_config_speed_all_port,
1689 (void *)&cmd_config_rxtx_queue_portid,
1690 (void *)&cmd_config_rxtx_queue_rxtxq,
1691 (void *)&cmd_config_rxtx_queue_qid,
1692 (void *)&cmd_config_rxtx_queue_opname,
1697 /* *** Configure RSS RETA *** */
1698 struct cmd_config_rss_reta {
1699 cmdline_fixed_string_t port;
1700 cmdline_fixed_string_t keyword;
1702 cmdline_fixed_string_t name;
1703 cmdline_fixed_string_t list_name;
1704 cmdline_fixed_string_t list_of_items;
1708 parse_reta_config(const char *str,
1709 struct rte_eth_rss_reta_entry64 *reta_conf,
1710 uint16_t nb_entries)
1714 uint16_t hash_index, idx, shift;
1717 const char *p, *p0 = str;
1724 unsigned long int_fld[_NUM_FLD];
1725 char *str_fld[_NUM_FLD];
1727 while ((p = strchr(p0,'(')) != NULL) {
1729 if((p0 = strchr(p,')')) == NULL)
1733 if(size >= sizeof(s))
1736 snprintf(s, sizeof(s), "%.*s", size, p);
1737 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1739 for (i = 0; i < _NUM_FLD; i++) {
1741 int_fld[i] = strtoul(str_fld[i], &end, 0);
1742 if (errno != 0 || end == str_fld[i] ||
1747 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1748 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1750 if (hash_index >= nb_entries) {
1751 printf("Invalid RETA hash index=%d\n", hash_index);
1755 idx = hash_index / RTE_RETA_GROUP_SIZE;
1756 shift = hash_index % RTE_RETA_GROUP_SIZE;
1757 reta_conf[idx].mask |= (1ULL << shift);
1758 reta_conf[idx].reta[shift] = nb_queue;
1765 cmd_set_rss_reta_parsed(void *parsed_result,
1766 __attribute__((unused)) struct cmdline *cl,
1767 __attribute__((unused)) void *data)
1770 struct rte_eth_dev_info dev_info;
1771 struct rte_eth_rss_reta_entry64 reta_conf[8];
1772 struct cmd_config_rss_reta *res = parsed_result;
1774 memset(&dev_info, 0, sizeof(dev_info));
1775 rte_eth_dev_info_get(res->port_id, &dev_info);
1776 if (dev_info.reta_size == 0) {
1777 printf("Redirection table size is 0 which is "
1778 "invalid for RSS\n");
1781 printf("The reta size of port %d is %u\n",
1782 res->port_id, dev_info.reta_size);
1783 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1784 printf("Currently do not support more than %u entries of "
1785 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1789 memset(reta_conf, 0, sizeof(reta_conf));
1790 if (!strcmp(res->list_name, "reta")) {
1791 if (parse_reta_config(res->list_of_items, reta_conf,
1792 dev_info.reta_size)) {
1793 printf("Invalid RSS Redirection Table "
1794 "config entered\n");
1797 ret = rte_eth_dev_rss_reta_update(res->port_id,
1798 reta_conf, dev_info.reta_size);
1800 printf("Bad redirection table parameter, "
1801 "return code = %d \n", ret);
1805 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1806 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1807 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1808 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1809 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1810 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1811 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1812 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1813 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1814 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1815 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1816 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1818 cmdline_parse_inst_t cmd_config_rss_reta = {
1819 .f = cmd_set_rss_reta_parsed,
1821 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1823 (void *)&cmd_config_rss_reta_port,
1824 (void *)&cmd_config_rss_reta_keyword,
1825 (void *)&cmd_config_rss_reta_port_id,
1826 (void *)&cmd_config_rss_reta_name,
1827 (void *)&cmd_config_rss_reta_list_name,
1828 (void *)&cmd_config_rss_reta_list_of_items,
1833 /* *** SHOW PORT RETA INFO *** */
1834 struct cmd_showport_reta {
1835 cmdline_fixed_string_t show;
1836 cmdline_fixed_string_t port;
1838 cmdline_fixed_string_t rss;
1839 cmdline_fixed_string_t reta;
1841 cmdline_fixed_string_t list_of_items;
1845 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1846 uint16_t nb_entries,
1850 const char *p, *p0 = str;
1854 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1857 p = strchr(p0, '(');
1861 p0 = strchr(p, ')');
1865 if (size >= sizeof(s)) {
1866 printf("The string size exceeds the internal buffer size\n");
1869 snprintf(s, sizeof(s), "%.*s", size, p);
1870 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1871 if (ret <= 0 || ret != num) {
1872 printf("The bits of masks do not match the number of "
1873 "reta entries: %u\n", num);
1876 for (i = 0; i < ret; i++)
1877 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1883 cmd_showport_reta_parsed(void *parsed_result,
1884 __attribute__((unused)) struct cmdline *cl,
1885 __attribute__((unused)) void *data)
1887 struct cmd_showport_reta *res = parsed_result;
1888 struct rte_eth_rss_reta_entry64 reta_conf[8];
1889 struct rte_eth_dev_info dev_info;
1891 memset(&dev_info, 0, sizeof(dev_info));
1892 rte_eth_dev_info_get(res->port_id, &dev_info);
1893 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1894 res->size > ETH_RSS_RETA_SIZE_512) {
1895 printf("Invalid redirection table size: %u\n", res->size);
1899 memset(reta_conf, 0, sizeof(reta_conf));
1900 if (showport_parse_reta_config(reta_conf, res->size,
1901 res->list_of_items) < 0) {
1902 printf("Invalid string: %s for reta masks\n",
1903 res->list_of_items);
1906 port_rss_reta_info(res->port_id, reta_conf, res->size);
1909 cmdline_parse_token_string_t cmd_showport_reta_show =
1910 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1911 cmdline_parse_token_string_t cmd_showport_reta_port =
1912 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1913 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1914 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1915 cmdline_parse_token_string_t cmd_showport_reta_rss =
1916 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1917 cmdline_parse_token_string_t cmd_showport_reta_reta =
1918 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1919 cmdline_parse_token_num_t cmd_showport_reta_size =
1920 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1921 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1922 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1923 list_of_items, NULL);
1925 cmdline_parse_inst_t cmd_showport_reta = {
1926 .f = cmd_showport_reta_parsed,
1928 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1930 (void *)&cmd_showport_reta_show,
1931 (void *)&cmd_showport_reta_port,
1932 (void *)&cmd_showport_reta_port_id,
1933 (void *)&cmd_showport_reta_rss,
1934 (void *)&cmd_showport_reta_reta,
1935 (void *)&cmd_showport_reta_size,
1936 (void *)&cmd_showport_reta_list_of_items,
1941 /* *** Show RSS hash configuration *** */
1942 struct cmd_showport_rss_hash {
1943 cmdline_fixed_string_t show;
1944 cmdline_fixed_string_t port;
1946 cmdline_fixed_string_t rss_hash;
1947 cmdline_fixed_string_t rss_type;
1948 cmdline_fixed_string_t key; /* optional argument */
1951 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1952 __attribute__((unused)) struct cmdline *cl,
1955 struct cmd_showport_rss_hash *res = parsed_result;
1957 port_rss_hash_conf_show(res->port_id, res->rss_type,
1958 show_rss_key != NULL);
1961 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1962 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1963 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1964 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1965 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1966 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1967 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1968 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1970 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
1971 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
1972 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1973 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1974 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1975 "ipv6-tcp-ex#ipv6-udp-ex");
1976 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1977 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1979 cmdline_parse_inst_t cmd_showport_rss_hash = {
1980 .f = cmd_showport_rss_hash_parsed,
1983 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1984 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1985 "ipv6-sctp|ipv6-other|l2-payload|"
1986 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
1988 (void *)&cmd_showport_rss_hash_show,
1989 (void *)&cmd_showport_rss_hash_port,
1990 (void *)&cmd_showport_rss_hash_port_id,
1991 (void *)&cmd_showport_rss_hash_rss_hash,
1992 (void *)&cmd_showport_rss_hash_rss_hash_info,
1997 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1998 .f = cmd_showport_rss_hash_parsed,
2001 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2002 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2003 "ipv6-sctp|ipv6-other|l2-payload|"
2004 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2006 (void *)&cmd_showport_rss_hash_show,
2007 (void *)&cmd_showport_rss_hash_port,
2008 (void *)&cmd_showport_rss_hash_port_id,
2009 (void *)&cmd_showport_rss_hash_rss_hash,
2010 (void *)&cmd_showport_rss_hash_rss_hash_info,
2011 (void *)&cmd_showport_rss_hash_rss_key,
2016 /* *** Configure DCB *** */
2017 struct cmd_config_dcb {
2018 cmdline_fixed_string_t port;
2019 cmdline_fixed_string_t config;
2021 cmdline_fixed_string_t dcb;
2022 cmdline_fixed_string_t vt;
2023 cmdline_fixed_string_t vt_en;
2025 cmdline_fixed_string_t pfc;
2026 cmdline_fixed_string_t pfc_en;
2030 cmd_config_dcb_parsed(void *parsed_result,
2031 __attribute__((unused)) struct cmdline *cl,
2032 __attribute__((unused)) void *data)
2034 struct cmd_config_dcb *res = parsed_result;
2035 struct dcb_config dcb_conf;
2036 portid_t port_id = res->port_id;
2037 struct rte_port *port;
2039 port = &ports[port_id];
2040 /** Check if the port is not started **/
2041 if (port->port_status != RTE_PORT_STOPPED) {
2042 printf("Please stop port %d first\n",port_id);
2046 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
2047 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
2048 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
2052 /* DCB in VT mode */
2053 if (!strncmp(res->vt_en, "on",2))
2054 dcb_conf.dcb_mode = DCB_VT_ENABLED;
2056 dcb_conf.dcb_mode = DCB_ENABLED;
2058 if (!strncmp(res->pfc_en, "on",2)) {
2059 dcb_conf.pfc_en = 1;
2062 dcb_conf.pfc_en = 0;
2064 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
2065 printf("Cannot initialize network ports\n");
2069 cmd_reconfig_device_queue(port_id, 1, 1);
2072 cmdline_parse_token_string_t cmd_config_dcb_port =
2073 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2074 cmdline_parse_token_string_t cmd_config_dcb_config =
2075 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2076 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2077 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2078 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2079 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2080 cmdline_parse_token_string_t cmd_config_dcb_vt =
2081 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2082 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2083 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2084 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2085 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2086 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2087 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2088 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2089 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2091 cmdline_parse_inst_t cmd_config_dcb = {
2092 .f = cmd_config_dcb_parsed,
2094 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2096 (void *)&cmd_config_dcb_port,
2097 (void *)&cmd_config_dcb_config,
2098 (void *)&cmd_config_dcb_port_id,
2099 (void *)&cmd_config_dcb_dcb,
2100 (void *)&cmd_config_dcb_vt,
2101 (void *)&cmd_config_dcb_vt_en,
2102 (void *)&cmd_config_dcb_num_tcs,
2103 (void *)&cmd_config_dcb_pfc,
2104 (void *)&cmd_config_dcb_pfc_en,
2109 /* *** configure number of packets per burst *** */
2110 struct cmd_config_burst {
2111 cmdline_fixed_string_t port;
2112 cmdline_fixed_string_t keyword;
2113 cmdline_fixed_string_t all;
2114 cmdline_fixed_string_t name;
2119 cmd_config_burst_parsed(void *parsed_result,
2120 __attribute__((unused)) struct cmdline *cl,
2121 __attribute__((unused)) void *data)
2123 struct cmd_config_burst *res = parsed_result;
2125 if (!all_ports_stopped()) {
2126 printf("Please stop all ports first\n");
2130 if (!strcmp(res->name, "burst")) {
2131 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2132 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2135 nb_pkt_per_burst = res->value;
2137 printf("Unknown parameter\n");
2143 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2146 cmdline_parse_token_string_t cmd_config_burst_port =
2147 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2148 cmdline_parse_token_string_t cmd_config_burst_keyword =
2149 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2150 cmdline_parse_token_string_t cmd_config_burst_all =
2151 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2152 cmdline_parse_token_string_t cmd_config_burst_name =
2153 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2154 cmdline_parse_token_num_t cmd_config_burst_value =
2155 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2157 cmdline_parse_inst_t cmd_config_burst = {
2158 .f = cmd_config_burst_parsed,
2160 .help_str = "port config all burst value",
2162 (void *)&cmd_config_burst_port,
2163 (void *)&cmd_config_burst_keyword,
2164 (void *)&cmd_config_burst_all,
2165 (void *)&cmd_config_burst_name,
2166 (void *)&cmd_config_burst_value,
2171 /* *** configure rx/tx queues *** */
2172 struct cmd_config_thresh {
2173 cmdline_fixed_string_t port;
2174 cmdline_fixed_string_t keyword;
2175 cmdline_fixed_string_t all;
2176 cmdline_fixed_string_t name;
2181 cmd_config_thresh_parsed(void *parsed_result,
2182 __attribute__((unused)) struct cmdline *cl,
2183 __attribute__((unused)) void *data)
2185 struct cmd_config_thresh *res = parsed_result;
2187 if (!all_ports_stopped()) {
2188 printf("Please stop all ports first\n");
2192 if (!strcmp(res->name, "txpt"))
2193 tx_pthresh = res->value;
2194 else if(!strcmp(res->name, "txht"))
2195 tx_hthresh = res->value;
2196 else if(!strcmp(res->name, "txwt"))
2197 tx_wthresh = res->value;
2198 else if(!strcmp(res->name, "rxpt"))
2199 rx_pthresh = res->value;
2200 else if(!strcmp(res->name, "rxht"))
2201 rx_hthresh = res->value;
2202 else if(!strcmp(res->name, "rxwt"))
2203 rx_wthresh = res->value;
2205 printf("Unknown parameter\n");
2211 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2214 cmdline_parse_token_string_t cmd_config_thresh_port =
2215 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2216 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2217 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2218 cmdline_parse_token_string_t cmd_config_thresh_all =
2219 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2220 cmdline_parse_token_string_t cmd_config_thresh_name =
2221 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2222 "txpt#txht#txwt#rxpt#rxht#rxwt");
2223 cmdline_parse_token_num_t cmd_config_thresh_value =
2224 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2226 cmdline_parse_inst_t cmd_config_thresh = {
2227 .f = cmd_config_thresh_parsed,
2229 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2231 (void *)&cmd_config_thresh_port,
2232 (void *)&cmd_config_thresh_keyword,
2233 (void *)&cmd_config_thresh_all,
2234 (void *)&cmd_config_thresh_name,
2235 (void *)&cmd_config_thresh_value,
2240 /* *** configure free/rs threshold *** */
2241 struct cmd_config_threshold {
2242 cmdline_fixed_string_t port;
2243 cmdline_fixed_string_t keyword;
2244 cmdline_fixed_string_t all;
2245 cmdline_fixed_string_t name;
2250 cmd_config_threshold_parsed(void *parsed_result,
2251 __attribute__((unused)) struct cmdline *cl,
2252 __attribute__((unused)) void *data)
2254 struct cmd_config_threshold *res = parsed_result;
2256 if (!all_ports_stopped()) {
2257 printf("Please stop all ports first\n");
2261 if (!strcmp(res->name, "txfreet"))
2262 tx_free_thresh = res->value;
2263 else if (!strcmp(res->name, "txrst"))
2264 tx_rs_thresh = res->value;
2265 else if (!strcmp(res->name, "rxfreet"))
2266 rx_free_thresh = res->value;
2268 printf("Unknown parameter\n");
2274 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2277 cmdline_parse_token_string_t cmd_config_threshold_port =
2278 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2279 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2280 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2282 cmdline_parse_token_string_t cmd_config_threshold_all =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2284 cmdline_parse_token_string_t cmd_config_threshold_name =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2286 "txfreet#txrst#rxfreet");
2287 cmdline_parse_token_num_t cmd_config_threshold_value =
2288 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2290 cmdline_parse_inst_t cmd_config_threshold = {
2291 .f = cmd_config_threshold_parsed,
2293 .help_str = "port config all txfreet|txrst|rxfreet value",
2295 (void *)&cmd_config_threshold_port,
2296 (void *)&cmd_config_threshold_keyword,
2297 (void *)&cmd_config_threshold_all,
2298 (void *)&cmd_config_threshold_name,
2299 (void *)&cmd_config_threshold_value,
2305 struct cmd_stop_result {
2306 cmdline_fixed_string_t stop;
2309 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2310 __attribute__((unused)) struct cmdline *cl,
2311 __attribute__((unused)) void *data)
2313 stop_packet_forwarding();
2316 cmdline_parse_token_string_t cmd_stop_stop =
2317 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2319 cmdline_parse_inst_t cmd_stop = {
2320 .f = cmd_stop_parsed,
2322 .help_str = "stop - stop packet forwarding",
2324 (void *)&cmd_stop_stop,
2329 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2332 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2333 unsigned int *parsed_items, int check_unique_values)
2335 unsigned int nb_item;
2343 * First parse all items in the list and store their value.
2348 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2350 if ((c >= '0') && (c <= '9')) {
2351 value = (unsigned int) (value * 10 + (c - '0'));
2356 printf("character %c is not a decimal digit\n", c);
2360 printf("No valid value before comma\n");
2363 if (nb_item < max_items) {
2364 parsed_items[nb_item] = value;
2370 if (nb_item >= max_items) {
2371 printf("Number of %s = %u > %u (maximum items)\n",
2372 item_name, nb_item + 1, max_items);
2375 parsed_items[nb_item++] = value;
2376 if (! check_unique_values)
2380 * Then, check that all values in the list are differents.
2381 * No optimization here...
2383 for (i = 0; i < nb_item; i++) {
2384 for (j = i + 1; j < nb_item; j++) {
2385 if (parsed_items[j] == parsed_items[i]) {
2386 printf("duplicated %s %u at index %u and %u\n",
2387 item_name, parsed_items[i], i, j);
2395 struct cmd_set_list_result {
2396 cmdline_fixed_string_t cmd_keyword;
2397 cmdline_fixed_string_t list_name;
2398 cmdline_fixed_string_t list_of_items;
2401 static void cmd_set_list_parsed(void *parsed_result,
2402 __attribute__((unused)) struct cmdline *cl,
2403 __attribute__((unused)) void *data)
2405 struct cmd_set_list_result *res;
2407 unsigned int lcorelist[RTE_MAX_LCORE];
2408 unsigned int portlist[RTE_MAX_ETHPORTS];
2410 unsigned int nb_item;
2412 if (test_done == 0) {
2413 printf("Please stop forwarding first\n");
2417 res = parsed_result;
2418 if (!strcmp(res->list_name, "corelist")) {
2419 nb_item = parse_item_list(res->list_of_items, "core",
2421 parsed_items.lcorelist, 1);
2423 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2426 if (!strcmp(res->list_name, "portlist")) {
2427 nb_item = parse_item_list(res->list_of_items, "port",
2429 parsed_items.portlist, 1);
2431 set_fwd_ports_list(parsed_items.portlist, nb_item);
2435 cmdline_parse_token_string_t cmd_set_list_keyword =
2436 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2438 cmdline_parse_token_string_t cmd_set_list_name =
2439 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2440 "corelist#portlist");
2441 cmdline_parse_token_string_t cmd_set_list_of_items =
2442 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2445 cmdline_parse_inst_t cmd_set_fwd_list = {
2446 .f = cmd_set_list_parsed,
2448 .help_str = "set corelist|portlist x[,y]*",
2450 (void *)&cmd_set_list_keyword,
2451 (void *)&cmd_set_list_name,
2452 (void *)&cmd_set_list_of_items,
2457 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2459 struct cmd_setmask_result {
2460 cmdline_fixed_string_t set;
2461 cmdline_fixed_string_t mask;
2465 static void cmd_set_mask_parsed(void *parsed_result,
2466 __attribute__((unused)) struct cmdline *cl,
2467 __attribute__((unused)) void *data)
2469 struct cmd_setmask_result *res = parsed_result;
2471 if (test_done == 0) {
2472 printf("Please stop forwarding first\n");
2475 if (!strcmp(res->mask, "coremask"))
2476 set_fwd_lcores_mask(res->hexavalue);
2477 else if (!strcmp(res->mask, "portmask"))
2478 set_fwd_ports_mask(res->hexavalue);
2481 cmdline_parse_token_string_t cmd_setmask_set =
2482 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2483 cmdline_parse_token_string_t cmd_setmask_mask =
2484 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2485 "coremask#portmask");
2486 cmdline_parse_token_num_t cmd_setmask_value =
2487 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2489 cmdline_parse_inst_t cmd_set_fwd_mask = {
2490 .f = cmd_set_mask_parsed,
2492 .help_str = "set coremask|portmask hexadecimal value",
2494 (void *)&cmd_setmask_set,
2495 (void *)&cmd_setmask_mask,
2496 (void *)&cmd_setmask_value,
2502 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2504 struct cmd_set_result {
2505 cmdline_fixed_string_t set;
2506 cmdline_fixed_string_t what;
2510 static void cmd_set_parsed(void *parsed_result,
2511 __attribute__((unused)) struct cmdline *cl,
2512 __attribute__((unused)) void *data)
2514 struct cmd_set_result *res = parsed_result;
2515 if (!strcmp(res->what, "nbport"))
2516 set_fwd_ports_number(res->value);
2517 else if (!strcmp(res->what, "nbcore"))
2518 set_fwd_lcores_number(res->value);
2519 else if (!strcmp(res->what, "burst"))
2520 set_nb_pkt_per_burst(res->value);
2521 else if (!strcmp(res->what, "verbose"))
2522 set_verbose_level(res->value);
2525 cmdline_parse_token_string_t cmd_set_set =
2526 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2527 cmdline_parse_token_string_t cmd_set_what =
2528 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2529 "nbport#nbcore#burst#verbose");
2530 cmdline_parse_token_num_t cmd_set_value =
2531 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2533 cmdline_parse_inst_t cmd_set_numbers = {
2534 .f = cmd_set_parsed,
2536 .help_str = "set nbport|nbcore|burst|verbose value",
2538 (void *)&cmd_set_set,
2539 (void *)&cmd_set_what,
2540 (void *)&cmd_set_value,
2545 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2547 struct cmd_set_txpkts_result {
2548 cmdline_fixed_string_t cmd_keyword;
2549 cmdline_fixed_string_t txpkts;
2550 cmdline_fixed_string_t seg_lengths;
2554 cmd_set_txpkts_parsed(void *parsed_result,
2555 __attribute__((unused)) struct cmdline *cl,
2556 __attribute__((unused)) void *data)
2558 struct cmd_set_txpkts_result *res;
2559 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2560 unsigned int nb_segs;
2562 res = parsed_result;
2563 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2564 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2566 set_tx_pkt_segments(seg_lengths, nb_segs);
2569 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2570 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2571 cmd_keyword, "set");
2572 cmdline_parse_token_string_t cmd_set_txpkts_name =
2573 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2575 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2576 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2579 cmdline_parse_inst_t cmd_set_txpkts = {
2580 .f = cmd_set_txpkts_parsed,
2582 .help_str = "set txpkts x[,y]*",
2584 (void *)&cmd_set_txpkts_keyword,
2585 (void *)&cmd_set_txpkts_name,
2586 (void *)&cmd_set_txpkts_lengths,
2591 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2592 struct cmd_rx_vlan_filter_all_result {
2593 cmdline_fixed_string_t rx_vlan;
2594 cmdline_fixed_string_t what;
2595 cmdline_fixed_string_t all;
2600 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2601 __attribute__((unused)) struct cmdline *cl,
2602 __attribute__((unused)) void *data)
2604 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2606 if (!strcmp(res->what, "add"))
2607 rx_vlan_all_filter_set(res->port_id, 1);
2609 rx_vlan_all_filter_set(res->port_id, 0);
2612 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2613 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2614 rx_vlan, "rx_vlan");
2615 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2616 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2618 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2619 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2621 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2622 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2625 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2626 .f = cmd_rx_vlan_filter_all_parsed,
2628 .help_str = "add/remove all identifiers to/from the set of VLAN "
2629 "Identifiers filtered by a port",
2631 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2632 (void *)&cmd_rx_vlan_filter_all_what,
2633 (void *)&cmd_rx_vlan_filter_all_all,
2634 (void *)&cmd_rx_vlan_filter_all_portid,
2639 /* *** VLAN OFFLOAD SET ON A PORT *** */
2640 struct cmd_vlan_offload_result {
2641 cmdline_fixed_string_t vlan;
2642 cmdline_fixed_string_t set;
2643 cmdline_fixed_string_t what;
2644 cmdline_fixed_string_t on;
2645 cmdline_fixed_string_t port_id;
2649 cmd_vlan_offload_parsed(void *parsed_result,
2650 __attribute__((unused)) struct cmdline *cl,
2651 __attribute__((unused)) void *data)
2654 struct cmd_vlan_offload_result *res = parsed_result;
2657 portid_t port_id = 0;
2661 len = strnlen(str, STR_TOKEN_SIZE);
2663 /* Get port_id first */
2671 tmp = strtoul(str, NULL, 0);
2672 /* If port_id greater that what portid_t can represent, return */
2673 if(tmp >= RTE_MAX_ETHPORTS)
2675 port_id = (portid_t)tmp;
2677 if (!strcmp(res->on, "on"))
2682 if (!strcmp(res->what, "strip"))
2683 rx_vlan_strip_set(port_id, on);
2684 else if(!strcmp(res->what, "stripq")){
2685 uint16_t queue_id = 0;
2687 /* No queue_id, return */
2689 printf("must specify (port,queue_id)\n");
2692 tmp = strtoul(str + i + 1, NULL, 0);
2693 /* If queue_id greater that what 16-bits can represent, return */
2697 queue_id = (uint16_t)tmp;
2698 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2700 else if (!strcmp(res->what, "filter"))
2701 rx_vlan_filter_set(port_id, on);
2703 vlan_extend_set(port_id, on);
2708 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2709 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2711 cmdline_parse_token_string_t cmd_vlan_offload_set =
2712 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2714 cmdline_parse_token_string_t cmd_vlan_offload_what =
2715 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2716 what, "strip#filter#qinq#stripq");
2717 cmdline_parse_token_string_t cmd_vlan_offload_on =
2718 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2720 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2721 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2724 cmdline_parse_inst_t cmd_vlan_offload = {
2725 .f = cmd_vlan_offload_parsed,
2727 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2728 " qinq(extended) for both rx/tx sides ",
2730 (void *)&cmd_vlan_offload_vlan,
2731 (void *)&cmd_vlan_offload_set,
2732 (void *)&cmd_vlan_offload_what,
2733 (void *)&cmd_vlan_offload_on,
2734 (void *)&cmd_vlan_offload_portid,
2739 /* *** VLAN TPID SET ON A PORT *** */
2740 struct cmd_vlan_tpid_result {
2741 cmdline_fixed_string_t vlan;
2742 cmdline_fixed_string_t set;
2743 cmdline_fixed_string_t what;
2749 cmd_vlan_tpid_parsed(void *parsed_result,
2750 __attribute__((unused)) struct cmdline *cl,
2751 __attribute__((unused)) void *data)
2753 struct cmd_vlan_tpid_result *res = parsed_result;
2754 vlan_tpid_set(res->port_id, res->tp_id);
2758 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2759 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2761 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2762 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2764 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2765 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2767 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2768 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2770 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2771 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2774 cmdline_parse_inst_t cmd_vlan_tpid = {
2775 .f = cmd_vlan_tpid_parsed,
2777 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2779 (void *)&cmd_vlan_tpid_vlan,
2780 (void *)&cmd_vlan_tpid_set,
2781 (void *)&cmd_vlan_tpid_what,
2782 (void *)&cmd_vlan_tpid_tpid,
2783 (void *)&cmd_vlan_tpid_portid,
2788 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2789 struct cmd_rx_vlan_filter_result {
2790 cmdline_fixed_string_t rx_vlan;
2791 cmdline_fixed_string_t what;
2797 cmd_rx_vlan_filter_parsed(void *parsed_result,
2798 __attribute__((unused)) struct cmdline *cl,
2799 __attribute__((unused)) void *data)
2801 struct cmd_rx_vlan_filter_result *res = parsed_result;
2803 if (!strcmp(res->what, "add"))
2804 rx_vft_set(res->port_id, res->vlan_id, 1);
2806 rx_vft_set(res->port_id, res->vlan_id, 0);
2809 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2810 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2811 rx_vlan, "rx_vlan");
2812 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2813 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2815 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2816 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2818 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2819 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2822 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2823 .f = cmd_rx_vlan_filter_parsed,
2825 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2826 "Identifiers filtered by a port",
2828 (void *)&cmd_rx_vlan_filter_rx_vlan,
2829 (void *)&cmd_rx_vlan_filter_what,
2830 (void *)&cmd_rx_vlan_filter_vlanid,
2831 (void *)&cmd_rx_vlan_filter_portid,
2836 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2837 struct cmd_tx_vlan_set_result {
2838 cmdline_fixed_string_t tx_vlan;
2839 cmdline_fixed_string_t set;
2845 cmd_tx_vlan_set_parsed(void *parsed_result,
2846 __attribute__((unused)) struct cmdline *cl,
2847 __attribute__((unused)) void *data)
2849 struct cmd_tx_vlan_set_result *res = parsed_result;
2850 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2852 if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD) {
2853 printf("Error, as QinQ has been enabled.\n");
2857 tx_vlan_set(res->port_id, res->vlan_id);
2860 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2861 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2862 tx_vlan, "tx_vlan");
2863 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2864 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2866 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2867 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2869 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2870 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2873 cmdline_parse_inst_t cmd_tx_vlan_set = {
2874 .f = cmd_tx_vlan_set_parsed,
2876 .help_str = "enable hardware insertion of a single VLAN header "
2877 "with a given TAG Identifier in packets sent on a port",
2879 (void *)&cmd_tx_vlan_set_tx_vlan,
2880 (void *)&cmd_tx_vlan_set_set,
2881 (void *)&cmd_tx_vlan_set_portid,
2882 (void *)&cmd_tx_vlan_set_vlanid,
2887 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
2888 struct cmd_tx_vlan_set_qinq_result {
2889 cmdline_fixed_string_t tx_vlan;
2890 cmdline_fixed_string_t set;
2893 uint16_t vlan_id_outer;
2897 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
2898 __attribute__((unused)) struct cmdline *cl,
2899 __attribute__((unused)) void *data)
2901 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
2902 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2904 if (!(vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)) {
2905 printf("Error, as QinQ hasn't been enabled.\n");
2909 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
2912 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
2913 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2914 tx_vlan, "tx_vlan");
2915 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
2916 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2918 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
2919 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2921 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
2922 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2924 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
2925 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2926 vlan_id_outer, UINT16);
2928 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
2929 .f = cmd_tx_vlan_set_qinq_parsed,
2931 .help_str = "enable hardware insertion of double VLAN header "
2932 "with given TAG Identifiers in packets sent on a port",
2934 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
2935 (void *)&cmd_tx_vlan_set_qinq_set,
2936 (void *)&cmd_tx_vlan_set_qinq_portid,
2937 (void *)&cmd_tx_vlan_set_qinq_vlanid,
2938 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
2943 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2944 struct cmd_tx_vlan_set_pvid_result {
2945 cmdline_fixed_string_t tx_vlan;
2946 cmdline_fixed_string_t set;
2947 cmdline_fixed_string_t pvid;
2950 cmdline_fixed_string_t mode;
2954 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2955 __attribute__((unused)) struct cmdline *cl,
2956 __attribute__((unused)) void *data)
2958 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2960 if (strcmp(res->mode, "on") == 0)
2961 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2963 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2966 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2967 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2968 tx_vlan, "tx_vlan");
2969 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2970 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2972 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2973 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2975 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2976 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2978 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2979 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2981 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2982 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2985 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2986 .f = cmd_tx_vlan_set_pvid_parsed,
2988 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2990 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2991 (void *)&cmd_tx_vlan_set_pvid_set,
2992 (void *)&cmd_tx_vlan_set_pvid_pvid,
2993 (void *)&cmd_tx_vlan_set_pvid_port_id,
2994 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2995 (void *)&cmd_tx_vlan_set_pvid_mode,
3000 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3001 struct cmd_tx_vlan_reset_result {
3002 cmdline_fixed_string_t tx_vlan;
3003 cmdline_fixed_string_t reset;
3008 cmd_tx_vlan_reset_parsed(void *parsed_result,
3009 __attribute__((unused)) struct cmdline *cl,
3010 __attribute__((unused)) void *data)
3012 struct cmd_tx_vlan_reset_result *res = parsed_result;
3014 tx_vlan_reset(res->port_id);
3017 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3018 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3019 tx_vlan, "tx_vlan");
3020 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3021 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3023 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3024 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3027 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3028 .f = cmd_tx_vlan_reset_parsed,
3030 .help_str = "disable hardware insertion of a VLAN header in packets "
3033 (void *)&cmd_tx_vlan_reset_tx_vlan,
3034 (void *)&cmd_tx_vlan_reset_reset,
3035 (void *)&cmd_tx_vlan_reset_portid,
3041 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3042 struct cmd_csum_result {
3043 cmdline_fixed_string_t csum;
3044 cmdline_fixed_string_t mode;
3045 cmdline_fixed_string_t proto;
3046 cmdline_fixed_string_t hwsw;
3051 csum_show(int port_id)
3053 struct rte_eth_dev_info dev_info;
3056 ol_flags = ports[port_id].tx_ol_flags;
3057 printf("Parse tunnel is %s\n",
3058 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3059 printf("IP checksum offload is %s\n",
3060 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3061 printf("UDP checksum offload is %s\n",
3062 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3063 printf("TCP checksum offload is %s\n",
3064 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3065 printf("SCTP checksum offload is %s\n",
3066 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3067 printf("Outer-Ip checksum offload is %s\n",
3068 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3070 /* display warnings if configuration is not supported by the NIC */
3071 rte_eth_dev_info_get(port_id, &dev_info);
3072 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3073 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3074 printf("Warning: hardware IP checksum enabled but not "
3075 "supported by port %d\n", port_id);
3077 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3078 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3079 printf("Warning: hardware UDP checksum enabled but not "
3080 "supported by port %d\n", port_id);
3082 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3083 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3084 printf("Warning: hardware TCP checksum enabled but not "
3085 "supported by port %d\n", port_id);
3087 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3088 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3089 printf("Warning: hardware SCTP checksum enabled but not "
3090 "supported by port %d\n", port_id);
3092 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3093 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3094 printf("Warning: hardware outer IP checksum enabled but not "
3095 "supported by port %d\n", port_id);
3100 cmd_csum_parsed(void *parsed_result,
3101 __attribute__((unused)) struct cmdline *cl,
3102 __attribute__((unused)) void *data)
3104 struct cmd_csum_result *res = parsed_result;
3108 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3109 printf("invalid port %d\n", res->port_id);
3113 if (!strcmp(res->mode, "set")) {
3115 if (!strcmp(res->hwsw, "hw"))
3118 if (!strcmp(res->proto, "ip")) {
3119 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3120 } else if (!strcmp(res->proto, "udp")) {
3121 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3122 } else if (!strcmp(res->proto, "tcp")) {
3123 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3124 } else if (!strcmp(res->proto, "sctp")) {
3125 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3126 } else if (!strcmp(res->proto, "outer-ip")) {
3127 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3131 ports[res->port_id].tx_ol_flags |= mask;
3133 ports[res->port_id].tx_ol_flags &= (~mask);
3135 csum_show(res->port_id);
3138 cmdline_parse_token_string_t cmd_csum_csum =
3139 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3141 cmdline_parse_token_string_t cmd_csum_mode =
3142 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3144 cmdline_parse_token_string_t cmd_csum_proto =
3145 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3146 proto, "ip#tcp#udp#sctp#outer-ip");
3147 cmdline_parse_token_string_t cmd_csum_hwsw =
3148 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3150 cmdline_parse_token_num_t cmd_csum_portid =
3151 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3154 cmdline_parse_inst_t cmd_csum_set = {
3155 .f = cmd_csum_parsed,
3157 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3158 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3160 (void *)&cmd_csum_csum,
3161 (void *)&cmd_csum_mode,
3162 (void *)&cmd_csum_proto,
3163 (void *)&cmd_csum_hwsw,
3164 (void *)&cmd_csum_portid,
3169 cmdline_parse_token_string_t cmd_csum_mode_show =
3170 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3173 cmdline_parse_inst_t cmd_csum_show = {
3174 .f = cmd_csum_parsed,
3176 .help_str = "show checksum offload configuration: csum show <port>",
3178 (void *)&cmd_csum_csum,
3179 (void *)&cmd_csum_mode_show,
3180 (void *)&cmd_csum_portid,
3185 /* Enable/disable tunnel parsing */
3186 struct cmd_csum_tunnel_result {
3187 cmdline_fixed_string_t csum;
3188 cmdline_fixed_string_t parse;
3189 cmdline_fixed_string_t onoff;
3194 cmd_csum_tunnel_parsed(void *parsed_result,
3195 __attribute__((unused)) struct cmdline *cl,
3196 __attribute__((unused)) void *data)
3198 struct cmd_csum_tunnel_result *res = parsed_result;
3200 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3203 if (!strcmp(res->onoff, "on"))
3204 ports[res->port_id].tx_ol_flags |=
3205 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3207 ports[res->port_id].tx_ol_flags &=
3208 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3210 csum_show(res->port_id);
3213 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3214 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3216 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3217 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3218 parse, "parse_tunnel");
3219 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3220 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3222 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3223 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3226 cmdline_parse_inst_t cmd_csum_tunnel = {
3227 .f = cmd_csum_tunnel_parsed,
3229 .help_str = "enable/disable parsing of tunnels for csum engine: "
3230 "csum parse_tunnel on|off <tx-port>",
3232 (void *)&cmd_csum_tunnel_csum,
3233 (void *)&cmd_csum_tunnel_parse,
3234 (void *)&cmd_csum_tunnel_onoff,
3235 (void *)&cmd_csum_tunnel_portid,
3240 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3241 struct cmd_tso_set_result {
3242 cmdline_fixed_string_t tso;
3243 cmdline_fixed_string_t mode;
3249 cmd_tso_set_parsed(void *parsed_result,
3250 __attribute__((unused)) struct cmdline *cl,
3251 __attribute__((unused)) void *data)
3253 struct cmd_tso_set_result *res = parsed_result;
3254 struct rte_eth_dev_info dev_info;
3256 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3259 if (!strcmp(res->mode, "set"))
3260 ports[res->port_id].tso_segsz = res->tso_segsz;
3262 if (ports[res->port_id].tso_segsz == 0)
3263 printf("TSO is disabled\n");
3265 printf("TSO segment size is %d\n",
3266 ports[res->port_id].tso_segsz);
3268 /* display warnings if configuration is not supported by the NIC */
3269 rte_eth_dev_info_get(res->port_id, &dev_info);
3270 if ((ports[res->port_id].tso_segsz != 0) &&
3271 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3272 printf("Warning: TSO enabled but not "
3273 "supported by port %d\n", res->port_id);
3277 cmdline_parse_token_string_t cmd_tso_set_tso =
3278 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3280 cmdline_parse_token_string_t cmd_tso_set_mode =
3281 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3283 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3284 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3286 cmdline_parse_token_num_t cmd_tso_set_portid =
3287 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3290 cmdline_parse_inst_t cmd_tso_set = {
3291 .f = cmd_tso_set_parsed,
3293 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3294 "tso set <tso_segsz> <port>",
3296 (void *)&cmd_tso_set_tso,
3297 (void *)&cmd_tso_set_mode,
3298 (void *)&cmd_tso_set_tso_segsz,
3299 (void *)&cmd_tso_set_portid,
3304 cmdline_parse_token_string_t cmd_tso_show_mode =
3305 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3309 cmdline_parse_inst_t cmd_tso_show = {
3310 .f = cmd_tso_set_parsed,
3312 .help_str = "Show TSO segment size for csum engine: "
3315 (void *)&cmd_tso_set_tso,
3316 (void *)&cmd_tso_show_mode,
3317 (void *)&cmd_tso_set_portid,
3322 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3323 struct cmd_set_flush_rx {
3324 cmdline_fixed_string_t set;
3325 cmdline_fixed_string_t flush_rx;
3326 cmdline_fixed_string_t mode;
3330 cmd_set_flush_rx_parsed(void *parsed_result,
3331 __attribute__((unused)) struct cmdline *cl,
3332 __attribute__((unused)) void *data)
3334 struct cmd_set_flush_rx *res = parsed_result;
3335 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3338 cmdline_parse_token_string_t cmd_setflushrx_set =
3339 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3341 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3342 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3343 flush_rx, "flush_rx");
3344 cmdline_parse_token_string_t cmd_setflushrx_mode =
3345 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3349 cmdline_parse_inst_t cmd_set_flush_rx = {
3350 .f = cmd_set_flush_rx_parsed,
3351 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3354 (void *)&cmd_setflushrx_set,
3355 (void *)&cmd_setflushrx_flush_rx,
3356 (void *)&cmd_setflushrx_mode,
3361 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3362 struct cmd_set_link_check {
3363 cmdline_fixed_string_t set;
3364 cmdline_fixed_string_t link_check;
3365 cmdline_fixed_string_t mode;
3369 cmd_set_link_check_parsed(void *parsed_result,
3370 __attribute__((unused)) struct cmdline *cl,
3371 __attribute__((unused)) void *data)
3373 struct cmd_set_link_check *res = parsed_result;
3374 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3377 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3378 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3380 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3381 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3382 link_check, "link_check");
3383 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3384 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3388 cmdline_parse_inst_t cmd_set_link_check = {
3389 .f = cmd_set_link_check_parsed,
3390 .help_str = "set link_check on|off: enable/disable link status check "
3391 "when starting/stopping a port",
3394 (void *)&cmd_setlinkcheck_set,
3395 (void *)&cmd_setlinkcheck_link_check,
3396 (void *)&cmd_setlinkcheck_mode,
3401 #ifdef RTE_NIC_BYPASS
3402 /* *** SET NIC BYPASS MODE *** */
3403 struct cmd_set_bypass_mode_result {
3404 cmdline_fixed_string_t set;
3405 cmdline_fixed_string_t bypass;
3406 cmdline_fixed_string_t mode;
3407 cmdline_fixed_string_t value;
3412 cmd_set_bypass_mode_parsed(void *parsed_result,
3413 __attribute__((unused)) struct cmdline *cl,
3414 __attribute__((unused)) void *data)
3416 struct cmd_set_bypass_mode_result *res = parsed_result;
3417 portid_t port_id = res->port_id;
3418 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3420 if (!bypass_is_supported(port_id))
3423 if (!strcmp(res->value, "bypass"))
3424 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3425 else if (!strcmp(res->value, "isolate"))
3426 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3428 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3430 /* Set the bypass mode for the relevant port. */
3431 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3432 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3436 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3437 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3439 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3440 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3442 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3443 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3445 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3446 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3447 value, "normal#bypass#isolate");
3448 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3449 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3452 cmdline_parse_inst_t cmd_set_bypass_mode = {
3453 .f = cmd_set_bypass_mode_parsed,
3454 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3455 "Set the NIC bypass mode for port_id",
3458 (void *)&cmd_setbypass_mode_set,
3459 (void *)&cmd_setbypass_mode_bypass,
3460 (void *)&cmd_setbypass_mode_mode,
3461 (void *)&cmd_setbypass_mode_value,
3462 (void *)&cmd_setbypass_mode_port,
3467 /* *** SET NIC BYPASS EVENT *** */
3468 struct cmd_set_bypass_event_result {
3469 cmdline_fixed_string_t set;
3470 cmdline_fixed_string_t bypass;
3471 cmdline_fixed_string_t event;
3472 cmdline_fixed_string_t event_value;
3473 cmdline_fixed_string_t mode;
3474 cmdline_fixed_string_t mode_value;
3479 cmd_set_bypass_event_parsed(void *parsed_result,
3480 __attribute__((unused)) struct cmdline *cl,
3481 __attribute__((unused)) void *data)
3484 struct cmd_set_bypass_event_result *res = parsed_result;
3485 portid_t port_id = res->port_id;
3486 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3487 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3489 if (!bypass_is_supported(port_id))
3492 if (!strcmp(res->event_value, "timeout"))
3493 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3494 else if (!strcmp(res->event_value, "os_on"))
3495 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3496 else if (!strcmp(res->event_value, "os_off"))
3497 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3498 else if (!strcmp(res->event_value, "power_on"))
3499 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3500 else if (!strcmp(res->event_value, "power_off"))
3501 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3503 bypass_event = RTE_BYPASS_EVENT_NONE;
3505 if (!strcmp(res->mode_value, "bypass"))
3506 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3507 else if (!strcmp(res->mode_value, "isolate"))
3508 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3510 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3512 /* Set the watchdog timeout. */
3513 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3516 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3517 (rc = rte_eth_dev_wd_timeout_store(port_id,
3518 bypass_timeout)) != 0) {
3519 printf("Failed to set timeout value %u "
3520 "for port %d, errto code: %d.\n",
3521 bypass_timeout, port_id, rc);
3525 /* Set the bypass event to transition to bypass mode. */
3526 if (0 != rte_eth_dev_bypass_event_store(port_id,
3527 bypass_event, bypass_mode)) {
3528 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3533 cmdline_parse_token_string_t cmd_setbypass_event_set =
3534 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3536 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3537 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3539 cmdline_parse_token_string_t cmd_setbypass_event_event =
3540 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3542 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3543 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3544 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3545 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3546 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3548 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3549 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3550 mode_value, "normal#bypass#isolate");
3551 cmdline_parse_token_num_t cmd_setbypass_event_port =
3552 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3555 cmdline_parse_inst_t cmd_set_bypass_event = {
3556 .f = cmd_set_bypass_event_parsed,
3557 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3558 "mode (normal|bypass|isolate) (port_id): "
3559 "Set the NIC bypass event mode for port_id",
3562 (void *)&cmd_setbypass_event_set,
3563 (void *)&cmd_setbypass_event_bypass,
3564 (void *)&cmd_setbypass_event_event,
3565 (void *)&cmd_setbypass_event_event_value,
3566 (void *)&cmd_setbypass_event_mode,
3567 (void *)&cmd_setbypass_event_mode_value,
3568 (void *)&cmd_setbypass_event_port,
3574 /* *** SET NIC BYPASS TIMEOUT *** */
3575 struct cmd_set_bypass_timeout_result {
3576 cmdline_fixed_string_t set;
3577 cmdline_fixed_string_t bypass;
3578 cmdline_fixed_string_t timeout;
3579 cmdline_fixed_string_t value;
3583 cmd_set_bypass_timeout_parsed(void *parsed_result,
3584 __attribute__((unused)) struct cmdline *cl,
3585 __attribute__((unused)) void *data)
3587 struct cmd_set_bypass_timeout_result *res = parsed_result;
3589 if (!strcmp(res->value, "1.5"))
3590 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3591 else if (!strcmp(res->value, "2"))
3592 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3593 else if (!strcmp(res->value, "3"))
3594 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3595 else if (!strcmp(res->value, "4"))
3596 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3597 else if (!strcmp(res->value, "8"))
3598 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3599 else if (!strcmp(res->value, "16"))
3600 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3601 else if (!strcmp(res->value, "32"))
3602 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3604 bypass_timeout = RTE_BYPASS_TMT_OFF;
3607 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3608 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3610 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3611 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3613 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3614 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3615 timeout, "timeout");
3616 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3617 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3618 value, "0#1.5#2#3#4#8#16#32");
3620 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3621 .f = cmd_set_bypass_timeout_parsed,
3622 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3623 "Set the NIC bypass watchdog timeout",
3626 (void *)&cmd_setbypass_timeout_set,
3627 (void *)&cmd_setbypass_timeout_bypass,
3628 (void *)&cmd_setbypass_timeout_timeout,
3629 (void *)&cmd_setbypass_timeout_value,
3634 /* *** SHOW NIC BYPASS MODE *** */
3635 struct cmd_show_bypass_config_result {
3636 cmdline_fixed_string_t show;
3637 cmdline_fixed_string_t bypass;
3638 cmdline_fixed_string_t config;
3643 cmd_show_bypass_config_parsed(void *parsed_result,
3644 __attribute__((unused)) struct cmdline *cl,
3645 __attribute__((unused)) void *data)
3647 struct cmd_show_bypass_config_result *res = parsed_result;
3648 uint32_t event_mode;
3649 uint32_t bypass_mode;
3650 portid_t port_id = res->port_id;
3651 uint32_t timeout = bypass_timeout;
3654 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3655 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3656 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3657 {"UNKNOWN", "normal", "bypass", "isolate"};
3658 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3665 int num_events = (sizeof events) / (sizeof events[0]);
3667 if (!bypass_is_supported(port_id))
3670 /* Display the bypass mode.*/
3671 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3672 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3676 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3677 bypass_mode = RTE_BYPASS_MODE_NONE;
3679 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3682 /* Display the bypass timeout.*/
3683 if (!RTE_BYPASS_TMT_VALID(timeout))
3684 timeout = RTE_BYPASS_TMT_OFF;
3686 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3688 /* Display the bypass events and associated modes. */
3689 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3691 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3692 printf("\tFailed to get bypass mode for event = %s\n",
3695 if (!RTE_BYPASS_MODE_VALID(event_mode))
3696 event_mode = RTE_BYPASS_MODE_NONE;
3698 printf("\tbypass event: %-16s = %s\n", events[i],
3704 cmdline_parse_token_string_t cmd_showbypass_config_show =
3705 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3707 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3708 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3710 cmdline_parse_token_string_t cmd_showbypass_config_config =
3711 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3713 cmdline_parse_token_num_t cmd_showbypass_config_port =
3714 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3717 cmdline_parse_inst_t cmd_show_bypass_config = {
3718 .f = cmd_show_bypass_config_parsed,
3719 .help_str = "show bypass config (port_id): "
3720 "Show the NIC bypass config for port_id",
3723 (void *)&cmd_showbypass_config_show,
3724 (void *)&cmd_showbypass_config_bypass,
3725 (void *)&cmd_showbypass_config_config,
3726 (void *)&cmd_showbypass_config_port,
3732 #ifdef RTE_LIBRTE_PMD_BOND
3733 /* *** SET BONDING MODE *** */
3734 struct cmd_set_bonding_mode_result {
3735 cmdline_fixed_string_t set;
3736 cmdline_fixed_string_t bonding;
3737 cmdline_fixed_string_t mode;
3742 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3743 __attribute__((unused)) struct cmdline *cl,
3744 __attribute__((unused)) void *data)
3746 struct cmd_set_bonding_mode_result *res = parsed_result;
3747 portid_t port_id = res->port_id;
3749 /* Set the bonding mode for the relevant port. */
3750 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3751 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3754 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3755 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3757 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3758 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3759 bonding, "bonding");
3760 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3761 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3763 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3764 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3766 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3767 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3770 cmdline_parse_inst_t cmd_set_bonding_mode = {
3771 .f = cmd_set_bonding_mode_parsed,
3772 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3775 (void *) &cmd_setbonding_mode_set,
3776 (void *) &cmd_setbonding_mode_bonding,
3777 (void *) &cmd_setbonding_mode_mode,
3778 (void *) &cmd_setbonding_mode_value,
3779 (void *) &cmd_setbonding_mode_port,
3784 /* *** SET BALANCE XMIT POLICY *** */
3785 struct cmd_set_bonding_balance_xmit_policy_result {
3786 cmdline_fixed_string_t set;
3787 cmdline_fixed_string_t bonding;
3788 cmdline_fixed_string_t balance_xmit_policy;
3790 cmdline_fixed_string_t policy;
3793 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3794 __attribute__((unused)) struct cmdline *cl,
3795 __attribute__((unused)) void *data)
3797 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3798 portid_t port_id = res->port_id;
3801 if (!strcmp(res->policy, "l2")) {
3802 policy = BALANCE_XMIT_POLICY_LAYER2;
3803 } else if (!strcmp(res->policy, "l23")) {
3804 policy = BALANCE_XMIT_POLICY_LAYER23;
3805 } else if (!strcmp(res->policy, "l34")) {
3806 policy = BALANCE_XMIT_POLICY_LAYER34;
3808 printf("\t Invalid xmit policy selection");
3812 /* Set the bonding mode for the relevant port. */
3813 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3814 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3819 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3820 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3822 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3823 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3824 bonding, "bonding");
3825 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3826 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3827 balance_xmit_policy, "balance_xmit_policy");
3828 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3829 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3831 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3832 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3833 policy, "l2#l23#l34");
3835 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3836 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3837 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3840 (void *)&cmd_setbonding_balance_xmit_policy_set,
3841 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3842 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3843 (void *)&cmd_setbonding_balance_xmit_policy_port,
3844 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3849 /* *** SHOW NIC BONDING CONFIGURATION *** */
3850 struct cmd_show_bonding_config_result {
3851 cmdline_fixed_string_t show;
3852 cmdline_fixed_string_t bonding;
3853 cmdline_fixed_string_t config;
3857 static void cmd_show_bonding_config_parsed(void *parsed_result,
3858 __attribute__((unused)) struct cmdline *cl,
3859 __attribute__((unused)) void *data)
3861 struct cmd_show_bonding_config_result *res = parsed_result;
3863 uint8_t slaves[RTE_MAX_ETHPORTS];
3864 int num_slaves, num_active_slaves;
3867 portid_t port_id = res->port_id;
3869 /* Display the bonding mode.*/
3870 bonding_mode = rte_eth_bond_mode_get(port_id);
3871 if (bonding_mode < 0) {
3872 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3875 printf("\tBonding mode: %d\n", bonding_mode);
3877 if (bonding_mode == BONDING_MODE_BALANCE) {
3878 int balance_xmit_policy;
3880 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3881 if (balance_xmit_policy < 0) {
3882 printf("\tFailed to get balance xmit policy for port = %d\n",
3886 printf("\tBalance Xmit Policy: ");
3888 switch (balance_xmit_policy) {
3889 case BALANCE_XMIT_POLICY_LAYER2:
3890 printf("BALANCE_XMIT_POLICY_LAYER2");
3892 case BALANCE_XMIT_POLICY_LAYER23:
3893 printf("BALANCE_XMIT_POLICY_LAYER23");
3895 case BALANCE_XMIT_POLICY_LAYER34:
3896 printf("BALANCE_XMIT_POLICY_LAYER34");
3903 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3905 if (num_slaves < 0) {
3906 printf("\tFailed to get slave list for port = %d\n", port_id);
3909 if (num_slaves > 0) {
3910 printf("\tSlaves (%d): [", num_slaves);
3911 for (i = 0; i < num_slaves - 1; i++)
3912 printf("%d ", slaves[i]);
3914 printf("%d]\n", slaves[num_slaves - 1]);
3916 printf("\tSlaves: []\n");
3920 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3923 if (num_active_slaves < 0) {
3924 printf("\tFailed to get active slave list for port = %d\n", port_id);
3927 if (num_active_slaves > 0) {
3928 printf("\tActive Slaves (%d): [", num_active_slaves);
3929 for (i = 0; i < num_active_slaves - 1; i++)
3930 printf("%d ", slaves[i]);
3932 printf("%d]\n", slaves[num_active_slaves - 1]);
3935 printf("\tActive Slaves: []\n");
3939 primary_id = rte_eth_bond_primary_get(port_id);
3940 if (primary_id < 0) {
3941 printf("\tFailed to get primary slave for port = %d\n", port_id);
3944 printf("\tPrimary: [%d]\n", primary_id);
3948 cmdline_parse_token_string_t cmd_showbonding_config_show =
3949 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3951 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3952 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3953 bonding, "bonding");
3954 cmdline_parse_token_string_t cmd_showbonding_config_config =
3955 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3957 cmdline_parse_token_num_t cmd_showbonding_config_port =
3958 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3961 cmdline_parse_inst_t cmd_show_bonding_config = {
3962 .f = cmd_show_bonding_config_parsed,
3963 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3966 (void *)&cmd_showbonding_config_show,
3967 (void *)&cmd_showbonding_config_bonding,
3968 (void *)&cmd_showbonding_config_config,
3969 (void *)&cmd_showbonding_config_port,
3974 /* *** SET BONDING PRIMARY *** */
3975 struct cmd_set_bonding_primary_result {
3976 cmdline_fixed_string_t set;
3977 cmdline_fixed_string_t bonding;
3978 cmdline_fixed_string_t primary;
3983 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3984 __attribute__((unused)) struct cmdline *cl,
3985 __attribute__((unused)) void *data)
3987 struct cmd_set_bonding_primary_result *res = parsed_result;
3988 portid_t master_port_id = res->port_id;
3989 portid_t slave_port_id = res->slave_id;
3991 /* Set the primary slave for a bonded device. */
3992 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3993 printf("\t Failed to set primary slave for port = %d.\n",
4000 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4001 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4003 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4004 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4005 bonding, "bonding");
4006 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4007 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4008 primary, "primary");
4009 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4010 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4012 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4013 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4016 cmdline_parse_inst_t cmd_set_bonding_primary = {
4017 .f = cmd_set_bonding_primary_parsed,
4018 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4021 (void *)&cmd_setbonding_primary_set,
4022 (void *)&cmd_setbonding_primary_bonding,
4023 (void *)&cmd_setbonding_primary_primary,
4024 (void *)&cmd_setbonding_primary_slave,
4025 (void *)&cmd_setbonding_primary_port,
4030 /* *** ADD SLAVE *** */
4031 struct cmd_add_bonding_slave_result {
4032 cmdline_fixed_string_t add;
4033 cmdline_fixed_string_t bonding;
4034 cmdline_fixed_string_t slave;
4039 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4040 __attribute__((unused)) struct cmdline *cl,
4041 __attribute__((unused)) void *data)
4043 struct cmd_add_bonding_slave_result *res = parsed_result;
4044 portid_t master_port_id = res->port_id;
4045 portid_t slave_port_id = res->slave_id;
4047 /* Set the primary slave for a bonded device. */
4048 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4049 printf("\t Failed to add slave %d to master port = %d.\n",
4050 slave_port_id, master_port_id);
4054 set_port_slave_flag(slave_port_id);
4057 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4058 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4060 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4061 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4062 bonding, "bonding");
4063 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4064 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4066 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4067 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4069 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4070 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4073 cmdline_parse_inst_t cmd_add_bonding_slave = {
4074 .f = cmd_add_bonding_slave_parsed,
4075 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4078 (void *)&cmd_addbonding_slave_add,
4079 (void *)&cmd_addbonding_slave_bonding,
4080 (void *)&cmd_addbonding_slave_slave,
4081 (void *)&cmd_addbonding_slave_slaveid,
4082 (void *)&cmd_addbonding_slave_port,
4087 /* *** REMOVE SLAVE *** */
4088 struct cmd_remove_bonding_slave_result {
4089 cmdline_fixed_string_t remove;
4090 cmdline_fixed_string_t bonding;
4091 cmdline_fixed_string_t slave;
4096 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4097 __attribute__((unused)) struct cmdline *cl,
4098 __attribute__((unused)) void *data)
4100 struct cmd_remove_bonding_slave_result *res = parsed_result;
4101 portid_t master_port_id = res->port_id;
4102 portid_t slave_port_id = res->slave_id;
4104 /* Set the primary slave for a bonded device. */
4105 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4106 printf("\t Failed to remove slave %d from master port = %d.\n",
4107 slave_port_id, master_port_id);
4111 clear_port_slave_flag(slave_port_id);
4114 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4115 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4117 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4118 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4119 bonding, "bonding");
4120 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4121 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4123 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4124 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4126 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4127 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4130 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4131 .f = cmd_remove_bonding_slave_parsed,
4132 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4135 (void *)&cmd_removebonding_slave_remove,
4136 (void *)&cmd_removebonding_slave_bonding,
4137 (void *)&cmd_removebonding_slave_slave,
4138 (void *)&cmd_removebonding_slave_slaveid,
4139 (void *)&cmd_removebonding_slave_port,
4144 /* *** CREATE BONDED DEVICE *** */
4145 struct cmd_create_bonded_device_result {
4146 cmdline_fixed_string_t create;
4147 cmdline_fixed_string_t bonded;
4148 cmdline_fixed_string_t device;
4153 static int bond_dev_num = 0;
4155 static void cmd_create_bonded_device_parsed(void *parsed_result,
4156 __attribute__((unused)) struct cmdline *cl,
4157 __attribute__((unused)) void *data)
4159 struct cmd_create_bonded_device_result *res = parsed_result;
4160 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4163 if (test_done == 0) {
4164 printf("Please stop forwarding first\n");
4168 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4171 /* Create a new bonded device. */
4172 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4174 printf("\t Failed to create bonded device.\n");
4177 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4180 /* Update number of ports */
4181 nb_ports = rte_eth_dev_count();
4182 reconfig(port_id, res->socket);
4183 rte_eth_promiscuous_enable(port_id);
4184 ports[port_id].enabled = 1;
4189 cmdline_parse_token_string_t cmd_createbonded_device_create =
4190 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4192 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4193 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4195 cmdline_parse_token_string_t cmd_createbonded_device_device =
4196 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4198 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4199 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4201 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4202 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4205 cmdline_parse_inst_t cmd_create_bonded_device = {
4206 .f = cmd_create_bonded_device_parsed,
4207 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4210 (void *)&cmd_createbonded_device_create,
4211 (void *)&cmd_createbonded_device_bonded,
4212 (void *)&cmd_createbonded_device_device,
4213 (void *)&cmd_createbonded_device_mode,
4214 (void *)&cmd_createbonded_device_socket,
4219 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4220 struct cmd_set_bond_mac_addr_result {
4221 cmdline_fixed_string_t set;
4222 cmdline_fixed_string_t bonding;
4223 cmdline_fixed_string_t mac_addr;
4225 struct ether_addr address;
4228 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4229 __attribute__((unused)) struct cmdline *cl,
4230 __attribute__((unused)) void *data)
4232 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4235 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4238 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4240 /* check the return value and print it if is < 0 */
4242 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4245 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4246 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4247 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4248 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4250 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4251 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4253 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4254 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4255 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4256 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4258 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4259 .f = cmd_set_bond_mac_addr_parsed,
4261 .help_str = "set bonding mac_addr (port_id) (address): ",
4263 (void *)&cmd_set_bond_mac_addr_set,
4264 (void *)&cmd_set_bond_mac_addr_bonding,
4265 (void *)&cmd_set_bond_mac_addr_mac,
4266 (void *)&cmd_set_bond_mac_addr_portnum,
4267 (void *)&cmd_set_bond_mac_addr_addr,
4273 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4274 struct cmd_set_bond_mon_period_result {
4275 cmdline_fixed_string_t set;
4276 cmdline_fixed_string_t bonding;
4277 cmdline_fixed_string_t mon_period;
4282 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4283 __attribute__((unused)) struct cmdline *cl,
4284 __attribute__((unused)) void *data)
4286 struct cmd_set_bond_mon_period_result *res = parsed_result;
4289 if (res->port_num >= nb_ports) {
4290 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4294 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4296 /* check the return value and print it if is < 0 */
4298 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4301 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4302 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4304 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4305 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4306 bonding, "bonding");
4307 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4308 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4309 mon_period, "mon_period");
4310 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4311 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4313 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4314 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4317 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4318 .f = cmd_set_bond_mon_period_parsed,
4320 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4322 (void *)&cmd_set_bond_mon_period_set,
4323 (void *)&cmd_set_bond_mon_period_bonding,
4324 (void *)&cmd_set_bond_mon_period_mon_period,
4325 (void *)&cmd_set_bond_mon_period_portnum,
4326 (void *)&cmd_set_bond_mon_period_period_ms,
4331 #endif /* RTE_LIBRTE_PMD_BOND */
4333 /* *** SET FORWARDING MODE *** */
4334 struct cmd_set_fwd_mode_result {
4335 cmdline_fixed_string_t set;
4336 cmdline_fixed_string_t fwd;
4337 cmdline_fixed_string_t mode;
4340 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4341 __attribute__((unused)) struct cmdline *cl,
4342 __attribute__((unused)) void *data)
4344 struct cmd_set_fwd_mode_result *res = parsed_result;
4346 set_pkt_forwarding_mode(res->mode);
4349 cmdline_parse_token_string_t cmd_setfwd_set =
4350 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4351 cmdline_parse_token_string_t cmd_setfwd_fwd =
4352 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4353 cmdline_parse_token_string_t cmd_setfwd_mode =
4354 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4355 "" /* defined at init */);
4357 cmdline_parse_inst_t cmd_set_fwd_mode = {
4358 .f = cmd_set_fwd_mode_parsed,
4360 .help_str = NULL, /* defined at init */
4362 (void *)&cmd_setfwd_set,
4363 (void *)&cmd_setfwd_fwd,
4364 (void *)&cmd_setfwd_mode,
4369 static void cmd_set_fwd_mode_init(void)
4372 static char token[128];
4373 static char help[256];
4374 cmdline_parse_token_string_t *token_struct;
4376 modes = list_pkt_forwarding_modes();
4377 snprintf(help, sizeof help, "set fwd %s - "
4378 "set packet forwarding mode", modes);
4379 cmd_set_fwd_mode.help_str = help;
4381 /* string token separator is # */
4382 for (c = token; *modes != '\0'; modes++)
4387 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4388 token_struct->string_data.str = token;
4391 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4392 struct cmd_set_burst_tx_retry_result {
4393 cmdline_fixed_string_t set;
4394 cmdline_fixed_string_t burst;
4395 cmdline_fixed_string_t tx;
4396 cmdline_fixed_string_t delay;
4398 cmdline_fixed_string_t retry;
4402 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4403 __attribute__((unused)) struct cmdline *cl,
4404 __attribute__((unused)) void *data)
4406 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4408 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4409 && !strcmp(res->tx, "tx")) {
4410 if (!strcmp(res->delay, "delay"))
4411 burst_tx_delay_time = res->time;
4412 if (!strcmp(res->retry, "retry"))
4413 burst_tx_retry_num = res->retry_num;
4418 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4419 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4420 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4421 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4423 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4424 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4425 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4426 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4427 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4428 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4429 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4430 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4431 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4432 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4434 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4435 .f = cmd_set_burst_tx_retry_parsed,
4436 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4438 (void *)&cmd_set_burst_tx_retry_set,
4439 (void *)&cmd_set_burst_tx_retry_burst,
4440 (void *)&cmd_set_burst_tx_retry_tx,
4441 (void *)&cmd_set_burst_tx_retry_delay,
4442 (void *)&cmd_set_burst_tx_retry_time,
4443 (void *)&cmd_set_burst_tx_retry_retry,
4444 (void *)&cmd_set_burst_tx_retry_retry_num,
4449 /* *** SET PROMISC MODE *** */
4450 struct cmd_set_promisc_mode_result {
4451 cmdline_fixed_string_t set;
4452 cmdline_fixed_string_t promisc;
4453 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4454 uint8_t port_num; /* valid if "allports" argument == 0 */
4455 cmdline_fixed_string_t mode;
4458 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4459 __attribute__((unused)) struct cmdline *cl,
4462 struct cmd_set_promisc_mode_result *res = parsed_result;
4466 if (!strcmp(res->mode, "on"))
4473 FOREACH_PORT(i, ports) {
4475 rte_eth_promiscuous_enable(i);
4477 rte_eth_promiscuous_disable(i);
4482 rte_eth_promiscuous_enable(res->port_num);
4484 rte_eth_promiscuous_disable(res->port_num);
4488 cmdline_parse_token_string_t cmd_setpromisc_set =
4489 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4490 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4491 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4493 cmdline_parse_token_string_t cmd_setpromisc_portall =
4494 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4496 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4497 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4499 cmdline_parse_token_string_t cmd_setpromisc_mode =
4500 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4503 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4504 .f = cmd_set_promisc_mode_parsed,
4506 .help_str = "set promisc all on|off: set promisc mode for all ports",
4508 (void *)&cmd_setpromisc_set,
4509 (void *)&cmd_setpromisc_promisc,
4510 (void *)&cmd_setpromisc_portall,
4511 (void *)&cmd_setpromisc_mode,
4516 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4517 .f = cmd_set_promisc_mode_parsed,
4519 .help_str = "set promisc X on|off: set promisc mode on port X",
4521 (void *)&cmd_setpromisc_set,
4522 (void *)&cmd_setpromisc_promisc,
4523 (void *)&cmd_setpromisc_portnum,
4524 (void *)&cmd_setpromisc_mode,
4529 /* *** SET ALLMULTI MODE *** */
4530 struct cmd_set_allmulti_mode_result {
4531 cmdline_fixed_string_t set;
4532 cmdline_fixed_string_t allmulti;
4533 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4534 uint8_t port_num; /* valid if "allports" argument == 0 */
4535 cmdline_fixed_string_t mode;
4538 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4539 __attribute__((unused)) struct cmdline *cl,
4542 struct cmd_set_allmulti_mode_result *res = parsed_result;
4546 if (!strcmp(res->mode, "on"))
4553 FOREACH_PORT(i, ports) {
4555 rte_eth_allmulticast_enable(i);
4557 rte_eth_allmulticast_disable(i);
4562 rte_eth_allmulticast_enable(res->port_num);
4564 rte_eth_allmulticast_disable(res->port_num);
4568 cmdline_parse_token_string_t cmd_setallmulti_set =
4569 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4570 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4571 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4573 cmdline_parse_token_string_t cmd_setallmulti_portall =
4574 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4576 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4577 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4579 cmdline_parse_token_string_t cmd_setallmulti_mode =
4580 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4583 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4584 .f = cmd_set_allmulti_mode_parsed,
4586 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4588 (void *)&cmd_setallmulti_set,
4589 (void *)&cmd_setallmulti_allmulti,
4590 (void *)&cmd_setallmulti_portall,
4591 (void *)&cmd_setallmulti_mode,
4596 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4597 .f = cmd_set_allmulti_mode_parsed,
4599 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4601 (void *)&cmd_setallmulti_set,
4602 (void *)&cmd_setallmulti_allmulti,
4603 (void *)&cmd_setallmulti_portnum,
4604 (void *)&cmd_setallmulti_mode,
4609 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4610 struct cmd_link_flow_ctrl_set_result {
4611 cmdline_fixed_string_t set;
4612 cmdline_fixed_string_t flow_ctrl;
4613 cmdline_fixed_string_t rx;
4614 cmdline_fixed_string_t rx_lfc_mode;
4615 cmdline_fixed_string_t tx;
4616 cmdline_fixed_string_t tx_lfc_mode;
4617 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4618 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4619 cmdline_fixed_string_t autoneg_str;
4620 cmdline_fixed_string_t autoneg;
4621 cmdline_fixed_string_t hw_str;
4622 uint32_t high_water;
4623 cmdline_fixed_string_t lw_str;
4625 cmdline_fixed_string_t pt_str;
4626 uint16_t pause_time;
4627 cmdline_fixed_string_t xon_str;
4632 cmdline_parse_token_string_t cmd_lfc_set_set =
4633 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4635 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4636 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4637 flow_ctrl, "flow_ctrl");
4638 cmdline_parse_token_string_t cmd_lfc_set_rx =
4639 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4641 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4642 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4643 rx_lfc_mode, "on#off");
4644 cmdline_parse_token_string_t cmd_lfc_set_tx =
4645 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4647 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4648 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4649 tx_lfc_mode, "on#off");
4650 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4651 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4652 hw_str, "high_water");
4653 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4654 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4655 high_water, UINT32);
4656 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4657 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4658 lw_str, "low_water");
4659 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4660 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4662 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4663 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4664 pt_str, "pause_time");
4665 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4666 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4667 pause_time, UINT16);
4668 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4669 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4670 xon_str, "send_xon");
4671 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4672 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4674 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4675 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4676 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4677 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4678 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4679 mac_ctrl_frame_fwd_mode, "on#off");
4680 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4681 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4682 autoneg_str, "autoneg");
4683 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4684 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4686 cmdline_parse_token_num_t cmd_lfc_set_portid =
4687 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4690 /* forward declaration */
4692 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4695 cmdline_parse_inst_t cmd_link_flow_control_set = {
4696 .f = cmd_link_flow_ctrl_set_parsed,
4698 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4699 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4700 autoneg on|off port_id",
4702 (void *)&cmd_lfc_set_set,
4703 (void *)&cmd_lfc_set_flow_ctrl,
4704 (void *)&cmd_lfc_set_rx,
4705 (void *)&cmd_lfc_set_rx_mode,
4706 (void *)&cmd_lfc_set_tx,
4707 (void *)&cmd_lfc_set_tx_mode,
4708 (void *)&cmd_lfc_set_high_water,
4709 (void *)&cmd_lfc_set_low_water,
4710 (void *)&cmd_lfc_set_pause_time,
4711 (void *)&cmd_lfc_set_send_xon,
4712 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4713 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4714 (void *)&cmd_lfc_set_autoneg_str,
4715 (void *)&cmd_lfc_set_autoneg,
4716 (void *)&cmd_lfc_set_portid,
4721 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4722 .f = cmd_link_flow_ctrl_set_parsed,
4723 .data = (void *)&cmd_link_flow_control_set_rx,
4724 .help_str = "Change rx flow control parameter: set flow_ctrl "
4725 "rx on|off port_id",
4727 (void *)&cmd_lfc_set_set,
4728 (void *)&cmd_lfc_set_flow_ctrl,
4729 (void *)&cmd_lfc_set_rx,
4730 (void *)&cmd_lfc_set_rx_mode,
4731 (void *)&cmd_lfc_set_portid,
4736 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4737 .f = cmd_link_flow_ctrl_set_parsed,
4738 .data = (void *)&cmd_link_flow_control_set_tx,
4739 .help_str = "Change tx flow control parameter: set flow_ctrl "
4740 "tx on|off port_id",
4742 (void *)&cmd_lfc_set_set,
4743 (void *)&cmd_lfc_set_flow_ctrl,
4744 (void *)&cmd_lfc_set_tx,
4745 (void *)&cmd_lfc_set_tx_mode,
4746 (void *)&cmd_lfc_set_portid,
4751 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4752 .f = cmd_link_flow_ctrl_set_parsed,
4753 .data = (void *)&cmd_link_flow_control_set_hw,
4754 .help_str = "Change high water flow control parameter: set flow_ctrl "
4755 "high_water value port_id",
4757 (void *)&cmd_lfc_set_set,
4758 (void *)&cmd_lfc_set_flow_ctrl,
4759 (void *)&cmd_lfc_set_high_water_str,
4760 (void *)&cmd_lfc_set_high_water,
4761 (void *)&cmd_lfc_set_portid,
4766 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4767 .f = cmd_link_flow_ctrl_set_parsed,
4768 .data = (void *)&cmd_link_flow_control_set_lw,
4769 .help_str = "Change low water flow control parameter: set flow_ctrl "
4770 "low_water value port_id",
4772 (void *)&cmd_lfc_set_set,
4773 (void *)&cmd_lfc_set_flow_ctrl,
4774 (void *)&cmd_lfc_set_low_water_str,
4775 (void *)&cmd_lfc_set_low_water,
4776 (void *)&cmd_lfc_set_portid,
4781 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4782 .f = cmd_link_flow_ctrl_set_parsed,
4783 .data = (void *)&cmd_link_flow_control_set_pt,
4784 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4785 "pause_time value port_id",
4787 (void *)&cmd_lfc_set_set,
4788 (void *)&cmd_lfc_set_flow_ctrl,
4789 (void *)&cmd_lfc_set_pause_time_str,
4790 (void *)&cmd_lfc_set_pause_time,
4791 (void *)&cmd_lfc_set_portid,
4796 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4797 .f = cmd_link_flow_ctrl_set_parsed,
4798 .data = (void *)&cmd_link_flow_control_set_xon,
4799 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4800 "send_xon value port_id",
4802 (void *)&cmd_lfc_set_set,
4803 (void *)&cmd_lfc_set_flow_ctrl,
4804 (void *)&cmd_lfc_set_send_xon_str,
4805 (void *)&cmd_lfc_set_send_xon,
4806 (void *)&cmd_lfc_set_portid,
4811 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4812 .f = cmd_link_flow_ctrl_set_parsed,
4813 .data = (void *)&cmd_link_flow_control_set_macfwd,
4814 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4815 "mac_ctrl_frame_fwd on|off port_id",
4817 (void *)&cmd_lfc_set_set,
4818 (void *)&cmd_lfc_set_flow_ctrl,
4819 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4820 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4821 (void *)&cmd_lfc_set_portid,
4826 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4827 .f = cmd_link_flow_ctrl_set_parsed,
4828 .data = (void *)&cmd_link_flow_control_set_autoneg,
4829 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4830 "autoneg on|off port_id",
4832 (void *)&cmd_lfc_set_set,
4833 (void *)&cmd_lfc_set_flow_ctrl,
4834 (void *)&cmd_lfc_set_autoneg_str,
4835 (void *)&cmd_lfc_set_autoneg,
4836 (void *)&cmd_lfc_set_portid,
4842 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4843 __attribute__((unused)) struct cmdline *cl,
4846 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4847 cmdline_parse_inst_t *cmd = data;
4848 struct rte_eth_fc_conf fc_conf;
4854 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4855 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4856 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4857 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4859 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4860 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4863 /* Partial command line, retrieve current configuration */
4865 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4867 printf("cannot get current flow ctrl parameters, return"
4868 "code = %d\n", ret);
4872 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4873 (fc_conf.mode == RTE_FC_FULL))
4875 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4876 (fc_conf.mode == RTE_FC_FULL))
4880 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4881 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4883 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4884 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4886 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4888 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4889 fc_conf.high_water = res->high_water;
4891 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4892 fc_conf.low_water = res->low_water;
4894 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4895 fc_conf.pause_time = res->pause_time;
4897 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4898 fc_conf.send_xon = res->send_xon;
4900 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4901 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4902 fc_conf.mac_ctrl_frame_fwd = 1;
4904 fc_conf.mac_ctrl_frame_fwd = 0;
4907 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4908 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4910 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4912 printf("bad flow contrl parameter, return code = %d \n", ret);
4915 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4916 struct cmd_priority_flow_ctrl_set_result {
4917 cmdline_fixed_string_t set;
4918 cmdline_fixed_string_t pfc_ctrl;
4919 cmdline_fixed_string_t rx;
4920 cmdline_fixed_string_t rx_pfc_mode;
4921 cmdline_fixed_string_t tx;
4922 cmdline_fixed_string_t tx_pfc_mode;
4923 uint32_t high_water;
4925 uint16_t pause_time;
4931 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4932 __attribute__((unused)) struct cmdline *cl,
4933 __attribute__((unused)) void *data)
4935 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4936 struct rte_eth_pfc_conf pfc_conf;
4937 int rx_fc_enable, tx_fc_enable;
4941 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4942 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4943 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4944 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4946 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4947 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4950 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4951 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4952 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4953 pfc_conf.fc.high_water = res->high_water;
4954 pfc_conf.fc.low_water = res->low_water;
4955 pfc_conf.fc.pause_time = res->pause_time;
4956 pfc_conf.priority = res->priority;
4958 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4960 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4963 cmdline_parse_token_string_t cmd_pfc_set_set =
4964 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4966 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4967 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4968 pfc_ctrl, "pfc_ctrl");
4969 cmdline_parse_token_string_t cmd_pfc_set_rx =
4970 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4972 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4973 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4974 rx_pfc_mode, "on#off");
4975 cmdline_parse_token_string_t cmd_pfc_set_tx =
4976 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4978 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4979 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4980 tx_pfc_mode, "on#off");
4981 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4982 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4983 high_water, UINT32);
4984 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4985 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4987 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4988 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4989 pause_time, UINT16);
4990 cmdline_parse_token_num_t cmd_pfc_set_priority =
4991 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4993 cmdline_parse_token_num_t cmd_pfc_set_portid =
4994 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4997 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4998 .f = cmd_priority_flow_ctrl_set_parsed,
5000 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5001 tx on|off high_water low_water pause_time priority port_id",
5003 (void *)&cmd_pfc_set_set,
5004 (void *)&cmd_pfc_set_flow_ctrl,
5005 (void *)&cmd_pfc_set_rx,
5006 (void *)&cmd_pfc_set_rx_mode,
5007 (void *)&cmd_pfc_set_tx,
5008 (void *)&cmd_pfc_set_tx_mode,
5009 (void *)&cmd_pfc_set_high_water,
5010 (void *)&cmd_pfc_set_low_water,
5011 (void *)&cmd_pfc_set_pause_time,
5012 (void *)&cmd_pfc_set_priority,
5013 (void *)&cmd_pfc_set_portid,
5018 /* *** RESET CONFIGURATION *** */
5019 struct cmd_reset_result {
5020 cmdline_fixed_string_t reset;
5021 cmdline_fixed_string_t def;
5024 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5026 __attribute__((unused)) void *data)
5028 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5029 set_def_fwd_config();
5032 cmdline_parse_token_string_t cmd_reset_set =
5033 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5034 cmdline_parse_token_string_t cmd_reset_def =
5035 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5038 cmdline_parse_inst_t cmd_reset = {
5039 .f = cmd_reset_parsed,
5041 .help_str = "set default: reset default forwarding configuration",
5043 (void *)&cmd_reset_set,
5044 (void *)&cmd_reset_def,
5049 /* *** START FORWARDING *** */
5050 struct cmd_start_result {
5051 cmdline_fixed_string_t start;
5054 cmdline_parse_token_string_t cmd_start_start =
5055 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5057 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5058 __attribute__((unused)) struct cmdline *cl,
5059 __attribute__((unused)) void *data)
5061 start_packet_forwarding(0);
5064 cmdline_parse_inst_t cmd_start = {
5065 .f = cmd_start_parsed,
5067 .help_str = "start packet forwarding",
5069 (void *)&cmd_start_start,
5074 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5075 struct cmd_start_tx_first_result {
5076 cmdline_fixed_string_t start;
5077 cmdline_fixed_string_t tx_first;
5081 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5082 __attribute__((unused)) struct cmdline *cl,
5083 __attribute__((unused)) void *data)
5085 start_packet_forwarding(1);
5088 cmdline_parse_token_string_t cmd_start_tx_first_start =
5089 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5091 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5092 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5093 tx_first, "tx_first");
5095 cmdline_parse_inst_t cmd_start_tx_first = {
5096 .f = cmd_start_tx_first_parsed,
5098 .help_str = "start packet forwarding, after sending 1 burst of packets",
5100 (void *)&cmd_start_tx_first_start,
5101 (void *)&cmd_start_tx_first_tx_first,
5106 /* *** SET LINK UP *** */
5107 struct cmd_set_link_up_result {
5108 cmdline_fixed_string_t set;
5109 cmdline_fixed_string_t link_up;
5110 cmdline_fixed_string_t port;
5114 cmdline_parse_token_string_t cmd_set_link_up_set =
5115 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5116 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5117 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5119 cmdline_parse_token_string_t cmd_set_link_up_port =
5120 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5121 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5122 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5124 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5125 __attribute__((unused)) struct cmdline *cl,
5126 __attribute__((unused)) void *data)
5128 struct cmd_set_link_up_result *res = parsed_result;
5129 dev_set_link_up(res->port_id);
5132 cmdline_parse_inst_t cmd_set_link_up = {
5133 .f = cmd_set_link_up_parsed,
5135 .help_str = "set link-up port (port id)",
5137 (void *)&cmd_set_link_up_set,
5138 (void *)&cmd_set_link_up_link_up,
5139 (void *)&cmd_set_link_up_port,
5140 (void *)&cmd_set_link_up_port_id,
5145 /* *** SET LINK DOWN *** */
5146 struct cmd_set_link_down_result {
5147 cmdline_fixed_string_t set;
5148 cmdline_fixed_string_t link_down;
5149 cmdline_fixed_string_t port;
5153 cmdline_parse_token_string_t cmd_set_link_down_set =
5154 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5155 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5156 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5158 cmdline_parse_token_string_t cmd_set_link_down_port =
5159 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5160 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5161 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5163 static void cmd_set_link_down_parsed(
5164 __attribute__((unused)) void *parsed_result,
5165 __attribute__((unused)) struct cmdline *cl,
5166 __attribute__((unused)) void *data)
5168 struct cmd_set_link_down_result *res = parsed_result;
5169 dev_set_link_down(res->port_id);
5172 cmdline_parse_inst_t cmd_set_link_down = {
5173 .f = cmd_set_link_down_parsed,
5175 .help_str = "set link-down port (port id)",
5177 (void *)&cmd_set_link_down_set,
5178 (void *)&cmd_set_link_down_link_down,
5179 (void *)&cmd_set_link_down_port,
5180 (void *)&cmd_set_link_down_port_id,
5185 /* *** SHOW CFG *** */
5186 struct cmd_showcfg_result {
5187 cmdline_fixed_string_t show;
5188 cmdline_fixed_string_t cfg;
5189 cmdline_fixed_string_t what;
5192 static void cmd_showcfg_parsed(void *parsed_result,
5193 __attribute__((unused)) struct cmdline *cl,
5194 __attribute__((unused)) void *data)
5196 struct cmd_showcfg_result *res = parsed_result;
5197 if (!strcmp(res->what, "rxtx"))
5198 rxtx_config_display();
5199 else if (!strcmp(res->what, "cores"))
5200 fwd_lcores_config_display();
5201 else if (!strcmp(res->what, "fwd"))
5202 fwd_config_display();
5205 cmdline_parse_token_string_t cmd_showcfg_show =
5206 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5207 cmdline_parse_token_string_t cmd_showcfg_port =
5208 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5209 cmdline_parse_token_string_t cmd_showcfg_what =
5210 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5213 cmdline_parse_inst_t cmd_showcfg = {
5214 .f = cmd_showcfg_parsed,
5216 .help_str = "show config rxtx|cores|fwd",
5218 (void *)&cmd_showcfg_show,
5219 (void *)&cmd_showcfg_port,
5220 (void *)&cmd_showcfg_what,
5225 /* *** SHOW ALL PORT INFO *** */
5226 struct cmd_showportall_result {
5227 cmdline_fixed_string_t show;
5228 cmdline_fixed_string_t port;
5229 cmdline_fixed_string_t what;
5230 cmdline_fixed_string_t all;
5233 static void cmd_showportall_parsed(void *parsed_result,
5234 __attribute__((unused)) struct cmdline *cl,
5235 __attribute__((unused)) void *data)
5239 struct cmd_showportall_result *res = parsed_result;
5240 if (!strcmp(res->show, "clear")) {
5241 if (!strcmp(res->what, "stats"))
5242 FOREACH_PORT(i, ports)
5244 else if (!strcmp(res->what, "xstats"))
5245 FOREACH_PORT(i, ports)
5246 nic_xstats_clear(i);
5247 } else if (!strcmp(res->what, "info"))
5248 FOREACH_PORT(i, ports)
5249 port_infos_display(i);
5250 else if (!strcmp(res->what, "stats"))
5251 FOREACH_PORT(i, ports)
5252 nic_stats_display(i);
5253 else if (!strcmp(res->what, "xstats"))
5254 FOREACH_PORT(i, ports)
5255 nic_xstats_display(i);
5256 else if (!strcmp(res->what, "fdir"))
5257 FOREACH_PORT(i, ports)
5259 else if (!strcmp(res->what, "stat_qmap"))
5260 FOREACH_PORT(i, ports)
5261 nic_stats_mapping_display(i);
5264 cmdline_parse_token_string_t cmd_showportall_show =
5265 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5267 cmdline_parse_token_string_t cmd_showportall_port =
5268 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5269 cmdline_parse_token_string_t cmd_showportall_what =
5270 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5271 "info#stats#xstats#fdir#stat_qmap");
5272 cmdline_parse_token_string_t cmd_showportall_all =
5273 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5274 cmdline_parse_inst_t cmd_showportall = {
5275 .f = cmd_showportall_parsed,
5277 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5279 (void *)&cmd_showportall_show,
5280 (void *)&cmd_showportall_port,
5281 (void *)&cmd_showportall_what,
5282 (void *)&cmd_showportall_all,
5287 /* *** SHOW PORT INFO *** */
5288 struct cmd_showport_result {
5289 cmdline_fixed_string_t show;
5290 cmdline_fixed_string_t port;
5291 cmdline_fixed_string_t what;
5295 static void cmd_showport_parsed(void *parsed_result,
5296 __attribute__((unused)) struct cmdline *cl,
5297 __attribute__((unused)) void *data)
5299 struct cmd_showport_result *res = parsed_result;
5300 if (!strcmp(res->show, "clear")) {
5301 if (!strcmp(res->what, "stats"))
5302 nic_stats_clear(res->portnum);
5303 else if (!strcmp(res->what, "xstats"))
5304 nic_xstats_clear(res->portnum);
5305 } else if (!strcmp(res->what, "info"))
5306 port_infos_display(res->portnum);
5307 else if (!strcmp(res->what, "stats"))
5308 nic_stats_display(res->portnum);
5309 else if (!strcmp(res->what, "xstats"))
5310 nic_xstats_display(res->portnum);
5311 else if (!strcmp(res->what, "fdir"))
5312 fdir_get_infos(res->portnum);
5313 else if (!strcmp(res->what, "stat_qmap"))
5314 nic_stats_mapping_display(res->portnum);
5317 cmdline_parse_token_string_t cmd_showport_show =
5318 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5320 cmdline_parse_token_string_t cmd_showport_port =
5321 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5322 cmdline_parse_token_string_t cmd_showport_what =
5323 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5324 "info#stats#xstats#fdir#stat_qmap");
5325 cmdline_parse_token_num_t cmd_showport_portnum =
5326 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5328 cmdline_parse_inst_t cmd_showport = {
5329 .f = cmd_showport_parsed,
5331 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5333 (void *)&cmd_showport_show,
5334 (void *)&cmd_showport_port,
5335 (void *)&cmd_showport_what,
5336 (void *)&cmd_showport_portnum,
5341 /* *** READ PORT REGISTER *** */
5342 struct cmd_read_reg_result {
5343 cmdline_fixed_string_t read;
5344 cmdline_fixed_string_t reg;
5350 cmd_read_reg_parsed(void *parsed_result,
5351 __attribute__((unused)) struct cmdline *cl,
5352 __attribute__((unused)) void *data)
5354 struct cmd_read_reg_result *res = parsed_result;
5355 port_reg_display(res->port_id, res->reg_off);
5358 cmdline_parse_token_string_t cmd_read_reg_read =
5359 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5360 cmdline_parse_token_string_t cmd_read_reg_reg =
5361 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5362 cmdline_parse_token_num_t cmd_read_reg_port_id =
5363 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5364 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5365 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5367 cmdline_parse_inst_t cmd_read_reg = {
5368 .f = cmd_read_reg_parsed,
5370 .help_str = "read reg port_id reg_off",
5372 (void *)&cmd_read_reg_read,
5373 (void *)&cmd_read_reg_reg,
5374 (void *)&cmd_read_reg_port_id,
5375 (void *)&cmd_read_reg_reg_off,
5380 /* *** READ PORT REGISTER BIT FIELD *** */
5381 struct cmd_read_reg_bit_field_result {
5382 cmdline_fixed_string_t read;
5383 cmdline_fixed_string_t regfield;
5391 cmd_read_reg_bit_field_parsed(void *parsed_result,
5392 __attribute__((unused)) struct cmdline *cl,
5393 __attribute__((unused)) void *data)
5395 struct cmd_read_reg_bit_field_result *res = parsed_result;
5396 port_reg_bit_field_display(res->port_id, res->reg_off,
5397 res->bit1_pos, res->bit2_pos);
5400 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5401 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5403 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5404 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5405 regfield, "regfield");
5406 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5407 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5409 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5410 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5412 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5413 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5415 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5416 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5419 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5420 .f = cmd_read_reg_bit_field_parsed,
5422 .help_str = "read regfield port_id reg_off bit_x bit_y "
5423 "(read register bit field between bit_x and bit_y included)",
5425 (void *)&cmd_read_reg_bit_field_read,
5426 (void *)&cmd_read_reg_bit_field_regfield,
5427 (void *)&cmd_read_reg_bit_field_port_id,
5428 (void *)&cmd_read_reg_bit_field_reg_off,
5429 (void *)&cmd_read_reg_bit_field_bit1_pos,
5430 (void *)&cmd_read_reg_bit_field_bit2_pos,
5435 /* *** READ PORT REGISTER BIT *** */
5436 struct cmd_read_reg_bit_result {
5437 cmdline_fixed_string_t read;
5438 cmdline_fixed_string_t regbit;
5445 cmd_read_reg_bit_parsed(void *parsed_result,
5446 __attribute__((unused)) struct cmdline *cl,
5447 __attribute__((unused)) void *data)
5449 struct cmd_read_reg_bit_result *res = parsed_result;
5450 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5453 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5454 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5455 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5456 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5458 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5459 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5460 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5461 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5462 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5463 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5465 cmdline_parse_inst_t cmd_read_reg_bit = {
5466 .f = cmd_read_reg_bit_parsed,
5468 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5470 (void *)&cmd_read_reg_bit_read,
5471 (void *)&cmd_read_reg_bit_regbit,
5472 (void *)&cmd_read_reg_bit_port_id,
5473 (void *)&cmd_read_reg_bit_reg_off,
5474 (void *)&cmd_read_reg_bit_bit_pos,
5479 /* *** WRITE PORT REGISTER *** */
5480 struct cmd_write_reg_result {
5481 cmdline_fixed_string_t write;
5482 cmdline_fixed_string_t reg;
5489 cmd_write_reg_parsed(void *parsed_result,
5490 __attribute__((unused)) struct cmdline *cl,
5491 __attribute__((unused)) void *data)
5493 struct cmd_write_reg_result *res = parsed_result;
5494 port_reg_set(res->port_id, res->reg_off, res->value);
5497 cmdline_parse_token_string_t cmd_write_reg_write =
5498 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5499 cmdline_parse_token_string_t cmd_write_reg_reg =
5500 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5501 cmdline_parse_token_num_t cmd_write_reg_port_id =
5502 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5503 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5504 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5505 cmdline_parse_token_num_t cmd_write_reg_value =
5506 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5508 cmdline_parse_inst_t cmd_write_reg = {
5509 .f = cmd_write_reg_parsed,
5511 .help_str = "write reg port_id reg_off reg_value",
5513 (void *)&cmd_write_reg_write,
5514 (void *)&cmd_write_reg_reg,
5515 (void *)&cmd_write_reg_port_id,
5516 (void *)&cmd_write_reg_reg_off,
5517 (void *)&cmd_write_reg_value,
5522 /* *** WRITE PORT REGISTER BIT FIELD *** */
5523 struct cmd_write_reg_bit_field_result {
5524 cmdline_fixed_string_t write;
5525 cmdline_fixed_string_t regfield;
5534 cmd_write_reg_bit_field_parsed(void *parsed_result,
5535 __attribute__((unused)) struct cmdline *cl,
5536 __attribute__((unused)) void *data)
5538 struct cmd_write_reg_bit_field_result *res = parsed_result;
5539 port_reg_bit_field_set(res->port_id, res->reg_off,
5540 res->bit1_pos, res->bit2_pos, res->value);
5543 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5544 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5546 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5547 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5548 regfield, "regfield");
5549 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5550 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5552 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5553 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5555 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5556 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5558 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5559 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5561 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5562 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5565 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5566 .f = cmd_write_reg_bit_field_parsed,
5568 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5569 "(set register bit field between bit_x and bit_y included)",
5571 (void *)&cmd_write_reg_bit_field_write,
5572 (void *)&cmd_write_reg_bit_field_regfield,
5573 (void *)&cmd_write_reg_bit_field_port_id,
5574 (void *)&cmd_write_reg_bit_field_reg_off,
5575 (void *)&cmd_write_reg_bit_field_bit1_pos,
5576 (void *)&cmd_write_reg_bit_field_bit2_pos,
5577 (void *)&cmd_write_reg_bit_field_value,
5582 /* *** WRITE PORT REGISTER BIT *** */
5583 struct cmd_write_reg_bit_result {
5584 cmdline_fixed_string_t write;
5585 cmdline_fixed_string_t regbit;
5593 cmd_write_reg_bit_parsed(void *parsed_result,
5594 __attribute__((unused)) struct cmdline *cl,
5595 __attribute__((unused)) void *data)
5597 struct cmd_write_reg_bit_result *res = parsed_result;
5598 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5601 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5602 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5604 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5605 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5607 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5608 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5609 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5610 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5611 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5612 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5613 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5614 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5616 cmdline_parse_inst_t cmd_write_reg_bit = {
5617 .f = cmd_write_reg_bit_parsed,
5619 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5621 (void *)&cmd_write_reg_bit_write,
5622 (void *)&cmd_write_reg_bit_regbit,
5623 (void *)&cmd_write_reg_bit_port_id,
5624 (void *)&cmd_write_reg_bit_reg_off,
5625 (void *)&cmd_write_reg_bit_bit_pos,
5626 (void *)&cmd_write_reg_bit_value,
5631 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5632 struct cmd_read_rxd_txd_result {
5633 cmdline_fixed_string_t read;
5634 cmdline_fixed_string_t rxd_txd;
5641 cmd_read_rxd_txd_parsed(void *parsed_result,
5642 __attribute__((unused)) struct cmdline *cl,
5643 __attribute__((unused)) void *data)
5645 struct cmd_read_rxd_txd_result *res = parsed_result;
5647 if (!strcmp(res->rxd_txd, "rxd"))
5648 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5649 else if (!strcmp(res->rxd_txd, "txd"))
5650 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5653 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5654 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5655 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5656 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5658 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5659 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5660 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5661 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5662 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5663 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5665 cmdline_parse_inst_t cmd_read_rxd_txd = {
5666 .f = cmd_read_rxd_txd_parsed,
5668 .help_str = "read rxd|txd port_id queue_id rxd_id",
5670 (void *)&cmd_read_rxd_txd_read,
5671 (void *)&cmd_read_rxd_txd_rxd_txd,
5672 (void *)&cmd_read_rxd_txd_port_id,
5673 (void *)&cmd_read_rxd_txd_queue_id,
5674 (void *)&cmd_read_rxd_txd_desc_id,
5680 struct cmd_quit_result {
5681 cmdline_fixed_string_t quit;
5684 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5686 __attribute__((unused)) void *data)
5692 cmdline_parse_token_string_t cmd_quit_quit =
5693 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5695 cmdline_parse_inst_t cmd_quit = {
5696 .f = cmd_quit_parsed,
5698 .help_str = "exit application",
5700 (void *)&cmd_quit_quit,
5705 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5706 struct cmd_mac_addr_result {
5707 cmdline_fixed_string_t mac_addr_cmd;
5708 cmdline_fixed_string_t what;
5710 struct ether_addr address;
5713 static void cmd_mac_addr_parsed(void *parsed_result,
5714 __attribute__((unused)) struct cmdline *cl,
5715 __attribute__((unused)) void *data)
5717 struct cmd_mac_addr_result *res = parsed_result;
5720 if (strcmp(res->what, "add") == 0)
5721 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5723 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5725 /* check the return value and print it if is < 0 */
5727 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5731 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5732 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5734 cmdline_parse_token_string_t cmd_mac_addr_what =
5735 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5737 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5738 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5739 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5740 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5742 cmdline_parse_inst_t cmd_mac_addr = {
5743 .f = cmd_mac_addr_parsed,
5745 .help_str = "mac_addr add|remove X <address>: "
5746 "add/remove MAC address on port X",
5748 (void *)&cmd_mac_addr_cmd,
5749 (void *)&cmd_mac_addr_what,
5750 (void *)&cmd_mac_addr_portnum,
5751 (void *)&cmd_mac_addr_addr,
5757 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5758 struct cmd_set_qmap_result {
5759 cmdline_fixed_string_t set;
5760 cmdline_fixed_string_t qmap;
5761 cmdline_fixed_string_t what;
5768 cmd_set_qmap_parsed(void *parsed_result,
5769 __attribute__((unused)) struct cmdline *cl,
5770 __attribute__((unused)) void *data)
5772 struct cmd_set_qmap_result *res = parsed_result;
5773 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5775 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5778 cmdline_parse_token_string_t cmd_setqmap_set =
5779 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5781 cmdline_parse_token_string_t cmd_setqmap_qmap =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5784 cmdline_parse_token_string_t cmd_setqmap_what =
5785 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5787 cmdline_parse_token_num_t cmd_setqmap_portid =
5788 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5790 cmdline_parse_token_num_t cmd_setqmap_queueid =
5791 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5793 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5794 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5797 cmdline_parse_inst_t cmd_set_qmap = {
5798 .f = cmd_set_qmap_parsed,
5800 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5802 (void *)&cmd_setqmap_set,
5803 (void *)&cmd_setqmap_qmap,
5804 (void *)&cmd_setqmap_what,
5805 (void *)&cmd_setqmap_portid,
5806 (void *)&cmd_setqmap_queueid,
5807 (void *)&cmd_setqmap_mapvalue,
5812 /* *** CONFIGURE UNICAST HASH TABLE *** */
5813 struct cmd_set_uc_hash_table {
5814 cmdline_fixed_string_t set;
5815 cmdline_fixed_string_t port;
5817 cmdline_fixed_string_t what;
5818 struct ether_addr address;
5819 cmdline_fixed_string_t mode;
5823 cmd_set_uc_hash_parsed(void *parsed_result,
5824 __attribute__((unused)) struct cmdline *cl,
5825 __attribute__((unused)) void *data)
5828 struct cmd_set_uc_hash_table *res = parsed_result;
5830 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5832 if (strcmp(res->what, "uta") == 0)
5833 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5834 &res->address,(uint8_t)is_on);
5836 printf("bad unicast hash table parameter, return code = %d \n", ret);
5840 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5843 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5846 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5847 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5849 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5852 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5853 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5855 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5856 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5859 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5860 .f = cmd_set_uc_hash_parsed,
5862 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5864 (void *)&cmd_set_uc_hash_set,
5865 (void *)&cmd_set_uc_hash_port,
5866 (void *)&cmd_set_uc_hash_portid,
5867 (void *)&cmd_set_uc_hash_what,
5868 (void *)&cmd_set_uc_hash_mac,
5869 (void *)&cmd_set_uc_hash_mode,
5874 struct cmd_set_uc_all_hash_table {
5875 cmdline_fixed_string_t set;
5876 cmdline_fixed_string_t port;
5878 cmdline_fixed_string_t what;
5879 cmdline_fixed_string_t value;
5880 cmdline_fixed_string_t mode;
5884 cmd_set_uc_all_hash_parsed(void *parsed_result,
5885 __attribute__((unused)) struct cmdline *cl,
5886 __attribute__((unused)) void *data)
5889 struct cmd_set_uc_all_hash_table *res = parsed_result;
5891 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5893 if ((strcmp(res->what, "uta") == 0) &&
5894 (strcmp(res->value, "all") == 0))
5895 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5897 printf("bad unicast hash table parameter,"
5898 "return code = %d \n", ret);
5901 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5902 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5904 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5905 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5907 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5908 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5910 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5911 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5913 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5914 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5916 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5917 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5920 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5921 .f = cmd_set_uc_all_hash_parsed,
5923 .help_str = "set port X uta all on|off (X = port number)",
5925 (void *)&cmd_set_uc_all_hash_set,
5926 (void *)&cmd_set_uc_all_hash_port,
5927 (void *)&cmd_set_uc_all_hash_portid,
5928 (void *)&cmd_set_uc_all_hash_what,
5929 (void *)&cmd_set_uc_all_hash_value,
5930 (void *)&cmd_set_uc_all_hash_mode,
5935 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5936 struct cmd_set_vf_macvlan_filter {
5937 cmdline_fixed_string_t set;
5938 cmdline_fixed_string_t port;
5940 cmdline_fixed_string_t vf;
5942 struct ether_addr address;
5943 cmdline_fixed_string_t filter_type;
5944 cmdline_fixed_string_t mode;
5948 cmd_set_vf_macvlan_parsed(void *parsed_result,
5949 __attribute__((unused)) struct cmdline *cl,
5950 __attribute__((unused)) void *data)
5953 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5954 struct rte_eth_mac_filter filter;
5956 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5958 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5960 /* set VF MAC filter */
5964 filter.dst_id = res->vf_id;
5966 if (!strcmp(res->filter_type, "exact-mac"))
5967 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5968 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5969 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5970 else if (!strcmp(res->filter_type, "hashmac"))
5971 filter.filter_type = RTE_MAC_HASH_MATCH;
5972 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5973 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5975 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5978 ret = rte_eth_dev_filter_ctrl(res->port_id,
5979 RTE_ETH_FILTER_MACVLAN,
5983 ret = rte_eth_dev_filter_ctrl(res->port_id,
5984 RTE_ETH_FILTER_MACVLAN,
5985 RTE_ETH_FILTER_DELETE,
5989 printf("bad set MAC hash parameter, return code = %d\n", ret);
5993 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5994 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5996 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5997 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5999 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6000 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6002 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6003 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6005 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6006 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6008 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6009 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6011 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6012 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6013 filter_type, "exact-mac#exact-mac-vlan"
6014 "#hashmac#hashmac-vlan");
6015 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6019 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6020 .f = cmd_set_vf_macvlan_parsed,
6022 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6023 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6025 "exact match rule:exact match of MAC or MAC and VLAN; "
6026 "hash match rule: hash match of MAC and exact match "
6029 (void *)&cmd_set_vf_macvlan_set,
6030 (void *)&cmd_set_vf_macvlan_port,
6031 (void *)&cmd_set_vf_macvlan_portid,
6032 (void *)&cmd_set_vf_macvlan_vf,
6033 (void *)&cmd_set_vf_macvlan_vf_id,
6034 (void *)&cmd_set_vf_macvlan_mac,
6035 (void *)&cmd_set_vf_macvlan_filter_type,
6036 (void *)&cmd_set_vf_macvlan_mode,
6041 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6042 struct cmd_set_vf_traffic {
6043 cmdline_fixed_string_t set;
6044 cmdline_fixed_string_t port;
6046 cmdline_fixed_string_t vf;
6048 cmdline_fixed_string_t what;
6049 cmdline_fixed_string_t mode;
6053 cmd_set_vf_traffic_parsed(void *parsed_result,
6054 __attribute__((unused)) struct cmdline *cl,
6055 __attribute__((unused)) void *data)
6057 struct cmd_set_vf_traffic *res = parsed_result;
6058 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6059 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6061 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6064 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6065 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6067 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6068 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6070 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6071 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6073 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6074 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6076 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6077 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6079 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6080 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6082 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6083 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6086 cmdline_parse_inst_t cmd_set_vf_traffic = {
6087 .f = cmd_set_vf_traffic_parsed,
6089 .help_str = "set port X vf Y rx|tx on|off"
6090 "(X = port number,Y = vf id)",
6092 (void *)&cmd_setvf_traffic_set,
6093 (void *)&cmd_setvf_traffic_port,
6094 (void *)&cmd_setvf_traffic_portid,
6095 (void *)&cmd_setvf_traffic_vf,
6096 (void *)&cmd_setvf_traffic_vfid,
6097 (void *)&cmd_setvf_traffic_what,
6098 (void *)&cmd_setvf_traffic_mode,
6103 /* *** CONFIGURE VF RECEIVE MODE *** */
6104 struct cmd_set_vf_rxmode {
6105 cmdline_fixed_string_t set;
6106 cmdline_fixed_string_t port;
6108 cmdline_fixed_string_t vf;
6110 cmdline_fixed_string_t what;
6111 cmdline_fixed_string_t mode;
6112 cmdline_fixed_string_t on;
6116 cmd_set_vf_rxmode_parsed(void *parsed_result,
6117 __attribute__((unused)) struct cmdline *cl,
6118 __attribute__((unused)) void *data)
6121 uint16_t rx_mode = 0;
6122 struct cmd_set_vf_rxmode *res = parsed_result;
6124 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6125 if (!strcmp(res->what,"rxmode")) {
6126 if (!strcmp(res->mode, "AUPE"))
6127 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6128 else if (!strcmp(res->mode, "ROPE"))
6129 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6130 else if (!strcmp(res->mode, "BAM"))
6131 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6132 else if (!strncmp(res->mode, "MPE",3))
6133 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6136 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6138 printf("bad VF receive mode parameter, return code = %d \n",
6142 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6143 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6145 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6146 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6148 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6149 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6151 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6152 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6154 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6155 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6157 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6158 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6160 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6161 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6162 mode, "AUPE#ROPE#BAM#MPE");
6163 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6164 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6167 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6168 .f = cmd_set_vf_rxmode_parsed,
6170 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6172 (void *)&cmd_set_vf_rxmode_set,
6173 (void *)&cmd_set_vf_rxmode_port,
6174 (void *)&cmd_set_vf_rxmode_portid,
6175 (void *)&cmd_set_vf_rxmode_vf,
6176 (void *)&cmd_set_vf_rxmode_vfid,
6177 (void *)&cmd_set_vf_rxmode_what,
6178 (void *)&cmd_set_vf_rxmode_mode,
6179 (void *)&cmd_set_vf_rxmode_on,
6184 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6185 struct cmd_vf_mac_addr_result {
6186 cmdline_fixed_string_t mac_addr_cmd;
6187 cmdline_fixed_string_t what;
6188 cmdline_fixed_string_t port;
6190 cmdline_fixed_string_t vf;
6192 struct ether_addr address;
6195 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6196 __attribute__((unused)) struct cmdline *cl,
6197 __attribute__((unused)) void *data)
6199 struct cmd_vf_mac_addr_result *res = parsed_result;
6202 if (strcmp(res->what, "add") == 0)
6203 ret = rte_eth_dev_mac_addr_add(res->port_num,
6204 &res->address, res->vf_num);
6206 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6210 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6211 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6212 mac_addr_cmd,"mac_addr");
6213 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6214 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6216 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6217 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6219 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6220 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6222 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6223 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6225 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6226 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6228 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6229 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6232 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6233 .f = cmd_vf_mac_addr_parsed,
6235 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6236 "Y = VF number)add MAC address filtering for a VF on port X",
6238 (void *)&cmd_vf_mac_addr_cmd,
6239 (void *)&cmd_vf_mac_addr_what,
6240 (void *)&cmd_vf_mac_addr_port,
6241 (void *)&cmd_vf_mac_addr_portnum,
6242 (void *)&cmd_vf_mac_addr_vf,
6243 (void *)&cmd_vf_mac_addr_vfnum,
6244 (void *)&cmd_vf_mac_addr_addr,
6249 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6250 struct cmd_vf_rx_vlan_filter {
6251 cmdline_fixed_string_t rx_vlan;
6252 cmdline_fixed_string_t what;
6254 cmdline_fixed_string_t port;
6256 cmdline_fixed_string_t vf;
6261 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6262 __attribute__((unused)) struct cmdline *cl,
6263 __attribute__((unused)) void *data)
6265 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6267 if (!strcmp(res->what, "add"))
6268 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6270 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6273 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6274 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6275 rx_vlan, "rx_vlan");
6276 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6277 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6279 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6280 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6282 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6283 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6285 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6286 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6288 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6289 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6291 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6292 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6295 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6296 .f = cmd_vf_rx_vlan_filter_parsed,
6298 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6299 "Y = port number,Z = hexadecimal VF mask)",
6301 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6302 (void *)&cmd_vf_rx_vlan_filter_what,
6303 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6304 (void *)&cmd_vf_rx_vlan_filter_port,
6305 (void *)&cmd_vf_rx_vlan_filter_portid,
6306 (void *)&cmd_vf_rx_vlan_filter_vf,
6307 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6312 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6313 struct cmd_queue_rate_limit_result {
6314 cmdline_fixed_string_t set;
6315 cmdline_fixed_string_t port;
6317 cmdline_fixed_string_t queue;
6319 cmdline_fixed_string_t rate;
6323 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6324 __attribute__((unused)) struct cmdline *cl,
6325 __attribute__((unused)) void *data)
6327 struct cmd_queue_rate_limit_result *res = parsed_result;
6330 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6331 && (strcmp(res->queue, "queue") == 0)
6332 && (strcmp(res->rate, "rate") == 0))
6333 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6336 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6340 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6341 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6343 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6344 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6346 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6347 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6349 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6350 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6352 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6353 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6355 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6356 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6358 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6359 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6362 cmdline_parse_inst_t cmd_queue_rate_limit = {
6363 .f = cmd_queue_rate_limit_parsed,
6365 .help_str = "set port X queue Y rate Z:(X = port number,"
6366 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6368 (void *)&cmd_queue_rate_limit_set,
6369 (void *)&cmd_queue_rate_limit_port,
6370 (void *)&cmd_queue_rate_limit_portnum,
6371 (void *)&cmd_queue_rate_limit_queue,
6372 (void *)&cmd_queue_rate_limit_queuenum,
6373 (void *)&cmd_queue_rate_limit_rate,
6374 (void *)&cmd_queue_rate_limit_ratenum,
6379 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6380 struct cmd_vf_rate_limit_result {
6381 cmdline_fixed_string_t set;
6382 cmdline_fixed_string_t port;
6384 cmdline_fixed_string_t vf;
6386 cmdline_fixed_string_t rate;
6388 cmdline_fixed_string_t q_msk;
6392 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6393 __attribute__((unused)) struct cmdline *cl,
6394 __attribute__((unused)) void *data)
6396 struct cmd_vf_rate_limit_result *res = parsed_result;
6399 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6400 && (strcmp(res->vf, "vf") == 0)
6401 && (strcmp(res->rate, "rate") == 0)
6402 && (strcmp(res->q_msk, "queue_mask") == 0))
6403 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6404 res->rate_num, res->q_msk_val);
6406 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6410 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6411 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6413 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6414 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6416 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6417 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6419 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6420 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6422 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6423 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6425 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6426 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6428 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6429 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6431 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6432 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6433 q_msk, "queue_mask");
6434 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6435 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6438 cmdline_parse_inst_t cmd_vf_rate_limit = {
6439 .f = cmd_vf_rate_limit_parsed,
6441 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6442 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6443 "for queues of VF on port X",
6445 (void *)&cmd_vf_rate_limit_set,
6446 (void *)&cmd_vf_rate_limit_port,
6447 (void *)&cmd_vf_rate_limit_portnum,
6448 (void *)&cmd_vf_rate_limit_vf,
6449 (void *)&cmd_vf_rate_limit_vfnum,
6450 (void *)&cmd_vf_rate_limit_rate,
6451 (void *)&cmd_vf_rate_limit_ratenum,
6452 (void *)&cmd_vf_rate_limit_q_msk,
6453 (void *)&cmd_vf_rate_limit_q_msk_val,
6458 /* *** ADD TUNNEL FILTER OF A PORT *** */
6459 struct cmd_tunnel_filter_result {
6460 cmdline_fixed_string_t cmd;
6461 cmdline_fixed_string_t what;
6463 struct ether_addr outer_mac;
6464 struct ether_addr inner_mac;
6465 cmdline_ipaddr_t ip_value;
6466 uint16_t inner_vlan;
6467 cmdline_fixed_string_t tunnel_type;
6468 cmdline_fixed_string_t filter_type;
6474 cmd_tunnel_filter_parsed(void *parsed_result,
6475 __attribute__((unused)) struct cmdline *cl,
6476 __attribute__((unused)) void *data)
6478 struct cmd_tunnel_filter_result *res = parsed_result;
6479 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6482 tunnel_filter_conf.outer_mac = &res->outer_mac;
6483 tunnel_filter_conf.inner_mac = &res->inner_mac;
6484 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6486 if (res->ip_value.family == AF_INET) {
6487 tunnel_filter_conf.ip_addr.ipv4_addr =
6488 res->ip_value.addr.ipv4.s_addr;
6489 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6491 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6492 &(res->ip_value.addr.ipv6),
6493 sizeof(struct in6_addr));
6494 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6497 if (!strcmp(res->filter_type, "imac-ivlan"))
6498 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6499 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6500 tunnel_filter_conf.filter_type =
6501 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6502 else if (!strcmp(res->filter_type, "imac-tenid"))
6503 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6504 else if (!strcmp(res->filter_type, "imac"))
6505 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6506 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6507 tunnel_filter_conf.filter_type =
6508 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6510 printf("The filter type is not supported");
6514 if (!strcmp(res->tunnel_type, "vxlan"))
6515 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6516 else if (!strcmp(res->tunnel_type, "nvgre"))
6517 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6519 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6523 tunnel_filter_conf.tenant_id = res->tenant_id;
6524 tunnel_filter_conf.queue_id = res->queue_num;
6525 if (!strcmp(res->what, "add"))
6526 ret = rte_eth_dev_filter_ctrl(res->port_id,
6527 RTE_ETH_FILTER_TUNNEL,
6529 &tunnel_filter_conf);
6531 ret = rte_eth_dev_filter_ctrl(res->port_id,
6532 RTE_ETH_FILTER_TUNNEL,
6533 RTE_ETH_FILTER_DELETE,
6534 &tunnel_filter_conf);
6536 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6540 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6541 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6542 cmd, "tunnel_filter");
6543 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6544 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6546 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6547 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6549 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6550 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6552 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6553 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6555 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6556 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6557 inner_vlan, UINT16);
6558 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6559 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6561 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6562 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6563 tunnel_type, "vxlan#nvgre");
6565 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6566 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6567 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6568 "imac#omac-imac-tenid");
6569 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6570 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6572 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6573 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6576 cmdline_parse_inst_t cmd_tunnel_filter = {
6577 .f = cmd_tunnel_filter_parsed,
6579 .help_str = "add/rm tunnel filter of a port: "
6580 "tunnel_filter add port_id outer_mac inner_mac ip "
6581 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6582 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6583 "imac|omac-imac-tenid) "
6584 "tenant_id queue_num",
6586 (void *)&cmd_tunnel_filter_cmd,
6587 (void *)&cmd_tunnel_filter_what,
6588 (void *)&cmd_tunnel_filter_port_id,
6589 (void *)&cmd_tunnel_filter_outer_mac,
6590 (void *)&cmd_tunnel_filter_inner_mac,
6591 (void *)&cmd_tunnel_filter_ip_value,
6592 (void *)&cmd_tunnel_filter_innner_vlan,
6593 (void *)&cmd_tunnel_filter_tunnel_type,
6594 (void *)&cmd_tunnel_filter_filter_type,
6595 (void *)&cmd_tunnel_filter_tenant_id,
6596 (void *)&cmd_tunnel_filter_queue_num,
6601 /* *** CONFIGURE TUNNEL UDP PORT *** */
6602 struct cmd_tunnel_udp_config {
6603 cmdline_fixed_string_t cmd;
6604 cmdline_fixed_string_t what;
6610 cmd_tunnel_udp_config_parsed(void *parsed_result,
6611 __attribute__((unused)) struct cmdline *cl,
6612 __attribute__((unused)) void *data)
6614 struct cmd_tunnel_udp_config *res = parsed_result;
6615 struct rte_eth_udp_tunnel tunnel_udp;
6618 tunnel_udp.udp_port = res->udp_port;
6620 if (!strcmp(res->cmd, "rx_vxlan_port"))
6621 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6623 if (!strcmp(res->what, "add"))
6624 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6626 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6629 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6632 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6633 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6634 cmd, "rx_vxlan_port");
6635 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6636 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6638 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6639 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6641 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6642 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6645 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6646 .f = cmd_tunnel_udp_config_parsed,
6648 .help_str = "add/rm an tunneling UDP port filter: "
6649 "rx_vxlan_port add udp_port port_id",
6651 (void *)&cmd_tunnel_udp_config_cmd,
6652 (void *)&cmd_tunnel_udp_config_what,
6653 (void *)&cmd_tunnel_udp_config_udp_port,
6654 (void *)&cmd_tunnel_udp_config_port_id,
6659 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6660 struct cmd_set_mirror_mask_result {
6661 cmdline_fixed_string_t set;
6662 cmdline_fixed_string_t port;
6664 cmdline_fixed_string_t mirror;
6666 cmdline_fixed_string_t what;
6667 cmdline_fixed_string_t value;
6668 cmdline_fixed_string_t dstpool;
6670 cmdline_fixed_string_t on;
6673 cmdline_parse_token_string_t cmd_mirror_mask_set =
6674 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6676 cmdline_parse_token_string_t cmd_mirror_mask_port =
6677 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6679 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6680 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6682 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6683 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6684 mirror, "mirror-rule");
6685 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6686 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6688 cmdline_parse_token_string_t cmd_mirror_mask_what =
6689 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6690 what, "pool-mirror-up#pool-mirror-down"
6692 cmdline_parse_token_string_t cmd_mirror_mask_value =
6693 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6695 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6696 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6697 dstpool, "dst-pool");
6698 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6699 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6701 cmdline_parse_token_string_t cmd_mirror_mask_on =
6702 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6706 cmd_set_mirror_mask_parsed(void *parsed_result,
6707 __attribute__((unused)) struct cmdline *cl,
6708 __attribute__((unused)) void *data)
6711 struct cmd_set_mirror_mask_result *res = parsed_result;
6712 struct rte_eth_mirror_conf mr_conf;
6714 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6716 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6718 mr_conf.dst_pool = res->dstpool_id;
6720 if (!strcmp(res->what, "pool-mirror-up")) {
6721 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6722 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6723 } else if (!strcmp(res->what, "pool-mirror-down")) {
6724 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6725 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6726 } else if (!strcmp(res->what, "vlan-mirror")) {
6727 mr_conf.rule_type = ETH_MIRROR_VLAN;
6728 nb_item = parse_item_list(res->value, "vlan",
6729 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6733 for (i = 0; i < nb_item; i++) {
6734 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6735 printf("Invalid vlan_id: must be < 4096\n");
6739 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6740 mr_conf.vlan.vlan_mask |= 1ULL << i;
6744 if (!strcmp(res->on, "on"))
6745 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6748 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6751 printf("mirror rule add error: (%s)\n", strerror(-ret));
6754 cmdline_parse_inst_t cmd_set_mirror_mask = {
6755 .f = cmd_set_mirror_mask_parsed,
6757 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
6758 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6760 (void *)&cmd_mirror_mask_set,
6761 (void *)&cmd_mirror_mask_port,
6762 (void *)&cmd_mirror_mask_portid,
6763 (void *)&cmd_mirror_mask_mirror,
6764 (void *)&cmd_mirror_mask_ruleid,
6765 (void *)&cmd_mirror_mask_what,
6766 (void *)&cmd_mirror_mask_value,
6767 (void *)&cmd_mirror_mask_dstpool,
6768 (void *)&cmd_mirror_mask_poolid,
6769 (void *)&cmd_mirror_mask_on,
6774 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6775 struct cmd_set_mirror_link_result {
6776 cmdline_fixed_string_t set;
6777 cmdline_fixed_string_t port;
6779 cmdline_fixed_string_t mirror;
6781 cmdline_fixed_string_t what;
6782 cmdline_fixed_string_t dstpool;
6784 cmdline_fixed_string_t on;
6787 cmdline_parse_token_string_t cmd_mirror_link_set =
6788 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6790 cmdline_parse_token_string_t cmd_mirror_link_port =
6791 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6793 cmdline_parse_token_num_t cmd_mirror_link_portid =
6794 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6796 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6797 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6798 mirror, "mirror-rule");
6799 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6800 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6802 cmdline_parse_token_string_t cmd_mirror_link_what =
6803 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6804 what, "uplink-mirror#downlink-mirror");
6805 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6806 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6807 dstpool, "dst-pool");
6808 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6809 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6811 cmdline_parse_token_string_t cmd_mirror_link_on =
6812 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6816 cmd_set_mirror_link_parsed(void *parsed_result,
6817 __attribute__((unused)) struct cmdline *cl,
6818 __attribute__((unused)) void *data)
6821 struct cmd_set_mirror_link_result *res = parsed_result;
6822 struct rte_eth_mirror_conf mr_conf;
6824 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6825 if (!strcmp(res->what, "uplink-mirror"))
6826 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
6828 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
6830 mr_conf.dst_pool = res->dstpool_id;
6832 if (!strcmp(res->on, "on"))
6833 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6836 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6839 /* check the return value and print it if is < 0 */
6841 printf("mirror rule add error: (%s)\n", strerror(-ret));
6845 cmdline_parse_inst_t cmd_set_mirror_link = {
6846 .f = cmd_set_mirror_link_parsed,
6848 .help_str = "set port X mirror-rule Y uplink-mirror|"
6849 "downlink-mirror dst-pool Z on|off",
6851 (void *)&cmd_mirror_link_set,
6852 (void *)&cmd_mirror_link_port,
6853 (void *)&cmd_mirror_link_portid,
6854 (void *)&cmd_mirror_link_mirror,
6855 (void *)&cmd_mirror_link_ruleid,
6856 (void *)&cmd_mirror_link_what,
6857 (void *)&cmd_mirror_link_dstpool,
6858 (void *)&cmd_mirror_link_poolid,
6859 (void *)&cmd_mirror_link_on,
6864 /* *** RESET VM MIRROR RULE *** */
6865 struct cmd_rm_mirror_rule_result {
6866 cmdline_fixed_string_t reset;
6867 cmdline_fixed_string_t port;
6869 cmdline_fixed_string_t mirror;
6873 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6874 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6876 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6877 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6879 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6880 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6882 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6883 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6884 mirror, "mirror-rule");
6885 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6886 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6890 cmd_reset_mirror_rule_parsed(void *parsed_result,
6891 __attribute__((unused)) struct cmdline *cl,
6892 __attribute__((unused)) void *data)
6895 struct cmd_set_mirror_link_result *res = parsed_result;
6897 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6899 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6902 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6903 .f = cmd_reset_mirror_rule_parsed,
6905 .help_str = "reset port X mirror-rule Y",
6907 (void *)&cmd_rm_mirror_rule_reset,
6908 (void *)&cmd_rm_mirror_rule_port,
6909 (void *)&cmd_rm_mirror_rule_portid,
6910 (void *)&cmd_rm_mirror_rule_mirror,
6911 (void *)&cmd_rm_mirror_rule_ruleid,
6916 /* ******************************************************************************** */
6918 struct cmd_dump_result {
6919 cmdline_fixed_string_t dump;
6923 dump_struct_sizes(void)
6925 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6926 DUMP_SIZE(struct rte_mbuf);
6927 DUMP_SIZE(struct rte_mempool);
6928 DUMP_SIZE(struct rte_ring);
6932 static void cmd_dump_parsed(void *parsed_result,
6933 __attribute__((unused)) struct cmdline *cl,
6934 __attribute__((unused)) void *data)
6936 struct cmd_dump_result *res = parsed_result;
6938 if (!strcmp(res->dump, "dump_physmem"))
6939 rte_dump_physmem_layout(stdout);
6940 else if (!strcmp(res->dump, "dump_memzone"))
6941 rte_memzone_dump(stdout);
6942 else if (!strcmp(res->dump, "dump_log_history"))
6943 rte_log_dump_history(stdout);
6944 else if (!strcmp(res->dump, "dump_struct_sizes"))
6945 dump_struct_sizes();
6946 else if (!strcmp(res->dump, "dump_ring"))
6947 rte_ring_list_dump(stdout);
6948 else if (!strcmp(res->dump, "dump_mempool"))
6949 rte_mempool_list_dump(stdout);
6950 else if (!strcmp(res->dump, "dump_devargs"))
6951 rte_eal_devargs_dump(stdout);
6954 cmdline_parse_token_string_t cmd_dump_dump =
6955 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6959 "dump_struct_sizes#"
6964 cmdline_parse_inst_t cmd_dump = {
6965 .f = cmd_dump_parsed, /* function to call */
6966 .data = NULL, /* 2nd arg of func */
6967 .help_str = "dump status",
6968 .tokens = { /* token list, NULL terminated */
6969 (void *)&cmd_dump_dump,
6974 /* ******************************************************************************** */
6976 struct cmd_dump_one_result {
6977 cmdline_fixed_string_t dump;
6978 cmdline_fixed_string_t name;
6981 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6982 __attribute__((unused)) void *data)
6984 struct cmd_dump_one_result *res = parsed_result;
6986 if (!strcmp(res->dump, "dump_ring")) {
6988 r = rte_ring_lookup(res->name);
6990 cmdline_printf(cl, "Cannot find ring\n");
6993 rte_ring_dump(stdout, r);
6994 } else if (!strcmp(res->dump, "dump_mempool")) {
6995 struct rte_mempool *mp;
6996 mp = rte_mempool_lookup(res->name);
6998 cmdline_printf(cl, "Cannot find mempool\n");
7001 rte_mempool_dump(stdout, mp);
7005 cmdline_parse_token_string_t cmd_dump_one_dump =
7006 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7007 "dump_ring#dump_mempool");
7009 cmdline_parse_token_string_t cmd_dump_one_name =
7010 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7012 cmdline_parse_inst_t cmd_dump_one = {
7013 .f = cmd_dump_one_parsed, /* function to call */
7014 .data = NULL, /* 2nd arg of func */
7015 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7016 .tokens = { /* token list, NULL terminated */
7017 (void *)&cmd_dump_one_dump,
7018 (void *)&cmd_dump_one_name,
7023 /* *** Add/Del syn filter *** */
7024 struct cmd_syn_filter_result {
7025 cmdline_fixed_string_t filter;
7027 cmdline_fixed_string_t ops;
7028 cmdline_fixed_string_t priority;
7029 cmdline_fixed_string_t high;
7030 cmdline_fixed_string_t queue;
7035 cmd_syn_filter_parsed(void *parsed_result,
7036 __attribute__((unused)) struct cmdline *cl,
7037 __attribute__((unused)) void *data)
7039 struct cmd_syn_filter_result *res = parsed_result;
7040 struct rte_eth_syn_filter syn_filter;
7043 ret = rte_eth_dev_filter_supported(res->port_id,
7044 RTE_ETH_FILTER_SYN);
7046 printf("syn filter is not supported on port %u.\n",
7051 memset(&syn_filter, 0, sizeof(syn_filter));
7053 if (!strcmp(res->ops, "add")) {
7054 if (!strcmp(res->high, "high"))
7055 syn_filter.hig_pri = 1;
7057 syn_filter.hig_pri = 0;
7059 syn_filter.queue = res->queue_id;
7060 ret = rte_eth_dev_filter_ctrl(res->port_id,
7065 ret = rte_eth_dev_filter_ctrl(res->port_id,
7067 RTE_ETH_FILTER_DELETE,
7071 printf("syn filter programming error: (%s)\n",
7075 cmdline_parse_token_string_t cmd_syn_filter_filter =
7076 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7077 filter, "syn_filter");
7078 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7079 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7081 cmdline_parse_token_string_t cmd_syn_filter_ops =
7082 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7084 cmdline_parse_token_string_t cmd_syn_filter_priority =
7085 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7086 priority, "priority");
7087 cmdline_parse_token_string_t cmd_syn_filter_high =
7088 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7090 cmdline_parse_token_string_t cmd_syn_filter_queue =
7091 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7093 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7094 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7097 cmdline_parse_inst_t cmd_syn_filter = {
7098 .f = cmd_syn_filter_parsed,
7100 .help_str = "add/delete syn filter",
7102 (void *)&cmd_syn_filter_filter,
7103 (void *)&cmd_syn_filter_port_id,
7104 (void *)&cmd_syn_filter_ops,
7105 (void *)&cmd_syn_filter_priority,
7106 (void *)&cmd_syn_filter_high,
7107 (void *)&cmd_syn_filter_queue,
7108 (void *)&cmd_syn_filter_queue_id,
7113 /* *** ADD/REMOVE A 2tuple FILTER *** */
7114 struct cmd_2tuple_filter_result {
7115 cmdline_fixed_string_t filter;
7117 cmdline_fixed_string_t ops;
7118 cmdline_fixed_string_t dst_port;
7119 uint16_t dst_port_value;
7120 cmdline_fixed_string_t protocol;
7121 uint8_t protocol_value;
7122 cmdline_fixed_string_t mask;
7124 cmdline_fixed_string_t tcp_flags;
7125 uint8_t tcp_flags_value;
7126 cmdline_fixed_string_t priority;
7127 uint8_t priority_value;
7128 cmdline_fixed_string_t queue;
7133 cmd_2tuple_filter_parsed(void *parsed_result,
7134 __attribute__((unused)) struct cmdline *cl,
7135 __attribute__((unused)) void *data)
7137 struct rte_eth_ntuple_filter filter;
7138 struct cmd_2tuple_filter_result *res = parsed_result;
7141 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7143 printf("ntuple filter is not supported on port %u.\n",
7148 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7150 filter.flags = RTE_2TUPLE_FLAGS;
7151 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7152 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7153 filter.proto = res->protocol_value;
7154 filter.priority = res->priority_value;
7155 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7156 printf("nonzero tcp_flags is only meaningful"
7157 " when protocol is TCP.\n");
7160 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7161 printf("invalid TCP flags.\n");
7165 if (res->tcp_flags_value != 0) {
7166 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7167 filter.tcp_flags = res->tcp_flags_value;
7170 /* need convert to big endian. */
7171 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7172 filter.queue = res->queue_id;
7174 if (!strcmp(res->ops, "add"))
7175 ret = rte_eth_dev_filter_ctrl(res->port_id,
7176 RTE_ETH_FILTER_NTUPLE,
7180 ret = rte_eth_dev_filter_ctrl(res->port_id,
7181 RTE_ETH_FILTER_NTUPLE,
7182 RTE_ETH_FILTER_DELETE,
7185 printf("2tuple filter programming error: (%s)\n",
7190 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7191 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7192 filter, "2tuple_filter");
7193 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7194 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7196 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7197 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7199 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7200 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7201 dst_port, "dst_port");
7202 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7203 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7204 dst_port_value, UINT16);
7205 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7206 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7207 protocol, "protocol");
7208 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7209 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7210 protocol_value, UINT8);
7211 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7212 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7214 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7215 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7217 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7218 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7219 tcp_flags, "tcp_flags");
7220 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7221 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7222 tcp_flags_value, UINT8);
7223 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7224 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7225 priority, "priority");
7226 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7227 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7228 priority_value, UINT8);
7229 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7230 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7232 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7233 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7236 cmdline_parse_inst_t cmd_2tuple_filter = {
7237 .f = cmd_2tuple_filter_parsed,
7239 .help_str = "add a 2tuple filter",
7241 (void *)&cmd_2tuple_filter_filter,
7242 (void *)&cmd_2tuple_filter_port_id,
7243 (void *)&cmd_2tuple_filter_ops,
7244 (void *)&cmd_2tuple_filter_dst_port,
7245 (void *)&cmd_2tuple_filter_dst_port_value,
7246 (void *)&cmd_2tuple_filter_protocol,
7247 (void *)&cmd_2tuple_filter_protocol_value,
7248 (void *)&cmd_2tuple_filter_mask,
7249 (void *)&cmd_2tuple_filter_mask_value,
7250 (void *)&cmd_2tuple_filter_tcp_flags,
7251 (void *)&cmd_2tuple_filter_tcp_flags_value,
7252 (void *)&cmd_2tuple_filter_priority,
7253 (void *)&cmd_2tuple_filter_priority_value,
7254 (void *)&cmd_2tuple_filter_queue,
7255 (void *)&cmd_2tuple_filter_queue_id,
7260 /* *** ADD/REMOVE A 5tuple FILTER *** */
7261 struct cmd_5tuple_filter_result {
7262 cmdline_fixed_string_t filter;
7264 cmdline_fixed_string_t ops;
7265 cmdline_fixed_string_t dst_ip;
7266 cmdline_ipaddr_t dst_ip_value;
7267 cmdline_fixed_string_t src_ip;
7268 cmdline_ipaddr_t src_ip_value;
7269 cmdline_fixed_string_t dst_port;
7270 uint16_t dst_port_value;
7271 cmdline_fixed_string_t src_port;
7272 uint16_t src_port_value;
7273 cmdline_fixed_string_t protocol;
7274 uint8_t protocol_value;
7275 cmdline_fixed_string_t mask;
7277 cmdline_fixed_string_t tcp_flags;
7278 uint8_t tcp_flags_value;
7279 cmdline_fixed_string_t priority;
7280 uint8_t priority_value;
7281 cmdline_fixed_string_t queue;
7286 cmd_5tuple_filter_parsed(void *parsed_result,
7287 __attribute__((unused)) struct cmdline *cl,
7288 __attribute__((unused)) void *data)
7290 struct rte_eth_ntuple_filter filter;
7291 struct cmd_5tuple_filter_result *res = parsed_result;
7294 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7296 printf("ntuple filter is not supported on port %u.\n",
7301 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7303 filter.flags = RTE_5TUPLE_FLAGS;
7304 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7305 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7306 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7307 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7308 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7309 filter.proto = res->protocol_value;
7310 filter.priority = res->priority_value;
7311 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7312 printf("nonzero tcp_flags is only meaningful"
7313 " when protocol is TCP.\n");
7316 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7317 printf("invalid TCP flags.\n");
7321 if (res->tcp_flags_value != 0) {
7322 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7323 filter.tcp_flags = res->tcp_flags_value;
7326 if (res->dst_ip_value.family == AF_INET)
7327 /* no need to convert, already big endian. */
7328 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7330 if (filter.dst_ip_mask == 0) {
7331 printf("can not support ipv6 involved compare.\n");
7337 if (res->src_ip_value.family == AF_INET)
7338 /* no need to convert, already big endian. */
7339 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7341 if (filter.src_ip_mask == 0) {
7342 printf("can not support ipv6 involved compare.\n");
7347 /* need convert to big endian. */
7348 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7349 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7350 filter.queue = res->queue_id;
7352 if (!strcmp(res->ops, "add"))
7353 ret = rte_eth_dev_filter_ctrl(res->port_id,
7354 RTE_ETH_FILTER_NTUPLE,
7358 ret = rte_eth_dev_filter_ctrl(res->port_id,
7359 RTE_ETH_FILTER_NTUPLE,
7360 RTE_ETH_FILTER_DELETE,
7363 printf("5tuple filter programming error: (%s)\n",
7367 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7368 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7369 filter, "5tuple_filter");
7370 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7371 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7373 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7374 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7376 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7377 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7379 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7380 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7382 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7383 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7385 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7386 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7388 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7389 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7390 dst_port, "dst_port");
7391 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7392 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7393 dst_port_value, UINT16);
7394 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7395 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7396 src_port, "src_port");
7397 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7398 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7399 src_port_value, UINT16);
7400 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7401 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7402 protocol, "protocol");
7403 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7404 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7405 protocol_value, UINT8);
7406 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7407 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7409 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7410 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7412 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7413 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7414 tcp_flags, "tcp_flags");
7415 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7416 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7417 tcp_flags_value, UINT8);
7418 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7419 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7420 priority, "priority");
7421 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7422 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7423 priority_value, UINT8);
7424 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7425 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7427 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7428 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7431 cmdline_parse_inst_t cmd_5tuple_filter = {
7432 .f = cmd_5tuple_filter_parsed,
7434 .help_str = "add/del a 5tuple filter",
7436 (void *)&cmd_5tuple_filter_filter,
7437 (void *)&cmd_5tuple_filter_port_id,
7438 (void *)&cmd_5tuple_filter_ops,
7439 (void *)&cmd_5tuple_filter_dst_ip,
7440 (void *)&cmd_5tuple_filter_dst_ip_value,
7441 (void *)&cmd_5tuple_filter_src_ip,
7442 (void *)&cmd_5tuple_filter_src_ip_value,
7443 (void *)&cmd_5tuple_filter_dst_port,
7444 (void *)&cmd_5tuple_filter_dst_port_value,
7445 (void *)&cmd_5tuple_filter_src_port,
7446 (void *)&cmd_5tuple_filter_src_port_value,
7447 (void *)&cmd_5tuple_filter_protocol,
7448 (void *)&cmd_5tuple_filter_protocol_value,
7449 (void *)&cmd_5tuple_filter_mask,
7450 (void *)&cmd_5tuple_filter_mask_value,
7451 (void *)&cmd_5tuple_filter_tcp_flags,
7452 (void *)&cmd_5tuple_filter_tcp_flags_value,
7453 (void *)&cmd_5tuple_filter_priority,
7454 (void *)&cmd_5tuple_filter_priority_value,
7455 (void *)&cmd_5tuple_filter_queue,
7456 (void *)&cmd_5tuple_filter_queue_id,
7461 /* *** ADD/REMOVE A flex FILTER *** */
7462 struct cmd_flex_filter_result {
7463 cmdline_fixed_string_t filter;
7464 cmdline_fixed_string_t ops;
7466 cmdline_fixed_string_t len;
7468 cmdline_fixed_string_t bytes;
7469 cmdline_fixed_string_t bytes_value;
7470 cmdline_fixed_string_t mask;
7471 cmdline_fixed_string_t mask_value;
7472 cmdline_fixed_string_t priority;
7473 uint8_t priority_value;
7474 cmdline_fixed_string_t queue;
7478 static int xdigit2val(unsigned char c)
7483 else if (isupper(c))
7491 cmd_flex_filter_parsed(void *parsed_result,
7492 __attribute__((unused)) struct cmdline *cl,
7493 __attribute__((unused)) void *data)
7496 struct rte_eth_flex_filter filter;
7497 struct cmd_flex_filter_result *res = parsed_result;
7498 char *bytes_ptr, *mask_ptr;
7499 uint16_t len, i, j = 0;
7504 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7505 printf("the len exceed the max length 128\n");
7508 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7509 filter.len = res->len_value;
7510 filter.priority = res->priority_value;
7511 filter.queue = res->queue_id;
7512 bytes_ptr = res->bytes_value;
7513 mask_ptr = res->mask_value;
7515 /* translate bytes string to array. */
7516 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7517 (bytes_ptr[1] == 'X')))
7519 len = strnlen(bytes_ptr, res->len_value * 2);
7520 if (len == 0 || (len % 8 != 0)) {
7521 printf("please check len and bytes input\n");
7524 for (i = 0; i < len; i++) {
7526 if (isxdigit(c) == 0) {
7527 /* invalid characters. */
7528 printf("invalid input\n");
7531 val = xdigit2val(c);
7534 filter.bytes[j] = byte;
7535 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7542 /* translate mask string to uint8_t array. */
7543 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7544 (mask_ptr[1] == 'X')))
7546 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7548 printf("invalid input\n");
7553 for (i = 0; i < len; i++) {
7555 if (isxdigit(c) == 0) {
7556 /* invalid characters. */
7557 printf("invalid input\n");
7560 val = xdigit2val(c);
7563 filter.mask[j] = byte;
7564 printf("mask[%d]:%02x ", j, filter.mask[j]);
7572 if (!strcmp(res->ops, "add"))
7573 ret = rte_eth_dev_filter_ctrl(res->port_id,
7574 RTE_ETH_FILTER_FLEXIBLE,
7578 ret = rte_eth_dev_filter_ctrl(res->port_id,
7579 RTE_ETH_FILTER_FLEXIBLE,
7580 RTE_ETH_FILTER_DELETE,
7584 printf("flex filter setting error: (%s)\n", strerror(-ret));
7587 cmdline_parse_token_string_t cmd_flex_filter_filter =
7588 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7589 filter, "flex_filter");
7590 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7591 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7593 cmdline_parse_token_string_t cmd_flex_filter_ops =
7594 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7596 cmdline_parse_token_string_t cmd_flex_filter_len =
7597 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7599 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7600 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7602 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7603 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7605 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7606 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7608 cmdline_parse_token_string_t cmd_flex_filter_mask =
7609 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7611 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7612 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7614 cmdline_parse_token_string_t cmd_flex_filter_priority =
7615 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7616 priority, "priority");
7617 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7618 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7619 priority_value, UINT8);
7620 cmdline_parse_token_string_t cmd_flex_filter_queue =
7621 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7623 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7624 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7626 cmdline_parse_inst_t cmd_flex_filter = {
7627 .f = cmd_flex_filter_parsed,
7629 .help_str = "add/del a flex filter",
7631 (void *)&cmd_flex_filter_filter,
7632 (void *)&cmd_flex_filter_port_id,
7633 (void *)&cmd_flex_filter_ops,
7634 (void *)&cmd_flex_filter_len,
7635 (void *)&cmd_flex_filter_len_value,
7636 (void *)&cmd_flex_filter_bytes,
7637 (void *)&cmd_flex_filter_bytes_value,
7638 (void *)&cmd_flex_filter_mask,
7639 (void *)&cmd_flex_filter_mask_value,
7640 (void *)&cmd_flex_filter_priority,
7641 (void *)&cmd_flex_filter_priority_value,
7642 (void *)&cmd_flex_filter_queue,
7643 (void *)&cmd_flex_filter_queue_id,
7648 /* *** Filters Control *** */
7650 /* *** deal with ethertype filter *** */
7651 struct cmd_ethertype_filter_result {
7652 cmdline_fixed_string_t filter;
7654 cmdline_fixed_string_t ops;
7655 cmdline_fixed_string_t mac;
7656 struct ether_addr mac_addr;
7657 cmdline_fixed_string_t ethertype;
7658 uint16_t ethertype_value;
7659 cmdline_fixed_string_t drop;
7660 cmdline_fixed_string_t queue;
7664 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7665 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7666 filter, "ethertype_filter");
7667 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7668 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7670 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7671 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7673 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7674 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7675 mac, "mac_addr#mac_ignr");
7676 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7677 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7679 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7680 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7681 ethertype, "ethertype");
7682 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7683 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7684 ethertype_value, UINT16);
7685 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7686 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7688 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7689 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7691 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7692 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7696 cmd_ethertype_filter_parsed(void *parsed_result,
7697 __attribute__((unused)) struct cmdline *cl,
7698 __attribute__((unused)) void *data)
7700 struct cmd_ethertype_filter_result *res = parsed_result;
7701 struct rte_eth_ethertype_filter filter;
7704 ret = rte_eth_dev_filter_supported(res->port_id,
7705 RTE_ETH_FILTER_ETHERTYPE);
7707 printf("ethertype filter is not supported on port %u.\n",
7712 memset(&filter, 0, sizeof(filter));
7713 if (!strcmp(res->mac, "mac_addr")) {
7714 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7715 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7716 sizeof(struct ether_addr));
7718 if (!strcmp(res->drop, "drop"))
7719 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7720 filter.ether_type = res->ethertype_value;
7721 filter.queue = res->queue_id;
7723 if (!strcmp(res->ops, "add"))
7724 ret = rte_eth_dev_filter_ctrl(res->port_id,
7725 RTE_ETH_FILTER_ETHERTYPE,
7729 ret = rte_eth_dev_filter_ctrl(res->port_id,
7730 RTE_ETH_FILTER_ETHERTYPE,
7731 RTE_ETH_FILTER_DELETE,
7734 printf("ethertype filter programming error: (%s)\n",
7738 cmdline_parse_inst_t cmd_ethertype_filter = {
7739 .f = cmd_ethertype_filter_parsed,
7741 .help_str = "add or delete an ethertype filter entry",
7743 (void *)&cmd_ethertype_filter_filter,
7744 (void *)&cmd_ethertype_filter_port_id,
7745 (void *)&cmd_ethertype_filter_ops,
7746 (void *)&cmd_ethertype_filter_mac,
7747 (void *)&cmd_ethertype_filter_mac_addr,
7748 (void *)&cmd_ethertype_filter_ethertype,
7749 (void *)&cmd_ethertype_filter_ethertype_value,
7750 (void *)&cmd_ethertype_filter_drop,
7751 (void *)&cmd_ethertype_filter_queue,
7752 (void *)&cmd_ethertype_filter_queue_id,
7757 /* *** deal with flow director filter *** */
7758 struct cmd_flow_director_result {
7759 cmdline_fixed_string_t flow_director_filter;
7761 cmdline_fixed_string_t mode;
7762 cmdline_fixed_string_t mode_value;
7763 cmdline_fixed_string_t ops;
7764 cmdline_fixed_string_t flow;
7765 cmdline_fixed_string_t flow_type;
7766 cmdline_fixed_string_t ether;
7767 uint16_t ether_type;
7768 cmdline_fixed_string_t src;
7769 cmdline_ipaddr_t ip_src;
7771 cmdline_fixed_string_t dst;
7772 cmdline_ipaddr_t ip_dst;
7774 cmdline_fixed_string_t verify_tag;
7775 uint32_t verify_tag_value;
7776 cmdline_fixed_string_t vlan;
7777 uint16_t vlan_value;
7778 cmdline_fixed_string_t flexbytes;
7779 cmdline_fixed_string_t flexbytes_value;
7780 cmdline_fixed_string_t drop;
7781 cmdline_fixed_string_t queue;
7783 cmdline_fixed_string_t fd_id;
7784 uint32_t fd_id_value;
7785 cmdline_fixed_string_t mac;
7786 struct ether_addr mac_addr;
7787 cmdline_fixed_string_t tunnel;
7788 cmdline_fixed_string_t tunnel_type;
7789 cmdline_fixed_string_t tunnel_id;
7790 uint32_t tunnel_id_value;
7794 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7797 const char *p, *p0 = q_arg;
7799 unsigned long int_fld;
7800 char *str_fld[max_num];
7805 p = strchr(p0, '(');
7809 p0 = strchr(p, ')');
7814 if (size >= sizeof(s))
7817 snprintf(s, sizeof(s), "%.*s", size, p);
7818 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7819 if (ret < 0 || ret > max_num)
7821 for (i = 0; i < ret; i++) {
7823 int_fld = strtoul(str_fld[i], &end, 0);
7824 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7826 flexbytes[i] = (uint8_t)int_fld;
7832 str2flowtype(char *string)
7835 static const struct {
7838 } flowtype_str[] = {
7839 {"raw", RTE_ETH_FLOW_RAW},
7840 {"ipv4", RTE_ETH_FLOW_IPV4},
7841 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
7842 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
7843 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
7844 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
7845 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
7846 {"ipv6", RTE_ETH_FLOW_IPV6},
7847 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
7848 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
7849 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
7850 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
7851 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
7852 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
7855 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7856 if (!strcmp(flowtype_str[i].str, string))
7857 return flowtype_str[i].type;
7859 return RTE_ETH_FLOW_UNKNOWN;
7863 str2fdir_tunneltype(char *string)
7867 static const struct {
7870 } tunneltype_str[] = {
7871 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
7872 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
7875 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
7876 if (!strcmp(tunneltype_str[i].str, string))
7877 return tunneltype_str[i].type;
7879 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
7882 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
7884 if ((ip_addr).family == AF_INET) \
7885 (ip) = (ip_addr).addr.ipv4.s_addr; \
7887 printf("invalid parameter.\n"); \
7892 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
7894 if ((ip_addr).family == AF_INET6) \
7895 (void)rte_memcpy(&(ip), \
7896 &((ip_addr).addr.ipv6), \
7897 sizeof(struct in6_addr)); \
7899 printf("invalid parameter.\n"); \
7905 cmd_flow_director_filter_parsed(void *parsed_result,
7906 __attribute__((unused)) struct cmdline *cl,
7907 __attribute__((unused)) void *data)
7909 struct cmd_flow_director_result *res = parsed_result;
7910 struct rte_eth_fdir_filter entry;
7911 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
7914 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7916 printf("flow director is not supported on port %u.\n",
7920 memset(flexbytes, 0, sizeof(flexbytes));
7921 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
7923 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
7924 if (strcmp(res->mode_value, "MAC-VLAN")) {
7925 printf("Please set mode to MAC-VLAN.\n");
7928 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
7929 if (strcmp(res->mode_value, "Tunnel")) {
7930 printf("Please set mode to Tunnel.\n");
7934 if (strcmp(res->mode_value, "IP")) {
7935 printf("Please set mode to IP.\n");
7938 entry.input.flow_type = str2flowtype(res->flow_type);
7941 ret = parse_flexbytes(res->flexbytes_value,
7943 RTE_ETH_FDIR_MAX_FLEXLEN);
7945 printf("error: Cannot parse flexbytes input.\n");
7949 switch (entry.input.flow_type) {
7950 case RTE_ETH_FLOW_FRAG_IPV4:
7951 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
7952 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
7953 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
7954 IPV4_ADDR_TO_UINT(res->ip_dst,
7955 entry.input.flow.ip4_flow.dst_ip);
7956 IPV4_ADDR_TO_UINT(res->ip_src,
7957 entry.input.flow.ip4_flow.src_ip);
7958 /* need convert to big endian. */
7959 entry.input.flow.udp4_flow.dst_port =
7960 rte_cpu_to_be_16(res->port_dst);
7961 entry.input.flow.udp4_flow.src_port =
7962 rte_cpu_to_be_16(res->port_src);
7964 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
7965 IPV4_ADDR_TO_UINT(res->ip_dst,
7966 entry.input.flow.sctp4_flow.ip.dst_ip);
7967 IPV4_ADDR_TO_UINT(res->ip_src,
7968 entry.input.flow.sctp4_flow.ip.src_ip);
7969 /* need convert to big endian. */
7970 entry.input.flow.sctp4_flow.dst_port =
7971 rte_cpu_to_be_16(res->port_dst);
7972 entry.input.flow.sctp4_flow.src_port =
7973 rte_cpu_to_be_16(res->port_src);
7974 entry.input.flow.sctp4_flow.verify_tag =
7975 rte_cpu_to_be_32(res->verify_tag_value);
7977 case RTE_ETH_FLOW_FRAG_IPV6:
7978 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
7979 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
7980 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
7981 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7982 entry.input.flow.ipv6_flow.dst_ip);
7983 IPV6_ADDR_TO_ARRAY(res->ip_src,
7984 entry.input.flow.ipv6_flow.src_ip);
7985 /* need convert to big endian. */
7986 entry.input.flow.udp6_flow.dst_port =
7987 rte_cpu_to_be_16(res->port_dst);
7988 entry.input.flow.udp6_flow.src_port =
7989 rte_cpu_to_be_16(res->port_src);
7991 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
7992 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7993 entry.input.flow.sctp6_flow.ip.dst_ip);
7994 IPV6_ADDR_TO_ARRAY(res->ip_src,
7995 entry.input.flow.sctp6_flow.ip.src_ip);
7996 /* need convert to big endian. */
7997 entry.input.flow.sctp6_flow.dst_port =
7998 rte_cpu_to_be_16(res->port_dst);
7999 entry.input.flow.sctp6_flow.src_port =
8000 rte_cpu_to_be_16(res->port_src);
8001 entry.input.flow.sctp6_flow.verify_tag =
8002 rte_cpu_to_be_32(res->verify_tag_value);
8004 case RTE_ETH_FLOW_L2_PAYLOAD:
8005 entry.input.flow.l2_flow.ether_type =
8006 rte_cpu_to_be_16(res->ether_type);
8012 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8013 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8015 sizeof(struct ether_addr));
8017 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8018 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8020 sizeof(struct ether_addr));
8021 entry.input.flow.tunnel_flow.tunnel_type =
8022 str2fdir_tunneltype(res->tunnel_type);
8023 entry.input.flow.tunnel_flow.tunnel_id =
8024 rte_cpu_to_be_32(res->tunnel_id_value);
8027 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8029 RTE_ETH_FDIR_MAX_FLEXLEN);
8031 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8033 entry.action.flex_off = 0; /*use 0 by default */
8034 if (!strcmp(res->drop, "drop"))
8035 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8037 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8038 /* set to report FD ID by default */
8039 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8040 entry.action.rx_queue = res->queue_id;
8041 entry.soft_id = res->fd_id_value;
8042 if (!strcmp(res->ops, "add"))
8043 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8044 RTE_ETH_FILTER_ADD, &entry);
8045 else if (!strcmp(res->ops, "del"))
8046 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8047 RTE_ETH_FILTER_DELETE, &entry);
8049 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8050 RTE_ETH_FILTER_UPDATE, &entry);
8052 printf("flow director programming error: (%s)\n",
8056 cmdline_parse_token_string_t cmd_flow_director_filter =
8057 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8058 flow_director_filter, "flow_director_filter");
8059 cmdline_parse_token_num_t cmd_flow_director_port_id =
8060 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8062 cmdline_parse_token_string_t cmd_flow_director_ops =
8063 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8064 ops, "add#del#update");
8065 cmdline_parse_token_string_t cmd_flow_director_flow =
8066 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8068 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8069 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8070 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8071 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8072 cmdline_parse_token_string_t cmd_flow_director_ether =
8073 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8075 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8076 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8077 ether_type, UINT16);
8078 cmdline_parse_token_string_t cmd_flow_director_src =
8079 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8081 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8082 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8084 cmdline_parse_token_num_t cmd_flow_director_port_src =
8085 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8087 cmdline_parse_token_string_t cmd_flow_director_dst =
8088 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8090 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8091 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8093 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8094 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8096 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8097 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8098 verify_tag, "verify_tag");
8099 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8100 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8101 verify_tag_value, UINT32);
8102 cmdline_parse_token_string_t cmd_flow_director_vlan =
8103 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8105 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8106 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8107 vlan_value, UINT16);
8108 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8109 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8110 flexbytes, "flexbytes");
8111 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8112 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8113 flexbytes_value, NULL);
8114 cmdline_parse_token_string_t cmd_flow_director_drop =
8115 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8117 cmdline_parse_token_string_t cmd_flow_director_queue =
8118 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8120 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8121 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8123 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8124 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8126 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8127 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8128 fd_id_value, UINT32);
8130 cmdline_parse_token_string_t cmd_flow_director_mode =
8131 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8133 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8134 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8136 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8137 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8138 mode_value, "MAC-VLAN");
8139 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8140 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8141 mode_value, "Tunnel");
8142 cmdline_parse_token_string_t cmd_flow_director_mac =
8143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8145 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8146 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8148 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8151 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8153 tunnel_type, "NVGRE#VxLAN");
8154 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8156 tunnel_id, "tunnel-id");
8157 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8158 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8159 tunnel_id_value, UINT32);
8161 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8162 .f = cmd_flow_director_filter_parsed,
8164 .help_str = "add or delete an ip flow director entry on NIC",
8166 (void *)&cmd_flow_director_filter,
8167 (void *)&cmd_flow_director_port_id,
8168 (void *)&cmd_flow_director_mode,
8169 (void *)&cmd_flow_director_mode_ip,
8170 (void *)&cmd_flow_director_ops,
8171 (void *)&cmd_flow_director_flow,
8172 (void *)&cmd_flow_director_flow_type,
8173 (void *)&cmd_flow_director_src,
8174 (void *)&cmd_flow_director_ip_src,
8175 (void *)&cmd_flow_director_dst,
8176 (void *)&cmd_flow_director_ip_dst,
8177 (void *)&cmd_flow_director_vlan,
8178 (void *)&cmd_flow_director_vlan_value,
8179 (void *)&cmd_flow_director_flexbytes,
8180 (void *)&cmd_flow_director_flexbytes_value,
8181 (void *)&cmd_flow_director_drop,
8182 (void *)&cmd_flow_director_queue,
8183 (void *)&cmd_flow_director_queue_id,
8184 (void *)&cmd_flow_director_fd_id,
8185 (void *)&cmd_flow_director_fd_id_value,
8190 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8191 .f = cmd_flow_director_filter_parsed,
8193 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8195 (void *)&cmd_flow_director_filter,
8196 (void *)&cmd_flow_director_port_id,
8197 (void *)&cmd_flow_director_mode,
8198 (void *)&cmd_flow_director_mode_ip,
8199 (void *)&cmd_flow_director_ops,
8200 (void *)&cmd_flow_director_flow,
8201 (void *)&cmd_flow_director_flow_type,
8202 (void *)&cmd_flow_director_src,
8203 (void *)&cmd_flow_director_ip_src,
8204 (void *)&cmd_flow_director_port_src,
8205 (void *)&cmd_flow_director_dst,
8206 (void *)&cmd_flow_director_ip_dst,
8207 (void *)&cmd_flow_director_port_dst,
8208 (void *)&cmd_flow_director_vlan,
8209 (void *)&cmd_flow_director_vlan_value,
8210 (void *)&cmd_flow_director_flexbytes,
8211 (void *)&cmd_flow_director_flexbytes_value,
8212 (void *)&cmd_flow_director_drop,
8213 (void *)&cmd_flow_director_queue,
8214 (void *)&cmd_flow_director_queue_id,
8215 (void *)&cmd_flow_director_fd_id,
8216 (void *)&cmd_flow_director_fd_id_value,
8221 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8222 .f = cmd_flow_director_filter_parsed,
8224 .help_str = "add or delete a sctp flow director entry on NIC",
8226 (void *)&cmd_flow_director_filter,
8227 (void *)&cmd_flow_director_port_id,
8228 (void *)&cmd_flow_director_mode,
8229 (void *)&cmd_flow_director_mode_ip,
8230 (void *)&cmd_flow_director_ops,
8231 (void *)&cmd_flow_director_flow,
8232 (void *)&cmd_flow_director_flow_type,
8233 (void *)&cmd_flow_director_src,
8234 (void *)&cmd_flow_director_ip_src,
8235 (void *)&cmd_flow_director_port_dst,
8236 (void *)&cmd_flow_director_dst,
8237 (void *)&cmd_flow_director_ip_dst,
8238 (void *)&cmd_flow_director_port_dst,
8239 (void *)&cmd_flow_director_verify_tag,
8240 (void *)&cmd_flow_director_verify_tag_value,
8241 (void *)&cmd_flow_director_vlan,
8242 (void *)&cmd_flow_director_vlan_value,
8243 (void *)&cmd_flow_director_flexbytes,
8244 (void *)&cmd_flow_director_flexbytes_value,
8245 (void *)&cmd_flow_director_drop,
8246 (void *)&cmd_flow_director_queue,
8247 (void *)&cmd_flow_director_queue_id,
8248 (void *)&cmd_flow_director_fd_id,
8249 (void *)&cmd_flow_director_fd_id_value,
8254 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8255 .f = cmd_flow_director_filter_parsed,
8257 .help_str = "add or delete a L2 flow director entry on NIC",
8259 (void *)&cmd_flow_director_filter,
8260 (void *)&cmd_flow_director_port_id,
8261 (void *)&cmd_flow_director_mode,
8262 (void *)&cmd_flow_director_mode_ip,
8263 (void *)&cmd_flow_director_ops,
8264 (void *)&cmd_flow_director_flow,
8265 (void *)&cmd_flow_director_flow_type,
8266 (void *)&cmd_flow_director_ether,
8267 (void *)&cmd_flow_director_ether_type,
8268 (void *)&cmd_flow_director_flexbytes,
8269 (void *)&cmd_flow_director_flexbytes_value,
8270 (void *)&cmd_flow_director_drop,
8271 (void *)&cmd_flow_director_queue,
8272 (void *)&cmd_flow_director_queue_id,
8273 (void *)&cmd_flow_director_fd_id,
8274 (void *)&cmd_flow_director_fd_id_value,
8279 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8280 .f = cmd_flow_director_filter_parsed,
8282 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8284 (void *)&cmd_flow_director_filter,
8285 (void *)&cmd_flow_director_port_id,
8286 (void *)&cmd_flow_director_mode,
8287 (void *)&cmd_flow_director_mode_mac_vlan,
8288 (void *)&cmd_flow_director_ops,
8289 (void *)&cmd_flow_director_mac,
8290 (void *)&cmd_flow_director_mac_addr,
8291 (void *)&cmd_flow_director_vlan,
8292 (void *)&cmd_flow_director_vlan_value,
8293 (void *)&cmd_flow_director_flexbytes,
8294 (void *)&cmd_flow_director_flexbytes_value,
8295 (void *)&cmd_flow_director_drop,
8296 (void *)&cmd_flow_director_queue,
8297 (void *)&cmd_flow_director_queue_id,
8298 (void *)&cmd_flow_director_fd_id,
8299 (void *)&cmd_flow_director_fd_id_value,
8304 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8305 .f = cmd_flow_director_filter_parsed,
8307 .help_str = "add or delete a tunnel flow director entry on NIC",
8309 (void *)&cmd_flow_director_filter,
8310 (void *)&cmd_flow_director_port_id,
8311 (void *)&cmd_flow_director_mode,
8312 (void *)&cmd_flow_director_mode_tunnel,
8313 (void *)&cmd_flow_director_ops,
8314 (void *)&cmd_flow_director_mac,
8315 (void *)&cmd_flow_director_mac_addr,
8316 (void *)&cmd_flow_director_vlan,
8317 (void *)&cmd_flow_director_vlan_value,
8318 (void *)&cmd_flow_director_tunnel,
8319 (void *)&cmd_flow_director_tunnel_type,
8320 (void *)&cmd_flow_director_tunnel_id,
8321 (void *)&cmd_flow_director_tunnel_id_value,
8322 (void *)&cmd_flow_director_flexbytes,
8323 (void *)&cmd_flow_director_flexbytes_value,
8324 (void *)&cmd_flow_director_drop,
8325 (void *)&cmd_flow_director_queue,
8326 (void *)&cmd_flow_director_queue_id,
8327 (void *)&cmd_flow_director_fd_id,
8328 (void *)&cmd_flow_director_fd_id_value,
8333 struct cmd_flush_flow_director_result {
8334 cmdline_fixed_string_t flush_flow_director;
8338 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8339 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8340 flush_flow_director, "flush_flow_director");
8341 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8342 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8346 cmd_flush_flow_director_parsed(void *parsed_result,
8347 __attribute__((unused)) struct cmdline *cl,
8348 __attribute__((unused)) void *data)
8350 struct cmd_flow_director_result *res = parsed_result;
8353 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8355 printf("flow director is not supported on port %u.\n",
8360 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8361 RTE_ETH_FILTER_FLUSH, NULL);
8363 printf("flow director table flushing error: (%s)\n",
8367 cmdline_parse_inst_t cmd_flush_flow_director = {
8368 .f = cmd_flush_flow_director_parsed,
8370 .help_str = "flush all flow director entries of a device on NIC",
8372 (void *)&cmd_flush_flow_director_flush,
8373 (void *)&cmd_flush_flow_director_port_id,
8378 /* *** deal with flow director mask *** */
8379 struct cmd_flow_director_mask_result {
8380 cmdline_fixed_string_t flow_director_mask;
8382 cmdline_fixed_string_t mode;
8383 cmdline_fixed_string_t mode_value;
8384 cmdline_fixed_string_t vlan;
8386 cmdline_fixed_string_t src_mask;
8387 cmdline_ipaddr_t ipv4_src;
8388 cmdline_ipaddr_t ipv6_src;
8390 cmdline_fixed_string_t dst_mask;
8391 cmdline_ipaddr_t ipv4_dst;
8392 cmdline_ipaddr_t ipv6_dst;
8394 cmdline_fixed_string_t mac;
8395 uint8_t mac_addr_byte_mask;
8396 cmdline_fixed_string_t tunnel_id;
8397 uint32_t tunnel_id_mask;
8398 cmdline_fixed_string_t tunnel_type;
8399 uint8_t tunnel_type_mask;
8403 cmd_flow_director_mask_parsed(void *parsed_result,
8404 __attribute__((unused)) struct cmdline *cl,
8405 __attribute__((unused)) void *data)
8407 struct cmd_flow_director_mask_result *res = parsed_result;
8408 struct rte_eth_fdir_masks *mask;
8409 struct rte_port *port;
8411 if (res->port_id > nb_ports) {
8412 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8416 port = &ports[res->port_id];
8417 /** Check if the port is not started **/
8418 if (port->port_status != RTE_PORT_STOPPED) {
8419 printf("Please stop port %d first\n", res->port_id);
8423 mask = &port->dev_conf.fdir_conf.mask;
8425 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8426 if (strcmp(res->mode_value, "MAC-VLAN")) {
8427 printf("Please set mode to MAC-VLAN.\n");
8431 mask->vlan_tci_mask = res->vlan_mask;
8432 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8433 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8434 if (strcmp(res->mode_value, "Tunnel")) {
8435 printf("Please set mode to Tunnel.\n");
8439 mask->vlan_tci_mask = res->vlan_mask;
8440 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8441 mask->tunnel_id_mask = res->tunnel_id_mask;
8442 mask->tunnel_type_mask = res->tunnel_type_mask;
8444 if (strcmp(res->mode_value, "IP")) {
8445 printf("Please set mode to IP.\n");
8449 mask->vlan_tci_mask = res->vlan_mask;
8450 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8451 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8452 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8453 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8454 mask->src_port_mask = res->port_src;
8455 mask->dst_port_mask = res->port_dst;
8458 cmd_reconfig_device_queue(res->port_id, 1, 1);
8461 cmdline_parse_token_string_t cmd_flow_director_mask =
8462 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8463 flow_director_mask, "flow_director_mask");
8464 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8465 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8467 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8468 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8470 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8471 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8473 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8474 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8475 src_mask, "src_mask");
8476 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8477 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8479 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8480 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8482 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8483 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8485 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8486 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8487 dst_mask, "dst_mask");
8488 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8489 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8491 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8492 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8494 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8495 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8498 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8499 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8501 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8502 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8504 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8505 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8506 mode_value, "MAC-VLAN");
8507 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8508 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8509 mode_value, "Tunnel");
8510 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8511 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8513 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8514 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8515 mac_addr_byte_mask, UINT8);
8516 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8517 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8518 tunnel_type, "tunnel-type");
8519 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8520 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8521 tunnel_type_mask, UINT8);
8522 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8523 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8524 tunnel_id, "tunnel-id");
8525 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8526 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8527 tunnel_id_mask, UINT32);
8529 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8530 .f = cmd_flow_director_mask_parsed,
8532 .help_str = "set IP mode flow director's mask on NIC",
8534 (void *)&cmd_flow_director_mask,
8535 (void *)&cmd_flow_director_mask_port_id,
8536 (void *)&cmd_flow_director_mask_mode,
8537 (void *)&cmd_flow_director_mask_mode_ip,
8538 (void *)&cmd_flow_director_mask_vlan,
8539 (void *)&cmd_flow_director_mask_vlan_value,
8540 (void *)&cmd_flow_director_mask_src,
8541 (void *)&cmd_flow_director_mask_ipv4_src,
8542 (void *)&cmd_flow_director_mask_ipv6_src,
8543 (void *)&cmd_flow_director_mask_port_src,
8544 (void *)&cmd_flow_director_mask_dst,
8545 (void *)&cmd_flow_director_mask_ipv4_dst,
8546 (void *)&cmd_flow_director_mask_ipv6_dst,
8547 (void *)&cmd_flow_director_mask_port_dst,
8552 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8553 .f = cmd_flow_director_mask_parsed,
8555 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8557 (void *)&cmd_flow_director_mask,
8558 (void *)&cmd_flow_director_mask_port_id,
8559 (void *)&cmd_flow_director_mask_mode,
8560 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8561 (void *)&cmd_flow_director_mask_vlan,
8562 (void *)&cmd_flow_director_mask_vlan_value,
8563 (void *)&cmd_flow_director_mask_mac,
8564 (void *)&cmd_flow_director_mask_mac_value,
8569 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8570 .f = cmd_flow_director_mask_parsed,
8572 .help_str = "set tunnel mode flow director's mask on NIC",
8574 (void *)&cmd_flow_director_mask,
8575 (void *)&cmd_flow_director_mask_port_id,
8576 (void *)&cmd_flow_director_mask_mode,
8577 (void *)&cmd_flow_director_mask_mode_tunnel,
8578 (void *)&cmd_flow_director_mask_vlan,
8579 (void *)&cmd_flow_director_mask_vlan_value,
8580 (void *)&cmd_flow_director_mask_mac,
8581 (void *)&cmd_flow_director_mask_mac_value,
8582 (void *)&cmd_flow_director_mask_tunnel_type,
8583 (void *)&cmd_flow_director_mask_tunnel_type_value,
8584 (void *)&cmd_flow_director_mask_tunnel_id,
8585 (void *)&cmd_flow_director_mask_tunnel_id_value,
8590 /* *** deal with flow director mask on flexible payload *** */
8591 struct cmd_flow_director_flex_mask_result {
8592 cmdline_fixed_string_t flow_director_flexmask;
8594 cmdline_fixed_string_t flow;
8595 cmdline_fixed_string_t flow_type;
8596 cmdline_fixed_string_t mask;
8600 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8601 __attribute__((unused)) struct cmdline *cl,
8602 __attribute__((unused)) void *data)
8604 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8605 struct rte_eth_fdir_info fdir_info;
8606 struct rte_eth_fdir_flex_mask flex_mask;
8607 struct rte_port *port;
8608 uint32_t flow_type_mask;
8612 if (res->port_id > nb_ports) {
8613 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8617 port = &ports[res->port_id];
8618 /** Check if the port is not started **/
8619 if (port->port_status != RTE_PORT_STOPPED) {
8620 printf("Please stop port %d first\n", res->port_id);
8624 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8625 ret = parse_flexbytes(res->mask,
8627 RTE_ETH_FDIR_MAX_FLEXLEN);
8629 printf("error: Cannot parse mask input.\n");
8633 memset(&fdir_info, 0, sizeof(fdir_info));
8634 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8635 RTE_ETH_FILTER_INFO, &fdir_info);
8637 printf("Cannot get FDir filter info\n");
8641 if (!strcmp(res->flow_type, "none")) {
8642 /* means don't specify the flow type */
8643 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8644 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8645 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8646 0, sizeof(struct rte_eth_fdir_flex_mask));
8647 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8648 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8650 sizeof(struct rte_eth_fdir_flex_mask));
8651 cmd_reconfig_device_queue(res->port_id, 1, 1);
8654 flow_type_mask = fdir_info.flow_types_mask[0];
8655 if (!strcmp(res->flow_type, "all")) {
8656 if (!flow_type_mask) {
8657 printf("No flow type supported\n");
8660 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8661 if (flow_type_mask & (1 << i)) {
8662 flex_mask.flow_type = i;
8663 fdir_set_flex_mask(res->port_id, &flex_mask);
8666 cmd_reconfig_device_queue(res->port_id, 1, 1);
8669 flex_mask.flow_type = str2flowtype(res->flow_type);
8670 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8671 printf("Flow type %s not supported on port %d\n",
8672 res->flow_type, res->port_id);
8675 fdir_set_flex_mask(res->port_id, &flex_mask);
8676 cmd_reconfig_device_queue(res->port_id, 1, 1);
8679 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8680 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8681 flow_director_flexmask,
8682 "flow_director_flex_mask");
8683 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8684 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8686 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8687 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8689 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8691 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8692 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8693 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8697 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8698 .f = cmd_flow_director_flex_mask_parsed,
8700 .help_str = "set flow director's flex mask on NIC",
8702 (void *)&cmd_flow_director_flexmask,
8703 (void *)&cmd_flow_director_flexmask_port_id,
8704 (void *)&cmd_flow_director_flexmask_flow,
8705 (void *)&cmd_flow_director_flexmask_flow_type,
8706 (void *)&cmd_flow_director_flexmask_mask,
8711 /* *** deal with flow director flexible payload configuration *** */
8712 struct cmd_flow_director_flexpayload_result {
8713 cmdline_fixed_string_t flow_director_flexpayload;
8715 cmdline_fixed_string_t payload_layer;
8716 cmdline_fixed_string_t payload_cfg;
8720 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8723 const char *p, *p0 = q_arg;
8725 unsigned long int_fld;
8726 char *str_fld[max_num];
8731 p = strchr(p0, '(');
8735 p0 = strchr(p, ')');
8740 if (size >= sizeof(s))
8743 snprintf(s, sizeof(s), "%.*s", size, p);
8744 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8745 if (ret < 0 || ret > max_num)
8747 for (i = 0; i < ret; i++) {
8749 int_fld = strtoul(str_fld[i], &end, 0);
8750 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8752 offsets[i] = (uint16_t)int_fld;
8758 cmd_flow_director_flxpld_parsed(void *parsed_result,
8759 __attribute__((unused)) struct cmdline *cl,
8760 __attribute__((unused)) void *data)
8762 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8763 struct rte_eth_flex_payload_cfg flex_cfg;
8764 struct rte_port *port;
8767 if (res->port_id > nb_ports) {
8768 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8772 port = &ports[res->port_id];
8773 /** Check if the port is not started **/
8774 if (port->port_status != RTE_PORT_STOPPED) {
8775 printf("Please stop port %d first\n", res->port_id);
8779 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8781 if (!strcmp(res->payload_layer, "raw"))
8782 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8783 else if (!strcmp(res->payload_layer, "l2"))
8784 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8785 else if (!strcmp(res->payload_layer, "l3"))
8786 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8787 else if (!strcmp(res->payload_layer, "l4"))
8788 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8790 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8791 RTE_ETH_FDIR_MAX_FLEXLEN);
8793 printf("error: Cannot parse flex payload input.\n");
8797 fdir_set_flex_payload(res->port_id, &flex_cfg);
8798 cmd_reconfig_device_queue(res->port_id, 1, 1);
8801 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8802 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8803 flow_director_flexpayload,
8804 "flow_director_flex_payload");
8805 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8806 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8808 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8809 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8810 payload_layer, "raw#l2#l3#l4");
8811 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8812 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8815 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8816 .f = cmd_flow_director_flxpld_parsed,
8818 .help_str = "set flow director's flex payload on NIC",
8820 (void *)&cmd_flow_director_flexpayload,
8821 (void *)&cmd_flow_director_flexpayload_port_id,
8822 (void *)&cmd_flow_director_flexpayload_payload_layer,
8823 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8828 /* *** Classification Filters Control *** */
8829 /* *** Get symmetric hash enable per port *** */
8830 struct cmd_get_sym_hash_ena_per_port_result {
8831 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8836 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8837 __rte_unused struct cmdline *cl,
8838 __rte_unused void *data)
8840 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8841 struct rte_eth_hash_filter_info info;
8844 if (rte_eth_dev_filter_supported(res->port_id,
8845 RTE_ETH_FILTER_HASH) < 0) {
8846 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8851 memset(&info, 0, sizeof(info));
8852 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8853 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8854 RTE_ETH_FILTER_GET, &info);
8857 printf("Cannot get symmetric hash enable per port "
8858 "on port %u\n", res->port_id);
8862 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8863 "enabled" : "disabled", res->port_id);
8866 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8867 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8868 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8869 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8870 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8873 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8874 .f = cmd_get_sym_hash_per_port_parsed,
8876 .help_str = "get_sym_hash_ena_per_port port_id",
8878 (void *)&cmd_get_sym_hash_ena_per_port_all,
8879 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8884 /* *** Set symmetric hash enable per port *** */
8885 struct cmd_set_sym_hash_ena_per_port_result {
8886 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8887 cmdline_fixed_string_t enable;
8892 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8893 __rte_unused struct cmdline *cl,
8894 __rte_unused void *data)
8896 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8897 struct rte_eth_hash_filter_info info;
8900 if (rte_eth_dev_filter_supported(res->port_id,
8901 RTE_ETH_FILTER_HASH) < 0) {
8902 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8907 memset(&info, 0, sizeof(info));
8908 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8909 if (!strcmp(res->enable, "enable"))
8910 info.info.enable = 1;
8911 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8912 RTE_ETH_FILTER_SET, &info);
8914 printf("Cannot set symmetric hash enable per port on "
8915 "port %u\n", res->port_id);
8918 printf("Symmetric hash has been set to %s on port %u\n",
8919 res->enable, res->port_id);
8922 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8923 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8924 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8925 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8926 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8928 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8929 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8930 enable, "enable#disable");
8932 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8933 .f = cmd_set_sym_hash_per_port_parsed,
8935 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8937 (void *)&cmd_set_sym_hash_ena_per_port_all,
8938 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8939 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8944 /* Get global config of hash function */
8945 struct cmd_get_hash_global_config_result {
8946 cmdline_fixed_string_t get_hash_global_config;
8951 flowtype_to_str(uint16_t ftype)
8958 {"ipv4", RTE_ETH_FLOW_IPV4},
8959 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8960 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8961 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8962 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8963 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8964 {"ipv6", RTE_ETH_FLOW_IPV6},
8965 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8966 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8967 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8968 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8969 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8970 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8973 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8974 if (ftype_table[i].ftype == ftype)
8975 return ftype_table[i].str;
8982 cmd_get_hash_global_config_parsed(void *parsed_result,
8983 __rte_unused struct cmdline *cl,
8984 __rte_unused void *data)
8986 struct cmd_get_hash_global_config_result *res = parsed_result;
8987 struct rte_eth_hash_filter_info info;
8988 uint32_t idx, offset;
8993 if (rte_eth_dev_filter_supported(res->port_id,
8994 RTE_ETH_FILTER_HASH) < 0) {
8995 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9000 memset(&info, 0, sizeof(info));
9001 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9002 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9003 RTE_ETH_FILTER_GET, &info);
9005 printf("Cannot get hash global configurations by port %d\n",
9010 switch (info.info.global_conf.hash_func) {
9011 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9012 printf("Hash function is Toeplitz\n");
9014 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9015 printf("Hash function is Simple XOR\n");
9018 printf("Unknown hash function\n");
9022 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9023 idx = i / UINT32_BIT;
9024 offset = i % UINT32_BIT;
9025 if (!(info.info.global_conf.valid_bit_mask[idx] &
9028 str = flowtype_to_str(i);
9031 printf("Symmetric hash is %s globally for flow type %s "
9033 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9034 (1UL << offset)) ? "enabled" : "disabled"), str,
9039 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9040 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9041 get_hash_global_config, "get_hash_global_config");
9042 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9043 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9046 cmdline_parse_inst_t cmd_get_hash_global_config = {
9047 .f = cmd_get_hash_global_config_parsed,
9049 .help_str = "get_hash_global_config port_id",
9051 (void *)&cmd_get_hash_global_config_all,
9052 (void *)&cmd_get_hash_global_config_port_id,
9057 /* Set global config of hash function */
9058 struct cmd_set_hash_global_config_result {
9059 cmdline_fixed_string_t set_hash_global_config;
9061 cmdline_fixed_string_t hash_func;
9062 cmdline_fixed_string_t flow_type;
9063 cmdline_fixed_string_t enable;
9067 cmd_set_hash_global_config_parsed(void *parsed_result,
9068 __rte_unused struct cmdline *cl,
9069 __rte_unused void *data)
9071 struct cmd_set_hash_global_config_result *res = parsed_result;
9072 struct rte_eth_hash_filter_info info;
9073 uint32_t ftype, idx, offset;
9076 if (rte_eth_dev_filter_supported(res->port_id,
9077 RTE_ETH_FILTER_HASH) < 0) {
9078 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9082 memset(&info, 0, sizeof(info));
9083 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9084 if (!strcmp(res->hash_func, "toeplitz"))
9085 info.info.global_conf.hash_func =
9086 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9087 else if (!strcmp(res->hash_func, "simple_xor"))
9088 info.info.global_conf.hash_func =
9089 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9090 else if (!strcmp(res->hash_func, "default"))
9091 info.info.global_conf.hash_func =
9092 RTE_ETH_HASH_FUNCTION_DEFAULT;
9094 ftype = str2flowtype(res->flow_type);
9095 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9096 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9097 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9098 if (!strcmp(res->enable, "enable"))
9099 info.info.global_conf.sym_hash_enable_mask[idx] |=
9101 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9102 RTE_ETH_FILTER_SET, &info);
9104 printf("Cannot set global hash configurations by port %d\n",
9107 printf("Global hash configurations have been set "
9108 "succcessfully by port %d\n", res->port_id);
9111 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9112 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9113 set_hash_global_config, "set_hash_global_config");
9114 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9115 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9117 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9118 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9119 hash_func, "toeplitz#simple_xor#default");
9120 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9121 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9123 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9124 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9125 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9126 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9127 enable, "enable#disable");
9129 cmdline_parse_inst_t cmd_set_hash_global_config = {
9130 .f = cmd_set_hash_global_config_parsed,
9132 .help_str = "set_hash_global_config port_id "
9133 "toeplitz|simple_xor|default "
9134 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9135 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9138 (void *)&cmd_set_hash_global_config_all,
9139 (void *)&cmd_set_hash_global_config_port_id,
9140 (void *)&cmd_set_hash_global_config_hash_func,
9141 (void *)&cmd_set_hash_global_config_flow_type,
9142 (void *)&cmd_set_hash_global_config_enable,
9147 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9148 struct cmd_mcast_addr_result {
9149 cmdline_fixed_string_t mcast_addr_cmd;
9150 cmdline_fixed_string_t what;
9152 struct ether_addr mc_addr;
9155 static void cmd_mcast_addr_parsed(void *parsed_result,
9156 __attribute__((unused)) struct cmdline *cl,
9157 __attribute__((unused)) void *data)
9159 struct cmd_mcast_addr_result *res = parsed_result;
9161 if (!is_multicast_ether_addr(&res->mc_addr)) {
9162 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9163 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9164 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9165 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9168 if (strcmp(res->what, "add") == 0)
9169 mcast_addr_add(res->port_num, &res->mc_addr);
9171 mcast_addr_remove(res->port_num, &res->mc_addr);
9174 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9175 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9176 mcast_addr_cmd, "mcast_addr");
9177 cmdline_parse_token_string_t cmd_mcast_addr_what =
9178 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9180 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9181 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9182 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9183 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9185 cmdline_parse_inst_t cmd_mcast_addr = {
9186 .f = cmd_mcast_addr_parsed,
9188 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9190 (void *)&cmd_mcast_addr_cmd,
9191 (void *)&cmd_mcast_addr_what,
9192 (void *)&cmd_mcast_addr_portnum,
9193 (void *)&cmd_mcast_addr_addr,
9198 /* ******************************************************************************** */
9200 /* list of instructions */
9201 cmdline_parse_ctx_t main_ctx[] = {
9202 (cmdline_parse_inst_t *)&cmd_help_brief,
9203 (cmdline_parse_inst_t *)&cmd_help_long,
9204 (cmdline_parse_inst_t *)&cmd_quit,
9205 (cmdline_parse_inst_t *)&cmd_showport,
9206 (cmdline_parse_inst_t *)&cmd_showportall,
9207 (cmdline_parse_inst_t *)&cmd_showcfg,
9208 (cmdline_parse_inst_t *)&cmd_start,
9209 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9210 (cmdline_parse_inst_t *)&cmd_set_link_up,
9211 (cmdline_parse_inst_t *)&cmd_set_link_down,
9212 (cmdline_parse_inst_t *)&cmd_reset,
9213 (cmdline_parse_inst_t *)&cmd_set_numbers,
9214 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9215 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9216 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9217 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9218 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9219 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9220 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9221 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9222 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9223 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9224 (cmdline_parse_inst_t *)&cmd_set_link_check,
9225 #ifdef RTE_NIC_BYPASS
9226 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9227 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9228 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9229 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9231 #ifdef RTE_LIBRTE_PMD_BOND
9232 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9233 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9234 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9235 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9236 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9237 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9238 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9239 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9240 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9242 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9243 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9244 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9245 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9246 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9247 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
9248 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9249 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9250 (cmdline_parse_inst_t *)&cmd_csum_set,
9251 (cmdline_parse_inst_t *)&cmd_csum_show,
9252 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
9253 (cmdline_parse_inst_t *)&cmd_tso_set,
9254 (cmdline_parse_inst_t *)&cmd_tso_show,
9255 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9256 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9257 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9258 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9259 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9260 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9261 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9262 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9263 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9264 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9265 (cmdline_parse_inst_t *)&cmd_config_dcb,
9266 (cmdline_parse_inst_t *)&cmd_read_reg,
9267 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9268 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9269 (cmdline_parse_inst_t *)&cmd_write_reg,
9270 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9271 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9272 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9273 (cmdline_parse_inst_t *)&cmd_stop,
9274 (cmdline_parse_inst_t *)&cmd_mac_addr,
9275 (cmdline_parse_inst_t *)&cmd_set_qmap,
9276 (cmdline_parse_inst_t *)&cmd_operate_port,
9277 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9278 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
9279 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
9280 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9281 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9282 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9283 (cmdline_parse_inst_t *)&cmd_config_mtu,
9284 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9285 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9286 (cmdline_parse_inst_t *)&cmd_config_rss,
9287 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9288 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9289 (cmdline_parse_inst_t *)&cmd_showport_reta,
9290 (cmdline_parse_inst_t *)&cmd_config_burst,
9291 (cmdline_parse_inst_t *)&cmd_config_thresh,
9292 (cmdline_parse_inst_t *)&cmd_config_threshold,
9293 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9294 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9295 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9296 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9297 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9298 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9299 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9300 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9301 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9302 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9303 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9304 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9305 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9306 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9307 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9308 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9309 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9310 (cmdline_parse_inst_t *)&cmd_dump,
9311 (cmdline_parse_inst_t *)&cmd_dump_one,
9312 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9313 (cmdline_parse_inst_t *)&cmd_syn_filter,
9314 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
9315 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
9316 (cmdline_parse_inst_t *)&cmd_flex_filter,
9317 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9318 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9319 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9320 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
9321 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
9322 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
9323 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9324 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
9325 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
9326 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
9327 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9328 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9329 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9330 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9331 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9332 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9333 (cmdline_parse_inst_t *)&cmd_mcast_addr,
9337 /* prompt function, called from main on MASTER lcore */
9343 /* initialize non-constant commands */
9344 cmd_set_fwd_mode_init();
9346 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9350 cmdline_interact(cl);
9351 cmdline_stdin_exit(cl);
9355 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9357 if (id == (portid_t)RTE_PORT_ALL) {
9360 FOREACH_PORT(pid, ports) {
9361 /* check if need_reconfig has been set to 1 */
9362 if (ports[pid].need_reconfig == 0)
9363 ports[pid].need_reconfig = dev;
9364 /* check if need_reconfig_queues has been set to 1 */
9365 if (ports[pid].need_reconfig_queues == 0)
9366 ports[pid].need_reconfig_queues = queue;
9368 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
9369 /* check if need_reconfig has been set to 1 */
9370 if (ports[id].need_reconfig == 0)
9371 ports[id].need_reconfig = dev;
9372 /* check if need_reconfig_queues has been set to 1 */
9373 if (ports[id].need_reconfig_queues == 0)
9374 ports[id].need_reconfig_queues = queue;
9378 #ifdef RTE_NIC_BYPASS
9379 #include <rte_pci_dev_ids.h>
9381 bypass_is_supported(portid_t port_id)
9383 struct rte_port *port;
9384 struct rte_pci_id *pci_id;
9386 if (port_id_is_invalid(port_id, ENABLED_WARN))
9389 /* Get the device id. */
9390 port = &ports[port_id];
9391 pci_id = &port->dev_info.pci_dev->id;
9393 /* Check if NIC supports bypass. */
9394 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9398 printf("\tBypass not supported for port_id = %d.\n", port_id);