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 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
627 " add syn filter.\n\n"
629 "remove_syn_filter (port_id)"
630 " remove syn filter.\n\n"
632 "get_syn_filter (port_id) "
633 " get syn filter info.\n\n"
635 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
636 " priority (prio_value) queue (queue_id) index (idx)\n"
637 " add a flex filter.\n\n"
639 "remove_flex_filter (port_id) index (idx)\n"
640 " remove a flex filter.\n\n"
642 "get_flex_filter (port_id) index (idx)\n"
643 " get info of a flex filter.\n\n"
645 "flow_director_filter (port_id) (add|del|update)"
646 " flow (ip4|ip4-frag|ip6|ip6-frag)"
647 " src (src_ip_address) dst (dst_ip_address)"
648 " vlan (vlan_value) flexbytes (flexbytes_value)"
649 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
650 " Add/Del an IP type flow director filter.\n\n"
652 "flow_director_filter (port_id) (add|del|update)"
653 " flow (udp4|tcp4|udp6|tcp6)"
654 " src (src_ip_address) (src_port)"
655 " dst (dst_ip_address) (dst_port)"
656 " vlan (vlan_value) flexbytes (flexbytes_value)"
657 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
658 " Add/Del an UDP/TCP type flow director filter.\n\n"
660 "flow_director_filter (port_id) (add|del|update)"
661 " flow (sctp4|sctp6)"
662 " src (src_ip_address) (src_port)"
663 " dst (dst_ip_address) (dst_port)"
664 " tag (verification_tag) vlan (vlan_value)"
665 " flexbytes (flexbytes_value) (drop|fwd)"
666 " queue (queue_id) fd_id (fd_id_value)\n"
667 " Add/Del a SCTP type flow director filter.\n\n"
669 "flush_flow_director (port_id)\n"
670 " Flush all flow director entries of a device.\n\n"
672 "flow_director_mask (port_id) vlan (vlan_value)"
673 " src_mask (ipv4_src) (ipv6_src) (src_port)"
674 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
675 " Set flow director mask.\n\n"
677 "flow_director_flex_mask (port_id)"
678 " flow (raw|ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
680 " Configure mask of flex payload.\n\n"
682 "flow_director_flex_payload (port_id)"
683 " (raw|l2|l3|l4) (config)\n"
684 " Configure flex payload selection.\n\n"
686 "get_sym_hash_ena_per_port (port_id)\n"
687 " get symmetric hash enable configuration per port.\n\n"
689 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
690 " set symmetric hash enable configuration per port"
691 " to enable or disable.\n\n"
693 "get_hash_global_config (port_id)\n"
694 " Get the global configurations of hash filters.\n\n"
696 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
697 " (ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6)"
698 " (enable|disable)\n"
699 " Set the global configurations of hash filters.\n\n"
704 cmdline_parse_token_string_t cmd_help_long_help =
705 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
707 cmdline_parse_token_string_t cmd_help_long_section =
708 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
709 "all#control#display#config#"
710 "ports#registers#filters");
712 cmdline_parse_inst_t cmd_help_long = {
713 .f = cmd_help_long_parsed,
715 .help_str = "show help",
717 (void *)&cmd_help_long_help,
718 (void *)&cmd_help_long_section,
724 /* *** start/stop/close all ports *** */
725 struct cmd_operate_port_result {
726 cmdline_fixed_string_t keyword;
727 cmdline_fixed_string_t name;
728 cmdline_fixed_string_t value;
731 static void cmd_operate_port_parsed(void *parsed_result,
732 __attribute__((unused)) struct cmdline *cl,
733 __attribute__((unused)) void *data)
735 struct cmd_operate_port_result *res = parsed_result;
737 if (!strcmp(res->name, "start"))
738 start_port(RTE_PORT_ALL);
739 else if (!strcmp(res->name, "stop"))
740 stop_port(RTE_PORT_ALL);
741 else if (!strcmp(res->name, "close"))
742 close_port(RTE_PORT_ALL);
744 printf("Unknown parameter\n");
747 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
748 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
750 cmdline_parse_token_string_t cmd_operate_port_all_port =
751 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
753 cmdline_parse_token_string_t cmd_operate_port_all_all =
754 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
756 cmdline_parse_inst_t cmd_operate_port = {
757 .f = cmd_operate_port_parsed,
759 .help_str = "port start|stop|close all: start/stop/close all ports",
761 (void *)&cmd_operate_port_all_cmd,
762 (void *)&cmd_operate_port_all_port,
763 (void *)&cmd_operate_port_all_all,
768 /* *** start/stop/close specific port *** */
769 struct cmd_operate_specific_port_result {
770 cmdline_fixed_string_t keyword;
771 cmdline_fixed_string_t name;
775 static void cmd_operate_specific_port_parsed(void *parsed_result,
776 __attribute__((unused)) struct cmdline *cl,
777 __attribute__((unused)) void *data)
779 struct cmd_operate_specific_port_result *res = parsed_result;
781 if (!strcmp(res->name, "start"))
782 start_port(res->value);
783 else if (!strcmp(res->name, "stop"))
784 stop_port(res->value);
785 else if (!strcmp(res->name, "close"))
786 close_port(res->value);
788 printf("Unknown parameter\n");
791 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
792 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
794 cmdline_parse_token_string_t cmd_operate_specific_port_port =
795 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
796 name, "start#stop#close");
797 cmdline_parse_token_num_t cmd_operate_specific_port_id =
798 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
801 cmdline_parse_inst_t cmd_operate_specific_port = {
802 .f = cmd_operate_specific_port_parsed,
804 .help_str = "port start|stop|close X: start/stop/close port X",
806 (void *)&cmd_operate_specific_port_cmd,
807 (void *)&cmd_operate_specific_port_port,
808 (void *)&cmd_operate_specific_port_id,
813 /* *** configure speed for all ports *** */
814 struct cmd_config_speed_all {
815 cmdline_fixed_string_t port;
816 cmdline_fixed_string_t keyword;
817 cmdline_fixed_string_t all;
818 cmdline_fixed_string_t item1;
819 cmdline_fixed_string_t item2;
820 cmdline_fixed_string_t value1;
821 cmdline_fixed_string_t value2;
825 cmd_config_speed_all_parsed(void *parsed_result,
826 __attribute__((unused)) struct cmdline *cl,
827 __attribute__((unused)) void *data)
829 struct cmd_config_speed_all *res = parsed_result;
830 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
831 uint16_t link_duplex = 0;
834 if (!all_ports_stopped()) {
835 printf("Please stop all ports first\n");
839 if (!strcmp(res->value1, "10"))
840 link_speed = ETH_LINK_SPEED_10;
841 else if (!strcmp(res->value1, "100"))
842 link_speed = ETH_LINK_SPEED_100;
843 else if (!strcmp(res->value1, "1000"))
844 link_speed = ETH_LINK_SPEED_1000;
845 else if (!strcmp(res->value1, "10000"))
846 link_speed = ETH_LINK_SPEED_10G;
847 else if (!strcmp(res->value1, "40000"))
848 link_speed = ETH_LINK_SPEED_40G;
849 else if (!strcmp(res->value1, "auto"))
850 link_speed = ETH_LINK_SPEED_AUTONEG;
852 printf("Unknown parameter\n");
856 if (!strcmp(res->value2, "half"))
857 link_duplex = ETH_LINK_HALF_DUPLEX;
858 else if (!strcmp(res->value2, "full"))
859 link_duplex = ETH_LINK_FULL_DUPLEX;
860 else if (!strcmp(res->value2, "auto"))
861 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
863 printf("Unknown parameter\n");
867 for (pid = 0; pid < nb_ports; pid++) {
868 ports[pid].dev_conf.link_speed = link_speed;
869 ports[pid].dev_conf.link_duplex = link_duplex;
872 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
875 cmdline_parse_token_string_t cmd_config_speed_all_port =
876 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
877 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
878 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
880 cmdline_parse_token_string_t cmd_config_speed_all_all =
881 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
882 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
883 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
884 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
885 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
886 "10#100#1000#10000#40000#auto");
887 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
888 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
889 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
890 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
893 cmdline_parse_inst_t cmd_config_speed_all = {
894 .f = cmd_config_speed_all_parsed,
896 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
899 (void *)&cmd_config_speed_all_port,
900 (void *)&cmd_config_speed_all_keyword,
901 (void *)&cmd_config_speed_all_all,
902 (void *)&cmd_config_speed_all_item1,
903 (void *)&cmd_config_speed_all_value1,
904 (void *)&cmd_config_speed_all_item2,
905 (void *)&cmd_config_speed_all_value2,
910 /* *** configure speed for specific port *** */
911 struct cmd_config_speed_specific {
912 cmdline_fixed_string_t port;
913 cmdline_fixed_string_t keyword;
915 cmdline_fixed_string_t item1;
916 cmdline_fixed_string_t item2;
917 cmdline_fixed_string_t value1;
918 cmdline_fixed_string_t value2;
922 cmd_config_speed_specific_parsed(void *parsed_result,
923 __attribute__((unused)) struct cmdline *cl,
924 __attribute__((unused)) void *data)
926 struct cmd_config_speed_specific *res = parsed_result;
927 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
928 uint16_t link_duplex = 0;
930 if (!all_ports_stopped()) {
931 printf("Please stop all ports first\n");
935 if (res->id >= nb_ports) {
936 printf("Port id %d must be less than %d\n", res->id, nb_ports);
940 if (!strcmp(res->value1, "10"))
941 link_speed = ETH_LINK_SPEED_10;
942 else if (!strcmp(res->value1, "100"))
943 link_speed = ETH_LINK_SPEED_100;
944 else if (!strcmp(res->value1, "1000"))
945 link_speed = ETH_LINK_SPEED_1000;
946 else if (!strcmp(res->value1, "10000"))
947 link_speed = ETH_LINK_SPEED_10000;
948 else if (!strcmp(res->value1, "40000"))
949 link_speed = ETH_LINK_SPEED_40G;
950 else if (!strcmp(res->value1, "auto"))
951 link_speed = ETH_LINK_SPEED_AUTONEG;
953 printf("Unknown parameter\n");
957 if (!strcmp(res->value2, "half"))
958 link_duplex = ETH_LINK_HALF_DUPLEX;
959 else if (!strcmp(res->value2, "full"))
960 link_duplex = ETH_LINK_FULL_DUPLEX;
961 else if (!strcmp(res->value2, "auto"))
962 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
964 printf("Unknown parameter\n");
968 ports[res->id].dev_conf.link_speed = link_speed;
969 ports[res->id].dev_conf.link_duplex = link_duplex;
971 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
975 cmdline_parse_token_string_t cmd_config_speed_specific_port =
976 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
978 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
979 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
981 cmdline_parse_token_num_t cmd_config_speed_specific_id =
982 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
983 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
984 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
986 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
987 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
988 "10#100#1000#10000#40000#auto");
989 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
990 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
992 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
993 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
996 cmdline_parse_inst_t cmd_config_speed_specific = {
997 .f = cmd_config_speed_specific_parsed,
999 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1002 (void *)&cmd_config_speed_specific_port,
1003 (void *)&cmd_config_speed_specific_keyword,
1004 (void *)&cmd_config_speed_specific_id,
1005 (void *)&cmd_config_speed_specific_item1,
1006 (void *)&cmd_config_speed_specific_value1,
1007 (void *)&cmd_config_speed_specific_item2,
1008 (void *)&cmd_config_speed_specific_value2,
1013 /* *** configure txq/rxq, txd/rxd *** */
1014 struct cmd_config_rx_tx {
1015 cmdline_fixed_string_t port;
1016 cmdline_fixed_string_t keyword;
1017 cmdline_fixed_string_t all;
1018 cmdline_fixed_string_t name;
1023 cmd_config_rx_tx_parsed(void *parsed_result,
1024 __attribute__((unused)) struct cmdline *cl,
1025 __attribute__((unused)) void *data)
1027 struct cmd_config_rx_tx *res = parsed_result;
1029 if (!all_ports_stopped()) {
1030 printf("Please stop all ports first\n");
1034 if (!strcmp(res->name, "rxq")) {
1035 if (res->value <= 0) {
1036 printf("rxq %d invalid - must be > 0\n", res->value);
1039 nb_rxq = res->value;
1041 else if (!strcmp(res->name, "txq")) {
1042 if (res->value <= 0) {
1043 printf("txq %d invalid - must be > 0\n", res->value);
1046 nb_txq = res->value;
1048 else if (!strcmp(res->name, "rxd")) {
1049 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1050 printf("rxd %d invalid - must be > 0 && <= %d\n",
1051 res->value, RTE_TEST_RX_DESC_MAX);
1054 nb_rxd = res->value;
1055 } else if (!strcmp(res->name, "txd")) {
1056 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1057 printf("txd %d invalid - must be > 0 && <= %d\n",
1058 res->value, RTE_TEST_TX_DESC_MAX);
1061 nb_txd = res->value;
1063 printf("Unknown parameter\n");
1069 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1072 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1073 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1074 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1075 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1076 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1077 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1078 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1079 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1081 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1082 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1084 cmdline_parse_inst_t cmd_config_rx_tx = {
1085 .f = cmd_config_rx_tx_parsed,
1087 .help_str = "port config all rxq|txq|rxd|txd value",
1089 (void *)&cmd_config_rx_tx_port,
1090 (void *)&cmd_config_rx_tx_keyword,
1091 (void *)&cmd_config_rx_tx_all,
1092 (void *)&cmd_config_rx_tx_name,
1093 (void *)&cmd_config_rx_tx_value,
1098 /* *** config max packet length *** */
1099 struct cmd_config_max_pkt_len_result {
1100 cmdline_fixed_string_t port;
1101 cmdline_fixed_string_t keyword;
1102 cmdline_fixed_string_t all;
1103 cmdline_fixed_string_t name;
1108 cmd_config_max_pkt_len_parsed(void *parsed_result,
1109 __attribute__((unused)) struct cmdline *cl,
1110 __attribute__((unused)) void *data)
1112 struct cmd_config_max_pkt_len_result *res = parsed_result;
1114 if (!all_ports_stopped()) {
1115 printf("Please stop all ports first\n");
1119 if (!strcmp(res->name, "max-pkt-len")) {
1120 if (res->value < ETHER_MIN_LEN) {
1121 printf("max-pkt-len can not be less than %d\n",
1125 if (res->value == rx_mode.max_rx_pkt_len)
1128 rx_mode.max_rx_pkt_len = res->value;
1129 if (res->value > ETHER_MAX_LEN)
1130 rx_mode.jumbo_frame = 1;
1132 rx_mode.jumbo_frame = 0;
1134 printf("Unknown parameter\n");
1140 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1143 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1144 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1146 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1147 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1149 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1152 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1155 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1156 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1159 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1160 .f = cmd_config_max_pkt_len_parsed,
1162 .help_str = "port config all max-pkt-len value",
1164 (void *)&cmd_config_max_pkt_len_port,
1165 (void *)&cmd_config_max_pkt_len_keyword,
1166 (void *)&cmd_config_max_pkt_len_all,
1167 (void *)&cmd_config_max_pkt_len_name,
1168 (void *)&cmd_config_max_pkt_len_value,
1173 /* *** configure port MTU *** */
1174 struct cmd_config_mtu_result {
1175 cmdline_fixed_string_t port;
1176 cmdline_fixed_string_t keyword;
1177 cmdline_fixed_string_t mtu;
1183 cmd_config_mtu_parsed(void *parsed_result,
1184 __attribute__((unused)) struct cmdline *cl,
1185 __attribute__((unused)) void *data)
1187 struct cmd_config_mtu_result *res = parsed_result;
1189 if (res->value < ETHER_MIN_LEN) {
1190 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1193 port_mtu_set(res->port_id, res->value);
1196 cmdline_parse_token_string_t cmd_config_mtu_port =
1197 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1199 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1200 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1202 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1203 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1205 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1206 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1207 cmdline_parse_token_num_t cmd_config_mtu_value =
1208 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1210 cmdline_parse_inst_t cmd_config_mtu = {
1211 .f = cmd_config_mtu_parsed,
1213 .help_str = "port config mtu value",
1215 (void *)&cmd_config_mtu_port,
1216 (void *)&cmd_config_mtu_keyword,
1217 (void *)&cmd_config_mtu_mtu,
1218 (void *)&cmd_config_mtu_port_id,
1219 (void *)&cmd_config_mtu_value,
1224 /* *** configure rx mode *** */
1225 struct cmd_config_rx_mode_flag {
1226 cmdline_fixed_string_t port;
1227 cmdline_fixed_string_t keyword;
1228 cmdline_fixed_string_t all;
1229 cmdline_fixed_string_t name;
1230 cmdline_fixed_string_t value;
1234 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1235 __attribute__((unused)) struct cmdline *cl,
1236 __attribute__((unused)) void *data)
1238 struct cmd_config_rx_mode_flag *res = parsed_result;
1240 if (!all_ports_stopped()) {
1241 printf("Please stop all ports first\n");
1245 if (!strcmp(res->name, "crc-strip")) {
1246 if (!strcmp(res->value, "on"))
1247 rx_mode.hw_strip_crc = 1;
1248 else if (!strcmp(res->value, "off"))
1249 rx_mode.hw_strip_crc = 0;
1251 printf("Unknown parameter\n");
1254 } else if (!strcmp(res->name, "rx-cksum")) {
1255 if (!strcmp(res->value, "on"))
1256 rx_mode.hw_ip_checksum = 1;
1257 else if (!strcmp(res->value, "off"))
1258 rx_mode.hw_ip_checksum = 0;
1260 printf("Unknown parameter\n");
1263 } else if (!strcmp(res->name, "hw-vlan")) {
1264 if (!strcmp(res->value, "on")) {
1265 rx_mode.hw_vlan_filter = 1;
1266 rx_mode.hw_vlan_strip = 1;
1268 else if (!strcmp(res->value, "off")) {
1269 rx_mode.hw_vlan_filter = 0;
1270 rx_mode.hw_vlan_strip = 0;
1273 printf("Unknown parameter\n");
1276 } else if (!strcmp(res->name, "drop-en")) {
1277 if (!strcmp(res->value, "on"))
1279 else if (!strcmp(res->value, "off"))
1282 printf("Unknown parameter\n");
1286 printf("Unknown parameter\n");
1292 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1295 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1296 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1297 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1298 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1300 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1301 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1302 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1303 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1304 "crc-strip#rx-cksum#hw-vlan");
1305 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1306 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1309 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1310 .f = cmd_config_rx_mode_flag_parsed,
1312 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1314 (void *)&cmd_config_rx_mode_flag_port,
1315 (void *)&cmd_config_rx_mode_flag_keyword,
1316 (void *)&cmd_config_rx_mode_flag_all,
1317 (void *)&cmd_config_rx_mode_flag_name,
1318 (void *)&cmd_config_rx_mode_flag_value,
1323 /* *** configure rss *** */
1324 struct cmd_config_rss {
1325 cmdline_fixed_string_t port;
1326 cmdline_fixed_string_t keyword;
1327 cmdline_fixed_string_t all;
1328 cmdline_fixed_string_t name;
1329 cmdline_fixed_string_t value;
1333 cmd_config_rss_parsed(void *parsed_result,
1334 __attribute__((unused)) struct cmdline *cl,
1335 __attribute__((unused)) void *data)
1337 struct cmd_config_rss *res = parsed_result;
1338 struct rte_eth_rss_conf rss_conf;
1341 if (!strcmp(res->value, "ip"))
1342 rss_conf.rss_hf = ETH_RSS_IP;
1343 else if (!strcmp(res->value, "udp"))
1344 rss_conf.rss_hf = ETH_RSS_UDP;
1345 else if (!strcmp(res->value, "none"))
1346 rss_conf.rss_hf = 0;
1348 printf("Unknown parameter\n");
1351 rss_conf.rss_key = NULL;
1352 for (i = 0; i < rte_eth_dev_count(); i++)
1353 rte_eth_dev_rss_hash_update(i, &rss_conf);
1356 cmdline_parse_token_string_t cmd_config_rss_port =
1357 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1358 cmdline_parse_token_string_t cmd_config_rss_keyword =
1359 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1360 cmdline_parse_token_string_t cmd_config_rss_all =
1361 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1362 cmdline_parse_token_string_t cmd_config_rss_name =
1363 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1364 cmdline_parse_token_string_t cmd_config_rss_value =
1365 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1367 cmdline_parse_inst_t cmd_config_rss = {
1368 .f = cmd_config_rss_parsed,
1370 .help_str = "port config all rss ip|udp|none",
1372 (void *)&cmd_config_rss_port,
1373 (void *)&cmd_config_rss_keyword,
1374 (void *)&cmd_config_rss_all,
1375 (void *)&cmd_config_rss_name,
1376 (void *)&cmd_config_rss_value,
1381 /* *** configure rss hash key *** */
1382 struct cmd_config_rss_hash_key {
1383 cmdline_fixed_string_t port;
1384 cmdline_fixed_string_t config;
1386 cmdline_fixed_string_t rss_hash_key;
1387 cmdline_fixed_string_t key;
1390 #define RSS_HASH_KEY_LENGTH 40
1392 hexa_digit_to_value(char hexa_digit)
1394 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1395 return (uint8_t) (hexa_digit - '0');
1396 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1397 return (uint8_t) ((hexa_digit - 'a') + 10);
1398 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1399 return (uint8_t) ((hexa_digit - 'A') + 10);
1400 /* Invalid hexa digit */
1405 parse_and_check_key_hexa_digit(char *key, int idx)
1409 hexa_v = hexa_digit_to_value(key[idx]);
1411 printf("invalid key: character %c at position %d is not a "
1412 "valid hexa digit\n", key[idx], idx);
1417 cmd_config_rss_hash_key_parsed(void *parsed_result,
1418 __attribute__((unused)) struct cmdline *cl,
1419 __attribute__((unused)) void *data)
1421 struct cmd_config_rss_hash_key *res = parsed_result;
1422 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1427 /* Check the length of the RSS hash key */
1428 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1429 printf("key length: %d invalid - key must be a string of %d"
1430 "hexa-decimal numbers\n", (int) strlen(res->key),
1431 RSS_HASH_KEY_LENGTH * 2);
1434 /* Translate RSS hash key into binary representation */
1435 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1436 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1439 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1442 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1444 port_rss_hash_key_update(res->port_id, hash_key);
1447 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1448 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1449 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1450 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1452 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1453 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1454 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1455 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1456 rss_hash_key, "rss-hash-key");
1457 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1460 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1461 .f = cmd_config_rss_hash_key_parsed,
1463 .help_str = "port config X rss-hash-key 80 hexa digits",
1465 (void *)&cmd_config_rss_hash_key_port,
1466 (void *)&cmd_config_rss_hash_key_config,
1467 (void *)&cmd_config_rss_hash_key_port_id,
1468 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1469 (void *)&cmd_config_rss_hash_key_value,
1474 /* *** configure port rxq/txq start/stop *** */
1475 struct cmd_config_rxtx_queue {
1476 cmdline_fixed_string_t port;
1478 cmdline_fixed_string_t rxtxq;
1480 cmdline_fixed_string_t opname;
1484 cmd_config_rxtx_queue_parsed(void *parsed_result,
1485 __attribute__((unused)) struct cmdline *cl,
1486 __attribute__((unused)) void *data)
1488 struct cmd_config_rxtx_queue *res = parsed_result;
1493 if (test_done == 0) {
1494 printf("Please stop forwarding first\n");
1498 if (port_id_is_invalid(res->portid))
1501 if (port_is_started(res->portid) != 1) {
1502 printf("Please start port %u first\n", res->portid);
1506 if (!strcmp(res->rxtxq, "rxq"))
1508 else if (!strcmp(res->rxtxq, "txq"))
1511 printf("Unknown parameter\n");
1515 if (isrx && rx_queue_id_is_invalid(res->qid))
1517 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1520 if (!strcmp(res->opname, "start"))
1522 else if (!strcmp(res->opname, "stop"))
1525 printf("Unknown parameter\n");
1529 if (isstart && isrx)
1530 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1531 else if (!isstart && isrx)
1532 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1533 else if (isstart && !isrx)
1534 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1536 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1538 if (ret == -ENOTSUP)
1539 printf("Function not supported in PMD driver\n");
1542 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1543 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1544 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1545 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1546 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1547 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1548 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1549 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1550 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1551 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1554 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1555 .f = cmd_config_rxtx_queue_parsed,
1557 .help_str = "port X rxq|txq ID start|stop",
1559 (void *)&cmd_config_speed_all_port,
1560 (void *)&cmd_config_rxtx_queue_portid,
1561 (void *)&cmd_config_rxtx_queue_rxtxq,
1562 (void *)&cmd_config_rxtx_queue_qid,
1563 (void *)&cmd_config_rxtx_queue_opname,
1568 /* *** Configure RSS RETA *** */
1569 struct cmd_config_rss_reta {
1570 cmdline_fixed_string_t port;
1571 cmdline_fixed_string_t keyword;
1573 cmdline_fixed_string_t name;
1574 cmdline_fixed_string_t list_name;
1575 cmdline_fixed_string_t list_of_items;
1579 parse_reta_config(const char *str,
1580 struct rte_eth_rss_reta_entry64 *reta_conf,
1581 uint16_t nb_entries)
1585 uint16_t hash_index, idx, shift;
1588 const char *p, *p0 = str;
1595 unsigned long int_fld[_NUM_FLD];
1596 char *str_fld[_NUM_FLD];
1598 while ((p = strchr(p0,'(')) != NULL) {
1600 if((p0 = strchr(p,')')) == NULL)
1604 if(size >= sizeof(s))
1607 snprintf(s, sizeof(s), "%.*s", size, p);
1608 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1610 for (i = 0; i < _NUM_FLD; i++) {
1612 int_fld[i] = strtoul(str_fld[i], &end, 0);
1613 if (errno != 0 || end == str_fld[i] ||
1618 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1619 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1621 if (hash_index >= nb_entries) {
1622 printf("Invalid RETA hash index=%d\n", hash_index);
1626 idx = hash_index / RTE_RETA_GROUP_SIZE;
1627 shift = hash_index % RTE_RETA_GROUP_SIZE;
1628 reta_conf[idx].mask |= (1ULL << shift);
1629 reta_conf[idx].reta[shift] = nb_queue;
1636 cmd_set_rss_reta_parsed(void *parsed_result,
1637 __attribute__((unused)) struct cmdline *cl,
1638 __attribute__((unused)) void *data)
1641 struct rte_eth_dev_info dev_info;
1642 struct rte_eth_rss_reta_entry64 reta_conf[8];
1643 struct cmd_config_rss_reta *res = parsed_result;
1645 memset(&dev_info, 0, sizeof(dev_info));
1646 rte_eth_dev_info_get(res->port_id, &dev_info);
1647 if (dev_info.reta_size == 0) {
1648 printf("Redirection table size is 0 which is "
1649 "invalid for RSS\n");
1652 printf("The reta size of port %d is %u\n",
1653 res->port_id, dev_info.reta_size);
1654 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1655 printf("Currently do not support more than %u entries of "
1656 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1660 memset(reta_conf, 0, sizeof(reta_conf));
1661 if (!strcmp(res->list_name, "reta")) {
1662 if (parse_reta_config(res->list_of_items, reta_conf,
1663 dev_info.reta_size)) {
1664 printf("Invalid RSS Redirection Table "
1665 "config entered\n");
1668 ret = rte_eth_dev_rss_reta_update(res->port_id,
1669 reta_conf, dev_info.reta_size);
1671 printf("Bad redirection table parameter, "
1672 "return code = %d \n", ret);
1676 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1678 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1680 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1681 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1682 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1683 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1684 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1685 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1686 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1687 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1689 cmdline_parse_inst_t cmd_config_rss_reta = {
1690 .f = cmd_set_rss_reta_parsed,
1692 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1694 (void *)&cmd_config_rss_reta_port,
1695 (void *)&cmd_config_rss_reta_keyword,
1696 (void *)&cmd_config_rss_reta_port_id,
1697 (void *)&cmd_config_rss_reta_name,
1698 (void *)&cmd_config_rss_reta_list_name,
1699 (void *)&cmd_config_rss_reta_list_of_items,
1704 /* *** SHOW PORT RETA INFO *** */
1705 struct cmd_showport_reta {
1706 cmdline_fixed_string_t show;
1707 cmdline_fixed_string_t port;
1709 cmdline_fixed_string_t rss;
1710 cmdline_fixed_string_t reta;
1712 cmdline_fixed_string_t list_of_items;
1716 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1717 uint16_t nb_entries,
1721 const char *p, *p0 = str;
1725 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1728 p = strchr(p0, '(');
1732 p0 = strchr(p, ')');
1736 if (size >= sizeof(s)) {
1737 printf("The string size exceeds the internal buffer size\n");
1740 snprintf(s, sizeof(s), "%.*s", size, p);
1741 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1742 if (ret <= 0 || ret != num) {
1743 printf("The bits of masks do not match the number of "
1744 "reta entries: %u\n", num);
1747 for (i = 0; i < ret; i++)
1748 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1754 cmd_showport_reta_parsed(void *parsed_result,
1755 __attribute__((unused)) struct cmdline *cl,
1756 __attribute__((unused)) void *data)
1758 struct cmd_showport_reta *res = parsed_result;
1759 struct rte_eth_rss_reta_entry64 reta_conf[8];
1760 struct rte_eth_dev_info dev_info;
1762 memset(&dev_info, 0, sizeof(dev_info));
1763 rte_eth_dev_info_get(res->port_id, &dev_info);
1764 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1765 res->size > ETH_RSS_RETA_SIZE_512) {
1766 printf("Invalid redirection table size: %u\n", res->size);
1770 memset(reta_conf, 0, sizeof(reta_conf));
1771 if (showport_parse_reta_config(reta_conf, res->size,
1772 res->list_of_items) < 0) {
1773 printf("Invalid string: %s for reta masks\n",
1774 res->list_of_items);
1777 port_rss_reta_info(res->port_id, reta_conf, res->size);
1780 cmdline_parse_token_string_t cmd_showport_reta_show =
1781 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1782 cmdline_parse_token_string_t cmd_showport_reta_port =
1783 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1784 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1785 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1786 cmdline_parse_token_string_t cmd_showport_reta_rss =
1787 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1788 cmdline_parse_token_string_t cmd_showport_reta_reta =
1789 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1790 cmdline_parse_token_num_t cmd_showport_reta_size =
1791 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1792 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1793 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1794 list_of_items, NULL);
1796 cmdline_parse_inst_t cmd_showport_reta = {
1797 .f = cmd_showport_reta_parsed,
1799 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1801 (void *)&cmd_showport_reta_show,
1802 (void *)&cmd_showport_reta_port,
1803 (void *)&cmd_showport_reta_port_id,
1804 (void *)&cmd_showport_reta_rss,
1805 (void *)&cmd_showport_reta_reta,
1806 (void *)&cmd_showport_reta_size,
1807 (void *)&cmd_showport_reta_list_of_items,
1812 /* *** Show RSS hash configuration *** */
1813 struct cmd_showport_rss_hash {
1814 cmdline_fixed_string_t show;
1815 cmdline_fixed_string_t port;
1817 cmdline_fixed_string_t rss_hash;
1818 cmdline_fixed_string_t key; /* optional argument */
1821 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1822 __attribute__((unused)) struct cmdline *cl,
1825 struct cmd_showport_rss_hash *res = parsed_result;
1827 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1830 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1831 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1832 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1833 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1834 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1835 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1836 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1837 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1839 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1840 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1842 cmdline_parse_inst_t cmd_showport_rss_hash = {
1843 .f = cmd_showport_rss_hash_parsed,
1845 .help_str = "show port X rss-hash (X = port number)\n",
1847 (void *)&cmd_showport_rss_hash_show,
1848 (void *)&cmd_showport_rss_hash_port,
1849 (void *)&cmd_showport_rss_hash_port_id,
1850 (void *)&cmd_showport_rss_hash_rss_hash,
1855 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1856 .f = cmd_showport_rss_hash_parsed,
1858 .help_str = "show port X rss-hash key (X = port number)\n",
1860 (void *)&cmd_showport_rss_hash_show,
1861 (void *)&cmd_showport_rss_hash_port,
1862 (void *)&cmd_showport_rss_hash_port_id,
1863 (void *)&cmd_showport_rss_hash_rss_hash,
1864 (void *)&cmd_showport_rss_hash_rss_key,
1869 /* *** Configure DCB *** */
1870 struct cmd_config_dcb {
1871 cmdline_fixed_string_t port;
1872 cmdline_fixed_string_t config;
1874 cmdline_fixed_string_t dcb;
1875 cmdline_fixed_string_t vt;
1876 cmdline_fixed_string_t vt_en;
1878 cmdline_fixed_string_t pfc;
1879 cmdline_fixed_string_t pfc_en;
1883 cmd_config_dcb_parsed(void *parsed_result,
1884 __attribute__((unused)) struct cmdline *cl,
1885 __attribute__((unused)) void *data)
1887 struct cmd_config_dcb *res = parsed_result;
1888 struct dcb_config dcb_conf;
1889 portid_t port_id = res->port_id;
1890 struct rte_port *port;
1892 port = &ports[port_id];
1893 /** Check if the port is not started **/
1894 if (port->port_status != RTE_PORT_STOPPED) {
1895 printf("Please stop port %d first\n",port_id);
1899 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1900 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1901 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1905 /* DCB in VT mode */
1906 if (!strncmp(res->vt_en, "on",2))
1907 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1909 dcb_conf.dcb_mode = DCB_ENABLED;
1911 if (!strncmp(res->pfc_en, "on",2)) {
1912 dcb_conf.pfc_en = 1;
1915 dcb_conf.pfc_en = 0;
1917 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1918 printf("Cannot initialize network ports\n");
1922 cmd_reconfig_device_queue(port_id, 1, 1);
1925 cmdline_parse_token_string_t cmd_config_dcb_port =
1926 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1927 cmdline_parse_token_string_t cmd_config_dcb_config =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1929 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1930 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1931 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1932 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1933 cmdline_parse_token_string_t cmd_config_dcb_vt =
1934 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1935 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1937 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1938 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1939 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1940 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1941 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1944 cmdline_parse_inst_t cmd_config_dcb = {
1945 .f = cmd_config_dcb_parsed,
1947 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1949 (void *)&cmd_config_dcb_port,
1950 (void *)&cmd_config_dcb_config,
1951 (void *)&cmd_config_dcb_port_id,
1952 (void *)&cmd_config_dcb_dcb,
1953 (void *)&cmd_config_dcb_vt,
1954 (void *)&cmd_config_dcb_vt_en,
1955 (void *)&cmd_config_dcb_num_tcs,
1956 (void *)&cmd_config_dcb_pfc,
1957 (void *)&cmd_config_dcb_pfc_en,
1962 /* *** configure number of packets per burst *** */
1963 struct cmd_config_burst {
1964 cmdline_fixed_string_t port;
1965 cmdline_fixed_string_t keyword;
1966 cmdline_fixed_string_t all;
1967 cmdline_fixed_string_t name;
1972 cmd_config_burst_parsed(void *parsed_result,
1973 __attribute__((unused)) struct cmdline *cl,
1974 __attribute__((unused)) void *data)
1976 struct cmd_config_burst *res = parsed_result;
1978 if (!all_ports_stopped()) {
1979 printf("Please stop all ports first\n");
1983 if (!strcmp(res->name, "burst")) {
1984 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1985 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1988 nb_pkt_per_burst = res->value;
1990 printf("Unknown parameter\n");
1996 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1999 cmdline_parse_token_string_t cmd_config_burst_port =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2001 cmdline_parse_token_string_t cmd_config_burst_keyword =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2003 cmdline_parse_token_string_t cmd_config_burst_all =
2004 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2005 cmdline_parse_token_string_t cmd_config_burst_name =
2006 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2007 cmdline_parse_token_num_t cmd_config_burst_value =
2008 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2010 cmdline_parse_inst_t cmd_config_burst = {
2011 .f = cmd_config_burst_parsed,
2013 .help_str = "port config all burst value",
2015 (void *)&cmd_config_burst_port,
2016 (void *)&cmd_config_burst_keyword,
2017 (void *)&cmd_config_burst_all,
2018 (void *)&cmd_config_burst_name,
2019 (void *)&cmd_config_burst_value,
2024 /* *** configure rx/tx queues *** */
2025 struct cmd_config_thresh {
2026 cmdline_fixed_string_t port;
2027 cmdline_fixed_string_t keyword;
2028 cmdline_fixed_string_t all;
2029 cmdline_fixed_string_t name;
2034 cmd_config_thresh_parsed(void *parsed_result,
2035 __attribute__((unused)) struct cmdline *cl,
2036 __attribute__((unused)) void *data)
2038 struct cmd_config_thresh *res = parsed_result;
2040 if (!all_ports_stopped()) {
2041 printf("Please stop all ports first\n");
2045 if (!strcmp(res->name, "txpt"))
2046 tx_pthresh = res->value;
2047 else if(!strcmp(res->name, "txht"))
2048 tx_hthresh = res->value;
2049 else if(!strcmp(res->name, "txwt"))
2050 tx_wthresh = res->value;
2051 else if(!strcmp(res->name, "rxpt"))
2052 rx_pthresh = res->value;
2053 else if(!strcmp(res->name, "rxht"))
2054 rx_hthresh = res->value;
2055 else if(!strcmp(res->name, "rxwt"))
2056 rx_wthresh = res->value;
2058 printf("Unknown parameter\n");
2064 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2067 cmdline_parse_token_string_t cmd_config_thresh_port =
2068 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2069 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2071 cmdline_parse_token_string_t cmd_config_thresh_all =
2072 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2073 cmdline_parse_token_string_t cmd_config_thresh_name =
2074 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2075 "txpt#txht#txwt#rxpt#rxht#rxwt");
2076 cmdline_parse_token_num_t cmd_config_thresh_value =
2077 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2079 cmdline_parse_inst_t cmd_config_thresh = {
2080 .f = cmd_config_thresh_parsed,
2082 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2084 (void *)&cmd_config_thresh_port,
2085 (void *)&cmd_config_thresh_keyword,
2086 (void *)&cmd_config_thresh_all,
2087 (void *)&cmd_config_thresh_name,
2088 (void *)&cmd_config_thresh_value,
2093 /* *** configure free/rs threshold *** */
2094 struct cmd_config_threshold {
2095 cmdline_fixed_string_t port;
2096 cmdline_fixed_string_t keyword;
2097 cmdline_fixed_string_t all;
2098 cmdline_fixed_string_t name;
2103 cmd_config_threshold_parsed(void *parsed_result,
2104 __attribute__((unused)) struct cmdline *cl,
2105 __attribute__((unused)) void *data)
2107 struct cmd_config_threshold *res = parsed_result;
2109 if (!all_ports_stopped()) {
2110 printf("Please stop all ports first\n");
2114 if (!strcmp(res->name, "txfreet"))
2115 tx_free_thresh = res->value;
2116 else if (!strcmp(res->name, "txrst"))
2117 tx_rs_thresh = res->value;
2118 else if (!strcmp(res->name, "rxfreet"))
2119 rx_free_thresh = res->value;
2121 printf("Unknown parameter\n");
2127 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2130 cmdline_parse_token_string_t cmd_config_threshold_port =
2131 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2132 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2133 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2135 cmdline_parse_token_string_t cmd_config_threshold_all =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2137 cmdline_parse_token_string_t cmd_config_threshold_name =
2138 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2139 "txfreet#txrst#rxfreet");
2140 cmdline_parse_token_num_t cmd_config_threshold_value =
2141 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2143 cmdline_parse_inst_t cmd_config_threshold = {
2144 .f = cmd_config_threshold_parsed,
2146 .help_str = "port config all txfreet|txrst|rxfreet value",
2148 (void *)&cmd_config_threshold_port,
2149 (void *)&cmd_config_threshold_keyword,
2150 (void *)&cmd_config_threshold_all,
2151 (void *)&cmd_config_threshold_name,
2152 (void *)&cmd_config_threshold_value,
2158 struct cmd_stop_result {
2159 cmdline_fixed_string_t stop;
2162 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2163 __attribute__((unused)) struct cmdline *cl,
2164 __attribute__((unused)) void *data)
2166 stop_packet_forwarding();
2169 cmdline_parse_token_string_t cmd_stop_stop =
2170 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2172 cmdline_parse_inst_t cmd_stop = {
2173 .f = cmd_stop_parsed,
2175 .help_str = "stop - stop packet forwarding",
2177 (void *)&cmd_stop_stop,
2182 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2185 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2186 unsigned int *parsed_items, int check_unique_values)
2188 unsigned int nb_item;
2196 * First parse all items in the list and store their value.
2201 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2203 if ((c >= '0') && (c <= '9')) {
2204 value = (unsigned int) (value * 10 + (c - '0'));
2209 printf("character %c is not a decimal digit\n", c);
2213 printf("No valid value before comma\n");
2216 if (nb_item < max_items) {
2217 parsed_items[nb_item] = value;
2223 if (nb_item >= max_items) {
2224 printf("Number of %s = %u > %u (maximum items)\n",
2225 item_name, nb_item + 1, max_items);
2228 parsed_items[nb_item++] = value;
2229 if (! check_unique_values)
2233 * Then, check that all values in the list are differents.
2234 * No optimization here...
2236 for (i = 0; i < nb_item; i++) {
2237 for (j = i + 1; j < nb_item; j++) {
2238 if (parsed_items[j] == parsed_items[i]) {
2239 printf("duplicated %s %u at index %u and %u\n",
2240 item_name, parsed_items[i], i, j);
2248 struct cmd_set_list_result {
2249 cmdline_fixed_string_t cmd_keyword;
2250 cmdline_fixed_string_t list_name;
2251 cmdline_fixed_string_t list_of_items;
2254 static void cmd_set_list_parsed(void *parsed_result,
2255 __attribute__((unused)) struct cmdline *cl,
2256 __attribute__((unused)) void *data)
2258 struct cmd_set_list_result *res;
2260 unsigned int lcorelist[RTE_MAX_LCORE];
2261 unsigned int portlist[RTE_MAX_ETHPORTS];
2263 unsigned int nb_item;
2265 if (test_done == 0) {
2266 printf("Please stop forwarding first\n");
2270 res = parsed_result;
2271 if (!strcmp(res->list_name, "corelist")) {
2272 nb_item = parse_item_list(res->list_of_items, "core",
2274 parsed_items.lcorelist, 1);
2276 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2279 if (!strcmp(res->list_name, "portlist")) {
2280 nb_item = parse_item_list(res->list_of_items, "port",
2282 parsed_items.portlist, 1);
2284 set_fwd_ports_list(parsed_items.portlist, nb_item);
2288 cmdline_parse_token_string_t cmd_set_list_keyword =
2289 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2291 cmdline_parse_token_string_t cmd_set_list_name =
2292 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2293 "corelist#portlist");
2294 cmdline_parse_token_string_t cmd_set_list_of_items =
2295 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2298 cmdline_parse_inst_t cmd_set_fwd_list = {
2299 .f = cmd_set_list_parsed,
2301 .help_str = "set corelist|portlist x[,y]*",
2303 (void *)&cmd_set_list_keyword,
2304 (void *)&cmd_set_list_name,
2305 (void *)&cmd_set_list_of_items,
2310 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2312 struct cmd_setmask_result {
2313 cmdline_fixed_string_t set;
2314 cmdline_fixed_string_t mask;
2318 static void cmd_set_mask_parsed(void *parsed_result,
2319 __attribute__((unused)) struct cmdline *cl,
2320 __attribute__((unused)) void *data)
2322 struct cmd_setmask_result *res = parsed_result;
2324 if (test_done == 0) {
2325 printf("Please stop forwarding first\n");
2328 if (!strcmp(res->mask, "coremask"))
2329 set_fwd_lcores_mask(res->hexavalue);
2330 else if (!strcmp(res->mask, "portmask"))
2331 set_fwd_ports_mask(res->hexavalue);
2334 cmdline_parse_token_string_t cmd_setmask_set =
2335 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2336 cmdline_parse_token_string_t cmd_setmask_mask =
2337 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2338 "coremask#portmask");
2339 cmdline_parse_token_num_t cmd_setmask_value =
2340 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2342 cmdline_parse_inst_t cmd_set_fwd_mask = {
2343 .f = cmd_set_mask_parsed,
2345 .help_str = "set coremask|portmask hexadecimal value",
2347 (void *)&cmd_setmask_set,
2348 (void *)&cmd_setmask_mask,
2349 (void *)&cmd_setmask_value,
2355 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2357 struct cmd_set_result {
2358 cmdline_fixed_string_t set;
2359 cmdline_fixed_string_t what;
2363 static void cmd_set_parsed(void *parsed_result,
2364 __attribute__((unused)) struct cmdline *cl,
2365 __attribute__((unused)) void *data)
2367 struct cmd_set_result *res = parsed_result;
2368 if (!strcmp(res->what, "nbport"))
2369 set_fwd_ports_number(res->value);
2370 else if (!strcmp(res->what, "nbcore"))
2371 set_fwd_lcores_number(res->value);
2372 else if (!strcmp(res->what, "burst"))
2373 set_nb_pkt_per_burst(res->value);
2374 else if (!strcmp(res->what, "verbose"))
2375 set_verbose_level(res->value);
2378 cmdline_parse_token_string_t cmd_set_set =
2379 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2380 cmdline_parse_token_string_t cmd_set_what =
2381 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2382 "nbport#nbcore#burst#verbose");
2383 cmdline_parse_token_num_t cmd_set_value =
2384 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2386 cmdline_parse_inst_t cmd_set_numbers = {
2387 .f = cmd_set_parsed,
2389 .help_str = "set nbport|nbcore|burst|verbose value",
2391 (void *)&cmd_set_set,
2392 (void *)&cmd_set_what,
2393 (void *)&cmd_set_value,
2398 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2400 struct cmd_set_txpkts_result {
2401 cmdline_fixed_string_t cmd_keyword;
2402 cmdline_fixed_string_t txpkts;
2403 cmdline_fixed_string_t seg_lengths;
2407 cmd_set_txpkts_parsed(void *parsed_result,
2408 __attribute__((unused)) struct cmdline *cl,
2409 __attribute__((unused)) void *data)
2411 struct cmd_set_txpkts_result *res;
2412 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2413 unsigned int nb_segs;
2415 res = parsed_result;
2416 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2417 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2419 set_tx_pkt_segments(seg_lengths, nb_segs);
2422 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2423 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2424 cmd_keyword, "set");
2425 cmdline_parse_token_string_t cmd_set_txpkts_name =
2426 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2428 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2429 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2432 cmdline_parse_inst_t cmd_set_txpkts = {
2433 .f = cmd_set_txpkts_parsed,
2435 .help_str = "set txpkts x[,y]*",
2437 (void *)&cmd_set_txpkts_keyword,
2438 (void *)&cmd_set_txpkts_name,
2439 (void *)&cmd_set_txpkts_lengths,
2444 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2445 struct cmd_rx_vlan_filter_all_result {
2446 cmdline_fixed_string_t rx_vlan;
2447 cmdline_fixed_string_t what;
2448 cmdline_fixed_string_t all;
2453 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2454 __attribute__((unused)) struct cmdline *cl,
2455 __attribute__((unused)) void *data)
2457 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2459 if (!strcmp(res->what, "add"))
2460 rx_vlan_all_filter_set(res->port_id, 1);
2462 rx_vlan_all_filter_set(res->port_id, 0);
2465 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2466 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2467 rx_vlan, "rx_vlan");
2468 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2469 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2471 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2472 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2474 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2475 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2478 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2479 .f = cmd_rx_vlan_filter_all_parsed,
2481 .help_str = "add/remove all identifiers to/from the set of VLAN "
2482 "Identifiers filtered by a port",
2484 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2485 (void *)&cmd_rx_vlan_filter_all_what,
2486 (void *)&cmd_rx_vlan_filter_all_all,
2487 (void *)&cmd_rx_vlan_filter_all_portid,
2492 /* *** VLAN OFFLOAD SET ON A PORT *** */
2493 struct cmd_vlan_offload_result {
2494 cmdline_fixed_string_t vlan;
2495 cmdline_fixed_string_t set;
2496 cmdline_fixed_string_t what;
2497 cmdline_fixed_string_t on;
2498 cmdline_fixed_string_t port_id;
2502 cmd_vlan_offload_parsed(void *parsed_result,
2503 __attribute__((unused)) struct cmdline *cl,
2504 __attribute__((unused)) void *data)
2507 struct cmd_vlan_offload_result *res = parsed_result;
2510 portid_t port_id = 0;
2514 len = strnlen(str, STR_TOKEN_SIZE);
2516 /* Get port_id first */
2524 tmp = strtoul(str, NULL, 0);
2525 /* If port_id greater that what portid_t can represent, return */
2526 if(tmp >= RTE_MAX_ETHPORTS)
2528 port_id = (portid_t)tmp;
2530 if (!strcmp(res->on, "on"))
2535 if (!strcmp(res->what, "strip"))
2536 rx_vlan_strip_set(port_id, on);
2537 else if(!strcmp(res->what, "stripq")){
2538 uint16_t queue_id = 0;
2540 /* No queue_id, return */
2542 printf("must specify (port,queue_id)\n");
2545 tmp = strtoul(str + i + 1, NULL, 0);
2546 /* If queue_id greater that what 16-bits can represent, return */
2550 queue_id = (uint16_t)tmp;
2551 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2553 else if (!strcmp(res->what, "filter"))
2554 rx_vlan_filter_set(port_id, on);
2556 vlan_extend_set(port_id, on);
2561 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2562 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2564 cmdline_parse_token_string_t cmd_vlan_offload_set =
2565 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2567 cmdline_parse_token_string_t cmd_vlan_offload_what =
2568 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2569 what, "strip#filter#qinq#stripq");
2570 cmdline_parse_token_string_t cmd_vlan_offload_on =
2571 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2573 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2574 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2577 cmdline_parse_inst_t cmd_vlan_offload = {
2578 .f = cmd_vlan_offload_parsed,
2580 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2581 " qinq(extended) for both rx/tx sides ",
2583 (void *)&cmd_vlan_offload_vlan,
2584 (void *)&cmd_vlan_offload_set,
2585 (void *)&cmd_vlan_offload_what,
2586 (void *)&cmd_vlan_offload_on,
2587 (void *)&cmd_vlan_offload_portid,
2592 /* *** VLAN TPID SET ON A PORT *** */
2593 struct cmd_vlan_tpid_result {
2594 cmdline_fixed_string_t vlan;
2595 cmdline_fixed_string_t set;
2596 cmdline_fixed_string_t what;
2602 cmd_vlan_tpid_parsed(void *parsed_result,
2603 __attribute__((unused)) struct cmdline *cl,
2604 __attribute__((unused)) void *data)
2606 struct cmd_vlan_tpid_result *res = parsed_result;
2607 vlan_tpid_set(res->port_id, res->tp_id);
2611 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2612 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2614 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2615 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2617 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2618 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2620 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2621 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2623 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2624 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2627 cmdline_parse_inst_t cmd_vlan_tpid = {
2628 .f = cmd_vlan_tpid_parsed,
2630 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2632 (void *)&cmd_vlan_tpid_vlan,
2633 (void *)&cmd_vlan_tpid_set,
2634 (void *)&cmd_vlan_tpid_what,
2635 (void *)&cmd_vlan_tpid_tpid,
2636 (void *)&cmd_vlan_tpid_portid,
2641 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2642 struct cmd_rx_vlan_filter_result {
2643 cmdline_fixed_string_t rx_vlan;
2644 cmdline_fixed_string_t what;
2650 cmd_rx_vlan_filter_parsed(void *parsed_result,
2651 __attribute__((unused)) struct cmdline *cl,
2652 __attribute__((unused)) void *data)
2654 struct cmd_rx_vlan_filter_result *res = parsed_result;
2656 if (!strcmp(res->what, "add"))
2657 rx_vft_set(res->port_id, res->vlan_id, 1);
2659 rx_vft_set(res->port_id, res->vlan_id, 0);
2662 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2663 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2664 rx_vlan, "rx_vlan");
2665 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2666 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2668 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2669 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2671 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2672 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2675 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2676 .f = cmd_rx_vlan_filter_parsed,
2678 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2679 "Identifiers filtered by a port",
2681 (void *)&cmd_rx_vlan_filter_rx_vlan,
2682 (void *)&cmd_rx_vlan_filter_what,
2683 (void *)&cmd_rx_vlan_filter_vlanid,
2684 (void *)&cmd_rx_vlan_filter_portid,
2689 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2690 struct cmd_tx_vlan_set_result {
2691 cmdline_fixed_string_t tx_vlan;
2692 cmdline_fixed_string_t set;
2698 cmd_tx_vlan_set_parsed(void *parsed_result,
2699 __attribute__((unused)) struct cmdline *cl,
2700 __attribute__((unused)) void *data)
2702 struct cmd_tx_vlan_set_result *res = parsed_result;
2703 tx_vlan_set(res->port_id, res->vlan_id);
2706 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2707 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2708 tx_vlan, "tx_vlan");
2709 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2710 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2712 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2713 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2715 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2716 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2719 cmdline_parse_inst_t cmd_tx_vlan_set = {
2720 .f = cmd_tx_vlan_set_parsed,
2722 .help_str = "enable hardware insertion of a VLAN header with a given "
2723 "TAG Identifier in packets sent on a port",
2725 (void *)&cmd_tx_vlan_set_tx_vlan,
2726 (void *)&cmd_tx_vlan_set_set,
2727 (void *)&cmd_tx_vlan_set_vlanid,
2728 (void *)&cmd_tx_vlan_set_portid,
2733 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2734 struct cmd_tx_vlan_set_pvid_result {
2735 cmdline_fixed_string_t tx_vlan;
2736 cmdline_fixed_string_t set;
2737 cmdline_fixed_string_t pvid;
2740 cmdline_fixed_string_t mode;
2744 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2745 __attribute__((unused)) struct cmdline *cl,
2746 __attribute__((unused)) void *data)
2748 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2750 if (strcmp(res->mode, "on") == 0)
2751 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2753 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2756 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2757 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2758 tx_vlan, "tx_vlan");
2759 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2760 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2762 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2763 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2765 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2766 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2768 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2769 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2771 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2772 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2775 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2776 .f = cmd_tx_vlan_set_pvid_parsed,
2778 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2780 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2781 (void *)&cmd_tx_vlan_set_pvid_set,
2782 (void *)&cmd_tx_vlan_set_pvid_pvid,
2783 (void *)&cmd_tx_vlan_set_pvid_port_id,
2784 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2785 (void *)&cmd_tx_vlan_set_pvid_mode,
2790 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2791 struct cmd_tx_vlan_reset_result {
2792 cmdline_fixed_string_t tx_vlan;
2793 cmdline_fixed_string_t reset;
2798 cmd_tx_vlan_reset_parsed(void *parsed_result,
2799 __attribute__((unused)) struct cmdline *cl,
2800 __attribute__((unused)) void *data)
2802 struct cmd_tx_vlan_reset_result *res = parsed_result;
2804 tx_vlan_reset(res->port_id);
2807 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2808 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2809 tx_vlan, "tx_vlan");
2810 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2811 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2813 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2814 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2817 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2818 .f = cmd_tx_vlan_reset_parsed,
2820 .help_str = "disable hardware insertion of a VLAN header in packets "
2823 (void *)&cmd_tx_vlan_reset_tx_vlan,
2824 (void *)&cmd_tx_vlan_reset_reset,
2825 (void *)&cmd_tx_vlan_reset_portid,
2831 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2832 struct cmd_csum_result {
2833 cmdline_fixed_string_t csum;
2834 cmdline_fixed_string_t mode;
2835 cmdline_fixed_string_t proto;
2836 cmdline_fixed_string_t hwsw;
2841 csum_show(int port_id)
2843 struct rte_eth_dev_info dev_info;
2846 ol_flags = ports[port_id].tx_ol_flags;
2847 printf("Parse tunnel is %s\n",
2848 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
2849 printf("IP checksum offload is %s\n",
2850 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2851 printf("UDP checksum offload is %s\n",
2852 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2853 printf("TCP checksum offload is %s\n",
2854 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2855 printf("SCTP checksum offload is %s\n",
2856 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2857 printf("Outer-Ip checksum offload is %s\n",
2858 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
2860 /* display warnings if configuration is not supported by the NIC */
2861 rte_eth_dev_info_get(port_id, &dev_info);
2862 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2863 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2864 printf("Warning: hardware IP checksum enabled but not "
2865 "supported by port %d\n", port_id);
2867 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2868 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2869 printf("Warning: hardware UDP checksum enabled but not "
2870 "supported by port %d\n", port_id);
2872 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2873 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2874 printf("Warning: hardware TCP checksum enabled but not "
2875 "supported by port %d\n", port_id);
2877 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2878 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2879 printf("Warning: hardware SCTP checksum enabled but not "
2880 "supported by port %d\n", port_id);
2882 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
2883 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
2884 printf("Warning: hardware outer IP checksum enabled but not "
2885 "supported by port %d\n", port_id);
2890 cmd_csum_parsed(void *parsed_result,
2891 __attribute__((unused)) struct cmdline *cl,
2892 __attribute__((unused)) void *data)
2894 struct cmd_csum_result *res = parsed_result;
2898 if (port_id_is_invalid(res->port_id)) {
2899 printf("invalid port %d\n", res->port_id);
2903 if (!strcmp(res->mode, "set")) {
2905 if (!strcmp(res->hwsw, "hw"))
2908 if (!strcmp(res->proto, "ip")) {
2909 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2910 } else if (!strcmp(res->proto, "udp")) {
2911 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2912 } else if (!strcmp(res->proto, "tcp")) {
2913 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2914 } else if (!strcmp(res->proto, "sctp")) {
2915 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2916 } else if (!strcmp(res->proto, "outer-ip")) {
2917 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
2921 ports[res->port_id].tx_ol_flags |= mask;
2923 ports[res->port_id].tx_ol_flags &= (~mask);
2925 csum_show(res->port_id);
2928 cmdline_parse_token_string_t cmd_csum_csum =
2929 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2931 cmdline_parse_token_string_t cmd_csum_mode =
2932 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2934 cmdline_parse_token_string_t cmd_csum_proto =
2935 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2936 proto, "ip#tcp#udp#sctp#outer-ip");
2937 cmdline_parse_token_string_t cmd_csum_hwsw =
2938 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2940 cmdline_parse_token_num_t cmd_csum_portid =
2941 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
2944 cmdline_parse_inst_t cmd_csum_set = {
2945 .f = cmd_csum_parsed,
2947 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
2948 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
2950 (void *)&cmd_csum_csum,
2951 (void *)&cmd_csum_mode,
2952 (void *)&cmd_csum_proto,
2953 (void *)&cmd_csum_hwsw,
2954 (void *)&cmd_csum_portid,
2959 cmdline_parse_token_string_t cmd_csum_mode_show =
2960 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2963 cmdline_parse_inst_t cmd_csum_show = {
2964 .f = cmd_csum_parsed,
2966 .help_str = "show checksum offload configuration: csum show <port>",
2968 (void *)&cmd_csum_csum,
2969 (void *)&cmd_csum_mode_show,
2970 (void *)&cmd_csum_portid,
2975 /* Enable/disable tunnel parsing */
2976 struct cmd_csum_tunnel_result {
2977 cmdline_fixed_string_t csum;
2978 cmdline_fixed_string_t parse;
2979 cmdline_fixed_string_t onoff;
2984 cmd_csum_tunnel_parsed(void *parsed_result,
2985 __attribute__((unused)) struct cmdline *cl,
2986 __attribute__((unused)) void *data)
2988 struct cmd_csum_tunnel_result *res = parsed_result;
2990 if (port_id_is_invalid(res->port_id)) {
2991 printf("invalid port %d\n", res->port_id);
2995 if (!strcmp(res->onoff, "on"))
2996 ports[res->port_id].tx_ol_flags |=
2997 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
2999 ports[res->port_id].tx_ol_flags &=
3000 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3002 csum_show(res->port_id);
3005 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3006 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3008 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3009 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3010 parse, "parse_tunnel");
3011 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3012 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3014 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3015 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3018 cmdline_parse_inst_t cmd_csum_tunnel = {
3019 .f = cmd_csum_tunnel_parsed,
3021 .help_str = "enable/disable parsing of tunnels for csum engine: "
3022 "csum parse_tunnel on|off <tx-port>",
3024 (void *)&cmd_csum_tunnel_csum,
3025 (void *)&cmd_csum_tunnel_parse,
3026 (void *)&cmd_csum_tunnel_onoff,
3027 (void *)&cmd_csum_tunnel_portid,
3032 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3033 struct cmd_tso_set_result {
3034 cmdline_fixed_string_t tso;
3035 cmdline_fixed_string_t mode;
3041 cmd_tso_set_parsed(void *parsed_result,
3042 __attribute__((unused)) struct cmdline *cl,
3043 __attribute__((unused)) void *data)
3045 struct cmd_tso_set_result *res = parsed_result;
3046 struct rte_eth_dev_info dev_info;
3048 if (port_id_is_invalid(res->port_id))
3051 if (!strcmp(res->mode, "set"))
3052 ports[res->port_id].tso_segsz = res->tso_segsz;
3054 if (ports[res->port_id].tso_segsz == 0)
3055 printf("TSO is disabled\n");
3057 printf("TSO segment size is %d\n",
3058 ports[res->port_id].tso_segsz);
3060 /* display warnings if configuration is not supported by the NIC */
3061 rte_eth_dev_info_get(res->port_id, &dev_info);
3062 if ((ports[res->port_id].tso_segsz != 0) &&
3063 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3064 printf("Warning: TSO enabled but not "
3065 "supported by port %d\n", res->port_id);
3069 cmdline_parse_token_string_t cmd_tso_set_tso =
3070 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3072 cmdline_parse_token_string_t cmd_tso_set_mode =
3073 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3075 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3076 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3078 cmdline_parse_token_num_t cmd_tso_set_portid =
3079 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3082 cmdline_parse_inst_t cmd_tso_set = {
3083 .f = cmd_tso_set_parsed,
3085 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3086 "tso set <tso_segsz> <port>",
3088 (void *)&cmd_tso_set_tso,
3089 (void *)&cmd_tso_set_mode,
3090 (void *)&cmd_tso_set_tso_segsz,
3091 (void *)&cmd_tso_set_portid,
3096 cmdline_parse_token_string_t cmd_tso_show_mode =
3097 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3101 cmdline_parse_inst_t cmd_tso_show = {
3102 .f = cmd_tso_set_parsed,
3104 .help_str = "Show TSO segment size for csum engine: "
3107 (void *)&cmd_tso_set_tso,
3108 (void *)&cmd_tso_show_mode,
3109 (void *)&cmd_tso_set_portid,
3114 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3115 struct cmd_set_flush_rx {
3116 cmdline_fixed_string_t set;
3117 cmdline_fixed_string_t flush_rx;
3118 cmdline_fixed_string_t mode;
3122 cmd_set_flush_rx_parsed(void *parsed_result,
3123 __attribute__((unused)) struct cmdline *cl,
3124 __attribute__((unused)) void *data)
3126 struct cmd_set_flush_rx *res = parsed_result;
3127 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3130 cmdline_parse_token_string_t cmd_setflushrx_set =
3131 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3133 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3134 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3135 flush_rx, "flush_rx");
3136 cmdline_parse_token_string_t cmd_setflushrx_mode =
3137 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3141 cmdline_parse_inst_t cmd_set_flush_rx = {
3142 .f = cmd_set_flush_rx_parsed,
3143 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3146 (void *)&cmd_setflushrx_set,
3147 (void *)&cmd_setflushrx_flush_rx,
3148 (void *)&cmd_setflushrx_mode,
3153 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3154 struct cmd_set_link_check {
3155 cmdline_fixed_string_t set;
3156 cmdline_fixed_string_t link_check;
3157 cmdline_fixed_string_t mode;
3161 cmd_set_link_check_parsed(void *parsed_result,
3162 __attribute__((unused)) struct cmdline *cl,
3163 __attribute__((unused)) void *data)
3165 struct cmd_set_link_check *res = parsed_result;
3166 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3169 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3170 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3172 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3173 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3174 link_check, "link_check");
3175 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3176 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3180 cmdline_parse_inst_t cmd_set_link_check = {
3181 .f = cmd_set_link_check_parsed,
3182 .help_str = "set link_check on|off: enable/disable link status check "
3183 "when starting/stopping a port",
3186 (void *)&cmd_setlinkcheck_set,
3187 (void *)&cmd_setlinkcheck_link_check,
3188 (void *)&cmd_setlinkcheck_mode,
3193 #ifdef RTE_NIC_BYPASS
3194 /* *** SET NIC BYPASS MODE *** */
3195 struct cmd_set_bypass_mode_result {
3196 cmdline_fixed_string_t set;
3197 cmdline_fixed_string_t bypass;
3198 cmdline_fixed_string_t mode;
3199 cmdline_fixed_string_t value;
3204 cmd_set_bypass_mode_parsed(void *parsed_result,
3205 __attribute__((unused)) struct cmdline *cl,
3206 __attribute__((unused)) void *data)
3208 struct cmd_set_bypass_mode_result *res = parsed_result;
3209 portid_t port_id = res->port_id;
3210 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3212 if (!bypass_is_supported(port_id))
3215 if (!strcmp(res->value, "bypass"))
3216 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3217 else if (!strcmp(res->value, "isolate"))
3218 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3220 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3222 /* Set the bypass mode for the relevant port. */
3223 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3224 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3228 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3229 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3231 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3232 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3234 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3235 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3237 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3238 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3239 value, "normal#bypass#isolate");
3240 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3241 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3244 cmdline_parse_inst_t cmd_set_bypass_mode = {
3245 .f = cmd_set_bypass_mode_parsed,
3246 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3247 "Set the NIC bypass mode for port_id",
3250 (void *)&cmd_setbypass_mode_set,
3251 (void *)&cmd_setbypass_mode_bypass,
3252 (void *)&cmd_setbypass_mode_mode,
3253 (void *)&cmd_setbypass_mode_value,
3254 (void *)&cmd_setbypass_mode_port,
3259 /* *** SET NIC BYPASS EVENT *** */
3260 struct cmd_set_bypass_event_result {
3261 cmdline_fixed_string_t set;
3262 cmdline_fixed_string_t bypass;
3263 cmdline_fixed_string_t event;
3264 cmdline_fixed_string_t event_value;
3265 cmdline_fixed_string_t mode;
3266 cmdline_fixed_string_t mode_value;
3271 cmd_set_bypass_event_parsed(void *parsed_result,
3272 __attribute__((unused)) struct cmdline *cl,
3273 __attribute__((unused)) void *data)
3276 struct cmd_set_bypass_event_result *res = parsed_result;
3277 portid_t port_id = res->port_id;
3278 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3279 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3281 if (!bypass_is_supported(port_id))
3284 if (!strcmp(res->event_value, "timeout"))
3285 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3286 else if (!strcmp(res->event_value, "os_on"))
3287 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3288 else if (!strcmp(res->event_value, "os_off"))
3289 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3290 else if (!strcmp(res->event_value, "power_on"))
3291 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3292 else if (!strcmp(res->event_value, "power_off"))
3293 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3295 bypass_event = RTE_BYPASS_EVENT_NONE;
3297 if (!strcmp(res->mode_value, "bypass"))
3298 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3299 else if (!strcmp(res->mode_value, "isolate"))
3300 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3302 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3304 /* Set the watchdog timeout. */
3305 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3308 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3309 (rc = rte_eth_dev_wd_timeout_store(port_id,
3310 bypass_timeout)) != 0) {
3311 printf("Failed to set timeout value %u "
3312 "for port %d, errto code: %d.\n",
3313 bypass_timeout, port_id, rc);
3317 /* Set the bypass event to transition to bypass mode. */
3318 if (0 != rte_eth_dev_bypass_event_store(port_id,
3319 bypass_event, bypass_mode)) {
3320 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3325 cmdline_parse_token_string_t cmd_setbypass_event_set =
3326 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3328 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3329 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3331 cmdline_parse_token_string_t cmd_setbypass_event_event =
3332 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3334 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3335 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3336 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3337 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3338 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3340 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3341 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3342 mode_value, "normal#bypass#isolate");
3343 cmdline_parse_token_num_t cmd_setbypass_event_port =
3344 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3347 cmdline_parse_inst_t cmd_set_bypass_event = {
3348 .f = cmd_set_bypass_event_parsed,
3349 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3350 "mode (normal|bypass|isolate) (port_id): "
3351 "Set the NIC bypass event mode for port_id",
3354 (void *)&cmd_setbypass_event_set,
3355 (void *)&cmd_setbypass_event_bypass,
3356 (void *)&cmd_setbypass_event_event,
3357 (void *)&cmd_setbypass_event_event_value,
3358 (void *)&cmd_setbypass_event_mode,
3359 (void *)&cmd_setbypass_event_mode_value,
3360 (void *)&cmd_setbypass_event_port,
3366 /* *** SET NIC BYPASS TIMEOUT *** */
3367 struct cmd_set_bypass_timeout_result {
3368 cmdline_fixed_string_t set;
3369 cmdline_fixed_string_t bypass;
3370 cmdline_fixed_string_t timeout;
3371 cmdline_fixed_string_t value;
3375 cmd_set_bypass_timeout_parsed(void *parsed_result,
3376 __attribute__((unused)) struct cmdline *cl,
3377 __attribute__((unused)) void *data)
3379 struct cmd_set_bypass_timeout_result *res = parsed_result;
3381 if (!strcmp(res->value, "1.5"))
3382 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3383 else if (!strcmp(res->value, "2"))
3384 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3385 else if (!strcmp(res->value, "3"))
3386 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3387 else if (!strcmp(res->value, "4"))
3388 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3389 else if (!strcmp(res->value, "8"))
3390 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3391 else if (!strcmp(res->value, "16"))
3392 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3393 else if (!strcmp(res->value, "32"))
3394 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3396 bypass_timeout = RTE_BYPASS_TMT_OFF;
3399 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3400 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3402 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3403 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3405 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3406 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3407 timeout, "timeout");
3408 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3409 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3410 value, "0#1.5#2#3#4#8#16#32");
3412 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3413 .f = cmd_set_bypass_timeout_parsed,
3414 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3415 "Set the NIC bypass watchdog timeout",
3418 (void *)&cmd_setbypass_timeout_set,
3419 (void *)&cmd_setbypass_timeout_bypass,
3420 (void *)&cmd_setbypass_timeout_timeout,
3421 (void *)&cmd_setbypass_timeout_value,
3426 /* *** SHOW NIC BYPASS MODE *** */
3427 struct cmd_show_bypass_config_result {
3428 cmdline_fixed_string_t show;
3429 cmdline_fixed_string_t bypass;
3430 cmdline_fixed_string_t config;
3435 cmd_show_bypass_config_parsed(void *parsed_result,
3436 __attribute__((unused)) struct cmdline *cl,
3437 __attribute__((unused)) void *data)
3439 struct cmd_show_bypass_config_result *res = parsed_result;
3440 uint32_t event_mode;
3441 uint32_t bypass_mode;
3442 portid_t port_id = res->port_id;
3443 uint32_t timeout = bypass_timeout;
3446 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3447 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3448 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3449 {"UNKNOWN", "normal", "bypass", "isolate"};
3450 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3457 int num_events = (sizeof events) / (sizeof events[0]);
3459 if (!bypass_is_supported(port_id))
3462 /* Display the bypass mode.*/
3463 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3464 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3468 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3469 bypass_mode = RTE_BYPASS_MODE_NONE;
3471 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3474 /* Display the bypass timeout.*/
3475 if (!RTE_BYPASS_TMT_VALID(timeout))
3476 timeout = RTE_BYPASS_TMT_OFF;
3478 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3480 /* Display the bypass events and associated modes. */
3481 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3483 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3484 printf("\tFailed to get bypass mode for event = %s\n",
3487 if (!RTE_BYPASS_MODE_VALID(event_mode))
3488 event_mode = RTE_BYPASS_MODE_NONE;
3490 printf("\tbypass event: %-16s = %s\n", events[i],
3496 cmdline_parse_token_string_t cmd_showbypass_config_show =
3497 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3499 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3500 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3502 cmdline_parse_token_string_t cmd_showbypass_config_config =
3503 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3505 cmdline_parse_token_num_t cmd_showbypass_config_port =
3506 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3509 cmdline_parse_inst_t cmd_show_bypass_config = {
3510 .f = cmd_show_bypass_config_parsed,
3511 .help_str = "show bypass config (port_id): "
3512 "Show the NIC bypass config for port_id",
3515 (void *)&cmd_showbypass_config_show,
3516 (void *)&cmd_showbypass_config_bypass,
3517 (void *)&cmd_showbypass_config_config,
3518 (void *)&cmd_showbypass_config_port,
3524 #ifdef RTE_LIBRTE_PMD_BOND
3525 /* *** SET BONDING MODE *** */
3526 struct cmd_set_bonding_mode_result {
3527 cmdline_fixed_string_t set;
3528 cmdline_fixed_string_t bonding;
3529 cmdline_fixed_string_t mode;
3534 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3535 __attribute__((unused)) struct cmdline *cl,
3536 __attribute__((unused)) void *data)
3538 struct cmd_set_bonding_mode_result *res = parsed_result;
3539 portid_t port_id = res->port_id;
3541 /* Set the bonding mode for the relevant port. */
3542 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3543 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3546 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3547 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3549 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3550 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3551 bonding, "bonding");
3552 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3553 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3555 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3556 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3558 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3559 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3562 cmdline_parse_inst_t cmd_set_bonding_mode = {
3563 .f = cmd_set_bonding_mode_parsed,
3564 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3567 (void *) &cmd_setbonding_mode_set,
3568 (void *) &cmd_setbonding_mode_bonding,
3569 (void *) &cmd_setbonding_mode_mode,
3570 (void *) &cmd_setbonding_mode_value,
3571 (void *) &cmd_setbonding_mode_port,
3576 /* *** SET BALANCE XMIT POLICY *** */
3577 struct cmd_set_bonding_balance_xmit_policy_result {
3578 cmdline_fixed_string_t set;
3579 cmdline_fixed_string_t bonding;
3580 cmdline_fixed_string_t balance_xmit_policy;
3582 cmdline_fixed_string_t policy;
3585 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3586 __attribute__((unused)) struct cmdline *cl,
3587 __attribute__((unused)) void *data)
3589 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3590 portid_t port_id = res->port_id;
3593 if (!strcmp(res->policy, "l2")) {
3594 policy = BALANCE_XMIT_POLICY_LAYER2;
3595 } else if (!strcmp(res->policy, "l23")) {
3596 policy = BALANCE_XMIT_POLICY_LAYER23;
3597 } else if (!strcmp(res->policy, "l34")) {
3598 policy = BALANCE_XMIT_POLICY_LAYER34;
3600 printf("\t Invalid xmit policy selection");
3604 /* Set the bonding mode for the relevant port. */
3605 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3606 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3611 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3612 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3614 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3615 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3616 bonding, "bonding");
3617 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3618 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3619 balance_xmit_policy, "balance_xmit_policy");
3620 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3621 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3623 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3624 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3625 policy, "l2#l23#l34");
3627 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3628 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3629 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3632 (void *)&cmd_setbonding_balance_xmit_policy_set,
3633 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3634 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3635 (void *)&cmd_setbonding_balance_xmit_policy_port,
3636 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3641 /* *** SHOW NIC BONDING CONFIGURATION *** */
3642 struct cmd_show_bonding_config_result {
3643 cmdline_fixed_string_t show;
3644 cmdline_fixed_string_t bonding;
3645 cmdline_fixed_string_t config;
3649 static void cmd_show_bonding_config_parsed(void *parsed_result,
3650 __attribute__((unused)) struct cmdline *cl,
3651 __attribute__((unused)) void *data)
3653 struct cmd_show_bonding_config_result *res = parsed_result;
3655 uint8_t slaves[RTE_MAX_ETHPORTS];
3656 int num_slaves, num_active_slaves;
3659 portid_t port_id = res->port_id;
3661 /* Display the bonding mode.*/
3662 bonding_mode = rte_eth_bond_mode_get(port_id);
3663 if (bonding_mode < 0) {
3664 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3667 printf("\tBonding mode: %d\n", bonding_mode);
3669 if (bonding_mode == BONDING_MODE_BALANCE) {
3670 int balance_xmit_policy;
3672 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3673 if (balance_xmit_policy < 0) {
3674 printf("\tFailed to get balance xmit policy for port = %d\n",
3678 printf("\tBalance Xmit Policy: ");
3680 switch (balance_xmit_policy) {
3681 case BALANCE_XMIT_POLICY_LAYER2:
3682 printf("BALANCE_XMIT_POLICY_LAYER2");
3684 case BALANCE_XMIT_POLICY_LAYER23:
3685 printf("BALANCE_XMIT_POLICY_LAYER23");
3687 case BALANCE_XMIT_POLICY_LAYER34:
3688 printf("BALANCE_XMIT_POLICY_LAYER34");
3695 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3697 if (num_slaves < 0) {
3698 printf("\tFailed to get slave list for port = %d\n", port_id);
3701 if (num_slaves > 0) {
3702 printf("\tSlaves (%d): [", num_slaves);
3703 for (i = 0; i < num_slaves - 1; i++)
3704 printf("%d ", slaves[i]);
3706 printf("%d]\n", slaves[num_slaves - 1]);
3708 printf("\tSlaves: []\n");
3712 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3715 if (num_active_slaves < 0) {
3716 printf("\tFailed to get active slave list for port = %d\n", port_id);
3719 if (num_active_slaves > 0) {
3720 printf("\tActive Slaves (%d): [", num_active_slaves);
3721 for (i = 0; i < num_active_slaves - 1; i++)
3722 printf("%d ", slaves[i]);
3724 printf("%d]\n", slaves[num_active_slaves - 1]);
3727 printf("\tActive Slaves: []\n");
3731 primary_id = rte_eth_bond_primary_get(port_id);
3732 if (primary_id < 0) {
3733 printf("\tFailed to get primary slave for port = %d\n", port_id);
3736 printf("\tPrimary: [%d]\n", primary_id);
3740 cmdline_parse_token_string_t cmd_showbonding_config_show =
3741 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3743 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3744 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3745 bonding, "bonding");
3746 cmdline_parse_token_string_t cmd_showbonding_config_config =
3747 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3749 cmdline_parse_token_num_t cmd_showbonding_config_port =
3750 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3753 cmdline_parse_inst_t cmd_show_bonding_config = {
3754 .f = cmd_show_bonding_config_parsed,
3755 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3758 (void *)&cmd_showbonding_config_show,
3759 (void *)&cmd_showbonding_config_bonding,
3760 (void *)&cmd_showbonding_config_config,
3761 (void *)&cmd_showbonding_config_port,
3766 /* *** SET BONDING PRIMARY *** */
3767 struct cmd_set_bonding_primary_result {
3768 cmdline_fixed_string_t set;
3769 cmdline_fixed_string_t bonding;
3770 cmdline_fixed_string_t primary;
3775 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3776 __attribute__((unused)) struct cmdline *cl,
3777 __attribute__((unused)) void *data)
3779 struct cmd_set_bonding_primary_result *res = parsed_result;
3780 portid_t master_port_id = res->port_id;
3781 portid_t slave_port_id = res->slave_id;
3783 /* Set the primary slave for a bonded device. */
3784 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3785 printf("\t Failed to set primary slave for port = %d.\n",
3792 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3793 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3795 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3796 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3797 bonding, "bonding");
3798 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3799 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3800 primary, "primary");
3801 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3802 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3804 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3805 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3808 cmdline_parse_inst_t cmd_set_bonding_primary = {
3809 .f = cmd_set_bonding_primary_parsed,
3810 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3813 (void *)&cmd_setbonding_primary_set,
3814 (void *)&cmd_setbonding_primary_bonding,
3815 (void *)&cmd_setbonding_primary_primary,
3816 (void *)&cmd_setbonding_primary_slave,
3817 (void *)&cmd_setbonding_primary_port,
3822 /* *** ADD SLAVE *** */
3823 struct cmd_add_bonding_slave_result {
3824 cmdline_fixed_string_t add;
3825 cmdline_fixed_string_t bonding;
3826 cmdline_fixed_string_t slave;
3831 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3832 __attribute__((unused)) struct cmdline *cl,
3833 __attribute__((unused)) void *data)
3835 struct cmd_add_bonding_slave_result *res = parsed_result;
3836 portid_t master_port_id = res->port_id;
3837 portid_t slave_port_id = res->slave_id;
3839 /* Set the primary slave for a bonded device. */
3840 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3841 printf("\t Failed to add slave %d to master port = %d.\n",
3842 slave_port_id, master_port_id);
3848 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3849 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3851 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3852 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3853 bonding, "bonding");
3854 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3855 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3857 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3858 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3860 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3861 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3864 cmdline_parse_inst_t cmd_add_bonding_slave = {
3865 .f = cmd_add_bonding_slave_parsed,
3866 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3869 (void *)&cmd_addbonding_slave_add,
3870 (void *)&cmd_addbonding_slave_bonding,
3871 (void *)&cmd_addbonding_slave_slave,
3872 (void *)&cmd_addbonding_slave_slaveid,
3873 (void *)&cmd_addbonding_slave_port,
3878 /* *** REMOVE SLAVE *** */
3879 struct cmd_remove_bonding_slave_result {
3880 cmdline_fixed_string_t remove;
3881 cmdline_fixed_string_t bonding;
3882 cmdline_fixed_string_t slave;
3887 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3888 __attribute__((unused)) struct cmdline *cl,
3889 __attribute__((unused)) void *data)
3891 struct cmd_remove_bonding_slave_result *res = parsed_result;
3892 portid_t master_port_id = res->port_id;
3893 portid_t slave_port_id = res->slave_id;
3895 /* Set the primary slave for a bonded device. */
3896 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3897 printf("\t Failed to remove slave %d from master port = %d.\n",
3898 slave_port_id, master_port_id);
3904 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3905 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3907 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3908 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3909 bonding, "bonding");
3910 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3911 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3913 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3914 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3916 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3917 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3920 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3921 .f = cmd_remove_bonding_slave_parsed,
3922 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3925 (void *)&cmd_removebonding_slave_remove,
3926 (void *)&cmd_removebonding_slave_bonding,
3927 (void *)&cmd_removebonding_slave_slave,
3928 (void *)&cmd_removebonding_slave_slaveid,
3929 (void *)&cmd_removebonding_slave_port,
3934 /* *** CREATE BONDED DEVICE *** */
3935 struct cmd_create_bonded_device_result {
3936 cmdline_fixed_string_t create;
3937 cmdline_fixed_string_t bonded;
3938 cmdline_fixed_string_t device;
3943 static int bond_dev_num = 0;
3945 static void cmd_create_bonded_device_parsed(void *parsed_result,
3946 __attribute__((unused)) struct cmdline *cl,
3947 __attribute__((unused)) void *data)
3949 struct cmd_create_bonded_device_result *res = parsed_result;
3950 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3953 if (test_done == 0) {
3954 printf("Please stop forwarding first\n");
3958 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3961 /* Create a new bonded device. */
3962 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3964 printf("\t Failed to create bonded device.\n");
3967 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3970 /* Update number of ports */
3971 nb_ports = rte_eth_dev_count();
3972 reconfig(port_id, res->socket);
3973 rte_eth_promiscuous_enable(port_id);
3978 cmdline_parse_token_string_t cmd_createbonded_device_create =
3979 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3981 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3982 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3984 cmdline_parse_token_string_t cmd_createbonded_device_device =
3985 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3987 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3988 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3990 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3991 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3994 cmdline_parse_inst_t cmd_create_bonded_device = {
3995 .f = cmd_create_bonded_device_parsed,
3996 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3999 (void *)&cmd_createbonded_device_create,
4000 (void *)&cmd_createbonded_device_bonded,
4001 (void *)&cmd_createbonded_device_device,
4002 (void *)&cmd_createbonded_device_mode,
4003 (void *)&cmd_createbonded_device_socket,
4008 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4009 struct cmd_set_bond_mac_addr_result {
4010 cmdline_fixed_string_t set;
4011 cmdline_fixed_string_t bonding;
4012 cmdline_fixed_string_t mac_addr;
4014 struct ether_addr address;
4017 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4018 __attribute__((unused)) struct cmdline *cl,
4019 __attribute__((unused)) void *data)
4021 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4024 if (res->port_num >= nb_ports) {
4025 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4029 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4031 /* check the return value and print it if is < 0 */
4033 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4036 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4037 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4038 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4039 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4041 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4042 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4044 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4045 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4046 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4047 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4049 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4050 .f = cmd_set_bond_mac_addr_parsed,
4052 .help_str = "set bonding mac_addr (port_id) (address): ",
4054 (void *)&cmd_set_bond_mac_addr_set,
4055 (void *)&cmd_set_bond_mac_addr_bonding,
4056 (void *)&cmd_set_bond_mac_addr_mac,
4057 (void *)&cmd_set_bond_mac_addr_portnum,
4058 (void *)&cmd_set_bond_mac_addr_addr,
4064 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4065 struct cmd_set_bond_mon_period_result {
4066 cmdline_fixed_string_t set;
4067 cmdline_fixed_string_t bonding;
4068 cmdline_fixed_string_t mon_period;
4073 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4074 __attribute__((unused)) struct cmdline *cl,
4075 __attribute__((unused)) void *data)
4077 struct cmd_set_bond_mon_period_result *res = parsed_result;
4080 if (res->port_num >= nb_ports) {
4081 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4085 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4087 /* check the return value and print it if is < 0 */
4089 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4092 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4093 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4095 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4096 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4097 bonding, "bonding");
4098 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4099 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4100 mon_period, "mon_period");
4101 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4102 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4104 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4105 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4108 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4109 .f = cmd_set_bond_mon_period_parsed,
4111 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4113 (void *)&cmd_set_bond_mon_period_set,
4114 (void *)&cmd_set_bond_mon_period_bonding,
4115 (void *)&cmd_set_bond_mon_period_mon_period,
4116 (void *)&cmd_set_bond_mon_period_portnum,
4117 (void *)&cmd_set_bond_mon_period_period_ms,
4122 #endif /* RTE_LIBRTE_PMD_BOND */
4124 /* *** SET FORWARDING MODE *** */
4125 struct cmd_set_fwd_mode_result {
4126 cmdline_fixed_string_t set;
4127 cmdline_fixed_string_t fwd;
4128 cmdline_fixed_string_t mode;
4131 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4132 __attribute__((unused)) struct cmdline *cl,
4133 __attribute__((unused)) void *data)
4135 struct cmd_set_fwd_mode_result *res = parsed_result;
4137 set_pkt_forwarding_mode(res->mode);
4140 cmdline_parse_token_string_t cmd_setfwd_set =
4141 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4142 cmdline_parse_token_string_t cmd_setfwd_fwd =
4143 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4144 cmdline_parse_token_string_t cmd_setfwd_mode =
4145 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4146 "" /* defined at init */);
4148 cmdline_parse_inst_t cmd_set_fwd_mode = {
4149 .f = cmd_set_fwd_mode_parsed,
4151 .help_str = NULL, /* defined at init */
4153 (void *)&cmd_setfwd_set,
4154 (void *)&cmd_setfwd_fwd,
4155 (void *)&cmd_setfwd_mode,
4160 static void cmd_set_fwd_mode_init(void)
4163 static char token[128];
4164 static char help[256];
4165 cmdline_parse_token_string_t *token_struct;
4167 modes = list_pkt_forwarding_modes();
4168 snprintf(help, sizeof help, "set fwd %s - "
4169 "set packet forwarding mode", modes);
4170 cmd_set_fwd_mode.help_str = help;
4172 /* string token separator is # */
4173 for (c = token; *modes != '\0'; modes++)
4178 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4179 token_struct->string_data.str = token;
4182 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4183 struct cmd_set_burst_tx_retry_result {
4184 cmdline_fixed_string_t set;
4185 cmdline_fixed_string_t burst;
4186 cmdline_fixed_string_t tx;
4187 cmdline_fixed_string_t delay;
4189 cmdline_fixed_string_t retry;
4193 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4194 __attribute__((unused)) struct cmdline *cl,
4195 __attribute__((unused)) void *data)
4197 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4199 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4200 && !strcmp(res->tx, "tx")) {
4201 if (!strcmp(res->delay, "delay"))
4202 burst_tx_delay_time = res->time;
4203 if (!strcmp(res->retry, "retry"))
4204 burst_tx_retry_num = res->retry_num;
4209 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4210 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4211 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4212 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4214 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4215 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4216 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4217 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4218 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4219 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4220 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4221 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4222 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4223 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4225 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4226 .f = cmd_set_burst_tx_retry_parsed,
4227 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4229 (void *)&cmd_set_burst_tx_retry_set,
4230 (void *)&cmd_set_burst_tx_retry_burst,
4231 (void *)&cmd_set_burst_tx_retry_tx,
4232 (void *)&cmd_set_burst_tx_retry_delay,
4233 (void *)&cmd_set_burst_tx_retry_time,
4234 (void *)&cmd_set_burst_tx_retry_retry,
4235 (void *)&cmd_set_burst_tx_retry_retry_num,
4240 /* *** SET PROMISC MODE *** */
4241 struct cmd_set_promisc_mode_result {
4242 cmdline_fixed_string_t set;
4243 cmdline_fixed_string_t promisc;
4244 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4245 uint8_t port_num; /* valid if "allports" argument == 0 */
4246 cmdline_fixed_string_t mode;
4249 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4250 __attribute__((unused)) struct cmdline *cl,
4253 struct cmd_set_promisc_mode_result *res = parsed_result;
4257 if (!strcmp(res->mode, "on"))
4264 for (i = 0; i < nb_ports; i++) {
4266 rte_eth_promiscuous_enable(i);
4268 rte_eth_promiscuous_disable(i);
4273 rte_eth_promiscuous_enable(res->port_num);
4275 rte_eth_promiscuous_disable(res->port_num);
4279 cmdline_parse_token_string_t cmd_setpromisc_set =
4280 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4281 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4282 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4284 cmdline_parse_token_string_t cmd_setpromisc_portall =
4285 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4287 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4288 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4290 cmdline_parse_token_string_t cmd_setpromisc_mode =
4291 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4294 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4295 .f = cmd_set_promisc_mode_parsed,
4297 .help_str = "set promisc all on|off: set promisc mode for all ports",
4299 (void *)&cmd_setpromisc_set,
4300 (void *)&cmd_setpromisc_promisc,
4301 (void *)&cmd_setpromisc_portall,
4302 (void *)&cmd_setpromisc_mode,
4307 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4308 .f = cmd_set_promisc_mode_parsed,
4310 .help_str = "set promisc X on|off: set promisc mode on port X",
4312 (void *)&cmd_setpromisc_set,
4313 (void *)&cmd_setpromisc_promisc,
4314 (void *)&cmd_setpromisc_portnum,
4315 (void *)&cmd_setpromisc_mode,
4320 /* *** SET ALLMULTI MODE *** */
4321 struct cmd_set_allmulti_mode_result {
4322 cmdline_fixed_string_t set;
4323 cmdline_fixed_string_t allmulti;
4324 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4325 uint8_t port_num; /* valid if "allports" argument == 0 */
4326 cmdline_fixed_string_t mode;
4329 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4330 __attribute__((unused)) struct cmdline *cl,
4333 struct cmd_set_allmulti_mode_result *res = parsed_result;
4337 if (!strcmp(res->mode, "on"))
4344 for (i = 0; i < nb_ports; i++) {
4346 rte_eth_allmulticast_enable(i);
4348 rte_eth_allmulticast_disable(i);
4353 rte_eth_allmulticast_enable(res->port_num);
4355 rte_eth_allmulticast_disable(res->port_num);
4359 cmdline_parse_token_string_t cmd_setallmulti_set =
4360 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4361 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4362 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4364 cmdline_parse_token_string_t cmd_setallmulti_portall =
4365 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4367 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4368 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4370 cmdline_parse_token_string_t cmd_setallmulti_mode =
4371 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4374 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4375 .f = cmd_set_allmulti_mode_parsed,
4377 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4379 (void *)&cmd_setallmulti_set,
4380 (void *)&cmd_setallmulti_allmulti,
4381 (void *)&cmd_setallmulti_portall,
4382 (void *)&cmd_setallmulti_mode,
4387 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4388 .f = cmd_set_allmulti_mode_parsed,
4390 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4392 (void *)&cmd_setallmulti_set,
4393 (void *)&cmd_setallmulti_allmulti,
4394 (void *)&cmd_setallmulti_portnum,
4395 (void *)&cmd_setallmulti_mode,
4400 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4401 struct cmd_link_flow_ctrl_set_result {
4402 cmdline_fixed_string_t set;
4403 cmdline_fixed_string_t flow_ctrl;
4404 cmdline_fixed_string_t rx;
4405 cmdline_fixed_string_t rx_lfc_mode;
4406 cmdline_fixed_string_t tx;
4407 cmdline_fixed_string_t tx_lfc_mode;
4408 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4409 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4410 cmdline_fixed_string_t autoneg_str;
4411 cmdline_fixed_string_t autoneg;
4412 cmdline_fixed_string_t hw_str;
4413 uint32_t high_water;
4414 cmdline_fixed_string_t lw_str;
4416 cmdline_fixed_string_t pt_str;
4417 uint16_t pause_time;
4418 cmdline_fixed_string_t xon_str;
4423 cmdline_parse_token_string_t cmd_lfc_set_set =
4424 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4426 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4427 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4428 flow_ctrl, "flow_ctrl");
4429 cmdline_parse_token_string_t cmd_lfc_set_rx =
4430 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4432 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4433 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4434 rx_lfc_mode, "on#off");
4435 cmdline_parse_token_string_t cmd_lfc_set_tx =
4436 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4438 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4439 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4440 tx_lfc_mode, "on#off");
4441 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4442 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4443 hw_str, "high_water");
4444 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4445 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4446 high_water, UINT32);
4447 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4448 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4449 lw_str, "low_water");
4450 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4451 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4453 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4454 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4455 pt_str, "pause_time");
4456 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4457 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4458 pause_time, UINT16);
4459 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4460 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4461 xon_str, "send_xon");
4462 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4463 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4465 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4466 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4467 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4468 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4469 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4470 mac_ctrl_frame_fwd_mode, "on#off");
4471 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4472 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4473 autoneg_str, "autoneg");
4474 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4475 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4477 cmdline_parse_token_num_t cmd_lfc_set_portid =
4478 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4481 /* forward declaration */
4483 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4486 cmdline_parse_inst_t cmd_link_flow_control_set = {
4487 .f = cmd_link_flow_ctrl_set_parsed,
4489 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4490 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4491 autoneg on|off port_id",
4493 (void *)&cmd_lfc_set_set,
4494 (void *)&cmd_lfc_set_flow_ctrl,
4495 (void *)&cmd_lfc_set_rx,
4496 (void *)&cmd_lfc_set_rx_mode,
4497 (void *)&cmd_lfc_set_tx,
4498 (void *)&cmd_lfc_set_tx_mode,
4499 (void *)&cmd_lfc_set_high_water,
4500 (void *)&cmd_lfc_set_low_water,
4501 (void *)&cmd_lfc_set_pause_time,
4502 (void *)&cmd_lfc_set_send_xon,
4503 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4504 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4505 (void *)&cmd_lfc_set_autoneg_str,
4506 (void *)&cmd_lfc_set_autoneg,
4507 (void *)&cmd_lfc_set_portid,
4512 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4513 .f = cmd_link_flow_ctrl_set_parsed,
4514 .data = (void *)&cmd_link_flow_control_set_rx,
4515 .help_str = "Change rx flow control parameter: set flow_ctrl "
4516 "rx on|off port_id",
4518 (void *)&cmd_lfc_set_set,
4519 (void *)&cmd_lfc_set_flow_ctrl,
4520 (void *)&cmd_lfc_set_rx,
4521 (void *)&cmd_lfc_set_rx_mode,
4522 (void *)&cmd_lfc_set_portid,
4527 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4528 .f = cmd_link_flow_ctrl_set_parsed,
4529 .data = (void *)&cmd_link_flow_control_set_tx,
4530 .help_str = "Change tx flow control parameter: set flow_ctrl "
4531 "tx on|off port_id",
4533 (void *)&cmd_lfc_set_set,
4534 (void *)&cmd_lfc_set_flow_ctrl,
4535 (void *)&cmd_lfc_set_tx,
4536 (void *)&cmd_lfc_set_tx_mode,
4537 (void *)&cmd_lfc_set_portid,
4542 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4543 .f = cmd_link_flow_ctrl_set_parsed,
4544 .data = (void *)&cmd_link_flow_control_set_hw,
4545 .help_str = "Change high water flow control parameter: set flow_ctrl "
4546 "high_water value port_id",
4548 (void *)&cmd_lfc_set_set,
4549 (void *)&cmd_lfc_set_flow_ctrl,
4550 (void *)&cmd_lfc_set_high_water_str,
4551 (void *)&cmd_lfc_set_high_water,
4552 (void *)&cmd_lfc_set_portid,
4557 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4558 .f = cmd_link_flow_ctrl_set_parsed,
4559 .data = (void *)&cmd_link_flow_control_set_lw,
4560 .help_str = "Change low water flow control parameter: set flow_ctrl "
4561 "low_water value port_id",
4563 (void *)&cmd_lfc_set_set,
4564 (void *)&cmd_lfc_set_flow_ctrl,
4565 (void *)&cmd_lfc_set_low_water_str,
4566 (void *)&cmd_lfc_set_low_water,
4567 (void *)&cmd_lfc_set_portid,
4572 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4573 .f = cmd_link_flow_ctrl_set_parsed,
4574 .data = (void *)&cmd_link_flow_control_set_pt,
4575 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4576 "pause_time value port_id",
4578 (void *)&cmd_lfc_set_set,
4579 (void *)&cmd_lfc_set_flow_ctrl,
4580 (void *)&cmd_lfc_set_pause_time_str,
4581 (void *)&cmd_lfc_set_pause_time,
4582 (void *)&cmd_lfc_set_portid,
4587 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4588 .f = cmd_link_flow_ctrl_set_parsed,
4589 .data = (void *)&cmd_link_flow_control_set_xon,
4590 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4591 "send_xon value port_id",
4593 (void *)&cmd_lfc_set_set,
4594 (void *)&cmd_lfc_set_flow_ctrl,
4595 (void *)&cmd_lfc_set_send_xon_str,
4596 (void *)&cmd_lfc_set_send_xon,
4597 (void *)&cmd_lfc_set_portid,
4602 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4603 .f = cmd_link_flow_ctrl_set_parsed,
4604 .data = (void *)&cmd_link_flow_control_set_macfwd,
4605 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4606 "mac_ctrl_frame_fwd on|off port_id",
4608 (void *)&cmd_lfc_set_set,
4609 (void *)&cmd_lfc_set_flow_ctrl,
4610 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4611 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4612 (void *)&cmd_lfc_set_portid,
4617 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4618 .f = cmd_link_flow_ctrl_set_parsed,
4619 .data = (void *)&cmd_link_flow_control_set_autoneg,
4620 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4621 "autoneg on|off port_id",
4623 (void *)&cmd_lfc_set_set,
4624 (void *)&cmd_lfc_set_flow_ctrl,
4625 (void *)&cmd_lfc_set_autoneg_str,
4626 (void *)&cmd_lfc_set_autoneg,
4627 (void *)&cmd_lfc_set_portid,
4633 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4634 __attribute__((unused)) struct cmdline *cl,
4637 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4638 cmdline_parse_inst_t *cmd = data;
4639 struct rte_eth_fc_conf fc_conf;
4640 int rx_fc_en, tx_fc_en = 0;
4644 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4645 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4646 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4647 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4649 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4650 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4653 /* Partial command line, retrieve current configuration */
4655 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4657 printf("cannot get current flow ctrl parameters, return"
4658 "code = %d\n", ret);
4662 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4663 (fc_conf.mode == RTE_FC_FULL))
4665 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4666 (fc_conf.mode == RTE_FC_FULL))
4670 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4671 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4673 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4674 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4676 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4678 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4679 fc_conf.high_water = res->high_water;
4681 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4682 fc_conf.low_water = res->low_water;
4684 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4685 fc_conf.pause_time = res->pause_time;
4687 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4688 fc_conf.send_xon = res->send_xon;
4690 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4691 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4692 fc_conf.mac_ctrl_frame_fwd = 1;
4694 fc_conf.mac_ctrl_frame_fwd = 0;
4697 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4698 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4700 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4702 printf("bad flow contrl parameter, return code = %d \n", ret);
4705 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4706 struct cmd_priority_flow_ctrl_set_result {
4707 cmdline_fixed_string_t set;
4708 cmdline_fixed_string_t pfc_ctrl;
4709 cmdline_fixed_string_t rx;
4710 cmdline_fixed_string_t rx_pfc_mode;
4711 cmdline_fixed_string_t tx;
4712 cmdline_fixed_string_t tx_pfc_mode;
4713 uint32_t high_water;
4715 uint16_t pause_time;
4721 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4722 __attribute__((unused)) struct cmdline *cl,
4723 __attribute__((unused)) void *data)
4725 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4726 struct rte_eth_pfc_conf pfc_conf;
4727 int rx_fc_enable, tx_fc_enable;
4731 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4732 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4733 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4734 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4736 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4737 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4740 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4741 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4742 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4743 pfc_conf.fc.high_water = res->high_water;
4744 pfc_conf.fc.low_water = res->low_water;
4745 pfc_conf.fc.pause_time = res->pause_time;
4746 pfc_conf.priority = res->priority;
4748 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4750 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4753 cmdline_parse_token_string_t cmd_pfc_set_set =
4754 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4756 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4757 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4758 pfc_ctrl, "pfc_ctrl");
4759 cmdline_parse_token_string_t cmd_pfc_set_rx =
4760 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4762 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4763 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4764 rx_pfc_mode, "on#off");
4765 cmdline_parse_token_string_t cmd_pfc_set_tx =
4766 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4768 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4769 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4770 tx_pfc_mode, "on#off");
4771 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4772 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4773 high_water, UINT32);
4774 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4775 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4777 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4778 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4779 pause_time, UINT16);
4780 cmdline_parse_token_num_t cmd_pfc_set_priority =
4781 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4783 cmdline_parse_token_num_t cmd_pfc_set_portid =
4784 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4787 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4788 .f = cmd_priority_flow_ctrl_set_parsed,
4790 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4791 tx on|off high_water low_water pause_time priority port_id",
4793 (void *)&cmd_pfc_set_set,
4794 (void *)&cmd_pfc_set_flow_ctrl,
4795 (void *)&cmd_pfc_set_rx,
4796 (void *)&cmd_pfc_set_rx_mode,
4797 (void *)&cmd_pfc_set_tx,
4798 (void *)&cmd_pfc_set_tx_mode,
4799 (void *)&cmd_pfc_set_high_water,
4800 (void *)&cmd_pfc_set_low_water,
4801 (void *)&cmd_pfc_set_pause_time,
4802 (void *)&cmd_pfc_set_priority,
4803 (void *)&cmd_pfc_set_portid,
4808 /* *** RESET CONFIGURATION *** */
4809 struct cmd_reset_result {
4810 cmdline_fixed_string_t reset;
4811 cmdline_fixed_string_t def;
4814 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4816 __attribute__((unused)) void *data)
4818 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4819 set_def_fwd_config();
4822 cmdline_parse_token_string_t cmd_reset_set =
4823 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4824 cmdline_parse_token_string_t cmd_reset_def =
4825 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4828 cmdline_parse_inst_t cmd_reset = {
4829 .f = cmd_reset_parsed,
4831 .help_str = "set default: reset default forwarding configuration",
4833 (void *)&cmd_reset_set,
4834 (void *)&cmd_reset_def,
4839 /* *** START FORWARDING *** */
4840 struct cmd_start_result {
4841 cmdline_fixed_string_t start;
4844 cmdline_parse_token_string_t cmd_start_start =
4845 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4847 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4848 __attribute__((unused)) struct cmdline *cl,
4849 __attribute__((unused)) void *data)
4851 start_packet_forwarding(0);
4854 cmdline_parse_inst_t cmd_start = {
4855 .f = cmd_start_parsed,
4857 .help_str = "start packet forwarding",
4859 (void *)&cmd_start_start,
4864 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4865 struct cmd_start_tx_first_result {
4866 cmdline_fixed_string_t start;
4867 cmdline_fixed_string_t tx_first;
4871 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4872 __attribute__((unused)) struct cmdline *cl,
4873 __attribute__((unused)) void *data)
4875 start_packet_forwarding(1);
4878 cmdline_parse_token_string_t cmd_start_tx_first_start =
4879 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4881 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4882 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4883 tx_first, "tx_first");
4885 cmdline_parse_inst_t cmd_start_tx_first = {
4886 .f = cmd_start_tx_first_parsed,
4888 .help_str = "start packet forwarding, after sending 1 burst of packets",
4890 (void *)&cmd_start_tx_first_start,
4891 (void *)&cmd_start_tx_first_tx_first,
4896 /* *** SET LINK UP *** */
4897 struct cmd_set_link_up_result {
4898 cmdline_fixed_string_t set;
4899 cmdline_fixed_string_t link_up;
4900 cmdline_fixed_string_t port;
4904 cmdline_parse_token_string_t cmd_set_link_up_set =
4905 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4906 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4907 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4909 cmdline_parse_token_string_t cmd_set_link_up_port =
4910 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4911 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4912 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4914 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4915 __attribute__((unused)) struct cmdline *cl,
4916 __attribute__((unused)) void *data)
4918 struct cmd_set_link_up_result *res = parsed_result;
4919 dev_set_link_up(res->port_id);
4922 cmdline_parse_inst_t cmd_set_link_up = {
4923 .f = cmd_set_link_up_parsed,
4925 .help_str = "set link-up port (port id)",
4927 (void *)&cmd_set_link_up_set,
4928 (void *)&cmd_set_link_up_link_up,
4929 (void *)&cmd_set_link_up_port,
4930 (void *)&cmd_set_link_up_port_id,
4935 /* *** SET LINK DOWN *** */
4936 struct cmd_set_link_down_result {
4937 cmdline_fixed_string_t set;
4938 cmdline_fixed_string_t link_down;
4939 cmdline_fixed_string_t port;
4943 cmdline_parse_token_string_t cmd_set_link_down_set =
4944 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4945 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4946 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4948 cmdline_parse_token_string_t cmd_set_link_down_port =
4949 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4950 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4951 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4953 static void cmd_set_link_down_parsed(
4954 __attribute__((unused)) void *parsed_result,
4955 __attribute__((unused)) struct cmdline *cl,
4956 __attribute__((unused)) void *data)
4958 struct cmd_set_link_down_result *res = parsed_result;
4959 dev_set_link_down(res->port_id);
4962 cmdline_parse_inst_t cmd_set_link_down = {
4963 .f = cmd_set_link_down_parsed,
4965 .help_str = "set link-down port (port id)",
4967 (void *)&cmd_set_link_down_set,
4968 (void *)&cmd_set_link_down_link_down,
4969 (void *)&cmd_set_link_down_port,
4970 (void *)&cmd_set_link_down_port_id,
4975 /* *** SHOW CFG *** */
4976 struct cmd_showcfg_result {
4977 cmdline_fixed_string_t show;
4978 cmdline_fixed_string_t cfg;
4979 cmdline_fixed_string_t what;
4982 static void cmd_showcfg_parsed(void *parsed_result,
4983 __attribute__((unused)) struct cmdline *cl,
4984 __attribute__((unused)) void *data)
4986 struct cmd_showcfg_result *res = parsed_result;
4987 if (!strcmp(res->what, "rxtx"))
4988 rxtx_config_display();
4989 else if (!strcmp(res->what, "cores"))
4990 fwd_lcores_config_display();
4991 else if (!strcmp(res->what, "fwd"))
4992 fwd_config_display();
4995 cmdline_parse_token_string_t cmd_showcfg_show =
4996 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4997 cmdline_parse_token_string_t cmd_showcfg_port =
4998 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4999 cmdline_parse_token_string_t cmd_showcfg_what =
5000 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5003 cmdline_parse_inst_t cmd_showcfg = {
5004 .f = cmd_showcfg_parsed,
5006 .help_str = "show config rxtx|cores|fwd",
5008 (void *)&cmd_showcfg_show,
5009 (void *)&cmd_showcfg_port,
5010 (void *)&cmd_showcfg_what,
5015 /* *** SHOW ALL PORT INFO *** */
5016 struct cmd_showportall_result {
5017 cmdline_fixed_string_t show;
5018 cmdline_fixed_string_t port;
5019 cmdline_fixed_string_t what;
5020 cmdline_fixed_string_t all;
5023 static void cmd_showportall_parsed(void *parsed_result,
5024 __attribute__((unused)) struct cmdline *cl,
5025 __attribute__((unused)) void *data)
5029 struct cmd_showportall_result *res = parsed_result;
5030 if (!strcmp(res->show, "clear")) {
5031 if (!strcmp(res->what, "stats"))
5032 for (i = 0; i < nb_ports; i++)
5034 else if (!strcmp(res->what, "xstats"))
5035 for (i = 0; i < nb_ports; i++)
5036 nic_xstats_clear(i);
5037 } else if (!strcmp(res->what, "info"))
5038 for (i = 0; i < nb_ports; i++)
5039 port_infos_display(i);
5040 else if (!strcmp(res->what, "stats"))
5041 for (i = 0; i < nb_ports; i++)
5042 nic_stats_display(i);
5043 else if (!strcmp(res->what, "xstats"))
5044 for (i = 0; i < nb_ports; i++)
5045 nic_xstats_display(i);
5046 else if (!strcmp(res->what, "fdir"))
5047 for (i = 0; i < nb_ports; i++)
5049 else if (!strcmp(res->what, "stat_qmap"))
5050 for (i = 0; i < nb_ports; i++)
5051 nic_stats_mapping_display(i);
5054 cmdline_parse_token_string_t cmd_showportall_show =
5055 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5057 cmdline_parse_token_string_t cmd_showportall_port =
5058 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5059 cmdline_parse_token_string_t cmd_showportall_what =
5060 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5061 "info#stats#xstats#fdir#stat_qmap");
5062 cmdline_parse_token_string_t cmd_showportall_all =
5063 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5064 cmdline_parse_inst_t cmd_showportall = {
5065 .f = cmd_showportall_parsed,
5067 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5069 (void *)&cmd_showportall_show,
5070 (void *)&cmd_showportall_port,
5071 (void *)&cmd_showportall_what,
5072 (void *)&cmd_showportall_all,
5077 /* *** SHOW PORT INFO *** */
5078 struct cmd_showport_result {
5079 cmdline_fixed_string_t show;
5080 cmdline_fixed_string_t port;
5081 cmdline_fixed_string_t what;
5085 static void cmd_showport_parsed(void *parsed_result,
5086 __attribute__((unused)) struct cmdline *cl,
5087 __attribute__((unused)) void *data)
5089 struct cmd_showport_result *res = parsed_result;
5090 if (!strcmp(res->show, "clear")) {
5091 if (!strcmp(res->what, "stats"))
5092 nic_stats_clear(res->portnum);
5093 else if (!strcmp(res->what, "xstats"))
5094 nic_xstats_clear(res->portnum);
5095 } else if (!strcmp(res->what, "info"))
5096 port_infos_display(res->portnum);
5097 else if (!strcmp(res->what, "stats"))
5098 nic_stats_display(res->portnum);
5099 else if (!strcmp(res->what, "xstats"))
5100 nic_xstats_display(res->portnum);
5101 else if (!strcmp(res->what, "fdir"))
5102 fdir_get_infos(res->portnum);
5103 else if (!strcmp(res->what, "stat_qmap"))
5104 nic_stats_mapping_display(res->portnum);
5107 cmdline_parse_token_string_t cmd_showport_show =
5108 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5110 cmdline_parse_token_string_t cmd_showport_port =
5111 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5112 cmdline_parse_token_string_t cmd_showport_what =
5113 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5114 "info#stats#xstats#fdir#stat_qmap");
5115 cmdline_parse_token_num_t cmd_showport_portnum =
5116 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5118 cmdline_parse_inst_t cmd_showport = {
5119 .f = cmd_showport_parsed,
5121 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5123 (void *)&cmd_showport_show,
5124 (void *)&cmd_showport_port,
5125 (void *)&cmd_showport_what,
5126 (void *)&cmd_showport_portnum,
5131 /* *** READ PORT REGISTER *** */
5132 struct cmd_read_reg_result {
5133 cmdline_fixed_string_t read;
5134 cmdline_fixed_string_t reg;
5140 cmd_read_reg_parsed(void *parsed_result,
5141 __attribute__((unused)) struct cmdline *cl,
5142 __attribute__((unused)) void *data)
5144 struct cmd_read_reg_result *res = parsed_result;
5145 port_reg_display(res->port_id, res->reg_off);
5148 cmdline_parse_token_string_t cmd_read_reg_read =
5149 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5150 cmdline_parse_token_string_t cmd_read_reg_reg =
5151 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5152 cmdline_parse_token_num_t cmd_read_reg_port_id =
5153 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5154 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5155 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5157 cmdline_parse_inst_t cmd_read_reg = {
5158 .f = cmd_read_reg_parsed,
5160 .help_str = "read reg port_id reg_off",
5162 (void *)&cmd_read_reg_read,
5163 (void *)&cmd_read_reg_reg,
5164 (void *)&cmd_read_reg_port_id,
5165 (void *)&cmd_read_reg_reg_off,
5170 /* *** READ PORT REGISTER BIT FIELD *** */
5171 struct cmd_read_reg_bit_field_result {
5172 cmdline_fixed_string_t read;
5173 cmdline_fixed_string_t regfield;
5181 cmd_read_reg_bit_field_parsed(void *parsed_result,
5182 __attribute__((unused)) struct cmdline *cl,
5183 __attribute__((unused)) void *data)
5185 struct cmd_read_reg_bit_field_result *res = parsed_result;
5186 port_reg_bit_field_display(res->port_id, res->reg_off,
5187 res->bit1_pos, res->bit2_pos);
5190 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5191 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5193 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5194 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5195 regfield, "regfield");
5196 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5197 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5199 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5200 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5202 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5203 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5205 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5206 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5209 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5210 .f = cmd_read_reg_bit_field_parsed,
5212 .help_str = "read regfield port_id reg_off bit_x bit_y "
5213 "(read register bit field between bit_x and bit_y included)",
5215 (void *)&cmd_read_reg_bit_field_read,
5216 (void *)&cmd_read_reg_bit_field_regfield,
5217 (void *)&cmd_read_reg_bit_field_port_id,
5218 (void *)&cmd_read_reg_bit_field_reg_off,
5219 (void *)&cmd_read_reg_bit_field_bit1_pos,
5220 (void *)&cmd_read_reg_bit_field_bit2_pos,
5225 /* *** READ PORT REGISTER BIT *** */
5226 struct cmd_read_reg_bit_result {
5227 cmdline_fixed_string_t read;
5228 cmdline_fixed_string_t regbit;
5235 cmd_read_reg_bit_parsed(void *parsed_result,
5236 __attribute__((unused)) struct cmdline *cl,
5237 __attribute__((unused)) void *data)
5239 struct cmd_read_reg_bit_result *res = parsed_result;
5240 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5243 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5244 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5245 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5246 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5248 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5249 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5250 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5251 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5252 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5253 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5255 cmdline_parse_inst_t cmd_read_reg_bit = {
5256 .f = cmd_read_reg_bit_parsed,
5258 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5260 (void *)&cmd_read_reg_bit_read,
5261 (void *)&cmd_read_reg_bit_regbit,
5262 (void *)&cmd_read_reg_bit_port_id,
5263 (void *)&cmd_read_reg_bit_reg_off,
5264 (void *)&cmd_read_reg_bit_bit_pos,
5269 /* *** WRITE PORT REGISTER *** */
5270 struct cmd_write_reg_result {
5271 cmdline_fixed_string_t write;
5272 cmdline_fixed_string_t reg;
5279 cmd_write_reg_parsed(void *parsed_result,
5280 __attribute__((unused)) struct cmdline *cl,
5281 __attribute__((unused)) void *data)
5283 struct cmd_write_reg_result *res = parsed_result;
5284 port_reg_set(res->port_id, res->reg_off, res->value);
5287 cmdline_parse_token_string_t cmd_write_reg_write =
5288 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5289 cmdline_parse_token_string_t cmd_write_reg_reg =
5290 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5291 cmdline_parse_token_num_t cmd_write_reg_port_id =
5292 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5293 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5294 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5295 cmdline_parse_token_num_t cmd_write_reg_value =
5296 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5298 cmdline_parse_inst_t cmd_write_reg = {
5299 .f = cmd_write_reg_parsed,
5301 .help_str = "write reg port_id reg_off reg_value",
5303 (void *)&cmd_write_reg_write,
5304 (void *)&cmd_write_reg_reg,
5305 (void *)&cmd_write_reg_port_id,
5306 (void *)&cmd_write_reg_reg_off,
5307 (void *)&cmd_write_reg_value,
5312 /* *** WRITE PORT REGISTER BIT FIELD *** */
5313 struct cmd_write_reg_bit_field_result {
5314 cmdline_fixed_string_t write;
5315 cmdline_fixed_string_t regfield;
5324 cmd_write_reg_bit_field_parsed(void *parsed_result,
5325 __attribute__((unused)) struct cmdline *cl,
5326 __attribute__((unused)) void *data)
5328 struct cmd_write_reg_bit_field_result *res = parsed_result;
5329 port_reg_bit_field_set(res->port_id, res->reg_off,
5330 res->bit1_pos, res->bit2_pos, res->value);
5333 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5334 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5336 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5337 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5338 regfield, "regfield");
5339 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5340 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5342 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5343 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5345 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5346 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5348 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5349 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5351 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5352 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5355 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5356 .f = cmd_write_reg_bit_field_parsed,
5358 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5359 "(set register bit field between bit_x and bit_y included)",
5361 (void *)&cmd_write_reg_bit_field_write,
5362 (void *)&cmd_write_reg_bit_field_regfield,
5363 (void *)&cmd_write_reg_bit_field_port_id,
5364 (void *)&cmd_write_reg_bit_field_reg_off,
5365 (void *)&cmd_write_reg_bit_field_bit1_pos,
5366 (void *)&cmd_write_reg_bit_field_bit2_pos,
5367 (void *)&cmd_write_reg_bit_field_value,
5372 /* *** WRITE PORT REGISTER BIT *** */
5373 struct cmd_write_reg_bit_result {
5374 cmdline_fixed_string_t write;
5375 cmdline_fixed_string_t regbit;
5383 cmd_write_reg_bit_parsed(void *parsed_result,
5384 __attribute__((unused)) struct cmdline *cl,
5385 __attribute__((unused)) void *data)
5387 struct cmd_write_reg_bit_result *res = parsed_result;
5388 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5391 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5392 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5394 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5395 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5397 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5398 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5399 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5400 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5401 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5402 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5403 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5404 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5406 cmdline_parse_inst_t cmd_write_reg_bit = {
5407 .f = cmd_write_reg_bit_parsed,
5409 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5411 (void *)&cmd_write_reg_bit_write,
5412 (void *)&cmd_write_reg_bit_regbit,
5413 (void *)&cmd_write_reg_bit_port_id,
5414 (void *)&cmd_write_reg_bit_reg_off,
5415 (void *)&cmd_write_reg_bit_bit_pos,
5416 (void *)&cmd_write_reg_bit_value,
5421 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5422 struct cmd_read_rxd_txd_result {
5423 cmdline_fixed_string_t read;
5424 cmdline_fixed_string_t rxd_txd;
5431 cmd_read_rxd_txd_parsed(void *parsed_result,
5432 __attribute__((unused)) struct cmdline *cl,
5433 __attribute__((unused)) void *data)
5435 struct cmd_read_rxd_txd_result *res = parsed_result;
5437 if (!strcmp(res->rxd_txd, "rxd"))
5438 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5439 else if (!strcmp(res->rxd_txd, "txd"))
5440 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5443 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5444 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5445 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5446 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5448 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5449 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5450 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5451 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5452 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5453 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5455 cmdline_parse_inst_t cmd_read_rxd_txd = {
5456 .f = cmd_read_rxd_txd_parsed,
5458 .help_str = "read rxd|txd port_id queue_id rxd_id",
5460 (void *)&cmd_read_rxd_txd_read,
5461 (void *)&cmd_read_rxd_txd_rxd_txd,
5462 (void *)&cmd_read_rxd_txd_port_id,
5463 (void *)&cmd_read_rxd_txd_queue_id,
5464 (void *)&cmd_read_rxd_txd_desc_id,
5470 struct cmd_quit_result {
5471 cmdline_fixed_string_t quit;
5474 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5476 __attribute__((unused)) void *data)
5482 cmdline_parse_token_string_t cmd_quit_quit =
5483 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5485 cmdline_parse_inst_t cmd_quit = {
5486 .f = cmd_quit_parsed,
5488 .help_str = "exit application",
5490 (void *)&cmd_quit_quit,
5495 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5496 struct cmd_mac_addr_result {
5497 cmdline_fixed_string_t mac_addr_cmd;
5498 cmdline_fixed_string_t what;
5500 struct ether_addr address;
5503 static void cmd_mac_addr_parsed(void *parsed_result,
5504 __attribute__((unused)) struct cmdline *cl,
5505 __attribute__((unused)) void *data)
5507 struct cmd_mac_addr_result *res = parsed_result;
5510 if (strcmp(res->what, "add") == 0)
5511 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5513 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5515 /* check the return value and print it if is < 0 */
5517 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5521 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5522 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5524 cmdline_parse_token_string_t cmd_mac_addr_what =
5525 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5527 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5528 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5529 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5530 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5532 cmdline_parse_inst_t cmd_mac_addr = {
5533 .f = cmd_mac_addr_parsed,
5535 .help_str = "mac_addr add|remove X <address>: "
5536 "add/remove MAC address on port X",
5538 (void *)&cmd_mac_addr_cmd,
5539 (void *)&cmd_mac_addr_what,
5540 (void *)&cmd_mac_addr_portnum,
5541 (void *)&cmd_mac_addr_addr,
5547 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5548 struct cmd_set_qmap_result {
5549 cmdline_fixed_string_t set;
5550 cmdline_fixed_string_t qmap;
5551 cmdline_fixed_string_t what;
5558 cmd_set_qmap_parsed(void *parsed_result,
5559 __attribute__((unused)) struct cmdline *cl,
5560 __attribute__((unused)) void *data)
5562 struct cmd_set_qmap_result *res = parsed_result;
5563 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5565 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5568 cmdline_parse_token_string_t cmd_setqmap_set =
5569 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5571 cmdline_parse_token_string_t cmd_setqmap_qmap =
5572 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5574 cmdline_parse_token_string_t cmd_setqmap_what =
5575 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5577 cmdline_parse_token_num_t cmd_setqmap_portid =
5578 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5580 cmdline_parse_token_num_t cmd_setqmap_queueid =
5581 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5583 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5584 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5587 cmdline_parse_inst_t cmd_set_qmap = {
5588 .f = cmd_set_qmap_parsed,
5590 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5592 (void *)&cmd_setqmap_set,
5593 (void *)&cmd_setqmap_qmap,
5594 (void *)&cmd_setqmap_what,
5595 (void *)&cmd_setqmap_portid,
5596 (void *)&cmd_setqmap_queueid,
5597 (void *)&cmd_setqmap_mapvalue,
5602 /* *** CONFIGURE UNICAST HASH TABLE *** */
5603 struct cmd_set_uc_hash_table {
5604 cmdline_fixed_string_t set;
5605 cmdline_fixed_string_t port;
5607 cmdline_fixed_string_t what;
5608 struct ether_addr address;
5609 cmdline_fixed_string_t mode;
5613 cmd_set_uc_hash_parsed(void *parsed_result,
5614 __attribute__((unused)) struct cmdline *cl,
5615 __attribute__((unused)) void *data)
5618 struct cmd_set_uc_hash_table *res = parsed_result;
5620 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5622 if (strcmp(res->what, "uta") == 0)
5623 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5624 &res->address,(uint8_t)is_on);
5626 printf("bad unicast hash table parameter, return code = %d \n", ret);
5630 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5631 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5633 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5634 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5636 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5637 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5639 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5640 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5642 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5643 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5645 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5646 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5649 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5650 .f = cmd_set_uc_hash_parsed,
5652 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5654 (void *)&cmd_set_uc_hash_set,
5655 (void *)&cmd_set_uc_hash_port,
5656 (void *)&cmd_set_uc_hash_portid,
5657 (void *)&cmd_set_uc_hash_what,
5658 (void *)&cmd_set_uc_hash_mac,
5659 (void *)&cmd_set_uc_hash_mode,
5664 struct cmd_set_uc_all_hash_table {
5665 cmdline_fixed_string_t set;
5666 cmdline_fixed_string_t port;
5668 cmdline_fixed_string_t what;
5669 cmdline_fixed_string_t value;
5670 cmdline_fixed_string_t mode;
5674 cmd_set_uc_all_hash_parsed(void *parsed_result,
5675 __attribute__((unused)) struct cmdline *cl,
5676 __attribute__((unused)) void *data)
5679 struct cmd_set_uc_all_hash_table *res = parsed_result;
5681 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5683 if ((strcmp(res->what, "uta") == 0) &&
5684 (strcmp(res->value, "all") == 0))
5685 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5687 printf("bad unicast hash table parameter,"
5688 "return code = %d \n", ret);
5691 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5692 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5694 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5695 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5697 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5698 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5700 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5701 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5703 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5706 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5707 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5710 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5711 .f = cmd_set_uc_all_hash_parsed,
5713 .help_str = "set port X uta all on|off (X = port number)",
5715 (void *)&cmd_set_uc_all_hash_set,
5716 (void *)&cmd_set_uc_all_hash_port,
5717 (void *)&cmd_set_uc_all_hash_portid,
5718 (void *)&cmd_set_uc_all_hash_what,
5719 (void *)&cmd_set_uc_all_hash_value,
5720 (void *)&cmd_set_uc_all_hash_mode,
5725 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5726 struct cmd_set_vf_macvlan_filter {
5727 cmdline_fixed_string_t set;
5728 cmdline_fixed_string_t port;
5730 cmdline_fixed_string_t vf;
5732 struct ether_addr address;
5733 cmdline_fixed_string_t filter_type;
5734 cmdline_fixed_string_t mode;
5738 cmd_set_vf_macvlan_parsed(void *parsed_result,
5739 __attribute__((unused)) struct cmdline *cl,
5740 __attribute__((unused)) void *data)
5743 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5744 struct rte_eth_mac_filter filter;
5746 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5748 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5750 /* set VF MAC filter */
5754 filter.dst_id = res->vf_id;
5756 if (!strcmp(res->filter_type, "exact-mac"))
5757 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5758 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5759 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5760 else if (!strcmp(res->filter_type, "hashmac"))
5761 filter.filter_type = RTE_MAC_HASH_MATCH;
5762 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5763 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5765 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5768 ret = rte_eth_dev_filter_ctrl(res->port_id,
5769 RTE_ETH_FILTER_MACVLAN,
5773 ret = rte_eth_dev_filter_ctrl(res->port_id,
5774 RTE_ETH_FILTER_MACVLAN,
5775 RTE_ETH_FILTER_DELETE,
5779 printf("bad set MAC hash parameter, return code = %d\n", ret);
5783 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5784 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5786 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5787 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5789 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5790 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5792 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5793 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5795 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5796 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5798 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5799 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5801 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5802 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5803 filter_type, "exact-mac#exact-mac-vlan"
5804 "#hashmac#hashmac-vlan");
5805 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5806 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5809 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5810 .f = cmd_set_vf_macvlan_parsed,
5812 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5813 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5815 "exact match rule:exact match of MAC or MAC and VLAN; "
5816 "hash match rule: hash match of MAC and exact match "
5819 (void *)&cmd_set_vf_macvlan_set,
5820 (void *)&cmd_set_vf_macvlan_port,
5821 (void *)&cmd_set_vf_macvlan_portid,
5822 (void *)&cmd_set_vf_macvlan_vf,
5823 (void *)&cmd_set_vf_macvlan_vf_id,
5824 (void *)&cmd_set_vf_macvlan_mac,
5825 (void *)&cmd_set_vf_macvlan_filter_type,
5826 (void *)&cmd_set_vf_macvlan_mode,
5831 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5832 struct cmd_set_vf_traffic {
5833 cmdline_fixed_string_t set;
5834 cmdline_fixed_string_t port;
5836 cmdline_fixed_string_t vf;
5838 cmdline_fixed_string_t what;
5839 cmdline_fixed_string_t mode;
5843 cmd_set_vf_traffic_parsed(void *parsed_result,
5844 __attribute__((unused)) struct cmdline *cl,
5845 __attribute__((unused)) void *data)
5847 struct cmd_set_vf_traffic *res = parsed_result;
5848 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5849 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5851 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5854 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5855 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5857 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5858 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5860 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5861 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5863 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5864 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5866 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5867 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5869 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5870 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5872 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5873 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5876 cmdline_parse_inst_t cmd_set_vf_traffic = {
5877 .f = cmd_set_vf_traffic_parsed,
5879 .help_str = "set port X vf Y rx|tx on|off"
5880 "(X = port number,Y = vf id)",
5882 (void *)&cmd_setvf_traffic_set,
5883 (void *)&cmd_setvf_traffic_port,
5884 (void *)&cmd_setvf_traffic_portid,
5885 (void *)&cmd_setvf_traffic_vf,
5886 (void *)&cmd_setvf_traffic_vfid,
5887 (void *)&cmd_setvf_traffic_what,
5888 (void *)&cmd_setvf_traffic_mode,
5893 /* *** CONFIGURE VF RECEIVE MODE *** */
5894 struct cmd_set_vf_rxmode {
5895 cmdline_fixed_string_t set;
5896 cmdline_fixed_string_t port;
5898 cmdline_fixed_string_t vf;
5900 cmdline_fixed_string_t what;
5901 cmdline_fixed_string_t mode;
5902 cmdline_fixed_string_t on;
5906 cmd_set_vf_rxmode_parsed(void *parsed_result,
5907 __attribute__((unused)) struct cmdline *cl,
5908 __attribute__((unused)) void *data)
5911 uint16_t rx_mode = 0;
5912 struct cmd_set_vf_rxmode *res = parsed_result;
5914 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5915 if (!strcmp(res->what,"rxmode")) {
5916 if (!strcmp(res->mode, "AUPE"))
5917 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5918 else if (!strcmp(res->mode, "ROPE"))
5919 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5920 else if (!strcmp(res->mode, "BAM"))
5921 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5922 else if (!strncmp(res->mode, "MPE",3))
5923 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5926 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5928 printf("bad VF receive mode parameter, return code = %d \n",
5932 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5933 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5935 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5936 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5938 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5939 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5941 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5942 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5944 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5945 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5947 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5948 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5950 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5951 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5952 mode, "AUPE#ROPE#BAM#MPE");
5953 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5954 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5957 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5958 .f = cmd_set_vf_rxmode_parsed,
5960 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5962 (void *)&cmd_set_vf_rxmode_set,
5963 (void *)&cmd_set_vf_rxmode_port,
5964 (void *)&cmd_set_vf_rxmode_portid,
5965 (void *)&cmd_set_vf_rxmode_vf,
5966 (void *)&cmd_set_vf_rxmode_vfid,
5967 (void *)&cmd_set_vf_rxmode_what,
5968 (void *)&cmd_set_vf_rxmode_mode,
5969 (void *)&cmd_set_vf_rxmode_on,
5974 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5975 struct cmd_vf_mac_addr_result {
5976 cmdline_fixed_string_t mac_addr_cmd;
5977 cmdline_fixed_string_t what;
5978 cmdline_fixed_string_t port;
5980 cmdline_fixed_string_t vf;
5982 struct ether_addr address;
5985 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5986 __attribute__((unused)) struct cmdline *cl,
5987 __attribute__((unused)) void *data)
5989 struct cmd_vf_mac_addr_result *res = parsed_result;
5992 if (strcmp(res->what, "add") == 0)
5993 ret = rte_eth_dev_mac_addr_add(res->port_num,
5994 &res->address, res->vf_num);
5996 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6000 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6001 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6002 mac_addr_cmd,"mac_addr");
6003 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6004 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6006 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6007 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6009 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6010 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6012 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6013 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6015 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6016 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6018 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6019 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6022 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6023 .f = cmd_vf_mac_addr_parsed,
6025 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6026 "Y = VF number)add MAC address filtering for a VF on port X",
6028 (void *)&cmd_vf_mac_addr_cmd,
6029 (void *)&cmd_vf_mac_addr_what,
6030 (void *)&cmd_vf_mac_addr_port,
6031 (void *)&cmd_vf_mac_addr_portnum,
6032 (void *)&cmd_vf_mac_addr_vf,
6033 (void *)&cmd_vf_mac_addr_vfnum,
6034 (void *)&cmd_vf_mac_addr_addr,
6039 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6040 struct cmd_vf_rx_vlan_filter {
6041 cmdline_fixed_string_t rx_vlan;
6042 cmdline_fixed_string_t what;
6044 cmdline_fixed_string_t port;
6046 cmdline_fixed_string_t vf;
6051 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6052 __attribute__((unused)) struct cmdline *cl,
6053 __attribute__((unused)) void *data)
6055 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6057 if (!strcmp(res->what, "add"))
6058 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6060 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6063 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6064 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6065 rx_vlan, "rx_vlan");
6066 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6067 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6069 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6070 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6072 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6073 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6075 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6076 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6078 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6079 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6081 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6082 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6085 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6086 .f = cmd_vf_rx_vlan_filter_parsed,
6088 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6089 "Y = port number,Z = hexadecimal VF mask)",
6091 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6092 (void *)&cmd_vf_rx_vlan_filter_what,
6093 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6094 (void *)&cmd_vf_rx_vlan_filter_port,
6095 (void *)&cmd_vf_rx_vlan_filter_portid,
6096 (void *)&cmd_vf_rx_vlan_filter_vf,
6097 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6102 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6103 struct cmd_queue_rate_limit_result {
6104 cmdline_fixed_string_t set;
6105 cmdline_fixed_string_t port;
6107 cmdline_fixed_string_t queue;
6109 cmdline_fixed_string_t rate;
6113 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6114 __attribute__((unused)) struct cmdline *cl,
6115 __attribute__((unused)) void *data)
6117 struct cmd_queue_rate_limit_result *res = parsed_result;
6120 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6121 && (strcmp(res->queue, "queue") == 0)
6122 && (strcmp(res->rate, "rate") == 0))
6123 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6126 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6130 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6131 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6133 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6134 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6136 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6137 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6139 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6140 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6142 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6143 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6145 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6146 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6148 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6149 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6152 cmdline_parse_inst_t cmd_queue_rate_limit = {
6153 .f = cmd_queue_rate_limit_parsed,
6155 .help_str = "set port X queue Y rate Z:(X = port number,"
6156 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6158 (void *)&cmd_queue_rate_limit_set,
6159 (void *)&cmd_queue_rate_limit_port,
6160 (void *)&cmd_queue_rate_limit_portnum,
6161 (void *)&cmd_queue_rate_limit_queue,
6162 (void *)&cmd_queue_rate_limit_queuenum,
6163 (void *)&cmd_queue_rate_limit_rate,
6164 (void *)&cmd_queue_rate_limit_ratenum,
6169 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6170 struct cmd_vf_rate_limit_result {
6171 cmdline_fixed_string_t set;
6172 cmdline_fixed_string_t port;
6174 cmdline_fixed_string_t vf;
6176 cmdline_fixed_string_t rate;
6178 cmdline_fixed_string_t q_msk;
6182 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6183 __attribute__((unused)) struct cmdline *cl,
6184 __attribute__((unused)) void *data)
6186 struct cmd_vf_rate_limit_result *res = parsed_result;
6189 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6190 && (strcmp(res->vf, "vf") == 0)
6191 && (strcmp(res->rate, "rate") == 0)
6192 && (strcmp(res->q_msk, "queue_mask") == 0))
6193 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6194 res->rate_num, res->q_msk_val);
6196 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6200 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6201 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6203 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6204 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6206 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6207 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6209 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6210 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6212 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6213 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6215 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6216 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6218 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6219 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6221 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6222 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6223 q_msk, "queue_mask");
6224 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6225 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6228 cmdline_parse_inst_t cmd_vf_rate_limit = {
6229 .f = cmd_vf_rate_limit_parsed,
6231 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6232 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6233 "for queues of VF on port X",
6235 (void *)&cmd_vf_rate_limit_set,
6236 (void *)&cmd_vf_rate_limit_port,
6237 (void *)&cmd_vf_rate_limit_portnum,
6238 (void *)&cmd_vf_rate_limit_vf,
6239 (void *)&cmd_vf_rate_limit_vfnum,
6240 (void *)&cmd_vf_rate_limit_rate,
6241 (void *)&cmd_vf_rate_limit_ratenum,
6242 (void *)&cmd_vf_rate_limit_q_msk,
6243 (void *)&cmd_vf_rate_limit_q_msk_val,
6248 /* *** ADD TUNNEL FILTER OF A PORT *** */
6249 struct cmd_tunnel_filter_result {
6250 cmdline_fixed_string_t cmd;
6251 cmdline_fixed_string_t what;
6253 struct ether_addr outer_mac;
6254 struct ether_addr inner_mac;
6255 cmdline_ipaddr_t ip_value;
6256 uint16_t inner_vlan;
6257 cmdline_fixed_string_t tunnel_type;
6258 cmdline_fixed_string_t filter_type;
6264 cmd_tunnel_filter_parsed(void *parsed_result,
6265 __attribute__((unused)) struct cmdline *cl,
6266 __attribute__((unused)) void *data)
6268 struct cmd_tunnel_filter_result *res = parsed_result;
6269 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6272 tunnel_filter_conf.outer_mac = &res->outer_mac;
6273 tunnel_filter_conf.inner_mac = &res->inner_mac;
6274 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6276 if (res->ip_value.family == AF_INET) {
6277 tunnel_filter_conf.ip_addr.ipv4_addr =
6278 res->ip_value.addr.ipv4.s_addr;
6279 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6281 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6282 &(res->ip_value.addr.ipv6),
6283 sizeof(struct in6_addr));
6284 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6287 if (!strcmp(res->filter_type, "imac-ivlan"))
6288 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6289 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6290 tunnel_filter_conf.filter_type =
6291 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6292 else if (!strcmp(res->filter_type, "imac-tenid"))
6293 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6294 else if (!strcmp(res->filter_type, "imac"))
6295 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6296 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6297 tunnel_filter_conf.filter_type =
6298 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6300 printf("The filter type is not supported");
6304 if (!strcmp(res->tunnel_type, "vxlan"))
6305 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6307 printf("Only VXLAN is supported now.\n");
6311 tunnel_filter_conf.tenant_id = res->tenant_id;
6312 tunnel_filter_conf.queue_id = res->queue_num;
6313 if (!strcmp(res->what, "add"))
6314 ret = rte_eth_dev_filter_ctrl(res->port_id,
6315 RTE_ETH_FILTER_TUNNEL,
6317 &tunnel_filter_conf);
6319 ret = rte_eth_dev_filter_ctrl(res->port_id,
6320 RTE_ETH_FILTER_TUNNEL,
6321 RTE_ETH_FILTER_DELETE,
6322 &tunnel_filter_conf);
6324 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6328 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6329 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6330 cmd, "tunnel_filter");
6331 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6332 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6334 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6335 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6337 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6338 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6340 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6341 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6343 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6344 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6345 inner_vlan, UINT16);
6346 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6347 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6349 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6350 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6351 tunnel_type, "vxlan");
6353 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6354 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6355 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6356 "imac#omac-imac-tenid");
6357 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6358 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6360 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6361 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6364 cmdline_parse_inst_t cmd_tunnel_filter = {
6365 .f = cmd_tunnel_filter_parsed,
6367 .help_str = "add/rm tunnel filter of a port: "
6368 "tunnel_filter add port_id outer_mac inner_mac ip "
6369 "inner_vlan tunnel_type(vxlan) filter_type "
6370 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6371 "imac|omac-imac-tenid) "
6372 "tenant_id queue_num",
6374 (void *)&cmd_tunnel_filter_cmd,
6375 (void *)&cmd_tunnel_filter_what,
6376 (void *)&cmd_tunnel_filter_port_id,
6377 (void *)&cmd_tunnel_filter_outer_mac,
6378 (void *)&cmd_tunnel_filter_inner_mac,
6379 (void *)&cmd_tunnel_filter_ip_value,
6380 (void *)&cmd_tunnel_filter_innner_vlan,
6381 (void *)&cmd_tunnel_filter_tunnel_type,
6382 (void *)&cmd_tunnel_filter_filter_type,
6383 (void *)&cmd_tunnel_filter_tenant_id,
6384 (void *)&cmd_tunnel_filter_queue_num,
6389 /* *** CONFIGURE TUNNEL UDP PORT *** */
6390 struct cmd_tunnel_udp_config {
6391 cmdline_fixed_string_t cmd;
6392 cmdline_fixed_string_t what;
6398 cmd_tunnel_udp_config_parsed(void *parsed_result,
6399 __attribute__((unused)) struct cmdline *cl,
6400 __attribute__((unused)) void *data)
6402 struct cmd_tunnel_udp_config *res = parsed_result;
6403 struct rte_eth_udp_tunnel tunnel_udp;
6406 tunnel_udp.udp_port = res->udp_port;
6408 if (!strcmp(res->cmd, "rx_vxlan_port"))
6409 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6411 if (!strcmp(res->what, "add"))
6412 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6414 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6417 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6420 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6421 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6422 cmd, "rx_vxlan_port");
6423 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6424 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6426 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6427 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6429 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6430 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6433 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6434 .f = cmd_tunnel_udp_config_parsed,
6436 .help_str = "add/rm an tunneling UDP port filter: "
6437 "rx_vxlan_port add udp_port port_id",
6439 (void *)&cmd_tunnel_udp_config_cmd,
6440 (void *)&cmd_tunnel_udp_config_what,
6441 (void *)&cmd_tunnel_udp_config_udp_port,
6442 (void *)&cmd_tunnel_udp_config_port_id,
6447 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6448 struct cmd_set_mirror_mask_result {
6449 cmdline_fixed_string_t set;
6450 cmdline_fixed_string_t port;
6452 cmdline_fixed_string_t mirror;
6454 cmdline_fixed_string_t what;
6455 cmdline_fixed_string_t value;
6456 cmdline_fixed_string_t dstpool;
6458 cmdline_fixed_string_t on;
6461 cmdline_parse_token_string_t cmd_mirror_mask_set =
6462 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6464 cmdline_parse_token_string_t cmd_mirror_mask_port =
6465 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6467 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6468 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6470 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6471 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6472 mirror, "mirror-rule");
6473 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6474 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6476 cmdline_parse_token_string_t cmd_mirror_mask_what =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6478 what, "pool-mirror#vlan-mirror");
6479 cmdline_parse_token_string_t cmd_mirror_mask_value =
6480 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6482 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6483 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6484 dstpool, "dst-pool");
6485 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6486 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6488 cmdline_parse_token_string_t cmd_mirror_mask_on =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6493 cmd_set_mirror_mask_parsed(void *parsed_result,
6494 __attribute__((unused)) struct cmdline *cl,
6495 __attribute__((unused)) void *data)
6498 struct cmd_set_mirror_mask_result *res = parsed_result;
6499 struct rte_eth_vmdq_mirror_conf mr_conf;
6501 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6503 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6505 mr_conf.dst_pool = res->dstpool_id;
6507 if (!strcmp(res->what, "pool-mirror")) {
6508 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6509 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6510 } else if(!strcmp(res->what, "vlan-mirror")) {
6511 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6512 nb_item = parse_item_list(res->value, "core",
6513 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6517 for(i=0; i < nb_item; i++) {
6518 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6519 printf("Invalid vlan_id: must be < 4096\n");
6523 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6524 mr_conf.vlan.vlan_mask |= 1ULL << i;
6528 if(!strcmp(res->on, "on"))
6529 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6532 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6535 printf("mirror rule add error: (%s)\n", strerror(-ret));
6538 cmdline_parse_inst_t cmd_set_mirror_mask = {
6539 .f = cmd_set_mirror_mask_parsed,
6541 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6542 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6544 (void *)&cmd_mirror_mask_set,
6545 (void *)&cmd_mirror_mask_port,
6546 (void *)&cmd_mirror_mask_portid,
6547 (void *)&cmd_mirror_mask_mirror,
6548 (void *)&cmd_mirror_mask_ruleid,
6549 (void *)&cmd_mirror_mask_what,
6550 (void *)&cmd_mirror_mask_value,
6551 (void *)&cmd_mirror_mask_dstpool,
6552 (void *)&cmd_mirror_mask_poolid,
6553 (void *)&cmd_mirror_mask_on,
6558 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6559 struct cmd_set_mirror_link_result {
6560 cmdline_fixed_string_t set;
6561 cmdline_fixed_string_t port;
6563 cmdline_fixed_string_t mirror;
6565 cmdline_fixed_string_t what;
6566 cmdline_fixed_string_t dstpool;
6568 cmdline_fixed_string_t on;
6571 cmdline_parse_token_string_t cmd_mirror_link_set =
6572 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6574 cmdline_parse_token_string_t cmd_mirror_link_port =
6575 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6577 cmdline_parse_token_num_t cmd_mirror_link_portid =
6578 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6580 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6581 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6582 mirror, "mirror-rule");
6583 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6584 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6586 cmdline_parse_token_string_t cmd_mirror_link_what =
6587 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6588 what, "uplink-mirror#downlink-mirror");
6589 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6590 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6591 dstpool, "dst-pool");
6592 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6593 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6595 cmdline_parse_token_string_t cmd_mirror_link_on =
6596 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6600 cmd_set_mirror_link_parsed(void *parsed_result,
6601 __attribute__((unused)) struct cmdline *cl,
6602 __attribute__((unused)) void *data)
6605 struct cmd_set_mirror_link_result *res = parsed_result;
6606 struct rte_eth_vmdq_mirror_conf mr_conf;
6608 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6609 if(!strcmp(res->what, "uplink-mirror")) {
6610 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6611 }else if(!strcmp(res->what, "downlink-mirror"))
6612 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6614 mr_conf.dst_pool = res->dstpool_id;
6616 if(!strcmp(res->on, "on"))
6617 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6620 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6623 /* check the return value and print it if is < 0 */
6625 printf("mirror rule add error: (%s)\n", strerror(-ret));
6629 cmdline_parse_inst_t cmd_set_mirror_link = {
6630 .f = cmd_set_mirror_link_parsed,
6632 .help_str = "set port X mirror-rule Y uplink-mirror|"
6633 "downlink-mirror dst-pool Z on|off",
6635 (void *)&cmd_mirror_link_set,
6636 (void *)&cmd_mirror_link_port,
6637 (void *)&cmd_mirror_link_portid,
6638 (void *)&cmd_mirror_link_mirror,
6639 (void *)&cmd_mirror_link_ruleid,
6640 (void *)&cmd_mirror_link_what,
6641 (void *)&cmd_mirror_link_dstpool,
6642 (void *)&cmd_mirror_link_poolid,
6643 (void *)&cmd_mirror_link_on,
6648 /* *** RESET VM MIRROR RULE *** */
6649 struct cmd_rm_mirror_rule_result {
6650 cmdline_fixed_string_t reset;
6651 cmdline_fixed_string_t port;
6653 cmdline_fixed_string_t mirror;
6657 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6658 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6660 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6661 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6663 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6664 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6666 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6667 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6668 mirror, "mirror-rule");
6669 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6670 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6674 cmd_reset_mirror_rule_parsed(void *parsed_result,
6675 __attribute__((unused)) struct cmdline *cl,
6676 __attribute__((unused)) void *data)
6679 struct cmd_set_mirror_link_result *res = parsed_result;
6681 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6683 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6686 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6687 .f = cmd_reset_mirror_rule_parsed,
6689 .help_str = "reset port X mirror-rule Y",
6691 (void *)&cmd_rm_mirror_rule_reset,
6692 (void *)&cmd_rm_mirror_rule_port,
6693 (void *)&cmd_rm_mirror_rule_portid,
6694 (void *)&cmd_rm_mirror_rule_mirror,
6695 (void *)&cmd_rm_mirror_rule_ruleid,
6700 /* ******************************************************************************** */
6702 struct cmd_dump_result {
6703 cmdline_fixed_string_t dump;
6707 dump_struct_sizes(void)
6709 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6710 DUMP_SIZE(struct rte_mbuf);
6711 DUMP_SIZE(struct rte_mempool);
6712 DUMP_SIZE(struct rte_ring);
6716 static void cmd_dump_parsed(void *parsed_result,
6717 __attribute__((unused)) struct cmdline *cl,
6718 __attribute__((unused)) void *data)
6720 struct cmd_dump_result *res = parsed_result;
6722 if (!strcmp(res->dump, "dump_physmem"))
6723 rte_dump_physmem_layout(stdout);
6724 else if (!strcmp(res->dump, "dump_memzone"))
6725 rte_memzone_dump(stdout);
6726 else if (!strcmp(res->dump, "dump_log_history"))
6727 rte_log_dump_history(stdout);
6728 else if (!strcmp(res->dump, "dump_struct_sizes"))
6729 dump_struct_sizes();
6730 else if (!strcmp(res->dump, "dump_ring"))
6731 rte_ring_list_dump(stdout);
6732 else if (!strcmp(res->dump, "dump_mempool"))
6733 rte_mempool_list_dump(stdout);
6734 else if (!strcmp(res->dump, "dump_devargs"))
6735 rte_eal_devargs_dump(stdout);
6738 cmdline_parse_token_string_t cmd_dump_dump =
6739 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6743 "dump_struct_sizes#"
6748 cmdline_parse_inst_t cmd_dump = {
6749 .f = cmd_dump_parsed, /* function to call */
6750 .data = NULL, /* 2nd arg of func */
6751 .help_str = "dump status",
6752 .tokens = { /* token list, NULL terminated */
6753 (void *)&cmd_dump_dump,
6758 /* ******************************************************************************** */
6760 struct cmd_dump_one_result {
6761 cmdline_fixed_string_t dump;
6762 cmdline_fixed_string_t name;
6765 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6766 __attribute__((unused)) void *data)
6768 struct cmd_dump_one_result *res = parsed_result;
6770 if (!strcmp(res->dump, "dump_ring")) {
6772 r = rte_ring_lookup(res->name);
6774 cmdline_printf(cl, "Cannot find ring\n");
6777 rte_ring_dump(stdout, r);
6778 } else if (!strcmp(res->dump, "dump_mempool")) {
6779 struct rte_mempool *mp;
6780 mp = rte_mempool_lookup(res->name);
6782 cmdline_printf(cl, "Cannot find mempool\n");
6785 rte_mempool_dump(stdout, mp);
6789 cmdline_parse_token_string_t cmd_dump_one_dump =
6790 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6791 "dump_ring#dump_mempool");
6793 cmdline_parse_token_string_t cmd_dump_one_name =
6794 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6796 cmdline_parse_inst_t cmd_dump_one = {
6797 .f = cmd_dump_one_parsed, /* function to call */
6798 .data = NULL, /* 2nd arg of func */
6799 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6800 .tokens = { /* token list, NULL terminated */
6801 (void *)&cmd_dump_one_dump,
6802 (void *)&cmd_dump_one_name,
6807 /* *** set SYN filter *** */
6808 struct cmd_set_syn_filter_result {
6809 cmdline_fixed_string_t filter;
6811 cmdline_fixed_string_t priority;
6812 cmdline_fixed_string_t high;
6813 cmdline_fixed_string_t queue;
6818 cmd_set_syn_filter_parsed(void *parsed_result,
6819 __attribute__((unused)) struct cmdline *cl,
6820 __attribute__((unused)) void *data)
6823 struct cmd_set_syn_filter_result *res = parsed_result;
6824 struct rte_syn_filter filter;
6826 if (!strcmp(res->filter, "add_syn_filter")) {
6827 if (!strcmp(res->high, "high"))
6831 ret = rte_eth_dev_add_syn_filter(res->port_id,
6832 &filter, res->queue_id);
6833 } else if (!strcmp(res->filter, "remove_syn_filter"))
6834 ret = rte_eth_dev_remove_syn_filter(res->port_id);
6835 else if (!strcmp(res->filter, "get_syn_filter"))
6836 get_syn_filter(res->port_id);
6838 printf("syn filter setting error: (%s)\n", strerror(-ret));
6841 cmdline_parse_token_num_t cmd_syn_filter_portid =
6842 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6844 cmdline_parse_token_string_t cmd_syn_filter_priority =
6845 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6846 priority, "priority");
6847 cmdline_parse_token_string_t cmd_syn_filter_high =
6848 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6850 cmdline_parse_token_string_t cmd_syn_filter_queue =
6851 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6853 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6854 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6856 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
6857 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6858 filter, "add_syn_filter");
6859 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
6860 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6861 filter, "remove_syn_filter");
6862 cmdline_parse_inst_t cmd_add_syn_filter = {
6863 .f = cmd_set_syn_filter_parsed,
6865 .help_str = "add syn filter",
6867 (void *)&cmd_syn_filter_add_filter,
6868 (void *)&cmd_syn_filter_portid,
6869 (void *)&cmd_syn_filter_priority,
6870 (void *)&cmd_syn_filter_high,
6871 (void *)&cmd_syn_filter_queue,
6872 (void *)&cmd_syn_filter_queue_id,
6876 cmdline_parse_inst_t cmd_remove_syn_filter = {
6877 .f = cmd_set_syn_filter_parsed,
6879 .help_str = "remove syn filter",
6881 (void *)&cmd_syn_filter_remove_filter,
6882 (void *)&cmd_syn_filter_portid,
6887 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
6888 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6889 filter, "get_syn_filter");
6891 cmdline_parse_inst_t cmd_get_syn_filter = {
6892 .f = cmd_set_syn_filter_parsed,
6894 .help_str = "get syn filter",
6896 (void *)&cmd_syn_filter_get_filter,
6897 (void *)&cmd_syn_filter_portid,
6902 /* *** ADD/REMOVE A 2tuple FILTER *** */
6903 struct cmd_2tuple_filter_result {
6904 cmdline_fixed_string_t filter;
6906 cmdline_fixed_string_t protocol;
6907 uint8_t protocol_value;
6908 uint8_t protocol_mask;
6909 cmdline_fixed_string_t dst_port;
6910 uint16_t dst_port_value;
6911 uint16_t dst_port_mask;
6912 cmdline_fixed_string_t flags;
6913 uint8_t flags_value;
6914 cmdline_fixed_string_t priority;
6915 uint8_t priority_value;
6916 cmdline_fixed_string_t queue;
6918 cmdline_fixed_string_t index;
6919 uint16_t index_value;
6923 cmd_2tuple_filter_parsed(void *parsed_result,
6924 __attribute__((unused)) struct cmdline *cl,
6925 __attribute__((unused)) void *data)
6928 struct rte_2tuple_filter filter;
6929 struct cmd_2tuple_filter_result *res = parsed_result;
6931 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
6933 if (!strcmp(res->filter, "add_2tuple_filter")) {
6934 /* need convert to big endian. */
6935 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6936 filter.protocol = res->protocol_value;
6937 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
6938 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
6939 filter.priority = res->priority_value;
6940 filter.tcp_flags = res->flags_value;
6941 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
6942 res->index_value, &filter, res->queue_id);
6943 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
6944 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
6946 else if (!strcmp(res->filter, "get_2tuple_filter"))
6947 get_2tuple_filter(res->port_id, res->index_value);
6950 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
6953 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6954 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6956 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6957 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6958 protocol, "protocol");
6959 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6960 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6961 protocol_value, UINT8);
6962 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
6963 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6964 protocol_mask, UINT8);
6965 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6966 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6967 dst_port, "dst_port");
6968 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6969 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6970 dst_port_value, UINT16);
6971 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
6972 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6973 dst_port_mask, UINT16);
6974 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
6975 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6977 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
6978 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6979 flags_value, UINT8);
6980 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6981 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6982 priority, "priority");
6983 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6984 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6985 priority_value, UINT8);
6986 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6987 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6989 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6990 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6992 cmdline_parse_token_string_t cmd_2tuple_filter_index =
6993 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6995 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
6996 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6997 index_value, UINT16);
6998 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
6999 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7000 filter, "add_2tuple_filter");
7001 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7002 .f = cmd_2tuple_filter_parsed,
7004 .help_str = "add a 2tuple filter",
7006 (void *)&cmd_2tuple_filter_add_filter,
7007 (void *)&cmd_2tuple_filter_port_id,
7008 (void *)&cmd_2tuple_filter_protocol,
7009 (void *)&cmd_2tuple_filter_protocol_value,
7010 (void *)&cmd_2tuple_filter_protocol_mask,
7011 (void *)&cmd_2tuple_filter_dst_port,
7012 (void *)&cmd_2tuple_filter_dst_port_value,
7013 (void *)&cmd_2tuple_filter_dst_port_mask,
7014 (void *)&cmd_2tuple_filter_flags,
7015 (void *)&cmd_2tuple_filter_flags_value,
7016 (void *)&cmd_2tuple_filter_priority,
7017 (void *)&cmd_2tuple_filter_priority_value,
7018 (void *)&cmd_2tuple_filter_queue,
7019 (void *)&cmd_2tuple_filter_queue_id,
7020 (void *)&cmd_2tuple_filter_index,
7021 (void *)&cmd_2tuple_filter_index_value,
7026 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7027 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7028 filter, "remove_2tuple_filter");
7029 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7030 .f = cmd_2tuple_filter_parsed,
7032 .help_str = "remove a 2tuple filter",
7034 (void *)&cmd_2tuple_filter_remove_filter,
7035 (void *)&cmd_2tuple_filter_port_id,
7036 (void *)&cmd_2tuple_filter_index,
7037 (void *)&cmd_2tuple_filter_index_value,
7041 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7042 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7043 filter, "get_2tuple_filter");
7044 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7045 .f = cmd_2tuple_filter_parsed,
7047 .help_str = "get a 2tuple filter",
7049 (void *)&cmd_2tuple_filter_get_filter,
7050 (void *)&cmd_2tuple_filter_port_id,
7051 (void *)&cmd_2tuple_filter_index,
7052 (void *)&cmd_2tuple_filter_index_value,
7057 /* *** ADD/REMOVE A 5tuple FILTER *** */
7058 struct cmd_5tuple_filter_result {
7059 cmdline_fixed_string_t filter;
7061 cmdline_fixed_string_t dst_ip;
7062 cmdline_ipaddr_t dst_ip_value;
7063 cmdline_fixed_string_t src_ip;
7064 cmdline_ipaddr_t src_ip_value;
7065 cmdline_fixed_string_t dst_port;
7066 uint16_t dst_port_value;
7067 cmdline_fixed_string_t src_port;
7068 uint16_t src_port_value;
7069 cmdline_fixed_string_t protocol;
7070 uint8_t protocol_value;
7071 cmdline_fixed_string_t mask;
7073 cmdline_fixed_string_t flags;
7074 uint8_t flags_value;
7075 cmdline_fixed_string_t priority;
7076 uint8_t priority_value;
7077 cmdline_fixed_string_t queue;
7079 cmdline_fixed_string_t index;
7080 uint16_t index_value;
7084 cmd_5tuple_filter_parsed(void *parsed_result,
7085 __attribute__((unused)) struct cmdline *cl,
7086 __attribute__((unused)) void *data)
7089 struct rte_5tuple_filter filter;
7090 struct cmd_5tuple_filter_result *res = parsed_result;
7092 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7094 if (!strcmp(res->filter, "add_5tuple_filter")) {
7095 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7096 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7097 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7098 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7099 filter.protocol = res->protocol_value;
7100 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7101 filter.priority = res->priority_value;
7102 filter.tcp_flags = res->flags_value;
7104 if (res->dst_ip_value.family == AF_INET)
7105 /* no need to convert, already big endian. */
7106 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7108 if (filter.dst_ip_mask == 0) {
7109 printf("can not support ipv6 involved compare.\n");
7115 if (res->src_ip_value.family == AF_INET)
7116 /* no need to convert, already big endian. */
7117 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7119 if (filter.src_ip_mask == 0) {
7120 printf("can not support ipv6 involved compare.\n");
7125 /* need convert to big endian. */
7126 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7127 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7129 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7130 res->index_value, &filter, res->queue_id);
7131 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7132 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7134 else if (!strcmp(res->filter, "get_5tuple_filter"))
7135 get_5tuple_filter(res->port_id, res->index_value);
7137 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7141 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7142 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7144 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7145 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7147 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7148 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7150 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7151 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7153 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7154 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7156 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7157 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7158 dst_port, "dst_port");
7159 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7160 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7161 dst_port_value, UINT16);
7162 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7163 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7164 src_port, "src_port");
7165 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7166 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7167 src_port_value, UINT16);
7168 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7169 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7170 protocol, "protocol");
7171 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7172 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7173 protocol_value, UINT8);
7174 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7175 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7177 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7178 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7180 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7181 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7183 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7184 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7185 flags_value, UINT8);
7186 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7187 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7188 priority, "priority");
7189 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7190 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7191 priority_value, UINT8);
7192 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7193 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7195 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7196 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7198 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7199 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7201 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7202 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7203 index_value, UINT16);
7205 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7206 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7207 filter, "add_5tuple_filter");
7208 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7209 .f = cmd_5tuple_filter_parsed,
7211 .help_str = "add a 5tuple filter",
7213 (void *)&cmd_5tuple_filter_add_filter,
7214 (void *)&cmd_5tuple_filter_port_id,
7215 (void *)&cmd_5tuple_filter_dst_ip,
7216 (void *)&cmd_5tuple_filter_dst_ip_value,
7217 (void *)&cmd_5tuple_filter_src_ip,
7218 (void *)&cmd_5tuple_filter_src_ip_value,
7219 (void *)&cmd_5tuple_filter_dst_port,
7220 (void *)&cmd_5tuple_filter_dst_port_value,
7221 (void *)&cmd_5tuple_filter_src_port,
7222 (void *)&cmd_5tuple_filter_src_port_value,
7223 (void *)&cmd_5tuple_filter_protocol,
7224 (void *)&cmd_5tuple_filter_protocol_value,
7225 (void *)&cmd_5tuple_filter_mask,
7226 (void *)&cmd_5tuple_filter_mask_value,
7227 (void *)&cmd_5tuple_filter_flags,
7228 (void *)&cmd_5tuple_filter_flags_value,
7229 (void *)&cmd_5tuple_filter_priority,
7230 (void *)&cmd_5tuple_filter_priority_value,
7231 (void *)&cmd_5tuple_filter_queue,
7232 (void *)&cmd_5tuple_filter_queue_id,
7233 (void *)&cmd_5tuple_filter_index,
7234 (void *)&cmd_5tuple_filter_index_value,
7239 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7240 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7241 filter, "remove_5tuple_filter");
7242 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7243 .f = cmd_5tuple_filter_parsed,
7245 .help_str = "remove a 5tuple filter",
7247 (void *)&cmd_5tuple_filter_remove_filter,
7248 (void *)&cmd_5tuple_filter_port_id,
7249 (void *)&cmd_5tuple_filter_index,
7250 (void *)&cmd_5tuple_filter_index_value,
7255 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7256 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7257 filter, "get_5tuple_filter");
7258 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7259 .f = cmd_5tuple_filter_parsed,
7261 .help_str = "get a 5tuple filter",
7263 (void *)&cmd_5tuple_filter_get_filter,
7264 (void *)&cmd_5tuple_filter_port_id,
7265 (void *)&cmd_5tuple_filter_index,
7266 (void *)&cmd_5tuple_filter_index_value,
7271 /* *** ADD/REMOVE A flex FILTER *** */
7272 struct cmd_flex_filter_result {
7273 cmdline_fixed_string_t filter;
7275 cmdline_fixed_string_t len;
7277 cmdline_fixed_string_t bytes;
7278 cmdline_fixed_string_t bytes_value;
7279 cmdline_fixed_string_t mask;
7280 cmdline_fixed_string_t mask_value;
7281 cmdline_fixed_string_t priority;
7282 uint8_t priority_value;
7283 cmdline_fixed_string_t queue;
7285 cmdline_fixed_string_t index;
7286 uint16_t index_value;
7289 static int xdigit2val(unsigned char c)
7294 else if (isupper(c))
7302 cmd_flex_filter_parsed(void *parsed_result,
7303 __attribute__((unused)) struct cmdline *cl,
7304 __attribute__((unused)) void *data)
7307 struct rte_flex_filter filter;
7308 struct cmd_flex_filter_result *res = parsed_result;
7309 char *bytes_ptr, *mask_ptr;
7317 if (!strcmp(res->filter, "add_flex_filter")) {
7318 if (res->len_value > 128) {
7319 printf("the len exceed the max length 128\n");
7322 memset(&filter, 0, sizeof(struct rte_flex_filter));
7323 filter.len = res->len_value;
7324 filter.priority = res->priority_value;
7325 bytes_ptr = res->bytes_value;
7326 mask_ptr = res->mask_value;
7329 /* translate bytes string to uint_32 array. */
7330 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7331 (bytes_ptr[1] == 'X')))
7333 len = strnlen(bytes_ptr, res->len_value * 2);
7334 if (len == 0 || (len % 8 != 0)) {
7335 printf("please check len and bytes input\n");
7338 for (i = 0; i < len; i++) {
7340 if (isxdigit(c) == 0) {
7341 /* invalid characters. */
7342 printf("invalid input\n");
7345 val = xdigit2val(c);
7349 dword |= byte << (4 * mod - 4);
7354 filter.dwords[j] = dword;
7355 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7361 /* translate mask string to uint8_t array. */
7363 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7364 (mask_ptr[1] == 'X')))
7366 len = strnlen(mask_ptr, (res->len_value+3)/4);
7368 printf("invalid input\n");
7371 for (i = 0; i < len; i++) {
7373 if (isxdigit(c) == 0) {
7374 /* invalid characters. */
7375 printf("invalid input\n");
7378 val = xdigit2val(c);
7379 hex |= (uint8_t)(val & 0x8) >> 3;
7380 hex |= (uint8_t)(val & 0x4) >> 1;
7381 hex |= (uint8_t)(val & 0x2) << 1;
7382 hex |= (uint8_t)(val & 0x1) << 3;
7385 filter.mask[j] = byte;
7386 printf("mask[%d]:%02x ", j, filter.mask[j]);
7394 printf("call function rte_eth_dev_add_flex_filter: "
7395 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7396 res->index_value, res->queue_id,
7397 filter.len, filter.priority);
7398 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7399 &filter, res->queue_id);
7401 } else if (!strcmp(res->filter, "remove_flex_filter"))
7402 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7404 else if (!strcmp(res->filter, "get_flex_filter"))
7405 get_flex_filter(res->port_id, res->index_value);
7408 printf("flex filter setting error: (%s)\n", strerror(-ret));
7411 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7412 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7414 cmdline_parse_token_string_t cmd_flex_filter_len =
7415 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7417 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7418 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7420 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7421 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7423 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7424 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7426 cmdline_parse_token_string_t cmd_flex_filter_mask =
7427 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7429 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7430 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7432 cmdline_parse_token_string_t cmd_flex_filter_priority =
7433 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7434 priority, "priority");
7435 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7436 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7437 priority_value, UINT8);
7438 cmdline_parse_token_string_t cmd_flex_filter_queue =
7439 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7441 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7442 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7444 cmdline_parse_token_string_t cmd_flex_filter_index =
7445 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7447 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7448 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7449 index_value, UINT16);
7450 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7451 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7452 filter, "add_flex_filter");
7453 cmdline_parse_inst_t cmd_add_flex_filter = {
7454 .f = cmd_flex_filter_parsed,
7456 .help_str = "add a flex filter",
7458 (void *)&cmd_flex_filter_add_filter,
7459 (void *)&cmd_flex_filter_port_id,
7460 (void *)&cmd_flex_filter_len,
7461 (void *)&cmd_flex_filter_len_value,
7462 (void *)&cmd_flex_filter_bytes,
7463 (void *)&cmd_flex_filter_bytes_value,
7464 (void *)&cmd_flex_filter_mask,
7465 (void *)&cmd_flex_filter_mask_value,
7466 (void *)&cmd_flex_filter_priority,
7467 (void *)&cmd_flex_filter_priority_value,
7468 (void *)&cmd_flex_filter_queue,
7469 (void *)&cmd_flex_filter_queue_id,
7470 (void *)&cmd_flex_filter_index,
7471 (void *)&cmd_flex_filter_index_value,
7476 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7477 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7478 filter, "remove_flex_filter");
7479 cmdline_parse_inst_t cmd_remove_flex_filter = {
7480 .f = cmd_flex_filter_parsed,
7482 .help_str = "remove a flex filter",
7484 (void *)&cmd_flex_filter_remove_filter,
7485 (void *)&cmd_flex_filter_port_id,
7486 (void *)&cmd_flex_filter_index,
7487 (void *)&cmd_flex_filter_index_value,
7492 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7493 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7494 filter, "get_flex_filter");
7495 cmdline_parse_inst_t cmd_get_flex_filter = {
7496 .f = cmd_flex_filter_parsed,
7498 .help_str = "get a flex filter",
7500 (void *)&cmd_flex_filter_get_filter,
7501 (void *)&cmd_flex_filter_port_id,
7502 (void *)&cmd_flex_filter_index,
7503 (void *)&cmd_flex_filter_index_value,
7508 /* *** Filters Control *** */
7510 /* *** deal with ethertype filter *** */
7511 struct cmd_ethertype_filter_result {
7512 cmdline_fixed_string_t filter;
7514 cmdline_fixed_string_t ops;
7515 cmdline_fixed_string_t mac;
7516 struct ether_addr mac_addr;
7517 cmdline_fixed_string_t ethertype;
7518 uint16_t ethertype_value;
7519 cmdline_fixed_string_t drop;
7520 cmdline_fixed_string_t queue;
7524 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7525 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7526 filter, "ethertype_filter");
7527 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7528 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7530 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7531 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7533 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7534 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7535 mac, "mac_addr#mac_ignr");
7536 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7537 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7539 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7540 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7541 ethertype, "ethertype");
7542 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7543 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7544 ethertype_value, UINT16);
7545 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7546 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7548 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7549 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7551 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7552 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7556 cmd_ethertype_filter_parsed(void *parsed_result,
7557 __attribute__((unused)) struct cmdline *cl,
7558 __attribute__((unused)) void *data)
7560 struct cmd_ethertype_filter_result *res = parsed_result;
7561 struct rte_eth_ethertype_filter filter;
7564 ret = rte_eth_dev_filter_supported(res->port_id,
7565 RTE_ETH_FILTER_ETHERTYPE);
7567 printf("ethertype filter is not supported on port %u.\n",
7572 memset(&filter, 0, sizeof(filter));
7573 if (!strcmp(res->mac, "mac_addr")) {
7574 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7575 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7576 sizeof(struct ether_addr));
7578 if (!strcmp(res->drop, "drop"))
7579 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7580 filter.ether_type = res->ethertype_value;
7581 filter.queue = res->queue_id;
7583 if (!strcmp(res->ops, "add"))
7584 ret = rte_eth_dev_filter_ctrl(res->port_id,
7585 RTE_ETH_FILTER_ETHERTYPE,
7589 ret = rte_eth_dev_filter_ctrl(res->port_id,
7590 RTE_ETH_FILTER_ETHERTYPE,
7591 RTE_ETH_FILTER_DELETE,
7594 printf("ethertype filter programming error: (%s)\n",
7598 cmdline_parse_inst_t cmd_ethertype_filter = {
7599 .f = cmd_ethertype_filter_parsed,
7601 .help_str = "add or delete an ethertype filter entry",
7603 (void *)&cmd_ethertype_filter_filter,
7604 (void *)&cmd_ethertype_filter_port_id,
7605 (void *)&cmd_ethertype_filter_ops,
7606 (void *)&cmd_ethertype_filter_mac,
7607 (void *)&cmd_ethertype_filter_mac_addr,
7608 (void *)&cmd_ethertype_filter_ethertype,
7609 (void *)&cmd_ethertype_filter_ethertype_value,
7610 (void *)&cmd_ethertype_filter_drop,
7611 (void *)&cmd_ethertype_filter_queue,
7612 (void *)&cmd_ethertype_filter_queue_id,
7617 /* *** deal with flow director filter *** */
7618 struct cmd_flow_director_result {
7619 cmdline_fixed_string_t flow_director_filter;
7621 cmdline_fixed_string_t ops;
7622 cmdline_fixed_string_t flow;
7623 cmdline_fixed_string_t flow_type;
7624 cmdline_fixed_string_t src;
7625 cmdline_ipaddr_t ip_src;
7627 cmdline_fixed_string_t dst;
7628 cmdline_ipaddr_t ip_dst;
7630 cmdline_fixed_string_t verify_tag;
7631 uint32_t verify_tag_value;
7632 cmdline_fixed_string_t vlan;
7633 uint16_t vlan_value;
7634 cmdline_fixed_string_t flexbytes;
7635 cmdline_fixed_string_t flexbytes_value;
7636 cmdline_fixed_string_t drop;
7637 cmdline_fixed_string_t queue;
7639 cmdline_fixed_string_t fd_id;
7640 uint32_t fd_id_value;
7644 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7647 const char *p, *p0 = q_arg;
7649 unsigned long int_fld;
7650 char *str_fld[max_num];
7655 p = strchr(p0, '(');
7659 p0 = strchr(p, ')');
7664 if (size >= sizeof(s))
7667 snprintf(s, sizeof(s), "%.*s", size, p);
7668 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7669 if (ret < 0 || ret > max_num)
7671 for (i = 0; i < ret; i++) {
7673 int_fld = strtoul(str_fld[i], &end, 0);
7674 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7676 flexbytes[i] = (uint8_t)int_fld;
7681 static enum rte_eth_flow_type
7682 str2flowtype(char *string)
7685 static const struct {
7687 enum rte_eth_flow_type type;
7688 } flowtype_str[] = {
7689 {"raw", RTE_ETH_FLOW_TYPE_RAW},
7690 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
7691 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
7692 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
7693 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
7694 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
7695 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
7696 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
7697 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
7698 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
7699 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
7702 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7703 if (!strcmp(flowtype_str[i].str, string))
7704 return flowtype_str[i].type;
7706 return RTE_ETH_FLOW_TYPE_NONE;
7709 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
7711 if ((ip_addr).family == AF_INET) \
7712 (ip) = (ip_addr).addr.ipv4.s_addr; \
7714 printf("invalid parameter.\n"); \
7719 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
7721 if ((ip_addr).family == AF_INET6) \
7722 (void)rte_memcpy(&(ip), \
7723 &((ip_addr).addr.ipv6), \
7724 sizeof(struct in6_addr)); \
7726 printf("invalid parameter.\n"); \
7732 cmd_flow_director_filter_parsed(void *parsed_result,
7733 __attribute__((unused)) struct cmdline *cl,
7734 __attribute__((unused)) void *data)
7736 struct cmd_flow_director_result *res = parsed_result;
7737 struct rte_eth_fdir_filter entry;
7738 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
7741 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7743 printf("flow director is not supported on port %u.\n",
7747 memset(flexbytes, 0, sizeof(flexbytes));
7748 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
7749 ret = parse_flexbytes(res->flexbytes_value,
7751 RTE_ETH_FDIR_MAX_FLEXLEN);
7753 printf("error: Cannot parse flexbytes input.\n");
7757 entry.input.flow_type = str2flowtype(res->flow_type);
7758 switch (entry.input.flow_type) {
7759 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
7760 case RTE_ETH_FLOW_TYPE_FRAG_IPV4:
7761 case RTE_ETH_FLOW_TYPE_UDPV4:
7762 case RTE_ETH_FLOW_TYPE_TCPV4:
7763 IPV4_ADDR_TO_UINT(res->ip_dst,
7764 entry.input.flow.ip4_flow.dst_ip);
7765 IPV4_ADDR_TO_UINT(res->ip_src,
7766 entry.input.flow.ip4_flow.src_ip);
7767 /* need convert to big endian. */
7768 entry.input.flow.udp4_flow.dst_port =
7769 rte_cpu_to_be_16(res->port_dst);
7770 entry.input.flow.udp4_flow.src_port =
7771 rte_cpu_to_be_16(res->port_src);
7773 case RTE_ETH_FLOW_TYPE_SCTPV4:
7774 IPV4_ADDR_TO_UINT(res->ip_dst,
7775 entry.input.flow.sctp4_flow.ip.dst_ip);
7776 IPV4_ADDR_TO_UINT(res->ip_src,
7777 entry.input.flow.sctp4_flow.ip.src_ip);
7778 /* need convert to big endian. */
7779 entry.input.flow.sctp4_flow.verify_tag =
7780 rte_cpu_to_be_32(res->verify_tag_value);
7782 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
7783 case RTE_ETH_FLOW_TYPE_FRAG_IPV6:
7784 case RTE_ETH_FLOW_TYPE_UDPV6:
7785 case RTE_ETH_FLOW_TYPE_TCPV6:
7786 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7787 entry.input.flow.ipv6_flow.dst_ip);
7788 IPV6_ADDR_TO_ARRAY(res->ip_src,
7789 entry.input.flow.ipv6_flow.src_ip);
7790 /* need convert to big endian. */
7791 entry.input.flow.udp6_flow.dst_port =
7792 rte_cpu_to_be_16(res->port_dst);
7793 entry.input.flow.udp6_flow.src_port =
7794 rte_cpu_to_be_16(res->port_src);
7796 case RTE_ETH_FLOW_TYPE_SCTPV6:
7797 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7798 entry.input.flow.sctp6_flow.ip.dst_ip);
7799 IPV6_ADDR_TO_ARRAY(res->ip_src,
7800 entry.input.flow.sctp6_flow.ip.src_ip);
7801 /* need convert to big endian. */
7802 entry.input.flow.sctp6_flow.verify_tag =
7803 rte_cpu_to_be_32(res->verify_tag_value);
7806 printf("invalid parameter.\n");
7809 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
7811 RTE_ETH_FDIR_MAX_FLEXLEN);
7813 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
7815 entry.action.flex_off = 0; /*use 0 by default */
7816 if (!strcmp(res->drop, "drop"))
7817 entry.action.behavior = RTE_ETH_FDIR_REJECT;
7819 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
7820 /* set to report FD ID by default */
7821 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
7822 entry.action.rx_queue = res->queue_id;
7823 entry.soft_id = res->fd_id_value;
7824 if (!strcmp(res->ops, "add"))
7825 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7826 RTE_ETH_FILTER_ADD, &entry);
7827 else if (!strcmp(res->ops, "del"))
7828 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7829 RTE_ETH_FILTER_DELETE, &entry);
7831 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7832 RTE_ETH_FILTER_UPDATE, &entry);
7834 printf("flow director programming error: (%s)\n",
7838 cmdline_parse_token_string_t cmd_flow_director_filter =
7839 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7840 flow_director_filter, "flow_director_filter");
7841 cmdline_parse_token_num_t cmd_flow_director_port_id =
7842 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7844 cmdline_parse_token_string_t cmd_flow_director_ops =
7845 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7846 ops, "add#del#update");
7847 cmdline_parse_token_string_t cmd_flow_director_flow =
7848 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7850 cmdline_parse_token_string_t cmd_flow_director_flow_type =
7851 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7853 "ip4#ip4-frag#tcp4#udp4#sctp4#"
7854 "ip6#ip6-frag#tcp6#udp6#sctp6");
7855 cmdline_parse_token_string_t cmd_flow_director_src =
7856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7858 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
7859 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7861 cmdline_parse_token_num_t cmd_flow_director_port_src =
7862 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7864 cmdline_parse_token_string_t cmd_flow_director_dst =
7865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7867 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
7868 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7870 cmdline_parse_token_num_t cmd_flow_director_port_dst =
7871 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7873 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
7874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7875 verify_tag, "verify_tag");
7876 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
7877 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7878 verify_tag_value, UINT32);
7879 cmdline_parse_token_string_t cmd_flow_director_vlan =
7880 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7882 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
7883 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7884 vlan_value, UINT16);
7885 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
7886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7887 flexbytes, "flexbytes");
7888 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
7889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7890 flexbytes_value, NULL);
7891 cmdline_parse_token_string_t cmd_flow_director_drop =
7892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7894 cmdline_parse_token_string_t cmd_flow_director_queue =
7895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7897 cmdline_parse_token_num_t cmd_flow_director_queue_id =
7898 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7900 cmdline_parse_token_string_t cmd_flow_director_fd_id =
7901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7903 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
7904 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7905 fd_id_value, UINT32);
7907 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
7908 .f = cmd_flow_director_filter_parsed,
7910 .help_str = "add or delete an ip flow director entry on NIC",
7912 (void *)&cmd_flow_director_filter,
7913 (void *)&cmd_flow_director_port_id,
7914 (void *)&cmd_flow_director_ops,
7915 (void *)&cmd_flow_director_flow,
7916 (void *)&cmd_flow_director_flow_type,
7917 (void *)&cmd_flow_director_src,
7918 (void *)&cmd_flow_director_ip_src,
7919 (void *)&cmd_flow_director_dst,
7920 (void *)&cmd_flow_director_ip_dst,
7921 (void *)&cmd_flow_director_vlan,
7922 (void *)&cmd_flow_director_vlan_value,
7923 (void *)&cmd_flow_director_flexbytes,
7924 (void *)&cmd_flow_director_flexbytes_value,
7925 (void *)&cmd_flow_director_drop,
7926 (void *)&cmd_flow_director_queue,
7927 (void *)&cmd_flow_director_queue_id,
7928 (void *)&cmd_flow_director_fd_id,
7929 (void *)&cmd_flow_director_fd_id_value,
7934 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
7935 .f = cmd_flow_director_filter_parsed,
7937 .help_str = "add or delete an udp/tcp flow director entry on NIC",
7939 (void *)&cmd_flow_director_filter,
7940 (void *)&cmd_flow_director_port_id,
7941 (void *)&cmd_flow_director_ops,
7942 (void *)&cmd_flow_director_flow,
7943 (void *)&cmd_flow_director_flow_type,
7944 (void *)&cmd_flow_director_src,
7945 (void *)&cmd_flow_director_ip_src,
7946 (void *)&cmd_flow_director_port_src,
7947 (void *)&cmd_flow_director_dst,
7948 (void *)&cmd_flow_director_ip_dst,
7949 (void *)&cmd_flow_director_port_dst,
7950 (void *)&cmd_flow_director_vlan,
7951 (void *)&cmd_flow_director_vlan_value,
7952 (void *)&cmd_flow_director_flexbytes,
7953 (void *)&cmd_flow_director_flexbytes_value,
7954 (void *)&cmd_flow_director_drop,
7955 (void *)&cmd_flow_director_queue,
7956 (void *)&cmd_flow_director_queue_id,
7957 (void *)&cmd_flow_director_fd_id,
7958 (void *)&cmd_flow_director_fd_id_value,
7963 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
7964 .f = cmd_flow_director_filter_parsed,
7966 .help_str = "add or delete a sctp flow director entry on NIC",
7968 (void *)&cmd_flow_director_filter,
7969 (void *)&cmd_flow_director_port_id,
7970 (void *)&cmd_flow_director_ops,
7971 (void *)&cmd_flow_director_flow,
7972 (void *)&cmd_flow_director_flow_type,
7973 (void *)&cmd_flow_director_src,
7974 (void *)&cmd_flow_director_ip_src,
7975 (void *)&cmd_flow_director_port_dst,
7976 (void *)&cmd_flow_director_dst,
7977 (void *)&cmd_flow_director_ip_dst,
7978 (void *)&cmd_flow_director_port_dst,
7979 (void *)&cmd_flow_director_verify_tag,
7980 (void *)&cmd_flow_director_verify_tag_value,
7981 (void *)&cmd_flow_director_vlan,
7982 (void *)&cmd_flow_director_vlan_value,
7983 (void *)&cmd_flow_director_flexbytes,
7984 (void *)&cmd_flow_director_flexbytes_value,
7985 (void *)&cmd_flow_director_drop,
7986 (void *)&cmd_flow_director_queue,
7987 (void *)&cmd_flow_director_queue_id,
7988 (void *)&cmd_flow_director_fd_id,
7989 (void *)&cmd_flow_director_fd_id_value,
7994 struct cmd_flush_flow_director_result {
7995 cmdline_fixed_string_t flush_flow_director;
7999 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8000 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8001 flush_flow_director, "flush_flow_director");
8002 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8003 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8007 cmd_flush_flow_director_parsed(void *parsed_result,
8008 __attribute__((unused)) struct cmdline *cl,
8009 __attribute__((unused)) void *data)
8011 struct cmd_flow_director_result *res = parsed_result;
8014 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8016 printf("flow director is not supported on port %u.\n",
8021 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8022 RTE_ETH_FILTER_FLUSH, NULL);
8024 printf("flow director table flushing error: (%s)\n",
8028 cmdline_parse_inst_t cmd_flush_flow_director = {
8029 .f = cmd_flush_flow_director_parsed,
8031 .help_str = "flush all flow director entries of a device on NIC",
8033 (void *)&cmd_flush_flow_director_flush,
8034 (void *)&cmd_flush_flow_director_port_id,
8039 /* *** deal with flow director mask *** */
8040 struct cmd_flow_director_mask_result {
8041 cmdline_fixed_string_t flow_director_mask;
8043 cmdline_fixed_string_t vlan;
8044 uint16_t vlan_value;
8045 cmdline_fixed_string_t src_mask;
8046 cmdline_ipaddr_t ipv4_src;
8047 cmdline_ipaddr_t ipv6_src;
8049 cmdline_fixed_string_t dst_mask;
8050 cmdline_ipaddr_t ipv4_dst;
8051 cmdline_ipaddr_t ipv6_dst;
8056 cmd_flow_director_mask_parsed(void *parsed_result,
8057 __attribute__((unused)) struct cmdline *cl,
8058 __attribute__((unused)) void *data)
8060 struct cmd_flow_director_mask_result *res = parsed_result;
8061 struct rte_eth_fdir_masks *mask;
8062 struct rte_port *port;
8064 if (res->port_id > nb_ports) {
8065 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8069 port = &ports[res->port_id];
8070 /** Check if the port is not started **/
8071 if (port->port_status != RTE_PORT_STOPPED) {
8072 printf("Please stop port %d first\n", res->port_id);
8075 mask = &port->dev_conf.fdir_conf.mask;
8077 mask->vlan_tci_mask = res->vlan_value;
8078 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8079 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8080 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8081 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8082 mask->src_port_mask = res->port_src;
8083 mask->dst_port_mask = res->port_dst;
8085 cmd_reconfig_device_queue(res->port_id, 1, 1);
8088 cmdline_parse_token_string_t cmd_flow_director_mask =
8089 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8090 flow_director_mask, "flow_director_mask");
8091 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8092 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8094 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8095 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8097 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8098 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8099 vlan_value, UINT16);
8100 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8101 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8102 src_mask, "src_mask");
8103 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8104 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8106 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8107 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8109 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8110 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8112 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8113 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8114 dst_mask, "dst_mask");
8115 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8116 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8118 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8119 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8121 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8122 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8124 cmdline_parse_inst_t cmd_set_flow_director_mask = {
8125 .f = cmd_flow_director_mask_parsed,
8127 .help_str = "set flow director's mask on NIC",
8129 (void *)&cmd_flow_director_mask,
8130 (void *)&cmd_flow_director_mask_port_id,
8131 (void *)&cmd_flow_director_mask_vlan,
8132 (void *)&cmd_flow_director_mask_vlan_value,
8133 (void *)&cmd_flow_director_mask_src,
8134 (void *)&cmd_flow_director_mask_ipv4_src,
8135 (void *)&cmd_flow_director_mask_ipv6_src,
8136 (void *)&cmd_flow_director_mask_port_src,
8137 (void *)&cmd_flow_director_mask_dst,
8138 (void *)&cmd_flow_director_mask_ipv4_dst,
8139 (void *)&cmd_flow_director_mask_ipv6_dst,
8140 (void *)&cmd_flow_director_mask_port_dst,
8145 /* *** deal with flow director mask on flexible payload *** */
8146 struct cmd_flow_director_flex_mask_result {
8147 cmdline_fixed_string_t flow_director_flexmask;
8149 cmdline_fixed_string_t flow;
8150 cmdline_fixed_string_t flow_type;
8151 cmdline_fixed_string_t mask;
8155 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8156 __attribute__((unused)) struct cmdline *cl,
8157 __attribute__((unused)) void *data)
8159 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8160 struct rte_eth_fdir_info fdir_info;
8161 struct rte_eth_fdir_flex_mask flex_mask;
8162 struct rte_port *port;
8163 enum rte_eth_flow_type i;
8166 if (res->port_id > nb_ports) {
8167 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8171 port = &ports[res->port_id];
8172 /** Check if the port is not started **/
8173 if (port->port_status != RTE_PORT_STOPPED) {
8174 printf("Please stop port %d first\n", res->port_id);
8178 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8179 ret = parse_flexbytes(res->mask,
8181 RTE_ETH_FDIR_MAX_FLEXLEN);
8183 printf("error: Cannot parse mask input.\n");
8187 if (!strcmp(res->flow_type, "all")) {
8188 memset(&fdir_info, 0, sizeof(fdir_info));
8189 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8190 RTE_ETH_FILTER_INFO, &fdir_info);
8191 for (i = RTE_ETH_FLOW_TYPE_RAW;
8192 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8194 if (fdir_info.flow_types_mask[0] & (1 << i)) {
8195 flex_mask.flow_type = i;
8196 fdir_set_flex_mask(res->port_id, &flex_mask);
8199 cmd_reconfig_device_queue(res->port_id, 1, 1);
8202 flex_mask.flow_type = str2flowtype(res->flow_type);
8203 fdir_set_flex_mask(res->port_id, &flex_mask);
8204 cmd_reconfig_device_queue(res->port_id, 1, 1);
8207 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8208 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8209 flow_director_flexmask,
8210 "flow_director_flex_mask");
8211 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8212 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8214 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8215 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8217 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8218 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8220 "raw#ip4#ip4-frag#tcp4#udp4#sctp4#"
8221 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8222 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8223 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8226 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8227 .f = cmd_flow_director_flex_mask_parsed,
8229 .help_str = "set flow director's flex mask on NIC",
8231 (void *)&cmd_flow_director_flexmask,
8232 (void *)&cmd_flow_director_flexmask_port_id,
8233 (void *)&cmd_flow_director_flexmask_flow,
8234 (void *)&cmd_flow_director_flexmask_flow_type,
8235 (void *)&cmd_flow_director_flexmask_mask,
8240 /* *** deal with flow director flexible payload configuration *** */
8241 struct cmd_flow_director_flexpayload_result {
8242 cmdline_fixed_string_t flow_director_flexpayload;
8244 cmdline_fixed_string_t payload_layer;
8245 cmdline_fixed_string_t payload_cfg;
8249 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8252 const char *p, *p0 = q_arg;
8254 unsigned long int_fld;
8255 char *str_fld[max_num];
8260 p = strchr(p0, '(');
8264 p0 = strchr(p, ')');
8269 if (size >= sizeof(s))
8272 snprintf(s, sizeof(s), "%.*s", size, p);
8273 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8274 if (ret < 0 || ret > max_num)
8276 for (i = 0; i < ret; i++) {
8278 int_fld = strtoul(str_fld[i], &end, 0);
8279 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8281 offsets[i] = (uint16_t)int_fld;
8287 cmd_flow_director_flxpld_parsed(void *parsed_result,
8288 __attribute__((unused)) struct cmdline *cl,
8289 __attribute__((unused)) void *data)
8291 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8292 struct rte_eth_flex_payload_cfg flex_cfg;
8293 struct rte_port *port;
8296 if (res->port_id > nb_ports) {
8297 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8301 port = &ports[res->port_id];
8302 /** Check if the port is not started **/
8303 if (port->port_status != RTE_PORT_STOPPED) {
8304 printf("Please stop port %d first\n", res->port_id);
8308 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8310 if (!strcmp(res->payload_layer, "raw"))
8311 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8312 else if (!strcmp(res->payload_layer, "l2"))
8313 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8314 else if (!strcmp(res->payload_layer, "l3"))
8315 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8316 else if (!strcmp(res->payload_layer, "l4"))
8317 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8319 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8320 RTE_ETH_FDIR_MAX_FLEXLEN);
8322 printf("error: Cannot parse flex payload input.\n");
8326 fdir_set_flex_payload(res->port_id, &flex_cfg);
8327 cmd_reconfig_device_queue(res->port_id, 1, 1);
8330 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8331 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8332 flow_director_flexpayload,
8333 "flow_director_flex_payload");
8334 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8335 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8337 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8338 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8339 payload_layer, "raw#l2#l3#l4");
8340 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8344 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8345 .f = cmd_flow_director_flxpld_parsed,
8347 .help_str = "set flow director's flex payload on NIC",
8349 (void *)&cmd_flow_director_flexpayload,
8350 (void *)&cmd_flow_director_flexpayload_port_id,
8351 (void *)&cmd_flow_director_flexpayload_payload_layer,
8352 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8357 /* *** Classification Filters Control *** */
8358 /* *** Get symmetric hash enable per port *** */
8359 struct cmd_get_sym_hash_ena_per_port_result {
8360 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8365 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8366 __rte_unused struct cmdline *cl,
8367 __rte_unused void *data)
8369 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8370 struct rte_eth_hash_filter_info info;
8373 if (rte_eth_dev_filter_supported(res->port_id,
8374 RTE_ETH_FILTER_HASH) < 0) {
8375 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8380 memset(&info, 0, sizeof(info));
8381 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8382 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8383 RTE_ETH_FILTER_GET, &info);
8386 printf("Cannot get symmetric hash enable per port "
8387 "on port %u\n", res->port_id);
8391 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8392 "enabled" : "disabled", res->port_id);
8395 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8396 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8397 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8398 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8399 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8402 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8403 .f = cmd_get_sym_hash_per_port_parsed,
8405 .help_str = "get_sym_hash_ena_per_port port_id",
8407 (void *)&cmd_get_sym_hash_ena_per_port_all,
8408 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8413 /* *** Set symmetric hash enable per port *** */
8414 struct cmd_set_sym_hash_ena_per_port_result {
8415 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8416 cmdline_fixed_string_t enable;
8421 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8422 __rte_unused struct cmdline *cl,
8423 __rte_unused void *data)
8425 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8426 struct rte_eth_hash_filter_info info;
8429 if (rte_eth_dev_filter_supported(res->port_id,
8430 RTE_ETH_FILTER_HASH) < 0) {
8431 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8436 memset(&info, 0, sizeof(info));
8437 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8438 if (!strcmp(res->enable, "enable"))
8439 info.info.enable = 1;
8440 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8441 RTE_ETH_FILTER_SET, &info);
8443 printf("Cannot set symmetric hash enable per port on "
8444 "port %u\n", res->port_id);
8447 printf("Symmetric hash has been set to %s on port %u\n",
8448 res->enable, res->port_id);
8451 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8452 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8453 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8454 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8455 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8457 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8458 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8459 enable, "enable#disable");
8461 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8462 .f = cmd_set_sym_hash_per_port_parsed,
8464 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8466 (void *)&cmd_set_sym_hash_ena_per_port_all,
8467 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8468 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8473 /* Get global config of hash function */
8474 struct cmd_get_hash_global_config_result {
8475 cmdline_fixed_string_t get_hash_global_config;
8480 flowtype_to_str(enum rte_eth_flow_type ftype)
8485 enum rte_eth_flow_type ftype;
8487 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8488 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8489 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8490 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8491 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8492 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8493 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8494 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8495 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8496 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8499 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8500 if (ftype_table[i].ftype == ftype)
8501 return ftype_table[i].str;
8508 cmd_get_hash_global_config_parsed(void *parsed_result,
8509 __rte_unused struct cmdline *cl,
8510 __rte_unused void *data)
8512 struct cmd_get_hash_global_config_result *res = parsed_result;
8513 struct rte_eth_hash_filter_info info;
8514 uint32_t idx, offset, i;
8518 if (rte_eth_dev_filter_supported(res->port_id,
8519 RTE_ETH_FILTER_HASH) < 0) {
8520 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8525 memset(&info, 0, sizeof(info));
8526 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8527 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8528 RTE_ETH_FILTER_GET, &info);
8530 printf("Cannot get hash global configurations by port %d\n",
8535 switch (info.info.global_conf.hash_func) {
8536 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8537 printf("Hash function is Toeplitz\n");
8539 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8540 printf("Hash function is Simple XOR\n");
8543 printf("Unknown hash function\n");
8547 for (i = 0; i < RTE_ETH_FLOW_TYPE_MAX; i++) {
8548 idx = i / UINT32_BIT;
8549 offset = i % UINT32_BIT;
8550 if (!(info.info.global_conf.valid_bit_mask[idx] &
8553 str = flowtype_to_str((enum rte_eth_flow_type)i);
8556 printf("Symmetric hash is %s globally for flow type %s "
8558 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8559 (1UL << offset)) ? "enabled" : "disabled"), str,
8564 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8565 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8566 get_hash_global_config, "get_hash_global_config");
8567 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8568 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8571 cmdline_parse_inst_t cmd_get_hash_global_config = {
8572 .f = cmd_get_hash_global_config_parsed,
8574 .help_str = "get_hash_global_config port_id",
8576 (void *)&cmd_get_hash_global_config_all,
8577 (void *)&cmd_get_hash_global_config_port_id,
8582 /* Set global config of hash function */
8583 struct cmd_set_hash_global_config_result {
8584 cmdline_fixed_string_t set_hash_global_config;
8586 cmdline_fixed_string_t hash_func;
8587 cmdline_fixed_string_t flow_type;
8588 cmdline_fixed_string_t enable;
8592 cmd_set_hash_global_config_parsed(void *parsed_result,
8593 __rte_unused struct cmdline *cl,
8594 __rte_unused void *data)
8596 struct cmd_set_hash_global_config_result *res = parsed_result;
8597 struct rte_eth_hash_filter_info info;
8598 uint32_t ftype, idx, offset;
8601 if (rte_eth_dev_filter_supported(res->port_id,
8602 RTE_ETH_FILTER_HASH) < 0) {
8603 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8607 memset(&info, 0, sizeof(info));
8608 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8609 if (!strcmp(res->hash_func, "toeplitz"))
8610 info.info.global_conf.hash_func =
8611 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8612 else if (!strcmp(res->hash_func, "simple_xor"))
8613 info.info.global_conf.hash_func =
8614 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8615 else if (!strcmp(res->hash_func, "default"))
8616 info.info.global_conf.hash_func =
8617 RTE_ETH_HASH_FUNCTION_DEFAULT;
8619 ftype = str2flowtype(res->flow_type);
8620 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8621 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8622 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8623 if (!strcmp(res->enable, "enable"))
8624 info.info.global_conf.sym_hash_enable_mask[idx] |=
8626 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8627 RTE_ETH_FILTER_SET, &info);
8629 printf("Cannot set global hash configurations by port %d\n",
8632 printf("Global hash configurations have been set "
8633 "succcessfully by port %d\n", res->port_id);
8636 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8637 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8638 set_hash_global_config, "set_hash_global_config");
8639 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8640 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8642 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8643 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8644 hash_func, "toeplitz#simple_xor#default");
8645 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8646 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8648 "ip4#ip4-frag#tcp4#udp4#sctp4#ip6#ip6-frag#tcp6#udp6#sctp6");
8649 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8650 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8651 enable, "enable#disable");
8653 cmdline_parse_inst_t cmd_set_hash_global_config = {
8654 .f = cmd_set_hash_global_config_parsed,
8656 .help_str = "set_hash_global_config port_id "
8657 "toeplitz|simple_xor|default "
8658 "ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6 "
8661 (void *)&cmd_set_hash_global_config_all,
8662 (void *)&cmd_set_hash_global_config_port_id,
8663 (void *)&cmd_set_hash_global_config_hash_func,
8664 (void *)&cmd_set_hash_global_config_flow_type,
8665 (void *)&cmd_set_hash_global_config_enable,
8670 /* ******************************************************************************** */
8672 /* list of instructions */
8673 cmdline_parse_ctx_t main_ctx[] = {
8674 (cmdline_parse_inst_t *)&cmd_help_brief,
8675 (cmdline_parse_inst_t *)&cmd_help_long,
8676 (cmdline_parse_inst_t *)&cmd_quit,
8677 (cmdline_parse_inst_t *)&cmd_showport,
8678 (cmdline_parse_inst_t *)&cmd_showportall,
8679 (cmdline_parse_inst_t *)&cmd_showcfg,
8680 (cmdline_parse_inst_t *)&cmd_start,
8681 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8682 (cmdline_parse_inst_t *)&cmd_set_link_up,
8683 (cmdline_parse_inst_t *)&cmd_set_link_down,
8684 (cmdline_parse_inst_t *)&cmd_reset,
8685 (cmdline_parse_inst_t *)&cmd_set_numbers,
8686 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8687 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8688 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8689 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8690 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8691 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8692 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8693 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8694 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8695 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8696 (cmdline_parse_inst_t *)&cmd_set_link_check,
8697 #ifdef RTE_NIC_BYPASS
8698 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8699 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8700 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8701 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8703 #ifdef RTE_LIBRTE_PMD_BOND
8704 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8705 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8706 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8707 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8708 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8709 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8710 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8711 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8712 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8714 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8715 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8716 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8717 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8718 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8719 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8720 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8721 (cmdline_parse_inst_t *)&cmd_csum_set,
8722 (cmdline_parse_inst_t *)&cmd_csum_show,
8723 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
8724 (cmdline_parse_inst_t *)&cmd_tso_set,
8725 (cmdline_parse_inst_t *)&cmd_tso_show,
8726 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8727 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8728 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8729 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8730 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8731 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8732 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8733 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8734 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8735 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8736 (cmdline_parse_inst_t *)&cmd_config_dcb,
8737 (cmdline_parse_inst_t *)&cmd_read_reg,
8738 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8739 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8740 (cmdline_parse_inst_t *)&cmd_write_reg,
8741 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8742 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8743 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8744 (cmdline_parse_inst_t *)&cmd_stop,
8745 (cmdline_parse_inst_t *)&cmd_mac_addr,
8746 (cmdline_parse_inst_t *)&cmd_set_qmap,
8747 (cmdline_parse_inst_t *)&cmd_operate_port,
8748 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8749 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8750 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8751 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8752 (cmdline_parse_inst_t *)&cmd_config_mtu,
8753 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8754 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8755 (cmdline_parse_inst_t *)&cmd_config_rss,
8756 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8757 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8758 (cmdline_parse_inst_t *)&cmd_showport_reta,
8759 (cmdline_parse_inst_t *)&cmd_config_burst,
8760 (cmdline_parse_inst_t *)&cmd_config_thresh,
8761 (cmdline_parse_inst_t *)&cmd_config_threshold,
8762 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8763 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8764 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8765 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8766 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8767 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8768 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8769 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8770 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8771 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8772 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8773 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8774 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8775 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8776 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8777 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8778 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8779 (cmdline_parse_inst_t *)&cmd_dump,
8780 (cmdline_parse_inst_t *)&cmd_dump_one,
8781 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
8782 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
8783 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
8784 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
8785 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
8786 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
8787 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
8788 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
8789 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
8790 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
8791 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
8792 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
8793 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
8794 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8795 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8796 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8797 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8798 (cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
8799 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8800 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
8801 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
8802 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
8803 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
8804 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
8808 /* prompt function, called from main on MASTER lcore */
8814 /* initialize non-constant commands */
8815 cmd_set_fwd_mode_init();
8817 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8821 cmdline_interact(cl);
8822 cmdline_stdin_exit(cl);
8826 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8828 if (id < nb_ports) {
8829 /* check if need_reconfig has been set to 1 */
8830 if (ports[id].need_reconfig == 0)
8831 ports[id].need_reconfig = dev;
8832 /* check if need_reconfig_queues has been set to 1 */
8833 if (ports[id].need_reconfig_queues == 0)
8834 ports[id].need_reconfig_queues = queue;
8838 for (pid = 0; pid < nb_ports; pid++) {
8839 /* check if need_reconfig has been set to 1 */
8840 if (ports[pid].need_reconfig == 0)
8841 ports[pid].need_reconfig = dev;
8842 /* check if need_reconfig_queues has been set to 1 */
8843 if (ports[pid].need_reconfig_queues == 0)
8844 ports[pid].need_reconfig_queues = queue;
8849 #ifdef RTE_NIC_BYPASS
8851 bypass_is_supported(portid_t port_id)
8853 struct rte_port *port;
8854 struct rte_pci_id *pci_id;
8856 if (port_id >= nb_ports) {
8857 printf("\tPort id must be less than %d.\n", nb_ports);
8861 /* Get the device id. */
8862 port = &ports[port_id];
8863 pci_id = &port->dev_info.pci_dev->id;
8865 /* Check if NIC supports bypass. */
8866 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8870 printf("\tBypass not supported for port_id = %d.\n", port_id);