4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_malloc.h>
63 #include <rte_launch.h>
64 #include <rte_tailq.h>
66 #include <rte_per_lcore.h>
67 #include <rte_lcore.h>
68 #include <rte_atomic.h>
69 #include <rte_branch_prediction.h>
71 #include <rte_mempool.h>
72 #include <rte_interrupts.h>
74 #include <rte_ether.h>
75 #include <rte_ethdev.h>
76 #include <rte_string_fns.h>
77 #include <rte_devargs.h>
78 #include <rte_eth_ctrl.h>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #include <rte_pci_dev_ids.h>
89 #ifdef RTE_LIBRTE_PMD_BOND
90 #include <rte_eth_bond.h>
95 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
98 uint8_t bypass_is_supported(portid_t port_id);
101 /* *** Help command with introduction. *** */
102 struct cmd_help_brief_result {
103 cmdline_fixed_string_t help;
106 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
108 __attribute__((unused)) void *data)
113 "Help is available for the following sections:\n\n"
114 " help control : Start and stop forwarding.\n"
115 " help display : Displaying port, stats and config "
117 " help config : Configuration information.\n"
118 " help ports : Configuring ports.\n"
119 " help registers : Reading and setting port registers.\n"
120 " help filters : Filters configuration help.\n"
121 " help all : All of the above sections.\n\n"
126 cmdline_parse_token_string_t cmd_help_brief_help =
127 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
129 cmdline_parse_inst_t cmd_help_brief = {
130 .f = cmd_help_brief_parsed,
132 .help_str = "show help",
134 (void *)&cmd_help_brief_help,
139 /* *** Help command with help sections. *** */
140 struct cmd_help_long_result {
141 cmdline_fixed_string_t help;
142 cmdline_fixed_string_t section;
145 static void cmd_help_long_parsed(void *parsed_result,
147 __attribute__((unused)) void *data)
150 struct cmd_help_long_result *res = parsed_result;
152 if (!strcmp(res->section, "all"))
155 if (show_all || !strcmp(res->section, "control")) {
160 "Control forwarding:\n"
161 "-------------------\n\n"
164 " Start packet forwarding with current configuration.\n\n"
167 " Start packet forwarding with current config"
168 " after sending one burst of packets.\n\n"
171 " Stop packet forwarding, and display accumulated"
175 " Quit to prompt.\n\n"
179 if (show_all || !strcmp(res->section, "display")) {
187 "show port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
188 " Display information for port_id, or all.\n\n"
190 "show port X rss reta (size) (mask0,mask1,...)\n"
191 " Display the rss redirection table entry indicated"
192 " by masks on port X. size is used to indicate the"
193 " hardware supported reta size\n\n"
195 "show port rss-hash [key]\n"
196 " Display the RSS hash functions and RSS hash key"
199 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
200 " Clear information for port_id, or all.\n\n"
202 "show config (rxtx|cores|fwd)\n"
203 " Display the given configuration.\n\n"
205 "read rxd (port_id) (queue_id) (rxd_id)\n"
206 " Display an RX descriptor of a port RX queue.\n\n"
208 "read txd (port_id) (queue_id) (txd_id)\n"
209 " Display a TX descriptor of a port TX queue.\n\n"
213 if (show_all || !strcmp(res->section, "config")) {
219 "Configuration changes only become active when"
220 " forwarding is started/restarted.\n\n"
223 " Reset forwarding to the default configuration.\n\n"
225 "set verbose (level)\n"
226 " Set the debug verbosity level X.\n\n"
229 " Set number of ports.\n\n"
232 " Set number of cores.\n\n"
234 "set coremask (mask)\n"
235 " Set the forwarding cores hexadecimal mask.\n\n"
237 "set portmask (mask)\n"
238 " Set the forwarding ports hexadecimal mask.\n\n"
241 " Set number of packets per burst.\n\n"
243 "set burst tx delay (microseconds) retry (num)\n"
244 " Set the transmit delay time and number of retries"
245 " in mac_retry forwarding mode.\n\n"
247 "set txpkts (x[,y]*)\n"
248 " Set the length of each segment of TXONLY"
251 "set corelist (x[,y]*)\n"
252 " Set the list of forwarding cores.\n\n"
254 "set portlist (x[,y]*)\n"
255 " Set the list of forwarding ports.\n\n"
257 "vlan set strip (on|off) (port_id)\n"
258 " Set the VLAN strip on a port.\n\n"
260 "vlan set stripq (on|off) (port_id,queue_id)\n"
261 " Set the VLAN strip for a queue on a port.\n\n"
263 "vlan set filter (on|off) (port_id)\n"
264 " Set the VLAN filter on a port.\n\n"
266 "vlan set qinq (on|off) (port_id)\n"
267 " Set the VLAN QinQ (extended queue in queue)"
270 "vlan set tpid (value) (port_id)\n"
271 " Set the outer VLAN TPID for Packet Filtering on"
274 "rx_vlan add (vlan_id|all) (port_id)\n"
275 " Add a vlan_id, or all identifiers, to the set"
276 " of VLAN identifiers filtered by port_id.\n\n"
278 "rx_vlan rm (vlan_id|all) (port_id)\n"
279 " Remove a vlan_id, or all identifiers, from the set"
280 " of VLAN identifiers filtered by port_id.\n\n"
282 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
283 " Add a vlan_id, to the set of VLAN identifiers"
284 "filtered for VF(s) from port_id.\n\n"
286 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
287 " Remove a vlan_id, to the set of VLAN identifiers"
288 "filtered for VF(s) from port_id.\n\n"
290 "rx_vlan set tpid (value) (port_id)\n"
291 " Set the outer VLAN TPID for Packet Filtering on"
294 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
295 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
296 " add a tunnel filter of a port.\n\n"
298 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
299 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
300 " remove a tunnel filter of a port.\n\n"
302 "rx_vxlan_port add (udp_port) (port_id)\n"
303 " Add an UDP port for VXLAN packet filter on a port\n\n"
305 "rx_vxlan_port rm (udp_port) (port_id)\n"
306 " Remove an UDP port for VXLAN packet filter on a port\n\n"
308 "tx_vlan set vlan_id (port_id)\n"
309 " Set hardware insertion of VLAN ID in packets sent"
312 "tx_vlan set pvid port_id vlan_id (on|off)\n"
313 " Set port based TX VLAN insertion.\n\n"
315 "tx_vlan reset (port_id)\n"
316 " Disable hardware insertion of a VLAN header in"
317 " packets sent on a port.\n\n"
319 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
320 " Select hardware or software calculation of the"
321 " checksum with when transmitting a packet using the"
322 " csum forward engine.\n"
323 " ip|udp|tcp|sctp always concern the inner layer.\n"
324 " 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|vlan-mirror)\n"
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 config (port_id|all)"
517 " speed (10|100|1000|10000|40000|auto)"
518 " duplex (half|full|auto)\n"
519 " Set speed and duplex for all ports or port_id\n\n"
521 "port config all (rxq|txq|rxd|txd) (value)\n"
522 " Set number for rxq/txq/rxd/txd.\n\n"
524 "port config all max-pkt-len (value)\n"
525 " Set the max packet length.\n\n"
527 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
529 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
532 "port config all rss (ip|udp|none)\n"
533 " Set the RSS mode.\n\n"
535 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
536 " Set the RSS redirection table.\n\n"
538 "port config (port_id) dcb vt (on|off) (traffic_class)"
540 " Set the DCB mode.\n\n"
542 "port config all burst (value)\n"
543 " Set the number of packets per burst.\n\n"
545 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
547 " Set the ring prefetch/host/writeback threshold"
548 " for tx/rx queue.\n\n"
550 "port config all (txfreet|txrst|rxfreet) (value)\n"
551 " Set free threshold for rx/tx, or set"
552 " tx rs bit threshold.\n\n"
553 "port config mtu X value\n"
554 " Set the MTU of port X to a given value\n\n"
556 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
557 " Start/stop a rx/tx queue of port X. Only take effect"
558 " when port X is started\n"
562 if (show_all || !strcmp(res->section, "registers")) {
570 "read reg (port_id) (address)\n"
571 " Display value of a port register.\n\n"
573 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
574 " Display a port register bit field.\n\n"
576 "read regbit (port_id) (address) (bit_x)\n"
577 " Display a single port register bit.\n\n"
579 "write reg (port_id) (address) (value)\n"
580 " Set value of a port register.\n\n"
582 "write regfield (port_id) (address) (bit_x) (bit_y)"
584 " Set bit field of a port register.\n\n"
586 "write regbit (port_id) (address) (bit_x) (value)\n"
587 " Set single bit value of a port register.\n\n"
590 if (show_all || !strcmp(res->section, "filters")) {
598 "ethertype_filter (port_id) (add|del)"
599 " (mac_addr|mac_ignr) (mac_address) ethertype"
600 " (ether_type) (drop|fwd) queue (queue_id)\n"
601 " Add/Del an ethertype filter.\n\n"
603 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
604 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
605 " queue (queue_id) index (idx)\n"
606 " add a 2tuple filter.\n\n"
608 "remove_2tuple_filter (port_id) index (idx)\n"
609 " remove a 2tuple filter.\n\n"
611 "get_2tuple_filter (port_id) index (idx)\n"
612 " get info of a 2tuple filter.\n\n"
614 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
615 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
616 " mask (mask_value) flags (flags_value) priority (prio_value)"
617 " queue (queue_id) index (idx)\n"
618 " add a 5tuple filter.\n\n"
620 "remove_5tuple_filter (port_id) index (idx)\n"
621 " remove a 5tuple filter.\n\n"
623 "get_5tuple_filter (port_id) index (idx)\n"
624 " get info of a 5tuple filter.\n\n"
626 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
627 " Add/Del syn filter.\n\n"
629 "flex_filter (port_id) (add|del) len (len_value)"
630 " bytes (bytes_value) mask (mask_value)"
631 " priority (prio_value) queue (queue_id)\n"
632 " Add/Del a flex filter.\n\n"
634 "flow_director_filter (port_id) (add|del|update)"
635 " flow (ip4|ip4-frag|ip6|ip6-frag)"
636 " src (src_ip_address) dst (dst_ip_address)"
637 " vlan (vlan_value) flexbytes (flexbytes_value)"
638 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
639 " Add/Del an IP type flow director filter.\n\n"
641 "flow_director_filter (port_id) (add|del|update)"
642 " flow (udp4|tcp4|udp6|tcp6)"
643 " src (src_ip_address) (src_port)"
644 " dst (dst_ip_address) (dst_port)"
645 " vlan (vlan_value) flexbytes (flexbytes_value)"
646 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
647 " Add/Del an UDP/TCP type flow director filter.\n\n"
649 "flow_director_filter (port_id) (add|del|update)"
650 " flow (sctp4|sctp6)"
651 " src (src_ip_address) (src_port)"
652 " dst (dst_ip_address) (dst_port)"
653 " tag (verification_tag) vlan (vlan_value)"
654 " flexbytes (flexbytes_value) (drop|fwd)"
655 " queue (queue_id) fd_id (fd_id_value)\n"
656 " Add/Del a SCTP type flow director filter.\n\n"
658 "flush_flow_director (port_id)\n"
659 " Flush all flow director entries of a device.\n\n"
661 "flow_director_mask (port_id) vlan (vlan_value)"
662 " src_mask (ipv4_src) (ipv6_src) (src_port)"
663 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
664 " Set flow director mask.\n\n"
666 "flow_director_flex_mask (port_id)"
667 " flow (raw|ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
669 " Configure mask of flex payload.\n\n"
671 "flow_director_flex_payload (port_id)"
672 " (raw|l2|l3|l4) (config)\n"
673 " Configure flex payload selection.\n\n"
675 "get_sym_hash_ena_per_port (port_id)\n"
676 " get symmetric hash enable configuration per port.\n\n"
678 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
679 " set symmetric hash enable configuration per port"
680 " to enable or disable.\n\n"
682 "get_hash_global_config (port_id)\n"
683 " Get the global configurations of hash filters.\n\n"
685 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
686 " (ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6)"
687 " (enable|disable)\n"
688 " Set the global configurations of hash filters.\n\n"
693 cmdline_parse_token_string_t cmd_help_long_help =
694 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
696 cmdline_parse_token_string_t cmd_help_long_section =
697 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
698 "all#control#display#config#"
699 "ports#registers#filters");
701 cmdline_parse_inst_t cmd_help_long = {
702 .f = cmd_help_long_parsed,
704 .help_str = "show help",
706 (void *)&cmd_help_long_help,
707 (void *)&cmd_help_long_section,
713 /* *** start/stop/close all ports *** */
714 struct cmd_operate_port_result {
715 cmdline_fixed_string_t keyword;
716 cmdline_fixed_string_t name;
717 cmdline_fixed_string_t value;
720 static void cmd_operate_port_parsed(void *parsed_result,
721 __attribute__((unused)) struct cmdline *cl,
722 __attribute__((unused)) void *data)
724 struct cmd_operate_port_result *res = parsed_result;
726 if (!strcmp(res->name, "start"))
727 start_port(RTE_PORT_ALL);
728 else if (!strcmp(res->name, "stop"))
729 stop_port(RTE_PORT_ALL);
730 else if (!strcmp(res->name, "close"))
731 close_port(RTE_PORT_ALL);
733 printf("Unknown parameter\n");
736 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
737 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
739 cmdline_parse_token_string_t cmd_operate_port_all_port =
740 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
742 cmdline_parse_token_string_t cmd_operate_port_all_all =
743 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
745 cmdline_parse_inst_t cmd_operate_port = {
746 .f = cmd_operate_port_parsed,
748 .help_str = "port start|stop|close all: start/stop/close all ports",
750 (void *)&cmd_operate_port_all_cmd,
751 (void *)&cmd_operate_port_all_port,
752 (void *)&cmd_operate_port_all_all,
757 /* *** start/stop/close specific port *** */
758 struct cmd_operate_specific_port_result {
759 cmdline_fixed_string_t keyword;
760 cmdline_fixed_string_t name;
764 static void cmd_operate_specific_port_parsed(void *parsed_result,
765 __attribute__((unused)) struct cmdline *cl,
766 __attribute__((unused)) void *data)
768 struct cmd_operate_specific_port_result *res = parsed_result;
770 if (!strcmp(res->name, "start"))
771 start_port(res->value);
772 else if (!strcmp(res->name, "stop"))
773 stop_port(res->value);
774 else if (!strcmp(res->name, "close"))
775 close_port(res->value);
777 printf("Unknown parameter\n");
780 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
781 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
783 cmdline_parse_token_string_t cmd_operate_specific_port_port =
784 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
785 name, "start#stop#close");
786 cmdline_parse_token_num_t cmd_operate_specific_port_id =
787 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
790 cmdline_parse_inst_t cmd_operate_specific_port = {
791 .f = cmd_operate_specific_port_parsed,
793 .help_str = "port start|stop|close X: start/stop/close port X",
795 (void *)&cmd_operate_specific_port_cmd,
796 (void *)&cmd_operate_specific_port_port,
797 (void *)&cmd_operate_specific_port_id,
802 /* *** configure speed for all ports *** */
803 struct cmd_config_speed_all {
804 cmdline_fixed_string_t port;
805 cmdline_fixed_string_t keyword;
806 cmdline_fixed_string_t all;
807 cmdline_fixed_string_t item1;
808 cmdline_fixed_string_t item2;
809 cmdline_fixed_string_t value1;
810 cmdline_fixed_string_t value2;
814 cmd_config_speed_all_parsed(void *parsed_result,
815 __attribute__((unused)) struct cmdline *cl,
816 __attribute__((unused)) void *data)
818 struct cmd_config_speed_all *res = parsed_result;
819 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
820 uint16_t link_duplex = 0;
823 if (!all_ports_stopped()) {
824 printf("Please stop all ports first\n");
828 if (!strcmp(res->value1, "10"))
829 link_speed = ETH_LINK_SPEED_10;
830 else if (!strcmp(res->value1, "100"))
831 link_speed = ETH_LINK_SPEED_100;
832 else if (!strcmp(res->value1, "1000"))
833 link_speed = ETH_LINK_SPEED_1000;
834 else if (!strcmp(res->value1, "10000"))
835 link_speed = ETH_LINK_SPEED_10G;
836 else if (!strcmp(res->value1, "40000"))
837 link_speed = ETH_LINK_SPEED_40G;
838 else if (!strcmp(res->value1, "auto"))
839 link_speed = ETH_LINK_SPEED_AUTONEG;
841 printf("Unknown parameter\n");
845 if (!strcmp(res->value2, "half"))
846 link_duplex = ETH_LINK_HALF_DUPLEX;
847 else if (!strcmp(res->value2, "full"))
848 link_duplex = ETH_LINK_FULL_DUPLEX;
849 else if (!strcmp(res->value2, "auto"))
850 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
852 printf("Unknown parameter\n");
856 for (pid = 0; pid < nb_ports; pid++) {
857 ports[pid].dev_conf.link_speed = link_speed;
858 ports[pid].dev_conf.link_duplex = link_duplex;
861 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
864 cmdline_parse_token_string_t cmd_config_speed_all_port =
865 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
866 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
867 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
869 cmdline_parse_token_string_t cmd_config_speed_all_all =
870 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
871 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
872 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
873 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
874 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
875 "10#100#1000#10000#40000#auto");
876 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
877 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
878 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
879 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
882 cmdline_parse_inst_t cmd_config_speed_all = {
883 .f = cmd_config_speed_all_parsed,
885 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
888 (void *)&cmd_config_speed_all_port,
889 (void *)&cmd_config_speed_all_keyword,
890 (void *)&cmd_config_speed_all_all,
891 (void *)&cmd_config_speed_all_item1,
892 (void *)&cmd_config_speed_all_value1,
893 (void *)&cmd_config_speed_all_item2,
894 (void *)&cmd_config_speed_all_value2,
899 /* *** configure speed for specific port *** */
900 struct cmd_config_speed_specific {
901 cmdline_fixed_string_t port;
902 cmdline_fixed_string_t keyword;
904 cmdline_fixed_string_t item1;
905 cmdline_fixed_string_t item2;
906 cmdline_fixed_string_t value1;
907 cmdline_fixed_string_t value2;
911 cmd_config_speed_specific_parsed(void *parsed_result,
912 __attribute__((unused)) struct cmdline *cl,
913 __attribute__((unused)) void *data)
915 struct cmd_config_speed_specific *res = parsed_result;
916 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
917 uint16_t link_duplex = 0;
919 if (!all_ports_stopped()) {
920 printf("Please stop all ports first\n");
924 if (res->id >= nb_ports) {
925 printf("Port id %d must be less than %d\n", res->id, nb_ports);
929 if (!strcmp(res->value1, "10"))
930 link_speed = ETH_LINK_SPEED_10;
931 else if (!strcmp(res->value1, "100"))
932 link_speed = ETH_LINK_SPEED_100;
933 else if (!strcmp(res->value1, "1000"))
934 link_speed = ETH_LINK_SPEED_1000;
935 else if (!strcmp(res->value1, "10000"))
936 link_speed = ETH_LINK_SPEED_10000;
937 else if (!strcmp(res->value1, "40000"))
938 link_speed = ETH_LINK_SPEED_40G;
939 else if (!strcmp(res->value1, "auto"))
940 link_speed = ETH_LINK_SPEED_AUTONEG;
942 printf("Unknown parameter\n");
946 if (!strcmp(res->value2, "half"))
947 link_duplex = ETH_LINK_HALF_DUPLEX;
948 else if (!strcmp(res->value2, "full"))
949 link_duplex = ETH_LINK_FULL_DUPLEX;
950 else if (!strcmp(res->value2, "auto"))
951 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
953 printf("Unknown parameter\n");
957 ports[res->id].dev_conf.link_speed = link_speed;
958 ports[res->id].dev_conf.link_duplex = link_duplex;
960 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
964 cmdline_parse_token_string_t cmd_config_speed_specific_port =
965 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
967 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
968 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
970 cmdline_parse_token_num_t cmd_config_speed_specific_id =
971 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
972 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
973 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
975 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
976 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
977 "10#100#1000#10000#40000#auto");
978 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
979 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
981 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
982 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
985 cmdline_parse_inst_t cmd_config_speed_specific = {
986 .f = cmd_config_speed_specific_parsed,
988 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
991 (void *)&cmd_config_speed_specific_port,
992 (void *)&cmd_config_speed_specific_keyword,
993 (void *)&cmd_config_speed_specific_id,
994 (void *)&cmd_config_speed_specific_item1,
995 (void *)&cmd_config_speed_specific_value1,
996 (void *)&cmd_config_speed_specific_item2,
997 (void *)&cmd_config_speed_specific_value2,
1002 /* *** configure txq/rxq, txd/rxd *** */
1003 struct cmd_config_rx_tx {
1004 cmdline_fixed_string_t port;
1005 cmdline_fixed_string_t keyword;
1006 cmdline_fixed_string_t all;
1007 cmdline_fixed_string_t name;
1012 cmd_config_rx_tx_parsed(void *parsed_result,
1013 __attribute__((unused)) struct cmdline *cl,
1014 __attribute__((unused)) void *data)
1016 struct cmd_config_rx_tx *res = parsed_result;
1018 if (!all_ports_stopped()) {
1019 printf("Please stop all ports first\n");
1023 if (!strcmp(res->name, "rxq")) {
1024 if (res->value <= 0) {
1025 printf("rxq %d invalid - must be > 0\n", res->value);
1028 nb_rxq = res->value;
1030 else if (!strcmp(res->name, "txq")) {
1031 if (res->value <= 0) {
1032 printf("txq %d invalid - must be > 0\n", res->value);
1035 nb_txq = res->value;
1037 else if (!strcmp(res->name, "rxd")) {
1038 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1039 printf("rxd %d invalid - must be > 0 && <= %d\n",
1040 res->value, RTE_TEST_RX_DESC_MAX);
1043 nb_rxd = res->value;
1044 } else if (!strcmp(res->name, "txd")) {
1045 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1046 printf("txd %d invalid - must be > 0 && <= %d\n",
1047 res->value, RTE_TEST_TX_DESC_MAX);
1050 nb_txd = res->value;
1052 printf("Unknown parameter\n");
1058 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1061 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1062 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1063 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1064 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1065 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1066 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1067 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1068 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1070 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1071 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1073 cmdline_parse_inst_t cmd_config_rx_tx = {
1074 .f = cmd_config_rx_tx_parsed,
1076 .help_str = "port config all rxq|txq|rxd|txd value",
1078 (void *)&cmd_config_rx_tx_port,
1079 (void *)&cmd_config_rx_tx_keyword,
1080 (void *)&cmd_config_rx_tx_all,
1081 (void *)&cmd_config_rx_tx_name,
1082 (void *)&cmd_config_rx_tx_value,
1087 /* *** config max packet length *** */
1088 struct cmd_config_max_pkt_len_result {
1089 cmdline_fixed_string_t port;
1090 cmdline_fixed_string_t keyword;
1091 cmdline_fixed_string_t all;
1092 cmdline_fixed_string_t name;
1097 cmd_config_max_pkt_len_parsed(void *parsed_result,
1098 __attribute__((unused)) struct cmdline *cl,
1099 __attribute__((unused)) void *data)
1101 struct cmd_config_max_pkt_len_result *res = parsed_result;
1103 if (!all_ports_stopped()) {
1104 printf("Please stop all ports first\n");
1108 if (!strcmp(res->name, "max-pkt-len")) {
1109 if (res->value < ETHER_MIN_LEN) {
1110 printf("max-pkt-len can not be less than %d\n",
1114 if (res->value == rx_mode.max_rx_pkt_len)
1117 rx_mode.max_rx_pkt_len = res->value;
1118 if (res->value > ETHER_MAX_LEN)
1119 rx_mode.jumbo_frame = 1;
1121 rx_mode.jumbo_frame = 0;
1123 printf("Unknown parameter\n");
1129 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1132 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1133 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1135 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1136 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1138 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1139 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1141 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1142 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1144 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1145 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1148 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1149 .f = cmd_config_max_pkt_len_parsed,
1151 .help_str = "port config all max-pkt-len value",
1153 (void *)&cmd_config_max_pkt_len_port,
1154 (void *)&cmd_config_max_pkt_len_keyword,
1155 (void *)&cmd_config_max_pkt_len_all,
1156 (void *)&cmd_config_max_pkt_len_name,
1157 (void *)&cmd_config_max_pkt_len_value,
1162 /* *** configure port MTU *** */
1163 struct cmd_config_mtu_result {
1164 cmdline_fixed_string_t port;
1165 cmdline_fixed_string_t keyword;
1166 cmdline_fixed_string_t mtu;
1172 cmd_config_mtu_parsed(void *parsed_result,
1173 __attribute__((unused)) struct cmdline *cl,
1174 __attribute__((unused)) void *data)
1176 struct cmd_config_mtu_result *res = parsed_result;
1178 if (res->value < ETHER_MIN_LEN) {
1179 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1182 port_mtu_set(res->port_id, res->value);
1185 cmdline_parse_token_string_t cmd_config_mtu_port =
1186 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1188 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1189 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1191 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1192 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1194 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1195 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1196 cmdline_parse_token_num_t cmd_config_mtu_value =
1197 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1199 cmdline_parse_inst_t cmd_config_mtu = {
1200 .f = cmd_config_mtu_parsed,
1202 .help_str = "port config mtu value",
1204 (void *)&cmd_config_mtu_port,
1205 (void *)&cmd_config_mtu_keyword,
1206 (void *)&cmd_config_mtu_mtu,
1207 (void *)&cmd_config_mtu_port_id,
1208 (void *)&cmd_config_mtu_value,
1213 /* *** configure rx mode *** */
1214 struct cmd_config_rx_mode_flag {
1215 cmdline_fixed_string_t port;
1216 cmdline_fixed_string_t keyword;
1217 cmdline_fixed_string_t all;
1218 cmdline_fixed_string_t name;
1219 cmdline_fixed_string_t value;
1223 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1224 __attribute__((unused)) struct cmdline *cl,
1225 __attribute__((unused)) void *data)
1227 struct cmd_config_rx_mode_flag *res = parsed_result;
1229 if (!all_ports_stopped()) {
1230 printf("Please stop all ports first\n");
1234 if (!strcmp(res->name, "crc-strip")) {
1235 if (!strcmp(res->value, "on"))
1236 rx_mode.hw_strip_crc = 1;
1237 else if (!strcmp(res->value, "off"))
1238 rx_mode.hw_strip_crc = 0;
1240 printf("Unknown parameter\n");
1243 } else if (!strcmp(res->name, "rx-cksum")) {
1244 if (!strcmp(res->value, "on"))
1245 rx_mode.hw_ip_checksum = 1;
1246 else if (!strcmp(res->value, "off"))
1247 rx_mode.hw_ip_checksum = 0;
1249 printf("Unknown parameter\n");
1252 } else if (!strcmp(res->name, "hw-vlan")) {
1253 if (!strcmp(res->value, "on")) {
1254 rx_mode.hw_vlan_filter = 1;
1255 rx_mode.hw_vlan_strip = 1;
1257 else if (!strcmp(res->value, "off")) {
1258 rx_mode.hw_vlan_filter = 0;
1259 rx_mode.hw_vlan_strip = 0;
1262 printf("Unknown parameter\n");
1265 } else if (!strcmp(res->name, "drop-en")) {
1266 if (!strcmp(res->value, "on"))
1268 else if (!strcmp(res->value, "off"))
1271 printf("Unknown parameter\n");
1275 printf("Unknown parameter\n");
1281 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1284 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1285 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1286 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1287 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1289 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1290 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1291 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1292 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1293 "crc-strip#rx-cksum#hw-vlan");
1294 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1295 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1298 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1299 .f = cmd_config_rx_mode_flag_parsed,
1301 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1303 (void *)&cmd_config_rx_mode_flag_port,
1304 (void *)&cmd_config_rx_mode_flag_keyword,
1305 (void *)&cmd_config_rx_mode_flag_all,
1306 (void *)&cmd_config_rx_mode_flag_name,
1307 (void *)&cmd_config_rx_mode_flag_value,
1312 /* *** configure rss *** */
1313 struct cmd_config_rss {
1314 cmdline_fixed_string_t port;
1315 cmdline_fixed_string_t keyword;
1316 cmdline_fixed_string_t all;
1317 cmdline_fixed_string_t name;
1318 cmdline_fixed_string_t value;
1322 cmd_config_rss_parsed(void *parsed_result,
1323 __attribute__((unused)) struct cmdline *cl,
1324 __attribute__((unused)) void *data)
1326 struct cmd_config_rss *res = parsed_result;
1327 struct rte_eth_rss_conf rss_conf;
1330 if (!strcmp(res->value, "ip"))
1331 rss_conf.rss_hf = ETH_RSS_IP;
1332 else if (!strcmp(res->value, "udp"))
1333 rss_conf.rss_hf = ETH_RSS_UDP;
1334 else if (!strcmp(res->value, "none"))
1335 rss_conf.rss_hf = 0;
1337 printf("Unknown parameter\n");
1340 rss_conf.rss_key = NULL;
1341 for (i = 0; i < rte_eth_dev_count(); i++)
1342 rte_eth_dev_rss_hash_update(i, &rss_conf);
1345 cmdline_parse_token_string_t cmd_config_rss_port =
1346 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1347 cmdline_parse_token_string_t cmd_config_rss_keyword =
1348 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1349 cmdline_parse_token_string_t cmd_config_rss_all =
1350 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1351 cmdline_parse_token_string_t cmd_config_rss_name =
1352 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1353 cmdline_parse_token_string_t cmd_config_rss_value =
1354 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1356 cmdline_parse_inst_t cmd_config_rss = {
1357 .f = cmd_config_rss_parsed,
1359 .help_str = "port config all rss ip|udp|none",
1361 (void *)&cmd_config_rss_port,
1362 (void *)&cmd_config_rss_keyword,
1363 (void *)&cmd_config_rss_all,
1364 (void *)&cmd_config_rss_name,
1365 (void *)&cmd_config_rss_value,
1370 /* *** configure rss hash key *** */
1371 struct cmd_config_rss_hash_key {
1372 cmdline_fixed_string_t port;
1373 cmdline_fixed_string_t config;
1375 cmdline_fixed_string_t rss_hash_key;
1376 cmdline_fixed_string_t key;
1379 #define RSS_HASH_KEY_LENGTH 40
1381 hexa_digit_to_value(char hexa_digit)
1383 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1384 return (uint8_t) (hexa_digit - '0');
1385 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1386 return (uint8_t) ((hexa_digit - 'a') + 10);
1387 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1388 return (uint8_t) ((hexa_digit - 'A') + 10);
1389 /* Invalid hexa digit */
1394 parse_and_check_key_hexa_digit(char *key, int idx)
1398 hexa_v = hexa_digit_to_value(key[idx]);
1400 printf("invalid key: character %c at position %d is not a "
1401 "valid hexa digit\n", key[idx], idx);
1406 cmd_config_rss_hash_key_parsed(void *parsed_result,
1407 __attribute__((unused)) struct cmdline *cl,
1408 __attribute__((unused)) void *data)
1410 struct cmd_config_rss_hash_key *res = parsed_result;
1411 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1416 /* Check the length of the RSS hash key */
1417 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1418 printf("key length: %d invalid - key must be a string of %d"
1419 "hexa-decimal numbers\n", (int) strlen(res->key),
1420 RSS_HASH_KEY_LENGTH * 2);
1423 /* Translate RSS hash key into binary representation */
1424 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1425 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1428 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1431 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1433 port_rss_hash_key_update(res->port_id, hash_key);
1436 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1437 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1438 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1439 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1441 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1442 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1443 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1444 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1445 rss_hash_key, "rss-hash-key");
1446 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1447 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1449 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1450 .f = cmd_config_rss_hash_key_parsed,
1452 .help_str = "port config X rss-hash-key 80 hexa digits",
1454 (void *)&cmd_config_rss_hash_key_port,
1455 (void *)&cmd_config_rss_hash_key_config,
1456 (void *)&cmd_config_rss_hash_key_port_id,
1457 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1458 (void *)&cmd_config_rss_hash_key_value,
1463 /* *** configure port rxq/txq start/stop *** */
1464 struct cmd_config_rxtx_queue {
1465 cmdline_fixed_string_t port;
1467 cmdline_fixed_string_t rxtxq;
1469 cmdline_fixed_string_t opname;
1473 cmd_config_rxtx_queue_parsed(void *parsed_result,
1474 __attribute__((unused)) struct cmdline *cl,
1475 __attribute__((unused)) void *data)
1477 struct cmd_config_rxtx_queue *res = parsed_result;
1482 if (test_done == 0) {
1483 printf("Please stop forwarding first\n");
1487 if (port_id_is_invalid(res->portid))
1490 if (port_is_started(res->portid) != 1) {
1491 printf("Please start port %u first\n", res->portid);
1495 if (!strcmp(res->rxtxq, "rxq"))
1497 else if (!strcmp(res->rxtxq, "txq"))
1500 printf("Unknown parameter\n");
1504 if (isrx && rx_queue_id_is_invalid(res->qid))
1506 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1509 if (!strcmp(res->opname, "start"))
1511 else if (!strcmp(res->opname, "stop"))
1514 printf("Unknown parameter\n");
1518 if (isstart && isrx)
1519 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1520 else if (!isstart && isrx)
1521 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1522 else if (isstart && !isrx)
1523 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1525 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1527 if (ret == -ENOTSUP)
1528 printf("Function not supported in PMD driver\n");
1531 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1532 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1533 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1534 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1535 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1536 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1537 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1538 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1539 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1540 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1543 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1544 .f = cmd_config_rxtx_queue_parsed,
1546 .help_str = "port X rxq|txq ID start|stop",
1548 (void *)&cmd_config_speed_all_port,
1549 (void *)&cmd_config_rxtx_queue_portid,
1550 (void *)&cmd_config_rxtx_queue_rxtxq,
1551 (void *)&cmd_config_rxtx_queue_qid,
1552 (void *)&cmd_config_rxtx_queue_opname,
1557 /* *** Configure RSS RETA *** */
1558 struct cmd_config_rss_reta {
1559 cmdline_fixed_string_t port;
1560 cmdline_fixed_string_t keyword;
1562 cmdline_fixed_string_t name;
1563 cmdline_fixed_string_t list_name;
1564 cmdline_fixed_string_t list_of_items;
1568 parse_reta_config(const char *str,
1569 struct rte_eth_rss_reta_entry64 *reta_conf,
1570 uint16_t nb_entries)
1574 uint16_t hash_index, idx, shift;
1577 const char *p, *p0 = str;
1584 unsigned long int_fld[_NUM_FLD];
1585 char *str_fld[_NUM_FLD];
1587 while ((p = strchr(p0,'(')) != NULL) {
1589 if((p0 = strchr(p,')')) == NULL)
1593 if(size >= sizeof(s))
1596 snprintf(s, sizeof(s), "%.*s", size, p);
1597 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1599 for (i = 0; i < _NUM_FLD; i++) {
1601 int_fld[i] = strtoul(str_fld[i], &end, 0);
1602 if (errno != 0 || end == str_fld[i] ||
1607 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1608 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1610 if (hash_index >= nb_entries) {
1611 printf("Invalid RETA hash index=%d\n", hash_index);
1615 idx = hash_index / RTE_RETA_GROUP_SIZE;
1616 shift = hash_index % RTE_RETA_GROUP_SIZE;
1617 reta_conf[idx].mask |= (1ULL << shift);
1618 reta_conf[idx].reta[shift] = nb_queue;
1625 cmd_set_rss_reta_parsed(void *parsed_result,
1626 __attribute__((unused)) struct cmdline *cl,
1627 __attribute__((unused)) void *data)
1630 struct rte_eth_dev_info dev_info;
1631 struct rte_eth_rss_reta_entry64 reta_conf[8];
1632 struct cmd_config_rss_reta *res = parsed_result;
1634 memset(&dev_info, 0, sizeof(dev_info));
1635 rte_eth_dev_info_get(res->port_id, &dev_info);
1636 if (dev_info.reta_size == 0) {
1637 printf("Redirection table size is 0 which is "
1638 "invalid for RSS\n");
1641 printf("The reta size of port %d is %u\n",
1642 res->port_id, dev_info.reta_size);
1643 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1644 printf("Currently do not support more than %u entries of "
1645 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1649 memset(reta_conf, 0, sizeof(reta_conf));
1650 if (!strcmp(res->list_name, "reta")) {
1651 if (parse_reta_config(res->list_of_items, reta_conf,
1652 dev_info.reta_size)) {
1653 printf("Invalid RSS Redirection Table "
1654 "config entered\n");
1657 ret = rte_eth_dev_rss_reta_update(res->port_id,
1658 reta_conf, dev_info.reta_size);
1660 printf("Bad redirection table parameter, "
1661 "return code = %d \n", ret);
1665 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1667 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1669 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1670 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1671 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1673 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1675 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1678 cmdline_parse_inst_t cmd_config_rss_reta = {
1679 .f = cmd_set_rss_reta_parsed,
1681 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1683 (void *)&cmd_config_rss_reta_port,
1684 (void *)&cmd_config_rss_reta_keyword,
1685 (void *)&cmd_config_rss_reta_port_id,
1686 (void *)&cmd_config_rss_reta_name,
1687 (void *)&cmd_config_rss_reta_list_name,
1688 (void *)&cmd_config_rss_reta_list_of_items,
1693 /* *** SHOW PORT RETA INFO *** */
1694 struct cmd_showport_reta {
1695 cmdline_fixed_string_t show;
1696 cmdline_fixed_string_t port;
1698 cmdline_fixed_string_t rss;
1699 cmdline_fixed_string_t reta;
1701 cmdline_fixed_string_t list_of_items;
1705 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1706 uint16_t nb_entries,
1710 const char *p, *p0 = str;
1714 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1717 p = strchr(p0, '(');
1721 p0 = strchr(p, ')');
1725 if (size >= sizeof(s)) {
1726 printf("The string size exceeds the internal buffer size\n");
1729 snprintf(s, sizeof(s), "%.*s", size, p);
1730 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1731 if (ret <= 0 || ret != num) {
1732 printf("The bits of masks do not match the number of "
1733 "reta entries: %u\n", num);
1736 for (i = 0; i < ret; i++)
1737 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1743 cmd_showport_reta_parsed(void *parsed_result,
1744 __attribute__((unused)) struct cmdline *cl,
1745 __attribute__((unused)) void *data)
1747 struct cmd_showport_reta *res = parsed_result;
1748 struct rte_eth_rss_reta_entry64 reta_conf[8];
1749 struct rte_eth_dev_info dev_info;
1751 memset(&dev_info, 0, sizeof(dev_info));
1752 rte_eth_dev_info_get(res->port_id, &dev_info);
1753 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1754 res->size > ETH_RSS_RETA_SIZE_512) {
1755 printf("Invalid redirection table size: %u\n", res->size);
1759 memset(reta_conf, 0, sizeof(reta_conf));
1760 if (showport_parse_reta_config(reta_conf, res->size,
1761 res->list_of_items) < 0) {
1762 printf("Invalid string: %s for reta masks\n",
1763 res->list_of_items);
1766 port_rss_reta_info(res->port_id, reta_conf, res->size);
1769 cmdline_parse_token_string_t cmd_showport_reta_show =
1770 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1771 cmdline_parse_token_string_t cmd_showport_reta_port =
1772 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1773 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1774 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1775 cmdline_parse_token_string_t cmd_showport_reta_rss =
1776 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1777 cmdline_parse_token_string_t cmd_showport_reta_reta =
1778 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1779 cmdline_parse_token_num_t cmd_showport_reta_size =
1780 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1781 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1782 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1783 list_of_items, NULL);
1785 cmdline_parse_inst_t cmd_showport_reta = {
1786 .f = cmd_showport_reta_parsed,
1788 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1790 (void *)&cmd_showport_reta_show,
1791 (void *)&cmd_showport_reta_port,
1792 (void *)&cmd_showport_reta_port_id,
1793 (void *)&cmd_showport_reta_rss,
1794 (void *)&cmd_showport_reta_reta,
1795 (void *)&cmd_showport_reta_size,
1796 (void *)&cmd_showport_reta_list_of_items,
1801 /* *** Show RSS hash configuration *** */
1802 struct cmd_showport_rss_hash {
1803 cmdline_fixed_string_t show;
1804 cmdline_fixed_string_t port;
1806 cmdline_fixed_string_t rss_hash;
1807 cmdline_fixed_string_t key; /* optional argument */
1810 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1811 __attribute__((unused)) struct cmdline *cl,
1814 struct cmd_showport_rss_hash *res = parsed_result;
1816 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1819 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1820 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1821 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1822 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1823 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1824 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1825 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1826 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1828 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1829 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1831 cmdline_parse_inst_t cmd_showport_rss_hash = {
1832 .f = cmd_showport_rss_hash_parsed,
1834 .help_str = "show port X rss-hash (X = port number)\n",
1836 (void *)&cmd_showport_rss_hash_show,
1837 (void *)&cmd_showport_rss_hash_port,
1838 (void *)&cmd_showport_rss_hash_port_id,
1839 (void *)&cmd_showport_rss_hash_rss_hash,
1844 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1845 .f = cmd_showport_rss_hash_parsed,
1847 .help_str = "show port X rss-hash key (X = port number)\n",
1849 (void *)&cmd_showport_rss_hash_show,
1850 (void *)&cmd_showport_rss_hash_port,
1851 (void *)&cmd_showport_rss_hash_port_id,
1852 (void *)&cmd_showport_rss_hash_rss_hash,
1853 (void *)&cmd_showport_rss_hash_rss_key,
1858 /* *** Configure DCB *** */
1859 struct cmd_config_dcb {
1860 cmdline_fixed_string_t port;
1861 cmdline_fixed_string_t config;
1863 cmdline_fixed_string_t dcb;
1864 cmdline_fixed_string_t vt;
1865 cmdline_fixed_string_t vt_en;
1867 cmdline_fixed_string_t pfc;
1868 cmdline_fixed_string_t pfc_en;
1872 cmd_config_dcb_parsed(void *parsed_result,
1873 __attribute__((unused)) struct cmdline *cl,
1874 __attribute__((unused)) void *data)
1876 struct cmd_config_dcb *res = parsed_result;
1877 struct dcb_config dcb_conf;
1878 portid_t port_id = res->port_id;
1879 struct rte_port *port;
1881 port = &ports[port_id];
1882 /** Check if the port is not started **/
1883 if (port->port_status != RTE_PORT_STOPPED) {
1884 printf("Please stop port %d first\n",port_id);
1888 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1889 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1890 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1894 /* DCB in VT mode */
1895 if (!strncmp(res->vt_en, "on",2))
1896 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1898 dcb_conf.dcb_mode = DCB_ENABLED;
1900 if (!strncmp(res->pfc_en, "on",2)) {
1901 dcb_conf.pfc_en = 1;
1904 dcb_conf.pfc_en = 0;
1906 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1907 printf("Cannot initialize network ports\n");
1911 cmd_reconfig_device_queue(port_id, 1, 1);
1914 cmdline_parse_token_string_t cmd_config_dcb_port =
1915 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1916 cmdline_parse_token_string_t cmd_config_dcb_config =
1917 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1918 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1919 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1920 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1921 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1922 cmdline_parse_token_string_t cmd_config_dcb_vt =
1923 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1924 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1925 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1926 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1927 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1928 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1929 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1930 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1931 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1933 cmdline_parse_inst_t cmd_config_dcb = {
1934 .f = cmd_config_dcb_parsed,
1936 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1938 (void *)&cmd_config_dcb_port,
1939 (void *)&cmd_config_dcb_config,
1940 (void *)&cmd_config_dcb_port_id,
1941 (void *)&cmd_config_dcb_dcb,
1942 (void *)&cmd_config_dcb_vt,
1943 (void *)&cmd_config_dcb_vt_en,
1944 (void *)&cmd_config_dcb_num_tcs,
1945 (void *)&cmd_config_dcb_pfc,
1946 (void *)&cmd_config_dcb_pfc_en,
1951 /* *** configure number of packets per burst *** */
1952 struct cmd_config_burst {
1953 cmdline_fixed_string_t port;
1954 cmdline_fixed_string_t keyword;
1955 cmdline_fixed_string_t all;
1956 cmdline_fixed_string_t name;
1961 cmd_config_burst_parsed(void *parsed_result,
1962 __attribute__((unused)) struct cmdline *cl,
1963 __attribute__((unused)) void *data)
1965 struct cmd_config_burst *res = parsed_result;
1967 if (!all_ports_stopped()) {
1968 printf("Please stop all ports first\n");
1972 if (!strcmp(res->name, "burst")) {
1973 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1974 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1977 nb_pkt_per_burst = res->value;
1979 printf("Unknown parameter\n");
1985 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1988 cmdline_parse_token_string_t cmd_config_burst_port =
1989 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1990 cmdline_parse_token_string_t cmd_config_burst_keyword =
1991 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1992 cmdline_parse_token_string_t cmd_config_burst_all =
1993 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1994 cmdline_parse_token_string_t cmd_config_burst_name =
1995 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1996 cmdline_parse_token_num_t cmd_config_burst_value =
1997 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1999 cmdline_parse_inst_t cmd_config_burst = {
2000 .f = cmd_config_burst_parsed,
2002 .help_str = "port config all burst value",
2004 (void *)&cmd_config_burst_port,
2005 (void *)&cmd_config_burst_keyword,
2006 (void *)&cmd_config_burst_all,
2007 (void *)&cmd_config_burst_name,
2008 (void *)&cmd_config_burst_value,
2013 /* *** configure rx/tx queues *** */
2014 struct cmd_config_thresh {
2015 cmdline_fixed_string_t port;
2016 cmdline_fixed_string_t keyword;
2017 cmdline_fixed_string_t all;
2018 cmdline_fixed_string_t name;
2023 cmd_config_thresh_parsed(void *parsed_result,
2024 __attribute__((unused)) struct cmdline *cl,
2025 __attribute__((unused)) void *data)
2027 struct cmd_config_thresh *res = parsed_result;
2029 if (!all_ports_stopped()) {
2030 printf("Please stop all ports first\n");
2034 if (!strcmp(res->name, "txpt"))
2035 tx_pthresh = res->value;
2036 else if(!strcmp(res->name, "txht"))
2037 tx_hthresh = res->value;
2038 else if(!strcmp(res->name, "txwt"))
2039 tx_wthresh = res->value;
2040 else if(!strcmp(res->name, "rxpt"))
2041 rx_pthresh = res->value;
2042 else if(!strcmp(res->name, "rxht"))
2043 rx_hthresh = res->value;
2044 else if(!strcmp(res->name, "rxwt"))
2045 rx_wthresh = res->value;
2047 printf("Unknown parameter\n");
2053 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2056 cmdline_parse_token_string_t cmd_config_thresh_port =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2058 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2059 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2060 cmdline_parse_token_string_t cmd_config_thresh_all =
2061 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2062 cmdline_parse_token_string_t cmd_config_thresh_name =
2063 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2064 "txpt#txht#txwt#rxpt#rxht#rxwt");
2065 cmdline_parse_token_num_t cmd_config_thresh_value =
2066 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2068 cmdline_parse_inst_t cmd_config_thresh = {
2069 .f = cmd_config_thresh_parsed,
2071 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2073 (void *)&cmd_config_thresh_port,
2074 (void *)&cmd_config_thresh_keyword,
2075 (void *)&cmd_config_thresh_all,
2076 (void *)&cmd_config_thresh_name,
2077 (void *)&cmd_config_thresh_value,
2082 /* *** configure free/rs threshold *** */
2083 struct cmd_config_threshold {
2084 cmdline_fixed_string_t port;
2085 cmdline_fixed_string_t keyword;
2086 cmdline_fixed_string_t all;
2087 cmdline_fixed_string_t name;
2092 cmd_config_threshold_parsed(void *parsed_result,
2093 __attribute__((unused)) struct cmdline *cl,
2094 __attribute__((unused)) void *data)
2096 struct cmd_config_threshold *res = parsed_result;
2098 if (!all_ports_stopped()) {
2099 printf("Please stop all ports first\n");
2103 if (!strcmp(res->name, "txfreet"))
2104 tx_free_thresh = res->value;
2105 else if (!strcmp(res->name, "txrst"))
2106 tx_rs_thresh = res->value;
2107 else if (!strcmp(res->name, "rxfreet"))
2108 rx_free_thresh = res->value;
2110 printf("Unknown parameter\n");
2116 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2119 cmdline_parse_token_string_t cmd_config_threshold_port =
2120 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2121 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2122 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2124 cmdline_parse_token_string_t cmd_config_threshold_all =
2125 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2126 cmdline_parse_token_string_t cmd_config_threshold_name =
2127 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2128 "txfreet#txrst#rxfreet");
2129 cmdline_parse_token_num_t cmd_config_threshold_value =
2130 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2132 cmdline_parse_inst_t cmd_config_threshold = {
2133 .f = cmd_config_threshold_parsed,
2135 .help_str = "port config all txfreet|txrst|rxfreet value",
2137 (void *)&cmd_config_threshold_port,
2138 (void *)&cmd_config_threshold_keyword,
2139 (void *)&cmd_config_threshold_all,
2140 (void *)&cmd_config_threshold_name,
2141 (void *)&cmd_config_threshold_value,
2147 struct cmd_stop_result {
2148 cmdline_fixed_string_t stop;
2151 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2152 __attribute__((unused)) struct cmdline *cl,
2153 __attribute__((unused)) void *data)
2155 stop_packet_forwarding();
2158 cmdline_parse_token_string_t cmd_stop_stop =
2159 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2161 cmdline_parse_inst_t cmd_stop = {
2162 .f = cmd_stop_parsed,
2164 .help_str = "stop - stop packet forwarding",
2166 (void *)&cmd_stop_stop,
2171 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2174 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2175 unsigned int *parsed_items, int check_unique_values)
2177 unsigned int nb_item;
2185 * First parse all items in the list and store their value.
2190 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2192 if ((c >= '0') && (c <= '9')) {
2193 value = (unsigned int) (value * 10 + (c - '0'));
2198 printf("character %c is not a decimal digit\n", c);
2202 printf("No valid value before comma\n");
2205 if (nb_item < max_items) {
2206 parsed_items[nb_item] = value;
2212 if (nb_item >= max_items) {
2213 printf("Number of %s = %u > %u (maximum items)\n",
2214 item_name, nb_item + 1, max_items);
2217 parsed_items[nb_item++] = value;
2218 if (! check_unique_values)
2222 * Then, check that all values in the list are differents.
2223 * No optimization here...
2225 for (i = 0; i < nb_item; i++) {
2226 for (j = i + 1; j < nb_item; j++) {
2227 if (parsed_items[j] == parsed_items[i]) {
2228 printf("duplicated %s %u at index %u and %u\n",
2229 item_name, parsed_items[i], i, j);
2237 struct cmd_set_list_result {
2238 cmdline_fixed_string_t cmd_keyword;
2239 cmdline_fixed_string_t list_name;
2240 cmdline_fixed_string_t list_of_items;
2243 static void cmd_set_list_parsed(void *parsed_result,
2244 __attribute__((unused)) struct cmdline *cl,
2245 __attribute__((unused)) void *data)
2247 struct cmd_set_list_result *res;
2249 unsigned int lcorelist[RTE_MAX_LCORE];
2250 unsigned int portlist[RTE_MAX_ETHPORTS];
2252 unsigned int nb_item;
2254 if (test_done == 0) {
2255 printf("Please stop forwarding first\n");
2259 res = parsed_result;
2260 if (!strcmp(res->list_name, "corelist")) {
2261 nb_item = parse_item_list(res->list_of_items, "core",
2263 parsed_items.lcorelist, 1);
2265 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2268 if (!strcmp(res->list_name, "portlist")) {
2269 nb_item = parse_item_list(res->list_of_items, "port",
2271 parsed_items.portlist, 1);
2273 set_fwd_ports_list(parsed_items.portlist, nb_item);
2277 cmdline_parse_token_string_t cmd_set_list_keyword =
2278 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2280 cmdline_parse_token_string_t cmd_set_list_name =
2281 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2282 "corelist#portlist");
2283 cmdline_parse_token_string_t cmd_set_list_of_items =
2284 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2287 cmdline_parse_inst_t cmd_set_fwd_list = {
2288 .f = cmd_set_list_parsed,
2290 .help_str = "set corelist|portlist x[,y]*",
2292 (void *)&cmd_set_list_keyword,
2293 (void *)&cmd_set_list_name,
2294 (void *)&cmd_set_list_of_items,
2299 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2301 struct cmd_setmask_result {
2302 cmdline_fixed_string_t set;
2303 cmdline_fixed_string_t mask;
2307 static void cmd_set_mask_parsed(void *parsed_result,
2308 __attribute__((unused)) struct cmdline *cl,
2309 __attribute__((unused)) void *data)
2311 struct cmd_setmask_result *res = parsed_result;
2313 if (test_done == 0) {
2314 printf("Please stop forwarding first\n");
2317 if (!strcmp(res->mask, "coremask"))
2318 set_fwd_lcores_mask(res->hexavalue);
2319 else if (!strcmp(res->mask, "portmask"))
2320 set_fwd_ports_mask(res->hexavalue);
2323 cmdline_parse_token_string_t cmd_setmask_set =
2324 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2325 cmdline_parse_token_string_t cmd_setmask_mask =
2326 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2327 "coremask#portmask");
2328 cmdline_parse_token_num_t cmd_setmask_value =
2329 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2331 cmdline_parse_inst_t cmd_set_fwd_mask = {
2332 .f = cmd_set_mask_parsed,
2334 .help_str = "set coremask|portmask hexadecimal value",
2336 (void *)&cmd_setmask_set,
2337 (void *)&cmd_setmask_mask,
2338 (void *)&cmd_setmask_value,
2344 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2346 struct cmd_set_result {
2347 cmdline_fixed_string_t set;
2348 cmdline_fixed_string_t what;
2352 static void cmd_set_parsed(void *parsed_result,
2353 __attribute__((unused)) struct cmdline *cl,
2354 __attribute__((unused)) void *data)
2356 struct cmd_set_result *res = parsed_result;
2357 if (!strcmp(res->what, "nbport"))
2358 set_fwd_ports_number(res->value);
2359 else if (!strcmp(res->what, "nbcore"))
2360 set_fwd_lcores_number(res->value);
2361 else if (!strcmp(res->what, "burst"))
2362 set_nb_pkt_per_burst(res->value);
2363 else if (!strcmp(res->what, "verbose"))
2364 set_verbose_level(res->value);
2367 cmdline_parse_token_string_t cmd_set_set =
2368 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2369 cmdline_parse_token_string_t cmd_set_what =
2370 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2371 "nbport#nbcore#burst#verbose");
2372 cmdline_parse_token_num_t cmd_set_value =
2373 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2375 cmdline_parse_inst_t cmd_set_numbers = {
2376 .f = cmd_set_parsed,
2378 .help_str = "set nbport|nbcore|burst|verbose value",
2380 (void *)&cmd_set_set,
2381 (void *)&cmd_set_what,
2382 (void *)&cmd_set_value,
2387 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2389 struct cmd_set_txpkts_result {
2390 cmdline_fixed_string_t cmd_keyword;
2391 cmdline_fixed_string_t txpkts;
2392 cmdline_fixed_string_t seg_lengths;
2396 cmd_set_txpkts_parsed(void *parsed_result,
2397 __attribute__((unused)) struct cmdline *cl,
2398 __attribute__((unused)) void *data)
2400 struct cmd_set_txpkts_result *res;
2401 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2402 unsigned int nb_segs;
2404 res = parsed_result;
2405 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2406 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2408 set_tx_pkt_segments(seg_lengths, nb_segs);
2411 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2412 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2413 cmd_keyword, "set");
2414 cmdline_parse_token_string_t cmd_set_txpkts_name =
2415 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2417 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2418 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2421 cmdline_parse_inst_t cmd_set_txpkts = {
2422 .f = cmd_set_txpkts_parsed,
2424 .help_str = "set txpkts x[,y]*",
2426 (void *)&cmd_set_txpkts_keyword,
2427 (void *)&cmd_set_txpkts_name,
2428 (void *)&cmd_set_txpkts_lengths,
2433 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2434 struct cmd_rx_vlan_filter_all_result {
2435 cmdline_fixed_string_t rx_vlan;
2436 cmdline_fixed_string_t what;
2437 cmdline_fixed_string_t all;
2442 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2443 __attribute__((unused)) struct cmdline *cl,
2444 __attribute__((unused)) void *data)
2446 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2448 if (!strcmp(res->what, "add"))
2449 rx_vlan_all_filter_set(res->port_id, 1);
2451 rx_vlan_all_filter_set(res->port_id, 0);
2454 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2455 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2456 rx_vlan, "rx_vlan");
2457 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2458 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2460 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2461 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2463 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2464 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2467 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2468 .f = cmd_rx_vlan_filter_all_parsed,
2470 .help_str = "add/remove all identifiers to/from the set of VLAN "
2471 "Identifiers filtered by a port",
2473 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2474 (void *)&cmd_rx_vlan_filter_all_what,
2475 (void *)&cmd_rx_vlan_filter_all_all,
2476 (void *)&cmd_rx_vlan_filter_all_portid,
2481 /* *** VLAN OFFLOAD SET ON A PORT *** */
2482 struct cmd_vlan_offload_result {
2483 cmdline_fixed_string_t vlan;
2484 cmdline_fixed_string_t set;
2485 cmdline_fixed_string_t what;
2486 cmdline_fixed_string_t on;
2487 cmdline_fixed_string_t port_id;
2491 cmd_vlan_offload_parsed(void *parsed_result,
2492 __attribute__((unused)) struct cmdline *cl,
2493 __attribute__((unused)) void *data)
2496 struct cmd_vlan_offload_result *res = parsed_result;
2499 portid_t port_id = 0;
2503 len = strnlen(str, STR_TOKEN_SIZE);
2505 /* Get port_id first */
2513 tmp = strtoul(str, NULL, 0);
2514 /* If port_id greater that what portid_t can represent, return */
2515 if(tmp >= RTE_MAX_ETHPORTS)
2517 port_id = (portid_t)tmp;
2519 if (!strcmp(res->on, "on"))
2524 if (!strcmp(res->what, "strip"))
2525 rx_vlan_strip_set(port_id, on);
2526 else if(!strcmp(res->what, "stripq")){
2527 uint16_t queue_id = 0;
2529 /* No queue_id, return */
2531 printf("must specify (port,queue_id)\n");
2534 tmp = strtoul(str + i + 1, NULL, 0);
2535 /* If queue_id greater that what 16-bits can represent, return */
2539 queue_id = (uint16_t)tmp;
2540 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2542 else if (!strcmp(res->what, "filter"))
2543 rx_vlan_filter_set(port_id, on);
2545 vlan_extend_set(port_id, on);
2550 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2551 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2553 cmdline_parse_token_string_t cmd_vlan_offload_set =
2554 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2556 cmdline_parse_token_string_t cmd_vlan_offload_what =
2557 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2558 what, "strip#filter#qinq#stripq");
2559 cmdline_parse_token_string_t cmd_vlan_offload_on =
2560 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2562 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2563 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2566 cmdline_parse_inst_t cmd_vlan_offload = {
2567 .f = cmd_vlan_offload_parsed,
2569 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2570 " qinq(extended) for both rx/tx sides ",
2572 (void *)&cmd_vlan_offload_vlan,
2573 (void *)&cmd_vlan_offload_set,
2574 (void *)&cmd_vlan_offload_what,
2575 (void *)&cmd_vlan_offload_on,
2576 (void *)&cmd_vlan_offload_portid,
2581 /* *** VLAN TPID SET ON A PORT *** */
2582 struct cmd_vlan_tpid_result {
2583 cmdline_fixed_string_t vlan;
2584 cmdline_fixed_string_t set;
2585 cmdline_fixed_string_t what;
2591 cmd_vlan_tpid_parsed(void *parsed_result,
2592 __attribute__((unused)) struct cmdline *cl,
2593 __attribute__((unused)) void *data)
2595 struct cmd_vlan_tpid_result *res = parsed_result;
2596 vlan_tpid_set(res->port_id, res->tp_id);
2600 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2601 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2603 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2604 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2606 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2607 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2609 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2610 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2612 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2613 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2616 cmdline_parse_inst_t cmd_vlan_tpid = {
2617 .f = cmd_vlan_tpid_parsed,
2619 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2621 (void *)&cmd_vlan_tpid_vlan,
2622 (void *)&cmd_vlan_tpid_set,
2623 (void *)&cmd_vlan_tpid_what,
2624 (void *)&cmd_vlan_tpid_tpid,
2625 (void *)&cmd_vlan_tpid_portid,
2630 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2631 struct cmd_rx_vlan_filter_result {
2632 cmdline_fixed_string_t rx_vlan;
2633 cmdline_fixed_string_t what;
2639 cmd_rx_vlan_filter_parsed(void *parsed_result,
2640 __attribute__((unused)) struct cmdline *cl,
2641 __attribute__((unused)) void *data)
2643 struct cmd_rx_vlan_filter_result *res = parsed_result;
2645 if (!strcmp(res->what, "add"))
2646 rx_vft_set(res->port_id, res->vlan_id, 1);
2648 rx_vft_set(res->port_id, res->vlan_id, 0);
2651 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2652 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2653 rx_vlan, "rx_vlan");
2654 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2655 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2657 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2658 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2660 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2661 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2664 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2665 .f = cmd_rx_vlan_filter_parsed,
2667 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2668 "Identifiers filtered by a port",
2670 (void *)&cmd_rx_vlan_filter_rx_vlan,
2671 (void *)&cmd_rx_vlan_filter_what,
2672 (void *)&cmd_rx_vlan_filter_vlanid,
2673 (void *)&cmd_rx_vlan_filter_portid,
2678 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2679 struct cmd_tx_vlan_set_result {
2680 cmdline_fixed_string_t tx_vlan;
2681 cmdline_fixed_string_t set;
2687 cmd_tx_vlan_set_parsed(void *parsed_result,
2688 __attribute__((unused)) struct cmdline *cl,
2689 __attribute__((unused)) void *data)
2691 struct cmd_tx_vlan_set_result *res = parsed_result;
2692 tx_vlan_set(res->port_id, res->vlan_id);
2695 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2696 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2697 tx_vlan, "tx_vlan");
2698 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2699 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2701 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2702 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2704 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2705 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2708 cmdline_parse_inst_t cmd_tx_vlan_set = {
2709 .f = cmd_tx_vlan_set_parsed,
2711 .help_str = "enable hardware insertion of a VLAN header with a given "
2712 "TAG Identifier in packets sent on a port",
2714 (void *)&cmd_tx_vlan_set_tx_vlan,
2715 (void *)&cmd_tx_vlan_set_set,
2716 (void *)&cmd_tx_vlan_set_vlanid,
2717 (void *)&cmd_tx_vlan_set_portid,
2722 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2723 struct cmd_tx_vlan_set_pvid_result {
2724 cmdline_fixed_string_t tx_vlan;
2725 cmdline_fixed_string_t set;
2726 cmdline_fixed_string_t pvid;
2729 cmdline_fixed_string_t mode;
2733 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2734 __attribute__((unused)) struct cmdline *cl,
2735 __attribute__((unused)) void *data)
2737 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2739 if (strcmp(res->mode, "on") == 0)
2740 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2742 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2745 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2746 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2747 tx_vlan, "tx_vlan");
2748 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2749 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2751 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2752 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2754 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2755 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2757 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2758 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2760 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2761 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2764 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2765 .f = cmd_tx_vlan_set_pvid_parsed,
2767 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2769 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2770 (void *)&cmd_tx_vlan_set_pvid_set,
2771 (void *)&cmd_tx_vlan_set_pvid_pvid,
2772 (void *)&cmd_tx_vlan_set_pvid_port_id,
2773 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2774 (void *)&cmd_tx_vlan_set_pvid_mode,
2779 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2780 struct cmd_tx_vlan_reset_result {
2781 cmdline_fixed_string_t tx_vlan;
2782 cmdline_fixed_string_t reset;
2787 cmd_tx_vlan_reset_parsed(void *parsed_result,
2788 __attribute__((unused)) struct cmdline *cl,
2789 __attribute__((unused)) void *data)
2791 struct cmd_tx_vlan_reset_result *res = parsed_result;
2793 tx_vlan_reset(res->port_id);
2796 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2797 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2798 tx_vlan, "tx_vlan");
2799 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2800 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2802 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2803 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2806 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2807 .f = cmd_tx_vlan_reset_parsed,
2809 .help_str = "disable hardware insertion of a VLAN header in packets "
2812 (void *)&cmd_tx_vlan_reset_tx_vlan,
2813 (void *)&cmd_tx_vlan_reset_reset,
2814 (void *)&cmd_tx_vlan_reset_portid,
2820 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2821 struct cmd_csum_result {
2822 cmdline_fixed_string_t csum;
2823 cmdline_fixed_string_t mode;
2824 cmdline_fixed_string_t proto;
2825 cmdline_fixed_string_t hwsw;
2830 csum_show(int port_id)
2832 struct rte_eth_dev_info dev_info;
2835 ol_flags = ports[port_id].tx_ol_flags;
2836 printf("Parse tunnel is %s\n",
2837 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
2838 printf("IP checksum offload is %s\n",
2839 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2840 printf("UDP checksum offload is %s\n",
2841 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2842 printf("TCP checksum offload is %s\n",
2843 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2844 printf("SCTP checksum offload is %s\n",
2845 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2846 printf("Outer-Ip checksum offload is %s\n",
2847 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
2849 /* display warnings if configuration is not supported by the NIC */
2850 rte_eth_dev_info_get(port_id, &dev_info);
2851 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2852 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2853 printf("Warning: hardware IP checksum enabled but not "
2854 "supported by port %d\n", port_id);
2856 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2857 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2858 printf("Warning: hardware UDP checksum enabled but not "
2859 "supported by port %d\n", port_id);
2861 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2862 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2863 printf("Warning: hardware TCP checksum enabled but not "
2864 "supported by port %d\n", port_id);
2866 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2867 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2868 printf("Warning: hardware SCTP checksum enabled but not "
2869 "supported by port %d\n", port_id);
2871 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
2872 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
2873 printf("Warning: hardware outer IP checksum enabled but not "
2874 "supported by port %d\n", port_id);
2879 cmd_csum_parsed(void *parsed_result,
2880 __attribute__((unused)) struct cmdline *cl,
2881 __attribute__((unused)) void *data)
2883 struct cmd_csum_result *res = parsed_result;
2887 if (port_id_is_invalid(res->port_id)) {
2888 printf("invalid port %d\n", res->port_id);
2892 if (!strcmp(res->mode, "set")) {
2894 if (!strcmp(res->hwsw, "hw"))
2897 if (!strcmp(res->proto, "ip")) {
2898 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2899 } else if (!strcmp(res->proto, "udp")) {
2900 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2901 } else if (!strcmp(res->proto, "tcp")) {
2902 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2903 } else if (!strcmp(res->proto, "sctp")) {
2904 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2905 } else if (!strcmp(res->proto, "outer-ip")) {
2906 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
2910 ports[res->port_id].tx_ol_flags |= mask;
2912 ports[res->port_id].tx_ol_flags &= (~mask);
2914 csum_show(res->port_id);
2917 cmdline_parse_token_string_t cmd_csum_csum =
2918 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2920 cmdline_parse_token_string_t cmd_csum_mode =
2921 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2923 cmdline_parse_token_string_t cmd_csum_proto =
2924 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2925 proto, "ip#tcp#udp#sctp#outer-ip");
2926 cmdline_parse_token_string_t cmd_csum_hwsw =
2927 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2929 cmdline_parse_token_num_t cmd_csum_portid =
2930 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
2933 cmdline_parse_inst_t cmd_csum_set = {
2934 .f = cmd_csum_parsed,
2936 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
2937 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
2939 (void *)&cmd_csum_csum,
2940 (void *)&cmd_csum_mode,
2941 (void *)&cmd_csum_proto,
2942 (void *)&cmd_csum_hwsw,
2943 (void *)&cmd_csum_portid,
2948 cmdline_parse_token_string_t cmd_csum_mode_show =
2949 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2952 cmdline_parse_inst_t cmd_csum_show = {
2953 .f = cmd_csum_parsed,
2955 .help_str = "show checksum offload configuration: csum show <port>",
2957 (void *)&cmd_csum_csum,
2958 (void *)&cmd_csum_mode_show,
2959 (void *)&cmd_csum_portid,
2964 /* Enable/disable tunnel parsing */
2965 struct cmd_csum_tunnel_result {
2966 cmdline_fixed_string_t csum;
2967 cmdline_fixed_string_t parse;
2968 cmdline_fixed_string_t onoff;
2973 cmd_csum_tunnel_parsed(void *parsed_result,
2974 __attribute__((unused)) struct cmdline *cl,
2975 __attribute__((unused)) void *data)
2977 struct cmd_csum_tunnel_result *res = parsed_result;
2979 if (port_id_is_invalid(res->port_id)) {
2980 printf("invalid port %d\n", res->port_id);
2984 if (!strcmp(res->onoff, "on"))
2985 ports[res->port_id].tx_ol_flags |=
2986 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
2988 ports[res->port_id].tx_ol_flags &=
2989 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
2991 csum_show(res->port_id);
2994 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
2995 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
2997 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
2998 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
2999 parse, "parse_tunnel");
3000 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3001 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3003 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3004 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3007 cmdline_parse_inst_t cmd_csum_tunnel = {
3008 .f = cmd_csum_tunnel_parsed,
3010 .help_str = "enable/disable parsing of tunnels for csum engine: "
3011 "csum parse_tunnel on|off <tx-port>",
3013 (void *)&cmd_csum_tunnel_csum,
3014 (void *)&cmd_csum_tunnel_parse,
3015 (void *)&cmd_csum_tunnel_onoff,
3016 (void *)&cmd_csum_tunnel_portid,
3021 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3022 struct cmd_tso_set_result {
3023 cmdline_fixed_string_t tso;
3024 cmdline_fixed_string_t mode;
3030 cmd_tso_set_parsed(void *parsed_result,
3031 __attribute__((unused)) struct cmdline *cl,
3032 __attribute__((unused)) void *data)
3034 struct cmd_tso_set_result *res = parsed_result;
3035 struct rte_eth_dev_info dev_info;
3037 if (port_id_is_invalid(res->port_id))
3040 if (!strcmp(res->mode, "set"))
3041 ports[res->port_id].tso_segsz = res->tso_segsz;
3043 if (ports[res->port_id].tso_segsz == 0)
3044 printf("TSO is disabled\n");
3046 printf("TSO segment size is %d\n",
3047 ports[res->port_id].tso_segsz);
3049 /* display warnings if configuration is not supported by the NIC */
3050 rte_eth_dev_info_get(res->port_id, &dev_info);
3051 if ((ports[res->port_id].tso_segsz != 0) &&
3052 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3053 printf("Warning: TSO enabled but not "
3054 "supported by port %d\n", res->port_id);
3058 cmdline_parse_token_string_t cmd_tso_set_tso =
3059 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3061 cmdline_parse_token_string_t cmd_tso_set_mode =
3062 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3064 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3065 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3067 cmdline_parse_token_num_t cmd_tso_set_portid =
3068 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3071 cmdline_parse_inst_t cmd_tso_set = {
3072 .f = cmd_tso_set_parsed,
3074 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3075 "tso set <tso_segsz> <port>",
3077 (void *)&cmd_tso_set_tso,
3078 (void *)&cmd_tso_set_mode,
3079 (void *)&cmd_tso_set_tso_segsz,
3080 (void *)&cmd_tso_set_portid,
3085 cmdline_parse_token_string_t cmd_tso_show_mode =
3086 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3090 cmdline_parse_inst_t cmd_tso_show = {
3091 .f = cmd_tso_set_parsed,
3093 .help_str = "Show TSO segment size for csum engine: "
3096 (void *)&cmd_tso_set_tso,
3097 (void *)&cmd_tso_show_mode,
3098 (void *)&cmd_tso_set_portid,
3103 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3104 struct cmd_set_flush_rx {
3105 cmdline_fixed_string_t set;
3106 cmdline_fixed_string_t flush_rx;
3107 cmdline_fixed_string_t mode;
3111 cmd_set_flush_rx_parsed(void *parsed_result,
3112 __attribute__((unused)) struct cmdline *cl,
3113 __attribute__((unused)) void *data)
3115 struct cmd_set_flush_rx *res = parsed_result;
3116 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3119 cmdline_parse_token_string_t cmd_setflushrx_set =
3120 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3122 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3123 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3124 flush_rx, "flush_rx");
3125 cmdline_parse_token_string_t cmd_setflushrx_mode =
3126 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3130 cmdline_parse_inst_t cmd_set_flush_rx = {
3131 .f = cmd_set_flush_rx_parsed,
3132 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3135 (void *)&cmd_setflushrx_set,
3136 (void *)&cmd_setflushrx_flush_rx,
3137 (void *)&cmd_setflushrx_mode,
3142 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3143 struct cmd_set_link_check {
3144 cmdline_fixed_string_t set;
3145 cmdline_fixed_string_t link_check;
3146 cmdline_fixed_string_t mode;
3150 cmd_set_link_check_parsed(void *parsed_result,
3151 __attribute__((unused)) struct cmdline *cl,
3152 __attribute__((unused)) void *data)
3154 struct cmd_set_link_check *res = parsed_result;
3155 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3158 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3159 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3161 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3162 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3163 link_check, "link_check");
3164 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3165 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3169 cmdline_parse_inst_t cmd_set_link_check = {
3170 .f = cmd_set_link_check_parsed,
3171 .help_str = "set link_check on|off: enable/disable link status check "
3172 "when starting/stopping a port",
3175 (void *)&cmd_setlinkcheck_set,
3176 (void *)&cmd_setlinkcheck_link_check,
3177 (void *)&cmd_setlinkcheck_mode,
3182 #ifdef RTE_NIC_BYPASS
3183 /* *** SET NIC BYPASS MODE *** */
3184 struct cmd_set_bypass_mode_result {
3185 cmdline_fixed_string_t set;
3186 cmdline_fixed_string_t bypass;
3187 cmdline_fixed_string_t mode;
3188 cmdline_fixed_string_t value;
3193 cmd_set_bypass_mode_parsed(void *parsed_result,
3194 __attribute__((unused)) struct cmdline *cl,
3195 __attribute__((unused)) void *data)
3197 struct cmd_set_bypass_mode_result *res = parsed_result;
3198 portid_t port_id = res->port_id;
3199 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3201 if (!bypass_is_supported(port_id))
3204 if (!strcmp(res->value, "bypass"))
3205 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3206 else if (!strcmp(res->value, "isolate"))
3207 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3209 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3211 /* Set the bypass mode for the relevant port. */
3212 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3213 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3217 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3218 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3220 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3221 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3223 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3224 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3226 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3227 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3228 value, "normal#bypass#isolate");
3229 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3230 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3233 cmdline_parse_inst_t cmd_set_bypass_mode = {
3234 .f = cmd_set_bypass_mode_parsed,
3235 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3236 "Set the NIC bypass mode for port_id",
3239 (void *)&cmd_setbypass_mode_set,
3240 (void *)&cmd_setbypass_mode_bypass,
3241 (void *)&cmd_setbypass_mode_mode,
3242 (void *)&cmd_setbypass_mode_value,
3243 (void *)&cmd_setbypass_mode_port,
3248 /* *** SET NIC BYPASS EVENT *** */
3249 struct cmd_set_bypass_event_result {
3250 cmdline_fixed_string_t set;
3251 cmdline_fixed_string_t bypass;
3252 cmdline_fixed_string_t event;
3253 cmdline_fixed_string_t event_value;
3254 cmdline_fixed_string_t mode;
3255 cmdline_fixed_string_t mode_value;
3260 cmd_set_bypass_event_parsed(void *parsed_result,
3261 __attribute__((unused)) struct cmdline *cl,
3262 __attribute__((unused)) void *data)
3265 struct cmd_set_bypass_event_result *res = parsed_result;
3266 portid_t port_id = res->port_id;
3267 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3268 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3270 if (!bypass_is_supported(port_id))
3273 if (!strcmp(res->event_value, "timeout"))
3274 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3275 else if (!strcmp(res->event_value, "os_on"))
3276 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3277 else if (!strcmp(res->event_value, "os_off"))
3278 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3279 else if (!strcmp(res->event_value, "power_on"))
3280 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3281 else if (!strcmp(res->event_value, "power_off"))
3282 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3284 bypass_event = RTE_BYPASS_EVENT_NONE;
3286 if (!strcmp(res->mode_value, "bypass"))
3287 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3288 else if (!strcmp(res->mode_value, "isolate"))
3289 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3291 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3293 /* Set the watchdog timeout. */
3294 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3297 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3298 (rc = rte_eth_dev_wd_timeout_store(port_id,
3299 bypass_timeout)) != 0) {
3300 printf("Failed to set timeout value %u "
3301 "for port %d, errto code: %d.\n",
3302 bypass_timeout, port_id, rc);
3306 /* Set the bypass event to transition to bypass mode. */
3307 if (0 != rte_eth_dev_bypass_event_store(port_id,
3308 bypass_event, bypass_mode)) {
3309 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3314 cmdline_parse_token_string_t cmd_setbypass_event_set =
3315 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3317 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3318 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3320 cmdline_parse_token_string_t cmd_setbypass_event_event =
3321 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3323 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3324 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3325 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3326 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3327 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3329 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3330 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3331 mode_value, "normal#bypass#isolate");
3332 cmdline_parse_token_num_t cmd_setbypass_event_port =
3333 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3336 cmdline_parse_inst_t cmd_set_bypass_event = {
3337 .f = cmd_set_bypass_event_parsed,
3338 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3339 "mode (normal|bypass|isolate) (port_id): "
3340 "Set the NIC bypass event mode for port_id",
3343 (void *)&cmd_setbypass_event_set,
3344 (void *)&cmd_setbypass_event_bypass,
3345 (void *)&cmd_setbypass_event_event,
3346 (void *)&cmd_setbypass_event_event_value,
3347 (void *)&cmd_setbypass_event_mode,
3348 (void *)&cmd_setbypass_event_mode_value,
3349 (void *)&cmd_setbypass_event_port,
3355 /* *** SET NIC BYPASS TIMEOUT *** */
3356 struct cmd_set_bypass_timeout_result {
3357 cmdline_fixed_string_t set;
3358 cmdline_fixed_string_t bypass;
3359 cmdline_fixed_string_t timeout;
3360 cmdline_fixed_string_t value;
3364 cmd_set_bypass_timeout_parsed(void *parsed_result,
3365 __attribute__((unused)) struct cmdline *cl,
3366 __attribute__((unused)) void *data)
3368 struct cmd_set_bypass_timeout_result *res = parsed_result;
3370 if (!strcmp(res->value, "1.5"))
3371 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3372 else if (!strcmp(res->value, "2"))
3373 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3374 else if (!strcmp(res->value, "3"))
3375 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3376 else if (!strcmp(res->value, "4"))
3377 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3378 else if (!strcmp(res->value, "8"))
3379 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3380 else if (!strcmp(res->value, "16"))
3381 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3382 else if (!strcmp(res->value, "32"))
3383 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3385 bypass_timeout = RTE_BYPASS_TMT_OFF;
3388 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3389 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3391 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3392 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3394 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3395 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3396 timeout, "timeout");
3397 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3398 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3399 value, "0#1.5#2#3#4#8#16#32");
3401 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3402 .f = cmd_set_bypass_timeout_parsed,
3403 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3404 "Set the NIC bypass watchdog timeout",
3407 (void *)&cmd_setbypass_timeout_set,
3408 (void *)&cmd_setbypass_timeout_bypass,
3409 (void *)&cmd_setbypass_timeout_timeout,
3410 (void *)&cmd_setbypass_timeout_value,
3415 /* *** SHOW NIC BYPASS MODE *** */
3416 struct cmd_show_bypass_config_result {
3417 cmdline_fixed_string_t show;
3418 cmdline_fixed_string_t bypass;
3419 cmdline_fixed_string_t config;
3424 cmd_show_bypass_config_parsed(void *parsed_result,
3425 __attribute__((unused)) struct cmdline *cl,
3426 __attribute__((unused)) void *data)
3428 struct cmd_show_bypass_config_result *res = parsed_result;
3429 uint32_t event_mode;
3430 uint32_t bypass_mode;
3431 portid_t port_id = res->port_id;
3432 uint32_t timeout = bypass_timeout;
3435 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3436 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3437 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3438 {"UNKNOWN", "normal", "bypass", "isolate"};
3439 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3446 int num_events = (sizeof events) / (sizeof events[0]);
3448 if (!bypass_is_supported(port_id))
3451 /* Display the bypass mode.*/
3452 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3453 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3457 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3458 bypass_mode = RTE_BYPASS_MODE_NONE;
3460 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3463 /* Display the bypass timeout.*/
3464 if (!RTE_BYPASS_TMT_VALID(timeout))
3465 timeout = RTE_BYPASS_TMT_OFF;
3467 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3469 /* Display the bypass events and associated modes. */
3470 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3472 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3473 printf("\tFailed to get bypass mode for event = %s\n",
3476 if (!RTE_BYPASS_MODE_VALID(event_mode))
3477 event_mode = RTE_BYPASS_MODE_NONE;
3479 printf("\tbypass event: %-16s = %s\n", events[i],
3485 cmdline_parse_token_string_t cmd_showbypass_config_show =
3486 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3488 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3489 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3491 cmdline_parse_token_string_t cmd_showbypass_config_config =
3492 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3494 cmdline_parse_token_num_t cmd_showbypass_config_port =
3495 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3498 cmdline_parse_inst_t cmd_show_bypass_config = {
3499 .f = cmd_show_bypass_config_parsed,
3500 .help_str = "show bypass config (port_id): "
3501 "Show the NIC bypass config for port_id",
3504 (void *)&cmd_showbypass_config_show,
3505 (void *)&cmd_showbypass_config_bypass,
3506 (void *)&cmd_showbypass_config_config,
3507 (void *)&cmd_showbypass_config_port,
3513 #ifdef RTE_LIBRTE_PMD_BOND
3514 /* *** SET BONDING MODE *** */
3515 struct cmd_set_bonding_mode_result {
3516 cmdline_fixed_string_t set;
3517 cmdline_fixed_string_t bonding;
3518 cmdline_fixed_string_t mode;
3523 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3524 __attribute__((unused)) struct cmdline *cl,
3525 __attribute__((unused)) void *data)
3527 struct cmd_set_bonding_mode_result *res = parsed_result;
3528 portid_t port_id = res->port_id;
3530 /* Set the bonding mode for the relevant port. */
3531 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3532 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3535 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3536 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3538 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3539 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3540 bonding, "bonding");
3541 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3542 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3544 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3545 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3547 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3548 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3551 cmdline_parse_inst_t cmd_set_bonding_mode = {
3552 .f = cmd_set_bonding_mode_parsed,
3553 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3556 (void *) &cmd_setbonding_mode_set,
3557 (void *) &cmd_setbonding_mode_bonding,
3558 (void *) &cmd_setbonding_mode_mode,
3559 (void *) &cmd_setbonding_mode_value,
3560 (void *) &cmd_setbonding_mode_port,
3565 /* *** SET BALANCE XMIT POLICY *** */
3566 struct cmd_set_bonding_balance_xmit_policy_result {
3567 cmdline_fixed_string_t set;
3568 cmdline_fixed_string_t bonding;
3569 cmdline_fixed_string_t balance_xmit_policy;
3571 cmdline_fixed_string_t policy;
3574 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3575 __attribute__((unused)) struct cmdline *cl,
3576 __attribute__((unused)) void *data)
3578 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3579 portid_t port_id = res->port_id;
3582 if (!strcmp(res->policy, "l2")) {
3583 policy = BALANCE_XMIT_POLICY_LAYER2;
3584 } else if (!strcmp(res->policy, "l23")) {
3585 policy = BALANCE_XMIT_POLICY_LAYER23;
3586 } else if (!strcmp(res->policy, "l34")) {
3587 policy = BALANCE_XMIT_POLICY_LAYER34;
3589 printf("\t Invalid xmit policy selection");
3593 /* Set the bonding mode for the relevant port. */
3594 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3595 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3600 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3601 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3603 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3604 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3605 bonding, "bonding");
3606 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3607 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3608 balance_xmit_policy, "balance_xmit_policy");
3609 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3610 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3612 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3613 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3614 policy, "l2#l23#l34");
3616 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3617 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3618 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3621 (void *)&cmd_setbonding_balance_xmit_policy_set,
3622 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3623 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3624 (void *)&cmd_setbonding_balance_xmit_policy_port,
3625 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3630 /* *** SHOW NIC BONDING CONFIGURATION *** */
3631 struct cmd_show_bonding_config_result {
3632 cmdline_fixed_string_t show;
3633 cmdline_fixed_string_t bonding;
3634 cmdline_fixed_string_t config;
3638 static void cmd_show_bonding_config_parsed(void *parsed_result,
3639 __attribute__((unused)) struct cmdline *cl,
3640 __attribute__((unused)) void *data)
3642 struct cmd_show_bonding_config_result *res = parsed_result;
3644 uint8_t slaves[RTE_MAX_ETHPORTS];
3645 int num_slaves, num_active_slaves;
3648 portid_t port_id = res->port_id;
3650 /* Display the bonding mode.*/
3651 bonding_mode = rte_eth_bond_mode_get(port_id);
3652 if (bonding_mode < 0) {
3653 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3656 printf("\tBonding mode: %d\n", bonding_mode);
3658 if (bonding_mode == BONDING_MODE_BALANCE) {
3659 int balance_xmit_policy;
3661 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3662 if (balance_xmit_policy < 0) {
3663 printf("\tFailed to get balance xmit policy for port = %d\n",
3667 printf("\tBalance Xmit Policy: ");
3669 switch (balance_xmit_policy) {
3670 case BALANCE_XMIT_POLICY_LAYER2:
3671 printf("BALANCE_XMIT_POLICY_LAYER2");
3673 case BALANCE_XMIT_POLICY_LAYER23:
3674 printf("BALANCE_XMIT_POLICY_LAYER23");
3676 case BALANCE_XMIT_POLICY_LAYER34:
3677 printf("BALANCE_XMIT_POLICY_LAYER34");
3684 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3686 if (num_slaves < 0) {
3687 printf("\tFailed to get slave list for port = %d\n", port_id);
3690 if (num_slaves > 0) {
3691 printf("\tSlaves (%d): [", num_slaves);
3692 for (i = 0; i < num_slaves - 1; i++)
3693 printf("%d ", slaves[i]);
3695 printf("%d]\n", slaves[num_slaves - 1]);
3697 printf("\tSlaves: []\n");
3701 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3704 if (num_active_slaves < 0) {
3705 printf("\tFailed to get active slave list for port = %d\n", port_id);
3708 if (num_active_slaves > 0) {
3709 printf("\tActive Slaves (%d): [", num_active_slaves);
3710 for (i = 0; i < num_active_slaves - 1; i++)
3711 printf("%d ", slaves[i]);
3713 printf("%d]\n", slaves[num_active_slaves - 1]);
3716 printf("\tActive Slaves: []\n");
3720 primary_id = rte_eth_bond_primary_get(port_id);
3721 if (primary_id < 0) {
3722 printf("\tFailed to get primary slave for port = %d\n", port_id);
3725 printf("\tPrimary: [%d]\n", primary_id);
3729 cmdline_parse_token_string_t cmd_showbonding_config_show =
3730 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3732 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3733 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3734 bonding, "bonding");
3735 cmdline_parse_token_string_t cmd_showbonding_config_config =
3736 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3738 cmdline_parse_token_num_t cmd_showbonding_config_port =
3739 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3742 cmdline_parse_inst_t cmd_show_bonding_config = {
3743 .f = cmd_show_bonding_config_parsed,
3744 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3747 (void *)&cmd_showbonding_config_show,
3748 (void *)&cmd_showbonding_config_bonding,
3749 (void *)&cmd_showbonding_config_config,
3750 (void *)&cmd_showbonding_config_port,
3755 /* *** SET BONDING PRIMARY *** */
3756 struct cmd_set_bonding_primary_result {
3757 cmdline_fixed_string_t set;
3758 cmdline_fixed_string_t bonding;
3759 cmdline_fixed_string_t primary;
3764 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3765 __attribute__((unused)) struct cmdline *cl,
3766 __attribute__((unused)) void *data)
3768 struct cmd_set_bonding_primary_result *res = parsed_result;
3769 portid_t master_port_id = res->port_id;
3770 portid_t slave_port_id = res->slave_id;
3772 /* Set the primary slave for a bonded device. */
3773 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3774 printf("\t Failed to set primary slave for port = %d.\n",
3781 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3782 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3784 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3785 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3786 bonding, "bonding");
3787 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3788 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3789 primary, "primary");
3790 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3791 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3793 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3794 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3797 cmdline_parse_inst_t cmd_set_bonding_primary = {
3798 .f = cmd_set_bonding_primary_parsed,
3799 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3802 (void *)&cmd_setbonding_primary_set,
3803 (void *)&cmd_setbonding_primary_bonding,
3804 (void *)&cmd_setbonding_primary_primary,
3805 (void *)&cmd_setbonding_primary_slave,
3806 (void *)&cmd_setbonding_primary_port,
3811 /* *** ADD SLAVE *** */
3812 struct cmd_add_bonding_slave_result {
3813 cmdline_fixed_string_t add;
3814 cmdline_fixed_string_t bonding;
3815 cmdline_fixed_string_t slave;
3820 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3821 __attribute__((unused)) struct cmdline *cl,
3822 __attribute__((unused)) void *data)
3824 struct cmd_add_bonding_slave_result *res = parsed_result;
3825 portid_t master_port_id = res->port_id;
3826 portid_t slave_port_id = res->slave_id;
3828 /* Set the primary slave for a bonded device. */
3829 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3830 printf("\t Failed to add slave %d to master port = %d.\n",
3831 slave_port_id, master_port_id);
3837 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3838 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3840 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3841 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3842 bonding, "bonding");
3843 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3844 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3846 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3847 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3849 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3850 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3853 cmdline_parse_inst_t cmd_add_bonding_slave = {
3854 .f = cmd_add_bonding_slave_parsed,
3855 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3858 (void *)&cmd_addbonding_slave_add,
3859 (void *)&cmd_addbonding_slave_bonding,
3860 (void *)&cmd_addbonding_slave_slave,
3861 (void *)&cmd_addbonding_slave_slaveid,
3862 (void *)&cmd_addbonding_slave_port,
3867 /* *** REMOVE SLAVE *** */
3868 struct cmd_remove_bonding_slave_result {
3869 cmdline_fixed_string_t remove;
3870 cmdline_fixed_string_t bonding;
3871 cmdline_fixed_string_t slave;
3876 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3877 __attribute__((unused)) struct cmdline *cl,
3878 __attribute__((unused)) void *data)
3880 struct cmd_remove_bonding_slave_result *res = parsed_result;
3881 portid_t master_port_id = res->port_id;
3882 portid_t slave_port_id = res->slave_id;
3884 /* Set the primary slave for a bonded device. */
3885 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3886 printf("\t Failed to remove slave %d from master port = %d.\n",
3887 slave_port_id, master_port_id);
3893 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3894 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3896 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3897 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3898 bonding, "bonding");
3899 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3900 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3902 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3903 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3905 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3906 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3909 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3910 .f = cmd_remove_bonding_slave_parsed,
3911 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3914 (void *)&cmd_removebonding_slave_remove,
3915 (void *)&cmd_removebonding_slave_bonding,
3916 (void *)&cmd_removebonding_slave_slave,
3917 (void *)&cmd_removebonding_slave_slaveid,
3918 (void *)&cmd_removebonding_slave_port,
3923 /* *** CREATE BONDED DEVICE *** */
3924 struct cmd_create_bonded_device_result {
3925 cmdline_fixed_string_t create;
3926 cmdline_fixed_string_t bonded;
3927 cmdline_fixed_string_t device;
3932 static int bond_dev_num = 0;
3934 static void cmd_create_bonded_device_parsed(void *parsed_result,
3935 __attribute__((unused)) struct cmdline *cl,
3936 __attribute__((unused)) void *data)
3938 struct cmd_create_bonded_device_result *res = parsed_result;
3939 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3942 if (test_done == 0) {
3943 printf("Please stop forwarding first\n");
3947 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3950 /* Create a new bonded device. */
3951 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3953 printf("\t Failed to create bonded device.\n");
3956 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3959 /* Update number of ports */
3960 nb_ports = rte_eth_dev_count();
3961 reconfig(port_id, res->socket);
3962 rte_eth_promiscuous_enable(port_id);
3967 cmdline_parse_token_string_t cmd_createbonded_device_create =
3968 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3970 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3971 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3973 cmdline_parse_token_string_t cmd_createbonded_device_device =
3974 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3976 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3977 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3979 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3980 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3983 cmdline_parse_inst_t cmd_create_bonded_device = {
3984 .f = cmd_create_bonded_device_parsed,
3985 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3988 (void *)&cmd_createbonded_device_create,
3989 (void *)&cmd_createbonded_device_bonded,
3990 (void *)&cmd_createbonded_device_device,
3991 (void *)&cmd_createbonded_device_mode,
3992 (void *)&cmd_createbonded_device_socket,
3997 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3998 struct cmd_set_bond_mac_addr_result {
3999 cmdline_fixed_string_t set;
4000 cmdline_fixed_string_t bonding;
4001 cmdline_fixed_string_t mac_addr;
4003 struct ether_addr address;
4006 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4007 __attribute__((unused)) struct cmdline *cl,
4008 __attribute__((unused)) void *data)
4010 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4013 if (res->port_num >= nb_ports) {
4014 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4018 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4020 /* check the return value and print it if is < 0 */
4022 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4025 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4026 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4027 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4028 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4030 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4031 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4033 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4034 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4035 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4036 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4038 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4039 .f = cmd_set_bond_mac_addr_parsed,
4041 .help_str = "set bonding mac_addr (port_id) (address): ",
4043 (void *)&cmd_set_bond_mac_addr_set,
4044 (void *)&cmd_set_bond_mac_addr_bonding,
4045 (void *)&cmd_set_bond_mac_addr_mac,
4046 (void *)&cmd_set_bond_mac_addr_portnum,
4047 (void *)&cmd_set_bond_mac_addr_addr,
4053 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4054 struct cmd_set_bond_mon_period_result {
4055 cmdline_fixed_string_t set;
4056 cmdline_fixed_string_t bonding;
4057 cmdline_fixed_string_t mon_period;
4062 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4063 __attribute__((unused)) struct cmdline *cl,
4064 __attribute__((unused)) void *data)
4066 struct cmd_set_bond_mon_period_result *res = parsed_result;
4069 if (res->port_num >= nb_ports) {
4070 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4074 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4076 /* check the return value and print it if is < 0 */
4078 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4081 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4082 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4084 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4085 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4086 bonding, "bonding");
4087 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4088 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4089 mon_period, "mon_period");
4090 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4091 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4093 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4094 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4097 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4098 .f = cmd_set_bond_mon_period_parsed,
4100 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4102 (void *)&cmd_set_bond_mon_period_set,
4103 (void *)&cmd_set_bond_mon_period_bonding,
4104 (void *)&cmd_set_bond_mon_period_mon_period,
4105 (void *)&cmd_set_bond_mon_period_portnum,
4106 (void *)&cmd_set_bond_mon_period_period_ms,
4111 #endif /* RTE_LIBRTE_PMD_BOND */
4113 /* *** SET FORWARDING MODE *** */
4114 struct cmd_set_fwd_mode_result {
4115 cmdline_fixed_string_t set;
4116 cmdline_fixed_string_t fwd;
4117 cmdline_fixed_string_t mode;
4120 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4121 __attribute__((unused)) struct cmdline *cl,
4122 __attribute__((unused)) void *data)
4124 struct cmd_set_fwd_mode_result *res = parsed_result;
4126 set_pkt_forwarding_mode(res->mode);
4129 cmdline_parse_token_string_t cmd_setfwd_set =
4130 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4131 cmdline_parse_token_string_t cmd_setfwd_fwd =
4132 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4133 cmdline_parse_token_string_t cmd_setfwd_mode =
4134 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4135 "" /* defined at init */);
4137 cmdline_parse_inst_t cmd_set_fwd_mode = {
4138 .f = cmd_set_fwd_mode_parsed,
4140 .help_str = NULL, /* defined at init */
4142 (void *)&cmd_setfwd_set,
4143 (void *)&cmd_setfwd_fwd,
4144 (void *)&cmd_setfwd_mode,
4149 static void cmd_set_fwd_mode_init(void)
4152 static char token[128];
4153 static char help[256];
4154 cmdline_parse_token_string_t *token_struct;
4156 modes = list_pkt_forwarding_modes();
4157 snprintf(help, sizeof help, "set fwd %s - "
4158 "set packet forwarding mode", modes);
4159 cmd_set_fwd_mode.help_str = help;
4161 /* string token separator is # */
4162 for (c = token; *modes != '\0'; modes++)
4167 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4168 token_struct->string_data.str = token;
4171 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4172 struct cmd_set_burst_tx_retry_result {
4173 cmdline_fixed_string_t set;
4174 cmdline_fixed_string_t burst;
4175 cmdline_fixed_string_t tx;
4176 cmdline_fixed_string_t delay;
4178 cmdline_fixed_string_t retry;
4182 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4183 __attribute__((unused)) struct cmdline *cl,
4184 __attribute__((unused)) void *data)
4186 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4188 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4189 && !strcmp(res->tx, "tx")) {
4190 if (!strcmp(res->delay, "delay"))
4191 burst_tx_delay_time = res->time;
4192 if (!strcmp(res->retry, "retry"))
4193 burst_tx_retry_num = res->retry_num;
4198 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4199 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4200 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4201 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4203 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4204 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4205 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4206 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4207 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4208 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4209 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4210 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4211 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4212 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4214 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4215 .f = cmd_set_burst_tx_retry_parsed,
4216 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4218 (void *)&cmd_set_burst_tx_retry_set,
4219 (void *)&cmd_set_burst_tx_retry_burst,
4220 (void *)&cmd_set_burst_tx_retry_tx,
4221 (void *)&cmd_set_burst_tx_retry_delay,
4222 (void *)&cmd_set_burst_tx_retry_time,
4223 (void *)&cmd_set_burst_tx_retry_retry,
4224 (void *)&cmd_set_burst_tx_retry_retry_num,
4229 /* *** SET PROMISC MODE *** */
4230 struct cmd_set_promisc_mode_result {
4231 cmdline_fixed_string_t set;
4232 cmdline_fixed_string_t promisc;
4233 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4234 uint8_t port_num; /* valid if "allports" argument == 0 */
4235 cmdline_fixed_string_t mode;
4238 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4239 __attribute__((unused)) struct cmdline *cl,
4242 struct cmd_set_promisc_mode_result *res = parsed_result;
4246 if (!strcmp(res->mode, "on"))
4253 for (i = 0; i < nb_ports; i++) {
4255 rte_eth_promiscuous_enable(i);
4257 rte_eth_promiscuous_disable(i);
4262 rte_eth_promiscuous_enable(res->port_num);
4264 rte_eth_promiscuous_disable(res->port_num);
4268 cmdline_parse_token_string_t cmd_setpromisc_set =
4269 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4270 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4271 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4273 cmdline_parse_token_string_t cmd_setpromisc_portall =
4274 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4276 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4277 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4279 cmdline_parse_token_string_t cmd_setpromisc_mode =
4280 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4283 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4284 .f = cmd_set_promisc_mode_parsed,
4286 .help_str = "set promisc all on|off: set promisc mode for all ports",
4288 (void *)&cmd_setpromisc_set,
4289 (void *)&cmd_setpromisc_promisc,
4290 (void *)&cmd_setpromisc_portall,
4291 (void *)&cmd_setpromisc_mode,
4296 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4297 .f = cmd_set_promisc_mode_parsed,
4299 .help_str = "set promisc X on|off: set promisc mode on port X",
4301 (void *)&cmd_setpromisc_set,
4302 (void *)&cmd_setpromisc_promisc,
4303 (void *)&cmd_setpromisc_portnum,
4304 (void *)&cmd_setpromisc_mode,
4309 /* *** SET ALLMULTI MODE *** */
4310 struct cmd_set_allmulti_mode_result {
4311 cmdline_fixed_string_t set;
4312 cmdline_fixed_string_t allmulti;
4313 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4314 uint8_t port_num; /* valid if "allports" argument == 0 */
4315 cmdline_fixed_string_t mode;
4318 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4319 __attribute__((unused)) struct cmdline *cl,
4322 struct cmd_set_allmulti_mode_result *res = parsed_result;
4326 if (!strcmp(res->mode, "on"))
4333 for (i = 0; i < nb_ports; i++) {
4335 rte_eth_allmulticast_enable(i);
4337 rte_eth_allmulticast_disable(i);
4342 rte_eth_allmulticast_enable(res->port_num);
4344 rte_eth_allmulticast_disable(res->port_num);
4348 cmdline_parse_token_string_t cmd_setallmulti_set =
4349 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4350 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4351 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4353 cmdline_parse_token_string_t cmd_setallmulti_portall =
4354 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4356 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4357 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4359 cmdline_parse_token_string_t cmd_setallmulti_mode =
4360 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4363 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4364 .f = cmd_set_allmulti_mode_parsed,
4366 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4368 (void *)&cmd_setallmulti_set,
4369 (void *)&cmd_setallmulti_allmulti,
4370 (void *)&cmd_setallmulti_portall,
4371 (void *)&cmd_setallmulti_mode,
4376 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4377 .f = cmd_set_allmulti_mode_parsed,
4379 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4381 (void *)&cmd_setallmulti_set,
4382 (void *)&cmd_setallmulti_allmulti,
4383 (void *)&cmd_setallmulti_portnum,
4384 (void *)&cmd_setallmulti_mode,
4389 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4390 struct cmd_link_flow_ctrl_set_result {
4391 cmdline_fixed_string_t set;
4392 cmdline_fixed_string_t flow_ctrl;
4393 cmdline_fixed_string_t rx;
4394 cmdline_fixed_string_t rx_lfc_mode;
4395 cmdline_fixed_string_t tx;
4396 cmdline_fixed_string_t tx_lfc_mode;
4397 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4398 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4399 cmdline_fixed_string_t autoneg_str;
4400 cmdline_fixed_string_t autoneg;
4401 cmdline_fixed_string_t hw_str;
4402 uint32_t high_water;
4403 cmdline_fixed_string_t lw_str;
4405 cmdline_fixed_string_t pt_str;
4406 uint16_t pause_time;
4407 cmdline_fixed_string_t xon_str;
4412 cmdline_parse_token_string_t cmd_lfc_set_set =
4413 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4415 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4416 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4417 flow_ctrl, "flow_ctrl");
4418 cmdline_parse_token_string_t cmd_lfc_set_rx =
4419 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4421 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4423 rx_lfc_mode, "on#off");
4424 cmdline_parse_token_string_t cmd_lfc_set_tx =
4425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4427 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4429 tx_lfc_mode, "on#off");
4430 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4431 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4432 hw_str, "high_water");
4433 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4434 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4435 high_water, UINT32);
4436 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4437 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4438 lw_str, "low_water");
4439 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4440 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4442 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4443 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4444 pt_str, "pause_time");
4445 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4446 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4447 pause_time, UINT16);
4448 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4449 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4450 xon_str, "send_xon");
4451 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4452 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4454 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4455 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4456 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4457 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4458 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4459 mac_ctrl_frame_fwd_mode, "on#off");
4460 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4461 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4462 autoneg_str, "autoneg");
4463 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4464 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4466 cmdline_parse_token_num_t cmd_lfc_set_portid =
4467 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4470 /* forward declaration */
4472 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4475 cmdline_parse_inst_t cmd_link_flow_control_set = {
4476 .f = cmd_link_flow_ctrl_set_parsed,
4478 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4479 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4480 autoneg on|off port_id",
4482 (void *)&cmd_lfc_set_set,
4483 (void *)&cmd_lfc_set_flow_ctrl,
4484 (void *)&cmd_lfc_set_rx,
4485 (void *)&cmd_lfc_set_rx_mode,
4486 (void *)&cmd_lfc_set_tx,
4487 (void *)&cmd_lfc_set_tx_mode,
4488 (void *)&cmd_lfc_set_high_water,
4489 (void *)&cmd_lfc_set_low_water,
4490 (void *)&cmd_lfc_set_pause_time,
4491 (void *)&cmd_lfc_set_send_xon,
4492 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4493 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4494 (void *)&cmd_lfc_set_autoneg_str,
4495 (void *)&cmd_lfc_set_autoneg,
4496 (void *)&cmd_lfc_set_portid,
4501 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4502 .f = cmd_link_flow_ctrl_set_parsed,
4503 .data = (void *)&cmd_link_flow_control_set_rx,
4504 .help_str = "Change rx flow control parameter: set flow_ctrl "
4505 "rx on|off port_id",
4507 (void *)&cmd_lfc_set_set,
4508 (void *)&cmd_lfc_set_flow_ctrl,
4509 (void *)&cmd_lfc_set_rx,
4510 (void *)&cmd_lfc_set_rx_mode,
4511 (void *)&cmd_lfc_set_portid,
4516 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4517 .f = cmd_link_flow_ctrl_set_parsed,
4518 .data = (void *)&cmd_link_flow_control_set_tx,
4519 .help_str = "Change tx flow control parameter: set flow_ctrl "
4520 "tx on|off port_id",
4522 (void *)&cmd_lfc_set_set,
4523 (void *)&cmd_lfc_set_flow_ctrl,
4524 (void *)&cmd_lfc_set_tx,
4525 (void *)&cmd_lfc_set_tx_mode,
4526 (void *)&cmd_lfc_set_portid,
4531 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4532 .f = cmd_link_flow_ctrl_set_parsed,
4533 .data = (void *)&cmd_link_flow_control_set_hw,
4534 .help_str = "Change high water flow control parameter: set flow_ctrl "
4535 "high_water value port_id",
4537 (void *)&cmd_lfc_set_set,
4538 (void *)&cmd_lfc_set_flow_ctrl,
4539 (void *)&cmd_lfc_set_high_water_str,
4540 (void *)&cmd_lfc_set_high_water,
4541 (void *)&cmd_lfc_set_portid,
4546 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4547 .f = cmd_link_flow_ctrl_set_parsed,
4548 .data = (void *)&cmd_link_flow_control_set_lw,
4549 .help_str = "Change low water flow control parameter: set flow_ctrl "
4550 "low_water value port_id",
4552 (void *)&cmd_lfc_set_set,
4553 (void *)&cmd_lfc_set_flow_ctrl,
4554 (void *)&cmd_lfc_set_low_water_str,
4555 (void *)&cmd_lfc_set_low_water,
4556 (void *)&cmd_lfc_set_portid,
4561 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4562 .f = cmd_link_flow_ctrl_set_parsed,
4563 .data = (void *)&cmd_link_flow_control_set_pt,
4564 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4565 "pause_time value port_id",
4567 (void *)&cmd_lfc_set_set,
4568 (void *)&cmd_lfc_set_flow_ctrl,
4569 (void *)&cmd_lfc_set_pause_time_str,
4570 (void *)&cmd_lfc_set_pause_time,
4571 (void *)&cmd_lfc_set_portid,
4576 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4577 .f = cmd_link_flow_ctrl_set_parsed,
4578 .data = (void *)&cmd_link_flow_control_set_xon,
4579 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4580 "send_xon value port_id",
4582 (void *)&cmd_lfc_set_set,
4583 (void *)&cmd_lfc_set_flow_ctrl,
4584 (void *)&cmd_lfc_set_send_xon_str,
4585 (void *)&cmd_lfc_set_send_xon,
4586 (void *)&cmd_lfc_set_portid,
4591 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4592 .f = cmd_link_flow_ctrl_set_parsed,
4593 .data = (void *)&cmd_link_flow_control_set_macfwd,
4594 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4595 "mac_ctrl_frame_fwd on|off port_id",
4597 (void *)&cmd_lfc_set_set,
4598 (void *)&cmd_lfc_set_flow_ctrl,
4599 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4600 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4601 (void *)&cmd_lfc_set_portid,
4606 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4607 .f = cmd_link_flow_ctrl_set_parsed,
4608 .data = (void *)&cmd_link_flow_control_set_autoneg,
4609 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4610 "autoneg on|off port_id",
4612 (void *)&cmd_lfc_set_set,
4613 (void *)&cmd_lfc_set_flow_ctrl,
4614 (void *)&cmd_lfc_set_autoneg_str,
4615 (void *)&cmd_lfc_set_autoneg,
4616 (void *)&cmd_lfc_set_portid,
4622 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4623 __attribute__((unused)) struct cmdline *cl,
4626 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4627 cmdline_parse_inst_t *cmd = data;
4628 struct rte_eth_fc_conf fc_conf;
4629 int rx_fc_en, tx_fc_en = 0;
4633 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4634 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4635 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4636 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4638 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4639 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4642 /* Partial command line, retrieve current configuration */
4644 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4646 printf("cannot get current flow ctrl parameters, return"
4647 "code = %d\n", ret);
4651 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4652 (fc_conf.mode == RTE_FC_FULL))
4654 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4655 (fc_conf.mode == RTE_FC_FULL))
4659 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4660 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4662 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4663 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4665 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4667 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4668 fc_conf.high_water = res->high_water;
4670 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4671 fc_conf.low_water = res->low_water;
4673 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4674 fc_conf.pause_time = res->pause_time;
4676 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4677 fc_conf.send_xon = res->send_xon;
4679 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4680 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4681 fc_conf.mac_ctrl_frame_fwd = 1;
4683 fc_conf.mac_ctrl_frame_fwd = 0;
4686 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4687 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4689 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4691 printf("bad flow contrl parameter, return code = %d \n", ret);
4694 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4695 struct cmd_priority_flow_ctrl_set_result {
4696 cmdline_fixed_string_t set;
4697 cmdline_fixed_string_t pfc_ctrl;
4698 cmdline_fixed_string_t rx;
4699 cmdline_fixed_string_t rx_pfc_mode;
4700 cmdline_fixed_string_t tx;
4701 cmdline_fixed_string_t tx_pfc_mode;
4702 uint32_t high_water;
4704 uint16_t pause_time;
4710 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4711 __attribute__((unused)) struct cmdline *cl,
4712 __attribute__((unused)) void *data)
4714 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4715 struct rte_eth_pfc_conf pfc_conf;
4716 int rx_fc_enable, tx_fc_enable;
4720 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4721 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4722 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4723 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4725 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4726 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4729 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4730 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4731 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4732 pfc_conf.fc.high_water = res->high_water;
4733 pfc_conf.fc.low_water = res->low_water;
4734 pfc_conf.fc.pause_time = res->pause_time;
4735 pfc_conf.priority = res->priority;
4737 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4739 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4742 cmdline_parse_token_string_t cmd_pfc_set_set =
4743 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4745 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4746 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4747 pfc_ctrl, "pfc_ctrl");
4748 cmdline_parse_token_string_t cmd_pfc_set_rx =
4749 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4751 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4752 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4753 rx_pfc_mode, "on#off");
4754 cmdline_parse_token_string_t cmd_pfc_set_tx =
4755 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4757 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4758 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4759 tx_pfc_mode, "on#off");
4760 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4761 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4762 high_water, UINT32);
4763 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4764 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4766 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4767 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4768 pause_time, UINT16);
4769 cmdline_parse_token_num_t cmd_pfc_set_priority =
4770 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4772 cmdline_parse_token_num_t cmd_pfc_set_portid =
4773 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4776 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4777 .f = cmd_priority_flow_ctrl_set_parsed,
4779 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4780 tx on|off high_water low_water pause_time priority port_id",
4782 (void *)&cmd_pfc_set_set,
4783 (void *)&cmd_pfc_set_flow_ctrl,
4784 (void *)&cmd_pfc_set_rx,
4785 (void *)&cmd_pfc_set_rx_mode,
4786 (void *)&cmd_pfc_set_tx,
4787 (void *)&cmd_pfc_set_tx_mode,
4788 (void *)&cmd_pfc_set_high_water,
4789 (void *)&cmd_pfc_set_low_water,
4790 (void *)&cmd_pfc_set_pause_time,
4791 (void *)&cmd_pfc_set_priority,
4792 (void *)&cmd_pfc_set_portid,
4797 /* *** RESET CONFIGURATION *** */
4798 struct cmd_reset_result {
4799 cmdline_fixed_string_t reset;
4800 cmdline_fixed_string_t def;
4803 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4805 __attribute__((unused)) void *data)
4807 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4808 set_def_fwd_config();
4811 cmdline_parse_token_string_t cmd_reset_set =
4812 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4813 cmdline_parse_token_string_t cmd_reset_def =
4814 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4817 cmdline_parse_inst_t cmd_reset = {
4818 .f = cmd_reset_parsed,
4820 .help_str = "set default: reset default forwarding configuration",
4822 (void *)&cmd_reset_set,
4823 (void *)&cmd_reset_def,
4828 /* *** START FORWARDING *** */
4829 struct cmd_start_result {
4830 cmdline_fixed_string_t start;
4833 cmdline_parse_token_string_t cmd_start_start =
4834 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4836 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4837 __attribute__((unused)) struct cmdline *cl,
4838 __attribute__((unused)) void *data)
4840 start_packet_forwarding(0);
4843 cmdline_parse_inst_t cmd_start = {
4844 .f = cmd_start_parsed,
4846 .help_str = "start packet forwarding",
4848 (void *)&cmd_start_start,
4853 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4854 struct cmd_start_tx_first_result {
4855 cmdline_fixed_string_t start;
4856 cmdline_fixed_string_t tx_first;
4860 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4861 __attribute__((unused)) struct cmdline *cl,
4862 __attribute__((unused)) void *data)
4864 start_packet_forwarding(1);
4867 cmdline_parse_token_string_t cmd_start_tx_first_start =
4868 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4870 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4871 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4872 tx_first, "tx_first");
4874 cmdline_parse_inst_t cmd_start_tx_first = {
4875 .f = cmd_start_tx_first_parsed,
4877 .help_str = "start packet forwarding, after sending 1 burst of packets",
4879 (void *)&cmd_start_tx_first_start,
4880 (void *)&cmd_start_tx_first_tx_first,
4885 /* *** SET LINK UP *** */
4886 struct cmd_set_link_up_result {
4887 cmdline_fixed_string_t set;
4888 cmdline_fixed_string_t link_up;
4889 cmdline_fixed_string_t port;
4893 cmdline_parse_token_string_t cmd_set_link_up_set =
4894 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4895 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4896 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4898 cmdline_parse_token_string_t cmd_set_link_up_port =
4899 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4900 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4901 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4903 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4904 __attribute__((unused)) struct cmdline *cl,
4905 __attribute__((unused)) void *data)
4907 struct cmd_set_link_up_result *res = parsed_result;
4908 dev_set_link_up(res->port_id);
4911 cmdline_parse_inst_t cmd_set_link_up = {
4912 .f = cmd_set_link_up_parsed,
4914 .help_str = "set link-up port (port id)",
4916 (void *)&cmd_set_link_up_set,
4917 (void *)&cmd_set_link_up_link_up,
4918 (void *)&cmd_set_link_up_port,
4919 (void *)&cmd_set_link_up_port_id,
4924 /* *** SET LINK DOWN *** */
4925 struct cmd_set_link_down_result {
4926 cmdline_fixed_string_t set;
4927 cmdline_fixed_string_t link_down;
4928 cmdline_fixed_string_t port;
4932 cmdline_parse_token_string_t cmd_set_link_down_set =
4933 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4934 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4935 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4937 cmdline_parse_token_string_t cmd_set_link_down_port =
4938 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4939 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4940 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4942 static void cmd_set_link_down_parsed(
4943 __attribute__((unused)) void *parsed_result,
4944 __attribute__((unused)) struct cmdline *cl,
4945 __attribute__((unused)) void *data)
4947 struct cmd_set_link_down_result *res = parsed_result;
4948 dev_set_link_down(res->port_id);
4951 cmdline_parse_inst_t cmd_set_link_down = {
4952 .f = cmd_set_link_down_parsed,
4954 .help_str = "set link-down port (port id)",
4956 (void *)&cmd_set_link_down_set,
4957 (void *)&cmd_set_link_down_link_down,
4958 (void *)&cmd_set_link_down_port,
4959 (void *)&cmd_set_link_down_port_id,
4964 /* *** SHOW CFG *** */
4965 struct cmd_showcfg_result {
4966 cmdline_fixed_string_t show;
4967 cmdline_fixed_string_t cfg;
4968 cmdline_fixed_string_t what;
4971 static void cmd_showcfg_parsed(void *parsed_result,
4972 __attribute__((unused)) struct cmdline *cl,
4973 __attribute__((unused)) void *data)
4975 struct cmd_showcfg_result *res = parsed_result;
4976 if (!strcmp(res->what, "rxtx"))
4977 rxtx_config_display();
4978 else if (!strcmp(res->what, "cores"))
4979 fwd_lcores_config_display();
4980 else if (!strcmp(res->what, "fwd"))
4981 fwd_config_display();
4984 cmdline_parse_token_string_t cmd_showcfg_show =
4985 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4986 cmdline_parse_token_string_t cmd_showcfg_port =
4987 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4988 cmdline_parse_token_string_t cmd_showcfg_what =
4989 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4992 cmdline_parse_inst_t cmd_showcfg = {
4993 .f = cmd_showcfg_parsed,
4995 .help_str = "show config rxtx|cores|fwd",
4997 (void *)&cmd_showcfg_show,
4998 (void *)&cmd_showcfg_port,
4999 (void *)&cmd_showcfg_what,
5004 /* *** SHOW ALL PORT INFO *** */
5005 struct cmd_showportall_result {
5006 cmdline_fixed_string_t show;
5007 cmdline_fixed_string_t port;
5008 cmdline_fixed_string_t what;
5009 cmdline_fixed_string_t all;
5012 static void cmd_showportall_parsed(void *parsed_result,
5013 __attribute__((unused)) struct cmdline *cl,
5014 __attribute__((unused)) void *data)
5018 struct cmd_showportall_result *res = parsed_result;
5019 if (!strcmp(res->show, "clear")) {
5020 if (!strcmp(res->what, "stats"))
5021 for (i = 0; i < nb_ports; i++)
5023 else if (!strcmp(res->what, "xstats"))
5024 for (i = 0; i < nb_ports; i++)
5025 nic_xstats_clear(i);
5026 } else if (!strcmp(res->what, "info"))
5027 for (i = 0; i < nb_ports; i++)
5028 port_infos_display(i);
5029 else if (!strcmp(res->what, "stats"))
5030 for (i = 0; i < nb_ports; i++)
5031 nic_stats_display(i);
5032 else if (!strcmp(res->what, "xstats"))
5033 for (i = 0; i < nb_ports; i++)
5034 nic_xstats_display(i);
5035 else if (!strcmp(res->what, "fdir"))
5036 for (i = 0; i < nb_ports; i++)
5038 else if (!strcmp(res->what, "stat_qmap"))
5039 for (i = 0; i < nb_ports; i++)
5040 nic_stats_mapping_display(i);
5043 cmdline_parse_token_string_t cmd_showportall_show =
5044 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5046 cmdline_parse_token_string_t cmd_showportall_port =
5047 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5048 cmdline_parse_token_string_t cmd_showportall_what =
5049 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5050 "info#stats#xstats#fdir#stat_qmap");
5051 cmdline_parse_token_string_t cmd_showportall_all =
5052 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5053 cmdline_parse_inst_t cmd_showportall = {
5054 .f = cmd_showportall_parsed,
5056 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5058 (void *)&cmd_showportall_show,
5059 (void *)&cmd_showportall_port,
5060 (void *)&cmd_showportall_what,
5061 (void *)&cmd_showportall_all,
5066 /* *** SHOW PORT INFO *** */
5067 struct cmd_showport_result {
5068 cmdline_fixed_string_t show;
5069 cmdline_fixed_string_t port;
5070 cmdline_fixed_string_t what;
5074 static void cmd_showport_parsed(void *parsed_result,
5075 __attribute__((unused)) struct cmdline *cl,
5076 __attribute__((unused)) void *data)
5078 struct cmd_showport_result *res = parsed_result;
5079 if (!strcmp(res->show, "clear")) {
5080 if (!strcmp(res->what, "stats"))
5081 nic_stats_clear(res->portnum);
5082 else if (!strcmp(res->what, "xstats"))
5083 nic_xstats_clear(res->portnum);
5084 } else if (!strcmp(res->what, "info"))
5085 port_infos_display(res->portnum);
5086 else if (!strcmp(res->what, "stats"))
5087 nic_stats_display(res->portnum);
5088 else if (!strcmp(res->what, "xstats"))
5089 nic_xstats_display(res->portnum);
5090 else if (!strcmp(res->what, "fdir"))
5091 fdir_get_infos(res->portnum);
5092 else if (!strcmp(res->what, "stat_qmap"))
5093 nic_stats_mapping_display(res->portnum);
5096 cmdline_parse_token_string_t cmd_showport_show =
5097 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5099 cmdline_parse_token_string_t cmd_showport_port =
5100 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5101 cmdline_parse_token_string_t cmd_showport_what =
5102 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5103 "info#stats#xstats#fdir#stat_qmap");
5104 cmdline_parse_token_num_t cmd_showport_portnum =
5105 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5107 cmdline_parse_inst_t cmd_showport = {
5108 .f = cmd_showport_parsed,
5110 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5112 (void *)&cmd_showport_show,
5113 (void *)&cmd_showport_port,
5114 (void *)&cmd_showport_what,
5115 (void *)&cmd_showport_portnum,
5120 /* *** READ PORT REGISTER *** */
5121 struct cmd_read_reg_result {
5122 cmdline_fixed_string_t read;
5123 cmdline_fixed_string_t reg;
5129 cmd_read_reg_parsed(void *parsed_result,
5130 __attribute__((unused)) struct cmdline *cl,
5131 __attribute__((unused)) void *data)
5133 struct cmd_read_reg_result *res = parsed_result;
5134 port_reg_display(res->port_id, res->reg_off);
5137 cmdline_parse_token_string_t cmd_read_reg_read =
5138 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5139 cmdline_parse_token_string_t cmd_read_reg_reg =
5140 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5141 cmdline_parse_token_num_t cmd_read_reg_port_id =
5142 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5143 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5144 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5146 cmdline_parse_inst_t cmd_read_reg = {
5147 .f = cmd_read_reg_parsed,
5149 .help_str = "read reg port_id reg_off",
5151 (void *)&cmd_read_reg_read,
5152 (void *)&cmd_read_reg_reg,
5153 (void *)&cmd_read_reg_port_id,
5154 (void *)&cmd_read_reg_reg_off,
5159 /* *** READ PORT REGISTER BIT FIELD *** */
5160 struct cmd_read_reg_bit_field_result {
5161 cmdline_fixed_string_t read;
5162 cmdline_fixed_string_t regfield;
5170 cmd_read_reg_bit_field_parsed(void *parsed_result,
5171 __attribute__((unused)) struct cmdline *cl,
5172 __attribute__((unused)) void *data)
5174 struct cmd_read_reg_bit_field_result *res = parsed_result;
5175 port_reg_bit_field_display(res->port_id, res->reg_off,
5176 res->bit1_pos, res->bit2_pos);
5179 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5180 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5182 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5183 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5184 regfield, "regfield");
5185 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5186 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5188 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5189 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5191 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5192 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5194 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5195 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5198 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5199 .f = cmd_read_reg_bit_field_parsed,
5201 .help_str = "read regfield port_id reg_off bit_x bit_y "
5202 "(read register bit field between bit_x and bit_y included)",
5204 (void *)&cmd_read_reg_bit_field_read,
5205 (void *)&cmd_read_reg_bit_field_regfield,
5206 (void *)&cmd_read_reg_bit_field_port_id,
5207 (void *)&cmd_read_reg_bit_field_reg_off,
5208 (void *)&cmd_read_reg_bit_field_bit1_pos,
5209 (void *)&cmd_read_reg_bit_field_bit2_pos,
5214 /* *** READ PORT REGISTER BIT *** */
5215 struct cmd_read_reg_bit_result {
5216 cmdline_fixed_string_t read;
5217 cmdline_fixed_string_t regbit;
5224 cmd_read_reg_bit_parsed(void *parsed_result,
5225 __attribute__((unused)) struct cmdline *cl,
5226 __attribute__((unused)) void *data)
5228 struct cmd_read_reg_bit_result *res = parsed_result;
5229 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5232 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5233 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5234 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5235 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5237 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5238 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5239 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5240 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5241 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5242 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5244 cmdline_parse_inst_t cmd_read_reg_bit = {
5245 .f = cmd_read_reg_bit_parsed,
5247 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5249 (void *)&cmd_read_reg_bit_read,
5250 (void *)&cmd_read_reg_bit_regbit,
5251 (void *)&cmd_read_reg_bit_port_id,
5252 (void *)&cmd_read_reg_bit_reg_off,
5253 (void *)&cmd_read_reg_bit_bit_pos,
5258 /* *** WRITE PORT REGISTER *** */
5259 struct cmd_write_reg_result {
5260 cmdline_fixed_string_t write;
5261 cmdline_fixed_string_t reg;
5268 cmd_write_reg_parsed(void *parsed_result,
5269 __attribute__((unused)) struct cmdline *cl,
5270 __attribute__((unused)) void *data)
5272 struct cmd_write_reg_result *res = parsed_result;
5273 port_reg_set(res->port_id, res->reg_off, res->value);
5276 cmdline_parse_token_string_t cmd_write_reg_write =
5277 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5278 cmdline_parse_token_string_t cmd_write_reg_reg =
5279 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5280 cmdline_parse_token_num_t cmd_write_reg_port_id =
5281 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5282 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5283 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5284 cmdline_parse_token_num_t cmd_write_reg_value =
5285 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5287 cmdline_parse_inst_t cmd_write_reg = {
5288 .f = cmd_write_reg_parsed,
5290 .help_str = "write reg port_id reg_off reg_value",
5292 (void *)&cmd_write_reg_write,
5293 (void *)&cmd_write_reg_reg,
5294 (void *)&cmd_write_reg_port_id,
5295 (void *)&cmd_write_reg_reg_off,
5296 (void *)&cmd_write_reg_value,
5301 /* *** WRITE PORT REGISTER BIT FIELD *** */
5302 struct cmd_write_reg_bit_field_result {
5303 cmdline_fixed_string_t write;
5304 cmdline_fixed_string_t regfield;
5313 cmd_write_reg_bit_field_parsed(void *parsed_result,
5314 __attribute__((unused)) struct cmdline *cl,
5315 __attribute__((unused)) void *data)
5317 struct cmd_write_reg_bit_field_result *res = parsed_result;
5318 port_reg_bit_field_set(res->port_id, res->reg_off,
5319 res->bit1_pos, res->bit2_pos, res->value);
5322 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5323 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5325 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5326 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5327 regfield, "regfield");
5328 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5329 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5331 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5332 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5334 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5335 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5337 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5338 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5340 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5341 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5344 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5345 .f = cmd_write_reg_bit_field_parsed,
5347 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5348 "(set register bit field between bit_x and bit_y included)",
5350 (void *)&cmd_write_reg_bit_field_write,
5351 (void *)&cmd_write_reg_bit_field_regfield,
5352 (void *)&cmd_write_reg_bit_field_port_id,
5353 (void *)&cmd_write_reg_bit_field_reg_off,
5354 (void *)&cmd_write_reg_bit_field_bit1_pos,
5355 (void *)&cmd_write_reg_bit_field_bit2_pos,
5356 (void *)&cmd_write_reg_bit_field_value,
5361 /* *** WRITE PORT REGISTER BIT *** */
5362 struct cmd_write_reg_bit_result {
5363 cmdline_fixed_string_t write;
5364 cmdline_fixed_string_t regbit;
5372 cmd_write_reg_bit_parsed(void *parsed_result,
5373 __attribute__((unused)) struct cmdline *cl,
5374 __attribute__((unused)) void *data)
5376 struct cmd_write_reg_bit_result *res = parsed_result;
5377 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5380 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5381 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5383 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5384 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5386 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5387 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5388 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5389 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5390 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5391 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5392 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5393 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5395 cmdline_parse_inst_t cmd_write_reg_bit = {
5396 .f = cmd_write_reg_bit_parsed,
5398 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5400 (void *)&cmd_write_reg_bit_write,
5401 (void *)&cmd_write_reg_bit_regbit,
5402 (void *)&cmd_write_reg_bit_port_id,
5403 (void *)&cmd_write_reg_bit_reg_off,
5404 (void *)&cmd_write_reg_bit_bit_pos,
5405 (void *)&cmd_write_reg_bit_value,
5410 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5411 struct cmd_read_rxd_txd_result {
5412 cmdline_fixed_string_t read;
5413 cmdline_fixed_string_t rxd_txd;
5420 cmd_read_rxd_txd_parsed(void *parsed_result,
5421 __attribute__((unused)) struct cmdline *cl,
5422 __attribute__((unused)) void *data)
5424 struct cmd_read_rxd_txd_result *res = parsed_result;
5426 if (!strcmp(res->rxd_txd, "rxd"))
5427 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5428 else if (!strcmp(res->rxd_txd, "txd"))
5429 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5432 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5433 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5434 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5435 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5437 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5438 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5439 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5440 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5441 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5442 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5444 cmdline_parse_inst_t cmd_read_rxd_txd = {
5445 .f = cmd_read_rxd_txd_parsed,
5447 .help_str = "read rxd|txd port_id queue_id rxd_id",
5449 (void *)&cmd_read_rxd_txd_read,
5450 (void *)&cmd_read_rxd_txd_rxd_txd,
5451 (void *)&cmd_read_rxd_txd_port_id,
5452 (void *)&cmd_read_rxd_txd_queue_id,
5453 (void *)&cmd_read_rxd_txd_desc_id,
5459 struct cmd_quit_result {
5460 cmdline_fixed_string_t quit;
5463 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5465 __attribute__((unused)) void *data)
5471 cmdline_parse_token_string_t cmd_quit_quit =
5472 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5474 cmdline_parse_inst_t cmd_quit = {
5475 .f = cmd_quit_parsed,
5477 .help_str = "exit application",
5479 (void *)&cmd_quit_quit,
5484 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5485 struct cmd_mac_addr_result {
5486 cmdline_fixed_string_t mac_addr_cmd;
5487 cmdline_fixed_string_t what;
5489 struct ether_addr address;
5492 static void cmd_mac_addr_parsed(void *parsed_result,
5493 __attribute__((unused)) struct cmdline *cl,
5494 __attribute__((unused)) void *data)
5496 struct cmd_mac_addr_result *res = parsed_result;
5499 if (strcmp(res->what, "add") == 0)
5500 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5502 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5504 /* check the return value and print it if is < 0 */
5506 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5510 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5511 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5513 cmdline_parse_token_string_t cmd_mac_addr_what =
5514 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5516 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5517 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5518 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5519 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5521 cmdline_parse_inst_t cmd_mac_addr = {
5522 .f = cmd_mac_addr_parsed,
5524 .help_str = "mac_addr add|remove X <address>: "
5525 "add/remove MAC address on port X",
5527 (void *)&cmd_mac_addr_cmd,
5528 (void *)&cmd_mac_addr_what,
5529 (void *)&cmd_mac_addr_portnum,
5530 (void *)&cmd_mac_addr_addr,
5536 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5537 struct cmd_set_qmap_result {
5538 cmdline_fixed_string_t set;
5539 cmdline_fixed_string_t qmap;
5540 cmdline_fixed_string_t what;
5547 cmd_set_qmap_parsed(void *parsed_result,
5548 __attribute__((unused)) struct cmdline *cl,
5549 __attribute__((unused)) void *data)
5551 struct cmd_set_qmap_result *res = parsed_result;
5552 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5554 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5557 cmdline_parse_token_string_t cmd_setqmap_set =
5558 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5560 cmdline_parse_token_string_t cmd_setqmap_qmap =
5561 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5563 cmdline_parse_token_string_t cmd_setqmap_what =
5564 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5566 cmdline_parse_token_num_t cmd_setqmap_portid =
5567 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5569 cmdline_parse_token_num_t cmd_setqmap_queueid =
5570 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5572 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5573 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5576 cmdline_parse_inst_t cmd_set_qmap = {
5577 .f = cmd_set_qmap_parsed,
5579 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5581 (void *)&cmd_setqmap_set,
5582 (void *)&cmd_setqmap_qmap,
5583 (void *)&cmd_setqmap_what,
5584 (void *)&cmd_setqmap_portid,
5585 (void *)&cmd_setqmap_queueid,
5586 (void *)&cmd_setqmap_mapvalue,
5591 /* *** CONFIGURE UNICAST HASH TABLE *** */
5592 struct cmd_set_uc_hash_table {
5593 cmdline_fixed_string_t set;
5594 cmdline_fixed_string_t port;
5596 cmdline_fixed_string_t what;
5597 struct ether_addr address;
5598 cmdline_fixed_string_t mode;
5602 cmd_set_uc_hash_parsed(void *parsed_result,
5603 __attribute__((unused)) struct cmdline *cl,
5604 __attribute__((unused)) void *data)
5607 struct cmd_set_uc_hash_table *res = parsed_result;
5609 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5611 if (strcmp(res->what, "uta") == 0)
5612 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5613 &res->address,(uint8_t)is_on);
5615 printf("bad unicast hash table parameter, return code = %d \n", ret);
5619 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5620 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5622 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5623 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5625 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5626 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5628 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5631 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5632 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5634 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5635 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5638 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5639 .f = cmd_set_uc_hash_parsed,
5641 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5643 (void *)&cmd_set_uc_hash_set,
5644 (void *)&cmd_set_uc_hash_port,
5645 (void *)&cmd_set_uc_hash_portid,
5646 (void *)&cmd_set_uc_hash_what,
5647 (void *)&cmd_set_uc_hash_mac,
5648 (void *)&cmd_set_uc_hash_mode,
5653 struct cmd_set_uc_all_hash_table {
5654 cmdline_fixed_string_t set;
5655 cmdline_fixed_string_t port;
5657 cmdline_fixed_string_t what;
5658 cmdline_fixed_string_t value;
5659 cmdline_fixed_string_t mode;
5663 cmd_set_uc_all_hash_parsed(void *parsed_result,
5664 __attribute__((unused)) struct cmdline *cl,
5665 __attribute__((unused)) void *data)
5668 struct cmd_set_uc_all_hash_table *res = parsed_result;
5670 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5672 if ((strcmp(res->what, "uta") == 0) &&
5673 (strcmp(res->value, "all") == 0))
5674 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5676 printf("bad unicast hash table parameter,"
5677 "return code = %d \n", ret);
5680 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5681 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5683 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5684 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5686 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5687 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5689 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5692 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5693 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5695 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5696 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5699 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5700 .f = cmd_set_uc_all_hash_parsed,
5702 .help_str = "set port X uta all on|off (X = port number)",
5704 (void *)&cmd_set_uc_all_hash_set,
5705 (void *)&cmd_set_uc_all_hash_port,
5706 (void *)&cmd_set_uc_all_hash_portid,
5707 (void *)&cmd_set_uc_all_hash_what,
5708 (void *)&cmd_set_uc_all_hash_value,
5709 (void *)&cmd_set_uc_all_hash_mode,
5714 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5715 struct cmd_set_vf_macvlan_filter {
5716 cmdline_fixed_string_t set;
5717 cmdline_fixed_string_t port;
5719 cmdline_fixed_string_t vf;
5721 struct ether_addr address;
5722 cmdline_fixed_string_t filter_type;
5723 cmdline_fixed_string_t mode;
5727 cmd_set_vf_macvlan_parsed(void *parsed_result,
5728 __attribute__((unused)) struct cmdline *cl,
5729 __attribute__((unused)) void *data)
5732 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5733 struct rte_eth_mac_filter filter;
5735 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5737 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5739 /* set VF MAC filter */
5743 filter.dst_id = res->vf_id;
5745 if (!strcmp(res->filter_type, "exact-mac"))
5746 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5747 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5748 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5749 else if (!strcmp(res->filter_type, "hashmac"))
5750 filter.filter_type = RTE_MAC_HASH_MATCH;
5751 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5752 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5754 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5757 ret = rte_eth_dev_filter_ctrl(res->port_id,
5758 RTE_ETH_FILTER_MACVLAN,
5762 ret = rte_eth_dev_filter_ctrl(res->port_id,
5763 RTE_ETH_FILTER_MACVLAN,
5764 RTE_ETH_FILTER_DELETE,
5768 printf("bad set MAC hash parameter, return code = %d\n", ret);
5772 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5773 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5775 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5776 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5778 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5779 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5781 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5784 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5785 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5787 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5788 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5790 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5791 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5792 filter_type, "exact-mac#exact-mac-vlan"
5793 "#hashmac#hashmac-vlan");
5794 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5795 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5798 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5799 .f = cmd_set_vf_macvlan_parsed,
5801 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5802 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5804 "exact match rule:exact match of MAC or MAC and VLAN; "
5805 "hash match rule: hash match of MAC and exact match "
5808 (void *)&cmd_set_vf_macvlan_set,
5809 (void *)&cmd_set_vf_macvlan_port,
5810 (void *)&cmd_set_vf_macvlan_portid,
5811 (void *)&cmd_set_vf_macvlan_vf,
5812 (void *)&cmd_set_vf_macvlan_vf_id,
5813 (void *)&cmd_set_vf_macvlan_mac,
5814 (void *)&cmd_set_vf_macvlan_filter_type,
5815 (void *)&cmd_set_vf_macvlan_mode,
5820 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5821 struct cmd_set_vf_traffic {
5822 cmdline_fixed_string_t set;
5823 cmdline_fixed_string_t port;
5825 cmdline_fixed_string_t vf;
5827 cmdline_fixed_string_t what;
5828 cmdline_fixed_string_t mode;
5832 cmd_set_vf_traffic_parsed(void *parsed_result,
5833 __attribute__((unused)) struct cmdline *cl,
5834 __attribute__((unused)) void *data)
5836 struct cmd_set_vf_traffic *res = parsed_result;
5837 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5838 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5840 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5843 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5846 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5849 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5850 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5852 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5855 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5856 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5858 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5859 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5861 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5862 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5865 cmdline_parse_inst_t cmd_set_vf_traffic = {
5866 .f = cmd_set_vf_traffic_parsed,
5868 .help_str = "set port X vf Y rx|tx on|off"
5869 "(X = port number,Y = vf id)",
5871 (void *)&cmd_setvf_traffic_set,
5872 (void *)&cmd_setvf_traffic_port,
5873 (void *)&cmd_setvf_traffic_portid,
5874 (void *)&cmd_setvf_traffic_vf,
5875 (void *)&cmd_setvf_traffic_vfid,
5876 (void *)&cmd_setvf_traffic_what,
5877 (void *)&cmd_setvf_traffic_mode,
5882 /* *** CONFIGURE VF RECEIVE MODE *** */
5883 struct cmd_set_vf_rxmode {
5884 cmdline_fixed_string_t set;
5885 cmdline_fixed_string_t port;
5887 cmdline_fixed_string_t vf;
5889 cmdline_fixed_string_t what;
5890 cmdline_fixed_string_t mode;
5891 cmdline_fixed_string_t on;
5895 cmd_set_vf_rxmode_parsed(void *parsed_result,
5896 __attribute__((unused)) struct cmdline *cl,
5897 __attribute__((unused)) void *data)
5900 uint16_t rx_mode = 0;
5901 struct cmd_set_vf_rxmode *res = parsed_result;
5903 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5904 if (!strcmp(res->what,"rxmode")) {
5905 if (!strcmp(res->mode, "AUPE"))
5906 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5907 else if (!strcmp(res->mode, "ROPE"))
5908 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5909 else if (!strcmp(res->mode, "BAM"))
5910 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5911 else if (!strncmp(res->mode, "MPE",3))
5912 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5915 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5917 printf("bad VF receive mode parameter, return code = %d \n",
5921 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5922 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5924 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5925 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5927 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5928 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5930 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5933 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5934 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5936 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5937 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5939 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5940 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5941 mode, "AUPE#ROPE#BAM#MPE");
5942 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5943 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5946 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5947 .f = cmd_set_vf_rxmode_parsed,
5949 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5951 (void *)&cmd_set_vf_rxmode_set,
5952 (void *)&cmd_set_vf_rxmode_port,
5953 (void *)&cmd_set_vf_rxmode_portid,
5954 (void *)&cmd_set_vf_rxmode_vf,
5955 (void *)&cmd_set_vf_rxmode_vfid,
5956 (void *)&cmd_set_vf_rxmode_what,
5957 (void *)&cmd_set_vf_rxmode_mode,
5958 (void *)&cmd_set_vf_rxmode_on,
5963 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5964 struct cmd_vf_mac_addr_result {
5965 cmdline_fixed_string_t mac_addr_cmd;
5966 cmdline_fixed_string_t what;
5967 cmdline_fixed_string_t port;
5969 cmdline_fixed_string_t vf;
5971 struct ether_addr address;
5974 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5975 __attribute__((unused)) struct cmdline *cl,
5976 __attribute__((unused)) void *data)
5978 struct cmd_vf_mac_addr_result *res = parsed_result;
5981 if (strcmp(res->what, "add") == 0)
5982 ret = rte_eth_dev_mac_addr_add(res->port_num,
5983 &res->address, res->vf_num);
5985 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5989 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5990 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5991 mac_addr_cmd,"mac_addr");
5992 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5993 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5995 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5996 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5998 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5999 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6001 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6002 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6004 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6005 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6007 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6008 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6011 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6012 .f = cmd_vf_mac_addr_parsed,
6014 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6015 "Y = VF number)add MAC address filtering for a VF on port X",
6017 (void *)&cmd_vf_mac_addr_cmd,
6018 (void *)&cmd_vf_mac_addr_what,
6019 (void *)&cmd_vf_mac_addr_port,
6020 (void *)&cmd_vf_mac_addr_portnum,
6021 (void *)&cmd_vf_mac_addr_vf,
6022 (void *)&cmd_vf_mac_addr_vfnum,
6023 (void *)&cmd_vf_mac_addr_addr,
6028 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6029 struct cmd_vf_rx_vlan_filter {
6030 cmdline_fixed_string_t rx_vlan;
6031 cmdline_fixed_string_t what;
6033 cmdline_fixed_string_t port;
6035 cmdline_fixed_string_t vf;
6040 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6041 __attribute__((unused)) struct cmdline *cl,
6042 __attribute__((unused)) void *data)
6044 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6046 if (!strcmp(res->what, "add"))
6047 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6049 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6052 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6053 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6054 rx_vlan, "rx_vlan");
6055 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6056 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6058 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6059 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6061 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6062 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6064 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6065 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6067 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6068 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6070 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6071 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6074 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6075 .f = cmd_vf_rx_vlan_filter_parsed,
6077 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6078 "Y = port number,Z = hexadecimal VF mask)",
6080 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6081 (void *)&cmd_vf_rx_vlan_filter_what,
6082 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6083 (void *)&cmd_vf_rx_vlan_filter_port,
6084 (void *)&cmd_vf_rx_vlan_filter_portid,
6085 (void *)&cmd_vf_rx_vlan_filter_vf,
6086 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6091 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6092 struct cmd_queue_rate_limit_result {
6093 cmdline_fixed_string_t set;
6094 cmdline_fixed_string_t port;
6096 cmdline_fixed_string_t queue;
6098 cmdline_fixed_string_t rate;
6102 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6103 __attribute__((unused)) struct cmdline *cl,
6104 __attribute__((unused)) void *data)
6106 struct cmd_queue_rate_limit_result *res = parsed_result;
6109 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6110 && (strcmp(res->queue, "queue") == 0)
6111 && (strcmp(res->rate, "rate") == 0))
6112 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6115 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6119 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6120 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6122 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6123 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6125 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6126 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6128 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6129 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6131 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6132 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6134 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6135 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6137 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6138 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6141 cmdline_parse_inst_t cmd_queue_rate_limit = {
6142 .f = cmd_queue_rate_limit_parsed,
6144 .help_str = "set port X queue Y rate Z:(X = port number,"
6145 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6147 (void *)&cmd_queue_rate_limit_set,
6148 (void *)&cmd_queue_rate_limit_port,
6149 (void *)&cmd_queue_rate_limit_portnum,
6150 (void *)&cmd_queue_rate_limit_queue,
6151 (void *)&cmd_queue_rate_limit_queuenum,
6152 (void *)&cmd_queue_rate_limit_rate,
6153 (void *)&cmd_queue_rate_limit_ratenum,
6158 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6159 struct cmd_vf_rate_limit_result {
6160 cmdline_fixed_string_t set;
6161 cmdline_fixed_string_t port;
6163 cmdline_fixed_string_t vf;
6165 cmdline_fixed_string_t rate;
6167 cmdline_fixed_string_t q_msk;
6171 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6172 __attribute__((unused)) struct cmdline *cl,
6173 __attribute__((unused)) void *data)
6175 struct cmd_vf_rate_limit_result *res = parsed_result;
6178 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6179 && (strcmp(res->vf, "vf") == 0)
6180 && (strcmp(res->rate, "rate") == 0)
6181 && (strcmp(res->q_msk, "queue_mask") == 0))
6182 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6183 res->rate_num, res->q_msk_val);
6185 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6189 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6190 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6192 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6193 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6195 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6196 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6198 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6199 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6201 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6202 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6204 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6205 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6207 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6208 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6210 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6211 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6212 q_msk, "queue_mask");
6213 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6214 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6217 cmdline_parse_inst_t cmd_vf_rate_limit = {
6218 .f = cmd_vf_rate_limit_parsed,
6220 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6221 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6222 "for queues of VF on port X",
6224 (void *)&cmd_vf_rate_limit_set,
6225 (void *)&cmd_vf_rate_limit_port,
6226 (void *)&cmd_vf_rate_limit_portnum,
6227 (void *)&cmd_vf_rate_limit_vf,
6228 (void *)&cmd_vf_rate_limit_vfnum,
6229 (void *)&cmd_vf_rate_limit_rate,
6230 (void *)&cmd_vf_rate_limit_ratenum,
6231 (void *)&cmd_vf_rate_limit_q_msk,
6232 (void *)&cmd_vf_rate_limit_q_msk_val,
6237 /* *** ADD TUNNEL FILTER OF A PORT *** */
6238 struct cmd_tunnel_filter_result {
6239 cmdline_fixed_string_t cmd;
6240 cmdline_fixed_string_t what;
6242 struct ether_addr outer_mac;
6243 struct ether_addr inner_mac;
6244 cmdline_ipaddr_t ip_value;
6245 uint16_t inner_vlan;
6246 cmdline_fixed_string_t tunnel_type;
6247 cmdline_fixed_string_t filter_type;
6253 cmd_tunnel_filter_parsed(void *parsed_result,
6254 __attribute__((unused)) struct cmdline *cl,
6255 __attribute__((unused)) void *data)
6257 struct cmd_tunnel_filter_result *res = parsed_result;
6258 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6261 tunnel_filter_conf.outer_mac = &res->outer_mac;
6262 tunnel_filter_conf.inner_mac = &res->inner_mac;
6263 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6265 if (res->ip_value.family == AF_INET) {
6266 tunnel_filter_conf.ip_addr.ipv4_addr =
6267 res->ip_value.addr.ipv4.s_addr;
6268 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6270 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6271 &(res->ip_value.addr.ipv6),
6272 sizeof(struct in6_addr));
6273 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6276 if (!strcmp(res->filter_type, "imac-ivlan"))
6277 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6278 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6279 tunnel_filter_conf.filter_type =
6280 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6281 else if (!strcmp(res->filter_type, "imac-tenid"))
6282 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6283 else if (!strcmp(res->filter_type, "imac"))
6284 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6285 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6286 tunnel_filter_conf.filter_type =
6287 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6289 printf("The filter type is not supported");
6293 if (!strcmp(res->tunnel_type, "vxlan"))
6294 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6296 printf("Only VXLAN is supported now.\n");
6300 tunnel_filter_conf.tenant_id = res->tenant_id;
6301 tunnel_filter_conf.queue_id = res->queue_num;
6302 if (!strcmp(res->what, "add"))
6303 ret = rte_eth_dev_filter_ctrl(res->port_id,
6304 RTE_ETH_FILTER_TUNNEL,
6306 &tunnel_filter_conf);
6308 ret = rte_eth_dev_filter_ctrl(res->port_id,
6309 RTE_ETH_FILTER_TUNNEL,
6310 RTE_ETH_FILTER_DELETE,
6311 &tunnel_filter_conf);
6313 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6317 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6318 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6319 cmd, "tunnel_filter");
6320 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6321 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6323 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6324 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6326 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6327 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6329 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6330 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6332 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6333 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6334 inner_vlan, UINT16);
6335 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6336 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6338 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6339 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6340 tunnel_type, "vxlan");
6342 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6343 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6344 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6345 "imac#omac-imac-tenid");
6346 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6347 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6349 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6350 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6353 cmdline_parse_inst_t cmd_tunnel_filter = {
6354 .f = cmd_tunnel_filter_parsed,
6356 .help_str = "add/rm tunnel filter of a port: "
6357 "tunnel_filter add port_id outer_mac inner_mac ip "
6358 "inner_vlan tunnel_type(vxlan) filter_type "
6359 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6360 "imac|omac-imac-tenid) "
6361 "tenant_id queue_num",
6363 (void *)&cmd_tunnel_filter_cmd,
6364 (void *)&cmd_tunnel_filter_what,
6365 (void *)&cmd_tunnel_filter_port_id,
6366 (void *)&cmd_tunnel_filter_outer_mac,
6367 (void *)&cmd_tunnel_filter_inner_mac,
6368 (void *)&cmd_tunnel_filter_ip_value,
6369 (void *)&cmd_tunnel_filter_innner_vlan,
6370 (void *)&cmd_tunnel_filter_tunnel_type,
6371 (void *)&cmd_tunnel_filter_filter_type,
6372 (void *)&cmd_tunnel_filter_tenant_id,
6373 (void *)&cmd_tunnel_filter_queue_num,
6378 /* *** CONFIGURE TUNNEL UDP PORT *** */
6379 struct cmd_tunnel_udp_config {
6380 cmdline_fixed_string_t cmd;
6381 cmdline_fixed_string_t what;
6387 cmd_tunnel_udp_config_parsed(void *parsed_result,
6388 __attribute__((unused)) struct cmdline *cl,
6389 __attribute__((unused)) void *data)
6391 struct cmd_tunnel_udp_config *res = parsed_result;
6392 struct rte_eth_udp_tunnel tunnel_udp;
6395 tunnel_udp.udp_port = res->udp_port;
6397 if (!strcmp(res->cmd, "rx_vxlan_port"))
6398 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6400 if (!strcmp(res->what, "add"))
6401 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6403 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6406 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6409 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6410 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6411 cmd, "rx_vxlan_port");
6412 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6413 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6415 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6416 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6418 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6419 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6422 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6423 .f = cmd_tunnel_udp_config_parsed,
6425 .help_str = "add/rm an tunneling UDP port filter: "
6426 "rx_vxlan_port add udp_port port_id",
6428 (void *)&cmd_tunnel_udp_config_cmd,
6429 (void *)&cmd_tunnel_udp_config_what,
6430 (void *)&cmd_tunnel_udp_config_udp_port,
6431 (void *)&cmd_tunnel_udp_config_port_id,
6436 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6437 struct cmd_set_mirror_mask_result {
6438 cmdline_fixed_string_t set;
6439 cmdline_fixed_string_t port;
6441 cmdline_fixed_string_t mirror;
6443 cmdline_fixed_string_t what;
6444 cmdline_fixed_string_t value;
6445 cmdline_fixed_string_t dstpool;
6447 cmdline_fixed_string_t on;
6450 cmdline_parse_token_string_t cmd_mirror_mask_set =
6451 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6453 cmdline_parse_token_string_t cmd_mirror_mask_port =
6454 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6456 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6457 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6459 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6460 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6461 mirror, "mirror-rule");
6462 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6463 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6465 cmdline_parse_token_string_t cmd_mirror_mask_what =
6466 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6467 what, "pool-mirror#vlan-mirror");
6468 cmdline_parse_token_string_t cmd_mirror_mask_value =
6469 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6471 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6472 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6473 dstpool, "dst-pool");
6474 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6475 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6477 cmdline_parse_token_string_t cmd_mirror_mask_on =
6478 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6482 cmd_set_mirror_mask_parsed(void *parsed_result,
6483 __attribute__((unused)) struct cmdline *cl,
6484 __attribute__((unused)) void *data)
6487 struct cmd_set_mirror_mask_result *res = parsed_result;
6488 struct rte_eth_vmdq_mirror_conf mr_conf;
6490 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6492 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6494 mr_conf.dst_pool = res->dstpool_id;
6496 if (!strcmp(res->what, "pool-mirror")) {
6497 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6498 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6499 } else if(!strcmp(res->what, "vlan-mirror")) {
6500 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6501 nb_item = parse_item_list(res->value, "core",
6502 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6506 for(i=0; i < nb_item; i++) {
6507 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6508 printf("Invalid vlan_id: must be < 4096\n");
6512 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6513 mr_conf.vlan.vlan_mask |= 1ULL << i;
6517 if(!strcmp(res->on, "on"))
6518 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6521 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6524 printf("mirror rule add error: (%s)\n", strerror(-ret));
6527 cmdline_parse_inst_t cmd_set_mirror_mask = {
6528 .f = cmd_set_mirror_mask_parsed,
6530 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6531 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6533 (void *)&cmd_mirror_mask_set,
6534 (void *)&cmd_mirror_mask_port,
6535 (void *)&cmd_mirror_mask_portid,
6536 (void *)&cmd_mirror_mask_mirror,
6537 (void *)&cmd_mirror_mask_ruleid,
6538 (void *)&cmd_mirror_mask_what,
6539 (void *)&cmd_mirror_mask_value,
6540 (void *)&cmd_mirror_mask_dstpool,
6541 (void *)&cmd_mirror_mask_poolid,
6542 (void *)&cmd_mirror_mask_on,
6547 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6548 struct cmd_set_mirror_link_result {
6549 cmdline_fixed_string_t set;
6550 cmdline_fixed_string_t port;
6552 cmdline_fixed_string_t mirror;
6554 cmdline_fixed_string_t what;
6555 cmdline_fixed_string_t dstpool;
6557 cmdline_fixed_string_t on;
6560 cmdline_parse_token_string_t cmd_mirror_link_set =
6561 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6563 cmdline_parse_token_string_t cmd_mirror_link_port =
6564 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6566 cmdline_parse_token_num_t cmd_mirror_link_portid =
6567 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6569 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6570 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6571 mirror, "mirror-rule");
6572 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6573 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6575 cmdline_parse_token_string_t cmd_mirror_link_what =
6576 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6577 what, "uplink-mirror#downlink-mirror");
6578 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6579 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6580 dstpool, "dst-pool");
6581 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6582 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6584 cmdline_parse_token_string_t cmd_mirror_link_on =
6585 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6589 cmd_set_mirror_link_parsed(void *parsed_result,
6590 __attribute__((unused)) struct cmdline *cl,
6591 __attribute__((unused)) void *data)
6594 struct cmd_set_mirror_link_result *res = parsed_result;
6595 struct rte_eth_vmdq_mirror_conf mr_conf;
6597 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6598 if(!strcmp(res->what, "uplink-mirror")) {
6599 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6600 }else if(!strcmp(res->what, "downlink-mirror"))
6601 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6603 mr_conf.dst_pool = res->dstpool_id;
6605 if(!strcmp(res->on, "on"))
6606 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6609 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6612 /* check the return value and print it if is < 0 */
6614 printf("mirror rule add error: (%s)\n", strerror(-ret));
6618 cmdline_parse_inst_t cmd_set_mirror_link = {
6619 .f = cmd_set_mirror_link_parsed,
6621 .help_str = "set port X mirror-rule Y uplink-mirror|"
6622 "downlink-mirror dst-pool Z on|off",
6624 (void *)&cmd_mirror_link_set,
6625 (void *)&cmd_mirror_link_port,
6626 (void *)&cmd_mirror_link_portid,
6627 (void *)&cmd_mirror_link_mirror,
6628 (void *)&cmd_mirror_link_ruleid,
6629 (void *)&cmd_mirror_link_what,
6630 (void *)&cmd_mirror_link_dstpool,
6631 (void *)&cmd_mirror_link_poolid,
6632 (void *)&cmd_mirror_link_on,
6637 /* *** RESET VM MIRROR RULE *** */
6638 struct cmd_rm_mirror_rule_result {
6639 cmdline_fixed_string_t reset;
6640 cmdline_fixed_string_t port;
6642 cmdline_fixed_string_t mirror;
6646 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6647 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6649 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6650 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6652 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6653 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6655 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6656 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6657 mirror, "mirror-rule");
6658 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6659 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6663 cmd_reset_mirror_rule_parsed(void *parsed_result,
6664 __attribute__((unused)) struct cmdline *cl,
6665 __attribute__((unused)) void *data)
6668 struct cmd_set_mirror_link_result *res = parsed_result;
6670 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6672 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6675 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6676 .f = cmd_reset_mirror_rule_parsed,
6678 .help_str = "reset port X mirror-rule Y",
6680 (void *)&cmd_rm_mirror_rule_reset,
6681 (void *)&cmd_rm_mirror_rule_port,
6682 (void *)&cmd_rm_mirror_rule_portid,
6683 (void *)&cmd_rm_mirror_rule_mirror,
6684 (void *)&cmd_rm_mirror_rule_ruleid,
6689 /* ******************************************************************************** */
6691 struct cmd_dump_result {
6692 cmdline_fixed_string_t dump;
6696 dump_struct_sizes(void)
6698 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6699 DUMP_SIZE(struct rte_mbuf);
6700 DUMP_SIZE(struct rte_mempool);
6701 DUMP_SIZE(struct rte_ring);
6705 static void cmd_dump_parsed(void *parsed_result,
6706 __attribute__((unused)) struct cmdline *cl,
6707 __attribute__((unused)) void *data)
6709 struct cmd_dump_result *res = parsed_result;
6711 if (!strcmp(res->dump, "dump_physmem"))
6712 rte_dump_physmem_layout(stdout);
6713 else if (!strcmp(res->dump, "dump_memzone"))
6714 rte_memzone_dump(stdout);
6715 else if (!strcmp(res->dump, "dump_log_history"))
6716 rte_log_dump_history(stdout);
6717 else if (!strcmp(res->dump, "dump_struct_sizes"))
6718 dump_struct_sizes();
6719 else if (!strcmp(res->dump, "dump_ring"))
6720 rte_ring_list_dump(stdout);
6721 else if (!strcmp(res->dump, "dump_mempool"))
6722 rte_mempool_list_dump(stdout);
6723 else if (!strcmp(res->dump, "dump_devargs"))
6724 rte_eal_devargs_dump(stdout);
6727 cmdline_parse_token_string_t cmd_dump_dump =
6728 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6732 "dump_struct_sizes#"
6737 cmdline_parse_inst_t cmd_dump = {
6738 .f = cmd_dump_parsed, /* function to call */
6739 .data = NULL, /* 2nd arg of func */
6740 .help_str = "dump status",
6741 .tokens = { /* token list, NULL terminated */
6742 (void *)&cmd_dump_dump,
6747 /* ******************************************************************************** */
6749 struct cmd_dump_one_result {
6750 cmdline_fixed_string_t dump;
6751 cmdline_fixed_string_t name;
6754 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6755 __attribute__((unused)) void *data)
6757 struct cmd_dump_one_result *res = parsed_result;
6759 if (!strcmp(res->dump, "dump_ring")) {
6761 r = rte_ring_lookup(res->name);
6763 cmdline_printf(cl, "Cannot find ring\n");
6766 rte_ring_dump(stdout, r);
6767 } else if (!strcmp(res->dump, "dump_mempool")) {
6768 struct rte_mempool *mp;
6769 mp = rte_mempool_lookup(res->name);
6771 cmdline_printf(cl, "Cannot find mempool\n");
6774 rte_mempool_dump(stdout, mp);
6778 cmdline_parse_token_string_t cmd_dump_one_dump =
6779 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6780 "dump_ring#dump_mempool");
6782 cmdline_parse_token_string_t cmd_dump_one_name =
6783 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6785 cmdline_parse_inst_t cmd_dump_one = {
6786 .f = cmd_dump_one_parsed, /* function to call */
6787 .data = NULL, /* 2nd arg of func */
6788 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6789 .tokens = { /* token list, NULL terminated */
6790 (void *)&cmd_dump_one_dump,
6791 (void *)&cmd_dump_one_name,
6796 /* *** Add/Del syn filter *** */
6797 struct cmd_syn_filter_result {
6798 cmdline_fixed_string_t filter;
6800 cmdline_fixed_string_t ops;
6801 cmdline_fixed_string_t priority;
6802 cmdline_fixed_string_t high;
6803 cmdline_fixed_string_t queue;
6808 cmd_syn_filter_parsed(void *parsed_result,
6809 __attribute__((unused)) struct cmdline *cl,
6810 __attribute__((unused)) void *data)
6812 struct cmd_syn_filter_result *res = parsed_result;
6813 struct rte_eth_syn_filter syn_filter;
6816 ret = rte_eth_dev_filter_supported(res->port_id,
6817 RTE_ETH_FILTER_SYN);
6819 printf("syn filter is not supported on port %u.\n",
6824 memset(&syn_filter, 0, sizeof(syn_filter));
6826 if (!strcmp(res->ops, "add")) {
6827 if (!strcmp(res->high, "high"))
6828 syn_filter.hig_pri = 1;
6830 syn_filter.hig_pri = 0;
6832 syn_filter.queue = res->queue_id;
6833 ret = rte_eth_dev_filter_ctrl(res->port_id,
6838 ret = rte_eth_dev_filter_ctrl(res->port_id,
6840 RTE_ETH_FILTER_DELETE,
6844 printf("syn filter programming error: (%s)\n",
6848 cmdline_parse_token_string_t cmd_syn_filter_filter =
6849 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6850 filter, "syn_filter");
6851 cmdline_parse_token_num_t cmd_syn_filter_port_id =
6852 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
6854 cmdline_parse_token_string_t cmd_syn_filter_ops =
6855 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6857 cmdline_parse_token_string_t cmd_syn_filter_priority =
6858 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6859 priority, "priority");
6860 cmdline_parse_token_string_t cmd_syn_filter_high =
6861 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6863 cmdline_parse_token_string_t cmd_syn_filter_queue =
6864 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6866 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6867 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
6870 cmdline_parse_inst_t cmd_syn_filter = {
6871 .f = cmd_syn_filter_parsed,
6873 .help_str = "add/delete syn filter",
6875 (void *)&cmd_syn_filter_filter,
6876 (void *)&cmd_syn_filter_port_id,
6877 (void *)&cmd_syn_filter_ops,
6878 (void *)&cmd_syn_filter_priority,
6879 (void *)&cmd_syn_filter_high,
6880 (void *)&cmd_syn_filter_queue,
6881 (void *)&cmd_syn_filter_queue_id,
6886 /* *** ADD/REMOVE A 2tuple FILTER *** */
6887 struct cmd_2tuple_filter_result {
6888 cmdline_fixed_string_t filter;
6890 cmdline_fixed_string_t protocol;
6891 uint8_t protocol_value;
6892 uint8_t protocol_mask;
6893 cmdline_fixed_string_t dst_port;
6894 uint16_t dst_port_value;
6895 uint16_t dst_port_mask;
6896 cmdline_fixed_string_t flags;
6897 uint8_t flags_value;
6898 cmdline_fixed_string_t priority;
6899 uint8_t priority_value;
6900 cmdline_fixed_string_t queue;
6902 cmdline_fixed_string_t index;
6903 uint16_t index_value;
6907 cmd_2tuple_filter_parsed(void *parsed_result,
6908 __attribute__((unused)) struct cmdline *cl,
6909 __attribute__((unused)) void *data)
6912 struct rte_2tuple_filter filter;
6913 struct cmd_2tuple_filter_result *res = parsed_result;
6915 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
6917 if (!strcmp(res->filter, "add_2tuple_filter")) {
6918 /* need convert to big endian. */
6919 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6920 filter.protocol = res->protocol_value;
6921 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
6922 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
6923 filter.priority = res->priority_value;
6924 filter.tcp_flags = res->flags_value;
6925 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
6926 res->index_value, &filter, res->queue_id);
6927 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
6928 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
6930 else if (!strcmp(res->filter, "get_2tuple_filter"))
6931 get_2tuple_filter(res->port_id, res->index_value);
6934 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
6937 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6938 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6940 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6941 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6942 protocol, "protocol");
6943 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6944 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6945 protocol_value, UINT8);
6946 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
6947 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6948 protocol_mask, UINT8);
6949 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6950 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6951 dst_port, "dst_port");
6952 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6953 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6954 dst_port_value, UINT16);
6955 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
6956 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6957 dst_port_mask, UINT16);
6958 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
6959 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6961 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
6962 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6963 flags_value, UINT8);
6964 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6965 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6966 priority, "priority");
6967 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6968 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6969 priority_value, UINT8);
6970 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6971 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6973 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6974 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6976 cmdline_parse_token_string_t cmd_2tuple_filter_index =
6977 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6979 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
6980 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6981 index_value, UINT16);
6982 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
6983 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6984 filter, "add_2tuple_filter");
6985 cmdline_parse_inst_t cmd_add_2tuple_filter = {
6986 .f = cmd_2tuple_filter_parsed,
6988 .help_str = "add a 2tuple filter",
6990 (void *)&cmd_2tuple_filter_add_filter,
6991 (void *)&cmd_2tuple_filter_port_id,
6992 (void *)&cmd_2tuple_filter_protocol,
6993 (void *)&cmd_2tuple_filter_protocol_value,
6994 (void *)&cmd_2tuple_filter_protocol_mask,
6995 (void *)&cmd_2tuple_filter_dst_port,
6996 (void *)&cmd_2tuple_filter_dst_port_value,
6997 (void *)&cmd_2tuple_filter_dst_port_mask,
6998 (void *)&cmd_2tuple_filter_flags,
6999 (void *)&cmd_2tuple_filter_flags_value,
7000 (void *)&cmd_2tuple_filter_priority,
7001 (void *)&cmd_2tuple_filter_priority_value,
7002 (void *)&cmd_2tuple_filter_queue,
7003 (void *)&cmd_2tuple_filter_queue_id,
7004 (void *)&cmd_2tuple_filter_index,
7005 (void *)&cmd_2tuple_filter_index_value,
7010 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7011 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7012 filter, "remove_2tuple_filter");
7013 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7014 .f = cmd_2tuple_filter_parsed,
7016 .help_str = "remove a 2tuple filter",
7018 (void *)&cmd_2tuple_filter_remove_filter,
7019 (void *)&cmd_2tuple_filter_port_id,
7020 (void *)&cmd_2tuple_filter_index,
7021 (void *)&cmd_2tuple_filter_index_value,
7025 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7026 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7027 filter, "get_2tuple_filter");
7028 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7029 .f = cmd_2tuple_filter_parsed,
7031 .help_str = "get a 2tuple filter",
7033 (void *)&cmd_2tuple_filter_get_filter,
7034 (void *)&cmd_2tuple_filter_port_id,
7035 (void *)&cmd_2tuple_filter_index,
7036 (void *)&cmd_2tuple_filter_index_value,
7041 /* *** ADD/REMOVE A 5tuple FILTER *** */
7042 struct cmd_5tuple_filter_result {
7043 cmdline_fixed_string_t filter;
7045 cmdline_fixed_string_t dst_ip;
7046 cmdline_ipaddr_t dst_ip_value;
7047 cmdline_fixed_string_t src_ip;
7048 cmdline_ipaddr_t src_ip_value;
7049 cmdline_fixed_string_t dst_port;
7050 uint16_t dst_port_value;
7051 cmdline_fixed_string_t src_port;
7052 uint16_t src_port_value;
7053 cmdline_fixed_string_t protocol;
7054 uint8_t protocol_value;
7055 cmdline_fixed_string_t mask;
7057 cmdline_fixed_string_t flags;
7058 uint8_t flags_value;
7059 cmdline_fixed_string_t priority;
7060 uint8_t priority_value;
7061 cmdline_fixed_string_t queue;
7063 cmdline_fixed_string_t index;
7064 uint16_t index_value;
7068 cmd_5tuple_filter_parsed(void *parsed_result,
7069 __attribute__((unused)) struct cmdline *cl,
7070 __attribute__((unused)) void *data)
7073 struct rte_5tuple_filter filter;
7074 struct cmd_5tuple_filter_result *res = parsed_result;
7076 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7078 if (!strcmp(res->filter, "add_5tuple_filter")) {
7079 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7080 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7081 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7082 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7083 filter.protocol = res->protocol_value;
7084 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7085 filter.priority = res->priority_value;
7086 filter.tcp_flags = res->flags_value;
7088 if (res->dst_ip_value.family == AF_INET)
7089 /* no need to convert, already big endian. */
7090 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7092 if (filter.dst_ip_mask == 0) {
7093 printf("can not support ipv6 involved compare.\n");
7099 if (res->src_ip_value.family == AF_INET)
7100 /* no need to convert, already big endian. */
7101 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7103 if (filter.src_ip_mask == 0) {
7104 printf("can not support ipv6 involved compare.\n");
7109 /* need convert to big endian. */
7110 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7111 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7113 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7114 res->index_value, &filter, res->queue_id);
7115 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7116 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7118 else if (!strcmp(res->filter, "get_5tuple_filter"))
7119 get_5tuple_filter(res->port_id, res->index_value);
7121 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7125 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7126 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7128 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7129 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7131 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7132 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7134 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7135 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7137 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7138 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7140 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7141 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7142 dst_port, "dst_port");
7143 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7144 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7145 dst_port_value, UINT16);
7146 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7147 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7148 src_port, "src_port");
7149 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7150 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7151 src_port_value, UINT16);
7152 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7153 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7154 protocol, "protocol");
7155 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7156 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7157 protocol_value, UINT8);
7158 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7159 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7161 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7162 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7164 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7165 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7167 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7168 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7169 flags_value, UINT8);
7170 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7171 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7172 priority, "priority");
7173 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7174 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7175 priority_value, UINT8);
7176 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7177 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7179 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7180 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7182 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7183 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7185 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7186 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7187 index_value, UINT16);
7189 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7190 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7191 filter, "add_5tuple_filter");
7192 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7193 .f = cmd_5tuple_filter_parsed,
7195 .help_str = "add a 5tuple filter",
7197 (void *)&cmd_5tuple_filter_add_filter,
7198 (void *)&cmd_5tuple_filter_port_id,
7199 (void *)&cmd_5tuple_filter_dst_ip,
7200 (void *)&cmd_5tuple_filter_dst_ip_value,
7201 (void *)&cmd_5tuple_filter_src_ip,
7202 (void *)&cmd_5tuple_filter_src_ip_value,
7203 (void *)&cmd_5tuple_filter_dst_port,
7204 (void *)&cmd_5tuple_filter_dst_port_value,
7205 (void *)&cmd_5tuple_filter_src_port,
7206 (void *)&cmd_5tuple_filter_src_port_value,
7207 (void *)&cmd_5tuple_filter_protocol,
7208 (void *)&cmd_5tuple_filter_protocol_value,
7209 (void *)&cmd_5tuple_filter_mask,
7210 (void *)&cmd_5tuple_filter_mask_value,
7211 (void *)&cmd_5tuple_filter_flags,
7212 (void *)&cmd_5tuple_filter_flags_value,
7213 (void *)&cmd_5tuple_filter_priority,
7214 (void *)&cmd_5tuple_filter_priority_value,
7215 (void *)&cmd_5tuple_filter_queue,
7216 (void *)&cmd_5tuple_filter_queue_id,
7217 (void *)&cmd_5tuple_filter_index,
7218 (void *)&cmd_5tuple_filter_index_value,
7223 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7224 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7225 filter, "remove_5tuple_filter");
7226 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7227 .f = cmd_5tuple_filter_parsed,
7229 .help_str = "remove a 5tuple filter",
7231 (void *)&cmd_5tuple_filter_remove_filter,
7232 (void *)&cmd_5tuple_filter_port_id,
7233 (void *)&cmd_5tuple_filter_index,
7234 (void *)&cmd_5tuple_filter_index_value,
7239 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7240 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7241 filter, "get_5tuple_filter");
7242 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7243 .f = cmd_5tuple_filter_parsed,
7245 .help_str = "get a 5tuple filter",
7247 (void *)&cmd_5tuple_filter_get_filter,
7248 (void *)&cmd_5tuple_filter_port_id,
7249 (void *)&cmd_5tuple_filter_index,
7250 (void *)&cmd_5tuple_filter_index_value,
7255 /* *** ADD/REMOVE A flex FILTER *** */
7256 struct cmd_flex_filter_result {
7257 cmdline_fixed_string_t filter;
7258 cmdline_fixed_string_t ops;
7260 cmdline_fixed_string_t len;
7262 cmdline_fixed_string_t bytes;
7263 cmdline_fixed_string_t bytes_value;
7264 cmdline_fixed_string_t mask;
7265 cmdline_fixed_string_t mask_value;
7266 cmdline_fixed_string_t priority;
7267 uint8_t priority_value;
7268 cmdline_fixed_string_t queue;
7272 static int xdigit2val(unsigned char c)
7277 else if (isupper(c))
7285 cmd_flex_filter_parsed(void *parsed_result,
7286 __attribute__((unused)) struct cmdline *cl,
7287 __attribute__((unused)) void *data)
7290 struct rte_eth_flex_filter filter;
7291 struct cmd_flex_filter_result *res = parsed_result;
7292 char *bytes_ptr, *mask_ptr;
7293 uint16_t len, i, j = 0;
7298 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7299 printf("the len exceed the max length 128\n");
7302 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7303 filter.len = res->len_value;
7304 filter.priority = res->priority_value;
7305 filter.queue = res->queue_id;
7306 bytes_ptr = res->bytes_value;
7307 mask_ptr = res->mask_value;
7309 /* translate bytes string to array. */
7310 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7311 (bytes_ptr[1] == 'X')))
7313 len = strnlen(bytes_ptr, res->len_value * 2);
7314 if (len == 0 || (len % 8 != 0)) {
7315 printf("please check len and bytes input\n");
7318 for (i = 0; i < len; i++) {
7320 if (isxdigit(c) == 0) {
7321 /* invalid characters. */
7322 printf("invalid input\n");
7325 val = xdigit2val(c);
7328 filter.bytes[j] = byte;
7329 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7336 /* translate mask string to uint8_t array. */
7337 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7338 (mask_ptr[1] == 'X')))
7340 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7342 printf("invalid input\n");
7347 for (i = 0; i < len; i++) {
7349 if (isxdigit(c) == 0) {
7350 /* invalid characters. */
7351 printf("invalid input\n");
7354 val = xdigit2val(c);
7357 filter.mask[j] = byte;
7358 printf("mask[%d]:%02x ", j, filter.mask[j]);
7366 if (!strcmp(res->ops, "add"))
7367 ret = rte_eth_dev_filter_ctrl(res->port_id,
7368 RTE_ETH_FILTER_FLEXIBLE,
7372 ret = rte_eth_dev_filter_ctrl(res->port_id,
7373 RTE_ETH_FILTER_FLEXIBLE,
7374 RTE_ETH_FILTER_DELETE,
7378 printf("flex filter setting error: (%s)\n", strerror(-ret));
7381 cmdline_parse_token_string_t cmd_flex_filter_filter =
7382 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7383 filter, "flex_filter");
7384 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7385 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7387 cmdline_parse_token_string_t cmd_flex_filter_ops =
7388 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7390 cmdline_parse_token_string_t cmd_flex_filter_len =
7391 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7393 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7394 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7396 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7397 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7399 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7400 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7402 cmdline_parse_token_string_t cmd_flex_filter_mask =
7403 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7405 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7406 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7408 cmdline_parse_token_string_t cmd_flex_filter_priority =
7409 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7410 priority, "priority");
7411 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7412 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7413 priority_value, UINT8);
7414 cmdline_parse_token_string_t cmd_flex_filter_queue =
7415 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7417 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7418 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7420 cmdline_parse_inst_t cmd_flex_filter = {
7421 .f = cmd_flex_filter_parsed,
7423 .help_str = "add/del a flex filter",
7425 (void *)&cmd_flex_filter_filter,
7426 (void *)&cmd_flex_filter_port_id,
7427 (void *)&cmd_flex_filter_ops,
7428 (void *)&cmd_flex_filter_len,
7429 (void *)&cmd_flex_filter_len_value,
7430 (void *)&cmd_flex_filter_bytes,
7431 (void *)&cmd_flex_filter_bytes_value,
7432 (void *)&cmd_flex_filter_mask,
7433 (void *)&cmd_flex_filter_mask_value,
7434 (void *)&cmd_flex_filter_priority,
7435 (void *)&cmd_flex_filter_priority_value,
7436 (void *)&cmd_flex_filter_queue,
7437 (void *)&cmd_flex_filter_queue_id,
7442 /* *** Filters Control *** */
7444 /* *** deal with ethertype filter *** */
7445 struct cmd_ethertype_filter_result {
7446 cmdline_fixed_string_t filter;
7448 cmdline_fixed_string_t ops;
7449 cmdline_fixed_string_t mac;
7450 struct ether_addr mac_addr;
7451 cmdline_fixed_string_t ethertype;
7452 uint16_t ethertype_value;
7453 cmdline_fixed_string_t drop;
7454 cmdline_fixed_string_t queue;
7458 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7459 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7460 filter, "ethertype_filter");
7461 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7462 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7464 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7465 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7467 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7468 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7469 mac, "mac_addr#mac_ignr");
7470 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7471 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7473 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7474 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7475 ethertype, "ethertype");
7476 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7477 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7478 ethertype_value, UINT16);
7479 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7480 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7482 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7483 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7485 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7486 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7490 cmd_ethertype_filter_parsed(void *parsed_result,
7491 __attribute__((unused)) struct cmdline *cl,
7492 __attribute__((unused)) void *data)
7494 struct cmd_ethertype_filter_result *res = parsed_result;
7495 struct rte_eth_ethertype_filter filter;
7498 ret = rte_eth_dev_filter_supported(res->port_id,
7499 RTE_ETH_FILTER_ETHERTYPE);
7501 printf("ethertype filter is not supported on port %u.\n",
7506 memset(&filter, 0, sizeof(filter));
7507 if (!strcmp(res->mac, "mac_addr")) {
7508 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7509 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7510 sizeof(struct ether_addr));
7512 if (!strcmp(res->drop, "drop"))
7513 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7514 filter.ether_type = res->ethertype_value;
7515 filter.queue = res->queue_id;
7517 if (!strcmp(res->ops, "add"))
7518 ret = rte_eth_dev_filter_ctrl(res->port_id,
7519 RTE_ETH_FILTER_ETHERTYPE,
7523 ret = rte_eth_dev_filter_ctrl(res->port_id,
7524 RTE_ETH_FILTER_ETHERTYPE,
7525 RTE_ETH_FILTER_DELETE,
7528 printf("ethertype filter programming error: (%s)\n",
7532 cmdline_parse_inst_t cmd_ethertype_filter = {
7533 .f = cmd_ethertype_filter_parsed,
7535 .help_str = "add or delete an ethertype filter entry",
7537 (void *)&cmd_ethertype_filter_filter,
7538 (void *)&cmd_ethertype_filter_port_id,
7539 (void *)&cmd_ethertype_filter_ops,
7540 (void *)&cmd_ethertype_filter_mac,
7541 (void *)&cmd_ethertype_filter_mac_addr,
7542 (void *)&cmd_ethertype_filter_ethertype,
7543 (void *)&cmd_ethertype_filter_ethertype_value,
7544 (void *)&cmd_ethertype_filter_drop,
7545 (void *)&cmd_ethertype_filter_queue,
7546 (void *)&cmd_ethertype_filter_queue_id,
7551 /* *** deal with flow director filter *** */
7552 struct cmd_flow_director_result {
7553 cmdline_fixed_string_t flow_director_filter;
7555 cmdline_fixed_string_t ops;
7556 cmdline_fixed_string_t flow;
7557 cmdline_fixed_string_t flow_type;
7558 cmdline_fixed_string_t src;
7559 cmdline_ipaddr_t ip_src;
7561 cmdline_fixed_string_t dst;
7562 cmdline_ipaddr_t ip_dst;
7564 cmdline_fixed_string_t verify_tag;
7565 uint32_t verify_tag_value;
7566 cmdline_fixed_string_t vlan;
7567 uint16_t vlan_value;
7568 cmdline_fixed_string_t flexbytes;
7569 cmdline_fixed_string_t flexbytes_value;
7570 cmdline_fixed_string_t drop;
7571 cmdline_fixed_string_t queue;
7573 cmdline_fixed_string_t fd_id;
7574 uint32_t fd_id_value;
7578 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7581 const char *p, *p0 = q_arg;
7583 unsigned long int_fld;
7584 char *str_fld[max_num];
7589 p = strchr(p0, '(');
7593 p0 = strchr(p, ')');
7598 if (size >= sizeof(s))
7601 snprintf(s, sizeof(s), "%.*s", size, p);
7602 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7603 if (ret < 0 || ret > max_num)
7605 for (i = 0; i < ret; i++) {
7607 int_fld = strtoul(str_fld[i], &end, 0);
7608 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7610 flexbytes[i] = (uint8_t)int_fld;
7615 static enum rte_eth_flow_type
7616 str2flowtype(char *string)
7619 static const struct {
7621 enum rte_eth_flow_type type;
7622 } flowtype_str[] = {
7623 {"raw", RTE_ETH_FLOW_TYPE_RAW},
7624 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
7625 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
7626 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
7627 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
7628 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
7629 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
7630 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
7631 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
7632 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
7633 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
7636 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7637 if (!strcmp(flowtype_str[i].str, string))
7638 return flowtype_str[i].type;
7640 return RTE_ETH_FLOW_TYPE_NONE;
7643 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
7645 if ((ip_addr).family == AF_INET) \
7646 (ip) = (ip_addr).addr.ipv4.s_addr; \
7648 printf("invalid parameter.\n"); \
7653 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
7655 if ((ip_addr).family == AF_INET6) \
7656 (void)rte_memcpy(&(ip), \
7657 &((ip_addr).addr.ipv6), \
7658 sizeof(struct in6_addr)); \
7660 printf("invalid parameter.\n"); \
7666 cmd_flow_director_filter_parsed(void *parsed_result,
7667 __attribute__((unused)) struct cmdline *cl,
7668 __attribute__((unused)) void *data)
7670 struct cmd_flow_director_result *res = parsed_result;
7671 struct rte_eth_fdir_filter entry;
7672 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
7675 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7677 printf("flow director is not supported on port %u.\n",
7681 memset(flexbytes, 0, sizeof(flexbytes));
7682 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
7683 ret = parse_flexbytes(res->flexbytes_value,
7685 RTE_ETH_FDIR_MAX_FLEXLEN);
7687 printf("error: Cannot parse flexbytes input.\n");
7691 entry.input.flow_type = str2flowtype(res->flow_type);
7692 switch (entry.input.flow_type) {
7693 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
7694 case RTE_ETH_FLOW_TYPE_FRAG_IPV4:
7695 case RTE_ETH_FLOW_TYPE_UDPV4:
7696 case RTE_ETH_FLOW_TYPE_TCPV4:
7697 IPV4_ADDR_TO_UINT(res->ip_dst,
7698 entry.input.flow.ip4_flow.dst_ip);
7699 IPV4_ADDR_TO_UINT(res->ip_src,
7700 entry.input.flow.ip4_flow.src_ip);
7701 /* need convert to big endian. */
7702 entry.input.flow.udp4_flow.dst_port =
7703 rte_cpu_to_be_16(res->port_dst);
7704 entry.input.flow.udp4_flow.src_port =
7705 rte_cpu_to_be_16(res->port_src);
7707 case RTE_ETH_FLOW_TYPE_SCTPV4:
7708 IPV4_ADDR_TO_UINT(res->ip_dst,
7709 entry.input.flow.sctp4_flow.ip.dst_ip);
7710 IPV4_ADDR_TO_UINT(res->ip_src,
7711 entry.input.flow.sctp4_flow.ip.src_ip);
7712 /* need convert to big endian. */
7713 entry.input.flow.sctp4_flow.verify_tag =
7714 rte_cpu_to_be_32(res->verify_tag_value);
7716 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
7717 case RTE_ETH_FLOW_TYPE_FRAG_IPV6:
7718 case RTE_ETH_FLOW_TYPE_UDPV6:
7719 case RTE_ETH_FLOW_TYPE_TCPV6:
7720 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7721 entry.input.flow.ipv6_flow.dst_ip);
7722 IPV6_ADDR_TO_ARRAY(res->ip_src,
7723 entry.input.flow.ipv6_flow.src_ip);
7724 /* need convert to big endian. */
7725 entry.input.flow.udp6_flow.dst_port =
7726 rte_cpu_to_be_16(res->port_dst);
7727 entry.input.flow.udp6_flow.src_port =
7728 rte_cpu_to_be_16(res->port_src);
7730 case RTE_ETH_FLOW_TYPE_SCTPV6:
7731 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7732 entry.input.flow.sctp6_flow.ip.dst_ip);
7733 IPV6_ADDR_TO_ARRAY(res->ip_src,
7734 entry.input.flow.sctp6_flow.ip.src_ip);
7735 /* need convert to big endian. */
7736 entry.input.flow.sctp6_flow.verify_tag =
7737 rte_cpu_to_be_32(res->verify_tag_value);
7740 printf("invalid parameter.\n");
7743 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
7745 RTE_ETH_FDIR_MAX_FLEXLEN);
7747 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
7749 entry.action.flex_off = 0; /*use 0 by default */
7750 if (!strcmp(res->drop, "drop"))
7751 entry.action.behavior = RTE_ETH_FDIR_REJECT;
7753 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
7754 /* set to report FD ID by default */
7755 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
7756 entry.action.rx_queue = res->queue_id;
7757 entry.soft_id = res->fd_id_value;
7758 if (!strcmp(res->ops, "add"))
7759 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7760 RTE_ETH_FILTER_ADD, &entry);
7761 else if (!strcmp(res->ops, "del"))
7762 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7763 RTE_ETH_FILTER_DELETE, &entry);
7765 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7766 RTE_ETH_FILTER_UPDATE, &entry);
7768 printf("flow director programming error: (%s)\n",
7772 cmdline_parse_token_string_t cmd_flow_director_filter =
7773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7774 flow_director_filter, "flow_director_filter");
7775 cmdline_parse_token_num_t cmd_flow_director_port_id =
7776 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7778 cmdline_parse_token_string_t cmd_flow_director_ops =
7779 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7780 ops, "add#del#update");
7781 cmdline_parse_token_string_t cmd_flow_director_flow =
7782 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7784 cmdline_parse_token_string_t cmd_flow_director_flow_type =
7785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7787 "ip4#ip4-frag#tcp4#udp4#sctp4#"
7788 "ip6#ip6-frag#tcp6#udp6#sctp6");
7789 cmdline_parse_token_string_t cmd_flow_director_src =
7790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7792 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
7793 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7795 cmdline_parse_token_num_t cmd_flow_director_port_src =
7796 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7798 cmdline_parse_token_string_t cmd_flow_director_dst =
7799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7801 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
7802 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7804 cmdline_parse_token_num_t cmd_flow_director_port_dst =
7805 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7807 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
7808 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7809 verify_tag, "verify_tag");
7810 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
7811 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7812 verify_tag_value, UINT32);
7813 cmdline_parse_token_string_t cmd_flow_director_vlan =
7814 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7816 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
7817 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7818 vlan_value, UINT16);
7819 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
7820 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7821 flexbytes, "flexbytes");
7822 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
7823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7824 flexbytes_value, NULL);
7825 cmdline_parse_token_string_t cmd_flow_director_drop =
7826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7828 cmdline_parse_token_string_t cmd_flow_director_queue =
7829 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7831 cmdline_parse_token_num_t cmd_flow_director_queue_id =
7832 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7834 cmdline_parse_token_string_t cmd_flow_director_fd_id =
7835 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7837 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
7838 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7839 fd_id_value, UINT32);
7841 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
7842 .f = cmd_flow_director_filter_parsed,
7844 .help_str = "add or delete an ip flow director entry on NIC",
7846 (void *)&cmd_flow_director_filter,
7847 (void *)&cmd_flow_director_port_id,
7848 (void *)&cmd_flow_director_ops,
7849 (void *)&cmd_flow_director_flow,
7850 (void *)&cmd_flow_director_flow_type,
7851 (void *)&cmd_flow_director_src,
7852 (void *)&cmd_flow_director_ip_src,
7853 (void *)&cmd_flow_director_dst,
7854 (void *)&cmd_flow_director_ip_dst,
7855 (void *)&cmd_flow_director_vlan,
7856 (void *)&cmd_flow_director_vlan_value,
7857 (void *)&cmd_flow_director_flexbytes,
7858 (void *)&cmd_flow_director_flexbytes_value,
7859 (void *)&cmd_flow_director_drop,
7860 (void *)&cmd_flow_director_queue,
7861 (void *)&cmd_flow_director_queue_id,
7862 (void *)&cmd_flow_director_fd_id,
7863 (void *)&cmd_flow_director_fd_id_value,
7868 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
7869 .f = cmd_flow_director_filter_parsed,
7871 .help_str = "add or delete an udp/tcp flow director entry on NIC",
7873 (void *)&cmd_flow_director_filter,
7874 (void *)&cmd_flow_director_port_id,
7875 (void *)&cmd_flow_director_ops,
7876 (void *)&cmd_flow_director_flow,
7877 (void *)&cmd_flow_director_flow_type,
7878 (void *)&cmd_flow_director_src,
7879 (void *)&cmd_flow_director_ip_src,
7880 (void *)&cmd_flow_director_port_src,
7881 (void *)&cmd_flow_director_dst,
7882 (void *)&cmd_flow_director_ip_dst,
7883 (void *)&cmd_flow_director_port_dst,
7884 (void *)&cmd_flow_director_vlan,
7885 (void *)&cmd_flow_director_vlan_value,
7886 (void *)&cmd_flow_director_flexbytes,
7887 (void *)&cmd_flow_director_flexbytes_value,
7888 (void *)&cmd_flow_director_drop,
7889 (void *)&cmd_flow_director_queue,
7890 (void *)&cmd_flow_director_queue_id,
7891 (void *)&cmd_flow_director_fd_id,
7892 (void *)&cmd_flow_director_fd_id_value,
7897 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
7898 .f = cmd_flow_director_filter_parsed,
7900 .help_str = "add or delete a sctp flow director entry on NIC",
7902 (void *)&cmd_flow_director_filter,
7903 (void *)&cmd_flow_director_port_id,
7904 (void *)&cmd_flow_director_ops,
7905 (void *)&cmd_flow_director_flow,
7906 (void *)&cmd_flow_director_flow_type,
7907 (void *)&cmd_flow_director_src,
7908 (void *)&cmd_flow_director_ip_src,
7909 (void *)&cmd_flow_director_port_dst,
7910 (void *)&cmd_flow_director_dst,
7911 (void *)&cmd_flow_director_ip_dst,
7912 (void *)&cmd_flow_director_port_dst,
7913 (void *)&cmd_flow_director_verify_tag,
7914 (void *)&cmd_flow_director_verify_tag_value,
7915 (void *)&cmd_flow_director_vlan,
7916 (void *)&cmd_flow_director_vlan_value,
7917 (void *)&cmd_flow_director_flexbytes,
7918 (void *)&cmd_flow_director_flexbytes_value,
7919 (void *)&cmd_flow_director_drop,
7920 (void *)&cmd_flow_director_queue,
7921 (void *)&cmd_flow_director_queue_id,
7922 (void *)&cmd_flow_director_fd_id,
7923 (void *)&cmd_flow_director_fd_id_value,
7928 struct cmd_flush_flow_director_result {
7929 cmdline_fixed_string_t flush_flow_director;
7933 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
7934 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
7935 flush_flow_director, "flush_flow_director");
7936 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
7937 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
7941 cmd_flush_flow_director_parsed(void *parsed_result,
7942 __attribute__((unused)) struct cmdline *cl,
7943 __attribute__((unused)) void *data)
7945 struct cmd_flow_director_result *res = parsed_result;
7948 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7950 printf("flow director is not supported on port %u.\n",
7955 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7956 RTE_ETH_FILTER_FLUSH, NULL);
7958 printf("flow director table flushing error: (%s)\n",
7962 cmdline_parse_inst_t cmd_flush_flow_director = {
7963 .f = cmd_flush_flow_director_parsed,
7965 .help_str = "flush all flow director entries of a device on NIC",
7967 (void *)&cmd_flush_flow_director_flush,
7968 (void *)&cmd_flush_flow_director_port_id,
7973 /* *** deal with flow director mask *** */
7974 struct cmd_flow_director_mask_result {
7975 cmdline_fixed_string_t flow_director_mask;
7977 cmdline_fixed_string_t vlan;
7978 uint16_t vlan_value;
7979 cmdline_fixed_string_t src_mask;
7980 cmdline_ipaddr_t ipv4_src;
7981 cmdline_ipaddr_t ipv6_src;
7983 cmdline_fixed_string_t dst_mask;
7984 cmdline_ipaddr_t ipv4_dst;
7985 cmdline_ipaddr_t ipv6_dst;
7990 cmd_flow_director_mask_parsed(void *parsed_result,
7991 __attribute__((unused)) struct cmdline *cl,
7992 __attribute__((unused)) void *data)
7994 struct cmd_flow_director_mask_result *res = parsed_result;
7995 struct rte_eth_fdir_masks *mask;
7996 struct rte_port *port;
7998 if (res->port_id > nb_ports) {
7999 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8003 port = &ports[res->port_id];
8004 /** Check if the port is not started **/
8005 if (port->port_status != RTE_PORT_STOPPED) {
8006 printf("Please stop port %d first\n", res->port_id);
8009 mask = &port->dev_conf.fdir_conf.mask;
8011 mask->vlan_tci_mask = res->vlan_value;
8012 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8013 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8014 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8015 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8016 mask->src_port_mask = res->port_src;
8017 mask->dst_port_mask = res->port_dst;
8019 cmd_reconfig_device_queue(res->port_id, 1, 1);
8022 cmdline_parse_token_string_t cmd_flow_director_mask =
8023 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8024 flow_director_mask, "flow_director_mask");
8025 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8026 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8028 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8029 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8031 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8032 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8033 vlan_value, UINT16);
8034 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8035 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8036 src_mask, "src_mask");
8037 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8038 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8040 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8041 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8043 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8044 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8046 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8048 dst_mask, "dst_mask");
8049 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8050 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8052 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8053 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8055 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8056 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8058 cmdline_parse_inst_t cmd_set_flow_director_mask = {
8059 .f = cmd_flow_director_mask_parsed,
8061 .help_str = "set flow director's mask on NIC",
8063 (void *)&cmd_flow_director_mask,
8064 (void *)&cmd_flow_director_mask_port_id,
8065 (void *)&cmd_flow_director_mask_vlan,
8066 (void *)&cmd_flow_director_mask_vlan_value,
8067 (void *)&cmd_flow_director_mask_src,
8068 (void *)&cmd_flow_director_mask_ipv4_src,
8069 (void *)&cmd_flow_director_mask_ipv6_src,
8070 (void *)&cmd_flow_director_mask_port_src,
8071 (void *)&cmd_flow_director_mask_dst,
8072 (void *)&cmd_flow_director_mask_ipv4_dst,
8073 (void *)&cmd_flow_director_mask_ipv6_dst,
8074 (void *)&cmd_flow_director_mask_port_dst,
8079 /* *** deal with flow director mask on flexible payload *** */
8080 struct cmd_flow_director_flex_mask_result {
8081 cmdline_fixed_string_t flow_director_flexmask;
8083 cmdline_fixed_string_t flow;
8084 cmdline_fixed_string_t flow_type;
8085 cmdline_fixed_string_t mask;
8089 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8090 __attribute__((unused)) struct cmdline *cl,
8091 __attribute__((unused)) void *data)
8093 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8094 struct rte_eth_fdir_info fdir_info;
8095 struct rte_eth_fdir_flex_mask flex_mask;
8096 struct rte_port *port;
8097 enum rte_eth_flow_type i;
8100 if (res->port_id > nb_ports) {
8101 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8105 port = &ports[res->port_id];
8106 /** Check if the port is not started **/
8107 if (port->port_status != RTE_PORT_STOPPED) {
8108 printf("Please stop port %d first\n", res->port_id);
8112 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8113 ret = parse_flexbytes(res->mask,
8115 RTE_ETH_FDIR_MAX_FLEXLEN);
8117 printf("error: Cannot parse mask input.\n");
8121 if (!strcmp(res->flow_type, "all")) {
8122 memset(&fdir_info, 0, sizeof(fdir_info));
8123 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8124 RTE_ETH_FILTER_INFO, &fdir_info);
8125 for (i = RTE_ETH_FLOW_TYPE_RAW;
8126 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8128 if (fdir_info.flow_types_mask[0] & (1 << i)) {
8129 flex_mask.flow_type = i;
8130 fdir_set_flex_mask(res->port_id, &flex_mask);
8133 cmd_reconfig_device_queue(res->port_id, 1, 1);
8136 flex_mask.flow_type = str2flowtype(res->flow_type);
8137 fdir_set_flex_mask(res->port_id, &flex_mask);
8138 cmd_reconfig_device_queue(res->port_id, 1, 1);
8141 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8142 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8143 flow_director_flexmask,
8144 "flow_director_flex_mask");
8145 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8146 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8148 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8151 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8154 "raw#ip4#ip4-frag#tcp4#udp4#sctp4#"
8155 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8156 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8157 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8160 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8161 .f = cmd_flow_director_flex_mask_parsed,
8163 .help_str = "set flow director's flex mask on NIC",
8165 (void *)&cmd_flow_director_flexmask,
8166 (void *)&cmd_flow_director_flexmask_port_id,
8167 (void *)&cmd_flow_director_flexmask_flow,
8168 (void *)&cmd_flow_director_flexmask_flow_type,
8169 (void *)&cmd_flow_director_flexmask_mask,
8174 /* *** deal with flow director flexible payload configuration *** */
8175 struct cmd_flow_director_flexpayload_result {
8176 cmdline_fixed_string_t flow_director_flexpayload;
8178 cmdline_fixed_string_t payload_layer;
8179 cmdline_fixed_string_t payload_cfg;
8183 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8186 const char *p, *p0 = q_arg;
8188 unsigned long int_fld;
8189 char *str_fld[max_num];
8194 p = strchr(p0, '(');
8198 p0 = strchr(p, ')');
8203 if (size >= sizeof(s))
8206 snprintf(s, sizeof(s), "%.*s", size, p);
8207 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8208 if (ret < 0 || ret > max_num)
8210 for (i = 0; i < ret; i++) {
8212 int_fld = strtoul(str_fld[i], &end, 0);
8213 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8215 offsets[i] = (uint16_t)int_fld;
8221 cmd_flow_director_flxpld_parsed(void *parsed_result,
8222 __attribute__((unused)) struct cmdline *cl,
8223 __attribute__((unused)) void *data)
8225 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8226 struct rte_eth_flex_payload_cfg flex_cfg;
8227 struct rte_port *port;
8230 if (res->port_id > nb_ports) {
8231 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8235 port = &ports[res->port_id];
8236 /** Check if the port is not started **/
8237 if (port->port_status != RTE_PORT_STOPPED) {
8238 printf("Please stop port %d first\n", res->port_id);
8242 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8244 if (!strcmp(res->payload_layer, "raw"))
8245 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8246 else if (!strcmp(res->payload_layer, "l2"))
8247 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8248 else if (!strcmp(res->payload_layer, "l3"))
8249 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8250 else if (!strcmp(res->payload_layer, "l4"))
8251 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8253 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8254 RTE_ETH_FDIR_MAX_FLEXLEN);
8256 printf("error: Cannot parse flex payload input.\n");
8260 fdir_set_flex_payload(res->port_id, &flex_cfg);
8261 cmd_reconfig_device_queue(res->port_id, 1, 1);
8264 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8266 flow_director_flexpayload,
8267 "flow_director_flex_payload");
8268 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8269 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8271 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8273 payload_layer, "raw#l2#l3#l4");
8274 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8275 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8278 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8279 .f = cmd_flow_director_flxpld_parsed,
8281 .help_str = "set flow director's flex payload on NIC",
8283 (void *)&cmd_flow_director_flexpayload,
8284 (void *)&cmd_flow_director_flexpayload_port_id,
8285 (void *)&cmd_flow_director_flexpayload_payload_layer,
8286 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8291 /* *** Classification Filters Control *** */
8292 /* *** Get symmetric hash enable per port *** */
8293 struct cmd_get_sym_hash_ena_per_port_result {
8294 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8299 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8300 __rte_unused struct cmdline *cl,
8301 __rte_unused void *data)
8303 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8304 struct rte_eth_hash_filter_info info;
8307 if (rte_eth_dev_filter_supported(res->port_id,
8308 RTE_ETH_FILTER_HASH) < 0) {
8309 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8314 memset(&info, 0, sizeof(info));
8315 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8316 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8317 RTE_ETH_FILTER_GET, &info);
8320 printf("Cannot get symmetric hash enable per port "
8321 "on port %u\n", res->port_id);
8325 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8326 "enabled" : "disabled", res->port_id);
8329 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8330 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8331 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8332 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8333 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8336 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8337 .f = cmd_get_sym_hash_per_port_parsed,
8339 .help_str = "get_sym_hash_ena_per_port port_id",
8341 (void *)&cmd_get_sym_hash_ena_per_port_all,
8342 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8347 /* *** Set symmetric hash enable per port *** */
8348 struct cmd_set_sym_hash_ena_per_port_result {
8349 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8350 cmdline_fixed_string_t enable;
8355 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8356 __rte_unused struct cmdline *cl,
8357 __rte_unused void *data)
8359 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8360 struct rte_eth_hash_filter_info info;
8363 if (rte_eth_dev_filter_supported(res->port_id,
8364 RTE_ETH_FILTER_HASH) < 0) {
8365 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8370 memset(&info, 0, sizeof(info));
8371 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8372 if (!strcmp(res->enable, "enable"))
8373 info.info.enable = 1;
8374 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8375 RTE_ETH_FILTER_SET, &info);
8377 printf("Cannot set symmetric hash enable per port on "
8378 "port %u\n", res->port_id);
8381 printf("Symmetric hash has been set to %s on port %u\n",
8382 res->enable, res->port_id);
8385 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8386 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8387 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8388 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8389 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8391 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8392 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8393 enable, "enable#disable");
8395 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8396 .f = cmd_set_sym_hash_per_port_parsed,
8398 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8400 (void *)&cmd_set_sym_hash_ena_per_port_all,
8401 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8402 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8407 /* Get global config of hash function */
8408 struct cmd_get_hash_global_config_result {
8409 cmdline_fixed_string_t get_hash_global_config;
8414 flowtype_to_str(enum rte_eth_flow_type ftype)
8419 enum rte_eth_flow_type ftype;
8421 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8422 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8423 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8424 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8425 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8426 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8427 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8428 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8429 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8430 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8433 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8434 if (ftype_table[i].ftype == ftype)
8435 return ftype_table[i].str;
8442 cmd_get_hash_global_config_parsed(void *parsed_result,
8443 __rte_unused struct cmdline *cl,
8444 __rte_unused void *data)
8446 struct cmd_get_hash_global_config_result *res = parsed_result;
8447 struct rte_eth_hash_filter_info info;
8448 uint32_t idx, offset, i;
8452 if (rte_eth_dev_filter_supported(res->port_id,
8453 RTE_ETH_FILTER_HASH) < 0) {
8454 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8459 memset(&info, 0, sizeof(info));
8460 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8461 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8462 RTE_ETH_FILTER_GET, &info);
8464 printf("Cannot get hash global configurations by port %d\n",
8469 switch (info.info.global_conf.hash_func) {
8470 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8471 printf("Hash function is Toeplitz\n");
8473 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8474 printf("Hash function is Simple XOR\n");
8477 printf("Unknown hash function\n");
8481 for (i = 0; i < RTE_ETH_FLOW_TYPE_MAX; i++) {
8482 idx = i / UINT32_BIT;
8483 offset = i % UINT32_BIT;
8484 if (!(info.info.global_conf.valid_bit_mask[idx] &
8487 str = flowtype_to_str((enum rte_eth_flow_type)i);
8490 printf("Symmetric hash is %s globally for flow type %s "
8492 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8493 (1UL << offset)) ? "enabled" : "disabled"), str,
8498 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8499 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8500 get_hash_global_config, "get_hash_global_config");
8501 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8502 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8505 cmdline_parse_inst_t cmd_get_hash_global_config = {
8506 .f = cmd_get_hash_global_config_parsed,
8508 .help_str = "get_hash_global_config port_id",
8510 (void *)&cmd_get_hash_global_config_all,
8511 (void *)&cmd_get_hash_global_config_port_id,
8516 /* Set global config of hash function */
8517 struct cmd_set_hash_global_config_result {
8518 cmdline_fixed_string_t set_hash_global_config;
8520 cmdline_fixed_string_t hash_func;
8521 cmdline_fixed_string_t flow_type;
8522 cmdline_fixed_string_t enable;
8526 cmd_set_hash_global_config_parsed(void *parsed_result,
8527 __rte_unused struct cmdline *cl,
8528 __rte_unused void *data)
8530 struct cmd_set_hash_global_config_result *res = parsed_result;
8531 struct rte_eth_hash_filter_info info;
8532 uint32_t ftype, idx, offset;
8535 if (rte_eth_dev_filter_supported(res->port_id,
8536 RTE_ETH_FILTER_HASH) < 0) {
8537 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8541 memset(&info, 0, sizeof(info));
8542 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8543 if (!strcmp(res->hash_func, "toeplitz"))
8544 info.info.global_conf.hash_func =
8545 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8546 else if (!strcmp(res->hash_func, "simple_xor"))
8547 info.info.global_conf.hash_func =
8548 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8549 else if (!strcmp(res->hash_func, "default"))
8550 info.info.global_conf.hash_func =
8551 RTE_ETH_HASH_FUNCTION_DEFAULT;
8553 ftype = str2flowtype(res->flow_type);
8554 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8555 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8556 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8557 if (!strcmp(res->enable, "enable"))
8558 info.info.global_conf.sym_hash_enable_mask[idx] |=
8560 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8561 RTE_ETH_FILTER_SET, &info);
8563 printf("Cannot set global hash configurations by port %d\n",
8566 printf("Global hash configurations have been set "
8567 "succcessfully by port %d\n", res->port_id);
8570 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8571 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8572 set_hash_global_config, "set_hash_global_config");
8573 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8574 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8576 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8577 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8578 hash_func, "toeplitz#simple_xor#default");
8579 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8580 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8582 "ip4#ip4-frag#tcp4#udp4#sctp4#ip6#ip6-frag#tcp6#udp6#sctp6");
8583 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8584 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8585 enable, "enable#disable");
8587 cmdline_parse_inst_t cmd_set_hash_global_config = {
8588 .f = cmd_set_hash_global_config_parsed,
8590 .help_str = "set_hash_global_config port_id "
8591 "toeplitz|simple_xor|default "
8592 "ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6 "
8595 (void *)&cmd_set_hash_global_config_all,
8596 (void *)&cmd_set_hash_global_config_port_id,
8597 (void *)&cmd_set_hash_global_config_hash_func,
8598 (void *)&cmd_set_hash_global_config_flow_type,
8599 (void *)&cmd_set_hash_global_config_enable,
8604 /* ******************************************************************************** */
8606 /* list of instructions */
8607 cmdline_parse_ctx_t main_ctx[] = {
8608 (cmdline_parse_inst_t *)&cmd_help_brief,
8609 (cmdline_parse_inst_t *)&cmd_help_long,
8610 (cmdline_parse_inst_t *)&cmd_quit,
8611 (cmdline_parse_inst_t *)&cmd_showport,
8612 (cmdline_parse_inst_t *)&cmd_showportall,
8613 (cmdline_parse_inst_t *)&cmd_showcfg,
8614 (cmdline_parse_inst_t *)&cmd_start,
8615 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8616 (cmdline_parse_inst_t *)&cmd_set_link_up,
8617 (cmdline_parse_inst_t *)&cmd_set_link_down,
8618 (cmdline_parse_inst_t *)&cmd_reset,
8619 (cmdline_parse_inst_t *)&cmd_set_numbers,
8620 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8621 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8622 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8623 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8624 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8625 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8626 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8627 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8628 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8629 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8630 (cmdline_parse_inst_t *)&cmd_set_link_check,
8631 #ifdef RTE_NIC_BYPASS
8632 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8633 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8634 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8635 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8637 #ifdef RTE_LIBRTE_PMD_BOND
8638 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8639 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8640 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8641 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8642 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8643 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8644 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8645 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8646 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8648 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8649 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8650 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8651 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8652 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8653 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8654 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8655 (cmdline_parse_inst_t *)&cmd_csum_set,
8656 (cmdline_parse_inst_t *)&cmd_csum_show,
8657 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
8658 (cmdline_parse_inst_t *)&cmd_tso_set,
8659 (cmdline_parse_inst_t *)&cmd_tso_show,
8660 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8661 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8662 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8663 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8664 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8665 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8666 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8667 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8668 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8669 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8670 (cmdline_parse_inst_t *)&cmd_config_dcb,
8671 (cmdline_parse_inst_t *)&cmd_read_reg,
8672 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8673 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8674 (cmdline_parse_inst_t *)&cmd_write_reg,
8675 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8676 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8677 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8678 (cmdline_parse_inst_t *)&cmd_stop,
8679 (cmdline_parse_inst_t *)&cmd_mac_addr,
8680 (cmdline_parse_inst_t *)&cmd_set_qmap,
8681 (cmdline_parse_inst_t *)&cmd_operate_port,
8682 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8683 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8684 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8685 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8686 (cmdline_parse_inst_t *)&cmd_config_mtu,
8687 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8688 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8689 (cmdline_parse_inst_t *)&cmd_config_rss,
8690 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8691 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8692 (cmdline_parse_inst_t *)&cmd_showport_reta,
8693 (cmdline_parse_inst_t *)&cmd_config_burst,
8694 (cmdline_parse_inst_t *)&cmd_config_thresh,
8695 (cmdline_parse_inst_t *)&cmd_config_threshold,
8696 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8697 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8698 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8699 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8700 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8701 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8702 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8703 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8704 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8705 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8706 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8707 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8708 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8709 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8710 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8711 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8712 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8713 (cmdline_parse_inst_t *)&cmd_dump,
8714 (cmdline_parse_inst_t *)&cmd_dump_one,
8715 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
8716 (cmdline_parse_inst_t *)&cmd_syn_filter,
8717 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
8718 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
8719 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
8720 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
8721 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
8722 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
8723 (cmdline_parse_inst_t *)&cmd_flex_filter,
8724 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8725 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8726 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8727 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8728 (cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
8729 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8730 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
8731 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
8732 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
8733 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
8734 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
8738 /* prompt function, called from main on MASTER lcore */
8744 /* initialize non-constant commands */
8745 cmd_set_fwd_mode_init();
8747 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8751 cmdline_interact(cl);
8752 cmdline_stdin_exit(cl);
8756 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8758 if (id < nb_ports) {
8759 /* check if need_reconfig has been set to 1 */
8760 if (ports[id].need_reconfig == 0)
8761 ports[id].need_reconfig = dev;
8762 /* check if need_reconfig_queues has been set to 1 */
8763 if (ports[id].need_reconfig_queues == 0)
8764 ports[id].need_reconfig_queues = queue;
8768 for (pid = 0; pid < nb_ports; pid++) {
8769 /* check if need_reconfig has been set to 1 */
8770 if (ports[pid].need_reconfig == 0)
8771 ports[pid].need_reconfig = dev;
8772 /* check if need_reconfig_queues has been set to 1 */
8773 if (ports[pid].need_reconfig_queues == 0)
8774 ports[pid].need_reconfig_queues = queue;
8779 #ifdef RTE_NIC_BYPASS
8781 bypass_is_supported(portid_t port_id)
8783 struct rte_port *port;
8784 struct rte_pci_id *pci_id;
8786 if (port_id >= nb_ports) {
8787 printf("\tPort id must be less than %d.\n", nb_ports);
8791 /* Get the device id. */
8792 port = &ports[port_id];
8793 pci_id = &port->dev_info.pci_dev->id;
8795 /* Check if NIC supports bypass. */
8796 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8800 printf("\tBypass not supported for port_id = %d.\n", port_id);