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 flowdir : Flow Director filter help.\n"
120 " help registers : Reading and setting port registers.\n"
121 " help filters : Filters configuration help.\n"
122 " help all : All of the above sections.\n\n"
127 cmdline_parse_token_string_t cmd_help_brief_help =
128 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
130 cmdline_parse_inst_t cmd_help_brief = {
131 .f = cmd_help_brief_parsed,
133 .help_str = "show help",
135 (void *)&cmd_help_brief_help,
140 /* *** Help command with help sections. *** */
141 struct cmd_help_long_result {
142 cmdline_fixed_string_t help;
143 cmdline_fixed_string_t section;
146 static void cmd_help_long_parsed(void *parsed_result,
148 __attribute__((unused)) void *data)
151 struct cmd_help_long_result *res = parsed_result;
153 if (!strcmp(res->section, "all"))
156 if (show_all || !strcmp(res->section, "control")) {
161 "Control forwarding:\n"
162 "-------------------\n\n"
165 " Start packet forwarding with current configuration.\n\n"
168 " Start packet forwarding with current config"
169 " after sending one burst of packets.\n\n"
172 " Stop packet forwarding, and display accumulated"
176 " Quit to prompt.\n\n"
180 if (show_all || !strcmp(res->section, "display")) {
188 "show port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
189 " Display information for port_id, or all.\n\n"
191 "show port X rss reta (size) (mask0,mask1,...)\n"
192 " Display the rss redirection table entry indicated"
193 " by masks on port X. size is used to indicate the"
194 " hardware supported reta size\n\n"
196 "show port rss-hash [key]\n"
197 " Display the RSS hash functions and RSS hash key"
200 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
201 " Clear information for port_id, or all.\n\n"
203 "show config (rxtx|cores|fwd)\n"
204 " Display the given configuration.\n\n"
206 "read rxd (port_id) (queue_id) (rxd_id)\n"
207 " Display an RX descriptor of a port RX queue.\n\n"
209 "read txd (port_id) (queue_id) (txd_id)\n"
210 " Display a TX descriptor of a port TX queue.\n\n"
214 if (show_all || !strcmp(res->section, "config")) {
220 "Configuration changes only become active when"
221 " forwarding is started/restarted.\n\n"
224 " Reset forwarding to the default configuration.\n\n"
226 "set verbose (level)\n"
227 " Set the debug verbosity level X.\n\n"
230 " Set number of ports.\n\n"
233 " Set number of cores.\n\n"
235 "set coremask (mask)\n"
236 " Set the forwarding cores hexadecimal mask.\n\n"
238 "set portmask (mask)\n"
239 " Set the forwarding ports hexadecimal mask.\n\n"
242 " Set number of packets per burst.\n\n"
244 "set burst tx delay (microseconds) retry (num)\n"
245 " Set the transmit delay time and number of retries"
246 " in mac_retry forwarding mode.\n\n"
248 "set txpkts (x[,y]*)\n"
249 " Set the length of each segment of TXONLY"
252 "set corelist (x[,y]*)\n"
253 " Set the list of forwarding cores.\n\n"
255 "set portlist (x[,y]*)\n"
256 " Set the list of forwarding ports.\n\n"
258 "vlan set strip (on|off) (port_id)\n"
259 " Set the VLAN strip on a port.\n\n"
261 "vlan set stripq (on|off) (port_id,queue_id)\n"
262 " Set the VLAN strip for a queue on a port.\n\n"
264 "vlan set filter (on|off) (port_id)\n"
265 " Set the VLAN filter on a port.\n\n"
267 "vlan set qinq (on|off) (port_id)\n"
268 " Set the VLAN QinQ (extended queue in queue)"
271 "vlan set tpid (value) (port_id)\n"
272 " Set the outer VLAN TPID for Packet Filtering on"
275 "rx_vlan add (vlan_id|all) (port_id)\n"
276 " Add a vlan_id, or all identifiers, to the set"
277 " of VLAN identifiers filtered by port_id.\n\n"
279 "rx_vlan rm (vlan_id|all) (port_id)\n"
280 " Remove a vlan_id, or all identifiers, from the set"
281 " of VLAN identifiers filtered by port_id.\n\n"
283 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
284 " Add a vlan_id, to the set of VLAN identifiers"
285 "filtered for VF(s) from port_id.\n\n"
287 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
288 " Remove a vlan_id, to the set of VLAN identifiers"
289 "filtered for VF(s) from port_id.\n\n"
291 "rx_vlan set tpid (value) (port_id)\n"
292 " Set the outer VLAN TPID for Packet Filtering on"
295 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
296 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
297 " add a tunnel filter of a port.\n\n"
299 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
300 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
301 " remove a tunnel filter of a port.\n\n"
303 "rx_vxlan_port add (udp_port) (port_id)\n"
304 " Add an UDP port for VXLAN packet filter on a port\n\n"
306 "rx_vxlan_port rm (udp_port) (port_id)\n"
307 " Remove an UDP port for VXLAN packet filter on a port\n\n"
309 "tx_vlan set vlan_id (port_id)\n"
310 " Set hardware insertion of VLAN ID in packets sent"
313 "tx_vlan set pvid port_id vlan_id (on|off)\n"
314 " Set port based TX VLAN insertion.\n\n"
316 "tx_vlan reset (port_id)\n"
317 " Disable hardware insertion of a VLAN header in"
318 " packets sent on a port.\n\n"
320 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
321 " Select hardware or software calculation of the"
322 " checksum with when transmitting a packet using the"
323 " csum forward engine.\n"
324 " ip|udp|tcp|sctp always concern the inner layer.\n"
325 " outer-ip concerns the outer IP layer in"
326 " case the packet is recognized as a tunnel packet by"
327 " the forward engine (vxlan, gre and ipip are supported)\n"
328 " Please check the NIC datasheet for HW limits.\n\n"
330 "csum parse-tunnel (on|off) (tx_port_id)\n"
331 " If disabled, treat tunnel packets as non-tunneled"
332 " packets (treat inner headers as payload). The port\n"
333 " argument is the port used for TX in csum forward"
336 "csum show (port_id)\n"
337 " Display tx checksum offload configuration\n\n"
339 "tso set (segsize) (portid)\n"
340 " Enable TCP Segmentation Offload in csum forward"
342 " Please check the NIC datasheet for HW limits.\n\n"
345 " Display the status of TCP Segmentation Offload.\n\n"
348 " Set packet forwarding mode.\n\n"
350 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
351 " Add a MAC address on port_id.\n\n"
353 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
354 " Remove a MAC address from port_id.\n\n"
356 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
357 " Add a MAC address for a VF on the port.\n\n"
359 "set port (port_id) uta (mac_address|all) (on|off)\n"
360 " Add/Remove a or all unicast hash filter(s)"
363 "set promisc (port_id|all) (on|off)\n"
364 " Set the promiscuous mode on port_id, or all.\n\n"
366 "set allmulti (port_id|all) (on|off)\n"
367 " Set the allmulti mode on port_id, or all.\n\n"
369 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
370 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
371 " (on|off) autoneg (on|off) (port_id)\n"
372 "set flow_ctrl rx (on|off) (portid)\n"
373 "set flow_ctrl tx (on|off) (portid)\n"
374 "set flow_ctrl high_water (high_water) (portid)\n"
375 "set flow_ctrl low_water (low_water) (portid)\n"
376 "set flow_ctrl pause_time (pause_time) (portid)\n"
377 "set flow_ctrl send_xon (send_xon) (portid)\n"
378 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
379 "set flow_ctrl autoneg (on|off) (port_id)\n"
380 " Set the link flow control parameter on a port.\n\n"
382 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
383 " (low_water) (pause_time) (priority) (port_id)\n"
384 " Set the priority flow control parameter on a"
387 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
388 " Set statistics mapping (qmapping 0..15) for RX/TX"
390 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
391 " on port 0 to mapping 5.\n\n"
393 "set port (port_id) vf (vf_id) rx|tx on|off\n"
394 " Enable/Disable a VF receive/tranmit from a port\n\n"
396 "set port (port_id) vf (vf_id) (mac_addr)"
397 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
398 " Add/Remove unicast or multicast MAC addr filter"
401 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
403 " AUPE:accepts untagged VLAN;"
404 "ROPE:accept unicast hash\n\n"
405 " BAM:accepts broadcast packets;"
406 "MPE:accepts all multicast packets\n\n"
407 " Enable/Disable a VF receive mode of a port\n\n"
409 "set port (port_id) queue (queue_id) rate (rate_num)\n"
410 " Set rate limit for a queue of a port\n\n"
412 "set port (port_id) vf (vf_id) rate (rate_num) "
413 "queue_mask (queue_mask_value)\n"
414 " Set rate limit for queues in VF of a port\n\n"
416 "set port (port_id) mirror-rule (rule_id)"
417 "(pool-mirror|vlan-mirror)\n"
418 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
419 " Set pool or vlan type mirror rule on a port.\n"
420 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
421 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
424 "set port (port_id) mirror-rule (rule_id)"
425 " (uplink-mirror|downlink-mirror) dst-pool"
426 " (pool_id) (on|off)\n"
427 " Set uplink or downlink type mirror rule on a port.\n"
428 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
429 " 0 on' enable mirror income traffic to pool 0.\n\n"
431 "reset port (port_id) mirror-rule (rule_id)\n"
432 " Reset a mirror rule.\n\n"
434 "set flush_rx (on|off)\n"
435 " Flush (default) or don't flush RX streams before"
436 " forwarding. Mainly used with PCAP drivers.\n\n"
438 #ifdef RTE_NIC_BYPASS
439 "set bypass mode (normal|bypass|isolate) (port_id)\n"
440 " Set the bypass mode for the lowest port on bypass enabled"
443 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
444 "mode (normal|bypass|isolate) (port_id)\n"
445 " Set the event required to initiate specified bypass mode for"
446 " the lowest port on a bypass enabled NIC where:\n"
447 " timeout = enable bypass after watchdog timeout.\n"
448 " os_on = enable bypass when OS/board is powered on.\n"
449 " os_off = enable bypass when OS/board is powered off.\n"
450 " power_on = enable bypass when power supply is turned on.\n"
451 " power_off = enable bypass when power supply is turned off."
454 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
455 " Set the bypass watchdog timeout to 'n' seconds"
456 " where 0 = instant.\n\n"
458 "show bypass config (port_id)\n"
459 " Show the bypass configuration for a bypass enabled NIC"
460 " using the lowest port on the NIC.\n\n"
462 #ifdef RTE_LIBRTE_PMD_BOND
463 "create bonded device (mode) (socket)\n"
464 " Create a new bonded device with specific bonding mode and socket.\n\n"
466 "add bonding slave (slave_id) (port_id)\n"
467 " Add a slave device to a bonded device.\n\n"
469 "remove bonding slave (slave_id) (port_id)\n"
470 " Remove a slave device from a bonded device.\n\n"
472 "set bonding mode (value) (port_id)\n"
473 " Set the bonding mode on a bonded device.\n\n"
475 "set bonding primary (slave_id) (port_id)\n"
476 " Set the primary slave for a bonded device.\n\n"
478 "show bonding config (port_id)\n"
479 " Show the bonding config for port_id.\n\n"
481 "set bonding mac_addr (port_id) (address)\n"
482 " Set the MAC address of a bonded device.\n\n"
484 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
485 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
487 "set bonding mon_period (port_id) (value)\n"
488 " Set the bonding link status monitoring polling period in ms.\n\n"
490 "set link-up port (port_id)\n"
491 " Set link up for a port.\n\n"
493 "set link-down port (port_id)\n"
494 " Set link down for a port.\n\n"
496 , list_pkt_forwarding_modes()
501 if (show_all || !strcmp(res->section, "flowdir")) {
506 "Flow director mode:\n"
507 "-------------------\n\n"
509 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
510 " src (src_ip_address) (src_port)"
511 " dst (dst_ip_address) (dst_port)"
512 " flexbytes (flexbytes_values) vlan (vlan_id)"
513 " queue (queue_id)\n"
514 " Add a signature filter.\n\n"
516 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
517 " src (src_ip_address) (src_port)"
518 " dst (dst_ip_address) (dst_port)"
519 " flexbytes (flexbytes_values) vlan (vlan_id)"
520 " queue (queue_id)\n"
521 " Update a signature filter.\n\n"
523 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
524 " src (src_ip_address) (src_port)"
525 " dst (dst_ip_address) (dst_port)"
526 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
527 " Remove a signature filter.\n\n"
529 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
530 " src (src_ip_address) (src_port)"
531 " dst (dst_ip_address) (dst_port)"
532 " flexbytes (flexbytes_values) vlan (vlan_id)"
533 " queue (queue_id) soft (soft_id)\n"
534 " Add a perfect filter.\n\n"
536 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
537 " src (src_ip_address) (src_port)"
538 " dst (dst_ip_address) (dst_port)"
539 " flexbytes (flexbytes_values) vlan (vlan_id)"
540 " queue (queue_id)\n"
541 " Update a perfect filter.\n\n"
543 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
544 " src (src_ip_address) (src_port)"
545 " dst (dst_ip_address) (dst_port)"
546 " flexbytes (flexbytes_values) vlan (vlan_id)"
548 " Remove a perfect filter.\n\n"
550 "set_masks_filter (port_id) only_ip_flow (0|1)"
551 " src_mask (ip_src_mask) (src_port_mask)"
552 " dst_mask (ip_dst_mask) (dst_port_mask)"
553 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
554 " Set IPv4 filter masks.\n\n"
556 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
557 " src_mask (ip_src_mask) (src_port_mask)"
558 " dst_mask (ip_dst_mask) (dst_port_mask)"
559 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
560 " compare_dst (0|1)\n"
561 " Set IPv6 filter masks.\n\n"
565 if (show_all || !strcmp(res->section, "ports")) {
571 "----------------\n\n"
573 "port start (port_id|all)\n"
574 " Start all ports or port_id.\n\n"
576 "port stop (port_id|all)\n"
577 " Stop all ports or port_id.\n\n"
579 "port close (port_id|all)\n"
580 " Close all ports or port_id.\n\n"
582 "port config (port_id|all)"
583 " speed (10|100|1000|10000|40000|auto)"
584 " duplex (half|full|auto)\n"
585 " Set speed and duplex for all ports or port_id\n\n"
587 "port config all (rxq|txq|rxd|txd) (value)\n"
588 " Set number for rxq/txq/rxd/txd.\n\n"
590 "port config all max-pkt-len (value)\n"
591 " Set the max packet length.\n\n"
593 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
595 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
598 "port config all rss (ip|udp|none)\n"
599 " Set the RSS mode.\n\n"
601 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
602 " Set the RSS redirection table.\n\n"
604 "port config (port_id) dcb vt (on|off) (traffic_class)"
606 " Set the DCB mode.\n\n"
608 "port config all burst (value)\n"
609 " Set the number of packets per burst.\n\n"
611 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
613 " Set the ring prefetch/host/writeback threshold"
614 " for tx/rx queue.\n\n"
616 "port config all (txfreet|txrst|rxfreet) (value)\n"
617 " Set free threshold for rx/tx, or set"
618 " tx rs bit threshold.\n\n"
619 "port config mtu X value\n"
620 " Set the MTU of port X to a given value\n\n"
622 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
623 " Start/stop a rx/tx queue of port X. Only take effect"
624 " when port X is started\n"
628 if (show_all || !strcmp(res->section, "registers")) {
636 "read reg (port_id) (address)\n"
637 " Display value of a port register.\n\n"
639 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
640 " Display a port register bit field.\n\n"
642 "read regbit (port_id) (address) (bit_x)\n"
643 " Display a single port register bit.\n\n"
645 "write reg (port_id) (address) (value)\n"
646 " Set value of a port register.\n\n"
648 "write regfield (port_id) (address) (bit_x) (bit_y)"
650 " Set bit field of a port register.\n\n"
652 "write regbit (port_id) (address) (bit_x) (value)\n"
653 " Set single bit value of a port register.\n\n"
656 if (show_all || !strcmp(res->section, "filters")) {
664 "ethertype_filter (port_id) (add|del)"
665 " (mac_addr|mac_ignr) (mac_address) ethertype"
666 " (ether_type) (drop|fwd) queue (queue_id)\n"
667 " Add/Del an ethertype filter.\n\n"
669 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
670 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
671 " queue (queue_id) index (idx)\n"
672 " add a 2tuple filter.\n\n"
674 "remove_2tuple_filter (port_id) index (idx)\n"
675 " remove a 2tuple filter.\n\n"
677 "get_2tuple_filter (port_id) index (idx)\n"
678 " get info of a 2tuple filter.\n\n"
680 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
681 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
682 " mask (mask_value) flags (flags_value) priority (prio_value)"
683 " queue (queue_id) index (idx)\n"
684 " add a 5tuple filter.\n\n"
686 "remove_5tuple_filter (port_id) index (idx)\n"
687 " remove a 5tuple filter.\n\n"
689 "get_5tuple_filter (port_id) index (idx)\n"
690 " get info of a 5tuple filter.\n\n"
692 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
693 " add syn filter.\n\n"
695 "remove_syn_filter (port_id)"
696 " remove syn filter.\n\n"
698 "get_syn_filter (port_id) "
699 " get syn filter info.\n\n"
701 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
702 " priority (prio_value) queue (queue_id) index (idx)\n"
703 " add a flex filter.\n\n"
705 "remove_flex_filter (port_id) index (idx)\n"
706 " remove a flex filter.\n\n"
708 "get_flex_filter (port_id) index (idx)\n"
709 " get info of a flex filter.\n\n"
711 "flow_director_filter (port_id) (add|del)"
712 " flow (ip4|ip4-frag|ip6|ip6-frag)"
713 " src (src_ip_address) dst (dst_ip_address)"
714 " flexbytes (flexbytes_value)"
715 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
716 " Add/Del an IP type flow director filter.\n\n"
718 "flow_director_filter (port_id) (add|del)"
719 " flow (udp4|tcp4|udp6|tcp6)"
720 " src (src_ip_address) (src_port)"
721 " dst (dst_ip_address) (dst_port)"
722 " flexbytes (flexbytes_value)"
723 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
724 " Add/Del an UDP/TCP type flow director filter.\n\n"
726 "flow_director_filter (port_id) (add|del)"
727 " flow (sctp4|sctp6)"
728 " src (src_ip_address) dst (dst_ip_address)"
729 " tag (verification_tag)"
730 " flexbytes (flexbytes_value) (drop|fwd)"
731 " queue (queue_id) fd_id (fd_id_value)\n"
732 " Add/Del a SCTP type flow director filter.\n\n"
734 "flush_flow_director (port_id)\n"
735 " Flush all flow director entries of a device.\n\n"
737 "flow_director_flex_mask (port_id)"
738 " flow (ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
740 " Configure mask of flex payload.\n\n"
742 "flow_director_flex_payload (port_id)"
743 " (l2|l3|l4) (config)\n"
744 " Configure flex payload selection.\n\n"
746 "get_sym_hash_ena_per_port (port_id)\n"
747 " get symmetric hash enable configuration per port.\n\n"
749 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
750 " set symmetric hash enable configuration per port"
751 " to enable or disable.\n\n"
753 "get_hash_global_config (port_id)\n"
754 " Get the global configurations of hash filters.\n\n"
756 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
757 " (ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6)"
758 " (enable|disable)\n"
759 " Set the global configurations of hash filters.\n\n"
764 cmdline_parse_token_string_t cmd_help_long_help =
765 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
767 cmdline_parse_token_string_t cmd_help_long_section =
768 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
769 "all#control#display#config#flowdir#"
770 "ports#registers#filters");
772 cmdline_parse_inst_t cmd_help_long = {
773 .f = cmd_help_long_parsed,
775 .help_str = "show help",
777 (void *)&cmd_help_long_help,
778 (void *)&cmd_help_long_section,
784 /* *** start/stop/close all ports *** */
785 struct cmd_operate_port_result {
786 cmdline_fixed_string_t keyword;
787 cmdline_fixed_string_t name;
788 cmdline_fixed_string_t value;
791 static void cmd_operate_port_parsed(void *parsed_result,
792 __attribute__((unused)) struct cmdline *cl,
793 __attribute__((unused)) void *data)
795 struct cmd_operate_port_result *res = parsed_result;
797 if (!strcmp(res->name, "start"))
798 start_port(RTE_PORT_ALL);
799 else if (!strcmp(res->name, "stop"))
800 stop_port(RTE_PORT_ALL);
801 else if (!strcmp(res->name, "close"))
802 close_port(RTE_PORT_ALL);
804 printf("Unknown parameter\n");
807 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
808 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
810 cmdline_parse_token_string_t cmd_operate_port_all_port =
811 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
813 cmdline_parse_token_string_t cmd_operate_port_all_all =
814 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
816 cmdline_parse_inst_t cmd_operate_port = {
817 .f = cmd_operate_port_parsed,
819 .help_str = "port start|stop|close all: start/stop/close all ports",
821 (void *)&cmd_operate_port_all_cmd,
822 (void *)&cmd_operate_port_all_port,
823 (void *)&cmd_operate_port_all_all,
828 /* *** start/stop/close specific port *** */
829 struct cmd_operate_specific_port_result {
830 cmdline_fixed_string_t keyword;
831 cmdline_fixed_string_t name;
835 static void cmd_operate_specific_port_parsed(void *parsed_result,
836 __attribute__((unused)) struct cmdline *cl,
837 __attribute__((unused)) void *data)
839 struct cmd_operate_specific_port_result *res = parsed_result;
841 if (!strcmp(res->name, "start"))
842 start_port(res->value);
843 else if (!strcmp(res->name, "stop"))
844 stop_port(res->value);
845 else if (!strcmp(res->name, "close"))
846 close_port(res->value);
848 printf("Unknown parameter\n");
851 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
852 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
854 cmdline_parse_token_string_t cmd_operate_specific_port_port =
855 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
856 name, "start#stop#close");
857 cmdline_parse_token_num_t cmd_operate_specific_port_id =
858 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
861 cmdline_parse_inst_t cmd_operate_specific_port = {
862 .f = cmd_operate_specific_port_parsed,
864 .help_str = "port start|stop|close X: start/stop/close port X",
866 (void *)&cmd_operate_specific_port_cmd,
867 (void *)&cmd_operate_specific_port_port,
868 (void *)&cmd_operate_specific_port_id,
873 /* *** configure speed for all ports *** */
874 struct cmd_config_speed_all {
875 cmdline_fixed_string_t port;
876 cmdline_fixed_string_t keyword;
877 cmdline_fixed_string_t all;
878 cmdline_fixed_string_t item1;
879 cmdline_fixed_string_t item2;
880 cmdline_fixed_string_t value1;
881 cmdline_fixed_string_t value2;
885 cmd_config_speed_all_parsed(void *parsed_result,
886 __attribute__((unused)) struct cmdline *cl,
887 __attribute__((unused)) void *data)
889 struct cmd_config_speed_all *res = parsed_result;
890 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
891 uint16_t link_duplex = 0;
894 if (!all_ports_stopped()) {
895 printf("Please stop all ports first\n");
899 if (!strcmp(res->value1, "10"))
900 link_speed = ETH_LINK_SPEED_10;
901 else if (!strcmp(res->value1, "100"))
902 link_speed = ETH_LINK_SPEED_100;
903 else if (!strcmp(res->value1, "1000"))
904 link_speed = ETH_LINK_SPEED_1000;
905 else if (!strcmp(res->value1, "10000"))
906 link_speed = ETH_LINK_SPEED_10G;
907 else if (!strcmp(res->value1, "40000"))
908 link_speed = ETH_LINK_SPEED_40G;
909 else if (!strcmp(res->value1, "auto"))
910 link_speed = ETH_LINK_SPEED_AUTONEG;
912 printf("Unknown parameter\n");
916 if (!strcmp(res->value2, "half"))
917 link_duplex = ETH_LINK_HALF_DUPLEX;
918 else if (!strcmp(res->value2, "full"))
919 link_duplex = ETH_LINK_FULL_DUPLEX;
920 else if (!strcmp(res->value2, "auto"))
921 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
923 printf("Unknown parameter\n");
927 for (pid = 0; pid < nb_ports; pid++) {
928 ports[pid].dev_conf.link_speed = link_speed;
929 ports[pid].dev_conf.link_duplex = link_duplex;
932 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
935 cmdline_parse_token_string_t cmd_config_speed_all_port =
936 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
937 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
938 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
940 cmdline_parse_token_string_t cmd_config_speed_all_all =
941 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
942 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
943 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
944 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
945 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
946 "10#100#1000#10000#40000#auto");
947 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
948 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
949 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
950 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
953 cmdline_parse_inst_t cmd_config_speed_all = {
954 .f = cmd_config_speed_all_parsed,
956 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
959 (void *)&cmd_config_speed_all_port,
960 (void *)&cmd_config_speed_all_keyword,
961 (void *)&cmd_config_speed_all_all,
962 (void *)&cmd_config_speed_all_item1,
963 (void *)&cmd_config_speed_all_value1,
964 (void *)&cmd_config_speed_all_item2,
965 (void *)&cmd_config_speed_all_value2,
970 /* *** configure speed for specific port *** */
971 struct cmd_config_speed_specific {
972 cmdline_fixed_string_t port;
973 cmdline_fixed_string_t keyword;
975 cmdline_fixed_string_t item1;
976 cmdline_fixed_string_t item2;
977 cmdline_fixed_string_t value1;
978 cmdline_fixed_string_t value2;
982 cmd_config_speed_specific_parsed(void *parsed_result,
983 __attribute__((unused)) struct cmdline *cl,
984 __attribute__((unused)) void *data)
986 struct cmd_config_speed_specific *res = parsed_result;
987 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
988 uint16_t link_duplex = 0;
990 if (!all_ports_stopped()) {
991 printf("Please stop all ports first\n");
995 if (res->id >= nb_ports) {
996 printf("Port id %d must be less than %d\n", res->id, nb_ports);
1000 if (!strcmp(res->value1, "10"))
1001 link_speed = ETH_LINK_SPEED_10;
1002 else if (!strcmp(res->value1, "100"))
1003 link_speed = ETH_LINK_SPEED_100;
1004 else if (!strcmp(res->value1, "1000"))
1005 link_speed = ETH_LINK_SPEED_1000;
1006 else if (!strcmp(res->value1, "10000"))
1007 link_speed = ETH_LINK_SPEED_10000;
1008 else if (!strcmp(res->value1, "40000"))
1009 link_speed = ETH_LINK_SPEED_40G;
1010 else if (!strcmp(res->value1, "auto"))
1011 link_speed = ETH_LINK_SPEED_AUTONEG;
1013 printf("Unknown parameter\n");
1017 if (!strcmp(res->value2, "half"))
1018 link_duplex = ETH_LINK_HALF_DUPLEX;
1019 else if (!strcmp(res->value2, "full"))
1020 link_duplex = ETH_LINK_FULL_DUPLEX;
1021 else if (!strcmp(res->value2, "auto"))
1022 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1024 printf("Unknown parameter\n");
1028 ports[res->id].dev_conf.link_speed = link_speed;
1029 ports[res->id].dev_conf.link_duplex = link_duplex;
1031 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1035 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1036 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1038 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1039 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1041 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1042 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1043 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1044 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1046 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1047 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1048 "10#100#1000#10000#40000#auto");
1049 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1050 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1052 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1053 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1056 cmdline_parse_inst_t cmd_config_speed_specific = {
1057 .f = cmd_config_speed_specific_parsed,
1059 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1062 (void *)&cmd_config_speed_specific_port,
1063 (void *)&cmd_config_speed_specific_keyword,
1064 (void *)&cmd_config_speed_specific_id,
1065 (void *)&cmd_config_speed_specific_item1,
1066 (void *)&cmd_config_speed_specific_value1,
1067 (void *)&cmd_config_speed_specific_item2,
1068 (void *)&cmd_config_speed_specific_value2,
1073 /* *** configure txq/rxq, txd/rxd *** */
1074 struct cmd_config_rx_tx {
1075 cmdline_fixed_string_t port;
1076 cmdline_fixed_string_t keyword;
1077 cmdline_fixed_string_t all;
1078 cmdline_fixed_string_t name;
1083 cmd_config_rx_tx_parsed(void *parsed_result,
1084 __attribute__((unused)) struct cmdline *cl,
1085 __attribute__((unused)) void *data)
1087 struct cmd_config_rx_tx *res = parsed_result;
1089 if (!all_ports_stopped()) {
1090 printf("Please stop all ports first\n");
1094 if (!strcmp(res->name, "rxq")) {
1095 if (res->value <= 0) {
1096 printf("rxq %d invalid - must be > 0\n", res->value);
1099 nb_rxq = res->value;
1101 else if (!strcmp(res->name, "txq")) {
1102 if (res->value <= 0) {
1103 printf("txq %d invalid - must be > 0\n", res->value);
1106 nb_txq = res->value;
1108 else if (!strcmp(res->name, "rxd")) {
1109 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1110 printf("rxd %d invalid - must be > 0 && <= %d\n",
1111 res->value, RTE_TEST_RX_DESC_MAX);
1114 nb_rxd = res->value;
1115 } else if (!strcmp(res->name, "txd")) {
1116 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1117 printf("txd %d invalid - must be > 0 && <= %d\n",
1118 res->value, RTE_TEST_TX_DESC_MAX);
1121 nb_txd = res->value;
1123 printf("Unknown parameter\n");
1129 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1132 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1133 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1134 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1135 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1136 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1138 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1139 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1141 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1142 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1144 cmdline_parse_inst_t cmd_config_rx_tx = {
1145 .f = cmd_config_rx_tx_parsed,
1147 .help_str = "port config all rxq|txq|rxd|txd value",
1149 (void *)&cmd_config_rx_tx_port,
1150 (void *)&cmd_config_rx_tx_keyword,
1151 (void *)&cmd_config_rx_tx_all,
1152 (void *)&cmd_config_rx_tx_name,
1153 (void *)&cmd_config_rx_tx_value,
1158 /* *** config max packet length *** */
1159 struct cmd_config_max_pkt_len_result {
1160 cmdline_fixed_string_t port;
1161 cmdline_fixed_string_t keyword;
1162 cmdline_fixed_string_t all;
1163 cmdline_fixed_string_t name;
1168 cmd_config_max_pkt_len_parsed(void *parsed_result,
1169 __attribute__((unused)) struct cmdline *cl,
1170 __attribute__((unused)) void *data)
1172 struct cmd_config_max_pkt_len_result *res = parsed_result;
1174 if (!all_ports_stopped()) {
1175 printf("Please stop all ports first\n");
1179 if (!strcmp(res->name, "max-pkt-len")) {
1180 if (res->value < ETHER_MIN_LEN) {
1181 printf("max-pkt-len can not be less than %d\n",
1185 if (res->value == rx_mode.max_rx_pkt_len)
1188 rx_mode.max_rx_pkt_len = res->value;
1189 if (res->value > ETHER_MAX_LEN)
1190 rx_mode.jumbo_frame = 1;
1192 rx_mode.jumbo_frame = 0;
1194 printf("Unknown parameter\n");
1200 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1203 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1204 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1206 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1207 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1209 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1210 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1212 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1213 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1215 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1216 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1219 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1220 .f = cmd_config_max_pkt_len_parsed,
1222 .help_str = "port config all max-pkt-len value",
1224 (void *)&cmd_config_max_pkt_len_port,
1225 (void *)&cmd_config_max_pkt_len_keyword,
1226 (void *)&cmd_config_max_pkt_len_all,
1227 (void *)&cmd_config_max_pkt_len_name,
1228 (void *)&cmd_config_max_pkt_len_value,
1233 /* *** configure port MTU *** */
1234 struct cmd_config_mtu_result {
1235 cmdline_fixed_string_t port;
1236 cmdline_fixed_string_t keyword;
1237 cmdline_fixed_string_t mtu;
1243 cmd_config_mtu_parsed(void *parsed_result,
1244 __attribute__((unused)) struct cmdline *cl,
1245 __attribute__((unused)) void *data)
1247 struct cmd_config_mtu_result *res = parsed_result;
1249 if (res->value < ETHER_MIN_LEN) {
1250 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1253 port_mtu_set(res->port_id, res->value);
1256 cmdline_parse_token_string_t cmd_config_mtu_port =
1257 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1259 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1260 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1262 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1263 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1265 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1266 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1267 cmdline_parse_token_num_t cmd_config_mtu_value =
1268 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1270 cmdline_parse_inst_t cmd_config_mtu = {
1271 .f = cmd_config_mtu_parsed,
1273 .help_str = "port config mtu value",
1275 (void *)&cmd_config_mtu_port,
1276 (void *)&cmd_config_mtu_keyword,
1277 (void *)&cmd_config_mtu_mtu,
1278 (void *)&cmd_config_mtu_port_id,
1279 (void *)&cmd_config_mtu_value,
1284 /* *** configure rx mode *** */
1285 struct cmd_config_rx_mode_flag {
1286 cmdline_fixed_string_t port;
1287 cmdline_fixed_string_t keyword;
1288 cmdline_fixed_string_t all;
1289 cmdline_fixed_string_t name;
1290 cmdline_fixed_string_t value;
1294 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1295 __attribute__((unused)) struct cmdline *cl,
1296 __attribute__((unused)) void *data)
1298 struct cmd_config_rx_mode_flag *res = parsed_result;
1300 if (!all_ports_stopped()) {
1301 printf("Please stop all ports first\n");
1305 if (!strcmp(res->name, "crc-strip")) {
1306 if (!strcmp(res->value, "on"))
1307 rx_mode.hw_strip_crc = 1;
1308 else if (!strcmp(res->value, "off"))
1309 rx_mode.hw_strip_crc = 0;
1311 printf("Unknown parameter\n");
1314 } else if (!strcmp(res->name, "rx-cksum")) {
1315 if (!strcmp(res->value, "on"))
1316 rx_mode.hw_ip_checksum = 1;
1317 else if (!strcmp(res->value, "off"))
1318 rx_mode.hw_ip_checksum = 0;
1320 printf("Unknown parameter\n");
1323 } else if (!strcmp(res->name, "hw-vlan")) {
1324 if (!strcmp(res->value, "on")) {
1325 rx_mode.hw_vlan_filter = 1;
1326 rx_mode.hw_vlan_strip = 1;
1328 else if (!strcmp(res->value, "off")) {
1329 rx_mode.hw_vlan_filter = 0;
1330 rx_mode.hw_vlan_strip = 0;
1333 printf("Unknown parameter\n");
1336 } else if (!strcmp(res->name, "drop-en")) {
1337 if (!strcmp(res->value, "on"))
1339 else if (!strcmp(res->value, "off"))
1342 printf("Unknown parameter\n");
1346 printf("Unknown parameter\n");
1352 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1355 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1356 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1357 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1358 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1360 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1361 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1362 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1363 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1364 "crc-strip#rx-cksum#hw-vlan");
1365 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1366 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1369 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1370 .f = cmd_config_rx_mode_flag_parsed,
1372 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1374 (void *)&cmd_config_rx_mode_flag_port,
1375 (void *)&cmd_config_rx_mode_flag_keyword,
1376 (void *)&cmd_config_rx_mode_flag_all,
1377 (void *)&cmd_config_rx_mode_flag_name,
1378 (void *)&cmd_config_rx_mode_flag_value,
1383 /* *** configure rss *** */
1384 struct cmd_config_rss {
1385 cmdline_fixed_string_t port;
1386 cmdline_fixed_string_t keyword;
1387 cmdline_fixed_string_t all;
1388 cmdline_fixed_string_t name;
1389 cmdline_fixed_string_t value;
1393 cmd_config_rss_parsed(void *parsed_result,
1394 __attribute__((unused)) struct cmdline *cl,
1395 __attribute__((unused)) void *data)
1397 struct cmd_config_rss *res = parsed_result;
1398 struct rte_eth_rss_conf rss_conf;
1401 if (!strcmp(res->value, "ip"))
1402 rss_conf.rss_hf = ETH_RSS_IP;
1403 else if (!strcmp(res->value, "udp"))
1404 rss_conf.rss_hf = ETH_RSS_UDP;
1405 else if (!strcmp(res->value, "none"))
1406 rss_conf.rss_hf = 0;
1408 printf("Unknown parameter\n");
1411 rss_conf.rss_key = NULL;
1412 for (i = 0; i < rte_eth_dev_count(); i++)
1413 rte_eth_dev_rss_hash_update(i, &rss_conf);
1416 cmdline_parse_token_string_t cmd_config_rss_port =
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1418 cmdline_parse_token_string_t cmd_config_rss_keyword =
1419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1420 cmdline_parse_token_string_t cmd_config_rss_all =
1421 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1422 cmdline_parse_token_string_t cmd_config_rss_name =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1424 cmdline_parse_token_string_t cmd_config_rss_value =
1425 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1427 cmdline_parse_inst_t cmd_config_rss = {
1428 .f = cmd_config_rss_parsed,
1430 .help_str = "port config all rss ip|udp|none",
1432 (void *)&cmd_config_rss_port,
1433 (void *)&cmd_config_rss_keyword,
1434 (void *)&cmd_config_rss_all,
1435 (void *)&cmd_config_rss_name,
1436 (void *)&cmd_config_rss_value,
1441 /* *** configure rss hash key *** */
1442 struct cmd_config_rss_hash_key {
1443 cmdline_fixed_string_t port;
1444 cmdline_fixed_string_t config;
1446 cmdline_fixed_string_t rss_hash_key;
1447 cmdline_fixed_string_t key;
1450 #define RSS_HASH_KEY_LENGTH 40
1452 hexa_digit_to_value(char hexa_digit)
1454 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1455 return (uint8_t) (hexa_digit - '0');
1456 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1457 return (uint8_t) ((hexa_digit - 'a') + 10);
1458 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1459 return (uint8_t) ((hexa_digit - 'A') + 10);
1460 /* Invalid hexa digit */
1465 parse_and_check_key_hexa_digit(char *key, int idx)
1469 hexa_v = hexa_digit_to_value(key[idx]);
1471 printf("invalid key: character %c at position %d is not a "
1472 "valid hexa digit\n", key[idx], idx);
1477 cmd_config_rss_hash_key_parsed(void *parsed_result,
1478 __attribute__((unused)) struct cmdline *cl,
1479 __attribute__((unused)) void *data)
1481 struct cmd_config_rss_hash_key *res = parsed_result;
1482 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1487 /* Check the length of the RSS hash key */
1488 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1489 printf("key length: %d invalid - key must be a string of %d"
1490 "hexa-decimal numbers\n", (int) strlen(res->key),
1491 RSS_HASH_KEY_LENGTH * 2);
1494 /* Translate RSS hash key into binary representation */
1495 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1496 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1499 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1502 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1504 port_rss_hash_key_update(res->port_id, hash_key);
1507 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1508 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1509 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1510 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1512 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1513 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1514 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1515 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1516 rss_hash_key, "rss-hash-key");
1517 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1518 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1520 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1521 .f = cmd_config_rss_hash_key_parsed,
1523 .help_str = "port config X rss-hash-key 80 hexa digits",
1525 (void *)&cmd_config_rss_hash_key_port,
1526 (void *)&cmd_config_rss_hash_key_config,
1527 (void *)&cmd_config_rss_hash_key_port_id,
1528 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1529 (void *)&cmd_config_rss_hash_key_value,
1534 /* *** configure port rxq/txq start/stop *** */
1535 struct cmd_config_rxtx_queue {
1536 cmdline_fixed_string_t port;
1538 cmdline_fixed_string_t rxtxq;
1540 cmdline_fixed_string_t opname;
1544 cmd_config_rxtx_queue_parsed(void *parsed_result,
1545 __attribute__((unused)) struct cmdline *cl,
1546 __attribute__((unused)) void *data)
1548 struct cmd_config_rxtx_queue *res = parsed_result;
1553 if (test_done == 0) {
1554 printf("Please stop forwarding first\n");
1558 if (port_id_is_invalid(res->portid))
1561 if (port_is_started(res->portid) != 1) {
1562 printf("Please start port %u first\n", res->portid);
1566 if (!strcmp(res->rxtxq, "rxq"))
1568 else if (!strcmp(res->rxtxq, "txq"))
1571 printf("Unknown parameter\n");
1575 if (isrx && rx_queue_id_is_invalid(res->qid))
1577 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1580 if (!strcmp(res->opname, "start"))
1582 else if (!strcmp(res->opname, "stop"))
1585 printf("Unknown parameter\n");
1589 if (isstart && isrx)
1590 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1591 else if (!isstart && isrx)
1592 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1593 else if (isstart && !isrx)
1594 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1596 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1598 if (ret == -ENOTSUP)
1599 printf("Function not supported in PMD driver\n");
1602 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1603 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1604 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1605 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1606 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1607 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1608 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1609 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1610 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1611 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1614 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1615 .f = cmd_config_rxtx_queue_parsed,
1617 .help_str = "port X rxq|txq ID start|stop",
1619 (void *)&cmd_config_speed_all_port,
1620 (void *)&cmd_config_rxtx_queue_portid,
1621 (void *)&cmd_config_rxtx_queue_rxtxq,
1622 (void *)&cmd_config_rxtx_queue_qid,
1623 (void *)&cmd_config_rxtx_queue_opname,
1628 /* *** Configure RSS RETA *** */
1629 struct cmd_config_rss_reta {
1630 cmdline_fixed_string_t port;
1631 cmdline_fixed_string_t keyword;
1633 cmdline_fixed_string_t name;
1634 cmdline_fixed_string_t list_name;
1635 cmdline_fixed_string_t list_of_items;
1639 parse_reta_config(const char *str,
1640 struct rte_eth_rss_reta_entry64 *reta_conf,
1641 uint16_t nb_entries)
1645 uint16_t hash_index, idx, shift;
1648 const char *p, *p0 = str;
1655 unsigned long int_fld[_NUM_FLD];
1656 char *str_fld[_NUM_FLD];
1658 while ((p = strchr(p0,'(')) != NULL) {
1660 if((p0 = strchr(p,')')) == NULL)
1664 if(size >= sizeof(s))
1667 snprintf(s, sizeof(s), "%.*s", size, p);
1668 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1670 for (i = 0; i < _NUM_FLD; i++) {
1672 int_fld[i] = strtoul(str_fld[i], &end, 0);
1673 if (errno != 0 || end == str_fld[i] ||
1678 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1679 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1681 if (hash_index >= nb_entries) {
1682 printf("Invalid RETA hash index=%d\n", hash_index);
1686 idx = hash_index / RTE_RETA_GROUP_SIZE;
1687 shift = hash_index % RTE_RETA_GROUP_SIZE;
1688 reta_conf[idx].mask |= (1ULL << shift);
1689 reta_conf[idx].reta[shift] = nb_queue;
1696 cmd_set_rss_reta_parsed(void *parsed_result,
1697 __attribute__((unused)) struct cmdline *cl,
1698 __attribute__((unused)) void *data)
1701 struct rte_eth_dev_info dev_info;
1702 struct rte_eth_rss_reta_entry64 reta_conf[8];
1703 struct cmd_config_rss_reta *res = parsed_result;
1705 memset(&dev_info, 0, sizeof(dev_info));
1706 rte_eth_dev_info_get(res->port_id, &dev_info);
1707 if (dev_info.reta_size == 0) {
1708 printf("Redirection table size is 0 which is "
1709 "invalid for RSS\n");
1712 printf("The reta size of port %d is %u\n",
1713 res->port_id, dev_info.reta_size);
1714 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1715 printf("Currently do not support more than %u entries of "
1716 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1720 memset(reta_conf, 0, sizeof(reta_conf));
1721 if (!strcmp(res->list_name, "reta")) {
1722 if (parse_reta_config(res->list_of_items, reta_conf,
1723 dev_info.reta_size)) {
1724 printf("Invalid RSS Redirection Table "
1725 "config entered\n");
1728 ret = rte_eth_dev_rss_reta_update(res->port_id,
1729 reta_conf, dev_info.reta_size);
1731 printf("Bad redirection table parameter, "
1732 "return code = %d \n", ret);
1736 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1738 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1739 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1740 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1741 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1742 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1743 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1744 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1745 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1746 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1747 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1749 cmdline_parse_inst_t cmd_config_rss_reta = {
1750 .f = cmd_set_rss_reta_parsed,
1752 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1754 (void *)&cmd_config_rss_reta_port,
1755 (void *)&cmd_config_rss_reta_keyword,
1756 (void *)&cmd_config_rss_reta_port_id,
1757 (void *)&cmd_config_rss_reta_name,
1758 (void *)&cmd_config_rss_reta_list_name,
1759 (void *)&cmd_config_rss_reta_list_of_items,
1764 /* *** SHOW PORT RETA INFO *** */
1765 struct cmd_showport_reta {
1766 cmdline_fixed_string_t show;
1767 cmdline_fixed_string_t port;
1769 cmdline_fixed_string_t rss;
1770 cmdline_fixed_string_t reta;
1772 cmdline_fixed_string_t list_of_items;
1776 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1777 uint16_t nb_entries,
1781 const char *p, *p0 = str;
1785 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1788 p = strchr(p0, '(');
1792 p0 = strchr(p, ')');
1796 if (size >= sizeof(s)) {
1797 printf("The string size exceeds the internal buffer size\n");
1800 snprintf(s, sizeof(s), "%.*s", size, p);
1801 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1802 if (ret <= 0 || ret != num) {
1803 printf("The bits of masks do not match the number of "
1804 "reta entries: %u\n", num);
1807 for (i = 0; i < ret; i++)
1808 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1814 cmd_showport_reta_parsed(void *parsed_result,
1815 __attribute__((unused)) struct cmdline *cl,
1816 __attribute__((unused)) void *data)
1818 struct cmd_showport_reta *res = parsed_result;
1819 struct rte_eth_rss_reta_entry64 reta_conf[8];
1820 struct rte_eth_dev_info dev_info;
1822 memset(&dev_info, 0, sizeof(dev_info));
1823 rte_eth_dev_info_get(res->port_id, &dev_info);
1824 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1825 res->size > ETH_RSS_RETA_SIZE_512) {
1826 printf("Invalid redirection table size: %u\n", res->size);
1830 memset(reta_conf, 0, sizeof(reta_conf));
1831 if (showport_parse_reta_config(reta_conf, res->size,
1832 res->list_of_items) < 0) {
1833 printf("Invalid string: %s for reta masks\n",
1834 res->list_of_items);
1837 port_rss_reta_info(res->port_id, reta_conf, res->size);
1840 cmdline_parse_token_string_t cmd_showport_reta_show =
1841 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1842 cmdline_parse_token_string_t cmd_showport_reta_port =
1843 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1844 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1845 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1846 cmdline_parse_token_string_t cmd_showport_reta_rss =
1847 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1848 cmdline_parse_token_string_t cmd_showport_reta_reta =
1849 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1850 cmdline_parse_token_num_t cmd_showport_reta_size =
1851 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1852 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1853 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1854 list_of_items, NULL);
1856 cmdline_parse_inst_t cmd_showport_reta = {
1857 .f = cmd_showport_reta_parsed,
1859 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1861 (void *)&cmd_showport_reta_show,
1862 (void *)&cmd_showport_reta_port,
1863 (void *)&cmd_showport_reta_port_id,
1864 (void *)&cmd_showport_reta_rss,
1865 (void *)&cmd_showport_reta_reta,
1866 (void *)&cmd_showport_reta_size,
1867 (void *)&cmd_showport_reta_list_of_items,
1872 /* *** Show RSS hash configuration *** */
1873 struct cmd_showport_rss_hash {
1874 cmdline_fixed_string_t show;
1875 cmdline_fixed_string_t port;
1877 cmdline_fixed_string_t rss_hash;
1878 cmdline_fixed_string_t key; /* optional argument */
1881 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1882 __attribute__((unused)) struct cmdline *cl,
1885 struct cmd_showport_rss_hash *res = parsed_result;
1887 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1890 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1891 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1892 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1893 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1894 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1895 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1896 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1897 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1899 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1900 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1902 cmdline_parse_inst_t cmd_showport_rss_hash = {
1903 .f = cmd_showport_rss_hash_parsed,
1905 .help_str = "show port X rss-hash (X = port number)\n",
1907 (void *)&cmd_showport_rss_hash_show,
1908 (void *)&cmd_showport_rss_hash_port,
1909 (void *)&cmd_showport_rss_hash_port_id,
1910 (void *)&cmd_showport_rss_hash_rss_hash,
1915 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1916 .f = cmd_showport_rss_hash_parsed,
1918 .help_str = "show port X rss-hash key (X = port number)\n",
1920 (void *)&cmd_showport_rss_hash_show,
1921 (void *)&cmd_showport_rss_hash_port,
1922 (void *)&cmd_showport_rss_hash_port_id,
1923 (void *)&cmd_showport_rss_hash_rss_hash,
1924 (void *)&cmd_showport_rss_hash_rss_key,
1929 /* *** Configure DCB *** */
1930 struct cmd_config_dcb {
1931 cmdline_fixed_string_t port;
1932 cmdline_fixed_string_t config;
1934 cmdline_fixed_string_t dcb;
1935 cmdline_fixed_string_t vt;
1936 cmdline_fixed_string_t vt_en;
1938 cmdline_fixed_string_t pfc;
1939 cmdline_fixed_string_t pfc_en;
1943 cmd_config_dcb_parsed(void *parsed_result,
1944 __attribute__((unused)) struct cmdline *cl,
1945 __attribute__((unused)) void *data)
1947 struct cmd_config_dcb *res = parsed_result;
1948 struct dcb_config dcb_conf;
1949 portid_t port_id = res->port_id;
1950 struct rte_port *port;
1952 port = &ports[port_id];
1953 /** Check if the port is not started **/
1954 if (port->port_status != RTE_PORT_STOPPED) {
1955 printf("Please stop port %d first\n",port_id);
1959 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1960 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1961 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1965 /* DCB in VT mode */
1966 if (!strncmp(res->vt_en, "on",2))
1967 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1969 dcb_conf.dcb_mode = DCB_ENABLED;
1971 if (!strncmp(res->pfc_en, "on",2)) {
1972 dcb_conf.pfc_en = 1;
1975 dcb_conf.pfc_en = 0;
1977 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1978 printf("Cannot initialize network ports\n");
1982 cmd_reconfig_device_queue(port_id, 1, 1);
1985 cmdline_parse_token_string_t cmd_config_dcb_port =
1986 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1987 cmdline_parse_token_string_t cmd_config_dcb_config =
1988 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1989 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1990 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1991 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1992 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1993 cmdline_parse_token_string_t cmd_config_dcb_vt =
1994 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1995 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1996 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1997 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1998 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1999 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2001 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2004 cmdline_parse_inst_t cmd_config_dcb = {
2005 .f = cmd_config_dcb_parsed,
2007 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2009 (void *)&cmd_config_dcb_port,
2010 (void *)&cmd_config_dcb_config,
2011 (void *)&cmd_config_dcb_port_id,
2012 (void *)&cmd_config_dcb_dcb,
2013 (void *)&cmd_config_dcb_vt,
2014 (void *)&cmd_config_dcb_vt_en,
2015 (void *)&cmd_config_dcb_num_tcs,
2016 (void *)&cmd_config_dcb_pfc,
2017 (void *)&cmd_config_dcb_pfc_en,
2022 /* *** configure number of packets per burst *** */
2023 struct cmd_config_burst {
2024 cmdline_fixed_string_t port;
2025 cmdline_fixed_string_t keyword;
2026 cmdline_fixed_string_t all;
2027 cmdline_fixed_string_t name;
2032 cmd_config_burst_parsed(void *parsed_result,
2033 __attribute__((unused)) struct cmdline *cl,
2034 __attribute__((unused)) void *data)
2036 struct cmd_config_burst *res = parsed_result;
2038 if (!all_ports_stopped()) {
2039 printf("Please stop all ports first\n");
2043 if (!strcmp(res->name, "burst")) {
2044 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2045 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2048 nb_pkt_per_burst = res->value;
2050 printf("Unknown parameter\n");
2056 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2059 cmdline_parse_token_string_t cmd_config_burst_port =
2060 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2061 cmdline_parse_token_string_t cmd_config_burst_keyword =
2062 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2063 cmdline_parse_token_string_t cmd_config_burst_all =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2065 cmdline_parse_token_string_t cmd_config_burst_name =
2066 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2067 cmdline_parse_token_num_t cmd_config_burst_value =
2068 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2070 cmdline_parse_inst_t cmd_config_burst = {
2071 .f = cmd_config_burst_parsed,
2073 .help_str = "port config all burst value",
2075 (void *)&cmd_config_burst_port,
2076 (void *)&cmd_config_burst_keyword,
2077 (void *)&cmd_config_burst_all,
2078 (void *)&cmd_config_burst_name,
2079 (void *)&cmd_config_burst_value,
2084 /* *** configure rx/tx queues *** */
2085 struct cmd_config_thresh {
2086 cmdline_fixed_string_t port;
2087 cmdline_fixed_string_t keyword;
2088 cmdline_fixed_string_t all;
2089 cmdline_fixed_string_t name;
2094 cmd_config_thresh_parsed(void *parsed_result,
2095 __attribute__((unused)) struct cmdline *cl,
2096 __attribute__((unused)) void *data)
2098 struct cmd_config_thresh *res = parsed_result;
2100 if (!all_ports_stopped()) {
2101 printf("Please stop all ports first\n");
2105 if (!strcmp(res->name, "txpt"))
2106 tx_pthresh = res->value;
2107 else if(!strcmp(res->name, "txht"))
2108 tx_hthresh = res->value;
2109 else if(!strcmp(res->name, "txwt"))
2110 tx_wthresh = res->value;
2111 else if(!strcmp(res->name, "rxpt"))
2112 rx_pthresh = res->value;
2113 else if(!strcmp(res->name, "rxht"))
2114 rx_hthresh = res->value;
2115 else if(!strcmp(res->name, "rxwt"))
2116 rx_wthresh = res->value;
2118 printf("Unknown parameter\n");
2124 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2127 cmdline_parse_token_string_t cmd_config_thresh_port =
2128 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2129 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2130 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2131 cmdline_parse_token_string_t cmd_config_thresh_all =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2133 cmdline_parse_token_string_t cmd_config_thresh_name =
2134 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2135 "txpt#txht#txwt#rxpt#rxht#rxwt");
2136 cmdline_parse_token_num_t cmd_config_thresh_value =
2137 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2139 cmdline_parse_inst_t cmd_config_thresh = {
2140 .f = cmd_config_thresh_parsed,
2142 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2144 (void *)&cmd_config_thresh_port,
2145 (void *)&cmd_config_thresh_keyword,
2146 (void *)&cmd_config_thresh_all,
2147 (void *)&cmd_config_thresh_name,
2148 (void *)&cmd_config_thresh_value,
2153 /* *** configure free/rs threshold *** */
2154 struct cmd_config_threshold {
2155 cmdline_fixed_string_t port;
2156 cmdline_fixed_string_t keyword;
2157 cmdline_fixed_string_t all;
2158 cmdline_fixed_string_t name;
2163 cmd_config_threshold_parsed(void *parsed_result,
2164 __attribute__((unused)) struct cmdline *cl,
2165 __attribute__((unused)) void *data)
2167 struct cmd_config_threshold *res = parsed_result;
2169 if (!all_ports_stopped()) {
2170 printf("Please stop all ports first\n");
2174 if (!strcmp(res->name, "txfreet"))
2175 tx_free_thresh = res->value;
2176 else if (!strcmp(res->name, "txrst"))
2177 tx_rs_thresh = res->value;
2178 else if (!strcmp(res->name, "rxfreet"))
2179 rx_free_thresh = res->value;
2181 printf("Unknown parameter\n");
2187 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2190 cmdline_parse_token_string_t cmd_config_threshold_port =
2191 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2192 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2193 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2195 cmdline_parse_token_string_t cmd_config_threshold_all =
2196 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2197 cmdline_parse_token_string_t cmd_config_threshold_name =
2198 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2199 "txfreet#txrst#rxfreet");
2200 cmdline_parse_token_num_t cmd_config_threshold_value =
2201 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2203 cmdline_parse_inst_t cmd_config_threshold = {
2204 .f = cmd_config_threshold_parsed,
2206 .help_str = "port config all txfreet|txrst|rxfreet value",
2208 (void *)&cmd_config_threshold_port,
2209 (void *)&cmd_config_threshold_keyword,
2210 (void *)&cmd_config_threshold_all,
2211 (void *)&cmd_config_threshold_name,
2212 (void *)&cmd_config_threshold_value,
2218 struct cmd_stop_result {
2219 cmdline_fixed_string_t stop;
2222 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2223 __attribute__((unused)) struct cmdline *cl,
2224 __attribute__((unused)) void *data)
2226 stop_packet_forwarding();
2229 cmdline_parse_token_string_t cmd_stop_stop =
2230 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2232 cmdline_parse_inst_t cmd_stop = {
2233 .f = cmd_stop_parsed,
2235 .help_str = "stop - stop packet forwarding",
2237 (void *)&cmd_stop_stop,
2242 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2245 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2246 unsigned int *parsed_items, int check_unique_values)
2248 unsigned int nb_item;
2256 * First parse all items in the list and store their value.
2261 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2263 if ((c >= '0') && (c <= '9')) {
2264 value = (unsigned int) (value * 10 + (c - '0'));
2269 printf("character %c is not a decimal digit\n", c);
2273 printf("No valid value before comma\n");
2276 if (nb_item < max_items) {
2277 parsed_items[nb_item] = value;
2283 if (nb_item >= max_items) {
2284 printf("Number of %s = %u > %u (maximum items)\n",
2285 item_name, nb_item + 1, max_items);
2288 parsed_items[nb_item++] = value;
2289 if (! check_unique_values)
2293 * Then, check that all values in the list are differents.
2294 * No optimization here...
2296 for (i = 0; i < nb_item; i++) {
2297 for (j = i + 1; j < nb_item; j++) {
2298 if (parsed_items[j] == parsed_items[i]) {
2299 printf("duplicated %s %u at index %u and %u\n",
2300 item_name, parsed_items[i], i, j);
2308 struct cmd_set_list_result {
2309 cmdline_fixed_string_t cmd_keyword;
2310 cmdline_fixed_string_t list_name;
2311 cmdline_fixed_string_t list_of_items;
2314 static void cmd_set_list_parsed(void *parsed_result,
2315 __attribute__((unused)) struct cmdline *cl,
2316 __attribute__((unused)) void *data)
2318 struct cmd_set_list_result *res;
2320 unsigned int lcorelist[RTE_MAX_LCORE];
2321 unsigned int portlist[RTE_MAX_ETHPORTS];
2323 unsigned int nb_item;
2325 if (test_done == 0) {
2326 printf("Please stop forwarding first\n");
2330 res = parsed_result;
2331 if (!strcmp(res->list_name, "corelist")) {
2332 nb_item = parse_item_list(res->list_of_items, "core",
2334 parsed_items.lcorelist, 1);
2336 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2339 if (!strcmp(res->list_name, "portlist")) {
2340 nb_item = parse_item_list(res->list_of_items, "port",
2342 parsed_items.portlist, 1);
2344 set_fwd_ports_list(parsed_items.portlist, nb_item);
2348 cmdline_parse_token_string_t cmd_set_list_keyword =
2349 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2351 cmdline_parse_token_string_t cmd_set_list_name =
2352 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2353 "corelist#portlist");
2354 cmdline_parse_token_string_t cmd_set_list_of_items =
2355 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2358 cmdline_parse_inst_t cmd_set_fwd_list = {
2359 .f = cmd_set_list_parsed,
2361 .help_str = "set corelist|portlist x[,y]*",
2363 (void *)&cmd_set_list_keyword,
2364 (void *)&cmd_set_list_name,
2365 (void *)&cmd_set_list_of_items,
2370 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2372 struct cmd_setmask_result {
2373 cmdline_fixed_string_t set;
2374 cmdline_fixed_string_t mask;
2378 static void cmd_set_mask_parsed(void *parsed_result,
2379 __attribute__((unused)) struct cmdline *cl,
2380 __attribute__((unused)) void *data)
2382 struct cmd_setmask_result *res = parsed_result;
2384 if (test_done == 0) {
2385 printf("Please stop forwarding first\n");
2388 if (!strcmp(res->mask, "coremask"))
2389 set_fwd_lcores_mask(res->hexavalue);
2390 else if (!strcmp(res->mask, "portmask"))
2391 set_fwd_ports_mask(res->hexavalue);
2394 cmdline_parse_token_string_t cmd_setmask_set =
2395 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2396 cmdline_parse_token_string_t cmd_setmask_mask =
2397 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2398 "coremask#portmask");
2399 cmdline_parse_token_num_t cmd_setmask_value =
2400 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2402 cmdline_parse_inst_t cmd_set_fwd_mask = {
2403 .f = cmd_set_mask_parsed,
2405 .help_str = "set coremask|portmask hexadecimal value",
2407 (void *)&cmd_setmask_set,
2408 (void *)&cmd_setmask_mask,
2409 (void *)&cmd_setmask_value,
2415 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2417 struct cmd_set_result {
2418 cmdline_fixed_string_t set;
2419 cmdline_fixed_string_t what;
2423 static void cmd_set_parsed(void *parsed_result,
2424 __attribute__((unused)) struct cmdline *cl,
2425 __attribute__((unused)) void *data)
2427 struct cmd_set_result *res = parsed_result;
2428 if (!strcmp(res->what, "nbport"))
2429 set_fwd_ports_number(res->value);
2430 else if (!strcmp(res->what, "nbcore"))
2431 set_fwd_lcores_number(res->value);
2432 else if (!strcmp(res->what, "burst"))
2433 set_nb_pkt_per_burst(res->value);
2434 else if (!strcmp(res->what, "verbose"))
2435 set_verbose_level(res->value);
2438 cmdline_parse_token_string_t cmd_set_set =
2439 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2440 cmdline_parse_token_string_t cmd_set_what =
2441 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2442 "nbport#nbcore#burst#verbose");
2443 cmdline_parse_token_num_t cmd_set_value =
2444 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2446 cmdline_parse_inst_t cmd_set_numbers = {
2447 .f = cmd_set_parsed,
2449 .help_str = "set nbport|nbcore|burst|verbose value",
2451 (void *)&cmd_set_set,
2452 (void *)&cmd_set_what,
2453 (void *)&cmd_set_value,
2458 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2460 struct cmd_set_txpkts_result {
2461 cmdline_fixed_string_t cmd_keyword;
2462 cmdline_fixed_string_t txpkts;
2463 cmdline_fixed_string_t seg_lengths;
2467 cmd_set_txpkts_parsed(void *parsed_result,
2468 __attribute__((unused)) struct cmdline *cl,
2469 __attribute__((unused)) void *data)
2471 struct cmd_set_txpkts_result *res;
2472 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2473 unsigned int nb_segs;
2475 res = parsed_result;
2476 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2477 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2479 set_tx_pkt_segments(seg_lengths, nb_segs);
2482 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2483 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2484 cmd_keyword, "set");
2485 cmdline_parse_token_string_t cmd_set_txpkts_name =
2486 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2488 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2489 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2492 cmdline_parse_inst_t cmd_set_txpkts = {
2493 .f = cmd_set_txpkts_parsed,
2495 .help_str = "set txpkts x[,y]*",
2497 (void *)&cmd_set_txpkts_keyword,
2498 (void *)&cmd_set_txpkts_name,
2499 (void *)&cmd_set_txpkts_lengths,
2504 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2505 struct cmd_rx_vlan_filter_all_result {
2506 cmdline_fixed_string_t rx_vlan;
2507 cmdline_fixed_string_t what;
2508 cmdline_fixed_string_t all;
2513 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2514 __attribute__((unused)) struct cmdline *cl,
2515 __attribute__((unused)) void *data)
2517 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2519 if (!strcmp(res->what, "add"))
2520 rx_vlan_all_filter_set(res->port_id, 1);
2522 rx_vlan_all_filter_set(res->port_id, 0);
2525 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2526 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2527 rx_vlan, "rx_vlan");
2528 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2529 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2531 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2532 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2534 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2535 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2538 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2539 .f = cmd_rx_vlan_filter_all_parsed,
2541 .help_str = "add/remove all identifiers to/from the set of VLAN "
2542 "Identifiers filtered by a port",
2544 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2545 (void *)&cmd_rx_vlan_filter_all_what,
2546 (void *)&cmd_rx_vlan_filter_all_all,
2547 (void *)&cmd_rx_vlan_filter_all_portid,
2552 /* *** VLAN OFFLOAD SET ON A PORT *** */
2553 struct cmd_vlan_offload_result {
2554 cmdline_fixed_string_t vlan;
2555 cmdline_fixed_string_t set;
2556 cmdline_fixed_string_t what;
2557 cmdline_fixed_string_t on;
2558 cmdline_fixed_string_t port_id;
2562 cmd_vlan_offload_parsed(void *parsed_result,
2563 __attribute__((unused)) struct cmdline *cl,
2564 __attribute__((unused)) void *data)
2567 struct cmd_vlan_offload_result *res = parsed_result;
2570 portid_t port_id = 0;
2574 len = strnlen(str, STR_TOKEN_SIZE);
2576 /* Get port_id first */
2584 tmp = strtoul(str, NULL, 0);
2585 /* If port_id greater that what portid_t can represent, return */
2586 if(tmp >= RTE_MAX_ETHPORTS)
2588 port_id = (portid_t)tmp;
2590 if (!strcmp(res->on, "on"))
2595 if (!strcmp(res->what, "strip"))
2596 rx_vlan_strip_set(port_id, on);
2597 else if(!strcmp(res->what, "stripq")){
2598 uint16_t queue_id = 0;
2600 /* No queue_id, return */
2602 printf("must specify (port,queue_id)\n");
2605 tmp = strtoul(str + i + 1, NULL, 0);
2606 /* If queue_id greater that what 16-bits can represent, return */
2610 queue_id = (uint16_t)tmp;
2611 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2613 else if (!strcmp(res->what, "filter"))
2614 rx_vlan_filter_set(port_id, on);
2616 vlan_extend_set(port_id, on);
2621 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2622 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2624 cmdline_parse_token_string_t cmd_vlan_offload_set =
2625 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2627 cmdline_parse_token_string_t cmd_vlan_offload_what =
2628 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2629 what, "strip#filter#qinq#stripq");
2630 cmdline_parse_token_string_t cmd_vlan_offload_on =
2631 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2633 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2634 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2637 cmdline_parse_inst_t cmd_vlan_offload = {
2638 .f = cmd_vlan_offload_parsed,
2640 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2641 " qinq(extended) for both rx/tx sides ",
2643 (void *)&cmd_vlan_offload_vlan,
2644 (void *)&cmd_vlan_offload_set,
2645 (void *)&cmd_vlan_offload_what,
2646 (void *)&cmd_vlan_offload_on,
2647 (void *)&cmd_vlan_offload_portid,
2652 /* *** VLAN TPID SET ON A PORT *** */
2653 struct cmd_vlan_tpid_result {
2654 cmdline_fixed_string_t vlan;
2655 cmdline_fixed_string_t set;
2656 cmdline_fixed_string_t what;
2662 cmd_vlan_tpid_parsed(void *parsed_result,
2663 __attribute__((unused)) struct cmdline *cl,
2664 __attribute__((unused)) void *data)
2666 struct cmd_vlan_tpid_result *res = parsed_result;
2667 vlan_tpid_set(res->port_id, res->tp_id);
2671 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2672 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2674 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2675 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2677 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2678 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2680 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2681 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2683 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2684 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2687 cmdline_parse_inst_t cmd_vlan_tpid = {
2688 .f = cmd_vlan_tpid_parsed,
2690 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2692 (void *)&cmd_vlan_tpid_vlan,
2693 (void *)&cmd_vlan_tpid_set,
2694 (void *)&cmd_vlan_tpid_what,
2695 (void *)&cmd_vlan_tpid_tpid,
2696 (void *)&cmd_vlan_tpid_portid,
2701 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2702 struct cmd_rx_vlan_filter_result {
2703 cmdline_fixed_string_t rx_vlan;
2704 cmdline_fixed_string_t what;
2710 cmd_rx_vlan_filter_parsed(void *parsed_result,
2711 __attribute__((unused)) struct cmdline *cl,
2712 __attribute__((unused)) void *data)
2714 struct cmd_rx_vlan_filter_result *res = parsed_result;
2716 if (!strcmp(res->what, "add"))
2717 rx_vft_set(res->port_id, res->vlan_id, 1);
2719 rx_vft_set(res->port_id, res->vlan_id, 0);
2722 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2723 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2724 rx_vlan, "rx_vlan");
2725 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2726 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2728 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2729 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2731 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2732 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2735 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2736 .f = cmd_rx_vlan_filter_parsed,
2738 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2739 "Identifiers filtered by a port",
2741 (void *)&cmd_rx_vlan_filter_rx_vlan,
2742 (void *)&cmd_rx_vlan_filter_what,
2743 (void *)&cmd_rx_vlan_filter_vlanid,
2744 (void *)&cmd_rx_vlan_filter_portid,
2749 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2750 struct cmd_tx_vlan_set_result {
2751 cmdline_fixed_string_t tx_vlan;
2752 cmdline_fixed_string_t set;
2758 cmd_tx_vlan_set_parsed(void *parsed_result,
2759 __attribute__((unused)) struct cmdline *cl,
2760 __attribute__((unused)) void *data)
2762 struct cmd_tx_vlan_set_result *res = parsed_result;
2763 tx_vlan_set(res->port_id, res->vlan_id);
2766 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2767 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2768 tx_vlan, "tx_vlan");
2769 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2770 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2772 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2773 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2775 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2776 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2779 cmdline_parse_inst_t cmd_tx_vlan_set = {
2780 .f = cmd_tx_vlan_set_parsed,
2782 .help_str = "enable hardware insertion of a VLAN header with a given "
2783 "TAG Identifier in packets sent on a port",
2785 (void *)&cmd_tx_vlan_set_tx_vlan,
2786 (void *)&cmd_tx_vlan_set_set,
2787 (void *)&cmd_tx_vlan_set_vlanid,
2788 (void *)&cmd_tx_vlan_set_portid,
2793 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2794 struct cmd_tx_vlan_set_pvid_result {
2795 cmdline_fixed_string_t tx_vlan;
2796 cmdline_fixed_string_t set;
2797 cmdline_fixed_string_t pvid;
2800 cmdline_fixed_string_t mode;
2804 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2805 __attribute__((unused)) struct cmdline *cl,
2806 __attribute__((unused)) void *data)
2808 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2810 if (strcmp(res->mode, "on") == 0)
2811 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2813 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2816 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2817 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2818 tx_vlan, "tx_vlan");
2819 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2820 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2822 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2823 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2825 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2826 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2828 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2829 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2831 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2832 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2835 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2836 .f = cmd_tx_vlan_set_pvid_parsed,
2838 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2840 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2841 (void *)&cmd_tx_vlan_set_pvid_set,
2842 (void *)&cmd_tx_vlan_set_pvid_pvid,
2843 (void *)&cmd_tx_vlan_set_pvid_port_id,
2844 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2845 (void *)&cmd_tx_vlan_set_pvid_mode,
2850 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2851 struct cmd_tx_vlan_reset_result {
2852 cmdline_fixed_string_t tx_vlan;
2853 cmdline_fixed_string_t reset;
2858 cmd_tx_vlan_reset_parsed(void *parsed_result,
2859 __attribute__((unused)) struct cmdline *cl,
2860 __attribute__((unused)) void *data)
2862 struct cmd_tx_vlan_reset_result *res = parsed_result;
2864 tx_vlan_reset(res->port_id);
2867 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2868 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2869 tx_vlan, "tx_vlan");
2870 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2871 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2873 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2874 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2877 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2878 .f = cmd_tx_vlan_reset_parsed,
2880 .help_str = "disable hardware insertion of a VLAN header in packets "
2883 (void *)&cmd_tx_vlan_reset_tx_vlan,
2884 (void *)&cmd_tx_vlan_reset_reset,
2885 (void *)&cmd_tx_vlan_reset_portid,
2891 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2892 struct cmd_csum_result {
2893 cmdline_fixed_string_t csum;
2894 cmdline_fixed_string_t mode;
2895 cmdline_fixed_string_t proto;
2896 cmdline_fixed_string_t hwsw;
2901 csum_show(int port_id)
2903 struct rte_eth_dev_info dev_info;
2906 ol_flags = ports[port_id].tx_ol_flags;
2907 printf("Parse tunnel is %s\n",
2908 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
2909 printf("IP checksum offload is %s\n",
2910 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2911 printf("UDP checksum offload is %s\n",
2912 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2913 printf("TCP checksum offload is %s\n",
2914 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2915 printf("SCTP checksum offload is %s\n",
2916 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2917 printf("Outer-Ip checksum offload is %s\n",
2918 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
2920 /* display warnings if configuration is not supported by the NIC */
2921 rte_eth_dev_info_get(port_id, &dev_info);
2922 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2923 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2924 printf("Warning: hardware IP checksum enabled but not "
2925 "supported by port %d\n", port_id);
2927 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2928 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2929 printf("Warning: hardware UDP checksum enabled but not "
2930 "supported by port %d\n", port_id);
2932 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2933 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2934 printf("Warning: hardware TCP checksum enabled but not "
2935 "supported by port %d\n", port_id);
2937 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2938 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2939 printf("Warning: hardware SCTP checksum enabled but not "
2940 "supported by port %d\n", port_id);
2946 cmd_csum_parsed(void *parsed_result,
2947 __attribute__((unused)) struct cmdline *cl,
2948 __attribute__((unused)) void *data)
2950 struct cmd_csum_result *res = parsed_result;
2954 if (port_id_is_invalid(res->port_id)) {
2955 printf("invalid port %d\n", res->port_id);
2959 if (!strcmp(res->mode, "set")) {
2961 if (!strcmp(res->hwsw, "hw"))
2964 if (!strcmp(res->proto, "ip")) {
2965 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2966 } else if (!strcmp(res->proto, "udp")) {
2967 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2968 } else if (!strcmp(res->proto, "tcp")) {
2969 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2970 } else if (!strcmp(res->proto, "sctp")) {
2971 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2972 } else if (!strcmp(res->proto, "outer-ip")) {
2973 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
2977 ports[res->port_id].tx_ol_flags |= mask;
2979 ports[res->port_id].tx_ol_flags &= (~mask);
2981 csum_show(res->port_id);
2984 cmdline_parse_token_string_t cmd_csum_csum =
2985 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2987 cmdline_parse_token_string_t cmd_csum_mode =
2988 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2990 cmdline_parse_token_string_t cmd_csum_proto =
2991 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2992 proto, "ip#tcp#udp#sctp#outer-ip");
2993 cmdline_parse_token_string_t cmd_csum_hwsw =
2994 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2996 cmdline_parse_token_num_t cmd_csum_portid =
2997 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3000 cmdline_parse_inst_t cmd_csum_set = {
3001 .f = cmd_csum_parsed,
3003 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3004 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3006 (void *)&cmd_csum_csum,
3007 (void *)&cmd_csum_mode,
3008 (void *)&cmd_csum_proto,
3009 (void *)&cmd_csum_hwsw,
3010 (void *)&cmd_csum_portid,
3015 cmdline_parse_token_string_t cmd_csum_mode_show =
3016 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3019 cmdline_parse_inst_t cmd_csum_show = {
3020 .f = cmd_csum_parsed,
3022 .help_str = "show checksum offload configuration: csum show <port>",
3024 (void *)&cmd_csum_csum,
3025 (void *)&cmd_csum_mode_show,
3026 (void *)&cmd_csum_portid,
3031 /* Enable/disable tunnel parsing */
3032 struct cmd_csum_tunnel_result {
3033 cmdline_fixed_string_t csum;
3034 cmdline_fixed_string_t parse;
3035 cmdline_fixed_string_t onoff;
3040 cmd_csum_tunnel_parsed(void *parsed_result,
3041 __attribute__((unused)) struct cmdline *cl,
3042 __attribute__((unused)) void *data)
3044 struct cmd_csum_tunnel_result *res = parsed_result;
3046 if (port_id_is_invalid(res->port_id)) {
3047 printf("invalid port %d\n", res->port_id);
3051 if (!strcmp(res->onoff, "on"))
3052 ports[res->port_id].tx_ol_flags |=
3053 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3055 ports[res->port_id].tx_ol_flags &=
3056 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3058 csum_show(res->port_id);
3061 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3062 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3064 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3065 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3066 parse, "parse_tunnel");
3067 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3068 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3070 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3071 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3074 cmdline_parse_inst_t cmd_csum_tunnel = {
3075 .f = cmd_csum_tunnel_parsed,
3077 .help_str = "enable/disable parsing of tunnels for csum engine: "
3078 "csum parse_tunnel on|off <tx-port>",
3080 (void *)&cmd_csum_tunnel_csum,
3081 (void *)&cmd_csum_tunnel_parse,
3082 (void *)&cmd_csum_tunnel_onoff,
3083 (void *)&cmd_csum_tunnel_portid,
3088 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3089 struct cmd_tso_set_result {
3090 cmdline_fixed_string_t tso;
3091 cmdline_fixed_string_t mode;
3097 cmd_tso_set_parsed(void *parsed_result,
3098 __attribute__((unused)) struct cmdline *cl,
3099 __attribute__((unused)) void *data)
3101 struct cmd_tso_set_result *res = parsed_result;
3102 struct rte_eth_dev_info dev_info;
3104 if (port_id_is_invalid(res->port_id))
3107 if (!strcmp(res->mode, "set"))
3108 ports[res->port_id].tso_segsz = res->tso_segsz;
3110 if (ports[res->port_id].tso_segsz == 0)
3111 printf("TSO is disabled\n");
3113 printf("TSO segment size is %d\n",
3114 ports[res->port_id].tso_segsz);
3116 /* display warnings if configuration is not supported by the NIC */
3117 rte_eth_dev_info_get(res->port_id, &dev_info);
3118 if ((ports[res->port_id].tso_segsz != 0) &&
3119 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3120 printf("Warning: TSO enabled but not "
3121 "supported by port %d\n", res->port_id);
3125 cmdline_parse_token_string_t cmd_tso_set_tso =
3126 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3128 cmdline_parse_token_string_t cmd_tso_set_mode =
3129 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3131 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3132 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3134 cmdline_parse_token_num_t cmd_tso_set_portid =
3135 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3138 cmdline_parse_inst_t cmd_tso_set = {
3139 .f = cmd_tso_set_parsed,
3141 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3142 "tso set <tso_segsz> <port>",
3144 (void *)&cmd_tso_set_tso,
3145 (void *)&cmd_tso_set_mode,
3146 (void *)&cmd_tso_set_tso_segsz,
3147 (void *)&cmd_tso_set_portid,
3152 cmdline_parse_token_string_t cmd_tso_show_mode =
3153 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3157 cmdline_parse_inst_t cmd_tso_show = {
3158 .f = cmd_tso_set_parsed,
3160 .help_str = "Show TSO segment size for csum engine: "
3163 (void *)&cmd_tso_set_tso,
3164 (void *)&cmd_tso_show_mode,
3165 (void *)&cmd_tso_set_portid,
3170 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3171 struct cmd_set_flush_rx {
3172 cmdline_fixed_string_t set;
3173 cmdline_fixed_string_t flush_rx;
3174 cmdline_fixed_string_t mode;
3178 cmd_set_flush_rx_parsed(void *parsed_result,
3179 __attribute__((unused)) struct cmdline *cl,
3180 __attribute__((unused)) void *data)
3182 struct cmd_set_flush_rx *res = parsed_result;
3183 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3186 cmdline_parse_token_string_t cmd_setflushrx_set =
3187 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3189 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3190 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3191 flush_rx, "flush_rx");
3192 cmdline_parse_token_string_t cmd_setflushrx_mode =
3193 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3197 cmdline_parse_inst_t cmd_set_flush_rx = {
3198 .f = cmd_set_flush_rx_parsed,
3199 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3202 (void *)&cmd_setflushrx_set,
3203 (void *)&cmd_setflushrx_flush_rx,
3204 (void *)&cmd_setflushrx_mode,
3209 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3210 struct cmd_set_link_check {
3211 cmdline_fixed_string_t set;
3212 cmdline_fixed_string_t link_check;
3213 cmdline_fixed_string_t mode;
3217 cmd_set_link_check_parsed(void *parsed_result,
3218 __attribute__((unused)) struct cmdline *cl,
3219 __attribute__((unused)) void *data)
3221 struct cmd_set_link_check *res = parsed_result;
3222 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3225 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3226 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3228 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3229 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3230 link_check, "link_check");
3231 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3232 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3236 cmdline_parse_inst_t cmd_set_link_check = {
3237 .f = cmd_set_link_check_parsed,
3238 .help_str = "set link_check on|off: enable/disable link status check "
3239 "when starting/stopping a port",
3242 (void *)&cmd_setlinkcheck_set,
3243 (void *)&cmd_setlinkcheck_link_check,
3244 (void *)&cmd_setlinkcheck_mode,
3249 #ifdef RTE_NIC_BYPASS
3250 /* *** SET NIC BYPASS MODE *** */
3251 struct cmd_set_bypass_mode_result {
3252 cmdline_fixed_string_t set;
3253 cmdline_fixed_string_t bypass;
3254 cmdline_fixed_string_t mode;
3255 cmdline_fixed_string_t value;
3260 cmd_set_bypass_mode_parsed(void *parsed_result,
3261 __attribute__((unused)) struct cmdline *cl,
3262 __attribute__((unused)) void *data)
3264 struct cmd_set_bypass_mode_result *res = parsed_result;
3265 portid_t port_id = res->port_id;
3266 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3268 if (!bypass_is_supported(port_id))
3271 if (!strcmp(res->value, "bypass"))
3272 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3273 else if (!strcmp(res->value, "isolate"))
3274 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3276 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3278 /* Set the bypass mode for the relevant port. */
3279 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3280 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3284 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3285 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3287 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3288 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3290 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3291 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3293 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3294 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3295 value, "normal#bypass#isolate");
3296 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3297 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3300 cmdline_parse_inst_t cmd_set_bypass_mode = {
3301 .f = cmd_set_bypass_mode_parsed,
3302 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3303 "Set the NIC bypass mode for port_id",
3306 (void *)&cmd_setbypass_mode_set,
3307 (void *)&cmd_setbypass_mode_bypass,
3308 (void *)&cmd_setbypass_mode_mode,
3309 (void *)&cmd_setbypass_mode_value,
3310 (void *)&cmd_setbypass_mode_port,
3315 /* *** SET NIC BYPASS EVENT *** */
3316 struct cmd_set_bypass_event_result {
3317 cmdline_fixed_string_t set;
3318 cmdline_fixed_string_t bypass;
3319 cmdline_fixed_string_t event;
3320 cmdline_fixed_string_t event_value;
3321 cmdline_fixed_string_t mode;
3322 cmdline_fixed_string_t mode_value;
3327 cmd_set_bypass_event_parsed(void *parsed_result,
3328 __attribute__((unused)) struct cmdline *cl,
3329 __attribute__((unused)) void *data)
3332 struct cmd_set_bypass_event_result *res = parsed_result;
3333 portid_t port_id = res->port_id;
3334 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3335 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3337 if (!bypass_is_supported(port_id))
3340 if (!strcmp(res->event_value, "timeout"))
3341 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3342 else if (!strcmp(res->event_value, "os_on"))
3343 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3344 else if (!strcmp(res->event_value, "os_off"))
3345 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3346 else if (!strcmp(res->event_value, "power_on"))
3347 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3348 else if (!strcmp(res->event_value, "power_off"))
3349 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3351 bypass_event = RTE_BYPASS_EVENT_NONE;
3353 if (!strcmp(res->mode_value, "bypass"))
3354 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3355 else if (!strcmp(res->mode_value, "isolate"))
3356 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3358 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3360 /* Set the watchdog timeout. */
3361 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3364 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3365 (rc = rte_eth_dev_wd_timeout_store(port_id,
3366 bypass_timeout)) != 0) {
3367 printf("Failed to set timeout value %u "
3368 "for port %d, errto code: %d.\n",
3369 bypass_timeout, port_id, rc);
3373 /* Set the bypass event to transition to bypass mode. */
3374 if (0 != rte_eth_dev_bypass_event_store(port_id,
3375 bypass_event, bypass_mode)) {
3376 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3381 cmdline_parse_token_string_t cmd_setbypass_event_set =
3382 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3384 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3385 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3387 cmdline_parse_token_string_t cmd_setbypass_event_event =
3388 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3390 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3391 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3392 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3393 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3394 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3396 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3397 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3398 mode_value, "normal#bypass#isolate");
3399 cmdline_parse_token_num_t cmd_setbypass_event_port =
3400 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3403 cmdline_parse_inst_t cmd_set_bypass_event = {
3404 .f = cmd_set_bypass_event_parsed,
3405 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3406 "mode (normal|bypass|isolate) (port_id): "
3407 "Set the NIC bypass event mode for port_id",
3410 (void *)&cmd_setbypass_event_set,
3411 (void *)&cmd_setbypass_event_bypass,
3412 (void *)&cmd_setbypass_event_event,
3413 (void *)&cmd_setbypass_event_event_value,
3414 (void *)&cmd_setbypass_event_mode,
3415 (void *)&cmd_setbypass_event_mode_value,
3416 (void *)&cmd_setbypass_event_port,
3422 /* *** SET NIC BYPASS TIMEOUT *** */
3423 struct cmd_set_bypass_timeout_result {
3424 cmdline_fixed_string_t set;
3425 cmdline_fixed_string_t bypass;
3426 cmdline_fixed_string_t timeout;
3427 cmdline_fixed_string_t value;
3431 cmd_set_bypass_timeout_parsed(void *parsed_result,
3432 __attribute__((unused)) struct cmdline *cl,
3433 __attribute__((unused)) void *data)
3435 struct cmd_set_bypass_timeout_result *res = parsed_result;
3437 if (!strcmp(res->value, "1.5"))
3438 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3439 else if (!strcmp(res->value, "2"))
3440 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3441 else if (!strcmp(res->value, "3"))
3442 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3443 else if (!strcmp(res->value, "4"))
3444 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3445 else if (!strcmp(res->value, "8"))
3446 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3447 else if (!strcmp(res->value, "16"))
3448 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3449 else if (!strcmp(res->value, "32"))
3450 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3452 bypass_timeout = RTE_BYPASS_TMT_OFF;
3455 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3456 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3458 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3459 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3461 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3462 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3463 timeout, "timeout");
3464 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3465 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3466 value, "0#1.5#2#3#4#8#16#32");
3468 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3469 .f = cmd_set_bypass_timeout_parsed,
3470 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3471 "Set the NIC bypass watchdog timeout",
3474 (void *)&cmd_setbypass_timeout_set,
3475 (void *)&cmd_setbypass_timeout_bypass,
3476 (void *)&cmd_setbypass_timeout_timeout,
3477 (void *)&cmd_setbypass_timeout_value,
3482 /* *** SHOW NIC BYPASS MODE *** */
3483 struct cmd_show_bypass_config_result {
3484 cmdline_fixed_string_t show;
3485 cmdline_fixed_string_t bypass;
3486 cmdline_fixed_string_t config;
3491 cmd_show_bypass_config_parsed(void *parsed_result,
3492 __attribute__((unused)) struct cmdline *cl,
3493 __attribute__((unused)) void *data)
3495 struct cmd_show_bypass_config_result *res = parsed_result;
3496 uint32_t event_mode;
3497 uint32_t bypass_mode;
3498 portid_t port_id = res->port_id;
3499 uint32_t timeout = bypass_timeout;
3502 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3503 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3504 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3505 {"UNKNOWN", "normal", "bypass", "isolate"};
3506 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3513 int num_events = (sizeof events) / (sizeof events[0]);
3515 if (!bypass_is_supported(port_id))
3518 /* Display the bypass mode.*/
3519 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3520 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3524 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3525 bypass_mode = RTE_BYPASS_MODE_NONE;
3527 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3530 /* Display the bypass timeout.*/
3531 if (!RTE_BYPASS_TMT_VALID(timeout))
3532 timeout = RTE_BYPASS_TMT_OFF;
3534 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3536 /* Display the bypass events and associated modes. */
3537 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3539 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3540 printf("\tFailed to get bypass mode for event = %s\n",
3543 if (!RTE_BYPASS_MODE_VALID(event_mode))
3544 event_mode = RTE_BYPASS_MODE_NONE;
3546 printf("\tbypass event: %-16s = %s\n", events[i],
3552 cmdline_parse_token_string_t cmd_showbypass_config_show =
3553 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3555 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3556 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3558 cmdline_parse_token_string_t cmd_showbypass_config_config =
3559 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3561 cmdline_parse_token_num_t cmd_showbypass_config_port =
3562 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3565 cmdline_parse_inst_t cmd_show_bypass_config = {
3566 .f = cmd_show_bypass_config_parsed,
3567 .help_str = "show bypass config (port_id): "
3568 "Show the NIC bypass config for port_id",
3571 (void *)&cmd_showbypass_config_show,
3572 (void *)&cmd_showbypass_config_bypass,
3573 (void *)&cmd_showbypass_config_config,
3574 (void *)&cmd_showbypass_config_port,
3580 #ifdef RTE_LIBRTE_PMD_BOND
3581 /* *** SET BONDING MODE *** */
3582 struct cmd_set_bonding_mode_result {
3583 cmdline_fixed_string_t set;
3584 cmdline_fixed_string_t bonding;
3585 cmdline_fixed_string_t mode;
3590 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3591 __attribute__((unused)) struct cmdline *cl,
3592 __attribute__((unused)) void *data)
3594 struct cmd_set_bonding_mode_result *res = parsed_result;
3595 portid_t port_id = res->port_id;
3597 /* Set the bonding mode for the relevant port. */
3598 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3599 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3602 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3603 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3605 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3606 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3607 bonding, "bonding");
3608 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3609 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3611 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3612 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3614 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3615 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3618 cmdline_parse_inst_t cmd_set_bonding_mode = {
3619 .f = cmd_set_bonding_mode_parsed,
3620 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3623 (void *) &cmd_setbonding_mode_set,
3624 (void *) &cmd_setbonding_mode_bonding,
3625 (void *) &cmd_setbonding_mode_mode,
3626 (void *) &cmd_setbonding_mode_value,
3627 (void *) &cmd_setbonding_mode_port,
3632 /* *** SET BALANCE XMIT POLICY *** */
3633 struct cmd_set_bonding_balance_xmit_policy_result {
3634 cmdline_fixed_string_t set;
3635 cmdline_fixed_string_t bonding;
3636 cmdline_fixed_string_t balance_xmit_policy;
3638 cmdline_fixed_string_t policy;
3641 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3642 __attribute__((unused)) struct cmdline *cl,
3643 __attribute__((unused)) void *data)
3645 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3646 portid_t port_id = res->port_id;
3649 if (!strcmp(res->policy, "l2")) {
3650 policy = BALANCE_XMIT_POLICY_LAYER2;
3651 } else if (!strcmp(res->policy, "l23")) {
3652 policy = BALANCE_XMIT_POLICY_LAYER23;
3653 } else if (!strcmp(res->policy, "l34")) {
3654 policy = BALANCE_XMIT_POLICY_LAYER34;
3656 printf("\t Invalid xmit policy selection");
3660 /* Set the bonding mode for the relevant port. */
3661 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3662 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3667 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3668 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3670 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3671 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3672 bonding, "bonding");
3673 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3674 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3675 balance_xmit_policy, "balance_xmit_policy");
3676 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3677 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3679 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3680 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3681 policy, "l2#l23#l34");
3683 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3684 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3685 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3688 (void *)&cmd_setbonding_balance_xmit_policy_set,
3689 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3690 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3691 (void *)&cmd_setbonding_balance_xmit_policy_port,
3692 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3697 /* *** SHOW NIC BONDING CONFIGURATION *** */
3698 struct cmd_show_bonding_config_result {
3699 cmdline_fixed_string_t show;
3700 cmdline_fixed_string_t bonding;
3701 cmdline_fixed_string_t config;
3705 static void cmd_show_bonding_config_parsed(void *parsed_result,
3706 __attribute__((unused)) struct cmdline *cl,
3707 __attribute__((unused)) void *data)
3709 struct cmd_show_bonding_config_result *res = parsed_result;
3711 uint8_t slaves[RTE_MAX_ETHPORTS];
3712 int num_slaves, num_active_slaves;
3715 portid_t port_id = res->port_id;
3717 /* Display the bonding mode.*/
3718 bonding_mode = rte_eth_bond_mode_get(port_id);
3719 if (bonding_mode < 0) {
3720 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3723 printf("\tBonding mode: %d\n", bonding_mode);
3725 if (bonding_mode == BONDING_MODE_BALANCE) {
3726 int balance_xmit_policy;
3728 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3729 if (balance_xmit_policy < 0) {
3730 printf("\tFailed to get balance xmit policy for port = %d\n",
3734 printf("\tBalance Xmit Policy: ");
3736 switch (balance_xmit_policy) {
3737 case BALANCE_XMIT_POLICY_LAYER2:
3738 printf("BALANCE_XMIT_POLICY_LAYER2");
3740 case BALANCE_XMIT_POLICY_LAYER23:
3741 printf("BALANCE_XMIT_POLICY_LAYER23");
3743 case BALANCE_XMIT_POLICY_LAYER34:
3744 printf("BALANCE_XMIT_POLICY_LAYER34");
3751 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3753 if (num_slaves < 0) {
3754 printf("\tFailed to get slave list for port = %d\n", port_id);
3757 if (num_slaves > 0) {
3758 printf("\tSlaves (%d): [", num_slaves);
3759 for (i = 0; i < num_slaves - 1; i++)
3760 printf("%d ", slaves[i]);
3762 printf("%d]\n", slaves[num_slaves - 1]);
3764 printf("\tSlaves: []\n");
3768 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3771 if (num_active_slaves < 0) {
3772 printf("\tFailed to get active slave list for port = %d\n", port_id);
3775 if (num_active_slaves > 0) {
3776 printf("\tActive Slaves (%d): [", num_active_slaves);
3777 for (i = 0; i < num_active_slaves - 1; i++)
3778 printf("%d ", slaves[i]);
3780 printf("%d]\n", slaves[num_active_slaves - 1]);
3783 printf("\tActive Slaves: []\n");
3787 primary_id = rte_eth_bond_primary_get(port_id);
3788 if (primary_id < 0) {
3789 printf("\tFailed to get primary slave for port = %d\n", port_id);
3792 printf("\tPrimary: [%d]\n", primary_id);
3796 cmdline_parse_token_string_t cmd_showbonding_config_show =
3797 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3799 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3800 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3801 bonding, "bonding");
3802 cmdline_parse_token_string_t cmd_showbonding_config_config =
3803 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3805 cmdline_parse_token_num_t cmd_showbonding_config_port =
3806 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3809 cmdline_parse_inst_t cmd_show_bonding_config = {
3810 .f = cmd_show_bonding_config_parsed,
3811 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3814 (void *)&cmd_showbonding_config_show,
3815 (void *)&cmd_showbonding_config_bonding,
3816 (void *)&cmd_showbonding_config_config,
3817 (void *)&cmd_showbonding_config_port,
3822 /* *** SET BONDING PRIMARY *** */
3823 struct cmd_set_bonding_primary_result {
3824 cmdline_fixed_string_t set;
3825 cmdline_fixed_string_t bonding;
3826 cmdline_fixed_string_t primary;
3831 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3832 __attribute__((unused)) struct cmdline *cl,
3833 __attribute__((unused)) void *data)
3835 struct cmd_set_bonding_primary_result *res = parsed_result;
3836 portid_t master_port_id = res->port_id;
3837 portid_t slave_port_id = res->slave_id;
3839 /* Set the primary slave for a bonded device. */
3840 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3841 printf("\t Failed to set primary slave for port = %d.\n",
3848 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3849 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3851 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3852 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3853 bonding, "bonding");
3854 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3855 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3856 primary, "primary");
3857 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3858 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3860 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3861 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3864 cmdline_parse_inst_t cmd_set_bonding_primary = {
3865 .f = cmd_set_bonding_primary_parsed,
3866 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3869 (void *)&cmd_setbonding_primary_set,
3870 (void *)&cmd_setbonding_primary_bonding,
3871 (void *)&cmd_setbonding_primary_primary,
3872 (void *)&cmd_setbonding_primary_slave,
3873 (void *)&cmd_setbonding_primary_port,
3878 /* *** ADD SLAVE *** */
3879 struct cmd_add_bonding_slave_result {
3880 cmdline_fixed_string_t add;
3881 cmdline_fixed_string_t bonding;
3882 cmdline_fixed_string_t slave;
3887 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3888 __attribute__((unused)) struct cmdline *cl,
3889 __attribute__((unused)) void *data)
3891 struct cmd_add_bonding_slave_result *res = parsed_result;
3892 portid_t master_port_id = res->port_id;
3893 portid_t slave_port_id = res->slave_id;
3895 /* Set the primary slave for a bonded device. */
3896 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3897 printf("\t Failed to add slave %d to master port = %d.\n",
3898 slave_port_id, master_port_id);
3904 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3905 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3907 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3908 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3909 bonding, "bonding");
3910 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3911 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3913 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3914 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3916 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3917 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3920 cmdline_parse_inst_t cmd_add_bonding_slave = {
3921 .f = cmd_add_bonding_slave_parsed,
3922 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3925 (void *)&cmd_addbonding_slave_add,
3926 (void *)&cmd_addbonding_slave_bonding,
3927 (void *)&cmd_addbonding_slave_slave,
3928 (void *)&cmd_addbonding_slave_slaveid,
3929 (void *)&cmd_addbonding_slave_port,
3934 /* *** REMOVE SLAVE *** */
3935 struct cmd_remove_bonding_slave_result {
3936 cmdline_fixed_string_t remove;
3937 cmdline_fixed_string_t bonding;
3938 cmdline_fixed_string_t slave;
3943 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3944 __attribute__((unused)) struct cmdline *cl,
3945 __attribute__((unused)) void *data)
3947 struct cmd_remove_bonding_slave_result *res = parsed_result;
3948 portid_t master_port_id = res->port_id;
3949 portid_t slave_port_id = res->slave_id;
3951 /* Set the primary slave for a bonded device. */
3952 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3953 printf("\t Failed to remove slave %d from master port = %d.\n",
3954 slave_port_id, master_port_id);
3960 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3961 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3963 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3964 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3965 bonding, "bonding");
3966 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3967 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3969 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3970 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3972 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3973 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3976 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3977 .f = cmd_remove_bonding_slave_parsed,
3978 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3981 (void *)&cmd_removebonding_slave_remove,
3982 (void *)&cmd_removebonding_slave_bonding,
3983 (void *)&cmd_removebonding_slave_slave,
3984 (void *)&cmd_removebonding_slave_slaveid,
3985 (void *)&cmd_removebonding_slave_port,
3990 /* *** CREATE BONDED DEVICE *** */
3991 struct cmd_create_bonded_device_result {
3992 cmdline_fixed_string_t create;
3993 cmdline_fixed_string_t bonded;
3994 cmdline_fixed_string_t device;
3999 static int bond_dev_num = 0;
4001 static void cmd_create_bonded_device_parsed(void *parsed_result,
4002 __attribute__((unused)) struct cmdline *cl,
4003 __attribute__((unused)) void *data)
4005 struct cmd_create_bonded_device_result *res = parsed_result;
4006 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4009 if (test_done == 0) {
4010 printf("Please stop forwarding first\n");
4014 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4017 /* Create a new bonded device. */
4018 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4020 printf("\t Failed to create bonded device.\n");
4023 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4026 /* Update number of ports */
4027 nb_ports = rte_eth_dev_count();
4028 reconfig(port_id, res->socket);
4029 rte_eth_promiscuous_enable(port_id);
4034 cmdline_parse_token_string_t cmd_createbonded_device_create =
4035 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4037 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4038 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4040 cmdline_parse_token_string_t cmd_createbonded_device_device =
4041 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4043 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4044 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4046 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4047 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4050 cmdline_parse_inst_t cmd_create_bonded_device = {
4051 .f = cmd_create_bonded_device_parsed,
4052 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4055 (void *)&cmd_createbonded_device_create,
4056 (void *)&cmd_createbonded_device_bonded,
4057 (void *)&cmd_createbonded_device_device,
4058 (void *)&cmd_createbonded_device_mode,
4059 (void *)&cmd_createbonded_device_socket,
4064 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4065 struct cmd_set_bond_mac_addr_result {
4066 cmdline_fixed_string_t set;
4067 cmdline_fixed_string_t bonding;
4068 cmdline_fixed_string_t mac_addr;
4070 struct ether_addr address;
4073 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4074 __attribute__((unused)) struct cmdline *cl,
4075 __attribute__((unused)) void *data)
4077 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4080 if (res->port_num >= nb_ports) {
4081 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4085 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4087 /* check the return value and print it if is < 0 */
4089 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4092 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4093 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4094 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4095 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4097 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4098 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4100 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4101 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4102 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4103 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4105 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4106 .f = cmd_set_bond_mac_addr_parsed,
4108 .help_str = "set bonding mac_addr (port_id) (address): ",
4110 (void *)&cmd_set_bond_mac_addr_set,
4111 (void *)&cmd_set_bond_mac_addr_bonding,
4112 (void *)&cmd_set_bond_mac_addr_mac,
4113 (void *)&cmd_set_bond_mac_addr_portnum,
4114 (void *)&cmd_set_bond_mac_addr_addr,
4120 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4121 struct cmd_set_bond_mon_period_result {
4122 cmdline_fixed_string_t set;
4123 cmdline_fixed_string_t bonding;
4124 cmdline_fixed_string_t mon_period;
4129 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4130 __attribute__((unused)) struct cmdline *cl,
4131 __attribute__((unused)) void *data)
4133 struct cmd_set_bond_mon_period_result *res = parsed_result;
4136 if (res->port_num >= nb_ports) {
4137 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4141 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4143 /* check the return value and print it if is < 0 */
4145 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4148 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4149 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4151 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4152 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4153 bonding, "bonding");
4154 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4155 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4156 mon_period, "mon_period");
4157 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4158 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4160 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4161 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4164 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4165 .f = cmd_set_bond_mon_period_parsed,
4167 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4169 (void *)&cmd_set_bond_mon_period_set,
4170 (void *)&cmd_set_bond_mon_period_bonding,
4171 (void *)&cmd_set_bond_mon_period_mon_period,
4172 (void *)&cmd_set_bond_mon_period_portnum,
4173 (void *)&cmd_set_bond_mon_period_period_ms,
4178 #endif /* RTE_LIBRTE_PMD_BOND */
4180 /* *** SET FORWARDING MODE *** */
4181 struct cmd_set_fwd_mode_result {
4182 cmdline_fixed_string_t set;
4183 cmdline_fixed_string_t fwd;
4184 cmdline_fixed_string_t mode;
4187 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4188 __attribute__((unused)) struct cmdline *cl,
4189 __attribute__((unused)) void *data)
4191 struct cmd_set_fwd_mode_result *res = parsed_result;
4193 set_pkt_forwarding_mode(res->mode);
4196 cmdline_parse_token_string_t cmd_setfwd_set =
4197 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4198 cmdline_parse_token_string_t cmd_setfwd_fwd =
4199 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4200 cmdline_parse_token_string_t cmd_setfwd_mode =
4201 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4202 "" /* defined at init */);
4204 cmdline_parse_inst_t cmd_set_fwd_mode = {
4205 .f = cmd_set_fwd_mode_parsed,
4207 .help_str = NULL, /* defined at init */
4209 (void *)&cmd_setfwd_set,
4210 (void *)&cmd_setfwd_fwd,
4211 (void *)&cmd_setfwd_mode,
4216 static void cmd_set_fwd_mode_init(void)
4219 static char token[128];
4220 static char help[256];
4221 cmdline_parse_token_string_t *token_struct;
4223 modes = list_pkt_forwarding_modes();
4224 snprintf(help, sizeof help, "set fwd %s - "
4225 "set packet forwarding mode", modes);
4226 cmd_set_fwd_mode.help_str = help;
4228 /* string token separator is # */
4229 for (c = token; *modes != '\0'; modes++)
4234 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4235 token_struct->string_data.str = token;
4238 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4239 struct cmd_set_burst_tx_retry_result {
4240 cmdline_fixed_string_t set;
4241 cmdline_fixed_string_t burst;
4242 cmdline_fixed_string_t tx;
4243 cmdline_fixed_string_t delay;
4245 cmdline_fixed_string_t retry;
4249 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4250 __attribute__((unused)) struct cmdline *cl,
4251 __attribute__((unused)) void *data)
4253 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4255 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4256 && !strcmp(res->tx, "tx")) {
4257 if (!strcmp(res->delay, "delay"))
4258 burst_tx_delay_time = res->time;
4259 if (!strcmp(res->retry, "retry"))
4260 burst_tx_retry_num = res->retry_num;
4265 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4266 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4267 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4268 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4270 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4271 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4272 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4273 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4274 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4275 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4276 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4277 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4278 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4279 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4281 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4282 .f = cmd_set_burst_tx_retry_parsed,
4283 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4285 (void *)&cmd_set_burst_tx_retry_set,
4286 (void *)&cmd_set_burst_tx_retry_burst,
4287 (void *)&cmd_set_burst_tx_retry_tx,
4288 (void *)&cmd_set_burst_tx_retry_delay,
4289 (void *)&cmd_set_burst_tx_retry_time,
4290 (void *)&cmd_set_burst_tx_retry_retry,
4291 (void *)&cmd_set_burst_tx_retry_retry_num,
4296 /* *** SET PROMISC MODE *** */
4297 struct cmd_set_promisc_mode_result {
4298 cmdline_fixed_string_t set;
4299 cmdline_fixed_string_t promisc;
4300 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4301 uint8_t port_num; /* valid if "allports" argument == 0 */
4302 cmdline_fixed_string_t mode;
4305 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4306 __attribute__((unused)) struct cmdline *cl,
4309 struct cmd_set_promisc_mode_result *res = parsed_result;
4313 if (!strcmp(res->mode, "on"))
4320 for (i = 0; i < nb_ports; i++) {
4322 rte_eth_promiscuous_enable(i);
4324 rte_eth_promiscuous_disable(i);
4329 rte_eth_promiscuous_enable(res->port_num);
4331 rte_eth_promiscuous_disable(res->port_num);
4335 cmdline_parse_token_string_t cmd_setpromisc_set =
4336 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4337 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4338 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4340 cmdline_parse_token_string_t cmd_setpromisc_portall =
4341 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4343 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4344 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4346 cmdline_parse_token_string_t cmd_setpromisc_mode =
4347 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4350 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4351 .f = cmd_set_promisc_mode_parsed,
4353 .help_str = "set promisc all on|off: set promisc mode for all ports",
4355 (void *)&cmd_setpromisc_set,
4356 (void *)&cmd_setpromisc_promisc,
4357 (void *)&cmd_setpromisc_portall,
4358 (void *)&cmd_setpromisc_mode,
4363 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4364 .f = cmd_set_promisc_mode_parsed,
4366 .help_str = "set promisc X on|off: set promisc mode on port X",
4368 (void *)&cmd_setpromisc_set,
4369 (void *)&cmd_setpromisc_promisc,
4370 (void *)&cmd_setpromisc_portnum,
4371 (void *)&cmd_setpromisc_mode,
4376 /* *** SET ALLMULTI MODE *** */
4377 struct cmd_set_allmulti_mode_result {
4378 cmdline_fixed_string_t set;
4379 cmdline_fixed_string_t allmulti;
4380 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4381 uint8_t port_num; /* valid if "allports" argument == 0 */
4382 cmdline_fixed_string_t mode;
4385 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4386 __attribute__((unused)) struct cmdline *cl,
4389 struct cmd_set_allmulti_mode_result *res = parsed_result;
4393 if (!strcmp(res->mode, "on"))
4400 for (i = 0; i < nb_ports; i++) {
4402 rte_eth_allmulticast_enable(i);
4404 rte_eth_allmulticast_disable(i);
4409 rte_eth_allmulticast_enable(res->port_num);
4411 rte_eth_allmulticast_disable(res->port_num);
4415 cmdline_parse_token_string_t cmd_setallmulti_set =
4416 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4417 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4418 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4420 cmdline_parse_token_string_t cmd_setallmulti_portall =
4421 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4423 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4424 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4426 cmdline_parse_token_string_t cmd_setallmulti_mode =
4427 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4430 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4431 .f = cmd_set_allmulti_mode_parsed,
4433 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4435 (void *)&cmd_setallmulti_set,
4436 (void *)&cmd_setallmulti_allmulti,
4437 (void *)&cmd_setallmulti_portall,
4438 (void *)&cmd_setallmulti_mode,
4443 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4444 .f = cmd_set_allmulti_mode_parsed,
4446 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4448 (void *)&cmd_setallmulti_set,
4449 (void *)&cmd_setallmulti_allmulti,
4450 (void *)&cmd_setallmulti_portnum,
4451 (void *)&cmd_setallmulti_mode,
4456 /* *** ADD/REMOVE A PKT FILTER *** */
4457 struct cmd_pkt_filter_result {
4458 cmdline_fixed_string_t pkt_filter;
4460 cmdline_fixed_string_t protocol;
4461 cmdline_fixed_string_t src;
4462 cmdline_ipaddr_t ip_src;
4464 cmdline_fixed_string_t dst;
4465 cmdline_ipaddr_t ip_dst;
4467 cmdline_fixed_string_t flexbytes;
4468 uint16_t flexbytes_value;
4469 cmdline_fixed_string_t vlan;
4471 cmdline_fixed_string_t queue;
4473 cmdline_fixed_string_t soft;
4478 cmd_pkt_filter_parsed(void *parsed_result,
4479 __attribute__((unused)) struct cmdline *cl,
4480 __attribute__((unused)) void *data)
4482 struct rte_fdir_filter fdir_filter;
4483 struct cmd_pkt_filter_result *res = parsed_result;
4485 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4487 if (res->ip_src.family == AF_INET)
4488 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4490 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4491 &(res->ip_src.addr.ipv6),
4492 sizeof(struct in6_addr));
4494 if (res->ip_dst.family == AF_INET)
4495 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4497 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4498 &(res->ip_dst.addr.ipv6),
4499 sizeof(struct in6_addr));
4501 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4502 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4504 if (!strcmp(res->protocol, "udp"))
4505 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4506 else if (!strcmp(res->protocol, "tcp"))
4507 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4508 else if (!strcmp(res->protocol, "sctp"))
4509 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4510 else /* default only IP */
4511 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4513 if (res->ip_dst.family == AF_INET6)
4514 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4516 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4518 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4519 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4521 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4522 fdir_add_signature_filter(res->port_id, res->queue_id,
4524 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4525 fdir_update_signature_filter(res->port_id, res->queue_id,
4527 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4528 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4529 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4530 fdir_add_perfect_filter(res->port_id, res->soft_id,
4532 (uint8_t) (res->queue_id < 0),
4534 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4535 fdir_update_perfect_filter(res->port_id, res->soft_id,
4537 (uint8_t) (res->queue_id < 0),
4539 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4540 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4546 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4547 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4549 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4550 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4551 protocol, "ip#tcp#udp#sctp");
4552 cmdline_parse_token_string_t cmd_pkt_filter_src =
4553 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4555 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4556 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4558 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4559 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4561 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4562 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4564 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4565 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4567 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4568 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4570 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4571 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4572 flexbytes, "flexbytes");
4573 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4574 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4575 flexbytes_value, UINT16);
4576 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4577 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4579 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4580 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4582 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4583 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4585 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4586 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4588 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4589 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4591 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4592 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4596 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4597 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4598 pkt_filter, "add_signature_filter");
4599 cmdline_parse_inst_t cmd_add_signature_filter = {
4600 .f = cmd_pkt_filter_parsed,
4602 .help_str = "add a signature filter",
4604 (void *)&cmd_pkt_filter_add_signature_filter,
4605 (void *)&cmd_pkt_filter_port_id,
4606 (void *)&cmd_pkt_filter_protocol,
4607 (void *)&cmd_pkt_filter_src,
4608 (void *)&cmd_pkt_filter_ip_src,
4609 (void *)&cmd_pkt_filter_port_src,
4610 (void *)&cmd_pkt_filter_dst,
4611 (void *)&cmd_pkt_filter_ip_dst,
4612 (void *)&cmd_pkt_filter_port_dst,
4613 (void *)&cmd_pkt_filter_flexbytes,
4614 (void *)&cmd_pkt_filter_flexbytes_value,
4615 (void *)&cmd_pkt_filter_vlan,
4616 (void *)&cmd_pkt_filter_vlan_id,
4617 (void *)&cmd_pkt_filter_queue,
4618 (void *)&cmd_pkt_filter_queue_id,
4624 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4625 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4626 pkt_filter, "upd_signature_filter");
4627 cmdline_parse_inst_t cmd_upd_signature_filter = {
4628 .f = cmd_pkt_filter_parsed,
4630 .help_str = "update a signature filter",
4632 (void *)&cmd_pkt_filter_upd_signature_filter,
4633 (void *)&cmd_pkt_filter_port_id,
4634 (void *)&cmd_pkt_filter_protocol,
4635 (void *)&cmd_pkt_filter_src,
4636 (void *)&cmd_pkt_filter_ip_src,
4637 (void *)&cmd_pkt_filter_port_src,
4638 (void *)&cmd_pkt_filter_dst,
4639 (void *)&cmd_pkt_filter_ip_dst,
4640 (void *)&cmd_pkt_filter_port_dst,
4641 (void *)&cmd_pkt_filter_flexbytes,
4642 (void *)&cmd_pkt_filter_flexbytes_value,
4643 (void *)&cmd_pkt_filter_vlan,
4644 (void *)&cmd_pkt_filter_vlan_id,
4645 (void *)&cmd_pkt_filter_queue,
4646 (void *)&cmd_pkt_filter_queue_id,
4652 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4653 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4654 pkt_filter, "rm_signature_filter");
4655 cmdline_parse_inst_t cmd_rm_signature_filter = {
4656 .f = cmd_pkt_filter_parsed,
4658 .help_str = "remove a signature filter",
4660 (void *)&cmd_pkt_filter_rm_signature_filter,
4661 (void *)&cmd_pkt_filter_port_id,
4662 (void *)&cmd_pkt_filter_protocol,
4663 (void *)&cmd_pkt_filter_src,
4664 (void *)&cmd_pkt_filter_ip_src,
4665 (void *)&cmd_pkt_filter_port_src,
4666 (void *)&cmd_pkt_filter_dst,
4667 (void *)&cmd_pkt_filter_ip_dst,
4668 (void *)&cmd_pkt_filter_port_dst,
4669 (void *)&cmd_pkt_filter_flexbytes,
4670 (void *)&cmd_pkt_filter_flexbytes_value,
4671 (void *)&cmd_pkt_filter_vlan,
4672 (void *)&cmd_pkt_filter_vlan_id,
4678 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4679 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4680 pkt_filter, "add_perfect_filter");
4681 cmdline_parse_inst_t cmd_add_perfect_filter = {
4682 .f = cmd_pkt_filter_parsed,
4684 .help_str = "add a perfect filter",
4686 (void *)&cmd_pkt_filter_add_perfect_filter,
4687 (void *)&cmd_pkt_filter_port_id,
4688 (void *)&cmd_pkt_filter_protocol,
4689 (void *)&cmd_pkt_filter_src,
4690 (void *)&cmd_pkt_filter_ip_src,
4691 (void *)&cmd_pkt_filter_port_src,
4692 (void *)&cmd_pkt_filter_dst,
4693 (void *)&cmd_pkt_filter_ip_dst,
4694 (void *)&cmd_pkt_filter_port_dst,
4695 (void *)&cmd_pkt_filter_flexbytes,
4696 (void *)&cmd_pkt_filter_flexbytes_value,
4697 (void *)&cmd_pkt_filter_vlan,
4698 (void *)&cmd_pkt_filter_vlan_id,
4699 (void *)&cmd_pkt_filter_queue,
4700 (void *)&cmd_pkt_filter_queue_id,
4701 (void *)&cmd_pkt_filter_soft,
4702 (void *)&cmd_pkt_filter_soft_id,
4708 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4709 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4710 pkt_filter, "upd_perfect_filter");
4711 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4712 .f = cmd_pkt_filter_parsed,
4714 .help_str = "update a perfect filter",
4716 (void *)&cmd_pkt_filter_upd_perfect_filter,
4717 (void *)&cmd_pkt_filter_port_id,
4718 (void *)&cmd_pkt_filter_protocol,
4719 (void *)&cmd_pkt_filter_src,
4720 (void *)&cmd_pkt_filter_ip_src,
4721 (void *)&cmd_pkt_filter_port_src,
4722 (void *)&cmd_pkt_filter_dst,
4723 (void *)&cmd_pkt_filter_ip_dst,
4724 (void *)&cmd_pkt_filter_port_dst,
4725 (void *)&cmd_pkt_filter_flexbytes,
4726 (void *)&cmd_pkt_filter_flexbytes_value,
4727 (void *)&cmd_pkt_filter_vlan,
4728 (void *)&cmd_pkt_filter_vlan_id,
4729 (void *)&cmd_pkt_filter_queue,
4730 (void *)&cmd_pkt_filter_queue_id,
4731 (void *)&cmd_pkt_filter_soft,
4732 (void *)&cmd_pkt_filter_soft_id,
4738 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4739 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4740 pkt_filter, "rm_perfect_filter");
4741 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4742 .f = cmd_pkt_filter_parsed,
4744 .help_str = "remove a perfect filter",
4746 (void *)&cmd_pkt_filter_rm_perfect_filter,
4747 (void *)&cmd_pkt_filter_port_id,
4748 (void *)&cmd_pkt_filter_protocol,
4749 (void *)&cmd_pkt_filter_src,
4750 (void *)&cmd_pkt_filter_ip_src,
4751 (void *)&cmd_pkt_filter_port_src,
4752 (void *)&cmd_pkt_filter_dst,
4753 (void *)&cmd_pkt_filter_ip_dst,
4754 (void *)&cmd_pkt_filter_port_dst,
4755 (void *)&cmd_pkt_filter_flexbytes,
4756 (void *)&cmd_pkt_filter_flexbytes_value,
4757 (void *)&cmd_pkt_filter_vlan,
4758 (void *)&cmd_pkt_filter_vlan_id,
4759 (void *)&cmd_pkt_filter_soft,
4760 (void *)&cmd_pkt_filter_soft_id,
4765 /* *** SETUP MASKS FILTER *** */
4766 struct cmd_pkt_filter_masks_result {
4767 cmdline_fixed_string_t filter_mask;
4769 cmdline_fixed_string_t src_mask;
4770 uint32_t ip_src_mask;
4771 uint16_t ipv6_src_mask;
4772 uint16_t port_src_mask;
4773 cmdline_fixed_string_t dst_mask;
4774 uint32_t ip_dst_mask;
4775 uint16_t ipv6_dst_mask;
4776 uint16_t port_dst_mask;
4777 cmdline_fixed_string_t flexbytes;
4778 uint8_t flexbytes_value;
4779 cmdline_fixed_string_t vlan_id;
4780 uint8_t vlan_id_value;
4781 cmdline_fixed_string_t vlan_prio;
4782 uint8_t vlan_prio_value;
4783 cmdline_fixed_string_t only_ip_flow;
4784 uint8_t only_ip_flow_value;
4785 cmdline_fixed_string_t comp_ipv6_dst;
4786 uint8_t comp_ipv6_dst_value;
4790 cmd_pkt_filter_masks_parsed(void *parsed_result,
4791 __attribute__((unused)) struct cmdline *cl,
4792 __attribute__((unused)) void *data)
4794 struct rte_fdir_masks fdir_masks;
4795 struct cmd_pkt_filter_masks_result *res = parsed_result;
4797 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4799 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4800 fdir_masks.vlan_id = res->vlan_id_value;
4801 fdir_masks.vlan_prio = res->vlan_prio_value;
4802 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4803 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4804 fdir_masks.src_port_mask = res->port_src_mask;
4805 fdir_masks.dst_port_mask = res->port_dst_mask;
4806 fdir_masks.flexbytes = res->flexbytes_value;
4808 fdir_set_masks(res->port_id, &fdir_masks);
4811 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4812 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4813 filter_mask, "set_masks_filter");
4814 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4815 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4817 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4818 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4819 only_ip_flow, "only_ip_flow");
4820 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4821 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4822 only_ip_flow_value, UINT8);
4823 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4824 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4825 src_mask, "src_mask");
4826 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4827 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4828 ip_src_mask, UINT32);
4829 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4830 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4831 port_src_mask, UINT16);
4832 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4833 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4834 dst_mask, "dst_mask");
4835 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4836 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4837 ip_dst_mask, UINT32);
4838 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4839 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4840 port_dst_mask, UINT16);
4841 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4842 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4843 flexbytes, "flexbytes");
4844 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4845 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4846 flexbytes_value, UINT8);
4847 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4848 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4849 vlan_id, "vlan_id");
4850 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4851 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4852 vlan_id_value, UINT8);
4853 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4854 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4855 vlan_prio, "vlan_prio");
4856 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4857 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4858 vlan_prio_value, UINT8);
4860 cmdline_parse_inst_t cmd_set_masks_filter = {
4861 .f = cmd_pkt_filter_masks_parsed,
4863 .help_str = "setup masks filter",
4865 (void *)&cmd_pkt_filter_masks_filter_mask,
4866 (void *)&cmd_pkt_filter_masks_port_id,
4867 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4868 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4869 (void *)&cmd_pkt_filter_masks_src_mask,
4870 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4871 (void *)&cmd_pkt_filter_masks_port_src_mask,
4872 (void *)&cmd_pkt_filter_masks_dst_mask,
4873 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4874 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4875 (void *)&cmd_pkt_filter_masks_flexbytes,
4876 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4877 (void *)&cmd_pkt_filter_masks_vlan_id,
4878 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4879 (void *)&cmd_pkt_filter_masks_vlan_prio,
4880 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4886 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4887 __attribute__((unused)) struct cmdline *cl,
4888 __attribute__((unused)) void *data)
4890 struct rte_fdir_masks fdir_masks;
4891 struct cmd_pkt_filter_masks_result *res = parsed_result;
4893 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4895 fdir_masks.set_ipv6_mask = 1;
4896 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4897 fdir_masks.vlan_id = res->vlan_id_value;
4898 fdir_masks.vlan_prio = res->vlan_prio_value;
4899 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4900 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4901 fdir_masks.src_port_mask = res->port_src_mask;
4902 fdir_masks.dst_port_mask = res->port_dst_mask;
4903 fdir_masks.flexbytes = res->flexbytes_value;
4904 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4906 fdir_set_masks(res->port_id, &fdir_masks);
4909 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4910 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4911 filter_mask, "set_ipv6_masks_filter");
4912 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4913 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4914 ipv6_src_mask, UINT16);
4915 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4916 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4917 ipv6_dst_mask, UINT16);
4919 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4920 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4921 comp_ipv6_dst, "compare_dst");
4922 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4923 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4924 comp_ipv6_dst_value, UINT8);
4926 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4927 .f = cmd_pkt_filter_masks_ipv6_parsed,
4929 .help_str = "setup ipv6 masks filter",
4931 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4932 (void *)&cmd_pkt_filter_masks_port_id,
4933 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4934 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4935 (void *)&cmd_pkt_filter_masks_src_mask,
4936 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4937 (void *)&cmd_pkt_filter_masks_port_src_mask,
4938 (void *)&cmd_pkt_filter_masks_dst_mask,
4939 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4940 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4941 (void *)&cmd_pkt_filter_masks_flexbytes,
4942 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4943 (void *)&cmd_pkt_filter_masks_vlan_id,
4944 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4945 (void *)&cmd_pkt_filter_masks_vlan_prio,
4946 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4947 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4948 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4953 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4954 struct cmd_link_flow_ctrl_set_result {
4955 cmdline_fixed_string_t set;
4956 cmdline_fixed_string_t flow_ctrl;
4957 cmdline_fixed_string_t rx;
4958 cmdline_fixed_string_t rx_lfc_mode;
4959 cmdline_fixed_string_t tx;
4960 cmdline_fixed_string_t tx_lfc_mode;
4961 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4962 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4963 cmdline_fixed_string_t autoneg_str;
4964 cmdline_fixed_string_t autoneg;
4965 cmdline_fixed_string_t hw_str;
4966 uint32_t high_water;
4967 cmdline_fixed_string_t lw_str;
4969 cmdline_fixed_string_t pt_str;
4970 uint16_t pause_time;
4971 cmdline_fixed_string_t xon_str;
4976 cmdline_parse_token_string_t cmd_lfc_set_set =
4977 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4979 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4980 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4981 flow_ctrl, "flow_ctrl");
4982 cmdline_parse_token_string_t cmd_lfc_set_rx =
4983 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4985 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4986 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4987 rx_lfc_mode, "on#off");
4988 cmdline_parse_token_string_t cmd_lfc_set_tx =
4989 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4991 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4992 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4993 tx_lfc_mode, "on#off");
4994 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4995 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4996 hw_str, "high_water");
4997 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4998 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4999 high_water, UINT32);
5000 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5001 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5002 lw_str, "low_water");
5003 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5004 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5006 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5007 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5008 pt_str, "pause_time");
5009 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5010 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5011 pause_time, UINT16);
5012 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5013 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5014 xon_str, "send_xon");
5015 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5016 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5018 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5019 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5020 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5021 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5022 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5023 mac_ctrl_frame_fwd_mode, "on#off");
5024 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5025 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5026 autoneg_str, "autoneg");
5027 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5028 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5030 cmdline_parse_token_num_t cmd_lfc_set_portid =
5031 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5034 /* forward declaration */
5036 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5039 cmdline_parse_inst_t cmd_link_flow_control_set = {
5040 .f = cmd_link_flow_ctrl_set_parsed,
5042 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
5043 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
5044 autoneg on|off port_id",
5046 (void *)&cmd_lfc_set_set,
5047 (void *)&cmd_lfc_set_flow_ctrl,
5048 (void *)&cmd_lfc_set_rx,
5049 (void *)&cmd_lfc_set_rx_mode,
5050 (void *)&cmd_lfc_set_tx,
5051 (void *)&cmd_lfc_set_tx_mode,
5052 (void *)&cmd_lfc_set_high_water,
5053 (void *)&cmd_lfc_set_low_water,
5054 (void *)&cmd_lfc_set_pause_time,
5055 (void *)&cmd_lfc_set_send_xon,
5056 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5057 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5058 (void *)&cmd_lfc_set_autoneg_str,
5059 (void *)&cmd_lfc_set_autoneg,
5060 (void *)&cmd_lfc_set_portid,
5065 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5066 .f = cmd_link_flow_ctrl_set_parsed,
5067 .data = (void *)&cmd_link_flow_control_set_rx,
5068 .help_str = "Change rx flow control parameter: set flow_ctrl "
5069 "rx on|off port_id",
5071 (void *)&cmd_lfc_set_set,
5072 (void *)&cmd_lfc_set_flow_ctrl,
5073 (void *)&cmd_lfc_set_rx,
5074 (void *)&cmd_lfc_set_rx_mode,
5075 (void *)&cmd_lfc_set_portid,
5080 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5081 .f = cmd_link_flow_ctrl_set_parsed,
5082 .data = (void *)&cmd_link_flow_control_set_tx,
5083 .help_str = "Change tx flow control parameter: set flow_ctrl "
5084 "tx on|off port_id",
5086 (void *)&cmd_lfc_set_set,
5087 (void *)&cmd_lfc_set_flow_ctrl,
5088 (void *)&cmd_lfc_set_tx,
5089 (void *)&cmd_lfc_set_tx_mode,
5090 (void *)&cmd_lfc_set_portid,
5095 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5096 .f = cmd_link_flow_ctrl_set_parsed,
5097 .data = (void *)&cmd_link_flow_control_set_hw,
5098 .help_str = "Change high water flow control parameter: set flow_ctrl "
5099 "high_water value port_id",
5101 (void *)&cmd_lfc_set_set,
5102 (void *)&cmd_lfc_set_flow_ctrl,
5103 (void *)&cmd_lfc_set_high_water_str,
5104 (void *)&cmd_lfc_set_high_water,
5105 (void *)&cmd_lfc_set_portid,
5110 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5111 .f = cmd_link_flow_ctrl_set_parsed,
5112 .data = (void *)&cmd_link_flow_control_set_lw,
5113 .help_str = "Change low water flow control parameter: set flow_ctrl "
5114 "low_water value port_id",
5116 (void *)&cmd_lfc_set_set,
5117 (void *)&cmd_lfc_set_flow_ctrl,
5118 (void *)&cmd_lfc_set_low_water_str,
5119 (void *)&cmd_lfc_set_low_water,
5120 (void *)&cmd_lfc_set_portid,
5125 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5126 .f = cmd_link_flow_ctrl_set_parsed,
5127 .data = (void *)&cmd_link_flow_control_set_pt,
5128 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5129 "pause_time value port_id",
5131 (void *)&cmd_lfc_set_set,
5132 (void *)&cmd_lfc_set_flow_ctrl,
5133 (void *)&cmd_lfc_set_pause_time_str,
5134 (void *)&cmd_lfc_set_pause_time,
5135 (void *)&cmd_lfc_set_portid,
5140 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5141 .f = cmd_link_flow_ctrl_set_parsed,
5142 .data = (void *)&cmd_link_flow_control_set_xon,
5143 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5144 "send_xon value port_id",
5146 (void *)&cmd_lfc_set_set,
5147 (void *)&cmd_lfc_set_flow_ctrl,
5148 (void *)&cmd_lfc_set_send_xon_str,
5149 (void *)&cmd_lfc_set_send_xon,
5150 (void *)&cmd_lfc_set_portid,
5155 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5156 .f = cmd_link_flow_ctrl_set_parsed,
5157 .data = (void *)&cmd_link_flow_control_set_macfwd,
5158 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5159 "mac_ctrl_frame_fwd on|off port_id",
5161 (void *)&cmd_lfc_set_set,
5162 (void *)&cmd_lfc_set_flow_ctrl,
5163 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5164 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5165 (void *)&cmd_lfc_set_portid,
5170 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5171 .f = cmd_link_flow_ctrl_set_parsed,
5172 .data = (void *)&cmd_link_flow_control_set_autoneg,
5173 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5174 "autoneg on|off port_id",
5176 (void *)&cmd_lfc_set_set,
5177 (void *)&cmd_lfc_set_flow_ctrl,
5178 (void *)&cmd_lfc_set_autoneg_str,
5179 (void *)&cmd_lfc_set_autoneg,
5180 (void *)&cmd_lfc_set_portid,
5186 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5187 __attribute__((unused)) struct cmdline *cl,
5190 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5191 cmdline_parse_inst_t *cmd = data;
5192 struct rte_eth_fc_conf fc_conf;
5193 int rx_fc_en, tx_fc_en;
5197 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5198 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5199 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5200 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5202 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5203 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5206 /* Partial command line, retrieve current configuration */
5208 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5210 printf("cannot get current flow ctrl parameters, return"
5211 "code = %d\n", ret);
5215 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5216 (fc_conf.mode == RTE_FC_FULL))
5218 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5219 (fc_conf.mode == RTE_FC_FULL))
5223 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5224 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5226 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5227 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5229 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5231 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5232 fc_conf.high_water = res->high_water;
5234 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5235 fc_conf.low_water = res->low_water;
5237 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5238 fc_conf.pause_time = res->pause_time;
5240 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5241 fc_conf.send_xon = res->send_xon;
5243 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5244 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5245 fc_conf.mac_ctrl_frame_fwd = 1;
5247 fc_conf.mac_ctrl_frame_fwd = 0;
5250 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5251 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5253 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5255 printf("bad flow contrl parameter, return code = %d \n", ret);
5258 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5259 struct cmd_priority_flow_ctrl_set_result {
5260 cmdline_fixed_string_t set;
5261 cmdline_fixed_string_t pfc_ctrl;
5262 cmdline_fixed_string_t rx;
5263 cmdline_fixed_string_t rx_pfc_mode;
5264 cmdline_fixed_string_t tx;
5265 cmdline_fixed_string_t tx_pfc_mode;
5266 uint32_t high_water;
5268 uint16_t pause_time;
5274 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5275 __attribute__((unused)) struct cmdline *cl,
5276 __attribute__((unused)) void *data)
5278 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5279 struct rte_eth_pfc_conf pfc_conf;
5280 int rx_fc_enable, tx_fc_enable;
5284 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5285 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5286 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5287 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5289 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5290 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5293 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5294 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5295 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5296 pfc_conf.fc.high_water = res->high_water;
5297 pfc_conf.fc.low_water = res->low_water;
5298 pfc_conf.fc.pause_time = res->pause_time;
5299 pfc_conf.priority = res->priority;
5301 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5303 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5306 cmdline_parse_token_string_t cmd_pfc_set_set =
5307 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5309 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5310 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5311 pfc_ctrl, "pfc_ctrl");
5312 cmdline_parse_token_string_t cmd_pfc_set_rx =
5313 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5315 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5316 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5317 rx_pfc_mode, "on#off");
5318 cmdline_parse_token_string_t cmd_pfc_set_tx =
5319 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5321 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5322 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5323 tx_pfc_mode, "on#off");
5324 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5325 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5326 high_water, UINT32);
5327 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5328 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5330 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5331 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5332 pause_time, UINT16);
5333 cmdline_parse_token_num_t cmd_pfc_set_priority =
5334 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5336 cmdline_parse_token_num_t cmd_pfc_set_portid =
5337 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5340 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5341 .f = cmd_priority_flow_ctrl_set_parsed,
5343 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5344 tx on|off high_water low_water pause_time priority port_id",
5346 (void *)&cmd_pfc_set_set,
5347 (void *)&cmd_pfc_set_flow_ctrl,
5348 (void *)&cmd_pfc_set_rx,
5349 (void *)&cmd_pfc_set_rx_mode,
5350 (void *)&cmd_pfc_set_tx,
5351 (void *)&cmd_pfc_set_tx_mode,
5352 (void *)&cmd_pfc_set_high_water,
5353 (void *)&cmd_pfc_set_low_water,
5354 (void *)&cmd_pfc_set_pause_time,
5355 (void *)&cmd_pfc_set_priority,
5356 (void *)&cmd_pfc_set_portid,
5361 /* *** RESET CONFIGURATION *** */
5362 struct cmd_reset_result {
5363 cmdline_fixed_string_t reset;
5364 cmdline_fixed_string_t def;
5367 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5369 __attribute__((unused)) void *data)
5371 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5372 set_def_fwd_config();
5375 cmdline_parse_token_string_t cmd_reset_set =
5376 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5377 cmdline_parse_token_string_t cmd_reset_def =
5378 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5381 cmdline_parse_inst_t cmd_reset = {
5382 .f = cmd_reset_parsed,
5384 .help_str = "set default: reset default forwarding configuration",
5386 (void *)&cmd_reset_set,
5387 (void *)&cmd_reset_def,
5392 /* *** START FORWARDING *** */
5393 struct cmd_start_result {
5394 cmdline_fixed_string_t start;
5397 cmdline_parse_token_string_t cmd_start_start =
5398 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5400 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5401 __attribute__((unused)) struct cmdline *cl,
5402 __attribute__((unused)) void *data)
5404 start_packet_forwarding(0);
5407 cmdline_parse_inst_t cmd_start = {
5408 .f = cmd_start_parsed,
5410 .help_str = "start packet forwarding",
5412 (void *)&cmd_start_start,
5417 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5418 struct cmd_start_tx_first_result {
5419 cmdline_fixed_string_t start;
5420 cmdline_fixed_string_t tx_first;
5424 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5425 __attribute__((unused)) struct cmdline *cl,
5426 __attribute__((unused)) void *data)
5428 start_packet_forwarding(1);
5431 cmdline_parse_token_string_t cmd_start_tx_first_start =
5432 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5434 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5435 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5436 tx_first, "tx_first");
5438 cmdline_parse_inst_t cmd_start_tx_first = {
5439 .f = cmd_start_tx_first_parsed,
5441 .help_str = "start packet forwarding, after sending 1 burst of packets",
5443 (void *)&cmd_start_tx_first_start,
5444 (void *)&cmd_start_tx_first_tx_first,
5449 /* *** SET LINK UP *** */
5450 struct cmd_set_link_up_result {
5451 cmdline_fixed_string_t set;
5452 cmdline_fixed_string_t link_up;
5453 cmdline_fixed_string_t port;
5457 cmdline_parse_token_string_t cmd_set_link_up_set =
5458 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5459 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5460 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5462 cmdline_parse_token_string_t cmd_set_link_up_port =
5463 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5464 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5465 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5467 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5468 __attribute__((unused)) struct cmdline *cl,
5469 __attribute__((unused)) void *data)
5471 struct cmd_set_link_up_result *res = parsed_result;
5472 dev_set_link_up(res->port_id);
5475 cmdline_parse_inst_t cmd_set_link_up = {
5476 .f = cmd_set_link_up_parsed,
5478 .help_str = "set link-up port (port id)",
5480 (void *)&cmd_set_link_up_set,
5481 (void *)&cmd_set_link_up_link_up,
5482 (void *)&cmd_set_link_up_port,
5483 (void *)&cmd_set_link_up_port_id,
5488 /* *** SET LINK DOWN *** */
5489 struct cmd_set_link_down_result {
5490 cmdline_fixed_string_t set;
5491 cmdline_fixed_string_t link_down;
5492 cmdline_fixed_string_t port;
5496 cmdline_parse_token_string_t cmd_set_link_down_set =
5497 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5498 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5499 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5501 cmdline_parse_token_string_t cmd_set_link_down_port =
5502 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5503 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5504 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5506 static void cmd_set_link_down_parsed(
5507 __attribute__((unused)) void *parsed_result,
5508 __attribute__((unused)) struct cmdline *cl,
5509 __attribute__((unused)) void *data)
5511 struct cmd_set_link_down_result *res = parsed_result;
5512 dev_set_link_down(res->port_id);
5515 cmdline_parse_inst_t cmd_set_link_down = {
5516 .f = cmd_set_link_down_parsed,
5518 .help_str = "set link-down port (port id)",
5520 (void *)&cmd_set_link_down_set,
5521 (void *)&cmd_set_link_down_link_down,
5522 (void *)&cmd_set_link_down_port,
5523 (void *)&cmd_set_link_down_port_id,
5528 /* *** SHOW CFG *** */
5529 struct cmd_showcfg_result {
5530 cmdline_fixed_string_t show;
5531 cmdline_fixed_string_t cfg;
5532 cmdline_fixed_string_t what;
5535 static void cmd_showcfg_parsed(void *parsed_result,
5536 __attribute__((unused)) struct cmdline *cl,
5537 __attribute__((unused)) void *data)
5539 struct cmd_showcfg_result *res = parsed_result;
5540 if (!strcmp(res->what, "rxtx"))
5541 rxtx_config_display();
5542 else if (!strcmp(res->what, "cores"))
5543 fwd_lcores_config_display();
5544 else if (!strcmp(res->what, "fwd"))
5545 fwd_config_display();
5548 cmdline_parse_token_string_t cmd_showcfg_show =
5549 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5550 cmdline_parse_token_string_t cmd_showcfg_port =
5551 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5552 cmdline_parse_token_string_t cmd_showcfg_what =
5553 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5556 cmdline_parse_inst_t cmd_showcfg = {
5557 .f = cmd_showcfg_parsed,
5559 .help_str = "show config rxtx|cores|fwd",
5561 (void *)&cmd_showcfg_show,
5562 (void *)&cmd_showcfg_port,
5563 (void *)&cmd_showcfg_what,
5568 /* *** SHOW ALL PORT INFO *** */
5569 struct cmd_showportall_result {
5570 cmdline_fixed_string_t show;
5571 cmdline_fixed_string_t port;
5572 cmdline_fixed_string_t what;
5573 cmdline_fixed_string_t all;
5576 static void cmd_showportall_parsed(void *parsed_result,
5577 __attribute__((unused)) struct cmdline *cl,
5578 __attribute__((unused)) void *data)
5582 struct cmd_showportall_result *res = parsed_result;
5583 if (!strcmp(res->show, "clear")) {
5584 if (!strcmp(res->what, "stats"))
5585 for (i = 0; i < nb_ports; i++)
5587 else if (!strcmp(res->what, "xstats"))
5588 for (i = 0; i < nb_ports; i++)
5589 nic_xstats_clear(i);
5590 } else if (!strcmp(res->what, "info"))
5591 for (i = 0; i < nb_ports; i++)
5592 port_infos_display(i);
5593 else if (!strcmp(res->what, "stats"))
5594 for (i = 0; i < nb_ports; i++)
5595 nic_stats_display(i);
5596 else if (!strcmp(res->what, "xstats"))
5597 for (i = 0; i < nb_ports; i++)
5598 nic_xstats_display(i);
5599 else if (!strcmp(res->what, "fdir"))
5600 for (i = 0; i < nb_ports; i++)
5602 else if (!strcmp(res->what, "stat_qmap"))
5603 for (i = 0; i < nb_ports; i++)
5604 nic_stats_mapping_display(i);
5607 cmdline_parse_token_string_t cmd_showportall_show =
5608 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5610 cmdline_parse_token_string_t cmd_showportall_port =
5611 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5612 cmdline_parse_token_string_t cmd_showportall_what =
5613 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5614 "info#stats#xstats#fdir#stat_qmap");
5615 cmdline_parse_token_string_t cmd_showportall_all =
5616 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5617 cmdline_parse_inst_t cmd_showportall = {
5618 .f = cmd_showportall_parsed,
5620 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5622 (void *)&cmd_showportall_show,
5623 (void *)&cmd_showportall_port,
5624 (void *)&cmd_showportall_what,
5625 (void *)&cmd_showportall_all,
5630 /* *** SHOW PORT INFO *** */
5631 struct cmd_showport_result {
5632 cmdline_fixed_string_t show;
5633 cmdline_fixed_string_t port;
5634 cmdline_fixed_string_t what;
5638 static void cmd_showport_parsed(void *parsed_result,
5639 __attribute__((unused)) struct cmdline *cl,
5640 __attribute__((unused)) void *data)
5642 struct cmd_showport_result *res = parsed_result;
5643 if (!strcmp(res->show, "clear")) {
5644 if (!strcmp(res->what, "stats"))
5645 nic_stats_clear(res->portnum);
5646 else if (!strcmp(res->what, "xstats"))
5647 nic_xstats_clear(res->portnum);
5648 } else if (!strcmp(res->what, "info"))
5649 port_infos_display(res->portnum);
5650 else if (!strcmp(res->what, "stats"))
5651 nic_stats_display(res->portnum);
5652 else if (!strcmp(res->what, "xstats"))
5653 nic_xstats_display(res->portnum);
5654 else if (!strcmp(res->what, "fdir"))
5655 fdir_get_infos(res->portnum);
5656 else if (!strcmp(res->what, "stat_qmap"))
5657 nic_stats_mapping_display(res->portnum);
5660 cmdline_parse_token_string_t cmd_showport_show =
5661 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5663 cmdline_parse_token_string_t cmd_showport_port =
5664 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5665 cmdline_parse_token_string_t cmd_showport_what =
5666 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5667 "info#stats#xstats#fdir#stat_qmap");
5668 cmdline_parse_token_num_t cmd_showport_portnum =
5669 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5671 cmdline_parse_inst_t cmd_showport = {
5672 .f = cmd_showport_parsed,
5674 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5676 (void *)&cmd_showport_show,
5677 (void *)&cmd_showport_port,
5678 (void *)&cmd_showport_what,
5679 (void *)&cmd_showport_portnum,
5684 /* *** READ PORT REGISTER *** */
5685 struct cmd_read_reg_result {
5686 cmdline_fixed_string_t read;
5687 cmdline_fixed_string_t reg;
5693 cmd_read_reg_parsed(void *parsed_result,
5694 __attribute__((unused)) struct cmdline *cl,
5695 __attribute__((unused)) void *data)
5697 struct cmd_read_reg_result *res = parsed_result;
5698 port_reg_display(res->port_id, res->reg_off);
5701 cmdline_parse_token_string_t cmd_read_reg_read =
5702 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5703 cmdline_parse_token_string_t cmd_read_reg_reg =
5704 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5705 cmdline_parse_token_num_t cmd_read_reg_port_id =
5706 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5707 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5708 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5710 cmdline_parse_inst_t cmd_read_reg = {
5711 .f = cmd_read_reg_parsed,
5713 .help_str = "read reg port_id reg_off",
5715 (void *)&cmd_read_reg_read,
5716 (void *)&cmd_read_reg_reg,
5717 (void *)&cmd_read_reg_port_id,
5718 (void *)&cmd_read_reg_reg_off,
5723 /* *** READ PORT REGISTER BIT FIELD *** */
5724 struct cmd_read_reg_bit_field_result {
5725 cmdline_fixed_string_t read;
5726 cmdline_fixed_string_t regfield;
5734 cmd_read_reg_bit_field_parsed(void *parsed_result,
5735 __attribute__((unused)) struct cmdline *cl,
5736 __attribute__((unused)) void *data)
5738 struct cmd_read_reg_bit_field_result *res = parsed_result;
5739 port_reg_bit_field_display(res->port_id, res->reg_off,
5740 res->bit1_pos, res->bit2_pos);
5743 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5744 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5746 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5747 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5748 regfield, "regfield");
5749 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5750 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5752 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5753 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5755 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5756 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5758 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5759 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5762 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5763 .f = cmd_read_reg_bit_field_parsed,
5765 .help_str = "read regfield port_id reg_off bit_x bit_y "
5766 "(read register bit field between bit_x and bit_y included)",
5768 (void *)&cmd_read_reg_bit_field_read,
5769 (void *)&cmd_read_reg_bit_field_regfield,
5770 (void *)&cmd_read_reg_bit_field_port_id,
5771 (void *)&cmd_read_reg_bit_field_reg_off,
5772 (void *)&cmd_read_reg_bit_field_bit1_pos,
5773 (void *)&cmd_read_reg_bit_field_bit2_pos,
5778 /* *** READ PORT REGISTER BIT *** */
5779 struct cmd_read_reg_bit_result {
5780 cmdline_fixed_string_t read;
5781 cmdline_fixed_string_t regbit;
5788 cmd_read_reg_bit_parsed(void *parsed_result,
5789 __attribute__((unused)) struct cmdline *cl,
5790 __attribute__((unused)) void *data)
5792 struct cmd_read_reg_bit_result *res = parsed_result;
5793 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5796 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5797 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5798 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5799 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5801 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5802 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5803 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5804 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5805 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5806 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5808 cmdline_parse_inst_t cmd_read_reg_bit = {
5809 .f = cmd_read_reg_bit_parsed,
5811 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5813 (void *)&cmd_read_reg_bit_read,
5814 (void *)&cmd_read_reg_bit_regbit,
5815 (void *)&cmd_read_reg_bit_port_id,
5816 (void *)&cmd_read_reg_bit_reg_off,
5817 (void *)&cmd_read_reg_bit_bit_pos,
5822 /* *** WRITE PORT REGISTER *** */
5823 struct cmd_write_reg_result {
5824 cmdline_fixed_string_t write;
5825 cmdline_fixed_string_t reg;
5832 cmd_write_reg_parsed(void *parsed_result,
5833 __attribute__((unused)) struct cmdline *cl,
5834 __attribute__((unused)) void *data)
5836 struct cmd_write_reg_result *res = parsed_result;
5837 port_reg_set(res->port_id, res->reg_off, res->value);
5840 cmdline_parse_token_string_t cmd_write_reg_write =
5841 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5842 cmdline_parse_token_string_t cmd_write_reg_reg =
5843 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5844 cmdline_parse_token_num_t cmd_write_reg_port_id =
5845 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5846 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5847 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5848 cmdline_parse_token_num_t cmd_write_reg_value =
5849 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5851 cmdline_parse_inst_t cmd_write_reg = {
5852 .f = cmd_write_reg_parsed,
5854 .help_str = "write reg port_id reg_off reg_value",
5856 (void *)&cmd_write_reg_write,
5857 (void *)&cmd_write_reg_reg,
5858 (void *)&cmd_write_reg_port_id,
5859 (void *)&cmd_write_reg_reg_off,
5860 (void *)&cmd_write_reg_value,
5865 /* *** WRITE PORT REGISTER BIT FIELD *** */
5866 struct cmd_write_reg_bit_field_result {
5867 cmdline_fixed_string_t write;
5868 cmdline_fixed_string_t regfield;
5877 cmd_write_reg_bit_field_parsed(void *parsed_result,
5878 __attribute__((unused)) struct cmdline *cl,
5879 __attribute__((unused)) void *data)
5881 struct cmd_write_reg_bit_field_result *res = parsed_result;
5882 port_reg_bit_field_set(res->port_id, res->reg_off,
5883 res->bit1_pos, res->bit2_pos, res->value);
5886 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5887 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5889 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5890 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5891 regfield, "regfield");
5892 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5893 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5895 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5896 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5898 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5899 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5901 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5902 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5904 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5905 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5908 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5909 .f = cmd_write_reg_bit_field_parsed,
5911 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5912 "(set register bit field between bit_x and bit_y included)",
5914 (void *)&cmd_write_reg_bit_field_write,
5915 (void *)&cmd_write_reg_bit_field_regfield,
5916 (void *)&cmd_write_reg_bit_field_port_id,
5917 (void *)&cmd_write_reg_bit_field_reg_off,
5918 (void *)&cmd_write_reg_bit_field_bit1_pos,
5919 (void *)&cmd_write_reg_bit_field_bit2_pos,
5920 (void *)&cmd_write_reg_bit_field_value,
5925 /* *** WRITE PORT REGISTER BIT *** */
5926 struct cmd_write_reg_bit_result {
5927 cmdline_fixed_string_t write;
5928 cmdline_fixed_string_t regbit;
5936 cmd_write_reg_bit_parsed(void *parsed_result,
5937 __attribute__((unused)) struct cmdline *cl,
5938 __attribute__((unused)) void *data)
5940 struct cmd_write_reg_bit_result *res = parsed_result;
5941 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5944 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5945 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5947 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5948 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5950 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5951 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5952 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5953 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5954 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5955 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5956 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5957 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5959 cmdline_parse_inst_t cmd_write_reg_bit = {
5960 .f = cmd_write_reg_bit_parsed,
5962 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5964 (void *)&cmd_write_reg_bit_write,
5965 (void *)&cmd_write_reg_bit_regbit,
5966 (void *)&cmd_write_reg_bit_port_id,
5967 (void *)&cmd_write_reg_bit_reg_off,
5968 (void *)&cmd_write_reg_bit_bit_pos,
5969 (void *)&cmd_write_reg_bit_value,
5974 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5975 struct cmd_read_rxd_txd_result {
5976 cmdline_fixed_string_t read;
5977 cmdline_fixed_string_t rxd_txd;
5984 cmd_read_rxd_txd_parsed(void *parsed_result,
5985 __attribute__((unused)) struct cmdline *cl,
5986 __attribute__((unused)) void *data)
5988 struct cmd_read_rxd_txd_result *res = parsed_result;
5990 if (!strcmp(res->rxd_txd, "rxd"))
5991 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5992 else if (!strcmp(res->rxd_txd, "txd"))
5993 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5996 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5997 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5998 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5999 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6001 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6002 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6003 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6004 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6005 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6006 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6008 cmdline_parse_inst_t cmd_read_rxd_txd = {
6009 .f = cmd_read_rxd_txd_parsed,
6011 .help_str = "read rxd|txd port_id queue_id rxd_id",
6013 (void *)&cmd_read_rxd_txd_read,
6014 (void *)&cmd_read_rxd_txd_rxd_txd,
6015 (void *)&cmd_read_rxd_txd_port_id,
6016 (void *)&cmd_read_rxd_txd_queue_id,
6017 (void *)&cmd_read_rxd_txd_desc_id,
6023 struct cmd_quit_result {
6024 cmdline_fixed_string_t quit;
6027 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6029 __attribute__((unused)) void *data)
6035 cmdline_parse_token_string_t cmd_quit_quit =
6036 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6038 cmdline_parse_inst_t cmd_quit = {
6039 .f = cmd_quit_parsed,
6041 .help_str = "exit application",
6043 (void *)&cmd_quit_quit,
6048 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6049 struct cmd_mac_addr_result {
6050 cmdline_fixed_string_t mac_addr_cmd;
6051 cmdline_fixed_string_t what;
6053 struct ether_addr address;
6056 static void cmd_mac_addr_parsed(void *parsed_result,
6057 __attribute__((unused)) struct cmdline *cl,
6058 __attribute__((unused)) void *data)
6060 struct cmd_mac_addr_result *res = parsed_result;
6063 if (strcmp(res->what, "add") == 0)
6064 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6066 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6068 /* check the return value and print it if is < 0 */
6070 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6074 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6075 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6077 cmdline_parse_token_string_t cmd_mac_addr_what =
6078 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6080 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6081 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6082 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6083 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6085 cmdline_parse_inst_t cmd_mac_addr = {
6086 .f = cmd_mac_addr_parsed,
6088 .help_str = "mac_addr add|remove X <address>: "
6089 "add/remove MAC address on port X",
6091 (void *)&cmd_mac_addr_cmd,
6092 (void *)&cmd_mac_addr_what,
6093 (void *)&cmd_mac_addr_portnum,
6094 (void *)&cmd_mac_addr_addr,
6100 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6101 struct cmd_set_qmap_result {
6102 cmdline_fixed_string_t set;
6103 cmdline_fixed_string_t qmap;
6104 cmdline_fixed_string_t what;
6111 cmd_set_qmap_parsed(void *parsed_result,
6112 __attribute__((unused)) struct cmdline *cl,
6113 __attribute__((unused)) void *data)
6115 struct cmd_set_qmap_result *res = parsed_result;
6116 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6118 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6121 cmdline_parse_token_string_t cmd_setqmap_set =
6122 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6124 cmdline_parse_token_string_t cmd_setqmap_qmap =
6125 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6127 cmdline_parse_token_string_t cmd_setqmap_what =
6128 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6130 cmdline_parse_token_num_t cmd_setqmap_portid =
6131 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6133 cmdline_parse_token_num_t cmd_setqmap_queueid =
6134 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6136 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6137 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6140 cmdline_parse_inst_t cmd_set_qmap = {
6141 .f = cmd_set_qmap_parsed,
6143 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6145 (void *)&cmd_setqmap_set,
6146 (void *)&cmd_setqmap_qmap,
6147 (void *)&cmd_setqmap_what,
6148 (void *)&cmd_setqmap_portid,
6149 (void *)&cmd_setqmap_queueid,
6150 (void *)&cmd_setqmap_mapvalue,
6155 /* *** CONFIGURE UNICAST HASH TABLE *** */
6156 struct cmd_set_uc_hash_table {
6157 cmdline_fixed_string_t set;
6158 cmdline_fixed_string_t port;
6160 cmdline_fixed_string_t what;
6161 struct ether_addr address;
6162 cmdline_fixed_string_t mode;
6166 cmd_set_uc_hash_parsed(void *parsed_result,
6167 __attribute__((unused)) struct cmdline *cl,
6168 __attribute__((unused)) void *data)
6171 struct cmd_set_uc_hash_table *res = parsed_result;
6173 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6175 if (strcmp(res->what, "uta") == 0)
6176 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6177 &res->address,(uint8_t)is_on);
6179 printf("bad unicast hash table parameter, return code = %d \n", ret);
6183 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6184 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6186 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6187 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6189 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6190 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6192 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6193 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6195 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6196 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6198 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6199 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6202 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6203 .f = cmd_set_uc_hash_parsed,
6205 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6207 (void *)&cmd_set_uc_hash_set,
6208 (void *)&cmd_set_uc_hash_port,
6209 (void *)&cmd_set_uc_hash_portid,
6210 (void *)&cmd_set_uc_hash_what,
6211 (void *)&cmd_set_uc_hash_mac,
6212 (void *)&cmd_set_uc_hash_mode,
6217 struct cmd_set_uc_all_hash_table {
6218 cmdline_fixed_string_t set;
6219 cmdline_fixed_string_t port;
6221 cmdline_fixed_string_t what;
6222 cmdline_fixed_string_t value;
6223 cmdline_fixed_string_t mode;
6227 cmd_set_uc_all_hash_parsed(void *parsed_result,
6228 __attribute__((unused)) struct cmdline *cl,
6229 __attribute__((unused)) void *data)
6232 struct cmd_set_uc_all_hash_table *res = parsed_result;
6234 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6236 if ((strcmp(res->what, "uta") == 0) &&
6237 (strcmp(res->value, "all") == 0))
6238 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6240 printf("bad unicast hash table parameter,"
6241 "return code = %d \n", ret);
6244 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6245 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6247 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6248 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6250 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6251 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6253 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6254 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6256 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6257 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6259 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6260 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6263 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6264 .f = cmd_set_uc_all_hash_parsed,
6266 .help_str = "set port X uta all on|off (X = port number)",
6268 (void *)&cmd_set_uc_all_hash_set,
6269 (void *)&cmd_set_uc_all_hash_port,
6270 (void *)&cmd_set_uc_all_hash_portid,
6271 (void *)&cmd_set_uc_all_hash_what,
6272 (void *)&cmd_set_uc_all_hash_value,
6273 (void *)&cmd_set_uc_all_hash_mode,
6278 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6279 struct cmd_set_vf_macvlan_filter {
6280 cmdline_fixed_string_t set;
6281 cmdline_fixed_string_t port;
6283 cmdline_fixed_string_t vf;
6285 struct ether_addr address;
6286 cmdline_fixed_string_t filter_type;
6287 cmdline_fixed_string_t mode;
6291 cmd_set_vf_macvlan_parsed(void *parsed_result,
6292 __attribute__((unused)) struct cmdline *cl,
6293 __attribute__((unused)) void *data)
6296 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6297 struct rte_eth_mac_filter filter;
6299 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6301 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6303 /* set VF MAC filter */
6307 filter.dst_id = res->vf_id;
6309 if (!strcmp(res->filter_type, "exact-mac"))
6310 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6311 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6312 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6313 else if (!strcmp(res->filter_type, "hashmac"))
6314 filter.filter_type = RTE_MAC_HASH_MATCH;
6315 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6316 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6318 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6321 ret = rte_eth_dev_filter_ctrl(res->port_id,
6322 RTE_ETH_FILTER_MACVLAN,
6326 ret = rte_eth_dev_filter_ctrl(res->port_id,
6327 RTE_ETH_FILTER_MACVLAN,
6328 RTE_ETH_FILTER_DELETE,
6332 printf("bad set MAC hash parameter, return code = %d\n", ret);
6336 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6337 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6339 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6340 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6342 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6343 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6345 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6346 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6348 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6349 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6351 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6352 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6354 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6355 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6356 filter_type, "exact-mac#exact-mac-vlan"
6357 "#hashmac#hashmac-vlan");
6358 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6359 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6362 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6363 .f = cmd_set_vf_macvlan_parsed,
6365 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6366 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6368 "exact match rule:exact match of MAC or MAC and VLAN; "
6369 "hash match rule: hash match of MAC and exact match "
6372 (void *)&cmd_set_vf_macvlan_set,
6373 (void *)&cmd_set_vf_macvlan_port,
6374 (void *)&cmd_set_vf_macvlan_portid,
6375 (void *)&cmd_set_vf_macvlan_vf,
6376 (void *)&cmd_set_vf_macvlan_vf_id,
6377 (void *)&cmd_set_vf_macvlan_mac,
6378 (void *)&cmd_set_vf_macvlan_filter_type,
6379 (void *)&cmd_set_vf_macvlan_mode,
6384 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6385 struct cmd_set_vf_traffic {
6386 cmdline_fixed_string_t set;
6387 cmdline_fixed_string_t port;
6389 cmdline_fixed_string_t vf;
6391 cmdline_fixed_string_t what;
6392 cmdline_fixed_string_t mode;
6396 cmd_set_vf_traffic_parsed(void *parsed_result,
6397 __attribute__((unused)) struct cmdline *cl,
6398 __attribute__((unused)) void *data)
6400 struct cmd_set_vf_traffic *res = parsed_result;
6401 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6402 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6404 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6407 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6408 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6410 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6411 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6413 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6414 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6416 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6417 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6419 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6420 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6422 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6423 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6425 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6426 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6429 cmdline_parse_inst_t cmd_set_vf_traffic = {
6430 .f = cmd_set_vf_traffic_parsed,
6432 .help_str = "set port X vf Y rx|tx on|off"
6433 "(X = port number,Y = vf id)",
6435 (void *)&cmd_setvf_traffic_set,
6436 (void *)&cmd_setvf_traffic_port,
6437 (void *)&cmd_setvf_traffic_portid,
6438 (void *)&cmd_setvf_traffic_vf,
6439 (void *)&cmd_setvf_traffic_vfid,
6440 (void *)&cmd_setvf_traffic_what,
6441 (void *)&cmd_setvf_traffic_mode,
6446 /* *** CONFIGURE VF RECEIVE MODE *** */
6447 struct cmd_set_vf_rxmode {
6448 cmdline_fixed_string_t set;
6449 cmdline_fixed_string_t port;
6451 cmdline_fixed_string_t vf;
6453 cmdline_fixed_string_t what;
6454 cmdline_fixed_string_t mode;
6455 cmdline_fixed_string_t on;
6459 cmd_set_vf_rxmode_parsed(void *parsed_result,
6460 __attribute__((unused)) struct cmdline *cl,
6461 __attribute__((unused)) void *data)
6464 uint16_t rx_mode = 0;
6465 struct cmd_set_vf_rxmode *res = parsed_result;
6467 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6468 if (!strcmp(res->what,"rxmode")) {
6469 if (!strcmp(res->mode, "AUPE"))
6470 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6471 else if (!strcmp(res->mode, "ROPE"))
6472 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6473 else if (!strcmp(res->mode, "BAM"))
6474 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6475 else if (!strncmp(res->mode, "MPE",3))
6476 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6479 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6481 printf("bad VF receive mode parameter, return code = %d \n",
6485 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6486 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6488 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6491 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6492 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6494 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6495 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6497 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6498 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6500 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6501 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6503 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6504 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6505 mode, "AUPE#ROPE#BAM#MPE");
6506 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6507 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6510 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6511 .f = cmd_set_vf_rxmode_parsed,
6513 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6515 (void *)&cmd_set_vf_rxmode_set,
6516 (void *)&cmd_set_vf_rxmode_port,
6517 (void *)&cmd_set_vf_rxmode_portid,
6518 (void *)&cmd_set_vf_rxmode_vf,
6519 (void *)&cmd_set_vf_rxmode_vfid,
6520 (void *)&cmd_set_vf_rxmode_what,
6521 (void *)&cmd_set_vf_rxmode_mode,
6522 (void *)&cmd_set_vf_rxmode_on,
6527 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6528 struct cmd_vf_mac_addr_result {
6529 cmdline_fixed_string_t mac_addr_cmd;
6530 cmdline_fixed_string_t what;
6531 cmdline_fixed_string_t port;
6533 cmdline_fixed_string_t vf;
6535 struct ether_addr address;
6538 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6539 __attribute__((unused)) struct cmdline *cl,
6540 __attribute__((unused)) void *data)
6542 struct cmd_vf_mac_addr_result *res = parsed_result;
6545 if (strcmp(res->what, "add") == 0)
6546 ret = rte_eth_dev_mac_addr_add(res->port_num,
6547 &res->address, res->vf_num);
6549 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6553 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6554 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6555 mac_addr_cmd,"mac_addr");
6556 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6557 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6559 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6560 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6562 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6563 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6565 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6566 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6568 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6569 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6571 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6572 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6575 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6576 .f = cmd_vf_mac_addr_parsed,
6578 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6579 "Y = VF number)add MAC address filtering for a VF on port X",
6581 (void *)&cmd_vf_mac_addr_cmd,
6582 (void *)&cmd_vf_mac_addr_what,
6583 (void *)&cmd_vf_mac_addr_port,
6584 (void *)&cmd_vf_mac_addr_portnum,
6585 (void *)&cmd_vf_mac_addr_vf,
6586 (void *)&cmd_vf_mac_addr_vfnum,
6587 (void *)&cmd_vf_mac_addr_addr,
6592 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6593 struct cmd_vf_rx_vlan_filter {
6594 cmdline_fixed_string_t rx_vlan;
6595 cmdline_fixed_string_t what;
6597 cmdline_fixed_string_t port;
6599 cmdline_fixed_string_t vf;
6604 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6605 __attribute__((unused)) struct cmdline *cl,
6606 __attribute__((unused)) void *data)
6608 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6610 if (!strcmp(res->what, "add"))
6611 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6613 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6616 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6617 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6618 rx_vlan, "rx_vlan");
6619 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6620 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6622 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6623 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6625 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6626 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6628 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6629 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6631 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6632 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6634 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6635 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6638 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6639 .f = cmd_vf_rx_vlan_filter_parsed,
6641 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6642 "Y = port number,Z = hexadecimal VF mask)",
6644 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6645 (void *)&cmd_vf_rx_vlan_filter_what,
6646 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6647 (void *)&cmd_vf_rx_vlan_filter_port,
6648 (void *)&cmd_vf_rx_vlan_filter_portid,
6649 (void *)&cmd_vf_rx_vlan_filter_vf,
6650 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6655 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6656 struct cmd_queue_rate_limit_result {
6657 cmdline_fixed_string_t set;
6658 cmdline_fixed_string_t port;
6660 cmdline_fixed_string_t queue;
6662 cmdline_fixed_string_t rate;
6666 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6667 __attribute__((unused)) struct cmdline *cl,
6668 __attribute__((unused)) void *data)
6670 struct cmd_queue_rate_limit_result *res = parsed_result;
6673 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6674 && (strcmp(res->queue, "queue") == 0)
6675 && (strcmp(res->rate, "rate") == 0))
6676 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6679 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6683 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6684 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6686 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6687 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6689 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6690 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6692 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6693 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6695 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6696 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6698 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6699 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6701 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6702 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6705 cmdline_parse_inst_t cmd_queue_rate_limit = {
6706 .f = cmd_queue_rate_limit_parsed,
6708 .help_str = "set port X queue Y rate Z:(X = port number,"
6709 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6711 (void *)&cmd_queue_rate_limit_set,
6712 (void *)&cmd_queue_rate_limit_port,
6713 (void *)&cmd_queue_rate_limit_portnum,
6714 (void *)&cmd_queue_rate_limit_queue,
6715 (void *)&cmd_queue_rate_limit_queuenum,
6716 (void *)&cmd_queue_rate_limit_rate,
6717 (void *)&cmd_queue_rate_limit_ratenum,
6722 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6723 struct cmd_vf_rate_limit_result {
6724 cmdline_fixed_string_t set;
6725 cmdline_fixed_string_t port;
6727 cmdline_fixed_string_t vf;
6729 cmdline_fixed_string_t rate;
6731 cmdline_fixed_string_t q_msk;
6735 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6736 __attribute__((unused)) struct cmdline *cl,
6737 __attribute__((unused)) void *data)
6739 struct cmd_vf_rate_limit_result *res = parsed_result;
6742 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6743 && (strcmp(res->vf, "vf") == 0)
6744 && (strcmp(res->rate, "rate") == 0)
6745 && (strcmp(res->q_msk, "queue_mask") == 0))
6746 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6747 res->rate_num, res->q_msk_val);
6749 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6753 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6754 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6756 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6757 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6759 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6760 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6762 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6763 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6765 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6766 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6768 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6769 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6771 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6772 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6774 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6775 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6776 q_msk, "queue_mask");
6777 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6778 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6781 cmdline_parse_inst_t cmd_vf_rate_limit = {
6782 .f = cmd_vf_rate_limit_parsed,
6784 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6785 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6786 "for queues of VF on port X",
6788 (void *)&cmd_vf_rate_limit_set,
6789 (void *)&cmd_vf_rate_limit_port,
6790 (void *)&cmd_vf_rate_limit_portnum,
6791 (void *)&cmd_vf_rate_limit_vf,
6792 (void *)&cmd_vf_rate_limit_vfnum,
6793 (void *)&cmd_vf_rate_limit_rate,
6794 (void *)&cmd_vf_rate_limit_ratenum,
6795 (void *)&cmd_vf_rate_limit_q_msk,
6796 (void *)&cmd_vf_rate_limit_q_msk_val,
6801 /* *** ADD TUNNEL FILTER OF A PORT *** */
6802 struct cmd_tunnel_filter_result {
6803 cmdline_fixed_string_t cmd;
6804 cmdline_fixed_string_t what;
6806 struct ether_addr outer_mac;
6807 struct ether_addr inner_mac;
6808 cmdline_ipaddr_t ip_value;
6809 uint16_t inner_vlan;
6810 cmdline_fixed_string_t tunnel_type;
6811 cmdline_fixed_string_t filter_type;
6817 cmd_tunnel_filter_parsed(void *parsed_result,
6818 __attribute__((unused)) struct cmdline *cl,
6819 __attribute__((unused)) void *data)
6821 struct cmd_tunnel_filter_result *res = parsed_result;
6822 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6825 tunnel_filter_conf.outer_mac = &res->outer_mac;
6826 tunnel_filter_conf.inner_mac = &res->inner_mac;
6827 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6829 if (res->ip_value.family == AF_INET) {
6830 tunnel_filter_conf.ip_addr.ipv4_addr =
6831 res->ip_value.addr.ipv4.s_addr;
6832 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6834 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6835 &(res->ip_value.addr.ipv6),
6836 sizeof(struct in6_addr));
6837 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6840 if (!strcmp(res->filter_type, "imac-ivlan"))
6841 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6842 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6843 tunnel_filter_conf.filter_type =
6844 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6845 else if (!strcmp(res->filter_type, "imac-tenid"))
6846 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6847 else if (!strcmp(res->filter_type, "imac"))
6848 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6849 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6850 tunnel_filter_conf.filter_type =
6851 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6853 printf("The filter type is not supported");
6857 if (!strcmp(res->tunnel_type, "vxlan"))
6858 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6860 printf("Only VXLAN is supported now.\n");
6864 tunnel_filter_conf.tenant_id = res->tenant_id;
6865 tunnel_filter_conf.queue_id = res->queue_num;
6866 if (!strcmp(res->what, "add"))
6867 ret = rte_eth_dev_filter_ctrl(res->port_id,
6868 RTE_ETH_FILTER_TUNNEL,
6870 &tunnel_filter_conf);
6872 ret = rte_eth_dev_filter_ctrl(res->port_id,
6873 RTE_ETH_FILTER_TUNNEL,
6874 RTE_ETH_FILTER_DELETE,
6875 &tunnel_filter_conf);
6877 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6881 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6882 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6883 cmd, "tunnel_filter");
6884 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6885 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6887 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6888 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6890 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6891 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6893 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6894 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6896 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6897 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6898 inner_vlan, UINT16);
6899 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6900 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6902 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6903 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6904 tunnel_type, "vxlan");
6906 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6907 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6908 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6909 "imac#omac-imac-tenid");
6910 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6911 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6913 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6914 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6917 cmdline_parse_inst_t cmd_tunnel_filter = {
6918 .f = cmd_tunnel_filter_parsed,
6920 .help_str = "add/rm tunnel filter of a port: "
6921 "tunnel_filter add port_id outer_mac inner_mac ip "
6922 "inner_vlan tunnel_type(vxlan) filter_type "
6923 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6924 "imac|omac-imac-tenid) "
6925 "tenant_id queue_num",
6927 (void *)&cmd_tunnel_filter_cmd,
6928 (void *)&cmd_tunnel_filter_what,
6929 (void *)&cmd_tunnel_filter_port_id,
6930 (void *)&cmd_tunnel_filter_outer_mac,
6931 (void *)&cmd_tunnel_filter_inner_mac,
6932 (void *)&cmd_tunnel_filter_ip_value,
6933 (void *)&cmd_tunnel_filter_innner_vlan,
6934 (void *)&cmd_tunnel_filter_tunnel_type,
6935 (void *)&cmd_tunnel_filter_filter_type,
6936 (void *)&cmd_tunnel_filter_tenant_id,
6937 (void *)&cmd_tunnel_filter_queue_num,
6942 /* *** CONFIGURE TUNNEL UDP PORT *** */
6943 struct cmd_tunnel_udp_config {
6944 cmdline_fixed_string_t cmd;
6945 cmdline_fixed_string_t what;
6951 cmd_tunnel_udp_config_parsed(void *parsed_result,
6952 __attribute__((unused)) struct cmdline *cl,
6953 __attribute__((unused)) void *data)
6955 struct cmd_tunnel_udp_config *res = parsed_result;
6956 struct rte_eth_udp_tunnel tunnel_udp;
6959 tunnel_udp.udp_port = res->udp_port;
6961 if (!strcmp(res->cmd, "rx_vxlan_port"))
6962 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6964 if (!strcmp(res->what, "add"))
6965 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6967 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6970 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6973 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6974 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6975 cmd, "rx_vxlan_port");
6976 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6977 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6979 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6980 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6982 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6983 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6986 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6987 .f = cmd_tunnel_udp_config_parsed,
6989 .help_str = "add/rm an tunneling UDP port filter: "
6990 "rx_vxlan_port add udp_port port_id",
6992 (void *)&cmd_tunnel_udp_config_cmd,
6993 (void *)&cmd_tunnel_udp_config_what,
6994 (void *)&cmd_tunnel_udp_config_udp_port,
6995 (void *)&cmd_tunnel_udp_config_port_id,
7000 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7001 struct cmd_set_mirror_mask_result {
7002 cmdline_fixed_string_t set;
7003 cmdline_fixed_string_t port;
7005 cmdline_fixed_string_t mirror;
7007 cmdline_fixed_string_t what;
7008 cmdline_fixed_string_t value;
7009 cmdline_fixed_string_t dstpool;
7011 cmdline_fixed_string_t on;
7014 cmdline_parse_token_string_t cmd_mirror_mask_set =
7015 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7017 cmdline_parse_token_string_t cmd_mirror_mask_port =
7018 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7020 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7021 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7023 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7024 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7025 mirror, "mirror-rule");
7026 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7027 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7029 cmdline_parse_token_string_t cmd_mirror_mask_what =
7030 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7031 what, "pool-mirror#vlan-mirror");
7032 cmdline_parse_token_string_t cmd_mirror_mask_value =
7033 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7035 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7036 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7037 dstpool, "dst-pool");
7038 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7039 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7041 cmdline_parse_token_string_t cmd_mirror_mask_on =
7042 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7046 cmd_set_mirror_mask_parsed(void *parsed_result,
7047 __attribute__((unused)) struct cmdline *cl,
7048 __attribute__((unused)) void *data)
7051 struct cmd_set_mirror_mask_result *res = parsed_result;
7052 struct rte_eth_vmdq_mirror_conf mr_conf;
7054 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
7056 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
7058 mr_conf.dst_pool = res->dstpool_id;
7060 if (!strcmp(res->what, "pool-mirror")) {
7061 mr_conf.pool_mask = strtoull(res->value,NULL,16);
7062 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
7063 } else if(!strcmp(res->what, "vlan-mirror")) {
7064 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
7065 nb_item = parse_item_list(res->value, "core",
7066 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
7070 for(i=0; i < nb_item; i++) {
7071 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7072 printf("Invalid vlan_id: must be < 4096\n");
7076 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7077 mr_conf.vlan.vlan_mask |= 1ULL << i;
7081 if(!strcmp(res->on, "on"))
7082 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7085 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7088 printf("mirror rule add error: (%s)\n", strerror(-ret));
7091 cmdline_parse_inst_t cmd_set_mirror_mask = {
7092 .f = cmd_set_mirror_mask_parsed,
7094 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
7095 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7097 (void *)&cmd_mirror_mask_set,
7098 (void *)&cmd_mirror_mask_port,
7099 (void *)&cmd_mirror_mask_portid,
7100 (void *)&cmd_mirror_mask_mirror,
7101 (void *)&cmd_mirror_mask_ruleid,
7102 (void *)&cmd_mirror_mask_what,
7103 (void *)&cmd_mirror_mask_value,
7104 (void *)&cmd_mirror_mask_dstpool,
7105 (void *)&cmd_mirror_mask_poolid,
7106 (void *)&cmd_mirror_mask_on,
7111 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7112 struct cmd_set_mirror_link_result {
7113 cmdline_fixed_string_t set;
7114 cmdline_fixed_string_t port;
7116 cmdline_fixed_string_t mirror;
7118 cmdline_fixed_string_t what;
7119 cmdline_fixed_string_t dstpool;
7121 cmdline_fixed_string_t on;
7124 cmdline_parse_token_string_t cmd_mirror_link_set =
7125 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7127 cmdline_parse_token_string_t cmd_mirror_link_port =
7128 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7130 cmdline_parse_token_num_t cmd_mirror_link_portid =
7131 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7133 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7134 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7135 mirror, "mirror-rule");
7136 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7137 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7139 cmdline_parse_token_string_t cmd_mirror_link_what =
7140 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7141 what, "uplink-mirror#downlink-mirror");
7142 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7143 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7144 dstpool, "dst-pool");
7145 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7146 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7148 cmdline_parse_token_string_t cmd_mirror_link_on =
7149 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7153 cmd_set_mirror_link_parsed(void *parsed_result,
7154 __attribute__((unused)) struct cmdline *cl,
7155 __attribute__((unused)) void *data)
7158 struct cmd_set_mirror_link_result *res = parsed_result;
7159 struct rte_eth_vmdq_mirror_conf mr_conf;
7161 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
7162 if(!strcmp(res->what, "uplink-mirror")) {
7163 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
7164 }else if(!strcmp(res->what, "downlink-mirror"))
7165 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
7167 mr_conf.dst_pool = res->dstpool_id;
7169 if(!strcmp(res->on, "on"))
7170 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7173 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7176 /* check the return value and print it if is < 0 */
7178 printf("mirror rule add error: (%s)\n", strerror(-ret));
7182 cmdline_parse_inst_t cmd_set_mirror_link = {
7183 .f = cmd_set_mirror_link_parsed,
7185 .help_str = "set port X mirror-rule Y uplink-mirror|"
7186 "downlink-mirror dst-pool Z on|off",
7188 (void *)&cmd_mirror_link_set,
7189 (void *)&cmd_mirror_link_port,
7190 (void *)&cmd_mirror_link_portid,
7191 (void *)&cmd_mirror_link_mirror,
7192 (void *)&cmd_mirror_link_ruleid,
7193 (void *)&cmd_mirror_link_what,
7194 (void *)&cmd_mirror_link_dstpool,
7195 (void *)&cmd_mirror_link_poolid,
7196 (void *)&cmd_mirror_link_on,
7201 /* *** RESET VM MIRROR RULE *** */
7202 struct cmd_rm_mirror_rule_result {
7203 cmdline_fixed_string_t reset;
7204 cmdline_fixed_string_t port;
7206 cmdline_fixed_string_t mirror;
7210 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7211 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7213 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7214 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7216 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7217 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7219 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7220 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7221 mirror, "mirror-rule");
7222 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7223 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7227 cmd_reset_mirror_rule_parsed(void *parsed_result,
7228 __attribute__((unused)) struct cmdline *cl,
7229 __attribute__((unused)) void *data)
7232 struct cmd_set_mirror_link_result *res = parsed_result;
7234 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7236 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7239 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7240 .f = cmd_reset_mirror_rule_parsed,
7242 .help_str = "reset port X mirror-rule Y",
7244 (void *)&cmd_rm_mirror_rule_reset,
7245 (void *)&cmd_rm_mirror_rule_port,
7246 (void *)&cmd_rm_mirror_rule_portid,
7247 (void *)&cmd_rm_mirror_rule_mirror,
7248 (void *)&cmd_rm_mirror_rule_ruleid,
7253 /* ******************************************************************************** */
7255 struct cmd_dump_result {
7256 cmdline_fixed_string_t dump;
7260 dump_struct_sizes(void)
7262 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7263 DUMP_SIZE(struct rte_mbuf);
7264 DUMP_SIZE(struct rte_mempool);
7265 DUMP_SIZE(struct rte_ring);
7269 static void cmd_dump_parsed(void *parsed_result,
7270 __attribute__((unused)) struct cmdline *cl,
7271 __attribute__((unused)) void *data)
7273 struct cmd_dump_result *res = parsed_result;
7275 if (!strcmp(res->dump, "dump_physmem"))
7276 rte_dump_physmem_layout(stdout);
7277 else if (!strcmp(res->dump, "dump_memzone"))
7278 rte_memzone_dump(stdout);
7279 else if (!strcmp(res->dump, "dump_log_history"))
7280 rte_log_dump_history(stdout);
7281 else if (!strcmp(res->dump, "dump_struct_sizes"))
7282 dump_struct_sizes();
7283 else if (!strcmp(res->dump, "dump_ring"))
7284 rte_ring_list_dump(stdout);
7285 else if (!strcmp(res->dump, "dump_mempool"))
7286 rte_mempool_list_dump(stdout);
7287 else if (!strcmp(res->dump, "dump_devargs"))
7288 rte_eal_devargs_dump(stdout);
7291 cmdline_parse_token_string_t cmd_dump_dump =
7292 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7296 "dump_struct_sizes#"
7301 cmdline_parse_inst_t cmd_dump = {
7302 .f = cmd_dump_parsed, /* function to call */
7303 .data = NULL, /* 2nd arg of func */
7304 .help_str = "dump status",
7305 .tokens = { /* token list, NULL terminated */
7306 (void *)&cmd_dump_dump,
7311 /* ******************************************************************************** */
7313 struct cmd_dump_one_result {
7314 cmdline_fixed_string_t dump;
7315 cmdline_fixed_string_t name;
7318 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7319 __attribute__((unused)) void *data)
7321 struct cmd_dump_one_result *res = parsed_result;
7323 if (!strcmp(res->dump, "dump_ring")) {
7325 r = rte_ring_lookup(res->name);
7327 cmdline_printf(cl, "Cannot find ring\n");
7330 rte_ring_dump(stdout, r);
7331 } else if (!strcmp(res->dump, "dump_mempool")) {
7332 struct rte_mempool *mp;
7333 mp = rte_mempool_lookup(res->name);
7335 cmdline_printf(cl, "Cannot find mempool\n");
7338 rte_mempool_dump(stdout, mp);
7342 cmdline_parse_token_string_t cmd_dump_one_dump =
7343 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7344 "dump_ring#dump_mempool");
7346 cmdline_parse_token_string_t cmd_dump_one_name =
7347 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7349 cmdline_parse_inst_t cmd_dump_one = {
7350 .f = cmd_dump_one_parsed, /* function to call */
7351 .data = NULL, /* 2nd arg of func */
7352 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7353 .tokens = { /* token list, NULL terminated */
7354 (void *)&cmd_dump_one_dump,
7355 (void *)&cmd_dump_one_name,
7360 /* *** set SYN filter *** */
7361 struct cmd_set_syn_filter_result {
7362 cmdline_fixed_string_t filter;
7364 cmdline_fixed_string_t priority;
7365 cmdline_fixed_string_t high;
7366 cmdline_fixed_string_t queue;
7371 cmd_set_syn_filter_parsed(void *parsed_result,
7372 __attribute__((unused)) struct cmdline *cl,
7373 __attribute__((unused)) void *data)
7376 struct cmd_set_syn_filter_result *res = parsed_result;
7377 struct rte_syn_filter filter;
7379 if (!strcmp(res->filter, "add_syn_filter")) {
7380 if (!strcmp(res->high, "high"))
7384 ret = rte_eth_dev_add_syn_filter(res->port_id,
7385 &filter, res->queue_id);
7386 } else if (!strcmp(res->filter, "remove_syn_filter"))
7387 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7388 else if (!strcmp(res->filter, "get_syn_filter"))
7389 get_syn_filter(res->port_id);
7391 printf("syn filter setting error: (%s)\n", strerror(-ret));
7394 cmdline_parse_token_num_t cmd_syn_filter_portid =
7395 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7397 cmdline_parse_token_string_t cmd_syn_filter_priority =
7398 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7399 priority, "priority");
7400 cmdline_parse_token_string_t cmd_syn_filter_high =
7401 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7403 cmdline_parse_token_string_t cmd_syn_filter_queue =
7404 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7406 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7407 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7409 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7410 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7411 filter, "add_syn_filter");
7412 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7413 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7414 filter, "remove_syn_filter");
7415 cmdline_parse_inst_t cmd_add_syn_filter = {
7416 .f = cmd_set_syn_filter_parsed,
7418 .help_str = "add syn filter",
7420 (void *)&cmd_syn_filter_add_filter,
7421 (void *)&cmd_syn_filter_portid,
7422 (void *)&cmd_syn_filter_priority,
7423 (void *)&cmd_syn_filter_high,
7424 (void *)&cmd_syn_filter_queue,
7425 (void *)&cmd_syn_filter_queue_id,
7429 cmdline_parse_inst_t cmd_remove_syn_filter = {
7430 .f = cmd_set_syn_filter_parsed,
7432 .help_str = "remove syn filter",
7434 (void *)&cmd_syn_filter_remove_filter,
7435 (void *)&cmd_syn_filter_portid,
7440 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7441 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7442 filter, "get_syn_filter");
7444 cmdline_parse_inst_t cmd_get_syn_filter = {
7445 .f = cmd_set_syn_filter_parsed,
7447 .help_str = "get syn filter",
7449 (void *)&cmd_syn_filter_get_filter,
7450 (void *)&cmd_syn_filter_portid,
7455 /* *** ADD/REMOVE A 2tuple FILTER *** */
7456 struct cmd_2tuple_filter_result {
7457 cmdline_fixed_string_t filter;
7459 cmdline_fixed_string_t protocol;
7460 uint8_t protocol_value;
7461 uint8_t protocol_mask;
7462 cmdline_fixed_string_t dst_port;
7463 uint16_t dst_port_value;
7464 uint16_t dst_port_mask;
7465 cmdline_fixed_string_t flags;
7466 uint8_t flags_value;
7467 cmdline_fixed_string_t priority;
7468 uint8_t priority_value;
7469 cmdline_fixed_string_t queue;
7471 cmdline_fixed_string_t index;
7472 uint16_t index_value;
7476 cmd_2tuple_filter_parsed(void *parsed_result,
7477 __attribute__((unused)) struct cmdline *cl,
7478 __attribute__((unused)) void *data)
7481 struct rte_2tuple_filter filter;
7482 struct cmd_2tuple_filter_result *res = parsed_result;
7484 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7486 if (!strcmp(res->filter, "add_2tuple_filter")) {
7487 /* need convert to big endian. */
7488 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7489 filter.protocol = res->protocol_value;
7490 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7491 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7492 filter.priority = res->priority_value;
7493 filter.tcp_flags = res->flags_value;
7494 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7495 res->index_value, &filter, res->queue_id);
7496 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7497 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7499 else if (!strcmp(res->filter, "get_2tuple_filter"))
7500 get_2tuple_filter(res->port_id, res->index_value);
7503 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7506 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7507 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7509 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7510 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7511 protocol, "protocol");
7512 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7513 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7514 protocol_value, UINT8);
7515 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7516 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7517 protocol_mask, UINT8);
7518 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7519 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7520 dst_port, "dst_port");
7521 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7522 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7523 dst_port_value, UINT16);
7524 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7525 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7526 dst_port_mask, UINT16);
7527 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7528 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7530 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7531 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7532 flags_value, UINT8);
7533 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7534 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7535 priority, "priority");
7536 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7537 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7538 priority_value, UINT8);
7539 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7540 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7542 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7543 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7545 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7546 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7548 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7549 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7550 index_value, UINT16);
7551 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7552 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7553 filter, "add_2tuple_filter");
7554 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7555 .f = cmd_2tuple_filter_parsed,
7557 .help_str = "add a 2tuple filter",
7559 (void *)&cmd_2tuple_filter_add_filter,
7560 (void *)&cmd_2tuple_filter_port_id,
7561 (void *)&cmd_2tuple_filter_protocol,
7562 (void *)&cmd_2tuple_filter_protocol_value,
7563 (void *)&cmd_2tuple_filter_protocol_mask,
7564 (void *)&cmd_2tuple_filter_dst_port,
7565 (void *)&cmd_2tuple_filter_dst_port_value,
7566 (void *)&cmd_2tuple_filter_dst_port_mask,
7567 (void *)&cmd_2tuple_filter_flags,
7568 (void *)&cmd_2tuple_filter_flags_value,
7569 (void *)&cmd_2tuple_filter_priority,
7570 (void *)&cmd_2tuple_filter_priority_value,
7571 (void *)&cmd_2tuple_filter_queue,
7572 (void *)&cmd_2tuple_filter_queue_id,
7573 (void *)&cmd_2tuple_filter_index,
7574 (void *)&cmd_2tuple_filter_index_value,
7579 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7580 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7581 filter, "remove_2tuple_filter");
7582 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7583 .f = cmd_2tuple_filter_parsed,
7585 .help_str = "remove a 2tuple filter",
7587 (void *)&cmd_2tuple_filter_remove_filter,
7588 (void *)&cmd_2tuple_filter_port_id,
7589 (void *)&cmd_2tuple_filter_index,
7590 (void *)&cmd_2tuple_filter_index_value,
7594 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7595 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7596 filter, "get_2tuple_filter");
7597 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7598 .f = cmd_2tuple_filter_parsed,
7600 .help_str = "get a 2tuple filter",
7602 (void *)&cmd_2tuple_filter_get_filter,
7603 (void *)&cmd_2tuple_filter_port_id,
7604 (void *)&cmd_2tuple_filter_index,
7605 (void *)&cmd_2tuple_filter_index_value,
7610 /* *** ADD/REMOVE A 5tuple FILTER *** */
7611 struct cmd_5tuple_filter_result {
7612 cmdline_fixed_string_t filter;
7614 cmdline_fixed_string_t dst_ip;
7615 cmdline_ipaddr_t dst_ip_value;
7616 cmdline_fixed_string_t src_ip;
7617 cmdline_ipaddr_t src_ip_value;
7618 cmdline_fixed_string_t dst_port;
7619 uint16_t dst_port_value;
7620 cmdline_fixed_string_t src_port;
7621 uint16_t src_port_value;
7622 cmdline_fixed_string_t protocol;
7623 uint8_t protocol_value;
7624 cmdline_fixed_string_t mask;
7626 cmdline_fixed_string_t flags;
7627 uint8_t flags_value;
7628 cmdline_fixed_string_t priority;
7629 uint8_t priority_value;
7630 cmdline_fixed_string_t queue;
7632 cmdline_fixed_string_t index;
7633 uint16_t index_value;
7637 cmd_5tuple_filter_parsed(void *parsed_result,
7638 __attribute__((unused)) struct cmdline *cl,
7639 __attribute__((unused)) void *data)
7642 struct rte_5tuple_filter filter;
7643 struct cmd_5tuple_filter_result *res = parsed_result;
7645 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7647 if (!strcmp(res->filter, "add_5tuple_filter")) {
7648 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7649 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7650 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7651 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7652 filter.protocol = res->protocol_value;
7653 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7654 filter.priority = res->priority_value;
7655 filter.tcp_flags = res->flags_value;
7657 if (res->dst_ip_value.family == AF_INET)
7658 /* no need to convert, already big endian. */
7659 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7661 if (filter.dst_ip_mask == 0) {
7662 printf("can not support ipv6 involved compare.\n");
7668 if (res->src_ip_value.family == AF_INET)
7669 /* no need to convert, already big endian. */
7670 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7672 if (filter.src_ip_mask == 0) {
7673 printf("can not support ipv6 involved compare.\n");
7678 /* need convert to big endian. */
7679 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7680 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7682 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7683 res->index_value, &filter, res->queue_id);
7684 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7685 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7687 else if (!strcmp(res->filter, "get_5tuple_filter"))
7688 get_5tuple_filter(res->port_id, res->index_value);
7690 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7694 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7695 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7697 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7698 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7700 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7701 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7703 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7704 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7706 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7707 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7709 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7710 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7711 dst_port, "dst_port");
7712 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7713 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7714 dst_port_value, UINT16);
7715 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7716 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7717 src_port, "src_port");
7718 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7719 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7720 src_port_value, UINT16);
7721 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7722 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7723 protocol, "protocol");
7724 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7725 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7726 protocol_value, UINT8);
7727 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7728 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7730 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7731 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7733 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7734 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7736 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7737 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7738 flags_value, UINT8);
7739 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7740 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7741 priority, "priority");
7742 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7743 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7744 priority_value, UINT8);
7745 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7746 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7748 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7749 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7751 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7752 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7754 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7755 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7756 index_value, UINT16);
7758 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7759 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7760 filter, "add_5tuple_filter");
7761 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7762 .f = cmd_5tuple_filter_parsed,
7764 .help_str = "add a 5tuple filter",
7766 (void *)&cmd_5tuple_filter_add_filter,
7767 (void *)&cmd_5tuple_filter_port_id,
7768 (void *)&cmd_5tuple_filter_dst_ip,
7769 (void *)&cmd_5tuple_filter_dst_ip_value,
7770 (void *)&cmd_5tuple_filter_src_ip,
7771 (void *)&cmd_5tuple_filter_src_ip_value,
7772 (void *)&cmd_5tuple_filter_dst_port,
7773 (void *)&cmd_5tuple_filter_dst_port_value,
7774 (void *)&cmd_5tuple_filter_src_port,
7775 (void *)&cmd_5tuple_filter_src_port_value,
7776 (void *)&cmd_5tuple_filter_protocol,
7777 (void *)&cmd_5tuple_filter_protocol_value,
7778 (void *)&cmd_5tuple_filter_mask,
7779 (void *)&cmd_5tuple_filter_mask_value,
7780 (void *)&cmd_5tuple_filter_flags,
7781 (void *)&cmd_5tuple_filter_flags_value,
7782 (void *)&cmd_5tuple_filter_priority,
7783 (void *)&cmd_5tuple_filter_priority_value,
7784 (void *)&cmd_5tuple_filter_queue,
7785 (void *)&cmd_5tuple_filter_queue_id,
7786 (void *)&cmd_5tuple_filter_index,
7787 (void *)&cmd_5tuple_filter_index_value,
7792 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7793 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7794 filter, "remove_5tuple_filter");
7795 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7796 .f = cmd_5tuple_filter_parsed,
7798 .help_str = "remove a 5tuple filter",
7800 (void *)&cmd_5tuple_filter_remove_filter,
7801 (void *)&cmd_5tuple_filter_port_id,
7802 (void *)&cmd_5tuple_filter_index,
7803 (void *)&cmd_5tuple_filter_index_value,
7808 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7809 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7810 filter, "get_5tuple_filter");
7811 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7812 .f = cmd_5tuple_filter_parsed,
7814 .help_str = "get a 5tuple filter",
7816 (void *)&cmd_5tuple_filter_get_filter,
7817 (void *)&cmd_5tuple_filter_port_id,
7818 (void *)&cmd_5tuple_filter_index,
7819 (void *)&cmd_5tuple_filter_index_value,
7824 /* *** ADD/REMOVE A flex FILTER *** */
7825 struct cmd_flex_filter_result {
7826 cmdline_fixed_string_t filter;
7828 cmdline_fixed_string_t len;
7830 cmdline_fixed_string_t bytes;
7831 cmdline_fixed_string_t bytes_value;
7832 cmdline_fixed_string_t mask;
7833 cmdline_fixed_string_t mask_value;
7834 cmdline_fixed_string_t priority;
7835 uint8_t priority_value;
7836 cmdline_fixed_string_t queue;
7838 cmdline_fixed_string_t index;
7839 uint16_t index_value;
7842 static int xdigit2val(unsigned char c)
7847 else if (isupper(c))
7855 cmd_flex_filter_parsed(void *parsed_result,
7856 __attribute__((unused)) struct cmdline *cl,
7857 __attribute__((unused)) void *data)
7860 struct rte_flex_filter filter;
7861 struct cmd_flex_filter_result *res = parsed_result;
7862 char *bytes_ptr, *mask_ptr;
7870 if (!strcmp(res->filter, "add_flex_filter")) {
7871 if (res->len_value > 128) {
7872 printf("the len exceed the max length 128\n");
7875 memset(&filter, 0, sizeof(struct rte_flex_filter));
7876 filter.len = res->len_value;
7877 filter.priority = res->priority_value;
7878 bytes_ptr = res->bytes_value;
7879 mask_ptr = res->mask_value;
7882 /* translate bytes string to uint_32 array. */
7883 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7884 (bytes_ptr[1] == 'X')))
7886 len = strnlen(bytes_ptr, res->len_value * 2);
7887 if (len == 0 || (len % 8 != 0)) {
7888 printf("please check len and bytes input\n");
7891 for (i = 0; i < len; i++) {
7893 if (isxdigit(c) == 0) {
7894 /* invalid characters. */
7895 printf("invalid input\n");
7898 val = xdigit2val(c);
7902 dword |= byte << (4 * mod - 4);
7907 filter.dwords[j] = dword;
7908 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7914 /* translate mask string to uint8_t array. */
7916 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7917 (mask_ptr[1] == 'X')))
7919 len = strnlen(mask_ptr, (res->len_value+3)/4);
7921 printf("invalid input\n");
7924 for (i = 0; i < len; i++) {
7926 if (isxdigit(c) == 0) {
7927 /* invalid characters. */
7928 printf("invalid input\n");
7931 val = xdigit2val(c);
7932 hex |= (uint8_t)(val & 0x8) >> 3;
7933 hex |= (uint8_t)(val & 0x4) >> 1;
7934 hex |= (uint8_t)(val & 0x2) << 1;
7935 hex |= (uint8_t)(val & 0x1) << 3;
7938 filter.mask[j] = byte;
7939 printf("mask[%d]:%02x ", j, filter.mask[j]);
7947 printf("call function rte_eth_dev_add_flex_filter: "
7948 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7949 res->index_value, res->queue_id,
7950 filter.len, filter.priority);
7951 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7952 &filter, res->queue_id);
7954 } else if (!strcmp(res->filter, "remove_flex_filter"))
7955 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7957 else if (!strcmp(res->filter, "get_flex_filter"))
7958 get_flex_filter(res->port_id, res->index_value);
7961 printf("flex filter setting error: (%s)\n", strerror(-ret));
7964 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7965 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7967 cmdline_parse_token_string_t cmd_flex_filter_len =
7968 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7970 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7971 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7973 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7974 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7976 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7977 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7979 cmdline_parse_token_string_t cmd_flex_filter_mask =
7980 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7982 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7983 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7985 cmdline_parse_token_string_t cmd_flex_filter_priority =
7986 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7987 priority, "priority");
7988 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7989 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7990 priority_value, UINT8);
7991 cmdline_parse_token_string_t cmd_flex_filter_queue =
7992 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7994 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7995 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7997 cmdline_parse_token_string_t cmd_flex_filter_index =
7998 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8000 cmdline_parse_token_num_t cmd_flex_filter_index_value =
8001 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8002 index_value, UINT16);
8003 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
8004 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8005 filter, "add_flex_filter");
8006 cmdline_parse_inst_t cmd_add_flex_filter = {
8007 .f = cmd_flex_filter_parsed,
8009 .help_str = "add a flex filter",
8011 (void *)&cmd_flex_filter_add_filter,
8012 (void *)&cmd_flex_filter_port_id,
8013 (void *)&cmd_flex_filter_len,
8014 (void *)&cmd_flex_filter_len_value,
8015 (void *)&cmd_flex_filter_bytes,
8016 (void *)&cmd_flex_filter_bytes_value,
8017 (void *)&cmd_flex_filter_mask,
8018 (void *)&cmd_flex_filter_mask_value,
8019 (void *)&cmd_flex_filter_priority,
8020 (void *)&cmd_flex_filter_priority_value,
8021 (void *)&cmd_flex_filter_queue,
8022 (void *)&cmd_flex_filter_queue_id,
8023 (void *)&cmd_flex_filter_index,
8024 (void *)&cmd_flex_filter_index_value,
8029 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
8030 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8031 filter, "remove_flex_filter");
8032 cmdline_parse_inst_t cmd_remove_flex_filter = {
8033 .f = cmd_flex_filter_parsed,
8035 .help_str = "remove a flex filter",
8037 (void *)&cmd_flex_filter_remove_filter,
8038 (void *)&cmd_flex_filter_port_id,
8039 (void *)&cmd_flex_filter_index,
8040 (void *)&cmd_flex_filter_index_value,
8045 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
8046 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8047 filter, "get_flex_filter");
8048 cmdline_parse_inst_t cmd_get_flex_filter = {
8049 .f = cmd_flex_filter_parsed,
8051 .help_str = "get a flex filter",
8053 (void *)&cmd_flex_filter_get_filter,
8054 (void *)&cmd_flex_filter_port_id,
8055 (void *)&cmd_flex_filter_index,
8056 (void *)&cmd_flex_filter_index_value,
8061 /* *** Filters Control *** */
8063 /* *** deal with ethertype filter *** */
8064 struct cmd_ethertype_filter_result {
8065 cmdline_fixed_string_t filter;
8067 cmdline_fixed_string_t ops;
8068 cmdline_fixed_string_t mac;
8069 struct ether_addr mac_addr;
8070 cmdline_fixed_string_t ethertype;
8071 uint16_t ethertype_value;
8072 cmdline_fixed_string_t drop;
8073 cmdline_fixed_string_t queue;
8077 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8078 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8079 filter, "ethertype_filter");
8080 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8081 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8083 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8084 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8086 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8087 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8088 mac, "mac_addr#mac_ignr");
8089 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8090 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8092 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8093 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8094 ethertype, "ethertype");
8095 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8096 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8097 ethertype_value, UINT16);
8098 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8099 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8101 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8102 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8104 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8105 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8109 cmd_ethertype_filter_parsed(void *parsed_result,
8110 __attribute__((unused)) struct cmdline *cl,
8111 __attribute__((unused)) void *data)
8113 struct cmd_ethertype_filter_result *res = parsed_result;
8114 struct rte_eth_ethertype_filter filter;
8117 ret = rte_eth_dev_filter_supported(res->port_id,
8118 RTE_ETH_FILTER_ETHERTYPE);
8120 printf("ethertype filter is not supported on port %u.\n",
8125 memset(&filter, 0, sizeof(filter));
8126 if (!strcmp(res->mac, "mac_addr")) {
8127 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8128 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8129 sizeof(struct ether_addr));
8131 if (!strcmp(res->drop, "drop"))
8132 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8133 filter.ether_type = res->ethertype_value;
8134 filter.queue = res->queue_id;
8136 if (!strcmp(res->ops, "add"))
8137 ret = rte_eth_dev_filter_ctrl(res->port_id,
8138 RTE_ETH_FILTER_ETHERTYPE,
8142 ret = rte_eth_dev_filter_ctrl(res->port_id,
8143 RTE_ETH_FILTER_ETHERTYPE,
8144 RTE_ETH_FILTER_DELETE,
8147 printf("ethertype filter programming error: (%s)\n",
8151 cmdline_parse_inst_t cmd_ethertype_filter = {
8152 .f = cmd_ethertype_filter_parsed,
8154 .help_str = "add or delete an ethertype filter entry",
8156 (void *)&cmd_ethertype_filter_filter,
8157 (void *)&cmd_ethertype_filter_port_id,
8158 (void *)&cmd_ethertype_filter_ops,
8159 (void *)&cmd_ethertype_filter_mac,
8160 (void *)&cmd_ethertype_filter_mac_addr,
8161 (void *)&cmd_ethertype_filter_ethertype,
8162 (void *)&cmd_ethertype_filter_ethertype_value,
8163 (void *)&cmd_ethertype_filter_drop,
8164 (void *)&cmd_ethertype_filter_queue,
8165 (void *)&cmd_ethertype_filter_queue_id,
8170 /* *** deal with flow director filter *** */
8171 struct cmd_flow_director_result {
8172 cmdline_fixed_string_t flow_director_filter;
8174 cmdline_fixed_string_t ops;
8175 cmdline_fixed_string_t flow;
8176 cmdline_fixed_string_t flow_type;
8177 cmdline_fixed_string_t src;
8178 cmdline_ipaddr_t ip_src;
8180 cmdline_fixed_string_t dst;
8181 cmdline_ipaddr_t ip_dst;
8183 cmdline_fixed_string_t verify_tag;
8184 uint32_t verify_tag_value;
8185 cmdline_fixed_string_t flexbytes;
8186 cmdline_fixed_string_t flexbytes_value;
8187 cmdline_fixed_string_t drop;
8188 cmdline_fixed_string_t queue;
8190 cmdline_fixed_string_t fd_id;
8191 uint32_t fd_id_value;
8195 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8198 const char *p, *p0 = q_arg;
8200 unsigned long int_fld;
8201 char *str_fld[max_num];
8206 p = strchr(p0, '(');
8210 p0 = strchr(p, ')');
8215 if (size >= sizeof(s))
8218 snprintf(s, sizeof(s), "%.*s", size, p);
8219 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8220 if (ret < 0 || ret > max_num)
8222 for (i = 0; i < ret; i++) {
8224 int_fld = strtoul(str_fld[i], &end, 0);
8225 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8227 flexbytes[i] = (uint8_t)int_fld;
8232 static enum rte_eth_flow_type
8233 str2flowtype(char *string)
8236 static const struct {
8238 enum rte_eth_flow_type type;
8239 } flowtype_str[] = {
8240 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8241 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8242 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8243 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8244 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8245 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8246 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8247 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8248 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8249 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8252 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8253 if (!strcmp(flowtype_str[i].str, string))
8254 return flowtype_str[i].type;
8256 return RTE_ETH_FLOW_TYPE_NONE;
8259 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8261 if ((ip_addr).family == AF_INET) \
8262 (ip) = (ip_addr).addr.ipv4.s_addr; \
8264 printf("invalid parameter.\n"); \
8269 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8271 if ((ip_addr).family == AF_INET6) \
8272 (void)rte_memcpy(&(ip), \
8273 &((ip_addr).addr.ipv6), \
8274 sizeof(struct in6_addr)); \
8276 printf("invalid parameter.\n"); \
8282 cmd_flow_director_filter_parsed(void *parsed_result,
8283 __attribute__((unused)) struct cmdline *cl,
8284 __attribute__((unused)) void *data)
8286 struct cmd_flow_director_result *res = parsed_result;
8287 struct rte_eth_fdir_filter entry;
8288 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8291 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8293 printf("flow director is not supported on port %u.\n",
8297 memset(flexbytes, 0, sizeof(flexbytes));
8298 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8299 ret = parse_flexbytes(res->flexbytes_value,
8301 RTE_ETH_FDIR_MAX_FLEXLEN);
8303 printf("error: Cannot parse flexbytes input.\n");
8307 entry.input.flow_type = str2flowtype(res->flow_type);
8308 switch (entry.input.flow_type) {
8309 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
8310 case RTE_ETH_FLOW_TYPE_UDPV4:
8311 case RTE_ETH_FLOW_TYPE_TCPV4:
8312 IPV4_ADDR_TO_UINT(res->ip_dst,
8313 entry.input.flow.ip4_flow.dst_ip);
8314 IPV4_ADDR_TO_UINT(res->ip_src,
8315 entry.input.flow.ip4_flow.src_ip);
8316 /* need convert to big endian. */
8317 entry.input.flow.udp4_flow.dst_port =
8318 rte_cpu_to_be_16(res->port_dst);
8319 entry.input.flow.udp4_flow.src_port =
8320 rte_cpu_to_be_16(res->port_src);
8322 case RTE_ETH_FLOW_TYPE_SCTPV4:
8323 IPV4_ADDR_TO_UINT(res->ip_dst,
8324 entry.input.flow.sctp4_flow.ip.dst_ip);
8325 IPV4_ADDR_TO_UINT(res->ip_src,
8326 entry.input.flow.sctp4_flow.ip.src_ip);
8327 /* need convert to big endian. */
8328 entry.input.flow.sctp4_flow.verify_tag =
8329 rte_cpu_to_be_32(res->verify_tag_value);
8331 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
8332 case RTE_ETH_FLOW_TYPE_UDPV6:
8333 case RTE_ETH_FLOW_TYPE_TCPV6:
8334 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8335 entry.input.flow.ipv6_flow.dst_ip);
8336 IPV6_ADDR_TO_ARRAY(res->ip_src,
8337 entry.input.flow.ipv6_flow.src_ip);
8338 /* need convert to big endian. */
8339 entry.input.flow.udp6_flow.dst_port =
8340 rte_cpu_to_be_16(res->port_dst);
8341 entry.input.flow.udp6_flow.src_port =
8342 rte_cpu_to_be_16(res->port_src);
8344 case RTE_ETH_FLOW_TYPE_SCTPV6:
8345 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8346 entry.input.flow.sctp6_flow.ip.dst_ip);
8347 IPV6_ADDR_TO_ARRAY(res->ip_src,
8348 entry.input.flow.sctp6_flow.ip.src_ip);
8349 /* need convert to big endian. */
8350 entry.input.flow.sctp6_flow.verify_tag =
8351 rte_cpu_to_be_32(res->verify_tag_value);
8354 printf("invalid parameter.\n");
8357 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8359 RTE_ETH_FDIR_MAX_FLEXLEN);
8361 entry.action.flex_off = 0; /*use 0 by default */
8362 if (!strcmp(res->drop, "drop"))
8363 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8365 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8366 /* set to report FD ID by default */
8367 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8368 entry.action.rx_queue = res->queue_id;
8369 entry.soft_id = res->fd_id_value;
8370 if (!strcmp(res->ops, "add"))
8371 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8372 RTE_ETH_FILTER_ADD, &entry);
8374 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8375 RTE_ETH_FILTER_DELETE, &entry);
8377 printf("flow director programming error: (%s)\n",
8381 cmdline_parse_token_string_t cmd_flow_director_filter =
8382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8383 flow_director_filter, "flow_director_filter");
8384 cmdline_parse_token_num_t cmd_flow_director_port_id =
8385 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8387 cmdline_parse_token_string_t cmd_flow_director_ops =
8388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8390 cmdline_parse_token_string_t cmd_flow_director_flow =
8391 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8393 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8394 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8396 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8397 "ip6#ip6-frag#tcp6#udp6#sctp6");
8398 cmdline_parse_token_string_t cmd_flow_director_src =
8399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8401 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8402 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8404 cmdline_parse_token_num_t cmd_flow_director_port_src =
8405 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8407 cmdline_parse_token_string_t cmd_flow_director_dst =
8408 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8410 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8411 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8413 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8414 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8416 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8417 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8418 verify_tag, "verify_tag");
8419 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8420 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8421 verify_tag_value, UINT32);
8422 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8423 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8424 flexbytes, "flexbytes");
8425 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8426 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8427 flexbytes_value, NULL);
8428 cmdline_parse_token_string_t cmd_flow_director_drop =
8429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8431 cmdline_parse_token_string_t cmd_flow_director_queue =
8432 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8434 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8435 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8437 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8440 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8441 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8442 fd_id_value, UINT32);
8444 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8445 .f = cmd_flow_director_filter_parsed,
8447 .help_str = "add or delete an ip flow director entry on NIC",
8449 (void *)&cmd_flow_director_filter,
8450 (void *)&cmd_flow_director_port_id,
8451 (void *)&cmd_flow_director_ops,
8452 (void *)&cmd_flow_director_flow,
8453 (void *)&cmd_flow_director_flow_type,
8454 (void *)&cmd_flow_director_src,
8455 (void *)&cmd_flow_director_ip_src,
8456 (void *)&cmd_flow_director_dst,
8457 (void *)&cmd_flow_director_ip_dst,
8458 (void *)&cmd_flow_director_flexbytes,
8459 (void *)&cmd_flow_director_flexbytes_value,
8460 (void *)&cmd_flow_director_drop,
8461 (void *)&cmd_flow_director_queue,
8462 (void *)&cmd_flow_director_queue_id,
8463 (void *)&cmd_flow_director_fd_id,
8464 (void *)&cmd_flow_director_fd_id_value,
8469 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8470 .f = cmd_flow_director_filter_parsed,
8472 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8474 (void *)&cmd_flow_director_filter,
8475 (void *)&cmd_flow_director_port_id,
8476 (void *)&cmd_flow_director_ops,
8477 (void *)&cmd_flow_director_flow,
8478 (void *)&cmd_flow_director_flow_type,
8479 (void *)&cmd_flow_director_src,
8480 (void *)&cmd_flow_director_ip_src,
8481 (void *)&cmd_flow_director_port_src,
8482 (void *)&cmd_flow_director_dst,
8483 (void *)&cmd_flow_director_ip_dst,
8484 (void *)&cmd_flow_director_port_dst,
8485 (void *)&cmd_flow_director_flexbytes,
8486 (void *)&cmd_flow_director_flexbytes_value,
8487 (void *)&cmd_flow_director_drop,
8488 (void *)&cmd_flow_director_queue,
8489 (void *)&cmd_flow_director_queue_id,
8490 (void *)&cmd_flow_director_fd_id,
8491 (void *)&cmd_flow_director_fd_id_value,
8496 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8497 .f = cmd_flow_director_filter_parsed,
8499 .help_str = "add or delete a sctp flow director entry on NIC",
8501 (void *)&cmd_flow_director_filter,
8502 (void *)&cmd_flow_director_port_id,
8503 (void *)&cmd_flow_director_ops,
8504 (void *)&cmd_flow_director_flow,
8505 (void *)&cmd_flow_director_flow_type,
8506 (void *)&cmd_flow_director_src,
8507 (void *)&cmd_flow_director_ip_src,
8508 (void *)&cmd_flow_director_dst,
8509 (void *)&cmd_flow_director_ip_dst,
8510 (void *)&cmd_flow_director_verify_tag,
8511 (void *)&cmd_flow_director_verify_tag_value,
8512 (void *)&cmd_flow_director_flexbytes,
8513 (void *)&cmd_flow_director_flexbytes_value,
8514 (void *)&cmd_flow_director_drop,
8515 (void *)&cmd_flow_director_queue,
8516 (void *)&cmd_flow_director_queue_id,
8517 (void *)&cmd_flow_director_fd_id,
8518 (void *)&cmd_flow_director_fd_id_value,
8523 struct cmd_flush_flow_director_result {
8524 cmdline_fixed_string_t flush_flow_director;
8528 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8529 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8530 flush_flow_director, "flush_flow_director");
8531 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8532 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8536 cmd_flush_flow_director_parsed(void *parsed_result,
8537 __attribute__((unused)) struct cmdline *cl,
8538 __attribute__((unused)) void *data)
8540 struct cmd_flow_director_result *res = parsed_result;
8543 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8545 printf("flow director is not supported on port %u.\n",
8550 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8551 RTE_ETH_FILTER_FLUSH, NULL);
8553 printf("flow director table flushing error: (%s)\n",
8557 cmdline_parse_inst_t cmd_flush_flow_director = {
8558 .f = cmd_flush_flow_director_parsed,
8560 .help_str = "flush all flow director entries of a device on NIC",
8562 (void *)&cmd_flush_flow_director_flush,
8563 (void *)&cmd_flush_flow_director_port_id,
8568 /* *** deal with flow director mask on flexible payload *** */
8569 struct cmd_flow_director_flex_mask_result {
8570 cmdline_fixed_string_t flow_director_flexmask;
8572 cmdline_fixed_string_t flow;
8573 cmdline_fixed_string_t flow_type;
8574 cmdline_fixed_string_t mask;
8578 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8579 __attribute__((unused)) struct cmdline *cl,
8580 __attribute__((unused)) void *data)
8582 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8583 struct rte_eth_fdir_flex_mask flex_mask;
8584 struct rte_port *port;
8585 enum rte_eth_flow_type i;
8588 if (res->port_id > nb_ports) {
8589 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8593 port = &ports[res->port_id];
8594 /** Check if the port is not started **/
8595 if (port->port_status != RTE_PORT_STOPPED) {
8596 printf("Please stop port %d first\n", res->port_id);
8600 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8601 ret = parse_flexbytes(res->mask,
8603 RTE_ETH_FDIR_MAX_FLEXLEN);
8605 printf("error: Cannot parse mask input.\n");
8608 if (!strcmp(res->flow_type, "all")) {
8609 for (i = RTE_ETH_FLOW_TYPE_UDPV4;
8610 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8612 flex_mask.flow_type = i;
8613 fdir_set_flex_mask(res->port_id, &flex_mask);
8615 cmd_reconfig_device_queue(res->port_id, 1, 0);
8618 flex_mask.flow_type = str2flowtype(res->flow_type);
8619 fdir_set_flex_mask(res->port_id, &flex_mask);
8620 cmd_reconfig_device_queue(res->port_id, 1, 1);
8623 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8624 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8625 flow_director_flexmask,
8626 "flow_director_flex_mask");
8627 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8628 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8630 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8631 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8633 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8634 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8636 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8637 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8638 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8639 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8642 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8643 .f = cmd_flow_director_flex_mask_parsed,
8645 .help_str = "set flow director's flex mask on NIC",
8647 (void *)&cmd_flow_director_flexmask,
8648 (void *)&cmd_flow_director_flexmask_port_id,
8649 (void *)&cmd_flow_director_flexmask_flow,
8650 (void *)&cmd_flow_director_flexmask_flow_type,
8651 (void *)&cmd_flow_director_flexmask_mask,
8656 /* *** deal with flow director flexible payload configuration *** */
8657 struct cmd_flow_director_flexpayload_result {
8658 cmdline_fixed_string_t flow_director_flexpayload;
8660 cmdline_fixed_string_t payload_layer;
8661 cmdline_fixed_string_t payload_cfg;
8665 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8668 const char *p, *p0 = q_arg;
8670 unsigned long int_fld;
8671 char *str_fld[max_num];
8676 p = strchr(p0, '(');
8680 p0 = strchr(p, ')');
8685 if (size >= sizeof(s))
8688 snprintf(s, sizeof(s), "%.*s", size, p);
8689 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8690 if (ret < 0 || ret > max_num)
8692 for (i = 0; i < ret; i++) {
8694 int_fld = strtoul(str_fld[i], &end, 0);
8695 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8697 offsets[i] = (uint16_t)int_fld;
8703 cmd_flow_director_flxpld_parsed(void *parsed_result,
8704 __attribute__((unused)) struct cmdline *cl,
8705 __attribute__((unused)) void *data)
8707 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8708 struct rte_eth_flex_payload_cfg flex_cfg;
8709 struct rte_port *port;
8712 if (res->port_id > nb_ports) {
8713 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8717 port = &ports[res->port_id];
8718 /** Check if the port is not started **/
8719 if (port->port_status != RTE_PORT_STOPPED) {
8720 printf("Please stop port %d first\n", res->port_id);
8724 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8726 if (!strcmp(res->payload_layer, "l2"))
8727 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8728 else if (!strcmp(res->payload_layer, "l3"))
8729 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8730 else if (!strcmp(res->payload_layer, "l4"))
8731 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8733 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8734 RTE_ETH_FDIR_MAX_FLEXLEN);
8736 printf("error: Cannot parse flex payload input.\n");
8740 fdir_set_flex_payload(res->port_id, &flex_cfg);
8741 cmd_reconfig_device_queue(res->port_id, 1, 1);
8744 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8745 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8746 flow_director_flexpayload,
8747 "flow_director_flex_payload");
8748 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8749 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8751 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8752 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8753 payload_layer, "l2#l3#l4");
8754 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8758 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8759 .f = cmd_flow_director_flxpld_parsed,
8761 .help_str = "set flow director's flex payload on NIC",
8763 (void *)&cmd_flow_director_flexpayload,
8764 (void *)&cmd_flow_director_flexpayload_port_id,
8765 (void *)&cmd_flow_director_flexpayload_payload_layer,
8766 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8771 /* *** Classification Filters Control *** */
8772 /* *** Get symmetric hash enable per port *** */
8773 struct cmd_get_sym_hash_ena_per_port_result {
8774 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8779 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8780 __rte_unused struct cmdline *cl,
8781 __rte_unused void *data)
8783 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8784 struct rte_eth_hash_filter_info info;
8787 if (rte_eth_dev_filter_supported(res->port_id,
8788 RTE_ETH_FILTER_HASH) < 0) {
8789 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8794 memset(&info, 0, sizeof(info));
8795 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8796 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8797 RTE_ETH_FILTER_GET, &info);
8800 printf("Cannot get symmetric hash enable per port "
8801 "on port %u\n", res->port_id);
8805 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8806 "enabled" : "disabled", res->port_id);
8809 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8810 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8811 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8812 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8813 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8816 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8817 .f = cmd_get_sym_hash_per_port_parsed,
8819 .help_str = "get_sym_hash_ena_per_port port_id",
8821 (void *)&cmd_get_sym_hash_ena_per_port_all,
8822 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8827 /* *** Set symmetric hash enable per port *** */
8828 struct cmd_set_sym_hash_ena_per_port_result {
8829 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8830 cmdline_fixed_string_t enable;
8835 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8836 __rte_unused struct cmdline *cl,
8837 __rte_unused void *data)
8839 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8840 struct rte_eth_hash_filter_info info;
8843 if (rte_eth_dev_filter_supported(res->port_id,
8844 RTE_ETH_FILTER_HASH) < 0) {
8845 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8850 memset(&info, 0, sizeof(info));
8851 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8852 if (!strcmp(res->enable, "enable"))
8853 info.info.enable = 1;
8854 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8855 RTE_ETH_FILTER_SET, &info);
8857 printf("Cannot set symmetric hash enable per port on "
8858 "port %u\n", res->port_id);
8861 printf("Symmetric hash has been set to %s on port %u\n",
8862 res->enable, res->port_id);
8865 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8866 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8867 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8868 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8869 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8871 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8872 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8873 enable, "enable#disable");
8875 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8876 .f = cmd_set_sym_hash_per_port_parsed,
8878 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8880 (void *)&cmd_set_sym_hash_ena_per_port_all,
8881 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8882 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8887 /* Get global config of hash function */
8888 struct cmd_get_hash_global_config_result {
8889 cmdline_fixed_string_t get_hash_global_config;
8894 flowtype_to_str(enum rte_eth_flow_type ftype)
8899 enum rte_eth_flow_type ftype;
8901 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8902 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8903 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8904 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8905 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8906 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8907 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8908 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8909 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8910 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8913 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8914 if (ftype_table[i].ftype == ftype)
8915 return ftype_table[i].str;
8922 cmd_get_hash_global_config_parsed(void *parsed_result,
8923 __rte_unused struct cmdline *cl,
8924 __rte_unused void *data)
8926 struct cmd_get_hash_global_config_result *res = parsed_result;
8927 struct rte_eth_hash_filter_info info;
8928 uint32_t idx, offset, i;
8932 if (rte_eth_dev_filter_supported(res->port_id,
8933 RTE_ETH_FILTER_HASH) < 0) {
8934 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8939 memset(&info, 0, sizeof(info));
8940 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8941 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8942 RTE_ETH_FILTER_GET, &info);
8944 printf("Cannot get hash global configurations by port %d\n",
8949 switch (info.info.global_conf.hash_func) {
8950 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8951 printf("Hash function is Toeplitz\n");
8953 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8954 printf("Hash function is Simple XOR\n");
8957 printf("Unknown hash function\n");
8961 for (i = 0; i < RTE_ETH_FLOW_TYPE_MAX; i++) {
8962 idx = i / UINT32_BIT;
8963 offset = i % UINT32_BIT;
8964 if (!(info.info.global_conf.valid_bit_mask[idx] &
8967 str = flowtype_to_str((enum rte_eth_flow_type)i);
8970 printf("Symmetric hash is %s globally for flow type %s "
8972 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8973 (1UL << offset)) ? "enabled" : "disabled"), str,
8978 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8979 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8980 get_hash_global_config, "get_hash_global_config");
8981 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8982 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8985 cmdline_parse_inst_t cmd_get_hash_global_config = {
8986 .f = cmd_get_hash_global_config_parsed,
8988 .help_str = "get_hash_global_config port_id",
8990 (void *)&cmd_get_hash_global_config_all,
8991 (void *)&cmd_get_hash_global_config_port_id,
8996 /* Set global config of hash function */
8997 struct cmd_set_hash_global_config_result {
8998 cmdline_fixed_string_t set_hash_global_config;
9000 cmdline_fixed_string_t hash_func;
9001 cmdline_fixed_string_t flow_type;
9002 cmdline_fixed_string_t enable;
9006 cmd_set_hash_global_config_parsed(void *parsed_result,
9007 __rte_unused struct cmdline *cl,
9008 __rte_unused void *data)
9010 struct cmd_set_hash_global_config_result *res = parsed_result;
9011 struct rte_eth_hash_filter_info info;
9012 uint32_t ftype, idx, offset;
9015 if (rte_eth_dev_filter_supported(res->port_id,
9016 RTE_ETH_FILTER_HASH) < 0) {
9017 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9021 memset(&info, 0, sizeof(info));
9022 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9023 if (!strcmp(res->hash_func, "toeplitz"))
9024 info.info.global_conf.hash_func =
9025 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9026 else if (!strcmp(res->hash_func, "simple_xor"))
9027 info.info.global_conf.hash_func =
9028 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9029 else if (!strcmp(res->hash_func, "default"))
9030 info.info.global_conf.hash_func =
9031 RTE_ETH_HASH_FUNCTION_DEFAULT;
9033 ftype = str2flowtype(res->flow_type);
9034 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9035 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9036 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9037 if (!strcmp(res->enable, "enable"))
9038 info.info.global_conf.sym_hash_enable_mask[idx] |=
9040 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9041 RTE_ETH_FILTER_SET, &info);
9043 printf("Cannot set global hash configurations by port %d\n",
9046 printf("Global hash configurations have been set "
9047 "succcessfully by port %d\n", res->port_id);
9050 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9051 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9052 set_hash_global_config, "set_hash_global_config");
9053 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9054 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9056 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9057 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9058 hash_func, "toeplitz#simple_xor#default");
9059 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9060 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9062 "ip4#ip4-frag#tcp4#udp4#sctp4#ip6#ip6-frag#tcp6#udp6#sctp6");
9063 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9064 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9065 enable, "enable#disable");
9067 cmdline_parse_inst_t cmd_set_hash_global_config = {
9068 .f = cmd_set_hash_global_config_parsed,
9070 .help_str = "set_hash_global_config port_id "
9071 "toeplitz|simple_xor|default "
9072 "ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6 "
9075 (void *)&cmd_set_hash_global_config_all,
9076 (void *)&cmd_set_hash_global_config_port_id,
9077 (void *)&cmd_set_hash_global_config_hash_func,
9078 (void *)&cmd_set_hash_global_config_flow_type,
9079 (void *)&cmd_set_hash_global_config_enable,
9084 /* ******************************************************************************** */
9086 /* list of instructions */
9087 cmdline_parse_ctx_t main_ctx[] = {
9088 (cmdline_parse_inst_t *)&cmd_help_brief,
9089 (cmdline_parse_inst_t *)&cmd_help_long,
9090 (cmdline_parse_inst_t *)&cmd_quit,
9091 (cmdline_parse_inst_t *)&cmd_showport,
9092 (cmdline_parse_inst_t *)&cmd_showportall,
9093 (cmdline_parse_inst_t *)&cmd_showcfg,
9094 (cmdline_parse_inst_t *)&cmd_start,
9095 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9096 (cmdline_parse_inst_t *)&cmd_set_link_up,
9097 (cmdline_parse_inst_t *)&cmd_set_link_down,
9098 (cmdline_parse_inst_t *)&cmd_reset,
9099 (cmdline_parse_inst_t *)&cmd_set_numbers,
9100 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9101 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9102 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9103 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9104 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9105 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9106 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9107 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9108 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9109 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9110 (cmdline_parse_inst_t *)&cmd_set_link_check,
9111 #ifdef RTE_NIC_BYPASS
9112 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9113 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9114 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9115 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9117 #ifdef RTE_LIBRTE_PMD_BOND
9118 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9119 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9120 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9121 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9122 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9123 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9124 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9125 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9126 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9128 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9129 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9130 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9131 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9132 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9133 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9134 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9135 (cmdline_parse_inst_t *)&cmd_csum_set,
9136 (cmdline_parse_inst_t *)&cmd_csum_show,
9137 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
9138 (cmdline_parse_inst_t *)&cmd_tso_set,
9139 (cmdline_parse_inst_t *)&cmd_tso_show,
9140 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9141 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9142 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9143 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9144 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9145 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9146 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9147 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9148 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9149 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9150 (cmdline_parse_inst_t *)&cmd_config_dcb,
9151 (cmdline_parse_inst_t *)&cmd_read_reg,
9152 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9153 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9154 (cmdline_parse_inst_t *)&cmd_write_reg,
9155 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9156 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9157 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9158 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
9159 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
9160 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
9161 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
9162 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
9163 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
9164 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
9165 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
9166 (cmdline_parse_inst_t *)&cmd_stop,
9167 (cmdline_parse_inst_t *)&cmd_mac_addr,
9168 (cmdline_parse_inst_t *)&cmd_set_qmap,
9169 (cmdline_parse_inst_t *)&cmd_operate_port,
9170 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9171 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9172 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9173 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9174 (cmdline_parse_inst_t *)&cmd_config_mtu,
9175 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9176 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9177 (cmdline_parse_inst_t *)&cmd_config_rss,
9178 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9179 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9180 (cmdline_parse_inst_t *)&cmd_showport_reta,
9181 (cmdline_parse_inst_t *)&cmd_config_burst,
9182 (cmdline_parse_inst_t *)&cmd_config_thresh,
9183 (cmdline_parse_inst_t *)&cmd_config_threshold,
9184 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9185 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9186 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9187 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9188 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9189 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9190 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9191 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9192 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9193 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9194 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9195 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9196 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9197 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9198 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9199 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9200 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9201 (cmdline_parse_inst_t *)&cmd_dump,
9202 (cmdline_parse_inst_t *)&cmd_dump_one,
9203 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9204 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
9205 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
9206 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
9207 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
9208 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
9209 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
9210 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
9211 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
9212 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
9213 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
9214 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
9215 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
9216 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9217 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9218 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9219 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9220 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9221 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9222 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9223 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9224 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9225 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9229 /* prompt function, called from main on MASTER lcore */
9235 /* initialize non-constant commands */
9236 cmd_set_fwd_mode_init();
9238 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9242 cmdline_interact(cl);
9243 cmdline_stdin_exit(cl);
9247 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9249 if (id < nb_ports) {
9250 /* check if need_reconfig has been set to 1 */
9251 if (ports[id].need_reconfig == 0)
9252 ports[id].need_reconfig = dev;
9253 /* check if need_reconfig_queues has been set to 1 */
9254 if (ports[id].need_reconfig_queues == 0)
9255 ports[id].need_reconfig_queues = queue;
9259 for (pid = 0; pid < nb_ports; pid++) {
9260 /* check if need_reconfig has been set to 1 */
9261 if (ports[pid].need_reconfig == 0)
9262 ports[pid].need_reconfig = dev;
9263 /* check if need_reconfig_queues has been set to 1 */
9264 if (ports[pid].need_reconfig_queues == 0)
9265 ports[pid].need_reconfig_queues = queue;
9270 #ifdef RTE_NIC_BYPASS
9272 bypass_is_supported(portid_t port_id)
9274 struct rte_port *port;
9275 struct rte_pci_id *pci_id;
9277 if (port_id >= nb_ports) {
9278 printf("\tPort id must be less than %d.\n", nb_ports);
9282 /* Get the device id. */
9283 port = &ports[port_id];
9284 pci_id = &port->dev_info.pci_dev->id;
9286 /* Check if NIC supports bypass. */
9287 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9291 printf("\tBypass not supported for port_id = %d.\n", port_id);