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 "flex_filter (port_id) (add|del) len (len_value)"
636 " bytes (bytes_value) mask (mask_value)"
637 " priority (prio_value) queue (queue_id)\n"
638 " Add/Del a flex filter.\n\n"
640 "flow_director_filter (port_id) (add|del|update)"
641 " flow (ip4|ip4-frag|ip6|ip6-frag)"
642 " src (src_ip_address) dst (dst_ip_address)"
643 " vlan (vlan_value) flexbytes (flexbytes_value)"
644 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
645 " Add/Del an IP type flow director filter.\n\n"
647 "flow_director_filter (port_id) (add|del|update)"
648 " flow (udp4|tcp4|udp6|tcp6)"
649 " src (src_ip_address) (src_port)"
650 " dst (dst_ip_address) (dst_port)"
651 " vlan (vlan_value) flexbytes (flexbytes_value)"
652 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
653 " Add/Del an UDP/TCP type flow director filter.\n\n"
655 "flow_director_filter (port_id) (add|del|update)"
656 " flow (sctp4|sctp6)"
657 " src (src_ip_address) (src_port)"
658 " dst (dst_ip_address) (dst_port)"
659 " tag (verification_tag) vlan (vlan_value)"
660 " flexbytes (flexbytes_value) (drop|fwd)"
661 " queue (queue_id) fd_id (fd_id_value)\n"
662 " Add/Del a SCTP type flow director filter.\n\n"
664 "flush_flow_director (port_id)\n"
665 " Flush all flow director entries of a device.\n\n"
667 "flow_director_mask (port_id) vlan (vlan_value)"
668 " src_mask (ipv4_src) (ipv6_src) (src_port)"
669 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
670 " Set flow director mask.\n\n"
672 "flow_director_flex_mask (port_id)"
673 " flow (raw|ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
675 " Configure mask of flex payload.\n\n"
677 "flow_director_flex_payload (port_id)"
678 " (raw|l2|l3|l4) (config)\n"
679 " Configure flex payload selection.\n\n"
681 "get_sym_hash_ena_per_port (port_id)\n"
682 " get symmetric hash enable configuration per port.\n\n"
684 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
685 " set symmetric hash enable configuration per port"
686 " to enable or disable.\n\n"
688 "get_hash_global_config (port_id)\n"
689 " Get the global configurations of hash filters.\n\n"
691 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
692 " (ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6)"
693 " (enable|disable)\n"
694 " Set the global configurations of hash filters.\n\n"
699 cmdline_parse_token_string_t cmd_help_long_help =
700 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
702 cmdline_parse_token_string_t cmd_help_long_section =
703 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
704 "all#control#display#config#"
705 "ports#registers#filters");
707 cmdline_parse_inst_t cmd_help_long = {
708 .f = cmd_help_long_parsed,
710 .help_str = "show help",
712 (void *)&cmd_help_long_help,
713 (void *)&cmd_help_long_section,
719 /* *** start/stop/close all ports *** */
720 struct cmd_operate_port_result {
721 cmdline_fixed_string_t keyword;
722 cmdline_fixed_string_t name;
723 cmdline_fixed_string_t value;
726 static void cmd_operate_port_parsed(void *parsed_result,
727 __attribute__((unused)) struct cmdline *cl,
728 __attribute__((unused)) void *data)
730 struct cmd_operate_port_result *res = parsed_result;
732 if (!strcmp(res->name, "start"))
733 start_port(RTE_PORT_ALL);
734 else if (!strcmp(res->name, "stop"))
735 stop_port(RTE_PORT_ALL);
736 else if (!strcmp(res->name, "close"))
737 close_port(RTE_PORT_ALL);
739 printf("Unknown parameter\n");
742 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
743 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
745 cmdline_parse_token_string_t cmd_operate_port_all_port =
746 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
748 cmdline_parse_token_string_t cmd_operate_port_all_all =
749 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
751 cmdline_parse_inst_t cmd_operate_port = {
752 .f = cmd_operate_port_parsed,
754 .help_str = "port start|stop|close all: start/stop/close all ports",
756 (void *)&cmd_operate_port_all_cmd,
757 (void *)&cmd_operate_port_all_port,
758 (void *)&cmd_operate_port_all_all,
763 /* *** start/stop/close specific port *** */
764 struct cmd_operate_specific_port_result {
765 cmdline_fixed_string_t keyword;
766 cmdline_fixed_string_t name;
770 static void cmd_operate_specific_port_parsed(void *parsed_result,
771 __attribute__((unused)) struct cmdline *cl,
772 __attribute__((unused)) void *data)
774 struct cmd_operate_specific_port_result *res = parsed_result;
776 if (!strcmp(res->name, "start"))
777 start_port(res->value);
778 else if (!strcmp(res->name, "stop"))
779 stop_port(res->value);
780 else if (!strcmp(res->name, "close"))
781 close_port(res->value);
783 printf("Unknown parameter\n");
786 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
787 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
789 cmdline_parse_token_string_t cmd_operate_specific_port_port =
790 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
791 name, "start#stop#close");
792 cmdline_parse_token_num_t cmd_operate_specific_port_id =
793 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
796 cmdline_parse_inst_t cmd_operate_specific_port = {
797 .f = cmd_operate_specific_port_parsed,
799 .help_str = "port start|stop|close X: start/stop/close port X",
801 (void *)&cmd_operate_specific_port_cmd,
802 (void *)&cmd_operate_specific_port_port,
803 (void *)&cmd_operate_specific_port_id,
808 /* *** configure speed for all ports *** */
809 struct cmd_config_speed_all {
810 cmdline_fixed_string_t port;
811 cmdline_fixed_string_t keyword;
812 cmdline_fixed_string_t all;
813 cmdline_fixed_string_t item1;
814 cmdline_fixed_string_t item2;
815 cmdline_fixed_string_t value1;
816 cmdline_fixed_string_t value2;
820 cmd_config_speed_all_parsed(void *parsed_result,
821 __attribute__((unused)) struct cmdline *cl,
822 __attribute__((unused)) void *data)
824 struct cmd_config_speed_all *res = parsed_result;
825 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
826 uint16_t link_duplex = 0;
829 if (!all_ports_stopped()) {
830 printf("Please stop all ports first\n");
834 if (!strcmp(res->value1, "10"))
835 link_speed = ETH_LINK_SPEED_10;
836 else if (!strcmp(res->value1, "100"))
837 link_speed = ETH_LINK_SPEED_100;
838 else if (!strcmp(res->value1, "1000"))
839 link_speed = ETH_LINK_SPEED_1000;
840 else if (!strcmp(res->value1, "10000"))
841 link_speed = ETH_LINK_SPEED_10G;
842 else if (!strcmp(res->value1, "40000"))
843 link_speed = ETH_LINK_SPEED_40G;
844 else if (!strcmp(res->value1, "auto"))
845 link_speed = ETH_LINK_SPEED_AUTONEG;
847 printf("Unknown parameter\n");
851 if (!strcmp(res->value2, "half"))
852 link_duplex = ETH_LINK_HALF_DUPLEX;
853 else if (!strcmp(res->value2, "full"))
854 link_duplex = ETH_LINK_FULL_DUPLEX;
855 else if (!strcmp(res->value2, "auto"))
856 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
858 printf("Unknown parameter\n");
862 for (pid = 0; pid < nb_ports; pid++) {
863 ports[pid].dev_conf.link_speed = link_speed;
864 ports[pid].dev_conf.link_duplex = link_duplex;
867 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
870 cmdline_parse_token_string_t cmd_config_speed_all_port =
871 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
872 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
873 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
875 cmdline_parse_token_string_t cmd_config_speed_all_all =
876 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
877 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
878 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
879 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
880 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
881 "10#100#1000#10000#40000#auto");
882 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
883 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
884 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
885 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
888 cmdline_parse_inst_t cmd_config_speed_all = {
889 .f = cmd_config_speed_all_parsed,
891 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
894 (void *)&cmd_config_speed_all_port,
895 (void *)&cmd_config_speed_all_keyword,
896 (void *)&cmd_config_speed_all_all,
897 (void *)&cmd_config_speed_all_item1,
898 (void *)&cmd_config_speed_all_value1,
899 (void *)&cmd_config_speed_all_item2,
900 (void *)&cmd_config_speed_all_value2,
905 /* *** configure speed for specific port *** */
906 struct cmd_config_speed_specific {
907 cmdline_fixed_string_t port;
908 cmdline_fixed_string_t keyword;
910 cmdline_fixed_string_t item1;
911 cmdline_fixed_string_t item2;
912 cmdline_fixed_string_t value1;
913 cmdline_fixed_string_t value2;
917 cmd_config_speed_specific_parsed(void *parsed_result,
918 __attribute__((unused)) struct cmdline *cl,
919 __attribute__((unused)) void *data)
921 struct cmd_config_speed_specific *res = parsed_result;
922 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
923 uint16_t link_duplex = 0;
925 if (!all_ports_stopped()) {
926 printf("Please stop all ports first\n");
930 if (res->id >= nb_ports) {
931 printf("Port id %d must be less than %d\n", res->id, nb_ports);
935 if (!strcmp(res->value1, "10"))
936 link_speed = ETH_LINK_SPEED_10;
937 else if (!strcmp(res->value1, "100"))
938 link_speed = ETH_LINK_SPEED_100;
939 else if (!strcmp(res->value1, "1000"))
940 link_speed = ETH_LINK_SPEED_1000;
941 else if (!strcmp(res->value1, "10000"))
942 link_speed = ETH_LINK_SPEED_10000;
943 else if (!strcmp(res->value1, "40000"))
944 link_speed = ETH_LINK_SPEED_40G;
945 else if (!strcmp(res->value1, "auto"))
946 link_speed = ETH_LINK_SPEED_AUTONEG;
948 printf("Unknown parameter\n");
952 if (!strcmp(res->value2, "half"))
953 link_duplex = ETH_LINK_HALF_DUPLEX;
954 else if (!strcmp(res->value2, "full"))
955 link_duplex = ETH_LINK_FULL_DUPLEX;
956 else if (!strcmp(res->value2, "auto"))
957 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
959 printf("Unknown parameter\n");
963 ports[res->id].dev_conf.link_speed = link_speed;
964 ports[res->id].dev_conf.link_duplex = link_duplex;
966 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
970 cmdline_parse_token_string_t cmd_config_speed_specific_port =
971 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
973 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
974 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
976 cmdline_parse_token_num_t cmd_config_speed_specific_id =
977 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
978 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
979 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
981 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
982 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
983 "10#100#1000#10000#40000#auto");
984 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
985 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
987 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
988 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
991 cmdline_parse_inst_t cmd_config_speed_specific = {
992 .f = cmd_config_speed_specific_parsed,
994 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
997 (void *)&cmd_config_speed_specific_port,
998 (void *)&cmd_config_speed_specific_keyword,
999 (void *)&cmd_config_speed_specific_id,
1000 (void *)&cmd_config_speed_specific_item1,
1001 (void *)&cmd_config_speed_specific_value1,
1002 (void *)&cmd_config_speed_specific_item2,
1003 (void *)&cmd_config_speed_specific_value2,
1008 /* *** configure txq/rxq, txd/rxd *** */
1009 struct cmd_config_rx_tx {
1010 cmdline_fixed_string_t port;
1011 cmdline_fixed_string_t keyword;
1012 cmdline_fixed_string_t all;
1013 cmdline_fixed_string_t name;
1018 cmd_config_rx_tx_parsed(void *parsed_result,
1019 __attribute__((unused)) struct cmdline *cl,
1020 __attribute__((unused)) void *data)
1022 struct cmd_config_rx_tx *res = parsed_result;
1024 if (!all_ports_stopped()) {
1025 printf("Please stop all ports first\n");
1029 if (!strcmp(res->name, "rxq")) {
1030 if (res->value <= 0) {
1031 printf("rxq %d invalid - must be > 0\n", res->value);
1034 nb_rxq = res->value;
1036 else if (!strcmp(res->name, "txq")) {
1037 if (res->value <= 0) {
1038 printf("txq %d invalid - must be > 0\n", res->value);
1041 nb_txq = res->value;
1043 else if (!strcmp(res->name, "rxd")) {
1044 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1045 printf("rxd %d invalid - must be > 0 && <= %d\n",
1046 res->value, RTE_TEST_RX_DESC_MAX);
1049 nb_rxd = res->value;
1050 } else if (!strcmp(res->name, "txd")) {
1051 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1052 printf("txd %d invalid - must be > 0 && <= %d\n",
1053 res->value, RTE_TEST_TX_DESC_MAX);
1056 nb_txd = res->value;
1058 printf("Unknown parameter\n");
1064 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1067 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1068 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1069 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1070 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1071 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1072 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1073 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1074 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1076 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1077 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1079 cmdline_parse_inst_t cmd_config_rx_tx = {
1080 .f = cmd_config_rx_tx_parsed,
1082 .help_str = "port config all rxq|txq|rxd|txd value",
1084 (void *)&cmd_config_rx_tx_port,
1085 (void *)&cmd_config_rx_tx_keyword,
1086 (void *)&cmd_config_rx_tx_all,
1087 (void *)&cmd_config_rx_tx_name,
1088 (void *)&cmd_config_rx_tx_value,
1093 /* *** config max packet length *** */
1094 struct cmd_config_max_pkt_len_result {
1095 cmdline_fixed_string_t port;
1096 cmdline_fixed_string_t keyword;
1097 cmdline_fixed_string_t all;
1098 cmdline_fixed_string_t name;
1103 cmd_config_max_pkt_len_parsed(void *parsed_result,
1104 __attribute__((unused)) struct cmdline *cl,
1105 __attribute__((unused)) void *data)
1107 struct cmd_config_max_pkt_len_result *res = parsed_result;
1109 if (!all_ports_stopped()) {
1110 printf("Please stop all ports first\n");
1114 if (!strcmp(res->name, "max-pkt-len")) {
1115 if (res->value < ETHER_MIN_LEN) {
1116 printf("max-pkt-len can not be less than %d\n",
1120 if (res->value == rx_mode.max_rx_pkt_len)
1123 rx_mode.max_rx_pkt_len = res->value;
1124 if (res->value > ETHER_MAX_LEN)
1125 rx_mode.jumbo_frame = 1;
1127 rx_mode.jumbo_frame = 0;
1129 printf("Unknown parameter\n");
1135 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1138 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1139 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1141 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1142 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1144 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1145 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1147 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1148 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1150 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1151 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1154 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1155 .f = cmd_config_max_pkt_len_parsed,
1157 .help_str = "port config all max-pkt-len value",
1159 (void *)&cmd_config_max_pkt_len_port,
1160 (void *)&cmd_config_max_pkt_len_keyword,
1161 (void *)&cmd_config_max_pkt_len_all,
1162 (void *)&cmd_config_max_pkt_len_name,
1163 (void *)&cmd_config_max_pkt_len_value,
1168 /* *** configure port MTU *** */
1169 struct cmd_config_mtu_result {
1170 cmdline_fixed_string_t port;
1171 cmdline_fixed_string_t keyword;
1172 cmdline_fixed_string_t mtu;
1178 cmd_config_mtu_parsed(void *parsed_result,
1179 __attribute__((unused)) struct cmdline *cl,
1180 __attribute__((unused)) void *data)
1182 struct cmd_config_mtu_result *res = parsed_result;
1184 if (res->value < ETHER_MIN_LEN) {
1185 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1188 port_mtu_set(res->port_id, res->value);
1191 cmdline_parse_token_string_t cmd_config_mtu_port =
1192 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1194 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1195 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1197 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1198 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1200 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1201 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1202 cmdline_parse_token_num_t cmd_config_mtu_value =
1203 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1205 cmdline_parse_inst_t cmd_config_mtu = {
1206 .f = cmd_config_mtu_parsed,
1208 .help_str = "port config mtu value",
1210 (void *)&cmd_config_mtu_port,
1211 (void *)&cmd_config_mtu_keyword,
1212 (void *)&cmd_config_mtu_mtu,
1213 (void *)&cmd_config_mtu_port_id,
1214 (void *)&cmd_config_mtu_value,
1219 /* *** configure rx mode *** */
1220 struct cmd_config_rx_mode_flag {
1221 cmdline_fixed_string_t port;
1222 cmdline_fixed_string_t keyword;
1223 cmdline_fixed_string_t all;
1224 cmdline_fixed_string_t name;
1225 cmdline_fixed_string_t value;
1229 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1230 __attribute__((unused)) struct cmdline *cl,
1231 __attribute__((unused)) void *data)
1233 struct cmd_config_rx_mode_flag *res = parsed_result;
1235 if (!all_ports_stopped()) {
1236 printf("Please stop all ports first\n");
1240 if (!strcmp(res->name, "crc-strip")) {
1241 if (!strcmp(res->value, "on"))
1242 rx_mode.hw_strip_crc = 1;
1243 else if (!strcmp(res->value, "off"))
1244 rx_mode.hw_strip_crc = 0;
1246 printf("Unknown parameter\n");
1249 } else if (!strcmp(res->name, "rx-cksum")) {
1250 if (!strcmp(res->value, "on"))
1251 rx_mode.hw_ip_checksum = 1;
1252 else if (!strcmp(res->value, "off"))
1253 rx_mode.hw_ip_checksum = 0;
1255 printf("Unknown parameter\n");
1258 } else if (!strcmp(res->name, "hw-vlan")) {
1259 if (!strcmp(res->value, "on")) {
1260 rx_mode.hw_vlan_filter = 1;
1261 rx_mode.hw_vlan_strip = 1;
1263 else if (!strcmp(res->value, "off")) {
1264 rx_mode.hw_vlan_filter = 0;
1265 rx_mode.hw_vlan_strip = 0;
1268 printf("Unknown parameter\n");
1271 } else if (!strcmp(res->name, "drop-en")) {
1272 if (!strcmp(res->value, "on"))
1274 else if (!strcmp(res->value, "off"))
1277 printf("Unknown parameter\n");
1281 printf("Unknown parameter\n");
1287 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1290 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1291 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1292 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1293 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1295 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1296 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1297 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1298 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1299 "crc-strip#rx-cksum#hw-vlan");
1300 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1301 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1304 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1305 .f = cmd_config_rx_mode_flag_parsed,
1307 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1309 (void *)&cmd_config_rx_mode_flag_port,
1310 (void *)&cmd_config_rx_mode_flag_keyword,
1311 (void *)&cmd_config_rx_mode_flag_all,
1312 (void *)&cmd_config_rx_mode_flag_name,
1313 (void *)&cmd_config_rx_mode_flag_value,
1318 /* *** configure rss *** */
1319 struct cmd_config_rss {
1320 cmdline_fixed_string_t port;
1321 cmdline_fixed_string_t keyword;
1322 cmdline_fixed_string_t all;
1323 cmdline_fixed_string_t name;
1324 cmdline_fixed_string_t value;
1328 cmd_config_rss_parsed(void *parsed_result,
1329 __attribute__((unused)) struct cmdline *cl,
1330 __attribute__((unused)) void *data)
1332 struct cmd_config_rss *res = parsed_result;
1333 struct rte_eth_rss_conf rss_conf;
1336 if (!strcmp(res->value, "ip"))
1337 rss_conf.rss_hf = ETH_RSS_IP;
1338 else if (!strcmp(res->value, "udp"))
1339 rss_conf.rss_hf = ETH_RSS_UDP;
1340 else if (!strcmp(res->value, "none"))
1341 rss_conf.rss_hf = 0;
1343 printf("Unknown parameter\n");
1346 rss_conf.rss_key = NULL;
1347 for (i = 0; i < rte_eth_dev_count(); i++)
1348 rte_eth_dev_rss_hash_update(i, &rss_conf);
1351 cmdline_parse_token_string_t cmd_config_rss_port =
1352 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1353 cmdline_parse_token_string_t cmd_config_rss_keyword =
1354 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1355 cmdline_parse_token_string_t cmd_config_rss_all =
1356 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1357 cmdline_parse_token_string_t cmd_config_rss_name =
1358 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1359 cmdline_parse_token_string_t cmd_config_rss_value =
1360 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1362 cmdline_parse_inst_t cmd_config_rss = {
1363 .f = cmd_config_rss_parsed,
1365 .help_str = "port config all rss ip|udp|none",
1367 (void *)&cmd_config_rss_port,
1368 (void *)&cmd_config_rss_keyword,
1369 (void *)&cmd_config_rss_all,
1370 (void *)&cmd_config_rss_name,
1371 (void *)&cmd_config_rss_value,
1376 /* *** configure rss hash key *** */
1377 struct cmd_config_rss_hash_key {
1378 cmdline_fixed_string_t port;
1379 cmdline_fixed_string_t config;
1381 cmdline_fixed_string_t rss_hash_key;
1382 cmdline_fixed_string_t key;
1385 #define RSS_HASH_KEY_LENGTH 40
1387 hexa_digit_to_value(char hexa_digit)
1389 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1390 return (uint8_t) (hexa_digit - '0');
1391 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1392 return (uint8_t) ((hexa_digit - 'a') + 10);
1393 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1394 return (uint8_t) ((hexa_digit - 'A') + 10);
1395 /* Invalid hexa digit */
1400 parse_and_check_key_hexa_digit(char *key, int idx)
1404 hexa_v = hexa_digit_to_value(key[idx]);
1406 printf("invalid key: character %c at position %d is not a "
1407 "valid hexa digit\n", key[idx], idx);
1412 cmd_config_rss_hash_key_parsed(void *parsed_result,
1413 __attribute__((unused)) struct cmdline *cl,
1414 __attribute__((unused)) void *data)
1416 struct cmd_config_rss_hash_key *res = parsed_result;
1417 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1422 /* Check the length of the RSS hash key */
1423 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1424 printf("key length: %d invalid - key must be a string of %d"
1425 "hexa-decimal numbers\n", (int) strlen(res->key),
1426 RSS_HASH_KEY_LENGTH * 2);
1429 /* Translate RSS hash key into binary representation */
1430 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1431 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1434 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1437 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1439 port_rss_hash_key_update(res->port_id, hash_key);
1442 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1443 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1444 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1445 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1447 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1448 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1449 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1450 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1451 rss_hash_key, "rss-hash-key");
1452 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1453 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1455 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1456 .f = cmd_config_rss_hash_key_parsed,
1458 .help_str = "port config X rss-hash-key 80 hexa digits",
1460 (void *)&cmd_config_rss_hash_key_port,
1461 (void *)&cmd_config_rss_hash_key_config,
1462 (void *)&cmd_config_rss_hash_key_port_id,
1463 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1464 (void *)&cmd_config_rss_hash_key_value,
1469 /* *** configure port rxq/txq start/stop *** */
1470 struct cmd_config_rxtx_queue {
1471 cmdline_fixed_string_t port;
1473 cmdline_fixed_string_t rxtxq;
1475 cmdline_fixed_string_t opname;
1479 cmd_config_rxtx_queue_parsed(void *parsed_result,
1480 __attribute__((unused)) struct cmdline *cl,
1481 __attribute__((unused)) void *data)
1483 struct cmd_config_rxtx_queue *res = parsed_result;
1488 if (test_done == 0) {
1489 printf("Please stop forwarding first\n");
1493 if (port_id_is_invalid(res->portid))
1496 if (port_is_started(res->portid) != 1) {
1497 printf("Please start port %u first\n", res->portid);
1501 if (!strcmp(res->rxtxq, "rxq"))
1503 else if (!strcmp(res->rxtxq, "txq"))
1506 printf("Unknown parameter\n");
1510 if (isrx && rx_queue_id_is_invalid(res->qid))
1512 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1515 if (!strcmp(res->opname, "start"))
1517 else if (!strcmp(res->opname, "stop"))
1520 printf("Unknown parameter\n");
1524 if (isstart && isrx)
1525 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1526 else if (!isstart && isrx)
1527 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1528 else if (isstart && !isrx)
1529 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1531 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1533 if (ret == -ENOTSUP)
1534 printf("Function not supported in PMD driver\n");
1537 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1538 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1539 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1540 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1541 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1542 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1543 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1544 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1545 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1546 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1549 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1550 .f = cmd_config_rxtx_queue_parsed,
1552 .help_str = "port X rxq|txq ID start|stop",
1554 (void *)&cmd_config_speed_all_port,
1555 (void *)&cmd_config_rxtx_queue_portid,
1556 (void *)&cmd_config_rxtx_queue_rxtxq,
1557 (void *)&cmd_config_rxtx_queue_qid,
1558 (void *)&cmd_config_rxtx_queue_opname,
1563 /* *** Configure RSS RETA *** */
1564 struct cmd_config_rss_reta {
1565 cmdline_fixed_string_t port;
1566 cmdline_fixed_string_t keyword;
1568 cmdline_fixed_string_t name;
1569 cmdline_fixed_string_t list_name;
1570 cmdline_fixed_string_t list_of_items;
1574 parse_reta_config(const char *str,
1575 struct rte_eth_rss_reta_entry64 *reta_conf,
1576 uint16_t nb_entries)
1580 uint16_t hash_index, idx, shift;
1583 const char *p, *p0 = str;
1590 unsigned long int_fld[_NUM_FLD];
1591 char *str_fld[_NUM_FLD];
1593 while ((p = strchr(p0,'(')) != NULL) {
1595 if((p0 = strchr(p,')')) == NULL)
1599 if(size >= sizeof(s))
1602 snprintf(s, sizeof(s), "%.*s", size, p);
1603 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1605 for (i = 0; i < _NUM_FLD; i++) {
1607 int_fld[i] = strtoul(str_fld[i], &end, 0);
1608 if (errno != 0 || end == str_fld[i] ||
1613 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1614 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1616 if (hash_index >= nb_entries) {
1617 printf("Invalid RETA hash index=%d\n", hash_index);
1621 idx = hash_index / RTE_RETA_GROUP_SIZE;
1622 shift = hash_index % RTE_RETA_GROUP_SIZE;
1623 reta_conf[idx].mask |= (1ULL << shift);
1624 reta_conf[idx].reta[shift] = nb_queue;
1631 cmd_set_rss_reta_parsed(void *parsed_result,
1632 __attribute__((unused)) struct cmdline *cl,
1633 __attribute__((unused)) void *data)
1636 struct rte_eth_dev_info dev_info;
1637 struct rte_eth_rss_reta_entry64 reta_conf[8];
1638 struct cmd_config_rss_reta *res = parsed_result;
1640 memset(&dev_info, 0, sizeof(dev_info));
1641 rte_eth_dev_info_get(res->port_id, &dev_info);
1642 if (dev_info.reta_size == 0) {
1643 printf("Redirection table size is 0 which is "
1644 "invalid for RSS\n");
1647 printf("The reta size of port %d is %u\n",
1648 res->port_id, dev_info.reta_size);
1649 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1650 printf("Currently do not support more than %u entries of "
1651 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1655 memset(reta_conf, 0, sizeof(reta_conf));
1656 if (!strcmp(res->list_name, "reta")) {
1657 if (parse_reta_config(res->list_of_items, reta_conf,
1658 dev_info.reta_size)) {
1659 printf("Invalid RSS Redirection Table "
1660 "config entered\n");
1663 ret = rte_eth_dev_rss_reta_update(res->port_id,
1664 reta_conf, dev_info.reta_size);
1666 printf("Bad redirection table parameter, "
1667 "return code = %d \n", ret);
1671 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1673 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1675 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1676 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1677 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1678 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1679 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1680 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1681 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1682 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1684 cmdline_parse_inst_t cmd_config_rss_reta = {
1685 .f = cmd_set_rss_reta_parsed,
1687 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1689 (void *)&cmd_config_rss_reta_port,
1690 (void *)&cmd_config_rss_reta_keyword,
1691 (void *)&cmd_config_rss_reta_port_id,
1692 (void *)&cmd_config_rss_reta_name,
1693 (void *)&cmd_config_rss_reta_list_name,
1694 (void *)&cmd_config_rss_reta_list_of_items,
1699 /* *** SHOW PORT RETA INFO *** */
1700 struct cmd_showport_reta {
1701 cmdline_fixed_string_t show;
1702 cmdline_fixed_string_t port;
1704 cmdline_fixed_string_t rss;
1705 cmdline_fixed_string_t reta;
1707 cmdline_fixed_string_t list_of_items;
1711 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1712 uint16_t nb_entries,
1716 const char *p, *p0 = str;
1720 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1723 p = strchr(p0, '(');
1727 p0 = strchr(p, ')');
1731 if (size >= sizeof(s)) {
1732 printf("The string size exceeds the internal buffer size\n");
1735 snprintf(s, sizeof(s), "%.*s", size, p);
1736 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1737 if (ret <= 0 || ret != num) {
1738 printf("The bits of masks do not match the number of "
1739 "reta entries: %u\n", num);
1742 for (i = 0; i < ret; i++)
1743 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1749 cmd_showport_reta_parsed(void *parsed_result,
1750 __attribute__((unused)) struct cmdline *cl,
1751 __attribute__((unused)) void *data)
1753 struct cmd_showport_reta *res = parsed_result;
1754 struct rte_eth_rss_reta_entry64 reta_conf[8];
1755 struct rte_eth_dev_info dev_info;
1757 memset(&dev_info, 0, sizeof(dev_info));
1758 rte_eth_dev_info_get(res->port_id, &dev_info);
1759 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1760 res->size > ETH_RSS_RETA_SIZE_512) {
1761 printf("Invalid redirection table size: %u\n", res->size);
1765 memset(reta_conf, 0, sizeof(reta_conf));
1766 if (showport_parse_reta_config(reta_conf, res->size,
1767 res->list_of_items) < 0) {
1768 printf("Invalid string: %s for reta masks\n",
1769 res->list_of_items);
1772 port_rss_reta_info(res->port_id, reta_conf, res->size);
1775 cmdline_parse_token_string_t cmd_showport_reta_show =
1776 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1777 cmdline_parse_token_string_t cmd_showport_reta_port =
1778 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1779 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1780 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1781 cmdline_parse_token_string_t cmd_showport_reta_rss =
1782 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1783 cmdline_parse_token_string_t cmd_showport_reta_reta =
1784 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1785 cmdline_parse_token_num_t cmd_showport_reta_size =
1786 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1787 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1788 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1789 list_of_items, NULL);
1791 cmdline_parse_inst_t cmd_showport_reta = {
1792 .f = cmd_showport_reta_parsed,
1794 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1796 (void *)&cmd_showport_reta_show,
1797 (void *)&cmd_showport_reta_port,
1798 (void *)&cmd_showport_reta_port_id,
1799 (void *)&cmd_showport_reta_rss,
1800 (void *)&cmd_showport_reta_reta,
1801 (void *)&cmd_showport_reta_size,
1802 (void *)&cmd_showport_reta_list_of_items,
1807 /* *** Show RSS hash configuration *** */
1808 struct cmd_showport_rss_hash {
1809 cmdline_fixed_string_t show;
1810 cmdline_fixed_string_t port;
1812 cmdline_fixed_string_t rss_hash;
1813 cmdline_fixed_string_t key; /* optional argument */
1816 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1817 __attribute__((unused)) struct cmdline *cl,
1820 struct cmd_showport_rss_hash *res = parsed_result;
1822 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1825 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1826 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1827 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1828 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1829 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1830 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1831 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1832 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1834 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1835 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1837 cmdline_parse_inst_t cmd_showport_rss_hash = {
1838 .f = cmd_showport_rss_hash_parsed,
1840 .help_str = "show port X rss-hash (X = port number)\n",
1842 (void *)&cmd_showport_rss_hash_show,
1843 (void *)&cmd_showport_rss_hash_port,
1844 (void *)&cmd_showport_rss_hash_port_id,
1845 (void *)&cmd_showport_rss_hash_rss_hash,
1850 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1851 .f = cmd_showport_rss_hash_parsed,
1853 .help_str = "show port X rss-hash key (X = port number)\n",
1855 (void *)&cmd_showport_rss_hash_show,
1856 (void *)&cmd_showport_rss_hash_port,
1857 (void *)&cmd_showport_rss_hash_port_id,
1858 (void *)&cmd_showport_rss_hash_rss_hash,
1859 (void *)&cmd_showport_rss_hash_rss_key,
1864 /* *** Configure DCB *** */
1865 struct cmd_config_dcb {
1866 cmdline_fixed_string_t port;
1867 cmdline_fixed_string_t config;
1869 cmdline_fixed_string_t dcb;
1870 cmdline_fixed_string_t vt;
1871 cmdline_fixed_string_t vt_en;
1873 cmdline_fixed_string_t pfc;
1874 cmdline_fixed_string_t pfc_en;
1878 cmd_config_dcb_parsed(void *parsed_result,
1879 __attribute__((unused)) struct cmdline *cl,
1880 __attribute__((unused)) void *data)
1882 struct cmd_config_dcb *res = parsed_result;
1883 struct dcb_config dcb_conf;
1884 portid_t port_id = res->port_id;
1885 struct rte_port *port;
1887 port = &ports[port_id];
1888 /** Check if the port is not started **/
1889 if (port->port_status != RTE_PORT_STOPPED) {
1890 printf("Please stop port %d first\n",port_id);
1894 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1895 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1896 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1900 /* DCB in VT mode */
1901 if (!strncmp(res->vt_en, "on",2))
1902 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1904 dcb_conf.dcb_mode = DCB_ENABLED;
1906 if (!strncmp(res->pfc_en, "on",2)) {
1907 dcb_conf.pfc_en = 1;
1910 dcb_conf.pfc_en = 0;
1912 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1913 printf("Cannot initialize network ports\n");
1917 cmd_reconfig_device_queue(port_id, 1, 1);
1920 cmdline_parse_token_string_t cmd_config_dcb_port =
1921 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1922 cmdline_parse_token_string_t cmd_config_dcb_config =
1923 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1924 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1925 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1926 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1927 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1928 cmdline_parse_token_string_t cmd_config_dcb_vt =
1929 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1930 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1931 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1932 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1933 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1934 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1935 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1936 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1937 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1939 cmdline_parse_inst_t cmd_config_dcb = {
1940 .f = cmd_config_dcb_parsed,
1942 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1944 (void *)&cmd_config_dcb_port,
1945 (void *)&cmd_config_dcb_config,
1946 (void *)&cmd_config_dcb_port_id,
1947 (void *)&cmd_config_dcb_dcb,
1948 (void *)&cmd_config_dcb_vt,
1949 (void *)&cmd_config_dcb_vt_en,
1950 (void *)&cmd_config_dcb_num_tcs,
1951 (void *)&cmd_config_dcb_pfc,
1952 (void *)&cmd_config_dcb_pfc_en,
1957 /* *** configure number of packets per burst *** */
1958 struct cmd_config_burst {
1959 cmdline_fixed_string_t port;
1960 cmdline_fixed_string_t keyword;
1961 cmdline_fixed_string_t all;
1962 cmdline_fixed_string_t name;
1967 cmd_config_burst_parsed(void *parsed_result,
1968 __attribute__((unused)) struct cmdline *cl,
1969 __attribute__((unused)) void *data)
1971 struct cmd_config_burst *res = parsed_result;
1973 if (!all_ports_stopped()) {
1974 printf("Please stop all ports first\n");
1978 if (!strcmp(res->name, "burst")) {
1979 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1980 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1983 nb_pkt_per_burst = res->value;
1985 printf("Unknown parameter\n");
1991 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1994 cmdline_parse_token_string_t cmd_config_burst_port =
1995 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1996 cmdline_parse_token_string_t cmd_config_burst_keyword =
1997 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1998 cmdline_parse_token_string_t cmd_config_burst_all =
1999 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2000 cmdline_parse_token_string_t cmd_config_burst_name =
2001 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2002 cmdline_parse_token_num_t cmd_config_burst_value =
2003 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2005 cmdline_parse_inst_t cmd_config_burst = {
2006 .f = cmd_config_burst_parsed,
2008 .help_str = "port config all burst value",
2010 (void *)&cmd_config_burst_port,
2011 (void *)&cmd_config_burst_keyword,
2012 (void *)&cmd_config_burst_all,
2013 (void *)&cmd_config_burst_name,
2014 (void *)&cmd_config_burst_value,
2019 /* *** configure rx/tx queues *** */
2020 struct cmd_config_thresh {
2021 cmdline_fixed_string_t port;
2022 cmdline_fixed_string_t keyword;
2023 cmdline_fixed_string_t all;
2024 cmdline_fixed_string_t name;
2029 cmd_config_thresh_parsed(void *parsed_result,
2030 __attribute__((unused)) struct cmdline *cl,
2031 __attribute__((unused)) void *data)
2033 struct cmd_config_thresh *res = parsed_result;
2035 if (!all_ports_stopped()) {
2036 printf("Please stop all ports first\n");
2040 if (!strcmp(res->name, "txpt"))
2041 tx_pthresh = res->value;
2042 else if(!strcmp(res->name, "txht"))
2043 tx_hthresh = res->value;
2044 else if(!strcmp(res->name, "txwt"))
2045 tx_wthresh = res->value;
2046 else if(!strcmp(res->name, "rxpt"))
2047 rx_pthresh = res->value;
2048 else if(!strcmp(res->name, "rxht"))
2049 rx_hthresh = res->value;
2050 else if(!strcmp(res->name, "rxwt"))
2051 rx_wthresh = res->value;
2053 printf("Unknown parameter\n");
2059 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2062 cmdline_parse_token_string_t cmd_config_thresh_port =
2063 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2064 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2066 cmdline_parse_token_string_t cmd_config_thresh_all =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2068 cmdline_parse_token_string_t cmd_config_thresh_name =
2069 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2070 "txpt#txht#txwt#rxpt#rxht#rxwt");
2071 cmdline_parse_token_num_t cmd_config_thresh_value =
2072 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2074 cmdline_parse_inst_t cmd_config_thresh = {
2075 .f = cmd_config_thresh_parsed,
2077 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2079 (void *)&cmd_config_thresh_port,
2080 (void *)&cmd_config_thresh_keyword,
2081 (void *)&cmd_config_thresh_all,
2082 (void *)&cmd_config_thresh_name,
2083 (void *)&cmd_config_thresh_value,
2088 /* *** configure free/rs threshold *** */
2089 struct cmd_config_threshold {
2090 cmdline_fixed_string_t port;
2091 cmdline_fixed_string_t keyword;
2092 cmdline_fixed_string_t all;
2093 cmdline_fixed_string_t name;
2098 cmd_config_threshold_parsed(void *parsed_result,
2099 __attribute__((unused)) struct cmdline *cl,
2100 __attribute__((unused)) void *data)
2102 struct cmd_config_threshold *res = parsed_result;
2104 if (!all_ports_stopped()) {
2105 printf("Please stop all ports first\n");
2109 if (!strcmp(res->name, "txfreet"))
2110 tx_free_thresh = res->value;
2111 else if (!strcmp(res->name, "txrst"))
2112 tx_rs_thresh = res->value;
2113 else if (!strcmp(res->name, "rxfreet"))
2114 rx_free_thresh = res->value;
2116 printf("Unknown parameter\n");
2122 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2125 cmdline_parse_token_string_t cmd_config_threshold_port =
2126 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2127 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2128 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2130 cmdline_parse_token_string_t cmd_config_threshold_all =
2131 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2132 cmdline_parse_token_string_t cmd_config_threshold_name =
2133 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2134 "txfreet#txrst#rxfreet");
2135 cmdline_parse_token_num_t cmd_config_threshold_value =
2136 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2138 cmdline_parse_inst_t cmd_config_threshold = {
2139 .f = cmd_config_threshold_parsed,
2141 .help_str = "port config all txfreet|txrst|rxfreet value",
2143 (void *)&cmd_config_threshold_port,
2144 (void *)&cmd_config_threshold_keyword,
2145 (void *)&cmd_config_threshold_all,
2146 (void *)&cmd_config_threshold_name,
2147 (void *)&cmd_config_threshold_value,
2153 struct cmd_stop_result {
2154 cmdline_fixed_string_t stop;
2157 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2158 __attribute__((unused)) struct cmdline *cl,
2159 __attribute__((unused)) void *data)
2161 stop_packet_forwarding();
2164 cmdline_parse_token_string_t cmd_stop_stop =
2165 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2167 cmdline_parse_inst_t cmd_stop = {
2168 .f = cmd_stop_parsed,
2170 .help_str = "stop - stop packet forwarding",
2172 (void *)&cmd_stop_stop,
2177 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2180 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2181 unsigned int *parsed_items, int check_unique_values)
2183 unsigned int nb_item;
2191 * First parse all items in the list and store their value.
2196 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2198 if ((c >= '0') && (c <= '9')) {
2199 value = (unsigned int) (value * 10 + (c - '0'));
2204 printf("character %c is not a decimal digit\n", c);
2208 printf("No valid value before comma\n");
2211 if (nb_item < max_items) {
2212 parsed_items[nb_item] = value;
2218 if (nb_item >= max_items) {
2219 printf("Number of %s = %u > %u (maximum items)\n",
2220 item_name, nb_item + 1, max_items);
2223 parsed_items[nb_item++] = value;
2224 if (! check_unique_values)
2228 * Then, check that all values in the list are differents.
2229 * No optimization here...
2231 for (i = 0; i < nb_item; i++) {
2232 for (j = i + 1; j < nb_item; j++) {
2233 if (parsed_items[j] == parsed_items[i]) {
2234 printf("duplicated %s %u at index %u and %u\n",
2235 item_name, parsed_items[i], i, j);
2243 struct cmd_set_list_result {
2244 cmdline_fixed_string_t cmd_keyword;
2245 cmdline_fixed_string_t list_name;
2246 cmdline_fixed_string_t list_of_items;
2249 static void cmd_set_list_parsed(void *parsed_result,
2250 __attribute__((unused)) struct cmdline *cl,
2251 __attribute__((unused)) void *data)
2253 struct cmd_set_list_result *res;
2255 unsigned int lcorelist[RTE_MAX_LCORE];
2256 unsigned int portlist[RTE_MAX_ETHPORTS];
2258 unsigned int nb_item;
2260 if (test_done == 0) {
2261 printf("Please stop forwarding first\n");
2265 res = parsed_result;
2266 if (!strcmp(res->list_name, "corelist")) {
2267 nb_item = parse_item_list(res->list_of_items, "core",
2269 parsed_items.lcorelist, 1);
2271 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2274 if (!strcmp(res->list_name, "portlist")) {
2275 nb_item = parse_item_list(res->list_of_items, "port",
2277 parsed_items.portlist, 1);
2279 set_fwd_ports_list(parsed_items.portlist, nb_item);
2283 cmdline_parse_token_string_t cmd_set_list_keyword =
2284 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2286 cmdline_parse_token_string_t cmd_set_list_name =
2287 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2288 "corelist#portlist");
2289 cmdline_parse_token_string_t cmd_set_list_of_items =
2290 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2293 cmdline_parse_inst_t cmd_set_fwd_list = {
2294 .f = cmd_set_list_parsed,
2296 .help_str = "set corelist|portlist x[,y]*",
2298 (void *)&cmd_set_list_keyword,
2299 (void *)&cmd_set_list_name,
2300 (void *)&cmd_set_list_of_items,
2305 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2307 struct cmd_setmask_result {
2308 cmdline_fixed_string_t set;
2309 cmdline_fixed_string_t mask;
2313 static void cmd_set_mask_parsed(void *parsed_result,
2314 __attribute__((unused)) struct cmdline *cl,
2315 __attribute__((unused)) void *data)
2317 struct cmd_setmask_result *res = parsed_result;
2319 if (test_done == 0) {
2320 printf("Please stop forwarding first\n");
2323 if (!strcmp(res->mask, "coremask"))
2324 set_fwd_lcores_mask(res->hexavalue);
2325 else if (!strcmp(res->mask, "portmask"))
2326 set_fwd_ports_mask(res->hexavalue);
2329 cmdline_parse_token_string_t cmd_setmask_set =
2330 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2331 cmdline_parse_token_string_t cmd_setmask_mask =
2332 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2333 "coremask#portmask");
2334 cmdline_parse_token_num_t cmd_setmask_value =
2335 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2337 cmdline_parse_inst_t cmd_set_fwd_mask = {
2338 .f = cmd_set_mask_parsed,
2340 .help_str = "set coremask|portmask hexadecimal value",
2342 (void *)&cmd_setmask_set,
2343 (void *)&cmd_setmask_mask,
2344 (void *)&cmd_setmask_value,
2350 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2352 struct cmd_set_result {
2353 cmdline_fixed_string_t set;
2354 cmdline_fixed_string_t what;
2358 static void cmd_set_parsed(void *parsed_result,
2359 __attribute__((unused)) struct cmdline *cl,
2360 __attribute__((unused)) void *data)
2362 struct cmd_set_result *res = parsed_result;
2363 if (!strcmp(res->what, "nbport"))
2364 set_fwd_ports_number(res->value);
2365 else if (!strcmp(res->what, "nbcore"))
2366 set_fwd_lcores_number(res->value);
2367 else if (!strcmp(res->what, "burst"))
2368 set_nb_pkt_per_burst(res->value);
2369 else if (!strcmp(res->what, "verbose"))
2370 set_verbose_level(res->value);
2373 cmdline_parse_token_string_t cmd_set_set =
2374 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2375 cmdline_parse_token_string_t cmd_set_what =
2376 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2377 "nbport#nbcore#burst#verbose");
2378 cmdline_parse_token_num_t cmd_set_value =
2379 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2381 cmdline_parse_inst_t cmd_set_numbers = {
2382 .f = cmd_set_parsed,
2384 .help_str = "set nbport|nbcore|burst|verbose value",
2386 (void *)&cmd_set_set,
2387 (void *)&cmd_set_what,
2388 (void *)&cmd_set_value,
2393 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2395 struct cmd_set_txpkts_result {
2396 cmdline_fixed_string_t cmd_keyword;
2397 cmdline_fixed_string_t txpkts;
2398 cmdline_fixed_string_t seg_lengths;
2402 cmd_set_txpkts_parsed(void *parsed_result,
2403 __attribute__((unused)) struct cmdline *cl,
2404 __attribute__((unused)) void *data)
2406 struct cmd_set_txpkts_result *res;
2407 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2408 unsigned int nb_segs;
2410 res = parsed_result;
2411 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2412 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2414 set_tx_pkt_segments(seg_lengths, nb_segs);
2417 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2418 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2419 cmd_keyword, "set");
2420 cmdline_parse_token_string_t cmd_set_txpkts_name =
2421 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2423 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2424 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2427 cmdline_parse_inst_t cmd_set_txpkts = {
2428 .f = cmd_set_txpkts_parsed,
2430 .help_str = "set txpkts x[,y]*",
2432 (void *)&cmd_set_txpkts_keyword,
2433 (void *)&cmd_set_txpkts_name,
2434 (void *)&cmd_set_txpkts_lengths,
2439 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2440 struct cmd_rx_vlan_filter_all_result {
2441 cmdline_fixed_string_t rx_vlan;
2442 cmdline_fixed_string_t what;
2443 cmdline_fixed_string_t all;
2448 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2449 __attribute__((unused)) struct cmdline *cl,
2450 __attribute__((unused)) void *data)
2452 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2454 if (!strcmp(res->what, "add"))
2455 rx_vlan_all_filter_set(res->port_id, 1);
2457 rx_vlan_all_filter_set(res->port_id, 0);
2460 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2461 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2462 rx_vlan, "rx_vlan");
2463 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2464 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2466 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2467 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2469 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2470 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2473 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2474 .f = cmd_rx_vlan_filter_all_parsed,
2476 .help_str = "add/remove all identifiers to/from the set of VLAN "
2477 "Identifiers filtered by a port",
2479 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2480 (void *)&cmd_rx_vlan_filter_all_what,
2481 (void *)&cmd_rx_vlan_filter_all_all,
2482 (void *)&cmd_rx_vlan_filter_all_portid,
2487 /* *** VLAN OFFLOAD SET ON A PORT *** */
2488 struct cmd_vlan_offload_result {
2489 cmdline_fixed_string_t vlan;
2490 cmdline_fixed_string_t set;
2491 cmdline_fixed_string_t what;
2492 cmdline_fixed_string_t on;
2493 cmdline_fixed_string_t port_id;
2497 cmd_vlan_offload_parsed(void *parsed_result,
2498 __attribute__((unused)) struct cmdline *cl,
2499 __attribute__((unused)) void *data)
2502 struct cmd_vlan_offload_result *res = parsed_result;
2505 portid_t port_id = 0;
2509 len = strnlen(str, STR_TOKEN_SIZE);
2511 /* Get port_id first */
2519 tmp = strtoul(str, NULL, 0);
2520 /* If port_id greater that what portid_t can represent, return */
2521 if(tmp >= RTE_MAX_ETHPORTS)
2523 port_id = (portid_t)tmp;
2525 if (!strcmp(res->on, "on"))
2530 if (!strcmp(res->what, "strip"))
2531 rx_vlan_strip_set(port_id, on);
2532 else if(!strcmp(res->what, "stripq")){
2533 uint16_t queue_id = 0;
2535 /* No queue_id, return */
2537 printf("must specify (port,queue_id)\n");
2540 tmp = strtoul(str + i + 1, NULL, 0);
2541 /* If queue_id greater that what 16-bits can represent, return */
2545 queue_id = (uint16_t)tmp;
2546 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2548 else if (!strcmp(res->what, "filter"))
2549 rx_vlan_filter_set(port_id, on);
2551 vlan_extend_set(port_id, on);
2556 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2557 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2559 cmdline_parse_token_string_t cmd_vlan_offload_set =
2560 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2562 cmdline_parse_token_string_t cmd_vlan_offload_what =
2563 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2564 what, "strip#filter#qinq#stripq");
2565 cmdline_parse_token_string_t cmd_vlan_offload_on =
2566 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2568 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2569 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2572 cmdline_parse_inst_t cmd_vlan_offload = {
2573 .f = cmd_vlan_offload_parsed,
2575 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2576 " qinq(extended) for both rx/tx sides ",
2578 (void *)&cmd_vlan_offload_vlan,
2579 (void *)&cmd_vlan_offload_set,
2580 (void *)&cmd_vlan_offload_what,
2581 (void *)&cmd_vlan_offload_on,
2582 (void *)&cmd_vlan_offload_portid,
2587 /* *** VLAN TPID SET ON A PORT *** */
2588 struct cmd_vlan_tpid_result {
2589 cmdline_fixed_string_t vlan;
2590 cmdline_fixed_string_t set;
2591 cmdline_fixed_string_t what;
2597 cmd_vlan_tpid_parsed(void *parsed_result,
2598 __attribute__((unused)) struct cmdline *cl,
2599 __attribute__((unused)) void *data)
2601 struct cmd_vlan_tpid_result *res = parsed_result;
2602 vlan_tpid_set(res->port_id, res->tp_id);
2606 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2607 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2609 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2610 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2612 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2613 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2615 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2616 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2618 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2619 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2622 cmdline_parse_inst_t cmd_vlan_tpid = {
2623 .f = cmd_vlan_tpid_parsed,
2625 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2627 (void *)&cmd_vlan_tpid_vlan,
2628 (void *)&cmd_vlan_tpid_set,
2629 (void *)&cmd_vlan_tpid_what,
2630 (void *)&cmd_vlan_tpid_tpid,
2631 (void *)&cmd_vlan_tpid_portid,
2636 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2637 struct cmd_rx_vlan_filter_result {
2638 cmdline_fixed_string_t rx_vlan;
2639 cmdline_fixed_string_t what;
2645 cmd_rx_vlan_filter_parsed(void *parsed_result,
2646 __attribute__((unused)) struct cmdline *cl,
2647 __attribute__((unused)) void *data)
2649 struct cmd_rx_vlan_filter_result *res = parsed_result;
2651 if (!strcmp(res->what, "add"))
2652 rx_vft_set(res->port_id, res->vlan_id, 1);
2654 rx_vft_set(res->port_id, res->vlan_id, 0);
2657 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2658 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2659 rx_vlan, "rx_vlan");
2660 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2661 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2663 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2664 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2666 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2667 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2670 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2671 .f = cmd_rx_vlan_filter_parsed,
2673 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2674 "Identifiers filtered by a port",
2676 (void *)&cmd_rx_vlan_filter_rx_vlan,
2677 (void *)&cmd_rx_vlan_filter_what,
2678 (void *)&cmd_rx_vlan_filter_vlanid,
2679 (void *)&cmd_rx_vlan_filter_portid,
2684 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2685 struct cmd_tx_vlan_set_result {
2686 cmdline_fixed_string_t tx_vlan;
2687 cmdline_fixed_string_t set;
2693 cmd_tx_vlan_set_parsed(void *parsed_result,
2694 __attribute__((unused)) struct cmdline *cl,
2695 __attribute__((unused)) void *data)
2697 struct cmd_tx_vlan_set_result *res = parsed_result;
2698 tx_vlan_set(res->port_id, res->vlan_id);
2701 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2702 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2703 tx_vlan, "tx_vlan");
2704 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2705 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2707 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2708 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2710 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2711 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2714 cmdline_parse_inst_t cmd_tx_vlan_set = {
2715 .f = cmd_tx_vlan_set_parsed,
2717 .help_str = "enable hardware insertion of a VLAN header with a given "
2718 "TAG Identifier in packets sent on a port",
2720 (void *)&cmd_tx_vlan_set_tx_vlan,
2721 (void *)&cmd_tx_vlan_set_set,
2722 (void *)&cmd_tx_vlan_set_vlanid,
2723 (void *)&cmd_tx_vlan_set_portid,
2728 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2729 struct cmd_tx_vlan_set_pvid_result {
2730 cmdline_fixed_string_t tx_vlan;
2731 cmdline_fixed_string_t set;
2732 cmdline_fixed_string_t pvid;
2735 cmdline_fixed_string_t mode;
2739 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2740 __attribute__((unused)) struct cmdline *cl,
2741 __attribute__((unused)) void *data)
2743 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2745 if (strcmp(res->mode, "on") == 0)
2746 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2748 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2751 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2752 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2753 tx_vlan, "tx_vlan");
2754 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2755 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2757 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2758 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2760 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2761 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2763 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2764 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2766 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2767 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2770 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2771 .f = cmd_tx_vlan_set_pvid_parsed,
2773 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2775 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2776 (void *)&cmd_tx_vlan_set_pvid_set,
2777 (void *)&cmd_tx_vlan_set_pvid_pvid,
2778 (void *)&cmd_tx_vlan_set_pvid_port_id,
2779 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2780 (void *)&cmd_tx_vlan_set_pvid_mode,
2785 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2786 struct cmd_tx_vlan_reset_result {
2787 cmdline_fixed_string_t tx_vlan;
2788 cmdline_fixed_string_t reset;
2793 cmd_tx_vlan_reset_parsed(void *parsed_result,
2794 __attribute__((unused)) struct cmdline *cl,
2795 __attribute__((unused)) void *data)
2797 struct cmd_tx_vlan_reset_result *res = parsed_result;
2799 tx_vlan_reset(res->port_id);
2802 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2803 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2804 tx_vlan, "tx_vlan");
2805 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2806 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2808 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2809 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2812 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2813 .f = cmd_tx_vlan_reset_parsed,
2815 .help_str = "disable hardware insertion of a VLAN header in packets "
2818 (void *)&cmd_tx_vlan_reset_tx_vlan,
2819 (void *)&cmd_tx_vlan_reset_reset,
2820 (void *)&cmd_tx_vlan_reset_portid,
2826 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2827 struct cmd_csum_result {
2828 cmdline_fixed_string_t csum;
2829 cmdline_fixed_string_t mode;
2830 cmdline_fixed_string_t proto;
2831 cmdline_fixed_string_t hwsw;
2836 csum_show(int port_id)
2838 struct rte_eth_dev_info dev_info;
2841 ol_flags = ports[port_id].tx_ol_flags;
2842 printf("Parse tunnel is %s\n",
2843 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
2844 printf("IP checksum offload is %s\n",
2845 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2846 printf("UDP checksum offload is %s\n",
2847 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2848 printf("TCP checksum offload is %s\n",
2849 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2850 printf("SCTP checksum offload is %s\n",
2851 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2852 printf("Outer-Ip checksum offload is %s\n",
2853 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
2855 /* display warnings if configuration is not supported by the NIC */
2856 rte_eth_dev_info_get(port_id, &dev_info);
2857 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2858 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2859 printf("Warning: hardware IP checksum enabled but not "
2860 "supported by port %d\n", port_id);
2862 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2863 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2864 printf("Warning: hardware UDP checksum enabled but not "
2865 "supported by port %d\n", port_id);
2867 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2868 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2869 printf("Warning: hardware TCP checksum enabled but not "
2870 "supported by port %d\n", port_id);
2872 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2873 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2874 printf("Warning: hardware SCTP checksum enabled but not "
2875 "supported by port %d\n", port_id);
2877 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
2878 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
2879 printf("Warning: hardware outer IP checksum enabled but not "
2880 "supported by port %d\n", port_id);
2885 cmd_csum_parsed(void *parsed_result,
2886 __attribute__((unused)) struct cmdline *cl,
2887 __attribute__((unused)) void *data)
2889 struct cmd_csum_result *res = parsed_result;
2893 if (port_id_is_invalid(res->port_id)) {
2894 printf("invalid port %d\n", res->port_id);
2898 if (!strcmp(res->mode, "set")) {
2900 if (!strcmp(res->hwsw, "hw"))
2903 if (!strcmp(res->proto, "ip")) {
2904 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2905 } else if (!strcmp(res->proto, "udp")) {
2906 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2907 } else if (!strcmp(res->proto, "tcp")) {
2908 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2909 } else if (!strcmp(res->proto, "sctp")) {
2910 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2911 } else if (!strcmp(res->proto, "outer-ip")) {
2912 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
2916 ports[res->port_id].tx_ol_flags |= mask;
2918 ports[res->port_id].tx_ol_flags &= (~mask);
2920 csum_show(res->port_id);
2923 cmdline_parse_token_string_t cmd_csum_csum =
2924 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2926 cmdline_parse_token_string_t cmd_csum_mode =
2927 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2929 cmdline_parse_token_string_t cmd_csum_proto =
2930 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2931 proto, "ip#tcp#udp#sctp#outer-ip");
2932 cmdline_parse_token_string_t cmd_csum_hwsw =
2933 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2935 cmdline_parse_token_num_t cmd_csum_portid =
2936 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
2939 cmdline_parse_inst_t cmd_csum_set = {
2940 .f = cmd_csum_parsed,
2942 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
2943 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
2945 (void *)&cmd_csum_csum,
2946 (void *)&cmd_csum_mode,
2947 (void *)&cmd_csum_proto,
2948 (void *)&cmd_csum_hwsw,
2949 (void *)&cmd_csum_portid,
2954 cmdline_parse_token_string_t cmd_csum_mode_show =
2955 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2958 cmdline_parse_inst_t cmd_csum_show = {
2959 .f = cmd_csum_parsed,
2961 .help_str = "show checksum offload configuration: csum show <port>",
2963 (void *)&cmd_csum_csum,
2964 (void *)&cmd_csum_mode_show,
2965 (void *)&cmd_csum_portid,
2970 /* Enable/disable tunnel parsing */
2971 struct cmd_csum_tunnel_result {
2972 cmdline_fixed_string_t csum;
2973 cmdline_fixed_string_t parse;
2974 cmdline_fixed_string_t onoff;
2979 cmd_csum_tunnel_parsed(void *parsed_result,
2980 __attribute__((unused)) struct cmdline *cl,
2981 __attribute__((unused)) void *data)
2983 struct cmd_csum_tunnel_result *res = parsed_result;
2985 if (port_id_is_invalid(res->port_id)) {
2986 printf("invalid port %d\n", res->port_id);
2990 if (!strcmp(res->onoff, "on"))
2991 ports[res->port_id].tx_ol_flags |=
2992 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
2994 ports[res->port_id].tx_ol_flags &=
2995 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
2997 csum_show(res->port_id);
3000 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3001 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3003 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3004 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3005 parse, "parse_tunnel");
3006 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3007 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3009 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3010 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3013 cmdline_parse_inst_t cmd_csum_tunnel = {
3014 .f = cmd_csum_tunnel_parsed,
3016 .help_str = "enable/disable parsing of tunnels for csum engine: "
3017 "csum parse_tunnel on|off <tx-port>",
3019 (void *)&cmd_csum_tunnel_csum,
3020 (void *)&cmd_csum_tunnel_parse,
3021 (void *)&cmd_csum_tunnel_onoff,
3022 (void *)&cmd_csum_tunnel_portid,
3027 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3028 struct cmd_tso_set_result {
3029 cmdline_fixed_string_t tso;
3030 cmdline_fixed_string_t mode;
3036 cmd_tso_set_parsed(void *parsed_result,
3037 __attribute__((unused)) struct cmdline *cl,
3038 __attribute__((unused)) void *data)
3040 struct cmd_tso_set_result *res = parsed_result;
3041 struct rte_eth_dev_info dev_info;
3043 if (port_id_is_invalid(res->port_id))
3046 if (!strcmp(res->mode, "set"))
3047 ports[res->port_id].tso_segsz = res->tso_segsz;
3049 if (ports[res->port_id].tso_segsz == 0)
3050 printf("TSO is disabled\n");
3052 printf("TSO segment size is %d\n",
3053 ports[res->port_id].tso_segsz);
3055 /* display warnings if configuration is not supported by the NIC */
3056 rte_eth_dev_info_get(res->port_id, &dev_info);
3057 if ((ports[res->port_id].tso_segsz != 0) &&
3058 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3059 printf("Warning: TSO enabled but not "
3060 "supported by port %d\n", res->port_id);
3064 cmdline_parse_token_string_t cmd_tso_set_tso =
3065 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3067 cmdline_parse_token_string_t cmd_tso_set_mode =
3068 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3070 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3071 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3073 cmdline_parse_token_num_t cmd_tso_set_portid =
3074 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3077 cmdline_parse_inst_t cmd_tso_set = {
3078 .f = cmd_tso_set_parsed,
3080 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3081 "tso set <tso_segsz> <port>",
3083 (void *)&cmd_tso_set_tso,
3084 (void *)&cmd_tso_set_mode,
3085 (void *)&cmd_tso_set_tso_segsz,
3086 (void *)&cmd_tso_set_portid,
3091 cmdline_parse_token_string_t cmd_tso_show_mode =
3092 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3096 cmdline_parse_inst_t cmd_tso_show = {
3097 .f = cmd_tso_set_parsed,
3099 .help_str = "Show TSO segment size for csum engine: "
3102 (void *)&cmd_tso_set_tso,
3103 (void *)&cmd_tso_show_mode,
3104 (void *)&cmd_tso_set_portid,
3109 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3110 struct cmd_set_flush_rx {
3111 cmdline_fixed_string_t set;
3112 cmdline_fixed_string_t flush_rx;
3113 cmdline_fixed_string_t mode;
3117 cmd_set_flush_rx_parsed(void *parsed_result,
3118 __attribute__((unused)) struct cmdline *cl,
3119 __attribute__((unused)) void *data)
3121 struct cmd_set_flush_rx *res = parsed_result;
3122 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3125 cmdline_parse_token_string_t cmd_setflushrx_set =
3126 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3128 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3129 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3130 flush_rx, "flush_rx");
3131 cmdline_parse_token_string_t cmd_setflushrx_mode =
3132 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3136 cmdline_parse_inst_t cmd_set_flush_rx = {
3137 .f = cmd_set_flush_rx_parsed,
3138 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3141 (void *)&cmd_setflushrx_set,
3142 (void *)&cmd_setflushrx_flush_rx,
3143 (void *)&cmd_setflushrx_mode,
3148 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3149 struct cmd_set_link_check {
3150 cmdline_fixed_string_t set;
3151 cmdline_fixed_string_t link_check;
3152 cmdline_fixed_string_t mode;
3156 cmd_set_link_check_parsed(void *parsed_result,
3157 __attribute__((unused)) struct cmdline *cl,
3158 __attribute__((unused)) void *data)
3160 struct cmd_set_link_check *res = parsed_result;
3161 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3164 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3165 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3167 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3168 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3169 link_check, "link_check");
3170 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3171 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3175 cmdline_parse_inst_t cmd_set_link_check = {
3176 .f = cmd_set_link_check_parsed,
3177 .help_str = "set link_check on|off: enable/disable link status check "
3178 "when starting/stopping a port",
3181 (void *)&cmd_setlinkcheck_set,
3182 (void *)&cmd_setlinkcheck_link_check,
3183 (void *)&cmd_setlinkcheck_mode,
3188 #ifdef RTE_NIC_BYPASS
3189 /* *** SET NIC BYPASS MODE *** */
3190 struct cmd_set_bypass_mode_result {
3191 cmdline_fixed_string_t set;
3192 cmdline_fixed_string_t bypass;
3193 cmdline_fixed_string_t mode;
3194 cmdline_fixed_string_t value;
3199 cmd_set_bypass_mode_parsed(void *parsed_result,
3200 __attribute__((unused)) struct cmdline *cl,
3201 __attribute__((unused)) void *data)
3203 struct cmd_set_bypass_mode_result *res = parsed_result;
3204 portid_t port_id = res->port_id;
3205 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3207 if (!bypass_is_supported(port_id))
3210 if (!strcmp(res->value, "bypass"))
3211 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3212 else if (!strcmp(res->value, "isolate"))
3213 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3215 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3217 /* Set the bypass mode for the relevant port. */
3218 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3219 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3223 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3224 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3226 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3227 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3229 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3230 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3232 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3233 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3234 value, "normal#bypass#isolate");
3235 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3236 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3239 cmdline_parse_inst_t cmd_set_bypass_mode = {
3240 .f = cmd_set_bypass_mode_parsed,
3241 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3242 "Set the NIC bypass mode for port_id",
3245 (void *)&cmd_setbypass_mode_set,
3246 (void *)&cmd_setbypass_mode_bypass,
3247 (void *)&cmd_setbypass_mode_mode,
3248 (void *)&cmd_setbypass_mode_value,
3249 (void *)&cmd_setbypass_mode_port,
3254 /* *** SET NIC BYPASS EVENT *** */
3255 struct cmd_set_bypass_event_result {
3256 cmdline_fixed_string_t set;
3257 cmdline_fixed_string_t bypass;
3258 cmdline_fixed_string_t event;
3259 cmdline_fixed_string_t event_value;
3260 cmdline_fixed_string_t mode;
3261 cmdline_fixed_string_t mode_value;
3266 cmd_set_bypass_event_parsed(void *parsed_result,
3267 __attribute__((unused)) struct cmdline *cl,
3268 __attribute__((unused)) void *data)
3271 struct cmd_set_bypass_event_result *res = parsed_result;
3272 portid_t port_id = res->port_id;
3273 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3274 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3276 if (!bypass_is_supported(port_id))
3279 if (!strcmp(res->event_value, "timeout"))
3280 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3281 else if (!strcmp(res->event_value, "os_on"))
3282 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3283 else if (!strcmp(res->event_value, "os_off"))
3284 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3285 else if (!strcmp(res->event_value, "power_on"))
3286 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3287 else if (!strcmp(res->event_value, "power_off"))
3288 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3290 bypass_event = RTE_BYPASS_EVENT_NONE;
3292 if (!strcmp(res->mode_value, "bypass"))
3293 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3294 else if (!strcmp(res->mode_value, "isolate"))
3295 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3297 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3299 /* Set the watchdog timeout. */
3300 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3303 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3304 (rc = rte_eth_dev_wd_timeout_store(port_id,
3305 bypass_timeout)) != 0) {
3306 printf("Failed to set timeout value %u "
3307 "for port %d, errto code: %d.\n",
3308 bypass_timeout, port_id, rc);
3312 /* Set the bypass event to transition to bypass mode. */
3313 if (0 != rte_eth_dev_bypass_event_store(port_id,
3314 bypass_event, bypass_mode)) {
3315 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3320 cmdline_parse_token_string_t cmd_setbypass_event_set =
3321 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3323 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3324 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3326 cmdline_parse_token_string_t cmd_setbypass_event_event =
3327 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3329 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3330 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3331 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3332 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3333 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3335 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3336 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3337 mode_value, "normal#bypass#isolate");
3338 cmdline_parse_token_num_t cmd_setbypass_event_port =
3339 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3342 cmdline_parse_inst_t cmd_set_bypass_event = {
3343 .f = cmd_set_bypass_event_parsed,
3344 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3345 "mode (normal|bypass|isolate) (port_id): "
3346 "Set the NIC bypass event mode for port_id",
3349 (void *)&cmd_setbypass_event_set,
3350 (void *)&cmd_setbypass_event_bypass,
3351 (void *)&cmd_setbypass_event_event,
3352 (void *)&cmd_setbypass_event_event_value,
3353 (void *)&cmd_setbypass_event_mode,
3354 (void *)&cmd_setbypass_event_mode_value,
3355 (void *)&cmd_setbypass_event_port,
3361 /* *** SET NIC BYPASS TIMEOUT *** */
3362 struct cmd_set_bypass_timeout_result {
3363 cmdline_fixed_string_t set;
3364 cmdline_fixed_string_t bypass;
3365 cmdline_fixed_string_t timeout;
3366 cmdline_fixed_string_t value;
3370 cmd_set_bypass_timeout_parsed(void *parsed_result,
3371 __attribute__((unused)) struct cmdline *cl,
3372 __attribute__((unused)) void *data)
3374 struct cmd_set_bypass_timeout_result *res = parsed_result;
3376 if (!strcmp(res->value, "1.5"))
3377 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3378 else if (!strcmp(res->value, "2"))
3379 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3380 else if (!strcmp(res->value, "3"))
3381 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3382 else if (!strcmp(res->value, "4"))
3383 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3384 else if (!strcmp(res->value, "8"))
3385 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3386 else if (!strcmp(res->value, "16"))
3387 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3388 else if (!strcmp(res->value, "32"))
3389 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3391 bypass_timeout = RTE_BYPASS_TMT_OFF;
3394 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3395 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3397 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3398 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3400 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3401 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3402 timeout, "timeout");
3403 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3404 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3405 value, "0#1.5#2#3#4#8#16#32");
3407 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3408 .f = cmd_set_bypass_timeout_parsed,
3409 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3410 "Set the NIC bypass watchdog timeout",
3413 (void *)&cmd_setbypass_timeout_set,
3414 (void *)&cmd_setbypass_timeout_bypass,
3415 (void *)&cmd_setbypass_timeout_timeout,
3416 (void *)&cmd_setbypass_timeout_value,
3421 /* *** SHOW NIC BYPASS MODE *** */
3422 struct cmd_show_bypass_config_result {
3423 cmdline_fixed_string_t show;
3424 cmdline_fixed_string_t bypass;
3425 cmdline_fixed_string_t config;
3430 cmd_show_bypass_config_parsed(void *parsed_result,
3431 __attribute__((unused)) struct cmdline *cl,
3432 __attribute__((unused)) void *data)
3434 struct cmd_show_bypass_config_result *res = parsed_result;
3435 uint32_t event_mode;
3436 uint32_t bypass_mode;
3437 portid_t port_id = res->port_id;
3438 uint32_t timeout = bypass_timeout;
3441 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3442 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3443 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3444 {"UNKNOWN", "normal", "bypass", "isolate"};
3445 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3452 int num_events = (sizeof events) / (sizeof events[0]);
3454 if (!bypass_is_supported(port_id))
3457 /* Display the bypass mode.*/
3458 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3459 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3463 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3464 bypass_mode = RTE_BYPASS_MODE_NONE;
3466 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3469 /* Display the bypass timeout.*/
3470 if (!RTE_BYPASS_TMT_VALID(timeout))
3471 timeout = RTE_BYPASS_TMT_OFF;
3473 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3475 /* Display the bypass events and associated modes. */
3476 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3478 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3479 printf("\tFailed to get bypass mode for event = %s\n",
3482 if (!RTE_BYPASS_MODE_VALID(event_mode))
3483 event_mode = RTE_BYPASS_MODE_NONE;
3485 printf("\tbypass event: %-16s = %s\n", events[i],
3491 cmdline_parse_token_string_t cmd_showbypass_config_show =
3492 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3494 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3495 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3497 cmdline_parse_token_string_t cmd_showbypass_config_config =
3498 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3500 cmdline_parse_token_num_t cmd_showbypass_config_port =
3501 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3504 cmdline_parse_inst_t cmd_show_bypass_config = {
3505 .f = cmd_show_bypass_config_parsed,
3506 .help_str = "show bypass config (port_id): "
3507 "Show the NIC bypass config for port_id",
3510 (void *)&cmd_showbypass_config_show,
3511 (void *)&cmd_showbypass_config_bypass,
3512 (void *)&cmd_showbypass_config_config,
3513 (void *)&cmd_showbypass_config_port,
3519 #ifdef RTE_LIBRTE_PMD_BOND
3520 /* *** SET BONDING MODE *** */
3521 struct cmd_set_bonding_mode_result {
3522 cmdline_fixed_string_t set;
3523 cmdline_fixed_string_t bonding;
3524 cmdline_fixed_string_t mode;
3529 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3530 __attribute__((unused)) struct cmdline *cl,
3531 __attribute__((unused)) void *data)
3533 struct cmd_set_bonding_mode_result *res = parsed_result;
3534 portid_t port_id = res->port_id;
3536 /* Set the bonding mode for the relevant port. */
3537 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3538 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3541 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3542 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3544 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3545 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3546 bonding, "bonding");
3547 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3548 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3550 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3551 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3553 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3554 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3557 cmdline_parse_inst_t cmd_set_bonding_mode = {
3558 .f = cmd_set_bonding_mode_parsed,
3559 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3562 (void *) &cmd_setbonding_mode_set,
3563 (void *) &cmd_setbonding_mode_bonding,
3564 (void *) &cmd_setbonding_mode_mode,
3565 (void *) &cmd_setbonding_mode_value,
3566 (void *) &cmd_setbonding_mode_port,
3571 /* *** SET BALANCE XMIT POLICY *** */
3572 struct cmd_set_bonding_balance_xmit_policy_result {
3573 cmdline_fixed_string_t set;
3574 cmdline_fixed_string_t bonding;
3575 cmdline_fixed_string_t balance_xmit_policy;
3577 cmdline_fixed_string_t policy;
3580 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3581 __attribute__((unused)) struct cmdline *cl,
3582 __attribute__((unused)) void *data)
3584 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3585 portid_t port_id = res->port_id;
3588 if (!strcmp(res->policy, "l2")) {
3589 policy = BALANCE_XMIT_POLICY_LAYER2;
3590 } else if (!strcmp(res->policy, "l23")) {
3591 policy = BALANCE_XMIT_POLICY_LAYER23;
3592 } else if (!strcmp(res->policy, "l34")) {
3593 policy = BALANCE_XMIT_POLICY_LAYER34;
3595 printf("\t Invalid xmit policy selection");
3599 /* Set the bonding mode for the relevant port. */
3600 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3601 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3606 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3607 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3609 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3610 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3611 bonding, "bonding");
3612 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3613 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3614 balance_xmit_policy, "balance_xmit_policy");
3615 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3616 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3618 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3619 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3620 policy, "l2#l23#l34");
3622 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3623 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3624 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3627 (void *)&cmd_setbonding_balance_xmit_policy_set,
3628 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3629 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3630 (void *)&cmd_setbonding_balance_xmit_policy_port,
3631 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3636 /* *** SHOW NIC BONDING CONFIGURATION *** */
3637 struct cmd_show_bonding_config_result {
3638 cmdline_fixed_string_t show;
3639 cmdline_fixed_string_t bonding;
3640 cmdline_fixed_string_t config;
3644 static void cmd_show_bonding_config_parsed(void *parsed_result,
3645 __attribute__((unused)) struct cmdline *cl,
3646 __attribute__((unused)) void *data)
3648 struct cmd_show_bonding_config_result *res = parsed_result;
3650 uint8_t slaves[RTE_MAX_ETHPORTS];
3651 int num_slaves, num_active_slaves;
3654 portid_t port_id = res->port_id;
3656 /* Display the bonding mode.*/
3657 bonding_mode = rte_eth_bond_mode_get(port_id);
3658 if (bonding_mode < 0) {
3659 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3662 printf("\tBonding mode: %d\n", bonding_mode);
3664 if (bonding_mode == BONDING_MODE_BALANCE) {
3665 int balance_xmit_policy;
3667 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3668 if (balance_xmit_policy < 0) {
3669 printf("\tFailed to get balance xmit policy for port = %d\n",
3673 printf("\tBalance Xmit Policy: ");
3675 switch (balance_xmit_policy) {
3676 case BALANCE_XMIT_POLICY_LAYER2:
3677 printf("BALANCE_XMIT_POLICY_LAYER2");
3679 case BALANCE_XMIT_POLICY_LAYER23:
3680 printf("BALANCE_XMIT_POLICY_LAYER23");
3682 case BALANCE_XMIT_POLICY_LAYER34:
3683 printf("BALANCE_XMIT_POLICY_LAYER34");
3690 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3692 if (num_slaves < 0) {
3693 printf("\tFailed to get slave list for port = %d\n", port_id);
3696 if (num_slaves > 0) {
3697 printf("\tSlaves (%d): [", num_slaves);
3698 for (i = 0; i < num_slaves - 1; i++)
3699 printf("%d ", slaves[i]);
3701 printf("%d]\n", slaves[num_slaves - 1]);
3703 printf("\tSlaves: []\n");
3707 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3710 if (num_active_slaves < 0) {
3711 printf("\tFailed to get active slave list for port = %d\n", port_id);
3714 if (num_active_slaves > 0) {
3715 printf("\tActive Slaves (%d): [", num_active_slaves);
3716 for (i = 0; i < num_active_slaves - 1; i++)
3717 printf("%d ", slaves[i]);
3719 printf("%d]\n", slaves[num_active_slaves - 1]);
3722 printf("\tActive Slaves: []\n");
3726 primary_id = rte_eth_bond_primary_get(port_id);
3727 if (primary_id < 0) {
3728 printf("\tFailed to get primary slave for port = %d\n", port_id);
3731 printf("\tPrimary: [%d]\n", primary_id);
3735 cmdline_parse_token_string_t cmd_showbonding_config_show =
3736 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3738 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3739 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3740 bonding, "bonding");
3741 cmdline_parse_token_string_t cmd_showbonding_config_config =
3742 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3744 cmdline_parse_token_num_t cmd_showbonding_config_port =
3745 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3748 cmdline_parse_inst_t cmd_show_bonding_config = {
3749 .f = cmd_show_bonding_config_parsed,
3750 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3753 (void *)&cmd_showbonding_config_show,
3754 (void *)&cmd_showbonding_config_bonding,
3755 (void *)&cmd_showbonding_config_config,
3756 (void *)&cmd_showbonding_config_port,
3761 /* *** SET BONDING PRIMARY *** */
3762 struct cmd_set_bonding_primary_result {
3763 cmdline_fixed_string_t set;
3764 cmdline_fixed_string_t bonding;
3765 cmdline_fixed_string_t primary;
3770 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3771 __attribute__((unused)) struct cmdline *cl,
3772 __attribute__((unused)) void *data)
3774 struct cmd_set_bonding_primary_result *res = parsed_result;
3775 portid_t master_port_id = res->port_id;
3776 portid_t slave_port_id = res->slave_id;
3778 /* Set the primary slave for a bonded device. */
3779 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3780 printf("\t Failed to set primary slave for port = %d.\n",
3787 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3788 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3790 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3791 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3792 bonding, "bonding");
3793 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3794 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3795 primary, "primary");
3796 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3797 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3799 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3800 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3803 cmdline_parse_inst_t cmd_set_bonding_primary = {
3804 .f = cmd_set_bonding_primary_parsed,
3805 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3808 (void *)&cmd_setbonding_primary_set,
3809 (void *)&cmd_setbonding_primary_bonding,
3810 (void *)&cmd_setbonding_primary_primary,
3811 (void *)&cmd_setbonding_primary_slave,
3812 (void *)&cmd_setbonding_primary_port,
3817 /* *** ADD SLAVE *** */
3818 struct cmd_add_bonding_slave_result {
3819 cmdline_fixed_string_t add;
3820 cmdline_fixed_string_t bonding;
3821 cmdline_fixed_string_t slave;
3826 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3827 __attribute__((unused)) struct cmdline *cl,
3828 __attribute__((unused)) void *data)
3830 struct cmd_add_bonding_slave_result *res = parsed_result;
3831 portid_t master_port_id = res->port_id;
3832 portid_t slave_port_id = res->slave_id;
3834 /* Set the primary slave for a bonded device. */
3835 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3836 printf("\t Failed to add slave %d to master port = %d.\n",
3837 slave_port_id, master_port_id);
3843 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3844 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3846 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3847 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3848 bonding, "bonding");
3849 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3850 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3852 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3853 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3855 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3856 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3859 cmdline_parse_inst_t cmd_add_bonding_slave = {
3860 .f = cmd_add_bonding_slave_parsed,
3861 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3864 (void *)&cmd_addbonding_slave_add,
3865 (void *)&cmd_addbonding_slave_bonding,
3866 (void *)&cmd_addbonding_slave_slave,
3867 (void *)&cmd_addbonding_slave_slaveid,
3868 (void *)&cmd_addbonding_slave_port,
3873 /* *** REMOVE SLAVE *** */
3874 struct cmd_remove_bonding_slave_result {
3875 cmdline_fixed_string_t remove;
3876 cmdline_fixed_string_t bonding;
3877 cmdline_fixed_string_t slave;
3882 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3883 __attribute__((unused)) struct cmdline *cl,
3884 __attribute__((unused)) void *data)
3886 struct cmd_remove_bonding_slave_result *res = parsed_result;
3887 portid_t master_port_id = res->port_id;
3888 portid_t slave_port_id = res->slave_id;
3890 /* Set the primary slave for a bonded device. */
3891 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3892 printf("\t Failed to remove slave %d from master port = %d.\n",
3893 slave_port_id, master_port_id);
3899 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3900 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3902 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3903 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3904 bonding, "bonding");
3905 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3906 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3908 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3909 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3911 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3912 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3915 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3916 .f = cmd_remove_bonding_slave_parsed,
3917 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3920 (void *)&cmd_removebonding_slave_remove,
3921 (void *)&cmd_removebonding_slave_bonding,
3922 (void *)&cmd_removebonding_slave_slave,
3923 (void *)&cmd_removebonding_slave_slaveid,
3924 (void *)&cmd_removebonding_slave_port,
3929 /* *** CREATE BONDED DEVICE *** */
3930 struct cmd_create_bonded_device_result {
3931 cmdline_fixed_string_t create;
3932 cmdline_fixed_string_t bonded;
3933 cmdline_fixed_string_t device;
3938 static int bond_dev_num = 0;
3940 static void cmd_create_bonded_device_parsed(void *parsed_result,
3941 __attribute__((unused)) struct cmdline *cl,
3942 __attribute__((unused)) void *data)
3944 struct cmd_create_bonded_device_result *res = parsed_result;
3945 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3948 if (test_done == 0) {
3949 printf("Please stop forwarding first\n");
3953 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3956 /* Create a new bonded device. */
3957 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3959 printf("\t Failed to create bonded device.\n");
3962 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3965 /* Update number of ports */
3966 nb_ports = rte_eth_dev_count();
3967 reconfig(port_id, res->socket);
3968 rte_eth_promiscuous_enable(port_id);
3973 cmdline_parse_token_string_t cmd_createbonded_device_create =
3974 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3976 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3977 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3979 cmdline_parse_token_string_t cmd_createbonded_device_device =
3980 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3982 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3983 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3985 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3986 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3989 cmdline_parse_inst_t cmd_create_bonded_device = {
3990 .f = cmd_create_bonded_device_parsed,
3991 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3994 (void *)&cmd_createbonded_device_create,
3995 (void *)&cmd_createbonded_device_bonded,
3996 (void *)&cmd_createbonded_device_device,
3997 (void *)&cmd_createbonded_device_mode,
3998 (void *)&cmd_createbonded_device_socket,
4003 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4004 struct cmd_set_bond_mac_addr_result {
4005 cmdline_fixed_string_t set;
4006 cmdline_fixed_string_t bonding;
4007 cmdline_fixed_string_t mac_addr;
4009 struct ether_addr address;
4012 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4013 __attribute__((unused)) struct cmdline *cl,
4014 __attribute__((unused)) void *data)
4016 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4019 if (res->port_num >= nb_ports) {
4020 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4024 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4026 /* check the return value and print it if is < 0 */
4028 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4031 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4032 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4033 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4034 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4036 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4037 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4039 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4040 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4041 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4042 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4044 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4045 .f = cmd_set_bond_mac_addr_parsed,
4047 .help_str = "set bonding mac_addr (port_id) (address): ",
4049 (void *)&cmd_set_bond_mac_addr_set,
4050 (void *)&cmd_set_bond_mac_addr_bonding,
4051 (void *)&cmd_set_bond_mac_addr_mac,
4052 (void *)&cmd_set_bond_mac_addr_portnum,
4053 (void *)&cmd_set_bond_mac_addr_addr,
4059 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4060 struct cmd_set_bond_mon_period_result {
4061 cmdline_fixed_string_t set;
4062 cmdline_fixed_string_t bonding;
4063 cmdline_fixed_string_t mon_period;
4068 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4069 __attribute__((unused)) struct cmdline *cl,
4070 __attribute__((unused)) void *data)
4072 struct cmd_set_bond_mon_period_result *res = parsed_result;
4075 if (res->port_num >= nb_ports) {
4076 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4080 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4082 /* check the return value and print it if is < 0 */
4084 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4087 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4088 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4090 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4091 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4092 bonding, "bonding");
4093 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4094 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4095 mon_period, "mon_period");
4096 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4097 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4099 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4100 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4103 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4104 .f = cmd_set_bond_mon_period_parsed,
4106 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4108 (void *)&cmd_set_bond_mon_period_set,
4109 (void *)&cmd_set_bond_mon_period_bonding,
4110 (void *)&cmd_set_bond_mon_period_mon_period,
4111 (void *)&cmd_set_bond_mon_period_portnum,
4112 (void *)&cmd_set_bond_mon_period_period_ms,
4117 #endif /* RTE_LIBRTE_PMD_BOND */
4119 /* *** SET FORWARDING MODE *** */
4120 struct cmd_set_fwd_mode_result {
4121 cmdline_fixed_string_t set;
4122 cmdline_fixed_string_t fwd;
4123 cmdline_fixed_string_t mode;
4126 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4127 __attribute__((unused)) struct cmdline *cl,
4128 __attribute__((unused)) void *data)
4130 struct cmd_set_fwd_mode_result *res = parsed_result;
4132 set_pkt_forwarding_mode(res->mode);
4135 cmdline_parse_token_string_t cmd_setfwd_set =
4136 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4137 cmdline_parse_token_string_t cmd_setfwd_fwd =
4138 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4139 cmdline_parse_token_string_t cmd_setfwd_mode =
4140 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4141 "" /* defined at init */);
4143 cmdline_parse_inst_t cmd_set_fwd_mode = {
4144 .f = cmd_set_fwd_mode_parsed,
4146 .help_str = NULL, /* defined at init */
4148 (void *)&cmd_setfwd_set,
4149 (void *)&cmd_setfwd_fwd,
4150 (void *)&cmd_setfwd_mode,
4155 static void cmd_set_fwd_mode_init(void)
4158 static char token[128];
4159 static char help[256];
4160 cmdline_parse_token_string_t *token_struct;
4162 modes = list_pkt_forwarding_modes();
4163 snprintf(help, sizeof help, "set fwd %s - "
4164 "set packet forwarding mode", modes);
4165 cmd_set_fwd_mode.help_str = help;
4167 /* string token separator is # */
4168 for (c = token; *modes != '\0'; modes++)
4173 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4174 token_struct->string_data.str = token;
4177 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4178 struct cmd_set_burst_tx_retry_result {
4179 cmdline_fixed_string_t set;
4180 cmdline_fixed_string_t burst;
4181 cmdline_fixed_string_t tx;
4182 cmdline_fixed_string_t delay;
4184 cmdline_fixed_string_t retry;
4188 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4189 __attribute__((unused)) struct cmdline *cl,
4190 __attribute__((unused)) void *data)
4192 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4194 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4195 && !strcmp(res->tx, "tx")) {
4196 if (!strcmp(res->delay, "delay"))
4197 burst_tx_delay_time = res->time;
4198 if (!strcmp(res->retry, "retry"))
4199 burst_tx_retry_num = res->retry_num;
4204 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4205 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4206 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4207 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4209 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4210 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4211 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4212 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4213 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4214 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4215 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4216 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4217 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4218 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4220 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4221 .f = cmd_set_burst_tx_retry_parsed,
4222 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4224 (void *)&cmd_set_burst_tx_retry_set,
4225 (void *)&cmd_set_burst_tx_retry_burst,
4226 (void *)&cmd_set_burst_tx_retry_tx,
4227 (void *)&cmd_set_burst_tx_retry_delay,
4228 (void *)&cmd_set_burst_tx_retry_time,
4229 (void *)&cmd_set_burst_tx_retry_retry,
4230 (void *)&cmd_set_burst_tx_retry_retry_num,
4235 /* *** SET PROMISC MODE *** */
4236 struct cmd_set_promisc_mode_result {
4237 cmdline_fixed_string_t set;
4238 cmdline_fixed_string_t promisc;
4239 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4240 uint8_t port_num; /* valid if "allports" argument == 0 */
4241 cmdline_fixed_string_t mode;
4244 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4245 __attribute__((unused)) struct cmdline *cl,
4248 struct cmd_set_promisc_mode_result *res = parsed_result;
4252 if (!strcmp(res->mode, "on"))
4259 for (i = 0; i < nb_ports; i++) {
4261 rte_eth_promiscuous_enable(i);
4263 rte_eth_promiscuous_disable(i);
4268 rte_eth_promiscuous_enable(res->port_num);
4270 rte_eth_promiscuous_disable(res->port_num);
4274 cmdline_parse_token_string_t cmd_setpromisc_set =
4275 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4276 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4277 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4279 cmdline_parse_token_string_t cmd_setpromisc_portall =
4280 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4282 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4283 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4285 cmdline_parse_token_string_t cmd_setpromisc_mode =
4286 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4289 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4290 .f = cmd_set_promisc_mode_parsed,
4292 .help_str = "set promisc all on|off: set promisc mode for all ports",
4294 (void *)&cmd_setpromisc_set,
4295 (void *)&cmd_setpromisc_promisc,
4296 (void *)&cmd_setpromisc_portall,
4297 (void *)&cmd_setpromisc_mode,
4302 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4303 .f = cmd_set_promisc_mode_parsed,
4305 .help_str = "set promisc X on|off: set promisc mode on port X",
4307 (void *)&cmd_setpromisc_set,
4308 (void *)&cmd_setpromisc_promisc,
4309 (void *)&cmd_setpromisc_portnum,
4310 (void *)&cmd_setpromisc_mode,
4315 /* *** SET ALLMULTI MODE *** */
4316 struct cmd_set_allmulti_mode_result {
4317 cmdline_fixed_string_t set;
4318 cmdline_fixed_string_t allmulti;
4319 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4320 uint8_t port_num; /* valid if "allports" argument == 0 */
4321 cmdline_fixed_string_t mode;
4324 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4325 __attribute__((unused)) struct cmdline *cl,
4328 struct cmd_set_allmulti_mode_result *res = parsed_result;
4332 if (!strcmp(res->mode, "on"))
4339 for (i = 0; i < nb_ports; i++) {
4341 rte_eth_allmulticast_enable(i);
4343 rte_eth_allmulticast_disable(i);
4348 rte_eth_allmulticast_enable(res->port_num);
4350 rte_eth_allmulticast_disable(res->port_num);
4354 cmdline_parse_token_string_t cmd_setallmulti_set =
4355 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4356 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4357 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4359 cmdline_parse_token_string_t cmd_setallmulti_portall =
4360 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4362 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4363 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4365 cmdline_parse_token_string_t cmd_setallmulti_mode =
4366 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4369 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4370 .f = cmd_set_allmulti_mode_parsed,
4372 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4374 (void *)&cmd_setallmulti_set,
4375 (void *)&cmd_setallmulti_allmulti,
4376 (void *)&cmd_setallmulti_portall,
4377 (void *)&cmd_setallmulti_mode,
4382 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4383 .f = cmd_set_allmulti_mode_parsed,
4385 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4387 (void *)&cmd_setallmulti_set,
4388 (void *)&cmd_setallmulti_allmulti,
4389 (void *)&cmd_setallmulti_portnum,
4390 (void *)&cmd_setallmulti_mode,
4395 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4396 struct cmd_link_flow_ctrl_set_result {
4397 cmdline_fixed_string_t set;
4398 cmdline_fixed_string_t flow_ctrl;
4399 cmdline_fixed_string_t rx;
4400 cmdline_fixed_string_t rx_lfc_mode;
4401 cmdline_fixed_string_t tx;
4402 cmdline_fixed_string_t tx_lfc_mode;
4403 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4404 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4405 cmdline_fixed_string_t autoneg_str;
4406 cmdline_fixed_string_t autoneg;
4407 cmdline_fixed_string_t hw_str;
4408 uint32_t high_water;
4409 cmdline_fixed_string_t lw_str;
4411 cmdline_fixed_string_t pt_str;
4412 uint16_t pause_time;
4413 cmdline_fixed_string_t xon_str;
4418 cmdline_parse_token_string_t cmd_lfc_set_set =
4419 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4421 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4423 flow_ctrl, "flow_ctrl");
4424 cmdline_parse_token_string_t cmd_lfc_set_rx =
4425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4427 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4429 rx_lfc_mode, "on#off");
4430 cmdline_parse_token_string_t cmd_lfc_set_tx =
4431 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4433 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4434 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4435 tx_lfc_mode, "on#off");
4436 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4437 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4438 hw_str, "high_water");
4439 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4440 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4441 high_water, UINT32);
4442 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4443 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4444 lw_str, "low_water");
4445 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4446 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4448 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4449 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4450 pt_str, "pause_time");
4451 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4452 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4453 pause_time, UINT16);
4454 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4455 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4456 xon_str, "send_xon");
4457 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4458 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4460 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4461 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4462 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4463 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4464 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4465 mac_ctrl_frame_fwd_mode, "on#off");
4466 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4467 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4468 autoneg_str, "autoneg");
4469 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4470 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4472 cmdline_parse_token_num_t cmd_lfc_set_portid =
4473 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4476 /* forward declaration */
4478 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4481 cmdline_parse_inst_t cmd_link_flow_control_set = {
4482 .f = cmd_link_flow_ctrl_set_parsed,
4484 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4485 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4486 autoneg on|off port_id",
4488 (void *)&cmd_lfc_set_set,
4489 (void *)&cmd_lfc_set_flow_ctrl,
4490 (void *)&cmd_lfc_set_rx,
4491 (void *)&cmd_lfc_set_rx_mode,
4492 (void *)&cmd_lfc_set_tx,
4493 (void *)&cmd_lfc_set_tx_mode,
4494 (void *)&cmd_lfc_set_high_water,
4495 (void *)&cmd_lfc_set_low_water,
4496 (void *)&cmd_lfc_set_pause_time,
4497 (void *)&cmd_lfc_set_send_xon,
4498 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4499 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4500 (void *)&cmd_lfc_set_autoneg_str,
4501 (void *)&cmd_lfc_set_autoneg,
4502 (void *)&cmd_lfc_set_portid,
4507 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4508 .f = cmd_link_flow_ctrl_set_parsed,
4509 .data = (void *)&cmd_link_flow_control_set_rx,
4510 .help_str = "Change rx flow control parameter: set flow_ctrl "
4511 "rx on|off port_id",
4513 (void *)&cmd_lfc_set_set,
4514 (void *)&cmd_lfc_set_flow_ctrl,
4515 (void *)&cmd_lfc_set_rx,
4516 (void *)&cmd_lfc_set_rx_mode,
4517 (void *)&cmd_lfc_set_portid,
4522 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4523 .f = cmd_link_flow_ctrl_set_parsed,
4524 .data = (void *)&cmd_link_flow_control_set_tx,
4525 .help_str = "Change tx flow control parameter: set flow_ctrl "
4526 "tx on|off port_id",
4528 (void *)&cmd_lfc_set_set,
4529 (void *)&cmd_lfc_set_flow_ctrl,
4530 (void *)&cmd_lfc_set_tx,
4531 (void *)&cmd_lfc_set_tx_mode,
4532 (void *)&cmd_lfc_set_portid,
4537 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4538 .f = cmd_link_flow_ctrl_set_parsed,
4539 .data = (void *)&cmd_link_flow_control_set_hw,
4540 .help_str = "Change high water flow control parameter: set flow_ctrl "
4541 "high_water value port_id",
4543 (void *)&cmd_lfc_set_set,
4544 (void *)&cmd_lfc_set_flow_ctrl,
4545 (void *)&cmd_lfc_set_high_water_str,
4546 (void *)&cmd_lfc_set_high_water,
4547 (void *)&cmd_lfc_set_portid,
4552 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4553 .f = cmd_link_flow_ctrl_set_parsed,
4554 .data = (void *)&cmd_link_flow_control_set_lw,
4555 .help_str = "Change low water flow control parameter: set flow_ctrl "
4556 "low_water value port_id",
4558 (void *)&cmd_lfc_set_set,
4559 (void *)&cmd_lfc_set_flow_ctrl,
4560 (void *)&cmd_lfc_set_low_water_str,
4561 (void *)&cmd_lfc_set_low_water,
4562 (void *)&cmd_lfc_set_portid,
4567 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4568 .f = cmd_link_flow_ctrl_set_parsed,
4569 .data = (void *)&cmd_link_flow_control_set_pt,
4570 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4571 "pause_time value port_id",
4573 (void *)&cmd_lfc_set_set,
4574 (void *)&cmd_lfc_set_flow_ctrl,
4575 (void *)&cmd_lfc_set_pause_time_str,
4576 (void *)&cmd_lfc_set_pause_time,
4577 (void *)&cmd_lfc_set_portid,
4582 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4583 .f = cmd_link_flow_ctrl_set_parsed,
4584 .data = (void *)&cmd_link_flow_control_set_xon,
4585 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4586 "send_xon value port_id",
4588 (void *)&cmd_lfc_set_set,
4589 (void *)&cmd_lfc_set_flow_ctrl,
4590 (void *)&cmd_lfc_set_send_xon_str,
4591 (void *)&cmd_lfc_set_send_xon,
4592 (void *)&cmd_lfc_set_portid,
4597 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4598 .f = cmd_link_flow_ctrl_set_parsed,
4599 .data = (void *)&cmd_link_flow_control_set_macfwd,
4600 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4601 "mac_ctrl_frame_fwd on|off port_id",
4603 (void *)&cmd_lfc_set_set,
4604 (void *)&cmd_lfc_set_flow_ctrl,
4605 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4606 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4607 (void *)&cmd_lfc_set_portid,
4612 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4613 .f = cmd_link_flow_ctrl_set_parsed,
4614 .data = (void *)&cmd_link_flow_control_set_autoneg,
4615 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4616 "autoneg on|off port_id",
4618 (void *)&cmd_lfc_set_set,
4619 (void *)&cmd_lfc_set_flow_ctrl,
4620 (void *)&cmd_lfc_set_autoneg_str,
4621 (void *)&cmd_lfc_set_autoneg,
4622 (void *)&cmd_lfc_set_portid,
4628 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4629 __attribute__((unused)) struct cmdline *cl,
4632 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4633 cmdline_parse_inst_t *cmd = data;
4634 struct rte_eth_fc_conf fc_conf;
4635 int rx_fc_en, tx_fc_en = 0;
4639 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4640 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4641 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4642 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4644 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4645 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4648 /* Partial command line, retrieve current configuration */
4650 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4652 printf("cannot get current flow ctrl parameters, return"
4653 "code = %d\n", ret);
4657 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4658 (fc_conf.mode == RTE_FC_FULL))
4660 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4661 (fc_conf.mode == RTE_FC_FULL))
4665 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4666 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4668 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4669 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4671 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4673 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4674 fc_conf.high_water = res->high_water;
4676 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4677 fc_conf.low_water = res->low_water;
4679 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4680 fc_conf.pause_time = res->pause_time;
4682 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4683 fc_conf.send_xon = res->send_xon;
4685 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4686 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4687 fc_conf.mac_ctrl_frame_fwd = 1;
4689 fc_conf.mac_ctrl_frame_fwd = 0;
4692 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4693 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4695 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4697 printf("bad flow contrl parameter, return code = %d \n", ret);
4700 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4701 struct cmd_priority_flow_ctrl_set_result {
4702 cmdline_fixed_string_t set;
4703 cmdline_fixed_string_t pfc_ctrl;
4704 cmdline_fixed_string_t rx;
4705 cmdline_fixed_string_t rx_pfc_mode;
4706 cmdline_fixed_string_t tx;
4707 cmdline_fixed_string_t tx_pfc_mode;
4708 uint32_t high_water;
4710 uint16_t pause_time;
4716 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4717 __attribute__((unused)) struct cmdline *cl,
4718 __attribute__((unused)) void *data)
4720 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4721 struct rte_eth_pfc_conf pfc_conf;
4722 int rx_fc_enable, tx_fc_enable;
4726 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4727 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4728 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4729 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4731 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4732 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4735 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4736 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4737 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4738 pfc_conf.fc.high_water = res->high_water;
4739 pfc_conf.fc.low_water = res->low_water;
4740 pfc_conf.fc.pause_time = res->pause_time;
4741 pfc_conf.priority = res->priority;
4743 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4745 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4748 cmdline_parse_token_string_t cmd_pfc_set_set =
4749 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4751 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4752 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4753 pfc_ctrl, "pfc_ctrl");
4754 cmdline_parse_token_string_t cmd_pfc_set_rx =
4755 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4757 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4758 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4759 rx_pfc_mode, "on#off");
4760 cmdline_parse_token_string_t cmd_pfc_set_tx =
4761 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4763 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4764 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4765 tx_pfc_mode, "on#off");
4766 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4767 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4768 high_water, UINT32);
4769 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4770 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4772 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4773 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4774 pause_time, UINT16);
4775 cmdline_parse_token_num_t cmd_pfc_set_priority =
4776 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4778 cmdline_parse_token_num_t cmd_pfc_set_portid =
4779 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4782 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4783 .f = cmd_priority_flow_ctrl_set_parsed,
4785 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4786 tx on|off high_water low_water pause_time priority port_id",
4788 (void *)&cmd_pfc_set_set,
4789 (void *)&cmd_pfc_set_flow_ctrl,
4790 (void *)&cmd_pfc_set_rx,
4791 (void *)&cmd_pfc_set_rx_mode,
4792 (void *)&cmd_pfc_set_tx,
4793 (void *)&cmd_pfc_set_tx_mode,
4794 (void *)&cmd_pfc_set_high_water,
4795 (void *)&cmd_pfc_set_low_water,
4796 (void *)&cmd_pfc_set_pause_time,
4797 (void *)&cmd_pfc_set_priority,
4798 (void *)&cmd_pfc_set_portid,
4803 /* *** RESET CONFIGURATION *** */
4804 struct cmd_reset_result {
4805 cmdline_fixed_string_t reset;
4806 cmdline_fixed_string_t def;
4809 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4811 __attribute__((unused)) void *data)
4813 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4814 set_def_fwd_config();
4817 cmdline_parse_token_string_t cmd_reset_set =
4818 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4819 cmdline_parse_token_string_t cmd_reset_def =
4820 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4823 cmdline_parse_inst_t cmd_reset = {
4824 .f = cmd_reset_parsed,
4826 .help_str = "set default: reset default forwarding configuration",
4828 (void *)&cmd_reset_set,
4829 (void *)&cmd_reset_def,
4834 /* *** START FORWARDING *** */
4835 struct cmd_start_result {
4836 cmdline_fixed_string_t start;
4839 cmdline_parse_token_string_t cmd_start_start =
4840 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4842 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4843 __attribute__((unused)) struct cmdline *cl,
4844 __attribute__((unused)) void *data)
4846 start_packet_forwarding(0);
4849 cmdline_parse_inst_t cmd_start = {
4850 .f = cmd_start_parsed,
4852 .help_str = "start packet forwarding",
4854 (void *)&cmd_start_start,
4859 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4860 struct cmd_start_tx_first_result {
4861 cmdline_fixed_string_t start;
4862 cmdline_fixed_string_t tx_first;
4866 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4867 __attribute__((unused)) struct cmdline *cl,
4868 __attribute__((unused)) void *data)
4870 start_packet_forwarding(1);
4873 cmdline_parse_token_string_t cmd_start_tx_first_start =
4874 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4876 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4877 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4878 tx_first, "tx_first");
4880 cmdline_parse_inst_t cmd_start_tx_first = {
4881 .f = cmd_start_tx_first_parsed,
4883 .help_str = "start packet forwarding, after sending 1 burst of packets",
4885 (void *)&cmd_start_tx_first_start,
4886 (void *)&cmd_start_tx_first_tx_first,
4891 /* *** SET LINK UP *** */
4892 struct cmd_set_link_up_result {
4893 cmdline_fixed_string_t set;
4894 cmdline_fixed_string_t link_up;
4895 cmdline_fixed_string_t port;
4899 cmdline_parse_token_string_t cmd_set_link_up_set =
4900 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4901 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4902 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4904 cmdline_parse_token_string_t cmd_set_link_up_port =
4905 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4906 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4907 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4909 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4910 __attribute__((unused)) struct cmdline *cl,
4911 __attribute__((unused)) void *data)
4913 struct cmd_set_link_up_result *res = parsed_result;
4914 dev_set_link_up(res->port_id);
4917 cmdline_parse_inst_t cmd_set_link_up = {
4918 .f = cmd_set_link_up_parsed,
4920 .help_str = "set link-up port (port id)",
4922 (void *)&cmd_set_link_up_set,
4923 (void *)&cmd_set_link_up_link_up,
4924 (void *)&cmd_set_link_up_port,
4925 (void *)&cmd_set_link_up_port_id,
4930 /* *** SET LINK DOWN *** */
4931 struct cmd_set_link_down_result {
4932 cmdline_fixed_string_t set;
4933 cmdline_fixed_string_t link_down;
4934 cmdline_fixed_string_t port;
4938 cmdline_parse_token_string_t cmd_set_link_down_set =
4939 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4940 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4941 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4943 cmdline_parse_token_string_t cmd_set_link_down_port =
4944 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4945 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4946 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4948 static void cmd_set_link_down_parsed(
4949 __attribute__((unused)) void *parsed_result,
4950 __attribute__((unused)) struct cmdline *cl,
4951 __attribute__((unused)) void *data)
4953 struct cmd_set_link_down_result *res = parsed_result;
4954 dev_set_link_down(res->port_id);
4957 cmdline_parse_inst_t cmd_set_link_down = {
4958 .f = cmd_set_link_down_parsed,
4960 .help_str = "set link-down port (port id)",
4962 (void *)&cmd_set_link_down_set,
4963 (void *)&cmd_set_link_down_link_down,
4964 (void *)&cmd_set_link_down_port,
4965 (void *)&cmd_set_link_down_port_id,
4970 /* *** SHOW CFG *** */
4971 struct cmd_showcfg_result {
4972 cmdline_fixed_string_t show;
4973 cmdline_fixed_string_t cfg;
4974 cmdline_fixed_string_t what;
4977 static void cmd_showcfg_parsed(void *parsed_result,
4978 __attribute__((unused)) struct cmdline *cl,
4979 __attribute__((unused)) void *data)
4981 struct cmd_showcfg_result *res = parsed_result;
4982 if (!strcmp(res->what, "rxtx"))
4983 rxtx_config_display();
4984 else if (!strcmp(res->what, "cores"))
4985 fwd_lcores_config_display();
4986 else if (!strcmp(res->what, "fwd"))
4987 fwd_config_display();
4990 cmdline_parse_token_string_t cmd_showcfg_show =
4991 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4992 cmdline_parse_token_string_t cmd_showcfg_port =
4993 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4994 cmdline_parse_token_string_t cmd_showcfg_what =
4995 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4998 cmdline_parse_inst_t cmd_showcfg = {
4999 .f = cmd_showcfg_parsed,
5001 .help_str = "show config rxtx|cores|fwd",
5003 (void *)&cmd_showcfg_show,
5004 (void *)&cmd_showcfg_port,
5005 (void *)&cmd_showcfg_what,
5010 /* *** SHOW ALL PORT INFO *** */
5011 struct cmd_showportall_result {
5012 cmdline_fixed_string_t show;
5013 cmdline_fixed_string_t port;
5014 cmdline_fixed_string_t what;
5015 cmdline_fixed_string_t all;
5018 static void cmd_showportall_parsed(void *parsed_result,
5019 __attribute__((unused)) struct cmdline *cl,
5020 __attribute__((unused)) void *data)
5024 struct cmd_showportall_result *res = parsed_result;
5025 if (!strcmp(res->show, "clear")) {
5026 if (!strcmp(res->what, "stats"))
5027 for (i = 0; i < nb_ports; i++)
5029 else if (!strcmp(res->what, "xstats"))
5030 for (i = 0; i < nb_ports; i++)
5031 nic_xstats_clear(i);
5032 } else if (!strcmp(res->what, "info"))
5033 for (i = 0; i < nb_ports; i++)
5034 port_infos_display(i);
5035 else if (!strcmp(res->what, "stats"))
5036 for (i = 0; i < nb_ports; i++)
5037 nic_stats_display(i);
5038 else if (!strcmp(res->what, "xstats"))
5039 for (i = 0; i < nb_ports; i++)
5040 nic_xstats_display(i);
5041 else if (!strcmp(res->what, "fdir"))
5042 for (i = 0; i < nb_ports; i++)
5044 else if (!strcmp(res->what, "stat_qmap"))
5045 for (i = 0; i < nb_ports; i++)
5046 nic_stats_mapping_display(i);
5049 cmdline_parse_token_string_t cmd_showportall_show =
5050 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5052 cmdline_parse_token_string_t cmd_showportall_port =
5053 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5054 cmdline_parse_token_string_t cmd_showportall_what =
5055 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5056 "info#stats#xstats#fdir#stat_qmap");
5057 cmdline_parse_token_string_t cmd_showportall_all =
5058 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5059 cmdline_parse_inst_t cmd_showportall = {
5060 .f = cmd_showportall_parsed,
5062 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5064 (void *)&cmd_showportall_show,
5065 (void *)&cmd_showportall_port,
5066 (void *)&cmd_showportall_what,
5067 (void *)&cmd_showportall_all,
5072 /* *** SHOW PORT INFO *** */
5073 struct cmd_showport_result {
5074 cmdline_fixed_string_t show;
5075 cmdline_fixed_string_t port;
5076 cmdline_fixed_string_t what;
5080 static void cmd_showport_parsed(void *parsed_result,
5081 __attribute__((unused)) struct cmdline *cl,
5082 __attribute__((unused)) void *data)
5084 struct cmd_showport_result *res = parsed_result;
5085 if (!strcmp(res->show, "clear")) {
5086 if (!strcmp(res->what, "stats"))
5087 nic_stats_clear(res->portnum);
5088 else if (!strcmp(res->what, "xstats"))
5089 nic_xstats_clear(res->portnum);
5090 } else if (!strcmp(res->what, "info"))
5091 port_infos_display(res->portnum);
5092 else if (!strcmp(res->what, "stats"))
5093 nic_stats_display(res->portnum);
5094 else if (!strcmp(res->what, "xstats"))
5095 nic_xstats_display(res->portnum);
5096 else if (!strcmp(res->what, "fdir"))
5097 fdir_get_infos(res->portnum);
5098 else if (!strcmp(res->what, "stat_qmap"))
5099 nic_stats_mapping_display(res->portnum);
5102 cmdline_parse_token_string_t cmd_showport_show =
5103 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5105 cmdline_parse_token_string_t cmd_showport_port =
5106 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5107 cmdline_parse_token_string_t cmd_showport_what =
5108 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5109 "info#stats#xstats#fdir#stat_qmap");
5110 cmdline_parse_token_num_t cmd_showport_portnum =
5111 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5113 cmdline_parse_inst_t cmd_showport = {
5114 .f = cmd_showport_parsed,
5116 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5118 (void *)&cmd_showport_show,
5119 (void *)&cmd_showport_port,
5120 (void *)&cmd_showport_what,
5121 (void *)&cmd_showport_portnum,
5126 /* *** READ PORT REGISTER *** */
5127 struct cmd_read_reg_result {
5128 cmdline_fixed_string_t read;
5129 cmdline_fixed_string_t reg;
5135 cmd_read_reg_parsed(void *parsed_result,
5136 __attribute__((unused)) struct cmdline *cl,
5137 __attribute__((unused)) void *data)
5139 struct cmd_read_reg_result *res = parsed_result;
5140 port_reg_display(res->port_id, res->reg_off);
5143 cmdline_parse_token_string_t cmd_read_reg_read =
5144 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5145 cmdline_parse_token_string_t cmd_read_reg_reg =
5146 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5147 cmdline_parse_token_num_t cmd_read_reg_port_id =
5148 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5149 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5150 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5152 cmdline_parse_inst_t cmd_read_reg = {
5153 .f = cmd_read_reg_parsed,
5155 .help_str = "read reg port_id reg_off",
5157 (void *)&cmd_read_reg_read,
5158 (void *)&cmd_read_reg_reg,
5159 (void *)&cmd_read_reg_port_id,
5160 (void *)&cmd_read_reg_reg_off,
5165 /* *** READ PORT REGISTER BIT FIELD *** */
5166 struct cmd_read_reg_bit_field_result {
5167 cmdline_fixed_string_t read;
5168 cmdline_fixed_string_t regfield;
5176 cmd_read_reg_bit_field_parsed(void *parsed_result,
5177 __attribute__((unused)) struct cmdline *cl,
5178 __attribute__((unused)) void *data)
5180 struct cmd_read_reg_bit_field_result *res = parsed_result;
5181 port_reg_bit_field_display(res->port_id, res->reg_off,
5182 res->bit1_pos, res->bit2_pos);
5185 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5186 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5188 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5189 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5190 regfield, "regfield");
5191 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5192 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5194 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5195 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5197 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5198 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5200 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5201 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5204 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5205 .f = cmd_read_reg_bit_field_parsed,
5207 .help_str = "read regfield port_id reg_off bit_x bit_y "
5208 "(read register bit field between bit_x and bit_y included)",
5210 (void *)&cmd_read_reg_bit_field_read,
5211 (void *)&cmd_read_reg_bit_field_regfield,
5212 (void *)&cmd_read_reg_bit_field_port_id,
5213 (void *)&cmd_read_reg_bit_field_reg_off,
5214 (void *)&cmd_read_reg_bit_field_bit1_pos,
5215 (void *)&cmd_read_reg_bit_field_bit2_pos,
5220 /* *** READ PORT REGISTER BIT *** */
5221 struct cmd_read_reg_bit_result {
5222 cmdline_fixed_string_t read;
5223 cmdline_fixed_string_t regbit;
5230 cmd_read_reg_bit_parsed(void *parsed_result,
5231 __attribute__((unused)) struct cmdline *cl,
5232 __attribute__((unused)) void *data)
5234 struct cmd_read_reg_bit_result *res = parsed_result;
5235 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5238 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5239 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5240 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5241 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5243 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5244 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5245 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5246 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5247 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5248 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5250 cmdline_parse_inst_t cmd_read_reg_bit = {
5251 .f = cmd_read_reg_bit_parsed,
5253 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5255 (void *)&cmd_read_reg_bit_read,
5256 (void *)&cmd_read_reg_bit_regbit,
5257 (void *)&cmd_read_reg_bit_port_id,
5258 (void *)&cmd_read_reg_bit_reg_off,
5259 (void *)&cmd_read_reg_bit_bit_pos,
5264 /* *** WRITE PORT REGISTER *** */
5265 struct cmd_write_reg_result {
5266 cmdline_fixed_string_t write;
5267 cmdline_fixed_string_t reg;
5274 cmd_write_reg_parsed(void *parsed_result,
5275 __attribute__((unused)) struct cmdline *cl,
5276 __attribute__((unused)) void *data)
5278 struct cmd_write_reg_result *res = parsed_result;
5279 port_reg_set(res->port_id, res->reg_off, res->value);
5282 cmdline_parse_token_string_t cmd_write_reg_write =
5283 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5284 cmdline_parse_token_string_t cmd_write_reg_reg =
5285 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5286 cmdline_parse_token_num_t cmd_write_reg_port_id =
5287 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5288 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5289 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5290 cmdline_parse_token_num_t cmd_write_reg_value =
5291 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5293 cmdline_parse_inst_t cmd_write_reg = {
5294 .f = cmd_write_reg_parsed,
5296 .help_str = "write reg port_id reg_off reg_value",
5298 (void *)&cmd_write_reg_write,
5299 (void *)&cmd_write_reg_reg,
5300 (void *)&cmd_write_reg_port_id,
5301 (void *)&cmd_write_reg_reg_off,
5302 (void *)&cmd_write_reg_value,
5307 /* *** WRITE PORT REGISTER BIT FIELD *** */
5308 struct cmd_write_reg_bit_field_result {
5309 cmdline_fixed_string_t write;
5310 cmdline_fixed_string_t regfield;
5319 cmd_write_reg_bit_field_parsed(void *parsed_result,
5320 __attribute__((unused)) struct cmdline *cl,
5321 __attribute__((unused)) void *data)
5323 struct cmd_write_reg_bit_field_result *res = parsed_result;
5324 port_reg_bit_field_set(res->port_id, res->reg_off,
5325 res->bit1_pos, res->bit2_pos, res->value);
5328 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5329 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5331 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5332 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5333 regfield, "regfield");
5334 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5335 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5337 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5338 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5340 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5341 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5343 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5344 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5346 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5347 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5350 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5351 .f = cmd_write_reg_bit_field_parsed,
5353 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5354 "(set register bit field between bit_x and bit_y included)",
5356 (void *)&cmd_write_reg_bit_field_write,
5357 (void *)&cmd_write_reg_bit_field_regfield,
5358 (void *)&cmd_write_reg_bit_field_port_id,
5359 (void *)&cmd_write_reg_bit_field_reg_off,
5360 (void *)&cmd_write_reg_bit_field_bit1_pos,
5361 (void *)&cmd_write_reg_bit_field_bit2_pos,
5362 (void *)&cmd_write_reg_bit_field_value,
5367 /* *** WRITE PORT REGISTER BIT *** */
5368 struct cmd_write_reg_bit_result {
5369 cmdline_fixed_string_t write;
5370 cmdline_fixed_string_t regbit;
5378 cmd_write_reg_bit_parsed(void *parsed_result,
5379 __attribute__((unused)) struct cmdline *cl,
5380 __attribute__((unused)) void *data)
5382 struct cmd_write_reg_bit_result *res = parsed_result;
5383 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5386 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5387 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5389 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5390 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5392 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5393 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5394 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5395 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5396 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5397 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5398 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5399 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5401 cmdline_parse_inst_t cmd_write_reg_bit = {
5402 .f = cmd_write_reg_bit_parsed,
5404 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5406 (void *)&cmd_write_reg_bit_write,
5407 (void *)&cmd_write_reg_bit_regbit,
5408 (void *)&cmd_write_reg_bit_port_id,
5409 (void *)&cmd_write_reg_bit_reg_off,
5410 (void *)&cmd_write_reg_bit_bit_pos,
5411 (void *)&cmd_write_reg_bit_value,
5416 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5417 struct cmd_read_rxd_txd_result {
5418 cmdline_fixed_string_t read;
5419 cmdline_fixed_string_t rxd_txd;
5426 cmd_read_rxd_txd_parsed(void *parsed_result,
5427 __attribute__((unused)) struct cmdline *cl,
5428 __attribute__((unused)) void *data)
5430 struct cmd_read_rxd_txd_result *res = parsed_result;
5432 if (!strcmp(res->rxd_txd, "rxd"))
5433 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5434 else if (!strcmp(res->rxd_txd, "txd"))
5435 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5438 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5439 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5440 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5441 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5443 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5444 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5445 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5446 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5447 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5448 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5450 cmdline_parse_inst_t cmd_read_rxd_txd = {
5451 .f = cmd_read_rxd_txd_parsed,
5453 .help_str = "read rxd|txd port_id queue_id rxd_id",
5455 (void *)&cmd_read_rxd_txd_read,
5456 (void *)&cmd_read_rxd_txd_rxd_txd,
5457 (void *)&cmd_read_rxd_txd_port_id,
5458 (void *)&cmd_read_rxd_txd_queue_id,
5459 (void *)&cmd_read_rxd_txd_desc_id,
5465 struct cmd_quit_result {
5466 cmdline_fixed_string_t quit;
5469 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5471 __attribute__((unused)) void *data)
5477 cmdline_parse_token_string_t cmd_quit_quit =
5478 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5480 cmdline_parse_inst_t cmd_quit = {
5481 .f = cmd_quit_parsed,
5483 .help_str = "exit application",
5485 (void *)&cmd_quit_quit,
5490 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5491 struct cmd_mac_addr_result {
5492 cmdline_fixed_string_t mac_addr_cmd;
5493 cmdline_fixed_string_t what;
5495 struct ether_addr address;
5498 static void cmd_mac_addr_parsed(void *parsed_result,
5499 __attribute__((unused)) struct cmdline *cl,
5500 __attribute__((unused)) void *data)
5502 struct cmd_mac_addr_result *res = parsed_result;
5505 if (strcmp(res->what, "add") == 0)
5506 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5508 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5510 /* check the return value and print it if is < 0 */
5512 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5516 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5517 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5519 cmdline_parse_token_string_t cmd_mac_addr_what =
5520 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5522 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5523 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5524 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5525 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5527 cmdline_parse_inst_t cmd_mac_addr = {
5528 .f = cmd_mac_addr_parsed,
5530 .help_str = "mac_addr add|remove X <address>: "
5531 "add/remove MAC address on port X",
5533 (void *)&cmd_mac_addr_cmd,
5534 (void *)&cmd_mac_addr_what,
5535 (void *)&cmd_mac_addr_portnum,
5536 (void *)&cmd_mac_addr_addr,
5542 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5543 struct cmd_set_qmap_result {
5544 cmdline_fixed_string_t set;
5545 cmdline_fixed_string_t qmap;
5546 cmdline_fixed_string_t what;
5553 cmd_set_qmap_parsed(void *parsed_result,
5554 __attribute__((unused)) struct cmdline *cl,
5555 __attribute__((unused)) void *data)
5557 struct cmd_set_qmap_result *res = parsed_result;
5558 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5560 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5563 cmdline_parse_token_string_t cmd_setqmap_set =
5564 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5566 cmdline_parse_token_string_t cmd_setqmap_qmap =
5567 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5569 cmdline_parse_token_string_t cmd_setqmap_what =
5570 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5572 cmdline_parse_token_num_t cmd_setqmap_portid =
5573 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5575 cmdline_parse_token_num_t cmd_setqmap_queueid =
5576 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5578 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5579 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5582 cmdline_parse_inst_t cmd_set_qmap = {
5583 .f = cmd_set_qmap_parsed,
5585 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5587 (void *)&cmd_setqmap_set,
5588 (void *)&cmd_setqmap_qmap,
5589 (void *)&cmd_setqmap_what,
5590 (void *)&cmd_setqmap_portid,
5591 (void *)&cmd_setqmap_queueid,
5592 (void *)&cmd_setqmap_mapvalue,
5597 /* *** CONFIGURE UNICAST HASH TABLE *** */
5598 struct cmd_set_uc_hash_table {
5599 cmdline_fixed_string_t set;
5600 cmdline_fixed_string_t port;
5602 cmdline_fixed_string_t what;
5603 struct ether_addr address;
5604 cmdline_fixed_string_t mode;
5608 cmd_set_uc_hash_parsed(void *parsed_result,
5609 __attribute__((unused)) struct cmdline *cl,
5610 __attribute__((unused)) void *data)
5613 struct cmd_set_uc_hash_table *res = parsed_result;
5615 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5617 if (strcmp(res->what, "uta") == 0)
5618 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5619 &res->address,(uint8_t)is_on);
5621 printf("bad unicast hash table parameter, return code = %d \n", ret);
5625 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5626 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5628 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5631 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5632 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5634 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5635 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5637 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5638 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5640 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5641 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5644 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5645 .f = cmd_set_uc_hash_parsed,
5647 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5649 (void *)&cmd_set_uc_hash_set,
5650 (void *)&cmd_set_uc_hash_port,
5651 (void *)&cmd_set_uc_hash_portid,
5652 (void *)&cmd_set_uc_hash_what,
5653 (void *)&cmd_set_uc_hash_mac,
5654 (void *)&cmd_set_uc_hash_mode,
5659 struct cmd_set_uc_all_hash_table {
5660 cmdline_fixed_string_t set;
5661 cmdline_fixed_string_t port;
5663 cmdline_fixed_string_t what;
5664 cmdline_fixed_string_t value;
5665 cmdline_fixed_string_t mode;
5669 cmd_set_uc_all_hash_parsed(void *parsed_result,
5670 __attribute__((unused)) struct cmdline *cl,
5671 __attribute__((unused)) void *data)
5674 struct cmd_set_uc_all_hash_table *res = parsed_result;
5676 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5678 if ((strcmp(res->what, "uta") == 0) &&
5679 (strcmp(res->value, "all") == 0))
5680 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5682 printf("bad unicast hash table parameter,"
5683 "return code = %d \n", ret);
5686 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5687 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5689 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5692 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5693 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5695 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5696 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5698 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5701 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5705 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5706 .f = cmd_set_uc_all_hash_parsed,
5708 .help_str = "set port X uta all on|off (X = port number)",
5710 (void *)&cmd_set_uc_all_hash_set,
5711 (void *)&cmd_set_uc_all_hash_port,
5712 (void *)&cmd_set_uc_all_hash_portid,
5713 (void *)&cmd_set_uc_all_hash_what,
5714 (void *)&cmd_set_uc_all_hash_value,
5715 (void *)&cmd_set_uc_all_hash_mode,
5720 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5721 struct cmd_set_vf_macvlan_filter {
5722 cmdline_fixed_string_t set;
5723 cmdline_fixed_string_t port;
5725 cmdline_fixed_string_t vf;
5727 struct ether_addr address;
5728 cmdline_fixed_string_t filter_type;
5729 cmdline_fixed_string_t mode;
5733 cmd_set_vf_macvlan_parsed(void *parsed_result,
5734 __attribute__((unused)) struct cmdline *cl,
5735 __attribute__((unused)) void *data)
5738 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5739 struct rte_eth_mac_filter filter;
5741 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5743 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5745 /* set VF MAC filter */
5749 filter.dst_id = res->vf_id;
5751 if (!strcmp(res->filter_type, "exact-mac"))
5752 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5753 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5754 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5755 else if (!strcmp(res->filter_type, "hashmac"))
5756 filter.filter_type = RTE_MAC_HASH_MATCH;
5757 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5758 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5760 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5763 ret = rte_eth_dev_filter_ctrl(res->port_id,
5764 RTE_ETH_FILTER_MACVLAN,
5768 ret = rte_eth_dev_filter_ctrl(res->port_id,
5769 RTE_ETH_FILTER_MACVLAN,
5770 RTE_ETH_FILTER_DELETE,
5774 printf("bad set MAC hash parameter, return code = %d\n", ret);
5778 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5779 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5781 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5784 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5785 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5787 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5788 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5790 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5791 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5793 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5794 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5796 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5797 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5798 filter_type, "exact-mac#exact-mac-vlan"
5799 "#hashmac#hashmac-vlan");
5800 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5801 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5804 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5805 .f = cmd_set_vf_macvlan_parsed,
5807 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5808 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5810 "exact match rule:exact match of MAC or MAC and VLAN; "
5811 "hash match rule: hash match of MAC and exact match "
5814 (void *)&cmd_set_vf_macvlan_set,
5815 (void *)&cmd_set_vf_macvlan_port,
5816 (void *)&cmd_set_vf_macvlan_portid,
5817 (void *)&cmd_set_vf_macvlan_vf,
5818 (void *)&cmd_set_vf_macvlan_vf_id,
5819 (void *)&cmd_set_vf_macvlan_mac,
5820 (void *)&cmd_set_vf_macvlan_filter_type,
5821 (void *)&cmd_set_vf_macvlan_mode,
5826 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5827 struct cmd_set_vf_traffic {
5828 cmdline_fixed_string_t set;
5829 cmdline_fixed_string_t port;
5831 cmdline_fixed_string_t vf;
5833 cmdline_fixed_string_t what;
5834 cmdline_fixed_string_t mode;
5838 cmd_set_vf_traffic_parsed(void *parsed_result,
5839 __attribute__((unused)) struct cmdline *cl,
5840 __attribute__((unused)) void *data)
5842 struct cmd_set_vf_traffic *res = parsed_result;
5843 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5844 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5846 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5849 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5852 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5855 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5856 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5858 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5859 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5861 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5862 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5864 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5865 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5867 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5868 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5871 cmdline_parse_inst_t cmd_set_vf_traffic = {
5872 .f = cmd_set_vf_traffic_parsed,
5874 .help_str = "set port X vf Y rx|tx on|off"
5875 "(X = port number,Y = vf id)",
5877 (void *)&cmd_setvf_traffic_set,
5878 (void *)&cmd_setvf_traffic_port,
5879 (void *)&cmd_setvf_traffic_portid,
5880 (void *)&cmd_setvf_traffic_vf,
5881 (void *)&cmd_setvf_traffic_vfid,
5882 (void *)&cmd_setvf_traffic_what,
5883 (void *)&cmd_setvf_traffic_mode,
5888 /* *** CONFIGURE VF RECEIVE MODE *** */
5889 struct cmd_set_vf_rxmode {
5890 cmdline_fixed_string_t set;
5891 cmdline_fixed_string_t port;
5893 cmdline_fixed_string_t vf;
5895 cmdline_fixed_string_t what;
5896 cmdline_fixed_string_t mode;
5897 cmdline_fixed_string_t on;
5901 cmd_set_vf_rxmode_parsed(void *parsed_result,
5902 __attribute__((unused)) struct cmdline *cl,
5903 __attribute__((unused)) void *data)
5906 uint16_t rx_mode = 0;
5907 struct cmd_set_vf_rxmode *res = parsed_result;
5909 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5910 if (!strcmp(res->what,"rxmode")) {
5911 if (!strcmp(res->mode, "AUPE"))
5912 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5913 else if (!strcmp(res->mode, "ROPE"))
5914 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5915 else if (!strcmp(res->mode, "BAM"))
5916 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5917 else if (!strncmp(res->mode, "MPE",3))
5918 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5921 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5923 printf("bad VF receive mode parameter, return code = %d \n",
5927 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5930 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5933 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5934 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5936 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5937 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5939 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5940 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5942 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5943 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5945 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5946 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5947 mode, "AUPE#ROPE#BAM#MPE");
5948 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5949 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5952 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5953 .f = cmd_set_vf_rxmode_parsed,
5955 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5957 (void *)&cmd_set_vf_rxmode_set,
5958 (void *)&cmd_set_vf_rxmode_port,
5959 (void *)&cmd_set_vf_rxmode_portid,
5960 (void *)&cmd_set_vf_rxmode_vf,
5961 (void *)&cmd_set_vf_rxmode_vfid,
5962 (void *)&cmd_set_vf_rxmode_what,
5963 (void *)&cmd_set_vf_rxmode_mode,
5964 (void *)&cmd_set_vf_rxmode_on,
5969 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5970 struct cmd_vf_mac_addr_result {
5971 cmdline_fixed_string_t mac_addr_cmd;
5972 cmdline_fixed_string_t what;
5973 cmdline_fixed_string_t port;
5975 cmdline_fixed_string_t vf;
5977 struct ether_addr address;
5980 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5981 __attribute__((unused)) struct cmdline *cl,
5982 __attribute__((unused)) void *data)
5984 struct cmd_vf_mac_addr_result *res = parsed_result;
5987 if (strcmp(res->what, "add") == 0)
5988 ret = rte_eth_dev_mac_addr_add(res->port_num,
5989 &res->address, res->vf_num);
5991 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5995 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5996 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5997 mac_addr_cmd,"mac_addr");
5998 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5999 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6001 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6002 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6004 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6005 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6007 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6008 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6010 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6011 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6013 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6014 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6017 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6018 .f = cmd_vf_mac_addr_parsed,
6020 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6021 "Y = VF number)add MAC address filtering for a VF on port X",
6023 (void *)&cmd_vf_mac_addr_cmd,
6024 (void *)&cmd_vf_mac_addr_what,
6025 (void *)&cmd_vf_mac_addr_port,
6026 (void *)&cmd_vf_mac_addr_portnum,
6027 (void *)&cmd_vf_mac_addr_vf,
6028 (void *)&cmd_vf_mac_addr_vfnum,
6029 (void *)&cmd_vf_mac_addr_addr,
6034 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6035 struct cmd_vf_rx_vlan_filter {
6036 cmdline_fixed_string_t rx_vlan;
6037 cmdline_fixed_string_t what;
6039 cmdline_fixed_string_t port;
6041 cmdline_fixed_string_t vf;
6046 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6047 __attribute__((unused)) struct cmdline *cl,
6048 __attribute__((unused)) void *data)
6050 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6052 if (!strcmp(res->what, "add"))
6053 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6055 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6058 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6059 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6060 rx_vlan, "rx_vlan");
6061 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6062 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6064 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6065 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6067 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6068 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6070 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6071 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6073 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6074 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6076 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6077 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6080 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6081 .f = cmd_vf_rx_vlan_filter_parsed,
6083 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6084 "Y = port number,Z = hexadecimal VF mask)",
6086 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6087 (void *)&cmd_vf_rx_vlan_filter_what,
6088 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6089 (void *)&cmd_vf_rx_vlan_filter_port,
6090 (void *)&cmd_vf_rx_vlan_filter_portid,
6091 (void *)&cmd_vf_rx_vlan_filter_vf,
6092 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6097 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6098 struct cmd_queue_rate_limit_result {
6099 cmdline_fixed_string_t set;
6100 cmdline_fixed_string_t port;
6102 cmdline_fixed_string_t queue;
6104 cmdline_fixed_string_t rate;
6108 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6109 __attribute__((unused)) struct cmdline *cl,
6110 __attribute__((unused)) void *data)
6112 struct cmd_queue_rate_limit_result *res = parsed_result;
6115 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6116 && (strcmp(res->queue, "queue") == 0)
6117 && (strcmp(res->rate, "rate") == 0))
6118 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6121 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6125 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6126 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6128 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6129 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6131 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6132 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6134 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6135 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6137 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6138 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6140 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6141 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6143 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6144 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6147 cmdline_parse_inst_t cmd_queue_rate_limit = {
6148 .f = cmd_queue_rate_limit_parsed,
6150 .help_str = "set port X queue Y rate Z:(X = port number,"
6151 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6153 (void *)&cmd_queue_rate_limit_set,
6154 (void *)&cmd_queue_rate_limit_port,
6155 (void *)&cmd_queue_rate_limit_portnum,
6156 (void *)&cmd_queue_rate_limit_queue,
6157 (void *)&cmd_queue_rate_limit_queuenum,
6158 (void *)&cmd_queue_rate_limit_rate,
6159 (void *)&cmd_queue_rate_limit_ratenum,
6164 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6165 struct cmd_vf_rate_limit_result {
6166 cmdline_fixed_string_t set;
6167 cmdline_fixed_string_t port;
6169 cmdline_fixed_string_t vf;
6171 cmdline_fixed_string_t rate;
6173 cmdline_fixed_string_t q_msk;
6177 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6178 __attribute__((unused)) struct cmdline *cl,
6179 __attribute__((unused)) void *data)
6181 struct cmd_vf_rate_limit_result *res = parsed_result;
6184 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6185 && (strcmp(res->vf, "vf") == 0)
6186 && (strcmp(res->rate, "rate") == 0)
6187 && (strcmp(res->q_msk, "queue_mask") == 0))
6188 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6189 res->rate_num, res->q_msk_val);
6191 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6195 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6196 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6198 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6199 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6201 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6202 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6204 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6205 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6207 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6208 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6210 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6211 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6213 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6214 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6216 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6217 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6218 q_msk, "queue_mask");
6219 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6220 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6223 cmdline_parse_inst_t cmd_vf_rate_limit = {
6224 .f = cmd_vf_rate_limit_parsed,
6226 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6227 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6228 "for queues of VF on port X",
6230 (void *)&cmd_vf_rate_limit_set,
6231 (void *)&cmd_vf_rate_limit_port,
6232 (void *)&cmd_vf_rate_limit_portnum,
6233 (void *)&cmd_vf_rate_limit_vf,
6234 (void *)&cmd_vf_rate_limit_vfnum,
6235 (void *)&cmd_vf_rate_limit_rate,
6236 (void *)&cmd_vf_rate_limit_ratenum,
6237 (void *)&cmd_vf_rate_limit_q_msk,
6238 (void *)&cmd_vf_rate_limit_q_msk_val,
6243 /* *** ADD TUNNEL FILTER OF A PORT *** */
6244 struct cmd_tunnel_filter_result {
6245 cmdline_fixed_string_t cmd;
6246 cmdline_fixed_string_t what;
6248 struct ether_addr outer_mac;
6249 struct ether_addr inner_mac;
6250 cmdline_ipaddr_t ip_value;
6251 uint16_t inner_vlan;
6252 cmdline_fixed_string_t tunnel_type;
6253 cmdline_fixed_string_t filter_type;
6259 cmd_tunnel_filter_parsed(void *parsed_result,
6260 __attribute__((unused)) struct cmdline *cl,
6261 __attribute__((unused)) void *data)
6263 struct cmd_tunnel_filter_result *res = parsed_result;
6264 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6267 tunnel_filter_conf.outer_mac = &res->outer_mac;
6268 tunnel_filter_conf.inner_mac = &res->inner_mac;
6269 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6271 if (res->ip_value.family == AF_INET) {
6272 tunnel_filter_conf.ip_addr.ipv4_addr =
6273 res->ip_value.addr.ipv4.s_addr;
6274 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6276 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6277 &(res->ip_value.addr.ipv6),
6278 sizeof(struct in6_addr));
6279 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6282 if (!strcmp(res->filter_type, "imac-ivlan"))
6283 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6284 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6285 tunnel_filter_conf.filter_type =
6286 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6287 else if (!strcmp(res->filter_type, "imac-tenid"))
6288 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6289 else if (!strcmp(res->filter_type, "imac"))
6290 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6291 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6292 tunnel_filter_conf.filter_type =
6293 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6295 printf("The filter type is not supported");
6299 if (!strcmp(res->tunnel_type, "vxlan"))
6300 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6302 printf("Only VXLAN is supported now.\n");
6306 tunnel_filter_conf.tenant_id = res->tenant_id;
6307 tunnel_filter_conf.queue_id = res->queue_num;
6308 if (!strcmp(res->what, "add"))
6309 ret = rte_eth_dev_filter_ctrl(res->port_id,
6310 RTE_ETH_FILTER_TUNNEL,
6312 &tunnel_filter_conf);
6314 ret = rte_eth_dev_filter_ctrl(res->port_id,
6315 RTE_ETH_FILTER_TUNNEL,
6316 RTE_ETH_FILTER_DELETE,
6317 &tunnel_filter_conf);
6319 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6323 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6324 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6325 cmd, "tunnel_filter");
6326 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6327 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6329 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6330 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6332 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6333 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6335 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6336 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6338 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6339 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6340 inner_vlan, UINT16);
6341 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6342 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6344 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6345 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6346 tunnel_type, "vxlan");
6348 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6349 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6350 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6351 "imac#omac-imac-tenid");
6352 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6353 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6355 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6356 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6359 cmdline_parse_inst_t cmd_tunnel_filter = {
6360 .f = cmd_tunnel_filter_parsed,
6362 .help_str = "add/rm tunnel filter of a port: "
6363 "tunnel_filter add port_id outer_mac inner_mac ip "
6364 "inner_vlan tunnel_type(vxlan) filter_type "
6365 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6366 "imac|omac-imac-tenid) "
6367 "tenant_id queue_num",
6369 (void *)&cmd_tunnel_filter_cmd,
6370 (void *)&cmd_tunnel_filter_what,
6371 (void *)&cmd_tunnel_filter_port_id,
6372 (void *)&cmd_tunnel_filter_outer_mac,
6373 (void *)&cmd_tunnel_filter_inner_mac,
6374 (void *)&cmd_tunnel_filter_ip_value,
6375 (void *)&cmd_tunnel_filter_innner_vlan,
6376 (void *)&cmd_tunnel_filter_tunnel_type,
6377 (void *)&cmd_tunnel_filter_filter_type,
6378 (void *)&cmd_tunnel_filter_tenant_id,
6379 (void *)&cmd_tunnel_filter_queue_num,
6384 /* *** CONFIGURE TUNNEL UDP PORT *** */
6385 struct cmd_tunnel_udp_config {
6386 cmdline_fixed_string_t cmd;
6387 cmdline_fixed_string_t what;
6393 cmd_tunnel_udp_config_parsed(void *parsed_result,
6394 __attribute__((unused)) struct cmdline *cl,
6395 __attribute__((unused)) void *data)
6397 struct cmd_tunnel_udp_config *res = parsed_result;
6398 struct rte_eth_udp_tunnel tunnel_udp;
6401 tunnel_udp.udp_port = res->udp_port;
6403 if (!strcmp(res->cmd, "rx_vxlan_port"))
6404 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6406 if (!strcmp(res->what, "add"))
6407 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6409 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6412 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6415 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6416 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6417 cmd, "rx_vxlan_port");
6418 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6419 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6421 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6422 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6424 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6425 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6428 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6429 .f = cmd_tunnel_udp_config_parsed,
6431 .help_str = "add/rm an tunneling UDP port filter: "
6432 "rx_vxlan_port add udp_port port_id",
6434 (void *)&cmd_tunnel_udp_config_cmd,
6435 (void *)&cmd_tunnel_udp_config_what,
6436 (void *)&cmd_tunnel_udp_config_udp_port,
6437 (void *)&cmd_tunnel_udp_config_port_id,
6442 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6443 struct cmd_set_mirror_mask_result {
6444 cmdline_fixed_string_t set;
6445 cmdline_fixed_string_t port;
6447 cmdline_fixed_string_t mirror;
6449 cmdline_fixed_string_t what;
6450 cmdline_fixed_string_t value;
6451 cmdline_fixed_string_t dstpool;
6453 cmdline_fixed_string_t on;
6456 cmdline_parse_token_string_t cmd_mirror_mask_set =
6457 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6459 cmdline_parse_token_string_t cmd_mirror_mask_port =
6460 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6462 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6463 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6465 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6466 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6467 mirror, "mirror-rule");
6468 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6469 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6471 cmdline_parse_token_string_t cmd_mirror_mask_what =
6472 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6473 what, "pool-mirror#vlan-mirror");
6474 cmdline_parse_token_string_t cmd_mirror_mask_value =
6475 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6477 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6478 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6479 dstpool, "dst-pool");
6480 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6481 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6483 cmdline_parse_token_string_t cmd_mirror_mask_on =
6484 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6488 cmd_set_mirror_mask_parsed(void *parsed_result,
6489 __attribute__((unused)) struct cmdline *cl,
6490 __attribute__((unused)) void *data)
6493 struct cmd_set_mirror_mask_result *res = parsed_result;
6494 struct rte_eth_vmdq_mirror_conf mr_conf;
6496 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6498 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6500 mr_conf.dst_pool = res->dstpool_id;
6502 if (!strcmp(res->what, "pool-mirror")) {
6503 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6504 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6505 } else if(!strcmp(res->what, "vlan-mirror")) {
6506 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6507 nb_item = parse_item_list(res->value, "core",
6508 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6512 for(i=0; i < nb_item; i++) {
6513 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6514 printf("Invalid vlan_id: must be < 4096\n");
6518 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6519 mr_conf.vlan.vlan_mask |= 1ULL << i;
6523 if(!strcmp(res->on, "on"))
6524 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6527 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6530 printf("mirror rule add error: (%s)\n", strerror(-ret));
6533 cmdline_parse_inst_t cmd_set_mirror_mask = {
6534 .f = cmd_set_mirror_mask_parsed,
6536 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6537 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6539 (void *)&cmd_mirror_mask_set,
6540 (void *)&cmd_mirror_mask_port,
6541 (void *)&cmd_mirror_mask_portid,
6542 (void *)&cmd_mirror_mask_mirror,
6543 (void *)&cmd_mirror_mask_ruleid,
6544 (void *)&cmd_mirror_mask_what,
6545 (void *)&cmd_mirror_mask_value,
6546 (void *)&cmd_mirror_mask_dstpool,
6547 (void *)&cmd_mirror_mask_poolid,
6548 (void *)&cmd_mirror_mask_on,
6553 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6554 struct cmd_set_mirror_link_result {
6555 cmdline_fixed_string_t set;
6556 cmdline_fixed_string_t port;
6558 cmdline_fixed_string_t mirror;
6560 cmdline_fixed_string_t what;
6561 cmdline_fixed_string_t dstpool;
6563 cmdline_fixed_string_t on;
6566 cmdline_parse_token_string_t cmd_mirror_link_set =
6567 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6569 cmdline_parse_token_string_t cmd_mirror_link_port =
6570 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6572 cmdline_parse_token_num_t cmd_mirror_link_portid =
6573 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6575 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6576 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6577 mirror, "mirror-rule");
6578 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6579 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6581 cmdline_parse_token_string_t cmd_mirror_link_what =
6582 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6583 what, "uplink-mirror#downlink-mirror");
6584 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6585 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6586 dstpool, "dst-pool");
6587 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6588 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6590 cmdline_parse_token_string_t cmd_mirror_link_on =
6591 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6595 cmd_set_mirror_link_parsed(void *parsed_result,
6596 __attribute__((unused)) struct cmdline *cl,
6597 __attribute__((unused)) void *data)
6600 struct cmd_set_mirror_link_result *res = parsed_result;
6601 struct rte_eth_vmdq_mirror_conf mr_conf;
6603 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6604 if(!strcmp(res->what, "uplink-mirror")) {
6605 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6606 }else if(!strcmp(res->what, "downlink-mirror"))
6607 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6609 mr_conf.dst_pool = res->dstpool_id;
6611 if(!strcmp(res->on, "on"))
6612 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6615 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6618 /* check the return value and print it if is < 0 */
6620 printf("mirror rule add error: (%s)\n", strerror(-ret));
6624 cmdline_parse_inst_t cmd_set_mirror_link = {
6625 .f = cmd_set_mirror_link_parsed,
6627 .help_str = "set port X mirror-rule Y uplink-mirror|"
6628 "downlink-mirror dst-pool Z on|off",
6630 (void *)&cmd_mirror_link_set,
6631 (void *)&cmd_mirror_link_port,
6632 (void *)&cmd_mirror_link_portid,
6633 (void *)&cmd_mirror_link_mirror,
6634 (void *)&cmd_mirror_link_ruleid,
6635 (void *)&cmd_mirror_link_what,
6636 (void *)&cmd_mirror_link_dstpool,
6637 (void *)&cmd_mirror_link_poolid,
6638 (void *)&cmd_mirror_link_on,
6643 /* *** RESET VM MIRROR RULE *** */
6644 struct cmd_rm_mirror_rule_result {
6645 cmdline_fixed_string_t reset;
6646 cmdline_fixed_string_t port;
6648 cmdline_fixed_string_t mirror;
6652 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6653 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6655 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6656 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6658 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6659 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6661 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6662 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6663 mirror, "mirror-rule");
6664 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6665 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6669 cmd_reset_mirror_rule_parsed(void *parsed_result,
6670 __attribute__((unused)) struct cmdline *cl,
6671 __attribute__((unused)) void *data)
6674 struct cmd_set_mirror_link_result *res = parsed_result;
6676 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6678 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6681 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6682 .f = cmd_reset_mirror_rule_parsed,
6684 .help_str = "reset port X mirror-rule Y",
6686 (void *)&cmd_rm_mirror_rule_reset,
6687 (void *)&cmd_rm_mirror_rule_port,
6688 (void *)&cmd_rm_mirror_rule_portid,
6689 (void *)&cmd_rm_mirror_rule_mirror,
6690 (void *)&cmd_rm_mirror_rule_ruleid,
6695 /* ******************************************************************************** */
6697 struct cmd_dump_result {
6698 cmdline_fixed_string_t dump;
6702 dump_struct_sizes(void)
6704 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6705 DUMP_SIZE(struct rte_mbuf);
6706 DUMP_SIZE(struct rte_mempool);
6707 DUMP_SIZE(struct rte_ring);
6711 static void cmd_dump_parsed(void *parsed_result,
6712 __attribute__((unused)) struct cmdline *cl,
6713 __attribute__((unused)) void *data)
6715 struct cmd_dump_result *res = parsed_result;
6717 if (!strcmp(res->dump, "dump_physmem"))
6718 rte_dump_physmem_layout(stdout);
6719 else if (!strcmp(res->dump, "dump_memzone"))
6720 rte_memzone_dump(stdout);
6721 else if (!strcmp(res->dump, "dump_log_history"))
6722 rte_log_dump_history(stdout);
6723 else if (!strcmp(res->dump, "dump_struct_sizes"))
6724 dump_struct_sizes();
6725 else if (!strcmp(res->dump, "dump_ring"))
6726 rte_ring_list_dump(stdout);
6727 else if (!strcmp(res->dump, "dump_mempool"))
6728 rte_mempool_list_dump(stdout);
6729 else if (!strcmp(res->dump, "dump_devargs"))
6730 rte_eal_devargs_dump(stdout);
6733 cmdline_parse_token_string_t cmd_dump_dump =
6734 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6738 "dump_struct_sizes#"
6743 cmdline_parse_inst_t cmd_dump = {
6744 .f = cmd_dump_parsed, /* function to call */
6745 .data = NULL, /* 2nd arg of func */
6746 .help_str = "dump status",
6747 .tokens = { /* token list, NULL terminated */
6748 (void *)&cmd_dump_dump,
6753 /* ******************************************************************************** */
6755 struct cmd_dump_one_result {
6756 cmdline_fixed_string_t dump;
6757 cmdline_fixed_string_t name;
6760 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6761 __attribute__((unused)) void *data)
6763 struct cmd_dump_one_result *res = parsed_result;
6765 if (!strcmp(res->dump, "dump_ring")) {
6767 r = rte_ring_lookup(res->name);
6769 cmdline_printf(cl, "Cannot find ring\n");
6772 rte_ring_dump(stdout, r);
6773 } else if (!strcmp(res->dump, "dump_mempool")) {
6774 struct rte_mempool *mp;
6775 mp = rte_mempool_lookup(res->name);
6777 cmdline_printf(cl, "Cannot find mempool\n");
6780 rte_mempool_dump(stdout, mp);
6784 cmdline_parse_token_string_t cmd_dump_one_dump =
6785 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6786 "dump_ring#dump_mempool");
6788 cmdline_parse_token_string_t cmd_dump_one_name =
6789 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6791 cmdline_parse_inst_t cmd_dump_one = {
6792 .f = cmd_dump_one_parsed, /* function to call */
6793 .data = NULL, /* 2nd arg of func */
6794 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6795 .tokens = { /* token list, NULL terminated */
6796 (void *)&cmd_dump_one_dump,
6797 (void *)&cmd_dump_one_name,
6802 /* *** set SYN filter *** */
6803 struct cmd_set_syn_filter_result {
6804 cmdline_fixed_string_t filter;
6806 cmdline_fixed_string_t priority;
6807 cmdline_fixed_string_t high;
6808 cmdline_fixed_string_t queue;
6813 cmd_set_syn_filter_parsed(void *parsed_result,
6814 __attribute__((unused)) struct cmdline *cl,
6815 __attribute__((unused)) void *data)
6818 struct cmd_set_syn_filter_result *res = parsed_result;
6819 struct rte_syn_filter filter;
6821 if (!strcmp(res->filter, "add_syn_filter")) {
6822 if (!strcmp(res->high, "high"))
6826 ret = rte_eth_dev_add_syn_filter(res->port_id,
6827 &filter, res->queue_id);
6828 } else if (!strcmp(res->filter, "remove_syn_filter"))
6829 ret = rte_eth_dev_remove_syn_filter(res->port_id);
6830 else if (!strcmp(res->filter, "get_syn_filter"))
6831 get_syn_filter(res->port_id);
6833 printf("syn filter setting error: (%s)\n", strerror(-ret));
6836 cmdline_parse_token_num_t cmd_syn_filter_portid =
6837 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6839 cmdline_parse_token_string_t cmd_syn_filter_priority =
6840 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6841 priority, "priority");
6842 cmdline_parse_token_string_t cmd_syn_filter_high =
6843 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6845 cmdline_parse_token_string_t cmd_syn_filter_queue =
6846 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6848 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6849 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6851 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
6852 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6853 filter, "add_syn_filter");
6854 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
6855 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6856 filter, "remove_syn_filter");
6857 cmdline_parse_inst_t cmd_add_syn_filter = {
6858 .f = cmd_set_syn_filter_parsed,
6860 .help_str = "add syn filter",
6862 (void *)&cmd_syn_filter_add_filter,
6863 (void *)&cmd_syn_filter_portid,
6864 (void *)&cmd_syn_filter_priority,
6865 (void *)&cmd_syn_filter_high,
6866 (void *)&cmd_syn_filter_queue,
6867 (void *)&cmd_syn_filter_queue_id,
6871 cmdline_parse_inst_t cmd_remove_syn_filter = {
6872 .f = cmd_set_syn_filter_parsed,
6874 .help_str = "remove syn filter",
6876 (void *)&cmd_syn_filter_remove_filter,
6877 (void *)&cmd_syn_filter_portid,
6882 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
6883 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6884 filter, "get_syn_filter");
6886 cmdline_parse_inst_t cmd_get_syn_filter = {
6887 .f = cmd_set_syn_filter_parsed,
6889 .help_str = "get syn filter",
6891 (void *)&cmd_syn_filter_get_filter,
6892 (void *)&cmd_syn_filter_portid,
6897 /* *** ADD/REMOVE A 2tuple FILTER *** */
6898 struct cmd_2tuple_filter_result {
6899 cmdline_fixed_string_t filter;
6901 cmdline_fixed_string_t protocol;
6902 uint8_t protocol_value;
6903 uint8_t protocol_mask;
6904 cmdline_fixed_string_t dst_port;
6905 uint16_t dst_port_value;
6906 uint16_t dst_port_mask;
6907 cmdline_fixed_string_t flags;
6908 uint8_t flags_value;
6909 cmdline_fixed_string_t priority;
6910 uint8_t priority_value;
6911 cmdline_fixed_string_t queue;
6913 cmdline_fixed_string_t index;
6914 uint16_t index_value;
6918 cmd_2tuple_filter_parsed(void *parsed_result,
6919 __attribute__((unused)) struct cmdline *cl,
6920 __attribute__((unused)) void *data)
6923 struct rte_2tuple_filter filter;
6924 struct cmd_2tuple_filter_result *res = parsed_result;
6926 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
6928 if (!strcmp(res->filter, "add_2tuple_filter")) {
6929 /* need convert to big endian. */
6930 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6931 filter.protocol = res->protocol_value;
6932 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
6933 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
6934 filter.priority = res->priority_value;
6935 filter.tcp_flags = res->flags_value;
6936 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
6937 res->index_value, &filter, res->queue_id);
6938 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
6939 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
6941 else if (!strcmp(res->filter, "get_2tuple_filter"))
6942 get_2tuple_filter(res->port_id, res->index_value);
6945 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
6948 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6949 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6951 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6952 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6953 protocol, "protocol");
6954 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6955 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6956 protocol_value, UINT8);
6957 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
6958 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6959 protocol_mask, UINT8);
6960 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6961 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6962 dst_port, "dst_port");
6963 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6964 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6965 dst_port_value, UINT16);
6966 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
6967 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6968 dst_port_mask, UINT16);
6969 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
6970 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6972 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
6973 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6974 flags_value, UINT8);
6975 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6976 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6977 priority, "priority");
6978 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6979 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6980 priority_value, UINT8);
6981 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6982 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6984 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6985 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6987 cmdline_parse_token_string_t cmd_2tuple_filter_index =
6988 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6990 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
6991 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6992 index_value, UINT16);
6993 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
6994 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6995 filter, "add_2tuple_filter");
6996 cmdline_parse_inst_t cmd_add_2tuple_filter = {
6997 .f = cmd_2tuple_filter_parsed,
6999 .help_str = "add a 2tuple filter",
7001 (void *)&cmd_2tuple_filter_add_filter,
7002 (void *)&cmd_2tuple_filter_port_id,
7003 (void *)&cmd_2tuple_filter_protocol,
7004 (void *)&cmd_2tuple_filter_protocol_value,
7005 (void *)&cmd_2tuple_filter_protocol_mask,
7006 (void *)&cmd_2tuple_filter_dst_port,
7007 (void *)&cmd_2tuple_filter_dst_port_value,
7008 (void *)&cmd_2tuple_filter_dst_port_mask,
7009 (void *)&cmd_2tuple_filter_flags,
7010 (void *)&cmd_2tuple_filter_flags_value,
7011 (void *)&cmd_2tuple_filter_priority,
7012 (void *)&cmd_2tuple_filter_priority_value,
7013 (void *)&cmd_2tuple_filter_queue,
7014 (void *)&cmd_2tuple_filter_queue_id,
7015 (void *)&cmd_2tuple_filter_index,
7016 (void *)&cmd_2tuple_filter_index_value,
7021 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7022 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7023 filter, "remove_2tuple_filter");
7024 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7025 .f = cmd_2tuple_filter_parsed,
7027 .help_str = "remove a 2tuple filter",
7029 (void *)&cmd_2tuple_filter_remove_filter,
7030 (void *)&cmd_2tuple_filter_port_id,
7031 (void *)&cmd_2tuple_filter_index,
7032 (void *)&cmd_2tuple_filter_index_value,
7036 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7037 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7038 filter, "get_2tuple_filter");
7039 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7040 .f = cmd_2tuple_filter_parsed,
7042 .help_str = "get a 2tuple filter",
7044 (void *)&cmd_2tuple_filter_get_filter,
7045 (void *)&cmd_2tuple_filter_port_id,
7046 (void *)&cmd_2tuple_filter_index,
7047 (void *)&cmd_2tuple_filter_index_value,
7052 /* *** ADD/REMOVE A 5tuple FILTER *** */
7053 struct cmd_5tuple_filter_result {
7054 cmdline_fixed_string_t filter;
7056 cmdline_fixed_string_t dst_ip;
7057 cmdline_ipaddr_t dst_ip_value;
7058 cmdline_fixed_string_t src_ip;
7059 cmdline_ipaddr_t src_ip_value;
7060 cmdline_fixed_string_t dst_port;
7061 uint16_t dst_port_value;
7062 cmdline_fixed_string_t src_port;
7063 uint16_t src_port_value;
7064 cmdline_fixed_string_t protocol;
7065 uint8_t protocol_value;
7066 cmdline_fixed_string_t mask;
7068 cmdline_fixed_string_t flags;
7069 uint8_t flags_value;
7070 cmdline_fixed_string_t priority;
7071 uint8_t priority_value;
7072 cmdline_fixed_string_t queue;
7074 cmdline_fixed_string_t index;
7075 uint16_t index_value;
7079 cmd_5tuple_filter_parsed(void *parsed_result,
7080 __attribute__((unused)) struct cmdline *cl,
7081 __attribute__((unused)) void *data)
7084 struct rte_5tuple_filter filter;
7085 struct cmd_5tuple_filter_result *res = parsed_result;
7087 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7089 if (!strcmp(res->filter, "add_5tuple_filter")) {
7090 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7091 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7092 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7093 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7094 filter.protocol = res->protocol_value;
7095 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7096 filter.priority = res->priority_value;
7097 filter.tcp_flags = res->flags_value;
7099 if (res->dst_ip_value.family == AF_INET)
7100 /* no need to convert, already big endian. */
7101 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7103 if (filter.dst_ip_mask == 0) {
7104 printf("can not support ipv6 involved compare.\n");
7110 if (res->src_ip_value.family == AF_INET)
7111 /* no need to convert, already big endian. */
7112 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7114 if (filter.src_ip_mask == 0) {
7115 printf("can not support ipv6 involved compare.\n");
7120 /* need convert to big endian. */
7121 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7122 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7124 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7125 res->index_value, &filter, res->queue_id);
7126 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7127 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7129 else if (!strcmp(res->filter, "get_5tuple_filter"))
7130 get_5tuple_filter(res->port_id, res->index_value);
7132 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7136 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7137 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7139 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7140 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7142 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7143 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7145 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7146 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7148 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7149 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7151 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7152 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7153 dst_port, "dst_port");
7154 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7155 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7156 dst_port_value, UINT16);
7157 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7158 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7159 src_port, "src_port");
7160 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7161 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7162 src_port_value, UINT16);
7163 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7164 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7165 protocol, "protocol");
7166 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7167 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7168 protocol_value, UINT8);
7169 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7170 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7172 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7173 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7175 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7176 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7178 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7179 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7180 flags_value, UINT8);
7181 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7182 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7183 priority, "priority");
7184 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7185 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7186 priority_value, UINT8);
7187 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7188 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7190 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7191 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7193 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7194 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7196 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7197 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7198 index_value, UINT16);
7200 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7201 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7202 filter, "add_5tuple_filter");
7203 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7204 .f = cmd_5tuple_filter_parsed,
7206 .help_str = "add a 5tuple filter",
7208 (void *)&cmd_5tuple_filter_add_filter,
7209 (void *)&cmd_5tuple_filter_port_id,
7210 (void *)&cmd_5tuple_filter_dst_ip,
7211 (void *)&cmd_5tuple_filter_dst_ip_value,
7212 (void *)&cmd_5tuple_filter_src_ip,
7213 (void *)&cmd_5tuple_filter_src_ip_value,
7214 (void *)&cmd_5tuple_filter_dst_port,
7215 (void *)&cmd_5tuple_filter_dst_port_value,
7216 (void *)&cmd_5tuple_filter_src_port,
7217 (void *)&cmd_5tuple_filter_src_port_value,
7218 (void *)&cmd_5tuple_filter_protocol,
7219 (void *)&cmd_5tuple_filter_protocol_value,
7220 (void *)&cmd_5tuple_filter_mask,
7221 (void *)&cmd_5tuple_filter_mask_value,
7222 (void *)&cmd_5tuple_filter_flags,
7223 (void *)&cmd_5tuple_filter_flags_value,
7224 (void *)&cmd_5tuple_filter_priority,
7225 (void *)&cmd_5tuple_filter_priority_value,
7226 (void *)&cmd_5tuple_filter_queue,
7227 (void *)&cmd_5tuple_filter_queue_id,
7228 (void *)&cmd_5tuple_filter_index,
7229 (void *)&cmd_5tuple_filter_index_value,
7234 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7235 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7236 filter, "remove_5tuple_filter");
7237 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7238 .f = cmd_5tuple_filter_parsed,
7240 .help_str = "remove a 5tuple filter",
7242 (void *)&cmd_5tuple_filter_remove_filter,
7243 (void *)&cmd_5tuple_filter_port_id,
7244 (void *)&cmd_5tuple_filter_index,
7245 (void *)&cmd_5tuple_filter_index_value,
7250 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7251 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7252 filter, "get_5tuple_filter");
7253 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7254 .f = cmd_5tuple_filter_parsed,
7256 .help_str = "get a 5tuple filter",
7258 (void *)&cmd_5tuple_filter_get_filter,
7259 (void *)&cmd_5tuple_filter_port_id,
7260 (void *)&cmd_5tuple_filter_index,
7261 (void *)&cmd_5tuple_filter_index_value,
7266 /* *** ADD/REMOVE A flex FILTER *** */
7267 struct cmd_flex_filter_result {
7268 cmdline_fixed_string_t filter;
7269 cmdline_fixed_string_t ops;
7271 cmdline_fixed_string_t len;
7273 cmdline_fixed_string_t bytes;
7274 cmdline_fixed_string_t bytes_value;
7275 cmdline_fixed_string_t mask;
7276 cmdline_fixed_string_t mask_value;
7277 cmdline_fixed_string_t priority;
7278 uint8_t priority_value;
7279 cmdline_fixed_string_t queue;
7283 static int xdigit2val(unsigned char c)
7288 else if (isupper(c))
7296 cmd_flex_filter_parsed(void *parsed_result,
7297 __attribute__((unused)) struct cmdline *cl,
7298 __attribute__((unused)) void *data)
7301 struct rte_eth_flex_filter filter;
7302 struct cmd_flex_filter_result *res = parsed_result;
7303 char *bytes_ptr, *mask_ptr;
7304 uint16_t len, i, j = 0;
7309 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7310 printf("the len exceed the max length 128\n");
7313 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7314 filter.len = res->len_value;
7315 filter.priority = res->priority_value;
7316 filter.queue = res->queue_id;
7317 bytes_ptr = res->bytes_value;
7318 mask_ptr = res->mask_value;
7320 /* translate bytes string to array. */
7321 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7322 (bytes_ptr[1] == 'X')))
7324 len = strnlen(bytes_ptr, res->len_value * 2);
7325 if (len == 0 || (len % 8 != 0)) {
7326 printf("please check len and bytes input\n");
7329 for (i = 0; i < len; i++) {
7331 if (isxdigit(c) == 0) {
7332 /* invalid characters. */
7333 printf("invalid input\n");
7336 val = xdigit2val(c);
7339 filter.bytes[j] = byte;
7340 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7347 /* translate mask string to uint8_t array. */
7348 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7349 (mask_ptr[1] == 'X')))
7351 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7353 printf("invalid input\n");
7358 for (i = 0; i < len; i++) {
7360 if (isxdigit(c) == 0) {
7361 /* invalid characters. */
7362 printf("invalid input\n");
7365 val = xdigit2val(c);
7368 filter.mask[j] = byte;
7369 printf("mask[%d]:%02x ", j, filter.mask[j]);
7377 if (!strcmp(res->ops, "add"))
7378 ret = rte_eth_dev_filter_ctrl(res->port_id,
7379 RTE_ETH_FILTER_FLEXIBLE,
7383 ret = rte_eth_dev_filter_ctrl(res->port_id,
7384 RTE_ETH_FILTER_FLEXIBLE,
7385 RTE_ETH_FILTER_DELETE,
7389 printf("flex filter setting error: (%s)\n", strerror(-ret));
7392 cmdline_parse_token_string_t cmd_flex_filter_filter =
7393 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7394 filter, "flex_filter");
7395 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7396 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7398 cmdline_parse_token_string_t cmd_flex_filter_ops =
7399 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7401 cmdline_parse_token_string_t cmd_flex_filter_len =
7402 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7404 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7405 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7407 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7408 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7410 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7411 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7413 cmdline_parse_token_string_t cmd_flex_filter_mask =
7414 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7416 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7417 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7419 cmdline_parse_token_string_t cmd_flex_filter_priority =
7420 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7421 priority, "priority");
7422 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7423 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7424 priority_value, UINT8);
7425 cmdline_parse_token_string_t cmd_flex_filter_queue =
7426 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7428 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7429 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7431 cmdline_parse_inst_t cmd_flex_filter = {
7432 .f = cmd_flex_filter_parsed,
7434 .help_str = "add/del a flex filter",
7436 (void *)&cmd_flex_filter_filter,
7437 (void *)&cmd_flex_filter_port_id,
7438 (void *)&cmd_flex_filter_ops,
7439 (void *)&cmd_flex_filter_len,
7440 (void *)&cmd_flex_filter_len_value,
7441 (void *)&cmd_flex_filter_bytes,
7442 (void *)&cmd_flex_filter_bytes_value,
7443 (void *)&cmd_flex_filter_mask,
7444 (void *)&cmd_flex_filter_mask_value,
7445 (void *)&cmd_flex_filter_priority,
7446 (void *)&cmd_flex_filter_priority_value,
7447 (void *)&cmd_flex_filter_queue,
7448 (void *)&cmd_flex_filter_queue_id,
7453 /* *** Filters Control *** */
7455 /* *** deal with ethertype filter *** */
7456 struct cmd_ethertype_filter_result {
7457 cmdline_fixed_string_t filter;
7459 cmdline_fixed_string_t ops;
7460 cmdline_fixed_string_t mac;
7461 struct ether_addr mac_addr;
7462 cmdline_fixed_string_t ethertype;
7463 uint16_t ethertype_value;
7464 cmdline_fixed_string_t drop;
7465 cmdline_fixed_string_t queue;
7469 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7470 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7471 filter, "ethertype_filter");
7472 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7473 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7475 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7476 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7478 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7479 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7480 mac, "mac_addr#mac_ignr");
7481 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7482 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7484 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7485 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7486 ethertype, "ethertype");
7487 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7488 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7489 ethertype_value, UINT16);
7490 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7491 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7493 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7494 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7496 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7497 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7501 cmd_ethertype_filter_parsed(void *parsed_result,
7502 __attribute__((unused)) struct cmdline *cl,
7503 __attribute__((unused)) void *data)
7505 struct cmd_ethertype_filter_result *res = parsed_result;
7506 struct rte_eth_ethertype_filter filter;
7509 ret = rte_eth_dev_filter_supported(res->port_id,
7510 RTE_ETH_FILTER_ETHERTYPE);
7512 printf("ethertype filter is not supported on port %u.\n",
7517 memset(&filter, 0, sizeof(filter));
7518 if (!strcmp(res->mac, "mac_addr")) {
7519 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7520 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7521 sizeof(struct ether_addr));
7523 if (!strcmp(res->drop, "drop"))
7524 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7525 filter.ether_type = res->ethertype_value;
7526 filter.queue = res->queue_id;
7528 if (!strcmp(res->ops, "add"))
7529 ret = rte_eth_dev_filter_ctrl(res->port_id,
7530 RTE_ETH_FILTER_ETHERTYPE,
7534 ret = rte_eth_dev_filter_ctrl(res->port_id,
7535 RTE_ETH_FILTER_ETHERTYPE,
7536 RTE_ETH_FILTER_DELETE,
7539 printf("ethertype filter programming error: (%s)\n",
7543 cmdline_parse_inst_t cmd_ethertype_filter = {
7544 .f = cmd_ethertype_filter_parsed,
7546 .help_str = "add or delete an ethertype filter entry",
7548 (void *)&cmd_ethertype_filter_filter,
7549 (void *)&cmd_ethertype_filter_port_id,
7550 (void *)&cmd_ethertype_filter_ops,
7551 (void *)&cmd_ethertype_filter_mac,
7552 (void *)&cmd_ethertype_filter_mac_addr,
7553 (void *)&cmd_ethertype_filter_ethertype,
7554 (void *)&cmd_ethertype_filter_ethertype_value,
7555 (void *)&cmd_ethertype_filter_drop,
7556 (void *)&cmd_ethertype_filter_queue,
7557 (void *)&cmd_ethertype_filter_queue_id,
7562 /* *** deal with flow director filter *** */
7563 struct cmd_flow_director_result {
7564 cmdline_fixed_string_t flow_director_filter;
7566 cmdline_fixed_string_t ops;
7567 cmdline_fixed_string_t flow;
7568 cmdline_fixed_string_t flow_type;
7569 cmdline_fixed_string_t src;
7570 cmdline_ipaddr_t ip_src;
7572 cmdline_fixed_string_t dst;
7573 cmdline_ipaddr_t ip_dst;
7575 cmdline_fixed_string_t verify_tag;
7576 uint32_t verify_tag_value;
7577 cmdline_fixed_string_t vlan;
7578 uint16_t vlan_value;
7579 cmdline_fixed_string_t flexbytes;
7580 cmdline_fixed_string_t flexbytes_value;
7581 cmdline_fixed_string_t drop;
7582 cmdline_fixed_string_t queue;
7584 cmdline_fixed_string_t fd_id;
7585 uint32_t fd_id_value;
7589 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7592 const char *p, *p0 = q_arg;
7594 unsigned long int_fld;
7595 char *str_fld[max_num];
7600 p = strchr(p0, '(');
7604 p0 = strchr(p, ')');
7609 if (size >= sizeof(s))
7612 snprintf(s, sizeof(s), "%.*s", size, p);
7613 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7614 if (ret < 0 || ret > max_num)
7616 for (i = 0; i < ret; i++) {
7618 int_fld = strtoul(str_fld[i], &end, 0);
7619 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7621 flexbytes[i] = (uint8_t)int_fld;
7626 static enum rte_eth_flow_type
7627 str2flowtype(char *string)
7630 static const struct {
7632 enum rte_eth_flow_type type;
7633 } flowtype_str[] = {
7634 {"raw", RTE_ETH_FLOW_TYPE_RAW},
7635 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
7636 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
7637 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
7638 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
7639 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
7640 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
7641 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
7642 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
7643 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
7644 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
7647 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7648 if (!strcmp(flowtype_str[i].str, string))
7649 return flowtype_str[i].type;
7651 return RTE_ETH_FLOW_TYPE_NONE;
7654 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
7656 if ((ip_addr).family == AF_INET) \
7657 (ip) = (ip_addr).addr.ipv4.s_addr; \
7659 printf("invalid parameter.\n"); \
7664 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
7666 if ((ip_addr).family == AF_INET6) \
7667 (void)rte_memcpy(&(ip), \
7668 &((ip_addr).addr.ipv6), \
7669 sizeof(struct in6_addr)); \
7671 printf("invalid parameter.\n"); \
7677 cmd_flow_director_filter_parsed(void *parsed_result,
7678 __attribute__((unused)) struct cmdline *cl,
7679 __attribute__((unused)) void *data)
7681 struct cmd_flow_director_result *res = parsed_result;
7682 struct rte_eth_fdir_filter entry;
7683 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
7686 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7688 printf("flow director is not supported on port %u.\n",
7692 memset(flexbytes, 0, sizeof(flexbytes));
7693 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
7694 ret = parse_flexbytes(res->flexbytes_value,
7696 RTE_ETH_FDIR_MAX_FLEXLEN);
7698 printf("error: Cannot parse flexbytes input.\n");
7702 entry.input.flow_type = str2flowtype(res->flow_type);
7703 switch (entry.input.flow_type) {
7704 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
7705 case RTE_ETH_FLOW_TYPE_FRAG_IPV4:
7706 case RTE_ETH_FLOW_TYPE_UDPV4:
7707 case RTE_ETH_FLOW_TYPE_TCPV4:
7708 IPV4_ADDR_TO_UINT(res->ip_dst,
7709 entry.input.flow.ip4_flow.dst_ip);
7710 IPV4_ADDR_TO_UINT(res->ip_src,
7711 entry.input.flow.ip4_flow.src_ip);
7712 /* need convert to big endian. */
7713 entry.input.flow.udp4_flow.dst_port =
7714 rte_cpu_to_be_16(res->port_dst);
7715 entry.input.flow.udp4_flow.src_port =
7716 rte_cpu_to_be_16(res->port_src);
7718 case RTE_ETH_FLOW_TYPE_SCTPV4:
7719 IPV4_ADDR_TO_UINT(res->ip_dst,
7720 entry.input.flow.sctp4_flow.ip.dst_ip);
7721 IPV4_ADDR_TO_UINT(res->ip_src,
7722 entry.input.flow.sctp4_flow.ip.src_ip);
7723 /* need convert to big endian. */
7724 entry.input.flow.sctp4_flow.verify_tag =
7725 rte_cpu_to_be_32(res->verify_tag_value);
7727 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
7728 case RTE_ETH_FLOW_TYPE_FRAG_IPV6:
7729 case RTE_ETH_FLOW_TYPE_UDPV6:
7730 case RTE_ETH_FLOW_TYPE_TCPV6:
7731 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7732 entry.input.flow.ipv6_flow.dst_ip);
7733 IPV6_ADDR_TO_ARRAY(res->ip_src,
7734 entry.input.flow.ipv6_flow.src_ip);
7735 /* need convert to big endian. */
7736 entry.input.flow.udp6_flow.dst_port =
7737 rte_cpu_to_be_16(res->port_dst);
7738 entry.input.flow.udp6_flow.src_port =
7739 rte_cpu_to_be_16(res->port_src);
7741 case RTE_ETH_FLOW_TYPE_SCTPV6:
7742 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7743 entry.input.flow.sctp6_flow.ip.dst_ip);
7744 IPV6_ADDR_TO_ARRAY(res->ip_src,
7745 entry.input.flow.sctp6_flow.ip.src_ip);
7746 /* need convert to big endian. */
7747 entry.input.flow.sctp6_flow.verify_tag =
7748 rte_cpu_to_be_32(res->verify_tag_value);
7751 printf("invalid parameter.\n");
7754 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
7756 RTE_ETH_FDIR_MAX_FLEXLEN);
7758 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
7760 entry.action.flex_off = 0; /*use 0 by default */
7761 if (!strcmp(res->drop, "drop"))
7762 entry.action.behavior = RTE_ETH_FDIR_REJECT;
7764 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
7765 /* set to report FD ID by default */
7766 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
7767 entry.action.rx_queue = res->queue_id;
7768 entry.soft_id = res->fd_id_value;
7769 if (!strcmp(res->ops, "add"))
7770 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7771 RTE_ETH_FILTER_ADD, &entry);
7772 else if (!strcmp(res->ops, "del"))
7773 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7774 RTE_ETH_FILTER_DELETE, &entry);
7776 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7777 RTE_ETH_FILTER_UPDATE, &entry);
7779 printf("flow director programming error: (%s)\n",
7783 cmdline_parse_token_string_t cmd_flow_director_filter =
7784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7785 flow_director_filter, "flow_director_filter");
7786 cmdline_parse_token_num_t cmd_flow_director_port_id =
7787 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7789 cmdline_parse_token_string_t cmd_flow_director_ops =
7790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7791 ops, "add#del#update");
7792 cmdline_parse_token_string_t cmd_flow_director_flow =
7793 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7795 cmdline_parse_token_string_t cmd_flow_director_flow_type =
7796 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7798 "ip4#ip4-frag#tcp4#udp4#sctp4#"
7799 "ip6#ip6-frag#tcp6#udp6#sctp6");
7800 cmdline_parse_token_string_t cmd_flow_director_src =
7801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7803 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
7804 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7806 cmdline_parse_token_num_t cmd_flow_director_port_src =
7807 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7809 cmdline_parse_token_string_t cmd_flow_director_dst =
7810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7812 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
7813 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7815 cmdline_parse_token_num_t cmd_flow_director_port_dst =
7816 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7818 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
7819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7820 verify_tag, "verify_tag");
7821 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
7822 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7823 verify_tag_value, UINT32);
7824 cmdline_parse_token_string_t cmd_flow_director_vlan =
7825 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7827 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
7828 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7829 vlan_value, UINT16);
7830 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
7831 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7832 flexbytes, "flexbytes");
7833 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
7834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7835 flexbytes_value, NULL);
7836 cmdline_parse_token_string_t cmd_flow_director_drop =
7837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7839 cmdline_parse_token_string_t cmd_flow_director_queue =
7840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7842 cmdline_parse_token_num_t cmd_flow_director_queue_id =
7843 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7845 cmdline_parse_token_string_t cmd_flow_director_fd_id =
7846 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7848 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
7849 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7850 fd_id_value, UINT32);
7852 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
7853 .f = cmd_flow_director_filter_parsed,
7855 .help_str = "add or delete an ip flow director entry on NIC",
7857 (void *)&cmd_flow_director_filter,
7858 (void *)&cmd_flow_director_port_id,
7859 (void *)&cmd_flow_director_ops,
7860 (void *)&cmd_flow_director_flow,
7861 (void *)&cmd_flow_director_flow_type,
7862 (void *)&cmd_flow_director_src,
7863 (void *)&cmd_flow_director_ip_src,
7864 (void *)&cmd_flow_director_dst,
7865 (void *)&cmd_flow_director_ip_dst,
7866 (void *)&cmd_flow_director_vlan,
7867 (void *)&cmd_flow_director_vlan_value,
7868 (void *)&cmd_flow_director_flexbytes,
7869 (void *)&cmd_flow_director_flexbytes_value,
7870 (void *)&cmd_flow_director_drop,
7871 (void *)&cmd_flow_director_queue,
7872 (void *)&cmd_flow_director_queue_id,
7873 (void *)&cmd_flow_director_fd_id,
7874 (void *)&cmd_flow_director_fd_id_value,
7879 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
7880 .f = cmd_flow_director_filter_parsed,
7882 .help_str = "add or delete an udp/tcp flow director entry on NIC",
7884 (void *)&cmd_flow_director_filter,
7885 (void *)&cmd_flow_director_port_id,
7886 (void *)&cmd_flow_director_ops,
7887 (void *)&cmd_flow_director_flow,
7888 (void *)&cmd_flow_director_flow_type,
7889 (void *)&cmd_flow_director_src,
7890 (void *)&cmd_flow_director_ip_src,
7891 (void *)&cmd_flow_director_port_src,
7892 (void *)&cmd_flow_director_dst,
7893 (void *)&cmd_flow_director_ip_dst,
7894 (void *)&cmd_flow_director_port_dst,
7895 (void *)&cmd_flow_director_vlan,
7896 (void *)&cmd_flow_director_vlan_value,
7897 (void *)&cmd_flow_director_flexbytes,
7898 (void *)&cmd_flow_director_flexbytes_value,
7899 (void *)&cmd_flow_director_drop,
7900 (void *)&cmd_flow_director_queue,
7901 (void *)&cmd_flow_director_queue_id,
7902 (void *)&cmd_flow_director_fd_id,
7903 (void *)&cmd_flow_director_fd_id_value,
7908 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
7909 .f = cmd_flow_director_filter_parsed,
7911 .help_str = "add or delete a sctp flow director entry on NIC",
7913 (void *)&cmd_flow_director_filter,
7914 (void *)&cmd_flow_director_port_id,
7915 (void *)&cmd_flow_director_ops,
7916 (void *)&cmd_flow_director_flow,
7917 (void *)&cmd_flow_director_flow_type,
7918 (void *)&cmd_flow_director_src,
7919 (void *)&cmd_flow_director_ip_src,
7920 (void *)&cmd_flow_director_port_dst,
7921 (void *)&cmd_flow_director_dst,
7922 (void *)&cmd_flow_director_ip_dst,
7923 (void *)&cmd_flow_director_port_dst,
7924 (void *)&cmd_flow_director_verify_tag,
7925 (void *)&cmd_flow_director_verify_tag_value,
7926 (void *)&cmd_flow_director_vlan,
7927 (void *)&cmd_flow_director_vlan_value,
7928 (void *)&cmd_flow_director_flexbytes,
7929 (void *)&cmd_flow_director_flexbytes_value,
7930 (void *)&cmd_flow_director_drop,
7931 (void *)&cmd_flow_director_queue,
7932 (void *)&cmd_flow_director_queue_id,
7933 (void *)&cmd_flow_director_fd_id,
7934 (void *)&cmd_flow_director_fd_id_value,
7939 struct cmd_flush_flow_director_result {
7940 cmdline_fixed_string_t flush_flow_director;
7944 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
7945 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
7946 flush_flow_director, "flush_flow_director");
7947 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
7948 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
7952 cmd_flush_flow_director_parsed(void *parsed_result,
7953 __attribute__((unused)) struct cmdline *cl,
7954 __attribute__((unused)) void *data)
7956 struct cmd_flow_director_result *res = parsed_result;
7959 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7961 printf("flow director is not supported on port %u.\n",
7966 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7967 RTE_ETH_FILTER_FLUSH, NULL);
7969 printf("flow director table flushing error: (%s)\n",
7973 cmdline_parse_inst_t cmd_flush_flow_director = {
7974 .f = cmd_flush_flow_director_parsed,
7976 .help_str = "flush all flow director entries of a device on NIC",
7978 (void *)&cmd_flush_flow_director_flush,
7979 (void *)&cmd_flush_flow_director_port_id,
7984 /* *** deal with flow director mask *** */
7985 struct cmd_flow_director_mask_result {
7986 cmdline_fixed_string_t flow_director_mask;
7988 cmdline_fixed_string_t vlan;
7989 uint16_t vlan_value;
7990 cmdline_fixed_string_t src_mask;
7991 cmdline_ipaddr_t ipv4_src;
7992 cmdline_ipaddr_t ipv6_src;
7994 cmdline_fixed_string_t dst_mask;
7995 cmdline_ipaddr_t ipv4_dst;
7996 cmdline_ipaddr_t ipv6_dst;
8001 cmd_flow_director_mask_parsed(void *parsed_result,
8002 __attribute__((unused)) struct cmdline *cl,
8003 __attribute__((unused)) void *data)
8005 struct cmd_flow_director_mask_result *res = parsed_result;
8006 struct rte_eth_fdir_masks *mask;
8007 struct rte_port *port;
8009 if (res->port_id > nb_ports) {
8010 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8014 port = &ports[res->port_id];
8015 /** Check if the port is not started **/
8016 if (port->port_status != RTE_PORT_STOPPED) {
8017 printf("Please stop port %d first\n", res->port_id);
8020 mask = &port->dev_conf.fdir_conf.mask;
8022 mask->vlan_tci_mask = res->vlan_value;
8023 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8024 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8025 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8026 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8027 mask->src_port_mask = res->port_src;
8028 mask->dst_port_mask = res->port_dst;
8030 cmd_reconfig_device_queue(res->port_id, 1, 1);
8033 cmdline_parse_token_string_t cmd_flow_director_mask =
8034 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8035 flow_director_mask, "flow_director_mask");
8036 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8037 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8039 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8040 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8042 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8043 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8044 vlan_value, UINT16);
8045 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8046 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8047 src_mask, "src_mask");
8048 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8049 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8051 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8052 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8054 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8055 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8057 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8058 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8059 dst_mask, "dst_mask");
8060 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8061 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8063 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8064 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8066 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8067 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8069 cmdline_parse_inst_t cmd_set_flow_director_mask = {
8070 .f = cmd_flow_director_mask_parsed,
8072 .help_str = "set flow director's mask on NIC",
8074 (void *)&cmd_flow_director_mask,
8075 (void *)&cmd_flow_director_mask_port_id,
8076 (void *)&cmd_flow_director_mask_vlan,
8077 (void *)&cmd_flow_director_mask_vlan_value,
8078 (void *)&cmd_flow_director_mask_src,
8079 (void *)&cmd_flow_director_mask_ipv4_src,
8080 (void *)&cmd_flow_director_mask_ipv6_src,
8081 (void *)&cmd_flow_director_mask_port_src,
8082 (void *)&cmd_flow_director_mask_dst,
8083 (void *)&cmd_flow_director_mask_ipv4_dst,
8084 (void *)&cmd_flow_director_mask_ipv6_dst,
8085 (void *)&cmd_flow_director_mask_port_dst,
8090 /* *** deal with flow director mask on flexible payload *** */
8091 struct cmd_flow_director_flex_mask_result {
8092 cmdline_fixed_string_t flow_director_flexmask;
8094 cmdline_fixed_string_t flow;
8095 cmdline_fixed_string_t flow_type;
8096 cmdline_fixed_string_t mask;
8100 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8101 __attribute__((unused)) struct cmdline *cl,
8102 __attribute__((unused)) void *data)
8104 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8105 struct rte_eth_fdir_info fdir_info;
8106 struct rte_eth_fdir_flex_mask flex_mask;
8107 struct rte_port *port;
8108 enum rte_eth_flow_type i;
8111 if (res->port_id > nb_ports) {
8112 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8116 port = &ports[res->port_id];
8117 /** Check if the port is not started **/
8118 if (port->port_status != RTE_PORT_STOPPED) {
8119 printf("Please stop port %d first\n", res->port_id);
8123 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8124 ret = parse_flexbytes(res->mask,
8126 RTE_ETH_FDIR_MAX_FLEXLEN);
8128 printf("error: Cannot parse mask input.\n");
8132 if (!strcmp(res->flow_type, "all")) {
8133 memset(&fdir_info, 0, sizeof(fdir_info));
8134 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8135 RTE_ETH_FILTER_INFO, &fdir_info);
8136 for (i = RTE_ETH_FLOW_TYPE_RAW;
8137 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8139 if (fdir_info.flow_types_mask[0] & (1 << i)) {
8140 flex_mask.flow_type = i;
8141 fdir_set_flex_mask(res->port_id, &flex_mask);
8144 cmd_reconfig_device_queue(res->port_id, 1, 1);
8147 flex_mask.flow_type = str2flowtype(res->flow_type);
8148 fdir_set_flex_mask(res->port_id, &flex_mask);
8149 cmd_reconfig_device_queue(res->port_id, 1, 1);
8152 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8153 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8154 flow_director_flexmask,
8155 "flow_director_flex_mask");
8156 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8157 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8159 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8160 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8162 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8163 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8165 "raw#ip4#ip4-frag#tcp4#udp4#sctp4#"
8166 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8167 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8168 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8171 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8172 .f = cmd_flow_director_flex_mask_parsed,
8174 .help_str = "set flow director's flex mask on NIC",
8176 (void *)&cmd_flow_director_flexmask,
8177 (void *)&cmd_flow_director_flexmask_port_id,
8178 (void *)&cmd_flow_director_flexmask_flow,
8179 (void *)&cmd_flow_director_flexmask_flow_type,
8180 (void *)&cmd_flow_director_flexmask_mask,
8185 /* *** deal with flow director flexible payload configuration *** */
8186 struct cmd_flow_director_flexpayload_result {
8187 cmdline_fixed_string_t flow_director_flexpayload;
8189 cmdline_fixed_string_t payload_layer;
8190 cmdline_fixed_string_t payload_cfg;
8194 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8197 const char *p, *p0 = q_arg;
8199 unsigned long int_fld;
8200 char *str_fld[max_num];
8205 p = strchr(p0, '(');
8209 p0 = strchr(p, ')');
8214 if (size >= sizeof(s))
8217 snprintf(s, sizeof(s), "%.*s", size, p);
8218 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8219 if (ret < 0 || ret > max_num)
8221 for (i = 0; i < ret; i++) {
8223 int_fld = strtoul(str_fld[i], &end, 0);
8224 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8226 offsets[i] = (uint16_t)int_fld;
8232 cmd_flow_director_flxpld_parsed(void *parsed_result,
8233 __attribute__((unused)) struct cmdline *cl,
8234 __attribute__((unused)) void *data)
8236 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8237 struct rte_eth_flex_payload_cfg flex_cfg;
8238 struct rte_port *port;
8241 if (res->port_id > nb_ports) {
8242 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8246 port = &ports[res->port_id];
8247 /** Check if the port is not started **/
8248 if (port->port_status != RTE_PORT_STOPPED) {
8249 printf("Please stop port %d first\n", res->port_id);
8253 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8255 if (!strcmp(res->payload_layer, "raw"))
8256 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8257 else if (!strcmp(res->payload_layer, "l2"))
8258 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8259 else if (!strcmp(res->payload_layer, "l3"))
8260 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8261 else if (!strcmp(res->payload_layer, "l4"))
8262 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8264 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8265 RTE_ETH_FDIR_MAX_FLEXLEN);
8267 printf("error: Cannot parse flex payload input.\n");
8271 fdir_set_flex_payload(res->port_id, &flex_cfg);
8272 cmd_reconfig_device_queue(res->port_id, 1, 1);
8275 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8277 flow_director_flexpayload,
8278 "flow_director_flex_payload");
8279 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8280 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8282 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8284 payload_layer, "raw#l2#l3#l4");
8285 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8289 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8290 .f = cmd_flow_director_flxpld_parsed,
8292 .help_str = "set flow director's flex payload on NIC",
8294 (void *)&cmd_flow_director_flexpayload,
8295 (void *)&cmd_flow_director_flexpayload_port_id,
8296 (void *)&cmd_flow_director_flexpayload_payload_layer,
8297 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8302 /* *** Classification Filters Control *** */
8303 /* *** Get symmetric hash enable per port *** */
8304 struct cmd_get_sym_hash_ena_per_port_result {
8305 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8310 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8311 __rte_unused struct cmdline *cl,
8312 __rte_unused void *data)
8314 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8315 struct rte_eth_hash_filter_info info;
8318 if (rte_eth_dev_filter_supported(res->port_id,
8319 RTE_ETH_FILTER_HASH) < 0) {
8320 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8325 memset(&info, 0, sizeof(info));
8326 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8327 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8328 RTE_ETH_FILTER_GET, &info);
8331 printf("Cannot get symmetric hash enable per port "
8332 "on port %u\n", res->port_id);
8336 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8337 "enabled" : "disabled", res->port_id);
8340 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8341 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8342 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8343 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8344 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8347 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8348 .f = cmd_get_sym_hash_per_port_parsed,
8350 .help_str = "get_sym_hash_ena_per_port port_id",
8352 (void *)&cmd_get_sym_hash_ena_per_port_all,
8353 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8358 /* *** Set symmetric hash enable per port *** */
8359 struct cmd_set_sym_hash_ena_per_port_result {
8360 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8361 cmdline_fixed_string_t enable;
8366 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8367 __rte_unused struct cmdline *cl,
8368 __rte_unused void *data)
8370 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8371 struct rte_eth_hash_filter_info info;
8374 if (rte_eth_dev_filter_supported(res->port_id,
8375 RTE_ETH_FILTER_HASH) < 0) {
8376 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8381 memset(&info, 0, sizeof(info));
8382 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8383 if (!strcmp(res->enable, "enable"))
8384 info.info.enable = 1;
8385 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8386 RTE_ETH_FILTER_SET, &info);
8388 printf("Cannot set symmetric hash enable per port on "
8389 "port %u\n", res->port_id);
8392 printf("Symmetric hash has been set to %s on port %u\n",
8393 res->enable, res->port_id);
8396 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8397 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8398 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8399 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8400 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8402 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8403 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8404 enable, "enable#disable");
8406 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8407 .f = cmd_set_sym_hash_per_port_parsed,
8409 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8411 (void *)&cmd_set_sym_hash_ena_per_port_all,
8412 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8413 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8418 /* Get global config of hash function */
8419 struct cmd_get_hash_global_config_result {
8420 cmdline_fixed_string_t get_hash_global_config;
8425 flowtype_to_str(enum rte_eth_flow_type ftype)
8430 enum rte_eth_flow_type ftype;
8432 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8433 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8434 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8435 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8436 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8437 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8438 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8439 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8440 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8441 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8444 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8445 if (ftype_table[i].ftype == ftype)
8446 return ftype_table[i].str;
8453 cmd_get_hash_global_config_parsed(void *parsed_result,
8454 __rte_unused struct cmdline *cl,
8455 __rte_unused void *data)
8457 struct cmd_get_hash_global_config_result *res = parsed_result;
8458 struct rte_eth_hash_filter_info info;
8459 uint32_t idx, offset, i;
8463 if (rte_eth_dev_filter_supported(res->port_id,
8464 RTE_ETH_FILTER_HASH) < 0) {
8465 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8470 memset(&info, 0, sizeof(info));
8471 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8472 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8473 RTE_ETH_FILTER_GET, &info);
8475 printf("Cannot get hash global configurations by port %d\n",
8480 switch (info.info.global_conf.hash_func) {
8481 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8482 printf("Hash function is Toeplitz\n");
8484 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8485 printf("Hash function is Simple XOR\n");
8488 printf("Unknown hash function\n");
8492 for (i = 0; i < RTE_ETH_FLOW_TYPE_MAX; i++) {
8493 idx = i / UINT32_BIT;
8494 offset = i % UINT32_BIT;
8495 if (!(info.info.global_conf.valid_bit_mask[idx] &
8498 str = flowtype_to_str((enum rte_eth_flow_type)i);
8501 printf("Symmetric hash is %s globally for flow type %s "
8503 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8504 (1UL << offset)) ? "enabled" : "disabled"), str,
8509 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8510 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8511 get_hash_global_config, "get_hash_global_config");
8512 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8513 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8516 cmdline_parse_inst_t cmd_get_hash_global_config = {
8517 .f = cmd_get_hash_global_config_parsed,
8519 .help_str = "get_hash_global_config port_id",
8521 (void *)&cmd_get_hash_global_config_all,
8522 (void *)&cmd_get_hash_global_config_port_id,
8527 /* Set global config of hash function */
8528 struct cmd_set_hash_global_config_result {
8529 cmdline_fixed_string_t set_hash_global_config;
8531 cmdline_fixed_string_t hash_func;
8532 cmdline_fixed_string_t flow_type;
8533 cmdline_fixed_string_t enable;
8537 cmd_set_hash_global_config_parsed(void *parsed_result,
8538 __rte_unused struct cmdline *cl,
8539 __rte_unused void *data)
8541 struct cmd_set_hash_global_config_result *res = parsed_result;
8542 struct rte_eth_hash_filter_info info;
8543 uint32_t ftype, idx, offset;
8546 if (rte_eth_dev_filter_supported(res->port_id,
8547 RTE_ETH_FILTER_HASH) < 0) {
8548 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8552 memset(&info, 0, sizeof(info));
8553 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8554 if (!strcmp(res->hash_func, "toeplitz"))
8555 info.info.global_conf.hash_func =
8556 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8557 else if (!strcmp(res->hash_func, "simple_xor"))
8558 info.info.global_conf.hash_func =
8559 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8560 else if (!strcmp(res->hash_func, "default"))
8561 info.info.global_conf.hash_func =
8562 RTE_ETH_HASH_FUNCTION_DEFAULT;
8564 ftype = str2flowtype(res->flow_type);
8565 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8566 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8567 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8568 if (!strcmp(res->enable, "enable"))
8569 info.info.global_conf.sym_hash_enable_mask[idx] |=
8571 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8572 RTE_ETH_FILTER_SET, &info);
8574 printf("Cannot set global hash configurations by port %d\n",
8577 printf("Global hash configurations have been set "
8578 "succcessfully by port %d\n", res->port_id);
8581 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8582 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8583 set_hash_global_config, "set_hash_global_config");
8584 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8585 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8587 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8588 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8589 hash_func, "toeplitz#simple_xor#default");
8590 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8591 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8593 "ip4#ip4-frag#tcp4#udp4#sctp4#ip6#ip6-frag#tcp6#udp6#sctp6");
8594 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8595 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8596 enable, "enable#disable");
8598 cmdline_parse_inst_t cmd_set_hash_global_config = {
8599 .f = cmd_set_hash_global_config_parsed,
8601 .help_str = "set_hash_global_config port_id "
8602 "toeplitz|simple_xor|default "
8603 "ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6 "
8606 (void *)&cmd_set_hash_global_config_all,
8607 (void *)&cmd_set_hash_global_config_port_id,
8608 (void *)&cmd_set_hash_global_config_hash_func,
8609 (void *)&cmd_set_hash_global_config_flow_type,
8610 (void *)&cmd_set_hash_global_config_enable,
8615 /* ******************************************************************************** */
8617 /* list of instructions */
8618 cmdline_parse_ctx_t main_ctx[] = {
8619 (cmdline_parse_inst_t *)&cmd_help_brief,
8620 (cmdline_parse_inst_t *)&cmd_help_long,
8621 (cmdline_parse_inst_t *)&cmd_quit,
8622 (cmdline_parse_inst_t *)&cmd_showport,
8623 (cmdline_parse_inst_t *)&cmd_showportall,
8624 (cmdline_parse_inst_t *)&cmd_showcfg,
8625 (cmdline_parse_inst_t *)&cmd_start,
8626 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8627 (cmdline_parse_inst_t *)&cmd_set_link_up,
8628 (cmdline_parse_inst_t *)&cmd_set_link_down,
8629 (cmdline_parse_inst_t *)&cmd_reset,
8630 (cmdline_parse_inst_t *)&cmd_set_numbers,
8631 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8632 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8633 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8634 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8635 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8636 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8637 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8638 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8639 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8640 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8641 (cmdline_parse_inst_t *)&cmd_set_link_check,
8642 #ifdef RTE_NIC_BYPASS
8643 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8644 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8645 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8646 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8648 #ifdef RTE_LIBRTE_PMD_BOND
8649 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8650 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8651 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8652 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8653 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8654 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8655 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8656 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8657 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8659 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8660 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8661 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8662 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8663 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8664 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8665 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8666 (cmdline_parse_inst_t *)&cmd_csum_set,
8667 (cmdline_parse_inst_t *)&cmd_csum_show,
8668 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
8669 (cmdline_parse_inst_t *)&cmd_tso_set,
8670 (cmdline_parse_inst_t *)&cmd_tso_show,
8671 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8672 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8673 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8674 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8675 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8676 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8677 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8678 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8679 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8680 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8681 (cmdline_parse_inst_t *)&cmd_config_dcb,
8682 (cmdline_parse_inst_t *)&cmd_read_reg,
8683 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8684 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8685 (cmdline_parse_inst_t *)&cmd_write_reg,
8686 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8687 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8688 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8689 (cmdline_parse_inst_t *)&cmd_stop,
8690 (cmdline_parse_inst_t *)&cmd_mac_addr,
8691 (cmdline_parse_inst_t *)&cmd_set_qmap,
8692 (cmdline_parse_inst_t *)&cmd_operate_port,
8693 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8694 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8695 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8696 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8697 (cmdline_parse_inst_t *)&cmd_config_mtu,
8698 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8699 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8700 (cmdline_parse_inst_t *)&cmd_config_rss,
8701 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8702 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8703 (cmdline_parse_inst_t *)&cmd_showport_reta,
8704 (cmdline_parse_inst_t *)&cmd_config_burst,
8705 (cmdline_parse_inst_t *)&cmd_config_thresh,
8706 (cmdline_parse_inst_t *)&cmd_config_threshold,
8707 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8708 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8709 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8710 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8711 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8712 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8713 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8714 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8715 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8716 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8717 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8718 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8719 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8720 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8721 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8722 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8723 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8724 (cmdline_parse_inst_t *)&cmd_dump,
8725 (cmdline_parse_inst_t *)&cmd_dump_one,
8726 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
8727 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
8728 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
8729 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
8730 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
8731 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
8732 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
8733 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
8734 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
8735 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
8736 (cmdline_parse_inst_t *)&cmd_flex_filter,
8737 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8738 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8739 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8740 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8741 (cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
8742 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8743 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
8744 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
8745 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
8746 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
8747 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
8751 /* prompt function, called from main on MASTER lcore */
8757 /* initialize non-constant commands */
8758 cmd_set_fwd_mode_init();
8760 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8764 cmdline_interact(cl);
8765 cmdline_stdin_exit(cl);
8769 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8771 if (id < nb_ports) {
8772 /* check if need_reconfig has been set to 1 */
8773 if (ports[id].need_reconfig == 0)
8774 ports[id].need_reconfig = dev;
8775 /* check if need_reconfig_queues has been set to 1 */
8776 if (ports[id].need_reconfig_queues == 0)
8777 ports[id].need_reconfig_queues = queue;
8781 for (pid = 0; pid < nb_ports; pid++) {
8782 /* check if need_reconfig has been set to 1 */
8783 if (ports[pid].need_reconfig == 0)
8784 ports[pid].need_reconfig = dev;
8785 /* check if need_reconfig_queues has been set to 1 */
8786 if (ports[pid].need_reconfig_queues == 0)
8787 ports[pid].need_reconfig_queues = queue;
8792 #ifdef RTE_NIC_BYPASS
8794 bypass_is_supported(portid_t port_id)
8796 struct rte_port *port;
8797 struct rte_pci_id *pci_id;
8799 if (port_id >= nb_ports) {
8800 printf("\tPort id must be less than %d.\n", nb_ports);
8804 /* Get the device id. */
8805 port = &ports[port_id];
8806 pci_id = &port->dev_info.pci_dev->id;
8808 /* Check if NIC supports bypass. */
8809 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8813 printf("\tBypass not supported for port_id = %d.\n", port_id);