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);
2942 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
2943 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
2944 printf("Warning: hardware outer IP checksum enabled but not "
2945 "supported by port %d\n", port_id);
2950 cmd_csum_parsed(void *parsed_result,
2951 __attribute__((unused)) struct cmdline *cl,
2952 __attribute__((unused)) void *data)
2954 struct cmd_csum_result *res = parsed_result;
2958 if (port_id_is_invalid(res->port_id)) {
2959 printf("invalid port %d\n", res->port_id);
2963 if (!strcmp(res->mode, "set")) {
2965 if (!strcmp(res->hwsw, "hw"))
2968 if (!strcmp(res->proto, "ip")) {
2969 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2970 } else if (!strcmp(res->proto, "udp")) {
2971 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2972 } else if (!strcmp(res->proto, "tcp")) {
2973 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2974 } else if (!strcmp(res->proto, "sctp")) {
2975 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2976 } else if (!strcmp(res->proto, "outer-ip")) {
2977 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
2981 ports[res->port_id].tx_ol_flags |= mask;
2983 ports[res->port_id].tx_ol_flags &= (~mask);
2985 csum_show(res->port_id);
2988 cmdline_parse_token_string_t cmd_csum_csum =
2989 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2991 cmdline_parse_token_string_t cmd_csum_mode =
2992 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2994 cmdline_parse_token_string_t cmd_csum_proto =
2995 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2996 proto, "ip#tcp#udp#sctp#outer-ip");
2997 cmdline_parse_token_string_t cmd_csum_hwsw =
2998 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3000 cmdline_parse_token_num_t cmd_csum_portid =
3001 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3004 cmdline_parse_inst_t cmd_csum_set = {
3005 .f = cmd_csum_parsed,
3007 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3008 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3010 (void *)&cmd_csum_csum,
3011 (void *)&cmd_csum_mode,
3012 (void *)&cmd_csum_proto,
3013 (void *)&cmd_csum_hwsw,
3014 (void *)&cmd_csum_portid,
3019 cmdline_parse_token_string_t cmd_csum_mode_show =
3020 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3023 cmdline_parse_inst_t cmd_csum_show = {
3024 .f = cmd_csum_parsed,
3026 .help_str = "show checksum offload configuration: csum show <port>",
3028 (void *)&cmd_csum_csum,
3029 (void *)&cmd_csum_mode_show,
3030 (void *)&cmd_csum_portid,
3035 /* Enable/disable tunnel parsing */
3036 struct cmd_csum_tunnel_result {
3037 cmdline_fixed_string_t csum;
3038 cmdline_fixed_string_t parse;
3039 cmdline_fixed_string_t onoff;
3044 cmd_csum_tunnel_parsed(void *parsed_result,
3045 __attribute__((unused)) struct cmdline *cl,
3046 __attribute__((unused)) void *data)
3048 struct cmd_csum_tunnel_result *res = parsed_result;
3050 if (port_id_is_invalid(res->port_id)) {
3051 printf("invalid port %d\n", res->port_id);
3055 if (!strcmp(res->onoff, "on"))
3056 ports[res->port_id].tx_ol_flags |=
3057 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3059 ports[res->port_id].tx_ol_flags &=
3060 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3062 csum_show(res->port_id);
3065 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3066 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3068 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3069 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3070 parse, "parse_tunnel");
3071 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3072 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3074 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3075 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3078 cmdline_parse_inst_t cmd_csum_tunnel = {
3079 .f = cmd_csum_tunnel_parsed,
3081 .help_str = "enable/disable parsing of tunnels for csum engine: "
3082 "csum parse_tunnel on|off <tx-port>",
3084 (void *)&cmd_csum_tunnel_csum,
3085 (void *)&cmd_csum_tunnel_parse,
3086 (void *)&cmd_csum_tunnel_onoff,
3087 (void *)&cmd_csum_tunnel_portid,
3092 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3093 struct cmd_tso_set_result {
3094 cmdline_fixed_string_t tso;
3095 cmdline_fixed_string_t mode;
3101 cmd_tso_set_parsed(void *parsed_result,
3102 __attribute__((unused)) struct cmdline *cl,
3103 __attribute__((unused)) void *data)
3105 struct cmd_tso_set_result *res = parsed_result;
3106 struct rte_eth_dev_info dev_info;
3108 if (port_id_is_invalid(res->port_id))
3111 if (!strcmp(res->mode, "set"))
3112 ports[res->port_id].tso_segsz = res->tso_segsz;
3114 if (ports[res->port_id].tso_segsz == 0)
3115 printf("TSO is disabled\n");
3117 printf("TSO segment size is %d\n",
3118 ports[res->port_id].tso_segsz);
3120 /* display warnings if configuration is not supported by the NIC */
3121 rte_eth_dev_info_get(res->port_id, &dev_info);
3122 if ((ports[res->port_id].tso_segsz != 0) &&
3123 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3124 printf("Warning: TSO enabled but not "
3125 "supported by port %d\n", res->port_id);
3129 cmdline_parse_token_string_t cmd_tso_set_tso =
3130 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3132 cmdline_parse_token_string_t cmd_tso_set_mode =
3133 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3135 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3136 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3138 cmdline_parse_token_num_t cmd_tso_set_portid =
3139 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3142 cmdline_parse_inst_t cmd_tso_set = {
3143 .f = cmd_tso_set_parsed,
3145 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3146 "tso set <tso_segsz> <port>",
3148 (void *)&cmd_tso_set_tso,
3149 (void *)&cmd_tso_set_mode,
3150 (void *)&cmd_tso_set_tso_segsz,
3151 (void *)&cmd_tso_set_portid,
3156 cmdline_parse_token_string_t cmd_tso_show_mode =
3157 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3161 cmdline_parse_inst_t cmd_tso_show = {
3162 .f = cmd_tso_set_parsed,
3164 .help_str = "Show TSO segment size for csum engine: "
3167 (void *)&cmd_tso_set_tso,
3168 (void *)&cmd_tso_show_mode,
3169 (void *)&cmd_tso_set_portid,
3174 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3175 struct cmd_set_flush_rx {
3176 cmdline_fixed_string_t set;
3177 cmdline_fixed_string_t flush_rx;
3178 cmdline_fixed_string_t mode;
3182 cmd_set_flush_rx_parsed(void *parsed_result,
3183 __attribute__((unused)) struct cmdline *cl,
3184 __attribute__((unused)) void *data)
3186 struct cmd_set_flush_rx *res = parsed_result;
3187 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3190 cmdline_parse_token_string_t cmd_setflushrx_set =
3191 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3193 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3194 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3195 flush_rx, "flush_rx");
3196 cmdline_parse_token_string_t cmd_setflushrx_mode =
3197 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3201 cmdline_parse_inst_t cmd_set_flush_rx = {
3202 .f = cmd_set_flush_rx_parsed,
3203 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3206 (void *)&cmd_setflushrx_set,
3207 (void *)&cmd_setflushrx_flush_rx,
3208 (void *)&cmd_setflushrx_mode,
3213 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3214 struct cmd_set_link_check {
3215 cmdline_fixed_string_t set;
3216 cmdline_fixed_string_t link_check;
3217 cmdline_fixed_string_t mode;
3221 cmd_set_link_check_parsed(void *parsed_result,
3222 __attribute__((unused)) struct cmdline *cl,
3223 __attribute__((unused)) void *data)
3225 struct cmd_set_link_check *res = parsed_result;
3226 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3229 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3230 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3232 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3233 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3234 link_check, "link_check");
3235 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3236 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3240 cmdline_parse_inst_t cmd_set_link_check = {
3241 .f = cmd_set_link_check_parsed,
3242 .help_str = "set link_check on|off: enable/disable link status check "
3243 "when starting/stopping a port",
3246 (void *)&cmd_setlinkcheck_set,
3247 (void *)&cmd_setlinkcheck_link_check,
3248 (void *)&cmd_setlinkcheck_mode,
3253 #ifdef RTE_NIC_BYPASS
3254 /* *** SET NIC BYPASS MODE *** */
3255 struct cmd_set_bypass_mode_result {
3256 cmdline_fixed_string_t set;
3257 cmdline_fixed_string_t bypass;
3258 cmdline_fixed_string_t mode;
3259 cmdline_fixed_string_t value;
3264 cmd_set_bypass_mode_parsed(void *parsed_result,
3265 __attribute__((unused)) struct cmdline *cl,
3266 __attribute__((unused)) void *data)
3268 struct cmd_set_bypass_mode_result *res = parsed_result;
3269 portid_t port_id = res->port_id;
3270 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3272 if (!bypass_is_supported(port_id))
3275 if (!strcmp(res->value, "bypass"))
3276 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3277 else if (!strcmp(res->value, "isolate"))
3278 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3280 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3282 /* Set the bypass mode for the relevant port. */
3283 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3284 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3288 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3289 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3291 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3292 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3294 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3295 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3297 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3298 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3299 value, "normal#bypass#isolate");
3300 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3301 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3304 cmdline_parse_inst_t cmd_set_bypass_mode = {
3305 .f = cmd_set_bypass_mode_parsed,
3306 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3307 "Set the NIC bypass mode for port_id",
3310 (void *)&cmd_setbypass_mode_set,
3311 (void *)&cmd_setbypass_mode_bypass,
3312 (void *)&cmd_setbypass_mode_mode,
3313 (void *)&cmd_setbypass_mode_value,
3314 (void *)&cmd_setbypass_mode_port,
3319 /* *** SET NIC BYPASS EVENT *** */
3320 struct cmd_set_bypass_event_result {
3321 cmdline_fixed_string_t set;
3322 cmdline_fixed_string_t bypass;
3323 cmdline_fixed_string_t event;
3324 cmdline_fixed_string_t event_value;
3325 cmdline_fixed_string_t mode;
3326 cmdline_fixed_string_t mode_value;
3331 cmd_set_bypass_event_parsed(void *parsed_result,
3332 __attribute__((unused)) struct cmdline *cl,
3333 __attribute__((unused)) void *data)
3336 struct cmd_set_bypass_event_result *res = parsed_result;
3337 portid_t port_id = res->port_id;
3338 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3339 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3341 if (!bypass_is_supported(port_id))
3344 if (!strcmp(res->event_value, "timeout"))
3345 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3346 else if (!strcmp(res->event_value, "os_on"))
3347 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3348 else if (!strcmp(res->event_value, "os_off"))
3349 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3350 else if (!strcmp(res->event_value, "power_on"))
3351 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3352 else if (!strcmp(res->event_value, "power_off"))
3353 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3355 bypass_event = RTE_BYPASS_EVENT_NONE;
3357 if (!strcmp(res->mode_value, "bypass"))
3358 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3359 else if (!strcmp(res->mode_value, "isolate"))
3360 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3362 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3364 /* Set the watchdog timeout. */
3365 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3368 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3369 (rc = rte_eth_dev_wd_timeout_store(port_id,
3370 bypass_timeout)) != 0) {
3371 printf("Failed to set timeout value %u "
3372 "for port %d, errto code: %d.\n",
3373 bypass_timeout, port_id, rc);
3377 /* Set the bypass event to transition to bypass mode. */
3378 if (0 != rte_eth_dev_bypass_event_store(port_id,
3379 bypass_event, bypass_mode)) {
3380 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3385 cmdline_parse_token_string_t cmd_setbypass_event_set =
3386 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3388 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3389 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3391 cmdline_parse_token_string_t cmd_setbypass_event_event =
3392 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3394 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3395 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3396 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3397 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3398 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3400 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3401 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3402 mode_value, "normal#bypass#isolate");
3403 cmdline_parse_token_num_t cmd_setbypass_event_port =
3404 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3407 cmdline_parse_inst_t cmd_set_bypass_event = {
3408 .f = cmd_set_bypass_event_parsed,
3409 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3410 "mode (normal|bypass|isolate) (port_id): "
3411 "Set the NIC bypass event mode for port_id",
3414 (void *)&cmd_setbypass_event_set,
3415 (void *)&cmd_setbypass_event_bypass,
3416 (void *)&cmd_setbypass_event_event,
3417 (void *)&cmd_setbypass_event_event_value,
3418 (void *)&cmd_setbypass_event_mode,
3419 (void *)&cmd_setbypass_event_mode_value,
3420 (void *)&cmd_setbypass_event_port,
3426 /* *** SET NIC BYPASS TIMEOUT *** */
3427 struct cmd_set_bypass_timeout_result {
3428 cmdline_fixed_string_t set;
3429 cmdline_fixed_string_t bypass;
3430 cmdline_fixed_string_t timeout;
3431 cmdline_fixed_string_t value;
3435 cmd_set_bypass_timeout_parsed(void *parsed_result,
3436 __attribute__((unused)) struct cmdline *cl,
3437 __attribute__((unused)) void *data)
3439 struct cmd_set_bypass_timeout_result *res = parsed_result;
3441 if (!strcmp(res->value, "1.5"))
3442 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3443 else if (!strcmp(res->value, "2"))
3444 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3445 else if (!strcmp(res->value, "3"))
3446 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3447 else if (!strcmp(res->value, "4"))
3448 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3449 else if (!strcmp(res->value, "8"))
3450 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3451 else if (!strcmp(res->value, "16"))
3452 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3453 else if (!strcmp(res->value, "32"))
3454 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3456 bypass_timeout = RTE_BYPASS_TMT_OFF;
3459 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3460 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3462 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3463 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3465 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3466 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3467 timeout, "timeout");
3468 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3469 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3470 value, "0#1.5#2#3#4#8#16#32");
3472 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3473 .f = cmd_set_bypass_timeout_parsed,
3474 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3475 "Set the NIC bypass watchdog timeout",
3478 (void *)&cmd_setbypass_timeout_set,
3479 (void *)&cmd_setbypass_timeout_bypass,
3480 (void *)&cmd_setbypass_timeout_timeout,
3481 (void *)&cmd_setbypass_timeout_value,
3486 /* *** SHOW NIC BYPASS MODE *** */
3487 struct cmd_show_bypass_config_result {
3488 cmdline_fixed_string_t show;
3489 cmdline_fixed_string_t bypass;
3490 cmdline_fixed_string_t config;
3495 cmd_show_bypass_config_parsed(void *parsed_result,
3496 __attribute__((unused)) struct cmdline *cl,
3497 __attribute__((unused)) void *data)
3499 struct cmd_show_bypass_config_result *res = parsed_result;
3500 uint32_t event_mode;
3501 uint32_t bypass_mode;
3502 portid_t port_id = res->port_id;
3503 uint32_t timeout = bypass_timeout;
3506 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3507 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3508 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3509 {"UNKNOWN", "normal", "bypass", "isolate"};
3510 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3517 int num_events = (sizeof events) / (sizeof events[0]);
3519 if (!bypass_is_supported(port_id))
3522 /* Display the bypass mode.*/
3523 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3524 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3528 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3529 bypass_mode = RTE_BYPASS_MODE_NONE;
3531 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3534 /* Display the bypass timeout.*/
3535 if (!RTE_BYPASS_TMT_VALID(timeout))
3536 timeout = RTE_BYPASS_TMT_OFF;
3538 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3540 /* Display the bypass events and associated modes. */
3541 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3543 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3544 printf("\tFailed to get bypass mode for event = %s\n",
3547 if (!RTE_BYPASS_MODE_VALID(event_mode))
3548 event_mode = RTE_BYPASS_MODE_NONE;
3550 printf("\tbypass event: %-16s = %s\n", events[i],
3556 cmdline_parse_token_string_t cmd_showbypass_config_show =
3557 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3559 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3560 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3562 cmdline_parse_token_string_t cmd_showbypass_config_config =
3563 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3565 cmdline_parse_token_num_t cmd_showbypass_config_port =
3566 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3569 cmdline_parse_inst_t cmd_show_bypass_config = {
3570 .f = cmd_show_bypass_config_parsed,
3571 .help_str = "show bypass config (port_id): "
3572 "Show the NIC bypass config for port_id",
3575 (void *)&cmd_showbypass_config_show,
3576 (void *)&cmd_showbypass_config_bypass,
3577 (void *)&cmd_showbypass_config_config,
3578 (void *)&cmd_showbypass_config_port,
3584 #ifdef RTE_LIBRTE_PMD_BOND
3585 /* *** SET BONDING MODE *** */
3586 struct cmd_set_bonding_mode_result {
3587 cmdline_fixed_string_t set;
3588 cmdline_fixed_string_t bonding;
3589 cmdline_fixed_string_t mode;
3594 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3595 __attribute__((unused)) struct cmdline *cl,
3596 __attribute__((unused)) void *data)
3598 struct cmd_set_bonding_mode_result *res = parsed_result;
3599 portid_t port_id = res->port_id;
3601 /* Set the bonding mode for the relevant port. */
3602 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3603 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3606 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3607 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3609 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3610 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3611 bonding, "bonding");
3612 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3613 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3615 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3616 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3618 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3619 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3622 cmdline_parse_inst_t cmd_set_bonding_mode = {
3623 .f = cmd_set_bonding_mode_parsed,
3624 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3627 (void *) &cmd_setbonding_mode_set,
3628 (void *) &cmd_setbonding_mode_bonding,
3629 (void *) &cmd_setbonding_mode_mode,
3630 (void *) &cmd_setbonding_mode_value,
3631 (void *) &cmd_setbonding_mode_port,
3636 /* *** SET BALANCE XMIT POLICY *** */
3637 struct cmd_set_bonding_balance_xmit_policy_result {
3638 cmdline_fixed_string_t set;
3639 cmdline_fixed_string_t bonding;
3640 cmdline_fixed_string_t balance_xmit_policy;
3642 cmdline_fixed_string_t policy;
3645 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3646 __attribute__((unused)) struct cmdline *cl,
3647 __attribute__((unused)) void *data)
3649 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3650 portid_t port_id = res->port_id;
3653 if (!strcmp(res->policy, "l2")) {
3654 policy = BALANCE_XMIT_POLICY_LAYER2;
3655 } else if (!strcmp(res->policy, "l23")) {
3656 policy = BALANCE_XMIT_POLICY_LAYER23;
3657 } else if (!strcmp(res->policy, "l34")) {
3658 policy = BALANCE_XMIT_POLICY_LAYER34;
3660 printf("\t Invalid xmit policy selection");
3664 /* Set the bonding mode for the relevant port. */
3665 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3666 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3671 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3672 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3674 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3675 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3676 bonding, "bonding");
3677 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3678 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3679 balance_xmit_policy, "balance_xmit_policy");
3680 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3681 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3683 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3684 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3685 policy, "l2#l23#l34");
3687 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3688 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3689 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3692 (void *)&cmd_setbonding_balance_xmit_policy_set,
3693 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3694 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3695 (void *)&cmd_setbonding_balance_xmit_policy_port,
3696 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3701 /* *** SHOW NIC BONDING CONFIGURATION *** */
3702 struct cmd_show_bonding_config_result {
3703 cmdline_fixed_string_t show;
3704 cmdline_fixed_string_t bonding;
3705 cmdline_fixed_string_t config;
3709 static void cmd_show_bonding_config_parsed(void *parsed_result,
3710 __attribute__((unused)) struct cmdline *cl,
3711 __attribute__((unused)) void *data)
3713 struct cmd_show_bonding_config_result *res = parsed_result;
3715 uint8_t slaves[RTE_MAX_ETHPORTS];
3716 int num_slaves, num_active_slaves;
3719 portid_t port_id = res->port_id;
3721 /* Display the bonding mode.*/
3722 bonding_mode = rte_eth_bond_mode_get(port_id);
3723 if (bonding_mode < 0) {
3724 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3727 printf("\tBonding mode: %d\n", bonding_mode);
3729 if (bonding_mode == BONDING_MODE_BALANCE) {
3730 int balance_xmit_policy;
3732 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3733 if (balance_xmit_policy < 0) {
3734 printf("\tFailed to get balance xmit policy for port = %d\n",
3738 printf("\tBalance Xmit Policy: ");
3740 switch (balance_xmit_policy) {
3741 case BALANCE_XMIT_POLICY_LAYER2:
3742 printf("BALANCE_XMIT_POLICY_LAYER2");
3744 case BALANCE_XMIT_POLICY_LAYER23:
3745 printf("BALANCE_XMIT_POLICY_LAYER23");
3747 case BALANCE_XMIT_POLICY_LAYER34:
3748 printf("BALANCE_XMIT_POLICY_LAYER34");
3755 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3757 if (num_slaves < 0) {
3758 printf("\tFailed to get slave list for port = %d\n", port_id);
3761 if (num_slaves > 0) {
3762 printf("\tSlaves (%d): [", num_slaves);
3763 for (i = 0; i < num_slaves - 1; i++)
3764 printf("%d ", slaves[i]);
3766 printf("%d]\n", slaves[num_slaves - 1]);
3768 printf("\tSlaves: []\n");
3772 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3775 if (num_active_slaves < 0) {
3776 printf("\tFailed to get active slave list for port = %d\n", port_id);
3779 if (num_active_slaves > 0) {
3780 printf("\tActive Slaves (%d): [", num_active_slaves);
3781 for (i = 0; i < num_active_slaves - 1; i++)
3782 printf("%d ", slaves[i]);
3784 printf("%d]\n", slaves[num_active_slaves - 1]);
3787 printf("\tActive Slaves: []\n");
3791 primary_id = rte_eth_bond_primary_get(port_id);
3792 if (primary_id < 0) {
3793 printf("\tFailed to get primary slave for port = %d\n", port_id);
3796 printf("\tPrimary: [%d]\n", primary_id);
3800 cmdline_parse_token_string_t cmd_showbonding_config_show =
3801 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3803 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3804 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3805 bonding, "bonding");
3806 cmdline_parse_token_string_t cmd_showbonding_config_config =
3807 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3809 cmdline_parse_token_num_t cmd_showbonding_config_port =
3810 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3813 cmdline_parse_inst_t cmd_show_bonding_config = {
3814 .f = cmd_show_bonding_config_parsed,
3815 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3818 (void *)&cmd_showbonding_config_show,
3819 (void *)&cmd_showbonding_config_bonding,
3820 (void *)&cmd_showbonding_config_config,
3821 (void *)&cmd_showbonding_config_port,
3826 /* *** SET BONDING PRIMARY *** */
3827 struct cmd_set_bonding_primary_result {
3828 cmdline_fixed_string_t set;
3829 cmdline_fixed_string_t bonding;
3830 cmdline_fixed_string_t primary;
3835 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3836 __attribute__((unused)) struct cmdline *cl,
3837 __attribute__((unused)) void *data)
3839 struct cmd_set_bonding_primary_result *res = parsed_result;
3840 portid_t master_port_id = res->port_id;
3841 portid_t slave_port_id = res->slave_id;
3843 /* Set the primary slave for a bonded device. */
3844 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3845 printf("\t Failed to set primary slave for port = %d.\n",
3852 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3853 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3855 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3856 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3857 bonding, "bonding");
3858 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3859 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3860 primary, "primary");
3861 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3862 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3864 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3865 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3868 cmdline_parse_inst_t cmd_set_bonding_primary = {
3869 .f = cmd_set_bonding_primary_parsed,
3870 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3873 (void *)&cmd_setbonding_primary_set,
3874 (void *)&cmd_setbonding_primary_bonding,
3875 (void *)&cmd_setbonding_primary_primary,
3876 (void *)&cmd_setbonding_primary_slave,
3877 (void *)&cmd_setbonding_primary_port,
3882 /* *** ADD SLAVE *** */
3883 struct cmd_add_bonding_slave_result {
3884 cmdline_fixed_string_t add;
3885 cmdline_fixed_string_t bonding;
3886 cmdline_fixed_string_t slave;
3891 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3892 __attribute__((unused)) struct cmdline *cl,
3893 __attribute__((unused)) void *data)
3895 struct cmd_add_bonding_slave_result *res = parsed_result;
3896 portid_t master_port_id = res->port_id;
3897 portid_t slave_port_id = res->slave_id;
3899 /* Set the primary slave for a bonded device. */
3900 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3901 printf("\t Failed to add slave %d to master port = %d.\n",
3902 slave_port_id, master_port_id);
3908 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3909 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3911 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3912 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3913 bonding, "bonding");
3914 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3915 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3917 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3918 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3920 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3921 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3924 cmdline_parse_inst_t cmd_add_bonding_slave = {
3925 .f = cmd_add_bonding_slave_parsed,
3926 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3929 (void *)&cmd_addbonding_slave_add,
3930 (void *)&cmd_addbonding_slave_bonding,
3931 (void *)&cmd_addbonding_slave_slave,
3932 (void *)&cmd_addbonding_slave_slaveid,
3933 (void *)&cmd_addbonding_slave_port,
3938 /* *** REMOVE SLAVE *** */
3939 struct cmd_remove_bonding_slave_result {
3940 cmdline_fixed_string_t remove;
3941 cmdline_fixed_string_t bonding;
3942 cmdline_fixed_string_t slave;
3947 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3948 __attribute__((unused)) struct cmdline *cl,
3949 __attribute__((unused)) void *data)
3951 struct cmd_remove_bonding_slave_result *res = parsed_result;
3952 portid_t master_port_id = res->port_id;
3953 portid_t slave_port_id = res->slave_id;
3955 /* Set the primary slave for a bonded device. */
3956 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3957 printf("\t Failed to remove slave %d from master port = %d.\n",
3958 slave_port_id, master_port_id);
3964 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3965 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3967 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3968 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3969 bonding, "bonding");
3970 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3971 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3973 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3974 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3976 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3977 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3980 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3981 .f = cmd_remove_bonding_slave_parsed,
3982 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3985 (void *)&cmd_removebonding_slave_remove,
3986 (void *)&cmd_removebonding_slave_bonding,
3987 (void *)&cmd_removebonding_slave_slave,
3988 (void *)&cmd_removebonding_slave_slaveid,
3989 (void *)&cmd_removebonding_slave_port,
3994 /* *** CREATE BONDED DEVICE *** */
3995 struct cmd_create_bonded_device_result {
3996 cmdline_fixed_string_t create;
3997 cmdline_fixed_string_t bonded;
3998 cmdline_fixed_string_t device;
4003 static int bond_dev_num = 0;
4005 static void cmd_create_bonded_device_parsed(void *parsed_result,
4006 __attribute__((unused)) struct cmdline *cl,
4007 __attribute__((unused)) void *data)
4009 struct cmd_create_bonded_device_result *res = parsed_result;
4010 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4013 if (test_done == 0) {
4014 printf("Please stop forwarding first\n");
4018 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4021 /* Create a new bonded device. */
4022 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4024 printf("\t Failed to create bonded device.\n");
4027 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4030 /* Update number of ports */
4031 nb_ports = rte_eth_dev_count();
4032 reconfig(port_id, res->socket);
4033 rte_eth_promiscuous_enable(port_id);
4038 cmdline_parse_token_string_t cmd_createbonded_device_create =
4039 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4041 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4042 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4044 cmdline_parse_token_string_t cmd_createbonded_device_device =
4045 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4047 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4048 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4050 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4051 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4054 cmdline_parse_inst_t cmd_create_bonded_device = {
4055 .f = cmd_create_bonded_device_parsed,
4056 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4059 (void *)&cmd_createbonded_device_create,
4060 (void *)&cmd_createbonded_device_bonded,
4061 (void *)&cmd_createbonded_device_device,
4062 (void *)&cmd_createbonded_device_mode,
4063 (void *)&cmd_createbonded_device_socket,
4068 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4069 struct cmd_set_bond_mac_addr_result {
4070 cmdline_fixed_string_t set;
4071 cmdline_fixed_string_t bonding;
4072 cmdline_fixed_string_t mac_addr;
4074 struct ether_addr address;
4077 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4078 __attribute__((unused)) struct cmdline *cl,
4079 __attribute__((unused)) void *data)
4081 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4084 if (res->port_num >= nb_ports) {
4085 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4089 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4091 /* check the return value and print it if is < 0 */
4093 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4096 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4097 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4098 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4099 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4101 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4102 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4104 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4105 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4106 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4107 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4109 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4110 .f = cmd_set_bond_mac_addr_parsed,
4112 .help_str = "set bonding mac_addr (port_id) (address): ",
4114 (void *)&cmd_set_bond_mac_addr_set,
4115 (void *)&cmd_set_bond_mac_addr_bonding,
4116 (void *)&cmd_set_bond_mac_addr_mac,
4117 (void *)&cmd_set_bond_mac_addr_portnum,
4118 (void *)&cmd_set_bond_mac_addr_addr,
4124 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4125 struct cmd_set_bond_mon_period_result {
4126 cmdline_fixed_string_t set;
4127 cmdline_fixed_string_t bonding;
4128 cmdline_fixed_string_t mon_period;
4133 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4134 __attribute__((unused)) struct cmdline *cl,
4135 __attribute__((unused)) void *data)
4137 struct cmd_set_bond_mon_period_result *res = parsed_result;
4140 if (res->port_num >= nb_ports) {
4141 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4145 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4147 /* check the return value and print it if is < 0 */
4149 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4152 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4153 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4155 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4156 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4157 bonding, "bonding");
4158 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4159 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4160 mon_period, "mon_period");
4161 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4162 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4164 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4165 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4168 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4169 .f = cmd_set_bond_mon_period_parsed,
4171 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4173 (void *)&cmd_set_bond_mon_period_set,
4174 (void *)&cmd_set_bond_mon_period_bonding,
4175 (void *)&cmd_set_bond_mon_period_mon_period,
4176 (void *)&cmd_set_bond_mon_period_portnum,
4177 (void *)&cmd_set_bond_mon_period_period_ms,
4182 #endif /* RTE_LIBRTE_PMD_BOND */
4184 /* *** SET FORWARDING MODE *** */
4185 struct cmd_set_fwd_mode_result {
4186 cmdline_fixed_string_t set;
4187 cmdline_fixed_string_t fwd;
4188 cmdline_fixed_string_t mode;
4191 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4192 __attribute__((unused)) struct cmdline *cl,
4193 __attribute__((unused)) void *data)
4195 struct cmd_set_fwd_mode_result *res = parsed_result;
4197 set_pkt_forwarding_mode(res->mode);
4200 cmdline_parse_token_string_t cmd_setfwd_set =
4201 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4202 cmdline_parse_token_string_t cmd_setfwd_fwd =
4203 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4204 cmdline_parse_token_string_t cmd_setfwd_mode =
4205 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4206 "" /* defined at init */);
4208 cmdline_parse_inst_t cmd_set_fwd_mode = {
4209 .f = cmd_set_fwd_mode_parsed,
4211 .help_str = NULL, /* defined at init */
4213 (void *)&cmd_setfwd_set,
4214 (void *)&cmd_setfwd_fwd,
4215 (void *)&cmd_setfwd_mode,
4220 static void cmd_set_fwd_mode_init(void)
4223 static char token[128];
4224 static char help[256];
4225 cmdline_parse_token_string_t *token_struct;
4227 modes = list_pkt_forwarding_modes();
4228 snprintf(help, sizeof help, "set fwd %s - "
4229 "set packet forwarding mode", modes);
4230 cmd_set_fwd_mode.help_str = help;
4232 /* string token separator is # */
4233 for (c = token; *modes != '\0'; modes++)
4238 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4239 token_struct->string_data.str = token;
4242 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4243 struct cmd_set_burst_tx_retry_result {
4244 cmdline_fixed_string_t set;
4245 cmdline_fixed_string_t burst;
4246 cmdline_fixed_string_t tx;
4247 cmdline_fixed_string_t delay;
4249 cmdline_fixed_string_t retry;
4253 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4254 __attribute__((unused)) struct cmdline *cl,
4255 __attribute__((unused)) void *data)
4257 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4259 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4260 && !strcmp(res->tx, "tx")) {
4261 if (!strcmp(res->delay, "delay"))
4262 burst_tx_delay_time = res->time;
4263 if (!strcmp(res->retry, "retry"))
4264 burst_tx_retry_num = res->retry_num;
4269 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4270 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4271 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4272 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4274 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4275 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4276 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4277 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4278 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4279 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4280 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4281 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4282 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4283 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4285 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4286 .f = cmd_set_burst_tx_retry_parsed,
4287 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4289 (void *)&cmd_set_burst_tx_retry_set,
4290 (void *)&cmd_set_burst_tx_retry_burst,
4291 (void *)&cmd_set_burst_tx_retry_tx,
4292 (void *)&cmd_set_burst_tx_retry_delay,
4293 (void *)&cmd_set_burst_tx_retry_time,
4294 (void *)&cmd_set_burst_tx_retry_retry,
4295 (void *)&cmd_set_burst_tx_retry_retry_num,
4300 /* *** SET PROMISC MODE *** */
4301 struct cmd_set_promisc_mode_result {
4302 cmdline_fixed_string_t set;
4303 cmdline_fixed_string_t promisc;
4304 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4305 uint8_t port_num; /* valid if "allports" argument == 0 */
4306 cmdline_fixed_string_t mode;
4309 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4310 __attribute__((unused)) struct cmdline *cl,
4313 struct cmd_set_promisc_mode_result *res = parsed_result;
4317 if (!strcmp(res->mode, "on"))
4324 for (i = 0; i < nb_ports; i++) {
4326 rte_eth_promiscuous_enable(i);
4328 rte_eth_promiscuous_disable(i);
4333 rte_eth_promiscuous_enable(res->port_num);
4335 rte_eth_promiscuous_disable(res->port_num);
4339 cmdline_parse_token_string_t cmd_setpromisc_set =
4340 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4341 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4342 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4344 cmdline_parse_token_string_t cmd_setpromisc_portall =
4345 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4347 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4348 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4350 cmdline_parse_token_string_t cmd_setpromisc_mode =
4351 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4354 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4355 .f = cmd_set_promisc_mode_parsed,
4357 .help_str = "set promisc all on|off: set promisc mode for all ports",
4359 (void *)&cmd_setpromisc_set,
4360 (void *)&cmd_setpromisc_promisc,
4361 (void *)&cmd_setpromisc_portall,
4362 (void *)&cmd_setpromisc_mode,
4367 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4368 .f = cmd_set_promisc_mode_parsed,
4370 .help_str = "set promisc X on|off: set promisc mode on port X",
4372 (void *)&cmd_setpromisc_set,
4373 (void *)&cmd_setpromisc_promisc,
4374 (void *)&cmd_setpromisc_portnum,
4375 (void *)&cmd_setpromisc_mode,
4380 /* *** SET ALLMULTI MODE *** */
4381 struct cmd_set_allmulti_mode_result {
4382 cmdline_fixed_string_t set;
4383 cmdline_fixed_string_t allmulti;
4384 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4385 uint8_t port_num; /* valid if "allports" argument == 0 */
4386 cmdline_fixed_string_t mode;
4389 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4390 __attribute__((unused)) struct cmdline *cl,
4393 struct cmd_set_allmulti_mode_result *res = parsed_result;
4397 if (!strcmp(res->mode, "on"))
4404 for (i = 0; i < nb_ports; i++) {
4406 rte_eth_allmulticast_enable(i);
4408 rte_eth_allmulticast_disable(i);
4413 rte_eth_allmulticast_enable(res->port_num);
4415 rte_eth_allmulticast_disable(res->port_num);
4419 cmdline_parse_token_string_t cmd_setallmulti_set =
4420 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4421 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4422 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4424 cmdline_parse_token_string_t cmd_setallmulti_portall =
4425 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4427 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4428 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4430 cmdline_parse_token_string_t cmd_setallmulti_mode =
4431 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4434 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4435 .f = cmd_set_allmulti_mode_parsed,
4437 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4439 (void *)&cmd_setallmulti_set,
4440 (void *)&cmd_setallmulti_allmulti,
4441 (void *)&cmd_setallmulti_portall,
4442 (void *)&cmd_setallmulti_mode,
4447 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4448 .f = cmd_set_allmulti_mode_parsed,
4450 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4452 (void *)&cmd_setallmulti_set,
4453 (void *)&cmd_setallmulti_allmulti,
4454 (void *)&cmd_setallmulti_portnum,
4455 (void *)&cmd_setallmulti_mode,
4460 /* *** ADD/REMOVE A PKT FILTER *** */
4461 struct cmd_pkt_filter_result {
4462 cmdline_fixed_string_t pkt_filter;
4464 cmdline_fixed_string_t protocol;
4465 cmdline_fixed_string_t src;
4466 cmdline_ipaddr_t ip_src;
4468 cmdline_fixed_string_t dst;
4469 cmdline_ipaddr_t ip_dst;
4471 cmdline_fixed_string_t flexbytes;
4472 uint16_t flexbytes_value;
4473 cmdline_fixed_string_t vlan;
4475 cmdline_fixed_string_t queue;
4477 cmdline_fixed_string_t soft;
4482 cmd_pkt_filter_parsed(void *parsed_result,
4483 __attribute__((unused)) struct cmdline *cl,
4484 __attribute__((unused)) void *data)
4486 struct rte_fdir_filter fdir_filter;
4487 struct cmd_pkt_filter_result *res = parsed_result;
4489 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4491 if (res->ip_src.family == AF_INET)
4492 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4494 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4495 &(res->ip_src.addr.ipv6),
4496 sizeof(struct in6_addr));
4498 if (res->ip_dst.family == AF_INET)
4499 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4501 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4502 &(res->ip_dst.addr.ipv6),
4503 sizeof(struct in6_addr));
4505 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4506 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4508 if (!strcmp(res->protocol, "udp"))
4509 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4510 else if (!strcmp(res->protocol, "tcp"))
4511 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4512 else if (!strcmp(res->protocol, "sctp"))
4513 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4514 else /* default only IP */
4515 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4517 if (res->ip_dst.family == AF_INET6)
4518 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4520 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4522 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4523 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4525 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4526 fdir_add_signature_filter(res->port_id, res->queue_id,
4528 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4529 fdir_update_signature_filter(res->port_id, res->queue_id,
4531 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4532 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4533 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4534 fdir_add_perfect_filter(res->port_id, res->soft_id,
4536 (uint8_t) (res->queue_id < 0),
4538 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4539 fdir_update_perfect_filter(res->port_id, res->soft_id,
4541 (uint8_t) (res->queue_id < 0),
4543 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4544 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4550 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4551 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4553 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4554 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4555 protocol, "ip#tcp#udp#sctp");
4556 cmdline_parse_token_string_t cmd_pkt_filter_src =
4557 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4559 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4560 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4562 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4563 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4565 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4566 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4568 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4569 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4571 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4572 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4574 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4575 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4576 flexbytes, "flexbytes");
4577 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4578 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4579 flexbytes_value, UINT16);
4580 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4581 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4583 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4584 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4586 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4587 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4589 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4590 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4592 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4593 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4595 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4596 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4600 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4601 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4602 pkt_filter, "add_signature_filter");
4603 cmdline_parse_inst_t cmd_add_signature_filter = {
4604 .f = cmd_pkt_filter_parsed,
4606 .help_str = "add a signature filter",
4608 (void *)&cmd_pkt_filter_add_signature_filter,
4609 (void *)&cmd_pkt_filter_port_id,
4610 (void *)&cmd_pkt_filter_protocol,
4611 (void *)&cmd_pkt_filter_src,
4612 (void *)&cmd_pkt_filter_ip_src,
4613 (void *)&cmd_pkt_filter_port_src,
4614 (void *)&cmd_pkt_filter_dst,
4615 (void *)&cmd_pkt_filter_ip_dst,
4616 (void *)&cmd_pkt_filter_port_dst,
4617 (void *)&cmd_pkt_filter_flexbytes,
4618 (void *)&cmd_pkt_filter_flexbytes_value,
4619 (void *)&cmd_pkt_filter_vlan,
4620 (void *)&cmd_pkt_filter_vlan_id,
4621 (void *)&cmd_pkt_filter_queue,
4622 (void *)&cmd_pkt_filter_queue_id,
4628 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4629 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4630 pkt_filter, "upd_signature_filter");
4631 cmdline_parse_inst_t cmd_upd_signature_filter = {
4632 .f = cmd_pkt_filter_parsed,
4634 .help_str = "update a signature filter",
4636 (void *)&cmd_pkt_filter_upd_signature_filter,
4637 (void *)&cmd_pkt_filter_port_id,
4638 (void *)&cmd_pkt_filter_protocol,
4639 (void *)&cmd_pkt_filter_src,
4640 (void *)&cmd_pkt_filter_ip_src,
4641 (void *)&cmd_pkt_filter_port_src,
4642 (void *)&cmd_pkt_filter_dst,
4643 (void *)&cmd_pkt_filter_ip_dst,
4644 (void *)&cmd_pkt_filter_port_dst,
4645 (void *)&cmd_pkt_filter_flexbytes,
4646 (void *)&cmd_pkt_filter_flexbytes_value,
4647 (void *)&cmd_pkt_filter_vlan,
4648 (void *)&cmd_pkt_filter_vlan_id,
4649 (void *)&cmd_pkt_filter_queue,
4650 (void *)&cmd_pkt_filter_queue_id,
4656 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4657 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4658 pkt_filter, "rm_signature_filter");
4659 cmdline_parse_inst_t cmd_rm_signature_filter = {
4660 .f = cmd_pkt_filter_parsed,
4662 .help_str = "remove a signature filter",
4664 (void *)&cmd_pkt_filter_rm_signature_filter,
4665 (void *)&cmd_pkt_filter_port_id,
4666 (void *)&cmd_pkt_filter_protocol,
4667 (void *)&cmd_pkt_filter_src,
4668 (void *)&cmd_pkt_filter_ip_src,
4669 (void *)&cmd_pkt_filter_port_src,
4670 (void *)&cmd_pkt_filter_dst,
4671 (void *)&cmd_pkt_filter_ip_dst,
4672 (void *)&cmd_pkt_filter_port_dst,
4673 (void *)&cmd_pkt_filter_flexbytes,
4674 (void *)&cmd_pkt_filter_flexbytes_value,
4675 (void *)&cmd_pkt_filter_vlan,
4676 (void *)&cmd_pkt_filter_vlan_id,
4682 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4683 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4684 pkt_filter, "add_perfect_filter");
4685 cmdline_parse_inst_t cmd_add_perfect_filter = {
4686 .f = cmd_pkt_filter_parsed,
4688 .help_str = "add a perfect filter",
4690 (void *)&cmd_pkt_filter_add_perfect_filter,
4691 (void *)&cmd_pkt_filter_port_id,
4692 (void *)&cmd_pkt_filter_protocol,
4693 (void *)&cmd_pkt_filter_src,
4694 (void *)&cmd_pkt_filter_ip_src,
4695 (void *)&cmd_pkt_filter_port_src,
4696 (void *)&cmd_pkt_filter_dst,
4697 (void *)&cmd_pkt_filter_ip_dst,
4698 (void *)&cmd_pkt_filter_port_dst,
4699 (void *)&cmd_pkt_filter_flexbytes,
4700 (void *)&cmd_pkt_filter_flexbytes_value,
4701 (void *)&cmd_pkt_filter_vlan,
4702 (void *)&cmd_pkt_filter_vlan_id,
4703 (void *)&cmd_pkt_filter_queue,
4704 (void *)&cmd_pkt_filter_queue_id,
4705 (void *)&cmd_pkt_filter_soft,
4706 (void *)&cmd_pkt_filter_soft_id,
4712 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4713 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4714 pkt_filter, "upd_perfect_filter");
4715 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4716 .f = cmd_pkt_filter_parsed,
4718 .help_str = "update a perfect filter",
4720 (void *)&cmd_pkt_filter_upd_perfect_filter,
4721 (void *)&cmd_pkt_filter_port_id,
4722 (void *)&cmd_pkt_filter_protocol,
4723 (void *)&cmd_pkt_filter_src,
4724 (void *)&cmd_pkt_filter_ip_src,
4725 (void *)&cmd_pkt_filter_port_src,
4726 (void *)&cmd_pkt_filter_dst,
4727 (void *)&cmd_pkt_filter_ip_dst,
4728 (void *)&cmd_pkt_filter_port_dst,
4729 (void *)&cmd_pkt_filter_flexbytes,
4730 (void *)&cmd_pkt_filter_flexbytes_value,
4731 (void *)&cmd_pkt_filter_vlan,
4732 (void *)&cmd_pkt_filter_vlan_id,
4733 (void *)&cmd_pkt_filter_queue,
4734 (void *)&cmd_pkt_filter_queue_id,
4735 (void *)&cmd_pkt_filter_soft,
4736 (void *)&cmd_pkt_filter_soft_id,
4742 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4743 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4744 pkt_filter, "rm_perfect_filter");
4745 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4746 .f = cmd_pkt_filter_parsed,
4748 .help_str = "remove a perfect filter",
4750 (void *)&cmd_pkt_filter_rm_perfect_filter,
4751 (void *)&cmd_pkt_filter_port_id,
4752 (void *)&cmd_pkt_filter_protocol,
4753 (void *)&cmd_pkt_filter_src,
4754 (void *)&cmd_pkt_filter_ip_src,
4755 (void *)&cmd_pkt_filter_port_src,
4756 (void *)&cmd_pkt_filter_dst,
4757 (void *)&cmd_pkt_filter_ip_dst,
4758 (void *)&cmd_pkt_filter_port_dst,
4759 (void *)&cmd_pkt_filter_flexbytes,
4760 (void *)&cmd_pkt_filter_flexbytes_value,
4761 (void *)&cmd_pkt_filter_vlan,
4762 (void *)&cmd_pkt_filter_vlan_id,
4763 (void *)&cmd_pkt_filter_soft,
4764 (void *)&cmd_pkt_filter_soft_id,
4769 /* *** SETUP MASKS FILTER *** */
4770 struct cmd_pkt_filter_masks_result {
4771 cmdline_fixed_string_t filter_mask;
4773 cmdline_fixed_string_t src_mask;
4774 uint32_t ip_src_mask;
4775 uint16_t ipv6_src_mask;
4776 uint16_t port_src_mask;
4777 cmdline_fixed_string_t dst_mask;
4778 uint32_t ip_dst_mask;
4779 uint16_t ipv6_dst_mask;
4780 uint16_t port_dst_mask;
4781 cmdline_fixed_string_t flexbytes;
4782 uint8_t flexbytes_value;
4783 cmdline_fixed_string_t vlan_id;
4784 uint8_t vlan_id_value;
4785 cmdline_fixed_string_t vlan_prio;
4786 uint8_t vlan_prio_value;
4787 cmdline_fixed_string_t only_ip_flow;
4788 uint8_t only_ip_flow_value;
4789 cmdline_fixed_string_t comp_ipv6_dst;
4790 uint8_t comp_ipv6_dst_value;
4794 cmd_pkt_filter_masks_parsed(void *parsed_result,
4795 __attribute__((unused)) struct cmdline *cl,
4796 __attribute__((unused)) void *data)
4798 struct rte_fdir_masks fdir_masks;
4799 struct cmd_pkt_filter_masks_result *res = parsed_result;
4801 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4803 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4804 fdir_masks.vlan_id = res->vlan_id_value;
4805 fdir_masks.vlan_prio = res->vlan_prio_value;
4806 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4807 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4808 fdir_masks.src_port_mask = res->port_src_mask;
4809 fdir_masks.dst_port_mask = res->port_dst_mask;
4810 fdir_masks.flexbytes = res->flexbytes_value;
4812 fdir_set_masks(res->port_id, &fdir_masks);
4815 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4816 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4817 filter_mask, "set_masks_filter");
4818 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4819 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4821 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4822 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4823 only_ip_flow, "only_ip_flow");
4824 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4825 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4826 only_ip_flow_value, UINT8);
4827 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4828 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4829 src_mask, "src_mask");
4830 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4831 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4832 ip_src_mask, UINT32);
4833 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4834 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4835 port_src_mask, UINT16);
4836 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4837 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4838 dst_mask, "dst_mask");
4839 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4840 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4841 ip_dst_mask, UINT32);
4842 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4843 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4844 port_dst_mask, UINT16);
4845 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4846 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4847 flexbytes, "flexbytes");
4848 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4849 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4850 flexbytes_value, UINT8);
4851 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4852 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4853 vlan_id, "vlan_id");
4854 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4855 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4856 vlan_id_value, UINT8);
4857 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4858 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4859 vlan_prio, "vlan_prio");
4860 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4861 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4862 vlan_prio_value, UINT8);
4864 cmdline_parse_inst_t cmd_set_masks_filter = {
4865 .f = cmd_pkt_filter_masks_parsed,
4867 .help_str = "setup masks filter",
4869 (void *)&cmd_pkt_filter_masks_filter_mask,
4870 (void *)&cmd_pkt_filter_masks_port_id,
4871 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4872 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4873 (void *)&cmd_pkt_filter_masks_src_mask,
4874 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4875 (void *)&cmd_pkt_filter_masks_port_src_mask,
4876 (void *)&cmd_pkt_filter_masks_dst_mask,
4877 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4878 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4879 (void *)&cmd_pkt_filter_masks_flexbytes,
4880 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4881 (void *)&cmd_pkt_filter_masks_vlan_id,
4882 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4883 (void *)&cmd_pkt_filter_masks_vlan_prio,
4884 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4890 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4891 __attribute__((unused)) struct cmdline *cl,
4892 __attribute__((unused)) void *data)
4894 struct rte_fdir_masks fdir_masks;
4895 struct cmd_pkt_filter_masks_result *res = parsed_result;
4897 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4899 fdir_masks.set_ipv6_mask = 1;
4900 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4901 fdir_masks.vlan_id = res->vlan_id_value;
4902 fdir_masks.vlan_prio = res->vlan_prio_value;
4903 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4904 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4905 fdir_masks.src_port_mask = res->port_src_mask;
4906 fdir_masks.dst_port_mask = res->port_dst_mask;
4907 fdir_masks.flexbytes = res->flexbytes_value;
4908 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4910 fdir_set_masks(res->port_id, &fdir_masks);
4913 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4914 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4915 filter_mask, "set_ipv6_masks_filter");
4916 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4917 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4918 ipv6_src_mask, UINT16);
4919 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4920 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4921 ipv6_dst_mask, UINT16);
4923 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4924 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4925 comp_ipv6_dst, "compare_dst");
4926 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4927 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4928 comp_ipv6_dst_value, UINT8);
4930 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4931 .f = cmd_pkt_filter_masks_ipv6_parsed,
4933 .help_str = "setup ipv6 masks filter",
4935 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4936 (void *)&cmd_pkt_filter_masks_port_id,
4937 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4938 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4939 (void *)&cmd_pkt_filter_masks_src_mask,
4940 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4941 (void *)&cmd_pkt_filter_masks_port_src_mask,
4942 (void *)&cmd_pkt_filter_masks_dst_mask,
4943 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4944 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4945 (void *)&cmd_pkt_filter_masks_flexbytes,
4946 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4947 (void *)&cmd_pkt_filter_masks_vlan_id,
4948 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4949 (void *)&cmd_pkt_filter_masks_vlan_prio,
4950 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4951 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4952 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4957 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4958 struct cmd_link_flow_ctrl_set_result {
4959 cmdline_fixed_string_t set;
4960 cmdline_fixed_string_t flow_ctrl;
4961 cmdline_fixed_string_t rx;
4962 cmdline_fixed_string_t rx_lfc_mode;
4963 cmdline_fixed_string_t tx;
4964 cmdline_fixed_string_t tx_lfc_mode;
4965 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4966 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4967 cmdline_fixed_string_t autoneg_str;
4968 cmdline_fixed_string_t autoneg;
4969 cmdline_fixed_string_t hw_str;
4970 uint32_t high_water;
4971 cmdline_fixed_string_t lw_str;
4973 cmdline_fixed_string_t pt_str;
4974 uint16_t pause_time;
4975 cmdline_fixed_string_t xon_str;
4980 cmdline_parse_token_string_t cmd_lfc_set_set =
4981 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4983 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4984 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4985 flow_ctrl, "flow_ctrl");
4986 cmdline_parse_token_string_t cmd_lfc_set_rx =
4987 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4989 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4990 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4991 rx_lfc_mode, "on#off");
4992 cmdline_parse_token_string_t cmd_lfc_set_tx =
4993 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4995 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4996 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4997 tx_lfc_mode, "on#off");
4998 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4999 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5000 hw_str, "high_water");
5001 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5002 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5003 high_water, UINT32);
5004 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5005 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5006 lw_str, "low_water");
5007 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5008 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5010 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5011 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5012 pt_str, "pause_time");
5013 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5014 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5015 pause_time, UINT16);
5016 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5017 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5018 xon_str, "send_xon");
5019 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5020 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5022 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5023 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5024 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5025 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5026 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5027 mac_ctrl_frame_fwd_mode, "on#off");
5028 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5029 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5030 autoneg_str, "autoneg");
5031 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5032 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5034 cmdline_parse_token_num_t cmd_lfc_set_portid =
5035 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5038 /* forward declaration */
5040 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5043 cmdline_parse_inst_t cmd_link_flow_control_set = {
5044 .f = cmd_link_flow_ctrl_set_parsed,
5046 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
5047 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
5048 autoneg on|off port_id",
5050 (void *)&cmd_lfc_set_set,
5051 (void *)&cmd_lfc_set_flow_ctrl,
5052 (void *)&cmd_lfc_set_rx,
5053 (void *)&cmd_lfc_set_rx_mode,
5054 (void *)&cmd_lfc_set_tx,
5055 (void *)&cmd_lfc_set_tx_mode,
5056 (void *)&cmd_lfc_set_high_water,
5057 (void *)&cmd_lfc_set_low_water,
5058 (void *)&cmd_lfc_set_pause_time,
5059 (void *)&cmd_lfc_set_send_xon,
5060 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5061 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5062 (void *)&cmd_lfc_set_autoneg_str,
5063 (void *)&cmd_lfc_set_autoneg,
5064 (void *)&cmd_lfc_set_portid,
5069 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5070 .f = cmd_link_flow_ctrl_set_parsed,
5071 .data = (void *)&cmd_link_flow_control_set_rx,
5072 .help_str = "Change rx flow control parameter: set flow_ctrl "
5073 "rx on|off port_id",
5075 (void *)&cmd_lfc_set_set,
5076 (void *)&cmd_lfc_set_flow_ctrl,
5077 (void *)&cmd_lfc_set_rx,
5078 (void *)&cmd_lfc_set_rx_mode,
5079 (void *)&cmd_lfc_set_portid,
5084 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5085 .f = cmd_link_flow_ctrl_set_parsed,
5086 .data = (void *)&cmd_link_flow_control_set_tx,
5087 .help_str = "Change tx flow control parameter: set flow_ctrl "
5088 "tx on|off port_id",
5090 (void *)&cmd_lfc_set_set,
5091 (void *)&cmd_lfc_set_flow_ctrl,
5092 (void *)&cmd_lfc_set_tx,
5093 (void *)&cmd_lfc_set_tx_mode,
5094 (void *)&cmd_lfc_set_portid,
5099 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5100 .f = cmd_link_flow_ctrl_set_parsed,
5101 .data = (void *)&cmd_link_flow_control_set_hw,
5102 .help_str = "Change high water flow control parameter: set flow_ctrl "
5103 "high_water value port_id",
5105 (void *)&cmd_lfc_set_set,
5106 (void *)&cmd_lfc_set_flow_ctrl,
5107 (void *)&cmd_lfc_set_high_water_str,
5108 (void *)&cmd_lfc_set_high_water,
5109 (void *)&cmd_lfc_set_portid,
5114 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5115 .f = cmd_link_flow_ctrl_set_parsed,
5116 .data = (void *)&cmd_link_flow_control_set_lw,
5117 .help_str = "Change low water flow control parameter: set flow_ctrl "
5118 "low_water value port_id",
5120 (void *)&cmd_lfc_set_set,
5121 (void *)&cmd_lfc_set_flow_ctrl,
5122 (void *)&cmd_lfc_set_low_water_str,
5123 (void *)&cmd_lfc_set_low_water,
5124 (void *)&cmd_lfc_set_portid,
5129 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5130 .f = cmd_link_flow_ctrl_set_parsed,
5131 .data = (void *)&cmd_link_flow_control_set_pt,
5132 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5133 "pause_time value port_id",
5135 (void *)&cmd_lfc_set_set,
5136 (void *)&cmd_lfc_set_flow_ctrl,
5137 (void *)&cmd_lfc_set_pause_time_str,
5138 (void *)&cmd_lfc_set_pause_time,
5139 (void *)&cmd_lfc_set_portid,
5144 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5145 .f = cmd_link_flow_ctrl_set_parsed,
5146 .data = (void *)&cmd_link_flow_control_set_xon,
5147 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5148 "send_xon value port_id",
5150 (void *)&cmd_lfc_set_set,
5151 (void *)&cmd_lfc_set_flow_ctrl,
5152 (void *)&cmd_lfc_set_send_xon_str,
5153 (void *)&cmd_lfc_set_send_xon,
5154 (void *)&cmd_lfc_set_portid,
5159 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5160 .f = cmd_link_flow_ctrl_set_parsed,
5161 .data = (void *)&cmd_link_flow_control_set_macfwd,
5162 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5163 "mac_ctrl_frame_fwd on|off port_id",
5165 (void *)&cmd_lfc_set_set,
5166 (void *)&cmd_lfc_set_flow_ctrl,
5167 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5168 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5169 (void *)&cmd_lfc_set_portid,
5174 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5175 .f = cmd_link_flow_ctrl_set_parsed,
5176 .data = (void *)&cmd_link_flow_control_set_autoneg,
5177 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5178 "autoneg on|off port_id",
5180 (void *)&cmd_lfc_set_set,
5181 (void *)&cmd_lfc_set_flow_ctrl,
5182 (void *)&cmd_lfc_set_autoneg_str,
5183 (void *)&cmd_lfc_set_autoneg,
5184 (void *)&cmd_lfc_set_portid,
5190 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5191 __attribute__((unused)) struct cmdline *cl,
5194 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5195 cmdline_parse_inst_t *cmd = data;
5196 struct rte_eth_fc_conf fc_conf;
5197 int rx_fc_en, tx_fc_en;
5201 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5202 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5203 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5204 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5206 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5207 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5210 /* Partial command line, retrieve current configuration */
5212 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5214 printf("cannot get current flow ctrl parameters, return"
5215 "code = %d\n", ret);
5219 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5220 (fc_conf.mode == RTE_FC_FULL))
5222 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5223 (fc_conf.mode == RTE_FC_FULL))
5227 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5228 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5230 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5231 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5233 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5235 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5236 fc_conf.high_water = res->high_water;
5238 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5239 fc_conf.low_water = res->low_water;
5241 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5242 fc_conf.pause_time = res->pause_time;
5244 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5245 fc_conf.send_xon = res->send_xon;
5247 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5248 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5249 fc_conf.mac_ctrl_frame_fwd = 1;
5251 fc_conf.mac_ctrl_frame_fwd = 0;
5254 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5255 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5257 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5259 printf("bad flow contrl parameter, return code = %d \n", ret);
5262 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5263 struct cmd_priority_flow_ctrl_set_result {
5264 cmdline_fixed_string_t set;
5265 cmdline_fixed_string_t pfc_ctrl;
5266 cmdline_fixed_string_t rx;
5267 cmdline_fixed_string_t rx_pfc_mode;
5268 cmdline_fixed_string_t tx;
5269 cmdline_fixed_string_t tx_pfc_mode;
5270 uint32_t high_water;
5272 uint16_t pause_time;
5278 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5279 __attribute__((unused)) struct cmdline *cl,
5280 __attribute__((unused)) void *data)
5282 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5283 struct rte_eth_pfc_conf pfc_conf;
5284 int rx_fc_enable, tx_fc_enable;
5288 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5289 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5290 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5291 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5293 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5294 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5297 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5298 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5299 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5300 pfc_conf.fc.high_water = res->high_water;
5301 pfc_conf.fc.low_water = res->low_water;
5302 pfc_conf.fc.pause_time = res->pause_time;
5303 pfc_conf.priority = res->priority;
5305 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5307 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5310 cmdline_parse_token_string_t cmd_pfc_set_set =
5311 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5313 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5314 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5315 pfc_ctrl, "pfc_ctrl");
5316 cmdline_parse_token_string_t cmd_pfc_set_rx =
5317 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5319 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5320 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5321 rx_pfc_mode, "on#off");
5322 cmdline_parse_token_string_t cmd_pfc_set_tx =
5323 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5325 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5326 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5327 tx_pfc_mode, "on#off");
5328 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5329 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5330 high_water, UINT32);
5331 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5332 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5334 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5335 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5336 pause_time, UINT16);
5337 cmdline_parse_token_num_t cmd_pfc_set_priority =
5338 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5340 cmdline_parse_token_num_t cmd_pfc_set_portid =
5341 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5344 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5345 .f = cmd_priority_flow_ctrl_set_parsed,
5347 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5348 tx on|off high_water low_water pause_time priority port_id",
5350 (void *)&cmd_pfc_set_set,
5351 (void *)&cmd_pfc_set_flow_ctrl,
5352 (void *)&cmd_pfc_set_rx,
5353 (void *)&cmd_pfc_set_rx_mode,
5354 (void *)&cmd_pfc_set_tx,
5355 (void *)&cmd_pfc_set_tx_mode,
5356 (void *)&cmd_pfc_set_high_water,
5357 (void *)&cmd_pfc_set_low_water,
5358 (void *)&cmd_pfc_set_pause_time,
5359 (void *)&cmd_pfc_set_priority,
5360 (void *)&cmd_pfc_set_portid,
5365 /* *** RESET CONFIGURATION *** */
5366 struct cmd_reset_result {
5367 cmdline_fixed_string_t reset;
5368 cmdline_fixed_string_t def;
5371 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5373 __attribute__((unused)) void *data)
5375 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5376 set_def_fwd_config();
5379 cmdline_parse_token_string_t cmd_reset_set =
5380 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5381 cmdline_parse_token_string_t cmd_reset_def =
5382 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5385 cmdline_parse_inst_t cmd_reset = {
5386 .f = cmd_reset_parsed,
5388 .help_str = "set default: reset default forwarding configuration",
5390 (void *)&cmd_reset_set,
5391 (void *)&cmd_reset_def,
5396 /* *** START FORWARDING *** */
5397 struct cmd_start_result {
5398 cmdline_fixed_string_t start;
5401 cmdline_parse_token_string_t cmd_start_start =
5402 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5404 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5405 __attribute__((unused)) struct cmdline *cl,
5406 __attribute__((unused)) void *data)
5408 start_packet_forwarding(0);
5411 cmdline_parse_inst_t cmd_start = {
5412 .f = cmd_start_parsed,
5414 .help_str = "start packet forwarding",
5416 (void *)&cmd_start_start,
5421 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5422 struct cmd_start_tx_first_result {
5423 cmdline_fixed_string_t start;
5424 cmdline_fixed_string_t tx_first;
5428 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5429 __attribute__((unused)) struct cmdline *cl,
5430 __attribute__((unused)) void *data)
5432 start_packet_forwarding(1);
5435 cmdline_parse_token_string_t cmd_start_tx_first_start =
5436 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5438 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5439 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5440 tx_first, "tx_first");
5442 cmdline_parse_inst_t cmd_start_tx_first = {
5443 .f = cmd_start_tx_first_parsed,
5445 .help_str = "start packet forwarding, after sending 1 burst of packets",
5447 (void *)&cmd_start_tx_first_start,
5448 (void *)&cmd_start_tx_first_tx_first,
5453 /* *** SET LINK UP *** */
5454 struct cmd_set_link_up_result {
5455 cmdline_fixed_string_t set;
5456 cmdline_fixed_string_t link_up;
5457 cmdline_fixed_string_t port;
5461 cmdline_parse_token_string_t cmd_set_link_up_set =
5462 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5463 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5464 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5466 cmdline_parse_token_string_t cmd_set_link_up_port =
5467 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5468 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5469 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5471 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5472 __attribute__((unused)) struct cmdline *cl,
5473 __attribute__((unused)) void *data)
5475 struct cmd_set_link_up_result *res = parsed_result;
5476 dev_set_link_up(res->port_id);
5479 cmdline_parse_inst_t cmd_set_link_up = {
5480 .f = cmd_set_link_up_parsed,
5482 .help_str = "set link-up port (port id)",
5484 (void *)&cmd_set_link_up_set,
5485 (void *)&cmd_set_link_up_link_up,
5486 (void *)&cmd_set_link_up_port,
5487 (void *)&cmd_set_link_up_port_id,
5492 /* *** SET LINK DOWN *** */
5493 struct cmd_set_link_down_result {
5494 cmdline_fixed_string_t set;
5495 cmdline_fixed_string_t link_down;
5496 cmdline_fixed_string_t port;
5500 cmdline_parse_token_string_t cmd_set_link_down_set =
5501 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5502 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5503 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5505 cmdline_parse_token_string_t cmd_set_link_down_port =
5506 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5507 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5508 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5510 static void cmd_set_link_down_parsed(
5511 __attribute__((unused)) void *parsed_result,
5512 __attribute__((unused)) struct cmdline *cl,
5513 __attribute__((unused)) void *data)
5515 struct cmd_set_link_down_result *res = parsed_result;
5516 dev_set_link_down(res->port_id);
5519 cmdline_parse_inst_t cmd_set_link_down = {
5520 .f = cmd_set_link_down_parsed,
5522 .help_str = "set link-down port (port id)",
5524 (void *)&cmd_set_link_down_set,
5525 (void *)&cmd_set_link_down_link_down,
5526 (void *)&cmd_set_link_down_port,
5527 (void *)&cmd_set_link_down_port_id,
5532 /* *** SHOW CFG *** */
5533 struct cmd_showcfg_result {
5534 cmdline_fixed_string_t show;
5535 cmdline_fixed_string_t cfg;
5536 cmdline_fixed_string_t what;
5539 static void cmd_showcfg_parsed(void *parsed_result,
5540 __attribute__((unused)) struct cmdline *cl,
5541 __attribute__((unused)) void *data)
5543 struct cmd_showcfg_result *res = parsed_result;
5544 if (!strcmp(res->what, "rxtx"))
5545 rxtx_config_display();
5546 else if (!strcmp(res->what, "cores"))
5547 fwd_lcores_config_display();
5548 else if (!strcmp(res->what, "fwd"))
5549 fwd_config_display();
5552 cmdline_parse_token_string_t cmd_showcfg_show =
5553 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5554 cmdline_parse_token_string_t cmd_showcfg_port =
5555 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5556 cmdline_parse_token_string_t cmd_showcfg_what =
5557 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5560 cmdline_parse_inst_t cmd_showcfg = {
5561 .f = cmd_showcfg_parsed,
5563 .help_str = "show config rxtx|cores|fwd",
5565 (void *)&cmd_showcfg_show,
5566 (void *)&cmd_showcfg_port,
5567 (void *)&cmd_showcfg_what,
5572 /* *** SHOW ALL PORT INFO *** */
5573 struct cmd_showportall_result {
5574 cmdline_fixed_string_t show;
5575 cmdline_fixed_string_t port;
5576 cmdline_fixed_string_t what;
5577 cmdline_fixed_string_t all;
5580 static void cmd_showportall_parsed(void *parsed_result,
5581 __attribute__((unused)) struct cmdline *cl,
5582 __attribute__((unused)) void *data)
5586 struct cmd_showportall_result *res = parsed_result;
5587 if (!strcmp(res->show, "clear")) {
5588 if (!strcmp(res->what, "stats"))
5589 for (i = 0; i < nb_ports; i++)
5591 else if (!strcmp(res->what, "xstats"))
5592 for (i = 0; i < nb_ports; i++)
5593 nic_xstats_clear(i);
5594 } else if (!strcmp(res->what, "info"))
5595 for (i = 0; i < nb_ports; i++)
5596 port_infos_display(i);
5597 else if (!strcmp(res->what, "stats"))
5598 for (i = 0; i < nb_ports; i++)
5599 nic_stats_display(i);
5600 else if (!strcmp(res->what, "xstats"))
5601 for (i = 0; i < nb_ports; i++)
5602 nic_xstats_display(i);
5603 else if (!strcmp(res->what, "fdir"))
5604 for (i = 0; i < nb_ports; i++)
5606 else if (!strcmp(res->what, "stat_qmap"))
5607 for (i = 0; i < nb_ports; i++)
5608 nic_stats_mapping_display(i);
5611 cmdline_parse_token_string_t cmd_showportall_show =
5612 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5614 cmdline_parse_token_string_t cmd_showportall_port =
5615 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5616 cmdline_parse_token_string_t cmd_showportall_what =
5617 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5618 "info#stats#xstats#fdir#stat_qmap");
5619 cmdline_parse_token_string_t cmd_showportall_all =
5620 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5621 cmdline_parse_inst_t cmd_showportall = {
5622 .f = cmd_showportall_parsed,
5624 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5626 (void *)&cmd_showportall_show,
5627 (void *)&cmd_showportall_port,
5628 (void *)&cmd_showportall_what,
5629 (void *)&cmd_showportall_all,
5634 /* *** SHOW PORT INFO *** */
5635 struct cmd_showport_result {
5636 cmdline_fixed_string_t show;
5637 cmdline_fixed_string_t port;
5638 cmdline_fixed_string_t what;
5642 static void cmd_showport_parsed(void *parsed_result,
5643 __attribute__((unused)) struct cmdline *cl,
5644 __attribute__((unused)) void *data)
5646 struct cmd_showport_result *res = parsed_result;
5647 if (!strcmp(res->show, "clear")) {
5648 if (!strcmp(res->what, "stats"))
5649 nic_stats_clear(res->portnum);
5650 else if (!strcmp(res->what, "xstats"))
5651 nic_xstats_clear(res->portnum);
5652 } else if (!strcmp(res->what, "info"))
5653 port_infos_display(res->portnum);
5654 else if (!strcmp(res->what, "stats"))
5655 nic_stats_display(res->portnum);
5656 else if (!strcmp(res->what, "xstats"))
5657 nic_xstats_display(res->portnum);
5658 else if (!strcmp(res->what, "fdir"))
5659 fdir_get_infos(res->portnum);
5660 else if (!strcmp(res->what, "stat_qmap"))
5661 nic_stats_mapping_display(res->portnum);
5664 cmdline_parse_token_string_t cmd_showport_show =
5665 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5667 cmdline_parse_token_string_t cmd_showport_port =
5668 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5669 cmdline_parse_token_string_t cmd_showport_what =
5670 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5671 "info#stats#xstats#fdir#stat_qmap");
5672 cmdline_parse_token_num_t cmd_showport_portnum =
5673 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5675 cmdline_parse_inst_t cmd_showport = {
5676 .f = cmd_showport_parsed,
5678 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5680 (void *)&cmd_showport_show,
5681 (void *)&cmd_showport_port,
5682 (void *)&cmd_showport_what,
5683 (void *)&cmd_showport_portnum,
5688 /* *** READ PORT REGISTER *** */
5689 struct cmd_read_reg_result {
5690 cmdline_fixed_string_t read;
5691 cmdline_fixed_string_t reg;
5697 cmd_read_reg_parsed(void *parsed_result,
5698 __attribute__((unused)) struct cmdline *cl,
5699 __attribute__((unused)) void *data)
5701 struct cmd_read_reg_result *res = parsed_result;
5702 port_reg_display(res->port_id, res->reg_off);
5705 cmdline_parse_token_string_t cmd_read_reg_read =
5706 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5707 cmdline_parse_token_string_t cmd_read_reg_reg =
5708 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5709 cmdline_parse_token_num_t cmd_read_reg_port_id =
5710 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5711 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5712 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5714 cmdline_parse_inst_t cmd_read_reg = {
5715 .f = cmd_read_reg_parsed,
5717 .help_str = "read reg port_id reg_off",
5719 (void *)&cmd_read_reg_read,
5720 (void *)&cmd_read_reg_reg,
5721 (void *)&cmd_read_reg_port_id,
5722 (void *)&cmd_read_reg_reg_off,
5727 /* *** READ PORT REGISTER BIT FIELD *** */
5728 struct cmd_read_reg_bit_field_result {
5729 cmdline_fixed_string_t read;
5730 cmdline_fixed_string_t regfield;
5738 cmd_read_reg_bit_field_parsed(void *parsed_result,
5739 __attribute__((unused)) struct cmdline *cl,
5740 __attribute__((unused)) void *data)
5742 struct cmd_read_reg_bit_field_result *res = parsed_result;
5743 port_reg_bit_field_display(res->port_id, res->reg_off,
5744 res->bit1_pos, res->bit2_pos);
5747 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5748 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5750 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5751 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5752 regfield, "regfield");
5753 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5754 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5756 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5757 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5759 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5760 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5762 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5763 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5766 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5767 .f = cmd_read_reg_bit_field_parsed,
5769 .help_str = "read regfield port_id reg_off bit_x bit_y "
5770 "(read register bit field between bit_x and bit_y included)",
5772 (void *)&cmd_read_reg_bit_field_read,
5773 (void *)&cmd_read_reg_bit_field_regfield,
5774 (void *)&cmd_read_reg_bit_field_port_id,
5775 (void *)&cmd_read_reg_bit_field_reg_off,
5776 (void *)&cmd_read_reg_bit_field_bit1_pos,
5777 (void *)&cmd_read_reg_bit_field_bit2_pos,
5782 /* *** READ PORT REGISTER BIT *** */
5783 struct cmd_read_reg_bit_result {
5784 cmdline_fixed_string_t read;
5785 cmdline_fixed_string_t regbit;
5792 cmd_read_reg_bit_parsed(void *parsed_result,
5793 __attribute__((unused)) struct cmdline *cl,
5794 __attribute__((unused)) void *data)
5796 struct cmd_read_reg_bit_result *res = parsed_result;
5797 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5800 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5801 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5802 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5803 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5805 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5806 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5807 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5808 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5809 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5810 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5812 cmdline_parse_inst_t cmd_read_reg_bit = {
5813 .f = cmd_read_reg_bit_parsed,
5815 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5817 (void *)&cmd_read_reg_bit_read,
5818 (void *)&cmd_read_reg_bit_regbit,
5819 (void *)&cmd_read_reg_bit_port_id,
5820 (void *)&cmd_read_reg_bit_reg_off,
5821 (void *)&cmd_read_reg_bit_bit_pos,
5826 /* *** WRITE PORT REGISTER *** */
5827 struct cmd_write_reg_result {
5828 cmdline_fixed_string_t write;
5829 cmdline_fixed_string_t reg;
5836 cmd_write_reg_parsed(void *parsed_result,
5837 __attribute__((unused)) struct cmdline *cl,
5838 __attribute__((unused)) void *data)
5840 struct cmd_write_reg_result *res = parsed_result;
5841 port_reg_set(res->port_id, res->reg_off, res->value);
5844 cmdline_parse_token_string_t cmd_write_reg_write =
5845 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5846 cmdline_parse_token_string_t cmd_write_reg_reg =
5847 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5848 cmdline_parse_token_num_t cmd_write_reg_port_id =
5849 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5850 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5851 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5852 cmdline_parse_token_num_t cmd_write_reg_value =
5853 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5855 cmdline_parse_inst_t cmd_write_reg = {
5856 .f = cmd_write_reg_parsed,
5858 .help_str = "write reg port_id reg_off reg_value",
5860 (void *)&cmd_write_reg_write,
5861 (void *)&cmd_write_reg_reg,
5862 (void *)&cmd_write_reg_port_id,
5863 (void *)&cmd_write_reg_reg_off,
5864 (void *)&cmd_write_reg_value,
5869 /* *** WRITE PORT REGISTER BIT FIELD *** */
5870 struct cmd_write_reg_bit_field_result {
5871 cmdline_fixed_string_t write;
5872 cmdline_fixed_string_t regfield;
5881 cmd_write_reg_bit_field_parsed(void *parsed_result,
5882 __attribute__((unused)) struct cmdline *cl,
5883 __attribute__((unused)) void *data)
5885 struct cmd_write_reg_bit_field_result *res = parsed_result;
5886 port_reg_bit_field_set(res->port_id, res->reg_off,
5887 res->bit1_pos, res->bit2_pos, res->value);
5890 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5891 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5893 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5894 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5895 regfield, "regfield");
5896 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5897 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5899 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5900 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5902 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5903 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5905 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5906 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5908 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5909 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5912 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5913 .f = cmd_write_reg_bit_field_parsed,
5915 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5916 "(set register bit field between bit_x and bit_y included)",
5918 (void *)&cmd_write_reg_bit_field_write,
5919 (void *)&cmd_write_reg_bit_field_regfield,
5920 (void *)&cmd_write_reg_bit_field_port_id,
5921 (void *)&cmd_write_reg_bit_field_reg_off,
5922 (void *)&cmd_write_reg_bit_field_bit1_pos,
5923 (void *)&cmd_write_reg_bit_field_bit2_pos,
5924 (void *)&cmd_write_reg_bit_field_value,
5929 /* *** WRITE PORT REGISTER BIT *** */
5930 struct cmd_write_reg_bit_result {
5931 cmdline_fixed_string_t write;
5932 cmdline_fixed_string_t regbit;
5940 cmd_write_reg_bit_parsed(void *parsed_result,
5941 __attribute__((unused)) struct cmdline *cl,
5942 __attribute__((unused)) void *data)
5944 struct cmd_write_reg_bit_result *res = parsed_result;
5945 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5948 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5949 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5951 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5952 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5954 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5955 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5956 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5957 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5958 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5959 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5960 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5961 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5963 cmdline_parse_inst_t cmd_write_reg_bit = {
5964 .f = cmd_write_reg_bit_parsed,
5966 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5968 (void *)&cmd_write_reg_bit_write,
5969 (void *)&cmd_write_reg_bit_regbit,
5970 (void *)&cmd_write_reg_bit_port_id,
5971 (void *)&cmd_write_reg_bit_reg_off,
5972 (void *)&cmd_write_reg_bit_bit_pos,
5973 (void *)&cmd_write_reg_bit_value,
5978 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5979 struct cmd_read_rxd_txd_result {
5980 cmdline_fixed_string_t read;
5981 cmdline_fixed_string_t rxd_txd;
5988 cmd_read_rxd_txd_parsed(void *parsed_result,
5989 __attribute__((unused)) struct cmdline *cl,
5990 __attribute__((unused)) void *data)
5992 struct cmd_read_rxd_txd_result *res = parsed_result;
5994 if (!strcmp(res->rxd_txd, "rxd"))
5995 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5996 else if (!strcmp(res->rxd_txd, "txd"))
5997 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6000 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6001 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6002 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6003 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6005 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6006 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6007 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6008 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6009 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6010 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6012 cmdline_parse_inst_t cmd_read_rxd_txd = {
6013 .f = cmd_read_rxd_txd_parsed,
6015 .help_str = "read rxd|txd port_id queue_id rxd_id",
6017 (void *)&cmd_read_rxd_txd_read,
6018 (void *)&cmd_read_rxd_txd_rxd_txd,
6019 (void *)&cmd_read_rxd_txd_port_id,
6020 (void *)&cmd_read_rxd_txd_queue_id,
6021 (void *)&cmd_read_rxd_txd_desc_id,
6027 struct cmd_quit_result {
6028 cmdline_fixed_string_t quit;
6031 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6033 __attribute__((unused)) void *data)
6039 cmdline_parse_token_string_t cmd_quit_quit =
6040 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6042 cmdline_parse_inst_t cmd_quit = {
6043 .f = cmd_quit_parsed,
6045 .help_str = "exit application",
6047 (void *)&cmd_quit_quit,
6052 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6053 struct cmd_mac_addr_result {
6054 cmdline_fixed_string_t mac_addr_cmd;
6055 cmdline_fixed_string_t what;
6057 struct ether_addr address;
6060 static void cmd_mac_addr_parsed(void *parsed_result,
6061 __attribute__((unused)) struct cmdline *cl,
6062 __attribute__((unused)) void *data)
6064 struct cmd_mac_addr_result *res = parsed_result;
6067 if (strcmp(res->what, "add") == 0)
6068 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6070 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6072 /* check the return value and print it if is < 0 */
6074 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6078 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6079 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6081 cmdline_parse_token_string_t cmd_mac_addr_what =
6082 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6084 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6085 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6086 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6087 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6089 cmdline_parse_inst_t cmd_mac_addr = {
6090 .f = cmd_mac_addr_parsed,
6092 .help_str = "mac_addr add|remove X <address>: "
6093 "add/remove MAC address on port X",
6095 (void *)&cmd_mac_addr_cmd,
6096 (void *)&cmd_mac_addr_what,
6097 (void *)&cmd_mac_addr_portnum,
6098 (void *)&cmd_mac_addr_addr,
6104 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6105 struct cmd_set_qmap_result {
6106 cmdline_fixed_string_t set;
6107 cmdline_fixed_string_t qmap;
6108 cmdline_fixed_string_t what;
6115 cmd_set_qmap_parsed(void *parsed_result,
6116 __attribute__((unused)) struct cmdline *cl,
6117 __attribute__((unused)) void *data)
6119 struct cmd_set_qmap_result *res = parsed_result;
6120 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6122 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6125 cmdline_parse_token_string_t cmd_setqmap_set =
6126 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6128 cmdline_parse_token_string_t cmd_setqmap_qmap =
6129 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6131 cmdline_parse_token_string_t cmd_setqmap_what =
6132 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6134 cmdline_parse_token_num_t cmd_setqmap_portid =
6135 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6137 cmdline_parse_token_num_t cmd_setqmap_queueid =
6138 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6140 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6141 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6144 cmdline_parse_inst_t cmd_set_qmap = {
6145 .f = cmd_set_qmap_parsed,
6147 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6149 (void *)&cmd_setqmap_set,
6150 (void *)&cmd_setqmap_qmap,
6151 (void *)&cmd_setqmap_what,
6152 (void *)&cmd_setqmap_portid,
6153 (void *)&cmd_setqmap_queueid,
6154 (void *)&cmd_setqmap_mapvalue,
6159 /* *** CONFIGURE UNICAST HASH TABLE *** */
6160 struct cmd_set_uc_hash_table {
6161 cmdline_fixed_string_t set;
6162 cmdline_fixed_string_t port;
6164 cmdline_fixed_string_t what;
6165 struct ether_addr address;
6166 cmdline_fixed_string_t mode;
6170 cmd_set_uc_hash_parsed(void *parsed_result,
6171 __attribute__((unused)) struct cmdline *cl,
6172 __attribute__((unused)) void *data)
6175 struct cmd_set_uc_hash_table *res = parsed_result;
6177 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6179 if (strcmp(res->what, "uta") == 0)
6180 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6181 &res->address,(uint8_t)is_on);
6183 printf("bad unicast hash table parameter, return code = %d \n", ret);
6187 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6188 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6190 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6191 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6193 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6194 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6196 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6197 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6199 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6200 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6202 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6203 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6206 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6207 .f = cmd_set_uc_hash_parsed,
6209 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6211 (void *)&cmd_set_uc_hash_set,
6212 (void *)&cmd_set_uc_hash_port,
6213 (void *)&cmd_set_uc_hash_portid,
6214 (void *)&cmd_set_uc_hash_what,
6215 (void *)&cmd_set_uc_hash_mac,
6216 (void *)&cmd_set_uc_hash_mode,
6221 struct cmd_set_uc_all_hash_table {
6222 cmdline_fixed_string_t set;
6223 cmdline_fixed_string_t port;
6225 cmdline_fixed_string_t what;
6226 cmdline_fixed_string_t value;
6227 cmdline_fixed_string_t mode;
6231 cmd_set_uc_all_hash_parsed(void *parsed_result,
6232 __attribute__((unused)) struct cmdline *cl,
6233 __attribute__((unused)) void *data)
6236 struct cmd_set_uc_all_hash_table *res = parsed_result;
6238 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6240 if ((strcmp(res->what, "uta") == 0) &&
6241 (strcmp(res->value, "all") == 0))
6242 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6244 printf("bad unicast hash table parameter,"
6245 "return code = %d \n", ret);
6248 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6249 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6251 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6252 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6254 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6255 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6257 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6258 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6260 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6261 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6263 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6264 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6267 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6268 .f = cmd_set_uc_all_hash_parsed,
6270 .help_str = "set port X uta all on|off (X = port number)",
6272 (void *)&cmd_set_uc_all_hash_set,
6273 (void *)&cmd_set_uc_all_hash_port,
6274 (void *)&cmd_set_uc_all_hash_portid,
6275 (void *)&cmd_set_uc_all_hash_what,
6276 (void *)&cmd_set_uc_all_hash_value,
6277 (void *)&cmd_set_uc_all_hash_mode,
6282 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6283 struct cmd_set_vf_macvlan_filter {
6284 cmdline_fixed_string_t set;
6285 cmdline_fixed_string_t port;
6287 cmdline_fixed_string_t vf;
6289 struct ether_addr address;
6290 cmdline_fixed_string_t filter_type;
6291 cmdline_fixed_string_t mode;
6295 cmd_set_vf_macvlan_parsed(void *parsed_result,
6296 __attribute__((unused)) struct cmdline *cl,
6297 __attribute__((unused)) void *data)
6300 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6301 struct rte_eth_mac_filter filter;
6303 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6305 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6307 /* set VF MAC filter */
6311 filter.dst_id = res->vf_id;
6313 if (!strcmp(res->filter_type, "exact-mac"))
6314 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6315 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6316 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6317 else if (!strcmp(res->filter_type, "hashmac"))
6318 filter.filter_type = RTE_MAC_HASH_MATCH;
6319 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6320 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6322 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6325 ret = rte_eth_dev_filter_ctrl(res->port_id,
6326 RTE_ETH_FILTER_MACVLAN,
6330 ret = rte_eth_dev_filter_ctrl(res->port_id,
6331 RTE_ETH_FILTER_MACVLAN,
6332 RTE_ETH_FILTER_DELETE,
6336 printf("bad set MAC hash parameter, return code = %d\n", ret);
6340 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6341 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6343 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6344 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6346 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6347 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6349 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6350 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6352 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6353 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6355 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6356 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6358 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6359 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6360 filter_type, "exact-mac#exact-mac-vlan"
6361 "#hashmac#hashmac-vlan");
6362 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6363 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6366 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6367 .f = cmd_set_vf_macvlan_parsed,
6369 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6370 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6372 "exact match rule:exact match of MAC or MAC and VLAN; "
6373 "hash match rule: hash match of MAC and exact match "
6376 (void *)&cmd_set_vf_macvlan_set,
6377 (void *)&cmd_set_vf_macvlan_port,
6378 (void *)&cmd_set_vf_macvlan_portid,
6379 (void *)&cmd_set_vf_macvlan_vf,
6380 (void *)&cmd_set_vf_macvlan_vf_id,
6381 (void *)&cmd_set_vf_macvlan_mac,
6382 (void *)&cmd_set_vf_macvlan_filter_type,
6383 (void *)&cmd_set_vf_macvlan_mode,
6388 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6389 struct cmd_set_vf_traffic {
6390 cmdline_fixed_string_t set;
6391 cmdline_fixed_string_t port;
6393 cmdline_fixed_string_t vf;
6395 cmdline_fixed_string_t what;
6396 cmdline_fixed_string_t mode;
6400 cmd_set_vf_traffic_parsed(void *parsed_result,
6401 __attribute__((unused)) struct cmdline *cl,
6402 __attribute__((unused)) void *data)
6404 struct cmd_set_vf_traffic *res = parsed_result;
6405 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6406 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6408 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6411 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6412 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6414 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6415 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6417 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6418 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6420 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6421 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6423 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6424 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6426 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6427 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6429 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6430 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6433 cmdline_parse_inst_t cmd_set_vf_traffic = {
6434 .f = cmd_set_vf_traffic_parsed,
6436 .help_str = "set port X vf Y rx|tx on|off"
6437 "(X = port number,Y = vf id)",
6439 (void *)&cmd_setvf_traffic_set,
6440 (void *)&cmd_setvf_traffic_port,
6441 (void *)&cmd_setvf_traffic_portid,
6442 (void *)&cmd_setvf_traffic_vf,
6443 (void *)&cmd_setvf_traffic_vfid,
6444 (void *)&cmd_setvf_traffic_what,
6445 (void *)&cmd_setvf_traffic_mode,
6450 /* *** CONFIGURE VF RECEIVE MODE *** */
6451 struct cmd_set_vf_rxmode {
6452 cmdline_fixed_string_t set;
6453 cmdline_fixed_string_t port;
6455 cmdline_fixed_string_t vf;
6457 cmdline_fixed_string_t what;
6458 cmdline_fixed_string_t mode;
6459 cmdline_fixed_string_t on;
6463 cmd_set_vf_rxmode_parsed(void *parsed_result,
6464 __attribute__((unused)) struct cmdline *cl,
6465 __attribute__((unused)) void *data)
6468 uint16_t rx_mode = 0;
6469 struct cmd_set_vf_rxmode *res = parsed_result;
6471 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6472 if (!strcmp(res->what,"rxmode")) {
6473 if (!strcmp(res->mode, "AUPE"))
6474 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6475 else if (!strcmp(res->mode, "ROPE"))
6476 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6477 else if (!strcmp(res->mode, "BAM"))
6478 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6479 else if (!strncmp(res->mode, "MPE",3))
6480 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6483 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6485 printf("bad VF receive mode parameter, return code = %d \n",
6489 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6490 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6492 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6493 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6495 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6496 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6498 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6499 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6501 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6502 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6504 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6505 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6507 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6508 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6509 mode, "AUPE#ROPE#BAM#MPE");
6510 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6511 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6514 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6515 .f = cmd_set_vf_rxmode_parsed,
6517 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6519 (void *)&cmd_set_vf_rxmode_set,
6520 (void *)&cmd_set_vf_rxmode_port,
6521 (void *)&cmd_set_vf_rxmode_portid,
6522 (void *)&cmd_set_vf_rxmode_vf,
6523 (void *)&cmd_set_vf_rxmode_vfid,
6524 (void *)&cmd_set_vf_rxmode_what,
6525 (void *)&cmd_set_vf_rxmode_mode,
6526 (void *)&cmd_set_vf_rxmode_on,
6531 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6532 struct cmd_vf_mac_addr_result {
6533 cmdline_fixed_string_t mac_addr_cmd;
6534 cmdline_fixed_string_t what;
6535 cmdline_fixed_string_t port;
6537 cmdline_fixed_string_t vf;
6539 struct ether_addr address;
6542 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6543 __attribute__((unused)) struct cmdline *cl,
6544 __attribute__((unused)) void *data)
6546 struct cmd_vf_mac_addr_result *res = parsed_result;
6549 if (strcmp(res->what, "add") == 0)
6550 ret = rte_eth_dev_mac_addr_add(res->port_num,
6551 &res->address, res->vf_num);
6553 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6557 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6558 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6559 mac_addr_cmd,"mac_addr");
6560 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6561 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6563 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6564 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6566 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6567 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6569 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6570 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6572 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6573 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6575 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6576 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6579 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6580 .f = cmd_vf_mac_addr_parsed,
6582 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6583 "Y = VF number)add MAC address filtering for a VF on port X",
6585 (void *)&cmd_vf_mac_addr_cmd,
6586 (void *)&cmd_vf_mac_addr_what,
6587 (void *)&cmd_vf_mac_addr_port,
6588 (void *)&cmd_vf_mac_addr_portnum,
6589 (void *)&cmd_vf_mac_addr_vf,
6590 (void *)&cmd_vf_mac_addr_vfnum,
6591 (void *)&cmd_vf_mac_addr_addr,
6596 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6597 struct cmd_vf_rx_vlan_filter {
6598 cmdline_fixed_string_t rx_vlan;
6599 cmdline_fixed_string_t what;
6601 cmdline_fixed_string_t port;
6603 cmdline_fixed_string_t vf;
6608 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6609 __attribute__((unused)) struct cmdline *cl,
6610 __attribute__((unused)) void *data)
6612 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6614 if (!strcmp(res->what, "add"))
6615 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6617 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6620 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6621 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6622 rx_vlan, "rx_vlan");
6623 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6624 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6626 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6627 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6629 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6630 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6632 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6633 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6635 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6636 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6638 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6639 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6642 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6643 .f = cmd_vf_rx_vlan_filter_parsed,
6645 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6646 "Y = port number,Z = hexadecimal VF mask)",
6648 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6649 (void *)&cmd_vf_rx_vlan_filter_what,
6650 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6651 (void *)&cmd_vf_rx_vlan_filter_port,
6652 (void *)&cmd_vf_rx_vlan_filter_portid,
6653 (void *)&cmd_vf_rx_vlan_filter_vf,
6654 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6659 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6660 struct cmd_queue_rate_limit_result {
6661 cmdline_fixed_string_t set;
6662 cmdline_fixed_string_t port;
6664 cmdline_fixed_string_t queue;
6666 cmdline_fixed_string_t rate;
6670 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6671 __attribute__((unused)) struct cmdline *cl,
6672 __attribute__((unused)) void *data)
6674 struct cmd_queue_rate_limit_result *res = parsed_result;
6677 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6678 && (strcmp(res->queue, "queue") == 0)
6679 && (strcmp(res->rate, "rate") == 0))
6680 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6683 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6687 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6688 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6690 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6691 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6693 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6694 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6696 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6697 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6699 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6700 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6702 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6703 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6705 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6706 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6709 cmdline_parse_inst_t cmd_queue_rate_limit = {
6710 .f = cmd_queue_rate_limit_parsed,
6712 .help_str = "set port X queue Y rate Z:(X = port number,"
6713 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6715 (void *)&cmd_queue_rate_limit_set,
6716 (void *)&cmd_queue_rate_limit_port,
6717 (void *)&cmd_queue_rate_limit_portnum,
6718 (void *)&cmd_queue_rate_limit_queue,
6719 (void *)&cmd_queue_rate_limit_queuenum,
6720 (void *)&cmd_queue_rate_limit_rate,
6721 (void *)&cmd_queue_rate_limit_ratenum,
6726 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6727 struct cmd_vf_rate_limit_result {
6728 cmdline_fixed_string_t set;
6729 cmdline_fixed_string_t port;
6731 cmdline_fixed_string_t vf;
6733 cmdline_fixed_string_t rate;
6735 cmdline_fixed_string_t q_msk;
6739 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6740 __attribute__((unused)) struct cmdline *cl,
6741 __attribute__((unused)) void *data)
6743 struct cmd_vf_rate_limit_result *res = parsed_result;
6746 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6747 && (strcmp(res->vf, "vf") == 0)
6748 && (strcmp(res->rate, "rate") == 0)
6749 && (strcmp(res->q_msk, "queue_mask") == 0))
6750 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6751 res->rate_num, res->q_msk_val);
6753 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6757 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6758 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6760 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6761 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6763 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6764 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6766 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6767 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6769 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6770 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6772 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6773 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6775 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6776 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6778 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6779 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6780 q_msk, "queue_mask");
6781 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6782 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6785 cmdline_parse_inst_t cmd_vf_rate_limit = {
6786 .f = cmd_vf_rate_limit_parsed,
6788 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6789 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6790 "for queues of VF on port X",
6792 (void *)&cmd_vf_rate_limit_set,
6793 (void *)&cmd_vf_rate_limit_port,
6794 (void *)&cmd_vf_rate_limit_portnum,
6795 (void *)&cmd_vf_rate_limit_vf,
6796 (void *)&cmd_vf_rate_limit_vfnum,
6797 (void *)&cmd_vf_rate_limit_rate,
6798 (void *)&cmd_vf_rate_limit_ratenum,
6799 (void *)&cmd_vf_rate_limit_q_msk,
6800 (void *)&cmd_vf_rate_limit_q_msk_val,
6805 /* *** ADD TUNNEL FILTER OF A PORT *** */
6806 struct cmd_tunnel_filter_result {
6807 cmdline_fixed_string_t cmd;
6808 cmdline_fixed_string_t what;
6810 struct ether_addr outer_mac;
6811 struct ether_addr inner_mac;
6812 cmdline_ipaddr_t ip_value;
6813 uint16_t inner_vlan;
6814 cmdline_fixed_string_t tunnel_type;
6815 cmdline_fixed_string_t filter_type;
6821 cmd_tunnel_filter_parsed(void *parsed_result,
6822 __attribute__((unused)) struct cmdline *cl,
6823 __attribute__((unused)) void *data)
6825 struct cmd_tunnel_filter_result *res = parsed_result;
6826 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6829 tunnel_filter_conf.outer_mac = &res->outer_mac;
6830 tunnel_filter_conf.inner_mac = &res->inner_mac;
6831 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6833 if (res->ip_value.family == AF_INET) {
6834 tunnel_filter_conf.ip_addr.ipv4_addr =
6835 res->ip_value.addr.ipv4.s_addr;
6836 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6838 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6839 &(res->ip_value.addr.ipv6),
6840 sizeof(struct in6_addr));
6841 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6844 if (!strcmp(res->filter_type, "imac-ivlan"))
6845 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6846 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6847 tunnel_filter_conf.filter_type =
6848 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6849 else if (!strcmp(res->filter_type, "imac-tenid"))
6850 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6851 else if (!strcmp(res->filter_type, "imac"))
6852 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6853 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6854 tunnel_filter_conf.filter_type =
6855 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6857 printf("The filter type is not supported");
6861 if (!strcmp(res->tunnel_type, "vxlan"))
6862 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6864 printf("Only VXLAN is supported now.\n");
6868 tunnel_filter_conf.tenant_id = res->tenant_id;
6869 tunnel_filter_conf.queue_id = res->queue_num;
6870 if (!strcmp(res->what, "add"))
6871 ret = rte_eth_dev_filter_ctrl(res->port_id,
6872 RTE_ETH_FILTER_TUNNEL,
6874 &tunnel_filter_conf);
6876 ret = rte_eth_dev_filter_ctrl(res->port_id,
6877 RTE_ETH_FILTER_TUNNEL,
6878 RTE_ETH_FILTER_DELETE,
6879 &tunnel_filter_conf);
6881 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6885 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6886 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6887 cmd, "tunnel_filter");
6888 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6889 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6891 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6892 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6894 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6895 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6897 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6898 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6900 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6901 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6902 inner_vlan, UINT16);
6903 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6904 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6906 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6907 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6908 tunnel_type, "vxlan");
6910 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6911 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6912 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6913 "imac#omac-imac-tenid");
6914 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6915 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6917 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6918 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6921 cmdline_parse_inst_t cmd_tunnel_filter = {
6922 .f = cmd_tunnel_filter_parsed,
6924 .help_str = "add/rm tunnel filter of a port: "
6925 "tunnel_filter add port_id outer_mac inner_mac ip "
6926 "inner_vlan tunnel_type(vxlan) filter_type "
6927 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6928 "imac|omac-imac-tenid) "
6929 "tenant_id queue_num",
6931 (void *)&cmd_tunnel_filter_cmd,
6932 (void *)&cmd_tunnel_filter_what,
6933 (void *)&cmd_tunnel_filter_port_id,
6934 (void *)&cmd_tunnel_filter_outer_mac,
6935 (void *)&cmd_tunnel_filter_inner_mac,
6936 (void *)&cmd_tunnel_filter_ip_value,
6937 (void *)&cmd_tunnel_filter_innner_vlan,
6938 (void *)&cmd_tunnel_filter_tunnel_type,
6939 (void *)&cmd_tunnel_filter_filter_type,
6940 (void *)&cmd_tunnel_filter_tenant_id,
6941 (void *)&cmd_tunnel_filter_queue_num,
6946 /* *** CONFIGURE TUNNEL UDP PORT *** */
6947 struct cmd_tunnel_udp_config {
6948 cmdline_fixed_string_t cmd;
6949 cmdline_fixed_string_t what;
6955 cmd_tunnel_udp_config_parsed(void *parsed_result,
6956 __attribute__((unused)) struct cmdline *cl,
6957 __attribute__((unused)) void *data)
6959 struct cmd_tunnel_udp_config *res = parsed_result;
6960 struct rte_eth_udp_tunnel tunnel_udp;
6963 tunnel_udp.udp_port = res->udp_port;
6965 if (!strcmp(res->cmd, "rx_vxlan_port"))
6966 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6968 if (!strcmp(res->what, "add"))
6969 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6971 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6974 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6977 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6978 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6979 cmd, "rx_vxlan_port");
6980 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6981 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6983 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6984 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6986 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6987 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6990 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6991 .f = cmd_tunnel_udp_config_parsed,
6993 .help_str = "add/rm an tunneling UDP port filter: "
6994 "rx_vxlan_port add udp_port port_id",
6996 (void *)&cmd_tunnel_udp_config_cmd,
6997 (void *)&cmd_tunnel_udp_config_what,
6998 (void *)&cmd_tunnel_udp_config_udp_port,
6999 (void *)&cmd_tunnel_udp_config_port_id,
7004 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7005 struct cmd_set_mirror_mask_result {
7006 cmdline_fixed_string_t set;
7007 cmdline_fixed_string_t port;
7009 cmdline_fixed_string_t mirror;
7011 cmdline_fixed_string_t what;
7012 cmdline_fixed_string_t value;
7013 cmdline_fixed_string_t dstpool;
7015 cmdline_fixed_string_t on;
7018 cmdline_parse_token_string_t cmd_mirror_mask_set =
7019 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7021 cmdline_parse_token_string_t cmd_mirror_mask_port =
7022 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7024 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7025 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7027 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7028 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7029 mirror, "mirror-rule");
7030 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7031 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7033 cmdline_parse_token_string_t cmd_mirror_mask_what =
7034 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7035 what, "pool-mirror#vlan-mirror");
7036 cmdline_parse_token_string_t cmd_mirror_mask_value =
7037 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7039 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7040 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7041 dstpool, "dst-pool");
7042 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7043 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7045 cmdline_parse_token_string_t cmd_mirror_mask_on =
7046 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7050 cmd_set_mirror_mask_parsed(void *parsed_result,
7051 __attribute__((unused)) struct cmdline *cl,
7052 __attribute__((unused)) void *data)
7055 struct cmd_set_mirror_mask_result *res = parsed_result;
7056 struct rte_eth_vmdq_mirror_conf mr_conf;
7058 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
7060 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
7062 mr_conf.dst_pool = res->dstpool_id;
7064 if (!strcmp(res->what, "pool-mirror")) {
7065 mr_conf.pool_mask = strtoull(res->value,NULL,16);
7066 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
7067 } else if(!strcmp(res->what, "vlan-mirror")) {
7068 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
7069 nb_item = parse_item_list(res->value, "core",
7070 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
7074 for(i=0; i < nb_item; i++) {
7075 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7076 printf("Invalid vlan_id: must be < 4096\n");
7080 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7081 mr_conf.vlan.vlan_mask |= 1ULL << i;
7085 if(!strcmp(res->on, "on"))
7086 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7089 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7092 printf("mirror rule add error: (%s)\n", strerror(-ret));
7095 cmdline_parse_inst_t cmd_set_mirror_mask = {
7096 .f = cmd_set_mirror_mask_parsed,
7098 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
7099 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7101 (void *)&cmd_mirror_mask_set,
7102 (void *)&cmd_mirror_mask_port,
7103 (void *)&cmd_mirror_mask_portid,
7104 (void *)&cmd_mirror_mask_mirror,
7105 (void *)&cmd_mirror_mask_ruleid,
7106 (void *)&cmd_mirror_mask_what,
7107 (void *)&cmd_mirror_mask_value,
7108 (void *)&cmd_mirror_mask_dstpool,
7109 (void *)&cmd_mirror_mask_poolid,
7110 (void *)&cmd_mirror_mask_on,
7115 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7116 struct cmd_set_mirror_link_result {
7117 cmdline_fixed_string_t set;
7118 cmdline_fixed_string_t port;
7120 cmdline_fixed_string_t mirror;
7122 cmdline_fixed_string_t what;
7123 cmdline_fixed_string_t dstpool;
7125 cmdline_fixed_string_t on;
7128 cmdline_parse_token_string_t cmd_mirror_link_set =
7129 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7131 cmdline_parse_token_string_t cmd_mirror_link_port =
7132 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7134 cmdline_parse_token_num_t cmd_mirror_link_portid =
7135 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7137 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7138 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7139 mirror, "mirror-rule");
7140 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7141 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7143 cmdline_parse_token_string_t cmd_mirror_link_what =
7144 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7145 what, "uplink-mirror#downlink-mirror");
7146 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7147 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7148 dstpool, "dst-pool");
7149 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7150 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7152 cmdline_parse_token_string_t cmd_mirror_link_on =
7153 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7157 cmd_set_mirror_link_parsed(void *parsed_result,
7158 __attribute__((unused)) struct cmdline *cl,
7159 __attribute__((unused)) void *data)
7162 struct cmd_set_mirror_link_result *res = parsed_result;
7163 struct rte_eth_vmdq_mirror_conf mr_conf;
7165 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
7166 if(!strcmp(res->what, "uplink-mirror")) {
7167 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
7168 }else if(!strcmp(res->what, "downlink-mirror"))
7169 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
7171 mr_conf.dst_pool = res->dstpool_id;
7173 if(!strcmp(res->on, "on"))
7174 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7177 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7180 /* check the return value and print it if is < 0 */
7182 printf("mirror rule add error: (%s)\n", strerror(-ret));
7186 cmdline_parse_inst_t cmd_set_mirror_link = {
7187 .f = cmd_set_mirror_link_parsed,
7189 .help_str = "set port X mirror-rule Y uplink-mirror|"
7190 "downlink-mirror dst-pool Z on|off",
7192 (void *)&cmd_mirror_link_set,
7193 (void *)&cmd_mirror_link_port,
7194 (void *)&cmd_mirror_link_portid,
7195 (void *)&cmd_mirror_link_mirror,
7196 (void *)&cmd_mirror_link_ruleid,
7197 (void *)&cmd_mirror_link_what,
7198 (void *)&cmd_mirror_link_dstpool,
7199 (void *)&cmd_mirror_link_poolid,
7200 (void *)&cmd_mirror_link_on,
7205 /* *** RESET VM MIRROR RULE *** */
7206 struct cmd_rm_mirror_rule_result {
7207 cmdline_fixed_string_t reset;
7208 cmdline_fixed_string_t port;
7210 cmdline_fixed_string_t mirror;
7214 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7215 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7217 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7218 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7220 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7221 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7223 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7224 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7225 mirror, "mirror-rule");
7226 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7227 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7231 cmd_reset_mirror_rule_parsed(void *parsed_result,
7232 __attribute__((unused)) struct cmdline *cl,
7233 __attribute__((unused)) void *data)
7236 struct cmd_set_mirror_link_result *res = parsed_result;
7238 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7240 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7243 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7244 .f = cmd_reset_mirror_rule_parsed,
7246 .help_str = "reset port X mirror-rule Y",
7248 (void *)&cmd_rm_mirror_rule_reset,
7249 (void *)&cmd_rm_mirror_rule_port,
7250 (void *)&cmd_rm_mirror_rule_portid,
7251 (void *)&cmd_rm_mirror_rule_mirror,
7252 (void *)&cmd_rm_mirror_rule_ruleid,
7257 /* ******************************************************************************** */
7259 struct cmd_dump_result {
7260 cmdline_fixed_string_t dump;
7264 dump_struct_sizes(void)
7266 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7267 DUMP_SIZE(struct rte_mbuf);
7268 DUMP_SIZE(struct rte_mempool);
7269 DUMP_SIZE(struct rte_ring);
7273 static void cmd_dump_parsed(void *parsed_result,
7274 __attribute__((unused)) struct cmdline *cl,
7275 __attribute__((unused)) void *data)
7277 struct cmd_dump_result *res = parsed_result;
7279 if (!strcmp(res->dump, "dump_physmem"))
7280 rte_dump_physmem_layout(stdout);
7281 else if (!strcmp(res->dump, "dump_memzone"))
7282 rte_memzone_dump(stdout);
7283 else if (!strcmp(res->dump, "dump_log_history"))
7284 rte_log_dump_history(stdout);
7285 else if (!strcmp(res->dump, "dump_struct_sizes"))
7286 dump_struct_sizes();
7287 else if (!strcmp(res->dump, "dump_ring"))
7288 rte_ring_list_dump(stdout);
7289 else if (!strcmp(res->dump, "dump_mempool"))
7290 rte_mempool_list_dump(stdout);
7291 else if (!strcmp(res->dump, "dump_devargs"))
7292 rte_eal_devargs_dump(stdout);
7295 cmdline_parse_token_string_t cmd_dump_dump =
7296 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7300 "dump_struct_sizes#"
7305 cmdline_parse_inst_t cmd_dump = {
7306 .f = cmd_dump_parsed, /* function to call */
7307 .data = NULL, /* 2nd arg of func */
7308 .help_str = "dump status",
7309 .tokens = { /* token list, NULL terminated */
7310 (void *)&cmd_dump_dump,
7315 /* ******************************************************************************** */
7317 struct cmd_dump_one_result {
7318 cmdline_fixed_string_t dump;
7319 cmdline_fixed_string_t name;
7322 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7323 __attribute__((unused)) void *data)
7325 struct cmd_dump_one_result *res = parsed_result;
7327 if (!strcmp(res->dump, "dump_ring")) {
7329 r = rte_ring_lookup(res->name);
7331 cmdline_printf(cl, "Cannot find ring\n");
7334 rte_ring_dump(stdout, r);
7335 } else if (!strcmp(res->dump, "dump_mempool")) {
7336 struct rte_mempool *mp;
7337 mp = rte_mempool_lookup(res->name);
7339 cmdline_printf(cl, "Cannot find mempool\n");
7342 rte_mempool_dump(stdout, mp);
7346 cmdline_parse_token_string_t cmd_dump_one_dump =
7347 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7348 "dump_ring#dump_mempool");
7350 cmdline_parse_token_string_t cmd_dump_one_name =
7351 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7353 cmdline_parse_inst_t cmd_dump_one = {
7354 .f = cmd_dump_one_parsed, /* function to call */
7355 .data = NULL, /* 2nd arg of func */
7356 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7357 .tokens = { /* token list, NULL terminated */
7358 (void *)&cmd_dump_one_dump,
7359 (void *)&cmd_dump_one_name,
7364 /* *** set SYN filter *** */
7365 struct cmd_set_syn_filter_result {
7366 cmdline_fixed_string_t filter;
7368 cmdline_fixed_string_t priority;
7369 cmdline_fixed_string_t high;
7370 cmdline_fixed_string_t queue;
7375 cmd_set_syn_filter_parsed(void *parsed_result,
7376 __attribute__((unused)) struct cmdline *cl,
7377 __attribute__((unused)) void *data)
7380 struct cmd_set_syn_filter_result *res = parsed_result;
7381 struct rte_syn_filter filter;
7383 if (!strcmp(res->filter, "add_syn_filter")) {
7384 if (!strcmp(res->high, "high"))
7388 ret = rte_eth_dev_add_syn_filter(res->port_id,
7389 &filter, res->queue_id);
7390 } else if (!strcmp(res->filter, "remove_syn_filter"))
7391 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7392 else if (!strcmp(res->filter, "get_syn_filter"))
7393 get_syn_filter(res->port_id);
7395 printf("syn filter setting error: (%s)\n", strerror(-ret));
7398 cmdline_parse_token_num_t cmd_syn_filter_portid =
7399 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7401 cmdline_parse_token_string_t cmd_syn_filter_priority =
7402 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7403 priority, "priority");
7404 cmdline_parse_token_string_t cmd_syn_filter_high =
7405 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7407 cmdline_parse_token_string_t cmd_syn_filter_queue =
7408 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7410 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7411 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7413 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7414 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7415 filter, "add_syn_filter");
7416 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7417 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7418 filter, "remove_syn_filter");
7419 cmdline_parse_inst_t cmd_add_syn_filter = {
7420 .f = cmd_set_syn_filter_parsed,
7422 .help_str = "add syn filter",
7424 (void *)&cmd_syn_filter_add_filter,
7425 (void *)&cmd_syn_filter_portid,
7426 (void *)&cmd_syn_filter_priority,
7427 (void *)&cmd_syn_filter_high,
7428 (void *)&cmd_syn_filter_queue,
7429 (void *)&cmd_syn_filter_queue_id,
7433 cmdline_parse_inst_t cmd_remove_syn_filter = {
7434 .f = cmd_set_syn_filter_parsed,
7436 .help_str = "remove syn filter",
7438 (void *)&cmd_syn_filter_remove_filter,
7439 (void *)&cmd_syn_filter_portid,
7444 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7445 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7446 filter, "get_syn_filter");
7448 cmdline_parse_inst_t cmd_get_syn_filter = {
7449 .f = cmd_set_syn_filter_parsed,
7451 .help_str = "get syn filter",
7453 (void *)&cmd_syn_filter_get_filter,
7454 (void *)&cmd_syn_filter_portid,
7459 /* *** ADD/REMOVE A 2tuple FILTER *** */
7460 struct cmd_2tuple_filter_result {
7461 cmdline_fixed_string_t filter;
7463 cmdline_fixed_string_t protocol;
7464 uint8_t protocol_value;
7465 uint8_t protocol_mask;
7466 cmdline_fixed_string_t dst_port;
7467 uint16_t dst_port_value;
7468 uint16_t dst_port_mask;
7469 cmdline_fixed_string_t flags;
7470 uint8_t flags_value;
7471 cmdline_fixed_string_t priority;
7472 uint8_t priority_value;
7473 cmdline_fixed_string_t queue;
7475 cmdline_fixed_string_t index;
7476 uint16_t index_value;
7480 cmd_2tuple_filter_parsed(void *parsed_result,
7481 __attribute__((unused)) struct cmdline *cl,
7482 __attribute__((unused)) void *data)
7485 struct rte_2tuple_filter filter;
7486 struct cmd_2tuple_filter_result *res = parsed_result;
7488 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7490 if (!strcmp(res->filter, "add_2tuple_filter")) {
7491 /* need convert to big endian. */
7492 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7493 filter.protocol = res->protocol_value;
7494 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7495 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7496 filter.priority = res->priority_value;
7497 filter.tcp_flags = res->flags_value;
7498 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7499 res->index_value, &filter, res->queue_id);
7500 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7501 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7503 else if (!strcmp(res->filter, "get_2tuple_filter"))
7504 get_2tuple_filter(res->port_id, res->index_value);
7507 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7510 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7511 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7513 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7514 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7515 protocol, "protocol");
7516 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7517 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7518 protocol_value, UINT8);
7519 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7520 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7521 protocol_mask, UINT8);
7522 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7523 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7524 dst_port, "dst_port");
7525 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7526 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7527 dst_port_value, UINT16);
7528 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7529 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7530 dst_port_mask, UINT16);
7531 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7532 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7534 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7535 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7536 flags_value, UINT8);
7537 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7538 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7539 priority, "priority");
7540 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7541 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7542 priority_value, UINT8);
7543 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7544 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7546 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7547 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7549 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7550 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7552 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7553 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7554 index_value, UINT16);
7555 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7556 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7557 filter, "add_2tuple_filter");
7558 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7559 .f = cmd_2tuple_filter_parsed,
7561 .help_str = "add a 2tuple filter",
7563 (void *)&cmd_2tuple_filter_add_filter,
7564 (void *)&cmd_2tuple_filter_port_id,
7565 (void *)&cmd_2tuple_filter_protocol,
7566 (void *)&cmd_2tuple_filter_protocol_value,
7567 (void *)&cmd_2tuple_filter_protocol_mask,
7568 (void *)&cmd_2tuple_filter_dst_port,
7569 (void *)&cmd_2tuple_filter_dst_port_value,
7570 (void *)&cmd_2tuple_filter_dst_port_mask,
7571 (void *)&cmd_2tuple_filter_flags,
7572 (void *)&cmd_2tuple_filter_flags_value,
7573 (void *)&cmd_2tuple_filter_priority,
7574 (void *)&cmd_2tuple_filter_priority_value,
7575 (void *)&cmd_2tuple_filter_queue,
7576 (void *)&cmd_2tuple_filter_queue_id,
7577 (void *)&cmd_2tuple_filter_index,
7578 (void *)&cmd_2tuple_filter_index_value,
7583 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7584 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7585 filter, "remove_2tuple_filter");
7586 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7587 .f = cmd_2tuple_filter_parsed,
7589 .help_str = "remove a 2tuple filter",
7591 (void *)&cmd_2tuple_filter_remove_filter,
7592 (void *)&cmd_2tuple_filter_port_id,
7593 (void *)&cmd_2tuple_filter_index,
7594 (void *)&cmd_2tuple_filter_index_value,
7598 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7599 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7600 filter, "get_2tuple_filter");
7601 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7602 .f = cmd_2tuple_filter_parsed,
7604 .help_str = "get a 2tuple filter",
7606 (void *)&cmd_2tuple_filter_get_filter,
7607 (void *)&cmd_2tuple_filter_port_id,
7608 (void *)&cmd_2tuple_filter_index,
7609 (void *)&cmd_2tuple_filter_index_value,
7614 /* *** ADD/REMOVE A 5tuple FILTER *** */
7615 struct cmd_5tuple_filter_result {
7616 cmdline_fixed_string_t filter;
7618 cmdline_fixed_string_t dst_ip;
7619 cmdline_ipaddr_t dst_ip_value;
7620 cmdline_fixed_string_t src_ip;
7621 cmdline_ipaddr_t src_ip_value;
7622 cmdline_fixed_string_t dst_port;
7623 uint16_t dst_port_value;
7624 cmdline_fixed_string_t src_port;
7625 uint16_t src_port_value;
7626 cmdline_fixed_string_t protocol;
7627 uint8_t protocol_value;
7628 cmdline_fixed_string_t mask;
7630 cmdline_fixed_string_t flags;
7631 uint8_t flags_value;
7632 cmdline_fixed_string_t priority;
7633 uint8_t priority_value;
7634 cmdline_fixed_string_t queue;
7636 cmdline_fixed_string_t index;
7637 uint16_t index_value;
7641 cmd_5tuple_filter_parsed(void *parsed_result,
7642 __attribute__((unused)) struct cmdline *cl,
7643 __attribute__((unused)) void *data)
7646 struct rte_5tuple_filter filter;
7647 struct cmd_5tuple_filter_result *res = parsed_result;
7649 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7651 if (!strcmp(res->filter, "add_5tuple_filter")) {
7652 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7653 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7654 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7655 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7656 filter.protocol = res->protocol_value;
7657 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7658 filter.priority = res->priority_value;
7659 filter.tcp_flags = res->flags_value;
7661 if (res->dst_ip_value.family == AF_INET)
7662 /* no need to convert, already big endian. */
7663 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7665 if (filter.dst_ip_mask == 0) {
7666 printf("can not support ipv6 involved compare.\n");
7672 if (res->src_ip_value.family == AF_INET)
7673 /* no need to convert, already big endian. */
7674 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7676 if (filter.src_ip_mask == 0) {
7677 printf("can not support ipv6 involved compare.\n");
7682 /* need convert to big endian. */
7683 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7684 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7686 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7687 res->index_value, &filter, res->queue_id);
7688 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7689 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7691 else if (!strcmp(res->filter, "get_5tuple_filter"))
7692 get_5tuple_filter(res->port_id, res->index_value);
7694 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7698 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7699 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7701 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7702 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7704 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7705 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7707 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7708 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7710 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7711 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7713 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7714 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7715 dst_port, "dst_port");
7716 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7717 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7718 dst_port_value, UINT16);
7719 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7720 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7721 src_port, "src_port");
7722 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7723 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7724 src_port_value, UINT16);
7725 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7726 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7727 protocol, "protocol");
7728 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7729 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7730 protocol_value, UINT8);
7731 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7732 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7734 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7735 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7737 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7738 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7740 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7741 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7742 flags_value, UINT8);
7743 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7744 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7745 priority, "priority");
7746 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7747 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7748 priority_value, UINT8);
7749 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7750 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7752 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7753 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7755 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7756 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7758 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7759 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7760 index_value, UINT16);
7762 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7763 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7764 filter, "add_5tuple_filter");
7765 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7766 .f = cmd_5tuple_filter_parsed,
7768 .help_str = "add a 5tuple filter",
7770 (void *)&cmd_5tuple_filter_add_filter,
7771 (void *)&cmd_5tuple_filter_port_id,
7772 (void *)&cmd_5tuple_filter_dst_ip,
7773 (void *)&cmd_5tuple_filter_dst_ip_value,
7774 (void *)&cmd_5tuple_filter_src_ip,
7775 (void *)&cmd_5tuple_filter_src_ip_value,
7776 (void *)&cmd_5tuple_filter_dst_port,
7777 (void *)&cmd_5tuple_filter_dst_port_value,
7778 (void *)&cmd_5tuple_filter_src_port,
7779 (void *)&cmd_5tuple_filter_src_port_value,
7780 (void *)&cmd_5tuple_filter_protocol,
7781 (void *)&cmd_5tuple_filter_protocol_value,
7782 (void *)&cmd_5tuple_filter_mask,
7783 (void *)&cmd_5tuple_filter_mask_value,
7784 (void *)&cmd_5tuple_filter_flags,
7785 (void *)&cmd_5tuple_filter_flags_value,
7786 (void *)&cmd_5tuple_filter_priority,
7787 (void *)&cmd_5tuple_filter_priority_value,
7788 (void *)&cmd_5tuple_filter_queue,
7789 (void *)&cmd_5tuple_filter_queue_id,
7790 (void *)&cmd_5tuple_filter_index,
7791 (void *)&cmd_5tuple_filter_index_value,
7796 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7797 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7798 filter, "remove_5tuple_filter");
7799 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7800 .f = cmd_5tuple_filter_parsed,
7802 .help_str = "remove a 5tuple filter",
7804 (void *)&cmd_5tuple_filter_remove_filter,
7805 (void *)&cmd_5tuple_filter_port_id,
7806 (void *)&cmd_5tuple_filter_index,
7807 (void *)&cmd_5tuple_filter_index_value,
7812 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7813 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7814 filter, "get_5tuple_filter");
7815 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7816 .f = cmd_5tuple_filter_parsed,
7818 .help_str = "get a 5tuple filter",
7820 (void *)&cmd_5tuple_filter_get_filter,
7821 (void *)&cmd_5tuple_filter_port_id,
7822 (void *)&cmd_5tuple_filter_index,
7823 (void *)&cmd_5tuple_filter_index_value,
7828 /* *** ADD/REMOVE A flex FILTER *** */
7829 struct cmd_flex_filter_result {
7830 cmdline_fixed_string_t filter;
7832 cmdline_fixed_string_t len;
7834 cmdline_fixed_string_t bytes;
7835 cmdline_fixed_string_t bytes_value;
7836 cmdline_fixed_string_t mask;
7837 cmdline_fixed_string_t mask_value;
7838 cmdline_fixed_string_t priority;
7839 uint8_t priority_value;
7840 cmdline_fixed_string_t queue;
7842 cmdline_fixed_string_t index;
7843 uint16_t index_value;
7846 static int xdigit2val(unsigned char c)
7851 else if (isupper(c))
7859 cmd_flex_filter_parsed(void *parsed_result,
7860 __attribute__((unused)) struct cmdline *cl,
7861 __attribute__((unused)) void *data)
7864 struct rte_flex_filter filter;
7865 struct cmd_flex_filter_result *res = parsed_result;
7866 char *bytes_ptr, *mask_ptr;
7874 if (!strcmp(res->filter, "add_flex_filter")) {
7875 if (res->len_value > 128) {
7876 printf("the len exceed the max length 128\n");
7879 memset(&filter, 0, sizeof(struct rte_flex_filter));
7880 filter.len = res->len_value;
7881 filter.priority = res->priority_value;
7882 bytes_ptr = res->bytes_value;
7883 mask_ptr = res->mask_value;
7886 /* translate bytes string to uint_32 array. */
7887 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7888 (bytes_ptr[1] == 'X')))
7890 len = strnlen(bytes_ptr, res->len_value * 2);
7891 if (len == 0 || (len % 8 != 0)) {
7892 printf("please check len and bytes input\n");
7895 for (i = 0; i < len; i++) {
7897 if (isxdigit(c) == 0) {
7898 /* invalid characters. */
7899 printf("invalid input\n");
7902 val = xdigit2val(c);
7906 dword |= byte << (4 * mod - 4);
7911 filter.dwords[j] = dword;
7912 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7918 /* translate mask string to uint8_t array. */
7920 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7921 (mask_ptr[1] == 'X')))
7923 len = strnlen(mask_ptr, (res->len_value+3)/4);
7925 printf("invalid input\n");
7928 for (i = 0; i < len; i++) {
7930 if (isxdigit(c) == 0) {
7931 /* invalid characters. */
7932 printf("invalid input\n");
7935 val = xdigit2val(c);
7936 hex |= (uint8_t)(val & 0x8) >> 3;
7937 hex |= (uint8_t)(val & 0x4) >> 1;
7938 hex |= (uint8_t)(val & 0x2) << 1;
7939 hex |= (uint8_t)(val & 0x1) << 3;
7942 filter.mask[j] = byte;
7943 printf("mask[%d]:%02x ", j, filter.mask[j]);
7951 printf("call function rte_eth_dev_add_flex_filter: "
7952 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7953 res->index_value, res->queue_id,
7954 filter.len, filter.priority);
7955 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7956 &filter, res->queue_id);
7958 } else if (!strcmp(res->filter, "remove_flex_filter"))
7959 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7961 else if (!strcmp(res->filter, "get_flex_filter"))
7962 get_flex_filter(res->port_id, res->index_value);
7965 printf("flex filter setting error: (%s)\n", strerror(-ret));
7968 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7969 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7971 cmdline_parse_token_string_t cmd_flex_filter_len =
7972 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7974 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7975 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7977 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7978 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7980 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7981 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7983 cmdline_parse_token_string_t cmd_flex_filter_mask =
7984 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7986 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7987 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7989 cmdline_parse_token_string_t cmd_flex_filter_priority =
7990 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7991 priority, "priority");
7992 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7993 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7994 priority_value, UINT8);
7995 cmdline_parse_token_string_t cmd_flex_filter_queue =
7996 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7998 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7999 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8001 cmdline_parse_token_string_t cmd_flex_filter_index =
8002 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8004 cmdline_parse_token_num_t cmd_flex_filter_index_value =
8005 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8006 index_value, UINT16);
8007 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
8008 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8009 filter, "add_flex_filter");
8010 cmdline_parse_inst_t cmd_add_flex_filter = {
8011 .f = cmd_flex_filter_parsed,
8013 .help_str = "add a flex filter",
8015 (void *)&cmd_flex_filter_add_filter,
8016 (void *)&cmd_flex_filter_port_id,
8017 (void *)&cmd_flex_filter_len,
8018 (void *)&cmd_flex_filter_len_value,
8019 (void *)&cmd_flex_filter_bytes,
8020 (void *)&cmd_flex_filter_bytes_value,
8021 (void *)&cmd_flex_filter_mask,
8022 (void *)&cmd_flex_filter_mask_value,
8023 (void *)&cmd_flex_filter_priority,
8024 (void *)&cmd_flex_filter_priority_value,
8025 (void *)&cmd_flex_filter_queue,
8026 (void *)&cmd_flex_filter_queue_id,
8027 (void *)&cmd_flex_filter_index,
8028 (void *)&cmd_flex_filter_index_value,
8033 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
8034 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8035 filter, "remove_flex_filter");
8036 cmdline_parse_inst_t cmd_remove_flex_filter = {
8037 .f = cmd_flex_filter_parsed,
8039 .help_str = "remove a flex filter",
8041 (void *)&cmd_flex_filter_remove_filter,
8042 (void *)&cmd_flex_filter_port_id,
8043 (void *)&cmd_flex_filter_index,
8044 (void *)&cmd_flex_filter_index_value,
8049 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
8050 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8051 filter, "get_flex_filter");
8052 cmdline_parse_inst_t cmd_get_flex_filter = {
8053 .f = cmd_flex_filter_parsed,
8055 .help_str = "get a flex filter",
8057 (void *)&cmd_flex_filter_get_filter,
8058 (void *)&cmd_flex_filter_port_id,
8059 (void *)&cmd_flex_filter_index,
8060 (void *)&cmd_flex_filter_index_value,
8065 /* *** Filters Control *** */
8067 /* *** deal with ethertype filter *** */
8068 struct cmd_ethertype_filter_result {
8069 cmdline_fixed_string_t filter;
8071 cmdline_fixed_string_t ops;
8072 cmdline_fixed_string_t mac;
8073 struct ether_addr mac_addr;
8074 cmdline_fixed_string_t ethertype;
8075 uint16_t ethertype_value;
8076 cmdline_fixed_string_t drop;
8077 cmdline_fixed_string_t queue;
8081 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8082 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8083 filter, "ethertype_filter");
8084 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8085 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8087 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8088 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8090 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8091 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8092 mac, "mac_addr#mac_ignr");
8093 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8094 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8096 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8097 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8098 ethertype, "ethertype");
8099 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8100 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8101 ethertype_value, UINT16);
8102 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8103 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8105 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8106 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8108 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8109 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8113 cmd_ethertype_filter_parsed(void *parsed_result,
8114 __attribute__((unused)) struct cmdline *cl,
8115 __attribute__((unused)) void *data)
8117 struct cmd_ethertype_filter_result *res = parsed_result;
8118 struct rte_eth_ethertype_filter filter;
8121 ret = rte_eth_dev_filter_supported(res->port_id,
8122 RTE_ETH_FILTER_ETHERTYPE);
8124 printf("ethertype filter is not supported on port %u.\n",
8129 memset(&filter, 0, sizeof(filter));
8130 if (!strcmp(res->mac, "mac_addr")) {
8131 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8132 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8133 sizeof(struct ether_addr));
8135 if (!strcmp(res->drop, "drop"))
8136 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8137 filter.ether_type = res->ethertype_value;
8138 filter.queue = res->queue_id;
8140 if (!strcmp(res->ops, "add"))
8141 ret = rte_eth_dev_filter_ctrl(res->port_id,
8142 RTE_ETH_FILTER_ETHERTYPE,
8146 ret = rte_eth_dev_filter_ctrl(res->port_id,
8147 RTE_ETH_FILTER_ETHERTYPE,
8148 RTE_ETH_FILTER_DELETE,
8151 printf("ethertype filter programming error: (%s)\n",
8155 cmdline_parse_inst_t cmd_ethertype_filter = {
8156 .f = cmd_ethertype_filter_parsed,
8158 .help_str = "add or delete an ethertype filter entry",
8160 (void *)&cmd_ethertype_filter_filter,
8161 (void *)&cmd_ethertype_filter_port_id,
8162 (void *)&cmd_ethertype_filter_ops,
8163 (void *)&cmd_ethertype_filter_mac,
8164 (void *)&cmd_ethertype_filter_mac_addr,
8165 (void *)&cmd_ethertype_filter_ethertype,
8166 (void *)&cmd_ethertype_filter_ethertype_value,
8167 (void *)&cmd_ethertype_filter_drop,
8168 (void *)&cmd_ethertype_filter_queue,
8169 (void *)&cmd_ethertype_filter_queue_id,
8174 /* *** deal with flow director filter *** */
8175 struct cmd_flow_director_result {
8176 cmdline_fixed_string_t flow_director_filter;
8178 cmdline_fixed_string_t ops;
8179 cmdline_fixed_string_t flow;
8180 cmdline_fixed_string_t flow_type;
8181 cmdline_fixed_string_t src;
8182 cmdline_ipaddr_t ip_src;
8184 cmdline_fixed_string_t dst;
8185 cmdline_ipaddr_t ip_dst;
8187 cmdline_fixed_string_t verify_tag;
8188 uint32_t verify_tag_value;
8189 cmdline_fixed_string_t flexbytes;
8190 cmdline_fixed_string_t flexbytes_value;
8191 cmdline_fixed_string_t drop;
8192 cmdline_fixed_string_t queue;
8194 cmdline_fixed_string_t fd_id;
8195 uint32_t fd_id_value;
8199 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8202 const char *p, *p0 = q_arg;
8204 unsigned long int_fld;
8205 char *str_fld[max_num];
8210 p = strchr(p0, '(');
8214 p0 = strchr(p, ')');
8219 if (size >= sizeof(s))
8222 snprintf(s, sizeof(s), "%.*s", size, p);
8223 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8224 if (ret < 0 || ret > max_num)
8226 for (i = 0; i < ret; i++) {
8228 int_fld = strtoul(str_fld[i], &end, 0);
8229 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8231 flexbytes[i] = (uint8_t)int_fld;
8236 static enum rte_eth_flow_type
8237 str2flowtype(char *string)
8240 static const struct {
8242 enum rte_eth_flow_type type;
8243 } flowtype_str[] = {
8244 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8245 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8246 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8247 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8248 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8249 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8250 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8251 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8252 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8253 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8256 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8257 if (!strcmp(flowtype_str[i].str, string))
8258 return flowtype_str[i].type;
8260 return RTE_ETH_FLOW_TYPE_NONE;
8263 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8265 if ((ip_addr).family == AF_INET) \
8266 (ip) = (ip_addr).addr.ipv4.s_addr; \
8268 printf("invalid parameter.\n"); \
8273 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8275 if ((ip_addr).family == AF_INET6) \
8276 (void)rte_memcpy(&(ip), \
8277 &((ip_addr).addr.ipv6), \
8278 sizeof(struct in6_addr)); \
8280 printf("invalid parameter.\n"); \
8286 cmd_flow_director_filter_parsed(void *parsed_result,
8287 __attribute__((unused)) struct cmdline *cl,
8288 __attribute__((unused)) void *data)
8290 struct cmd_flow_director_result *res = parsed_result;
8291 struct rte_eth_fdir_filter entry;
8292 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8295 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8297 printf("flow director is not supported on port %u.\n",
8301 memset(flexbytes, 0, sizeof(flexbytes));
8302 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8303 ret = parse_flexbytes(res->flexbytes_value,
8305 RTE_ETH_FDIR_MAX_FLEXLEN);
8307 printf("error: Cannot parse flexbytes input.\n");
8311 entry.input.flow_type = str2flowtype(res->flow_type);
8312 switch (entry.input.flow_type) {
8313 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
8314 case RTE_ETH_FLOW_TYPE_UDPV4:
8315 case RTE_ETH_FLOW_TYPE_TCPV4:
8316 IPV4_ADDR_TO_UINT(res->ip_dst,
8317 entry.input.flow.ip4_flow.dst_ip);
8318 IPV4_ADDR_TO_UINT(res->ip_src,
8319 entry.input.flow.ip4_flow.src_ip);
8320 /* need convert to big endian. */
8321 entry.input.flow.udp4_flow.dst_port =
8322 rte_cpu_to_be_16(res->port_dst);
8323 entry.input.flow.udp4_flow.src_port =
8324 rte_cpu_to_be_16(res->port_src);
8326 case RTE_ETH_FLOW_TYPE_SCTPV4:
8327 IPV4_ADDR_TO_UINT(res->ip_dst,
8328 entry.input.flow.sctp4_flow.ip.dst_ip);
8329 IPV4_ADDR_TO_UINT(res->ip_src,
8330 entry.input.flow.sctp4_flow.ip.src_ip);
8331 /* need convert to big endian. */
8332 entry.input.flow.sctp4_flow.verify_tag =
8333 rte_cpu_to_be_32(res->verify_tag_value);
8335 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
8336 case RTE_ETH_FLOW_TYPE_UDPV6:
8337 case RTE_ETH_FLOW_TYPE_TCPV6:
8338 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8339 entry.input.flow.ipv6_flow.dst_ip);
8340 IPV6_ADDR_TO_ARRAY(res->ip_src,
8341 entry.input.flow.ipv6_flow.src_ip);
8342 /* need convert to big endian. */
8343 entry.input.flow.udp6_flow.dst_port =
8344 rte_cpu_to_be_16(res->port_dst);
8345 entry.input.flow.udp6_flow.src_port =
8346 rte_cpu_to_be_16(res->port_src);
8348 case RTE_ETH_FLOW_TYPE_SCTPV6:
8349 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8350 entry.input.flow.sctp6_flow.ip.dst_ip);
8351 IPV6_ADDR_TO_ARRAY(res->ip_src,
8352 entry.input.flow.sctp6_flow.ip.src_ip);
8353 /* need convert to big endian. */
8354 entry.input.flow.sctp6_flow.verify_tag =
8355 rte_cpu_to_be_32(res->verify_tag_value);
8358 printf("invalid parameter.\n");
8361 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8363 RTE_ETH_FDIR_MAX_FLEXLEN);
8365 entry.action.flex_off = 0; /*use 0 by default */
8366 if (!strcmp(res->drop, "drop"))
8367 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8369 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8370 /* set to report FD ID by default */
8371 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8372 entry.action.rx_queue = res->queue_id;
8373 entry.soft_id = res->fd_id_value;
8374 if (!strcmp(res->ops, "add"))
8375 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8376 RTE_ETH_FILTER_ADD, &entry);
8378 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8379 RTE_ETH_FILTER_DELETE, &entry);
8381 printf("flow director programming error: (%s)\n",
8385 cmdline_parse_token_string_t cmd_flow_director_filter =
8386 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8387 flow_director_filter, "flow_director_filter");
8388 cmdline_parse_token_num_t cmd_flow_director_port_id =
8389 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8391 cmdline_parse_token_string_t cmd_flow_director_ops =
8392 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8394 cmdline_parse_token_string_t cmd_flow_director_flow =
8395 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8397 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8398 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8400 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8401 "ip6#ip6-frag#tcp6#udp6#sctp6");
8402 cmdline_parse_token_string_t cmd_flow_director_src =
8403 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8405 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8406 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8408 cmdline_parse_token_num_t cmd_flow_director_port_src =
8409 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8411 cmdline_parse_token_string_t cmd_flow_director_dst =
8412 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8414 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8415 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8417 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8418 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8420 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8421 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8422 verify_tag, "verify_tag");
8423 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8424 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8425 verify_tag_value, UINT32);
8426 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8427 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8428 flexbytes, "flexbytes");
8429 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8431 flexbytes_value, NULL);
8432 cmdline_parse_token_string_t cmd_flow_director_drop =
8433 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8435 cmdline_parse_token_string_t cmd_flow_director_queue =
8436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8438 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8439 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8441 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8444 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8445 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8446 fd_id_value, UINT32);
8448 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8449 .f = cmd_flow_director_filter_parsed,
8451 .help_str = "add or delete an ip flow director entry on NIC",
8453 (void *)&cmd_flow_director_filter,
8454 (void *)&cmd_flow_director_port_id,
8455 (void *)&cmd_flow_director_ops,
8456 (void *)&cmd_flow_director_flow,
8457 (void *)&cmd_flow_director_flow_type,
8458 (void *)&cmd_flow_director_src,
8459 (void *)&cmd_flow_director_ip_src,
8460 (void *)&cmd_flow_director_dst,
8461 (void *)&cmd_flow_director_ip_dst,
8462 (void *)&cmd_flow_director_flexbytes,
8463 (void *)&cmd_flow_director_flexbytes_value,
8464 (void *)&cmd_flow_director_drop,
8465 (void *)&cmd_flow_director_queue,
8466 (void *)&cmd_flow_director_queue_id,
8467 (void *)&cmd_flow_director_fd_id,
8468 (void *)&cmd_flow_director_fd_id_value,
8473 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8474 .f = cmd_flow_director_filter_parsed,
8476 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8478 (void *)&cmd_flow_director_filter,
8479 (void *)&cmd_flow_director_port_id,
8480 (void *)&cmd_flow_director_ops,
8481 (void *)&cmd_flow_director_flow,
8482 (void *)&cmd_flow_director_flow_type,
8483 (void *)&cmd_flow_director_src,
8484 (void *)&cmd_flow_director_ip_src,
8485 (void *)&cmd_flow_director_port_src,
8486 (void *)&cmd_flow_director_dst,
8487 (void *)&cmd_flow_director_ip_dst,
8488 (void *)&cmd_flow_director_port_dst,
8489 (void *)&cmd_flow_director_flexbytes,
8490 (void *)&cmd_flow_director_flexbytes_value,
8491 (void *)&cmd_flow_director_drop,
8492 (void *)&cmd_flow_director_queue,
8493 (void *)&cmd_flow_director_queue_id,
8494 (void *)&cmd_flow_director_fd_id,
8495 (void *)&cmd_flow_director_fd_id_value,
8500 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8501 .f = cmd_flow_director_filter_parsed,
8503 .help_str = "add or delete a sctp flow director entry on NIC",
8505 (void *)&cmd_flow_director_filter,
8506 (void *)&cmd_flow_director_port_id,
8507 (void *)&cmd_flow_director_ops,
8508 (void *)&cmd_flow_director_flow,
8509 (void *)&cmd_flow_director_flow_type,
8510 (void *)&cmd_flow_director_src,
8511 (void *)&cmd_flow_director_ip_src,
8512 (void *)&cmd_flow_director_dst,
8513 (void *)&cmd_flow_director_ip_dst,
8514 (void *)&cmd_flow_director_verify_tag,
8515 (void *)&cmd_flow_director_verify_tag_value,
8516 (void *)&cmd_flow_director_flexbytes,
8517 (void *)&cmd_flow_director_flexbytes_value,
8518 (void *)&cmd_flow_director_drop,
8519 (void *)&cmd_flow_director_queue,
8520 (void *)&cmd_flow_director_queue_id,
8521 (void *)&cmd_flow_director_fd_id,
8522 (void *)&cmd_flow_director_fd_id_value,
8527 struct cmd_flush_flow_director_result {
8528 cmdline_fixed_string_t flush_flow_director;
8532 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8533 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8534 flush_flow_director, "flush_flow_director");
8535 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8536 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8540 cmd_flush_flow_director_parsed(void *parsed_result,
8541 __attribute__((unused)) struct cmdline *cl,
8542 __attribute__((unused)) void *data)
8544 struct cmd_flow_director_result *res = parsed_result;
8547 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8549 printf("flow director is not supported on port %u.\n",
8554 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8555 RTE_ETH_FILTER_FLUSH, NULL);
8557 printf("flow director table flushing error: (%s)\n",
8561 cmdline_parse_inst_t cmd_flush_flow_director = {
8562 .f = cmd_flush_flow_director_parsed,
8564 .help_str = "flush all flow director entries of a device on NIC",
8566 (void *)&cmd_flush_flow_director_flush,
8567 (void *)&cmd_flush_flow_director_port_id,
8572 /* *** deal with flow director mask on flexible payload *** */
8573 struct cmd_flow_director_flex_mask_result {
8574 cmdline_fixed_string_t flow_director_flexmask;
8576 cmdline_fixed_string_t flow;
8577 cmdline_fixed_string_t flow_type;
8578 cmdline_fixed_string_t mask;
8582 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8583 __attribute__((unused)) struct cmdline *cl,
8584 __attribute__((unused)) void *data)
8586 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8587 struct rte_eth_fdir_flex_mask flex_mask;
8588 struct rte_port *port;
8589 enum rte_eth_flow_type i;
8592 if (res->port_id > nb_ports) {
8593 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8597 port = &ports[res->port_id];
8598 /** Check if the port is not started **/
8599 if (port->port_status != RTE_PORT_STOPPED) {
8600 printf("Please stop port %d first\n", res->port_id);
8604 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8605 ret = parse_flexbytes(res->mask,
8607 RTE_ETH_FDIR_MAX_FLEXLEN);
8609 printf("error: Cannot parse mask input.\n");
8612 if (!strcmp(res->flow_type, "all")) {
8613 for (i = RTE_ETH_FLOW_TYPE_UDPV4;
8614 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8616 flex_mask.flow_type = i;
8617 fdir_set_flex_mask(res->port_id, &flex_mask);
8619 cmd_reconfig_device_queue(res->port_id, 1, 0);
8622 flex_mask.flow_type = str2flowtype(res->flow_type);
8623 fdir_set_flex_mask(res->port_id, &flex_mask);
8624 cmd_reconfig_device_queue(res->port_id, 1, 1);
8627 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8628 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8629 flow_director_flexmask,
8630 "flow_director_flex_mask");
8631 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8632 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8634 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8635 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8637 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8638 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8640 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8641 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8642 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8643 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8646 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8647 .f = cmd_flow_director_flex_mask_parsed,
8649 .help_str = "set flow director's flex mask on NIC",
8651 (void *)&cmd_flow_director_flexmask,
8652 (void *)&cmd_flow_director_flexmask_port_id,
8653 (void *)&cmd_flow_director_flexmask_flow,
8654 (void *)&cmd_flow_director_flexmask_flow_type,
8655 (void *)&cmd_flow_director_flexmask_mask,
8660 /* *** deal with flow director flexible payload configuration *** */
8661 struct cmd_flow_director_flexpayload_result {
8662 cmdline_fixed_string_t flow_director_flexpayload;
8664 cmdline_fixed_string_t payload_layer;
8665 cmdline_fixed_string_t payload_cfg;
8669 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8672 const char *p, *p0 = q_arg;
8674 unsigned long int_fld;
8675 char *str_fld[max_num];
8680 p = strchr(p0, '(');
8684 p0 = strchr(p, ')');
8689 if (size >= sizeof(s))
8692 snprintf(s, sizeof(s), "%.*s", size, p);
8693 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8694 if (ret < 0 || ret > max_num)
8696 for (i = 0; i < ret; i++) {
8698 int_fld = strtoul(str_fld[i], &end, 0);
8699 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8701 offsets[i] = (uint16_t)int_fld;
8707 cmd_flow_director_flxpld_parsed(void *parsed_result,
8708 __attribute__((unused)) struct cmdline *cl,
8709 __attribute__((unused)) void *data)
8711 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8712 struct rte_eth_flex_payload_cfg flex_cfg;
8713 struct rte_port *port;
8716 if (res->port_id > nb_ports) {
8717 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8721 port = &ports[res->port_id];
8722 /** Check if the port is not started **/
8723 if (port->port_status != RTE_PORT_STOPPED) {
8724 printf("Please stop port %d first\n", res->port_id);
8728 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8730 if (!strcmp(res->payload_layer, "l2"))
8731 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8732 else if (!strcmp(res->payload_layer, "l3"))
8733 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8734 else if (!strcmp(res->payload_layer, "l4"))
8735 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8737 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8738 RTE_ETH_FDIR_MAX_FLEXLEN);
8740 printf("error: Cannot parse flex payload input.\n");
8744 fdir_set_flex_payload(res->port_id, &flex_cfg);
8745 cmd_reconfig_device_queue(res->port_id, 1, 1);
8748 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8749 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8750 flow_director_flexpayload,
8751 "flow_director_flex_payload");
8752 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8753 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8755 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8756 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8757 payload_layer, "l2#l3#l4");
8758 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8759 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8762 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8763 .f = cmd_flow_director_flxpld_parsed,
8765 .help_str = "set flow director's flex payload on NIC",
8767 (void *)&cmd_flow_director_flexpayload,
8768 (void *)&cmd_flow_director_flexpayload_port_id,
8769 (void *)&cmd_flow_director_flexpayload_payload_layer,
8770 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8775 /* *** Classification Filters Control *** */
8776 /* *** Get symmetric hash enable per port *** */
8777 struct cmd_get_sym_hash_ena_per_port_result {
8778 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8783 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8784 __rte_unused struct cmdline *cl,
8785 __rte_unused void *data)
8787 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8788 struct rte_eth_hash_filter_info info;
8791 if (rte_eth_dev_filter_supported(res->port_id,
8792 RTE_ETH_FILTER_HASH) < 0) {
8793 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8798 memset(&info, 0, sizeof(info));
8799 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8800 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8801 RTE_ETH_FILTER_GET, &info);
8804 printf("Cannot get symmetric hash enable per port "
8805 "on port %u\n", res->port_id);
8809 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8810 "enabled" : "disabled", res->port_id);
8813 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8814 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8815 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8816 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8817 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8820 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8821 .f = cmd_get_sym_hash_per_port_parsed,
8823 .help_str = "get_sym_hash_ena_per_port port_id",
8825 (void *)&cmd_get_sym_hash_ena_per_port_all,
8826 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8831 /* *** Set symmetric hash enable per port *** */
8832 struct cmd_set_sym_hash_ena_per_port_result {
8833 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8834 cmdline_fixed_string_t enable;
8839 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8840 __rte_unused struct cmdline *cl,
8841 __rte_unused void *data)
8843 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8844 struct rte_eth_hash_filter_info info;
8847 if (rte_eth_dev_filter_supported(res->port_id,
8848 RTE_ETH_FILTER_HASH) < 0) {
8849 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8854 memset(&info, 0, sizeof(info));
8855 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8856 if (!strcmp(res->enable, "enable"))
8857 info.info.enable = 1;
8858 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8859 RTE_ETH_FILTER_SET, &info);
8861 printf("Cannot set symmetric hash enable per port on "
8862 "port %u\n", res->port_id);
8865 printf("Symmetric hash has been set to %s on port %u\n",
8866 res->enable, res->port_id);
8869 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8870 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8871 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8872 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8873 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8875 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8876 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8877 enable, "enable#disable");
8879 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8880 .f = cmd_set_sym_hash_per_port_parsed,
8882 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8884 (void *)&cmd_set_sym_hash_ena_per_port_all,
8885 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8886 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8891 /* Get global config of hash function */
8892 struct cmd_get_hash_global_config_result {
8893 cmdline_fixed_string_t get_hash_global_config;
8898 flowtype_to_str(enum rte_eth_flow_type ftype)
8903 enum rte_eth_flow_type ftype;
8905 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8906 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8907 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8908 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8909 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8910 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8911 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8912 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8913 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8914 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8917 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8918 if (ftype_table[i].ftype == ftype)
8919 return ftype_table[i].str;
8926 cmd_get_hash_global_config_parsed(void *parsed_result,
8927 __rte_unused struct cmdline *cl,
8928 __rte_unused void *data)
8930 struct cmd_get_hash_global_config_result *res = parsed_result;
8931 struct rte_eth_hash_filter_info info;
8932 uint32_t idx, offset, i;
8936 if (rte_eth_dev_filter_supported(res->port_id,
8937 RTE_ETH_FILTER_HASH) < 0) {
8938 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8943 memset(&info, 0, sizeof(info));
8944 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8945 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8946 RTE_ETH_FILTER_GET, &info);
8948 printf("Cannot get hash global configurations by port %d\n",
8953 switch (info.info.global_conf.hash_func) {
8954 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8955 printf("Hash function is Toeplitz\n");
8957 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8958 printf("Hash function is Simple XOR\n");
8961 printf("Unknown hash function\n");
8965 for (i = 0; i < RTE_ETH_FLOW_TYPE_MAX; i++) {
8966 idx = i / UINT32_BIT;
8967 offset = i % UINT32_BIT;
8968 if (!(info.info.global_conf.valid_bit_mask[idx] &
8971 str = flowtype_to_str((enum rte_eth_flow_type)i);
8974 printf("Symmetric hash is %s globally for flow type %s "
8976 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8977 (1UL << offset)) ? "enabled" : "disabled"), str,
8982 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8983 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8984 get_hash_global_config, "get_hash_global_config");
8985 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8986 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8989 cmdline_parse_inst_t cmd_get_hash_global_config = {
8990 .f = cmd_get_hash_global_config_parsed,
8992 .help_str = "get_hash_global_config port_id",
8994 (void *)&cmd_get_hash_global_config_all,
8995 (void *)&cmd_get_hash_global_config_port_id,
9000 /* Set global config of hash function */
9001 struct cmd_set_hash_global_config_result {
9002 cmdline_fixed_string_t set_hash_global_config;
9004 cmdline_fixed_string_t hash_func;
9005 cmdline_fixed_string_t flow_type;
9006 cmdline_fixed_string_t enable;
9010 cmd_set_hash_global_config_parsed(void *parsed_result,
9011 __rte_unused struct cmdline *cl,
9012 __rte_unused void *data)
9014 struct cmd_set_hash_global_config_result *res = parsed_result;
9015 struct rte_eth_hash_filter_info info;
9016 uint32_t ftype, idx, offset;
9019 if (rte_eth_dev_filter_supported(res->port_id,
9020 RTE_ETH_FILTER_HASH) < 0) {
9021 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9025 memset(&info, 0, sizeof(info));
9026 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9027 if (!strcmp(res->hash_func, "toeplitz"))
9028 info.info.global_conf.hash_func =
9029 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9030 else if (!strcmp(res->hash_func, "simple_xor"))
9031 info.info.global_conf.hash_func =
9032 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9033 else if (!strcmp(res->hash_func, "default"))
9034 info.info.global_conf.hash_func =
9035 RTE_ETH_HASH_FUNCTION_DEFAULT;
9037 ftype = str2flowtype(res->flow_type);
9038 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9039 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9040 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9041 if (!strcmp(res->enable, "enable"))
9042 info.info.global_conf.sym_hash_enable_mask[idx] |=
9044 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9045 RTE_ETH_FILTER_SET, &info);
9047 printf("Cannot set global hash configurations by port %d\n",
9050 printf("Global hash configurations have been set "
9051 "succcessfully by port %d\n", res->port_id);
9054 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9055 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9056 set_hash_global_config, "set_hash_global_config");
9057 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9058 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9060 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9061 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9062 hash_func, "toeplitz#simple_xor#default");
9063 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9064 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9066 "ip4#ip4-frag#tcp4#udp4#sctp4#ip6#ip6-frag#tcp6#udp6#sctp6");
9067 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9068 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9069 enable, "enable#disable");
9071 cmdline_parse_inst_t cmd_set_hash_global_config = {
9072 .f = cmd_set_hash_global_config_parsed,
9074 .help_str = "set_hash_global_config port_id "
9075 "toeplitz|simple_xor|default "
9076 "ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6 "
9079 (void *)&cmd_set_hash_global_config_all,
9080 (void *)&cmd_set_hash_global_config_port_id,
9081 (void *)&cmd_set_hash_global_config_hash_func,
9082 (void *)&cmd_set_hash_global_config_flow_type,
9083 (void *)&cmd_set_hash_global_config_enable,
9088 /* ******************************************************************************** */
9090 /* list of instructions */
9091 cmdline_parse_ctx_t main_ctx[] = {
9092 (cmdline_parse_inst_t *)&cmd_help_brief,
9093 (cmdline_parse_inst_t *)&cmd_help_long,
9094 (cmdline_parse_inst_t *)&cmd_quit,
9095 (cmdline_parse_inst_t *)&cmd_showport,
9096 (cmdline_parse_inst_t *)&cmd_showportall,
9097 (cmdline_parse_inst_t *)&cmd_showcfg,
9098 (cmdline_parse_inst_t *)&cmd_start,
9099 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9100 (cmdline_parse_inst_t *)&cmd_set_link_up,
9101 (cmdline_parse_inst_t *)&cmd_set_link_down,
9102 (cmdline_parse_inst_t *)&cmd_reset,
9103 (cmdline_parse_inst_t *)&cmd_set_numbers,
9104 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9105 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9106 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9107 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9108 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9109 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9110 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9111 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9112 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9113 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9114 (cmdline_parse_inst_t *)&cmd_set_link_check,
9115 #ifdef RTE_NIC_BYPASS
9116 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9117 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9118 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9119 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9121 #ifdef RTE_LIBRTE_PMD_BOND
9122 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9123 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9124 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9125 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9126 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9127 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9128 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9129 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9130 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9132 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9133 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9134 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9135 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9136 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9137 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9138 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9139 (cmdline_parse_inst_t *)&cmd_csum_set,
9140 (cmdline_parse_inst_t *)&cmd_csum_show,
9141 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
9142 (cmdline_parse_inst_t *)&cmd_tso_set,
9143 (cmdline_parse_inst_t *)&cmd_tso_show,
9144 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9145 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9146 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9147 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9148 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9149 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9150 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9151 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9152 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9153 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9154 (cmdline_parse_inst_t *)&cmd_config_dcb,
9155 (cmdline_parse_inst_t *)&cmd_read_reg,
9156 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9157 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9158 (cmdline_parse_inst_t *)&cmd_write_reg,
9159 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9160 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9161 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9162 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
9163 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
9164 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
9165 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
9166 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
9167 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
9168 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
9169 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
9170 (cmdline_parse_inst_t *)&cmd_stop,
9171 (cmdline_parse_inst_t *)&cmd_mac_addr,
9172 (cmdline_parse_inst_t *)&cmd_set_qmap,
9173 (cmdline_parse_inst_t *)&cmd_operate_port,
9174 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9175 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9176 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9177 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9178 (cmdline_parse_inst_t *)&cmd_config_mtu,
9179 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9180 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9181 (cmdline_parse_inst_t *)&cmd_config_rss,
9182 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9183 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9184 (cmdline_parse_inst_t *)&cmd_showport_reta,
9185 (cmdline_parse_inst_t *)&cmd_config_burst,
9186 (cmdline_parse_inst_t *)&cmd_config_thresh,
9187 (cmdline_parse_inst_t *)&cmd_config_threshold,
9188 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9189 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9190 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9191 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9192 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9193 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9194 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9195 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9196 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9197 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9198 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9199 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9200 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9201 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9202 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9203 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9204 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9205 (cmdline_parse_inst_t *)&cmd_dump,
9206 (cmdline_parse_inst_t *)&cmd_dump_one,
9207 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9208 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
9209 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
9210 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
9211 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
9212 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
9213 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
9214 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
9215 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
9216 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
9217 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
9218 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
9219 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
9220 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9221 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9222 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9223 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9224 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9225 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9226 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9227 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9228 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9229 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9233 /* prompt function, called from main on MASTER lcore */
9239 /* initialize non-constant commands */
9240 cmd_set_fwd_mode_init();
9242 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9246 cmdline_interact(cl);
9247 cmdline_stdin_exit(cl);
9251 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9253 if (id < nb_ports) {
9254 /* check if need_reconfig has been set to 1 */
9255 if (ports[id].need_reconfig == 0)
9256 ports[id].need_reconfig = dev;
9257 /* check if need_reconfig_queues has been set to 1 */
9258 if (ports[id].need_reconfig_queues == 0)
9259 ports[id].need_reconfig_queues = queue;
9263 for (pid = 0; pid < nb_ports; pid++) {
9264 /* check if need_reconfig has been set to 1 */
9265 if (ports[pid].need_reconfig == 0)
9266 ports[pid].need_reconfig = dev;
9267 /* check if need_reconfig_queues has been set to 1 */
9268 if (ports[pid].need_reconfig_queues == 0)
9269 ports[pid].need_reconfig_queues = queue;
9274 #ifdef RTE_NIC_BYPASS
9276 bypass_is_supported(portid_t port_id)
9278 struct rte_port *port;
9279 struct rte_pci_id *pci_id;
9281 if (port_id >= nb_ports) {
9282 printf("\tPort id must be less than %d.\n", nb_ports);
9286 /* Get the device id. */
9287 port = &ports[port_id];
9288 pci_id = &port->dev_info.pci_dev->id;
9290 /* Check if NIC supports bypass. */
9291 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9295 printf("\tBypass not supported for port_id = %d.\n", port_id);