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|vxlan) (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 " vxlan concerns the outer IP and UDP layer (in"
326 " case the packet is recognized as a vxlan packet by"
327 " the forward engine)\n"
328 " Please check the NIC datasheet for HW limits.\n\n"
330 "csum show (port_id)\n"
331 " Display tx checksum offload configuration\n\n"
333 "tso set (segsize) (portid)\n"
334 " Enable TCP Segmentation Offload in csum forward"
336 " Please check the NIC datasheet for HW limits.\n\n"
339 " Display the status of TCP Segmentation Offload.\n\n"
342 " Set packet forwarding mode.\n\n"
344 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
345 " Add a MAC address on port_id.\n\n"
347 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
348 " Remove a MAC address from port_id.\n\n"
350 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
351 " Add a MAC address for a VF on the port.\n\n"
353 "set port (port_id) uta (mac_address|all) (on|off)\n"
354 " Add/Remove a or all unicast hash filter(s)"
357 "set promisc (port_id|all) (on|off)\n"
358 " Set the promiscuous mode on port_id, or all.\n\n"
360 "set allmulti (port_id|all) (on|off)\n"
361 " Set the allmulti mode on port_id, or all.\n\n"
363 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
364 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
365 " (on|off) autoneg (on|off) (port_id)\n"
366 "set flow_ctrl rx (on|off) (portid)\n"
367 "set flow_ctrl tx (on|off) (portid)\n"
368 "set flow_ctrl high_water (high_water) (portid)\n"
369 "set flow_ctrl low_water (low_water) (portid)\n"
370 "set flow_ctrl pause_time (pause_time) (portid)\n"
371 "set flow_ctrl send_xon (send_xon) (portid)\n"
372 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
373 "set flow_ctrl autoneg (on|off) (port_id)\n"
374 " Set the link flow control parameter on a port.\n\n"
376 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
377 " (low_water) (pause_time) (priority) (port_id)\n"
378 " Set the priority flow control parameter on a"
381 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
382 " Set statistics mapping (qmapping 0..15) for RX/TX"
384 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
385 " on port 0 to mapping 5.\n\n"
387 "set port (port_id) vf (vf_id) rx|tx on|off\n"
388 " Enable/Disable a VF receive/tranmit from a port\n\n"
390 "set port (port_id) vf (vf_id) (mac_addr)"
391 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
392 " Add/Remove unicast or multicast MAC addr filter"
395 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
397 " AUPE:accepts untagged VLAN;"
398 "ROPE:accept unicast hash\n\n"
399 " BAM:accepts broadcast packets;"
400 "MPE:accepts all multicast packets\n\n"
401 " Enable/Disable a VF receive mode of a port\n\n"
403 "set port (port_id) queue (queue_id) rate (rate_num)\n"
404 " Set rate limit for a queue of a port\n\n"
406 "set port (port_id) vf (vf_id) rate (rate_num) "
407 "queue_mask (queue_mask_value)\n"
408 " Set rate limit for queues in VF of a port\n\n"
410 "set port (port_id) mirror-rule (rule_id)"
411 "(pool-mirror|vlan-mirror)\n"
412 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
413 " Set pool or vlan type mirror rule on a port.\n"
414 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
415 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
418 "set port (port_id) mirror-rule (rule_id)"
419 " (uplink-mirror|downlink-mirror) dst-pool"
420 " (pool_id) (on|off)\n"
421 " Set uplink or downlink type mirror rule on a port.\n"
422 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
423 " 0 on' enable mirror income traffic to pool 0.\n\n"
425 "reset port (port_id) mirror-rule (rule_id)\n"
426 " Reset a mirror rule.\n\n"
428 "set flush_rx (on|off)\n"
429 " Flush (default) or don't flush RX streams before"
430 " forwarding. Mainly used with PCAP drivers.\n\n"
432 #ifdef RTE_NIC_BYPASS
433 "set bypass mode (normal|bypass|isolate) (port_id)\n"
434 " Set the bypass mode for the lowest port on bypass enabled"
437 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
438 "mode (normal|bypass|isolate) (port_id)\n"
439 " Set the event required to initiate specified bypass mode for"
440 " the lowest port on a bypass enabled NIC where:\n"
441 " timeout = enable bypass after watchdog timeout.\n"
442 " os_on = enable bypass when OS/board is powered on.\n"
443 " os_off = enable bypass when OS/board is powered off.\n"
444 " power_on = enable bypass when power supply is turned on.\n"
445 " power_off = enable bypass when power supply is turned off."
448 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
449 " Set the bypass watchdog timeout to 'n' seconds"
450 " where 0 = instant.\n\n"
452 "show bypass config (port_id)\n"
453 " Show the bypass configuration for a bypass enabled NIC"
454 " using the lowest port on the NIC.\n\n"
456 #ifdef RTE_LIBRTE_PMD_BOND
457 "create bonded device (mode) (socket)\n"
458 " Create a new bonded device with specific bonding mode and socket.\n\n"
460 "add bonding slave (slave_id) (port_id)\n"
461 " Add a slave device to a bonded device.\n\n"
463 "remove bonding slave (slave_id) (port_id)\n"
464 " Remove a slave device from a bonded device.\n\n"
466 "set bonding mode (value) (port_id)\n"
467 " Set the bonding mode on a bonded device.\n\n"
469 "set bonding primary (slave_id) (port_id)\n"
470 " Set the primary slave for a bonded device.\n\n"
472 "show bonding config (port_id)\n"
473 " Show the bonding config for port_id.\n\n"
475 "set bonding mac_addr (port_id) (address)\n"
476 " Set the MAC address of a bonded device.\n\n"
478 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
479 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
481 "set bonding mon_period (port_id) (value)\n"
482 " Set the bonding link status monitoring polling period in ms.\n\n"
484 "set link-up port (port_id)\n"
485 " Set link up for a port.\n\n"
487 "set link-down port (port_id)\n"
488 " Set link down for a port.\n\n"
490 , list_pkt_forwarding_modes()
495 if (show_all || !strcmp(res->section, "flowdir")) {
500 "Flow director mode:\n"
501 "-------------------\n\n"
503 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
504 " src (src_ip_address) (src_port)"
505 " dst (dst_ip_address) (dst_port)"
506 " flexbytes (flexbytes_values) vlan (vlan_id)"
507 " queue (queue_id)\n"
508 " Add a signature filter.\n\n"
510 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
511 " src (src_ip_address) (src_port)"
512 " dst (dst_ip_address) (dst_port)"
513 " flexbytes (flexbytes_values) vlan (vlan_id)"
514 " queue (queue_id)\n"
515 " Update a signature filter.\n\n"
517 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
518 " src (src_ip_address) (src_port)"
519 " dst (dst_ip_address) (dst_port)"
520 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
521 " Remove a signature filter.\n\n"
523 "add_perfect_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)"
527 " queue (queue_id) soft (soft_id)\n"
528 " Add a perfect filter.\n\n"
530 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
531 " src (src_ip_address) (src_port)"
532 " dst (dst_ip_address) (dst_port)"
533 " flexbytes (flexbytes_values) vlan (vlan_id)"
534 " queue (queue_id)\n"
535 " Update a perfect filter.\n\n"
537 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
538 " src (src_ip_address) (src_port)"
539 " dst (dst_ip_address) (dst_port)"
540 " flexbytes (flexbytes_values) vlan (vlan_id)"
542 " Remove a perfect filter.\n\n"
544 "set_masks_filter (port_id) only_ip_flow (0|1)"
545 " src_mask (ip_src_mask) (src_port_mask)"
546 " dst_mask (ip_dst_mask) (dst_port_mask)"
547 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
548 " Set IPv4 filter masks.\n\n"
550 "set_ipv6_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)"
554 " compare_dst (0|1)\n"
555 " Set IPv6 filter masks.\n\n"
559 if (show_all || !strcmp(res->section, "ports")) {
565 "----------------\n\n"
567 "port start (port_id|all)\n"
568 " Start all ports or port_id.\n\n"
570 "port stop (port_id|all)\n"
571 " Stop all ports or port_id.\n\n"
573 "port close (port_id|all)\n"
574 " Close all ports or port_id.\n\n"
576 "port config (port_id|all)"
577 " speed (10|100|1000|10000|40000|auto)"
578 " duplex (half|full|auto)\n"
579 " Set speed and duplex for all ports or port_id\n\n"
581 "port config all (rxq|txq|rxd|txd) (value)\n"
582 " Set number for rxq/txq/rxd/txd.\n\n"
584 "port config all max-pkt-len (value)\n"
585 " Set the max packet length.\n\n"
587 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
589 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
592 "port config all rss (ip|udp|none)\n"
593 " Set the RSS mode.\n\n"
595 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
596 " Set the RSS redirection table.\n\n"
598 "port config (port_id) dcb vt (on|off) (traffic_class)"
600 " Set the DCB mode.\n\n"
602 "port config all burst (value)\n"
603 " Set the number of packets per burst.\n\n"
605 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
607 " Set the ring prefetch/host/writeback threshold"
608 " for tx/rx queue.\n\n"
610 "port config all (txfreet|txrst|rxfreet) (value)\n"
611 " Set free threshold for rx/tx, or set"
612 " tx rs bit threshold.\n\n"
613 "port config mtu X value\n"
614 " Set the MTU of port X to a given value\n\n"
616 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
617 " Start/stop a rx/tx queue of port X. Only take effect"
618 " when port X is started\n"
622 if (show_all || !strcmp(res->section, "registers")) {
630 "read reg (port_id) (address)\n"
631 " Display value of a port register.\n\n"
633 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
634 " Display a port register bit field.\n\n"
636 "read regbit (port_id) (address) (bit_x)\n"
637 " Display a single port register bit.\n\n"
639 "write reg (port_id) (address) (value)\n"
640 " Set value of a port register.\n\n"
642 "write regfield (port_id) (address) (bit_x) (bit_y)"
644 " Set bit field of a port register.\n\n"
646 "write regbit (port_id) (address) (bit_x) (value)\n"
647 " Set single bit value of a port register.\n\n"
650 if (show_all || !strcmp(res->section, "filters")) {
658 "ethertype_filter (port_id) (add|del)"
659 " (mac_addr|mac_ignr) (mac_address) ethertype"
660 " (ether_type) (drop|fwd) queue (queue_id)\n"
661 " Add/Del an ethertype filter.\n\n"
663 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
664 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
665 " queue (queue_id) index (idx)\n"
666 " add a 2tuple filter.\n\n"
668 "remove_2tuple_filter (port_id) index (idx)\n"
669 " remove a 2tuple filter.\n\n"
671 "get_2tuple_filter (port_id) index (idx)\n"
672 " get info of a 2tuple filter.\n\n"
674 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
675 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
676 " mask (mask_value) flags (flags_value) priority (prio_value)"
677 " queue (queue_id) index (idx)\n"
678 " add a 5tuple filter.\n\n"
680 "remove_5tuple_filter (port_id) index (idx)\n"
681 " remove a 5tuple filter.\n\n"
683 "get_5tuple_filter (port_id) index (idx)\n"
684 " get info of a 5tuple filter.\n\n"
686 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
687 " add syn filter.\n\n"
689 "remove_syn_filter (port_id)"
690 " remove syn filter.\n\n"
692 "get_syn_filter (port_id) "
693 " get syn filter info.\n\n"
695 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
696 " priority (prio_value) queue (queue_id) index (idx)\n"
697 " add a flex filter.\n\n"
699 "remove_flex_filter (port_id) index (idx)\n"
700 " remove a flex filter.\n\n"
702 "get_flex_filter (port_id) index (idx)\n"
703 " get info of a flex filter.\n\n"
705 "flow_director_filter (port_id) (add|del)"
706 " flow (ip4|ip4-frag|ip6|ip6-frag)"
707 " src (src_ip_address) dst (dst_ip_address)"
708 " flexbytes (flexbytes_value)"
709 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
710 " Add/Del an IP type flow director filter.\n\n"
712 "flow_director_filter (port_id) (add|del)"
713 " flow (udp4|tcp4|udp6|tcp6)"
714 " src (src_ip_address) (src_port)"
715 " dst (dst_ip_address) (dst_port)"
716 " flexbytes (flexbytes_value)"
717 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
718 " Add/Del an UDP/TCP type flow director filter.\n\n"
720 "flow_director_filter (port_id) (add|del)"
721 " flow (sctp4|sctp6)"
722 " src (src_ip_address) dst (dst_ip_address)"
723 " tag (verification_tag)"
724 " flexbytes (flexbytes_value) (drop|fwd)"
725 " queue (queue_id) fd_id (fd_id_value)\n"
726 " Add/Del a SCTP type flow director filter.\n\n"
728 "flush_flow_director (port_id)\n"
729 " Flush all flow director entries of a device.\n\n"
731 "flow_director_flex_mask (port_id)"
732 " flow (ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
734 " Configure mask of flex payload.\n\n"
736 "flow_director_flex_payload (port_id)"
737 " (l2|l3|l4) (config)\n"
738 " Configure flex payload selection.\n\n"
740 "get_sym_hash_ena_per_port (port_id)\n"
741 " get symmetric hash enable configuration per port.\n\n"
743 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
744 " set symmetric hash enable configuration per port"
745 " to enable or disable.\n\n"
747 "get_hash_global_config (port_id)\n"
748 " Get the global configurations of hash filters.\n\n"
750 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
751 " (ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6)"
752 " (enable|disable)\n"
753 " Set the global configurations of hash filters.\n\n"
758 cmdline_parse_token_string_t cmd_help_long_help =
759 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
761 cmdline_parse_token_string_t cmd_help_long_section =
762 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
763 "all#control#display#config#flowdir#"
764 "ports#registers#filters");
766 cmdline_parse_inst_t cmd_help_long = {
767 .f = cmd_help_long_parsed,
769 .help_str = "show help",
771 (void *)&cmd_help_long_help,
772 (void *)&cmd_help_long_section,
778 /* *** start/stop/close all ports *** */
779 struct cmd_operate_port_result {
780 cmdline_fixed_string_t keyword;
781 cmdline_fixed_string_t name;
782 cmdline_fixed_string_t value;
785 static void cmd_operate_port_parsed(void *parsed_result,
786 __attribute__((unused)) struct cmdline *cl,
787 __attribute__((unused)) void *data)
789 struct cmd_operate_port_result *res = parsed_result;
791 if (!strcmp(res->name, "start"))
792 start_port(RTE_PORT_ALL);
793 else if (!strcmp(res->name, "stop"))
794 stop_port(RTE_PORT_ALL);
795 else if (!strcmp(res->name, "close"))
796 close_port(RTE_PORT_ALL);
798 printf("Unknown parameter\n");
801 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
802 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
804 cmdline_parse_token_string_t cmd_operate_port_all_port =
805 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
807 cmdline_parse_token_string_t cmd_operate_port_all_all =
808 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
810 cmdline_parse_inst_t cmd_operate_port = {
811 .f = cmd_operate_port_parsed,
813 .help_str = "port start|stop|close all: start/stop/close all ports",
815 (void *)&cmd_operate_port_all_cmd,
816 (void *)&cmd_operate_port_all_port,
817 (void *)&cmd_operate_port_all_all,
822 /* *** start/stop/close specific port *** */
823 struct cmd_operate_specific_port_result {
824 cmdline_fixed_string_t keyword;
825 cmdline_fixed_string_t name;
829 static void cmd_operate_specific_port_parsed(void *parsed_result,
830 __attribute__((unused)) struct cmdline *cl,
831 __attribute__((unused)) void *data)
833 struct cmd_operate_specific_port_result *res = parsed_result;
835 if (!strcmp(res->name, "start"))
836 start_port(res->value);
837 else if (!strcmp(res->name, "stop"))
838 stop_port(res->value);
839 else if (!strcmp(res->name, "close"))
840 close_port(res->value);
842 printf("Unknown parameter\n");
845 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
846 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
848 cmdline_parse_token_string_t cmd_operate_specific_port_port =
849 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
850 name, "start#stop#close");
851 cmdline_parse_token_num_t cmd_operate_specific_port_id =
852 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
855 cmdline_parse_inst_t cmd_operate_specific_port = {
856 .f = cmd_operate_specific_port_parsed,
858 .help_str = "port start|stop|close X: start/stop/close port X",
860 (void *)&cmd_operate_specific_port_cmd,
861 (void *)&cmd_operate_specific_port_port,
862 (void *)&cmd_operate_specific_port_id,
867 /* *** configure speed for all ports *** */
868 struct cmd_config_speed_all {
869 cmdline_fixed_string_t port;
870 cmdline_fixed_string_t keyword;
871 cmdline_fixed_string_t all;
872 cmdline_fixed_string_t item1;
873 cmdline_fixed_string_t item2;
874 cmdline_fixed_string_t value1;
875 cmdline_fixed_string_t value2;
879 cmd_config_speed_all_parsed(void *parsed_result,
880 __attribute__((unused)) struct cmdline *cl,
881 __attribute__((unused)) void *data)
883 struct cmd_config_speed_all *res = parsed_result;
884 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
885 uint16_t link_duplex = 0;
888 if (!all_ports_stopped()) {
889 printf("Please stop all ports first\n");
893 if (!strcmp(res->value1, "10"))
894 link_speed = ETH_LINK_SPEED_10;
895 else if (!strcmp(res->value1, "100"))
896 link_speed = ETH_LINK_SPEED_100;
897 else if (!strcmp(res->value1, "1000"))
898 link_speed = ETH_LINK_SPEED_1000;
899 else if (!strcmp(res->value1, "10000"))
900 link_speed = ETH_LINK_SPEED_10G;
901 else if (!strcmp(res->value1, "40000"))
902 link_speed = ETH_LINK_SPEED_40G;
903 else if (!strcmp(res->value1, "auto"))
904 link_speed = ETH_LINK_SPEED_AUTONEG;
906 printf("Unknown parameter\n");
910 if (!strcmp(res->value2, "half"))
911 link_duplex = ETH_LINK_HALF_DUPLEX;
912 else if (!strcmp(res->value2, "full"))
913 link_duplex = ETH_LINK_FULL_DUPLEX;
914 else if (!strcmp(res->value2, "auto"))
915 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
917 printf("Unknown parameter\n");
921 for (pid = 0; pid < nb_ports; pid++) {
922 ports[pid].dev_conf.link_speed = link_speed;
923 ports[pid].dev_conf.link_duplex = link_duplex;
926 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
929 cmdline_parse_token_string_t cmd_config_speed_all_port =
930 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
931 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
932 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
934 cmdline_parse_token_string_t cmd_config_speed_all_all =
935 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
936 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
937 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
938 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
939 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
940 "10#100#1000#10000#40000#auto");
941 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
942 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
943 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
944 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
947 cmdline_parse_inst_t cmd_config_speed_all = {
948 .f = cmd_config_speed_all_parsed,
950 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
953 (void *)&cmd_config_speed_all_port,
954 (void *)&cmd_config_speed_all_keyword,
955 (void *)&cmd_config_speed_all_all,
956 (void *)&cmd_config_speed_all_item1,
957 (void *)&cmd_config_speed_all_value1,
958 (void *)&cmd_config_speed_all_item2,
959 (void *)&cmd_config_speed_all_value2,
964 /* *** configure speed for specific port *** */
965 struct cmd_config_speed_specific {
966 cmdline_fixed_string_t port;
967 cmdline_fixed_string_t keyword;
969 cmdline_fixed_string_t item1;
970 cmdline_fixed_string_t item2;
971 cmdline_fixed_string_t value1;
972 cmdline_fixed_string_t value2;
976 cmd_config_speed_specific_parsed(void *parsed_result,
977 __attribute__((unused)) struct cmdline *cl,
978 __attribute__((unused)) void *data)
980 struct cmd_config_speed_specific *res = parsed_result;
981 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
982 uint16_t link_duplex = 0;
984 if (!all_ports_stopped()) {
985 printf("Please stop all ports first\n");
989 if (res->id >= nb_ports) {
990 printf("Port id %d must be less than %d\n", res->id, nb_ports);
994 if (!strcmp(res->value1, "10"))
995 link_speed = ETH_LINK_SPEED_10;
996 else if (!strcmp(res->value1, "100"))
997 link_speed = ETH_LINK_SPEED_100;
998 else if (!strcmp(res->value1, "1000"))
999 link_speed = ETH_LINK_SPEED_1000;
1000 else if (!strcmp(res->value1, "10000"))
1001 link_speed = ETH_LINK_SPEED_10000;
1002 else if (!strcmp(res->value1, "40000"))
1003 link_speed = ETH_LINK_SPEED_40G;
1004 else if (!strcmp(res->value1, "auto"))
1005 link_speed = ETH_LINK_SPEED_AUTONEG;
1007 printf("Unknown parameter\n");
1011 if (!strcmp(res->value2, "half"))
1012 link_duplex = ETH_LINK_HALF_DUPLEX;
1013 else if (!strcmp(res->value2, "full"))
1014 link_duplex = ETH_LINK_FULL_DUPLEX;
1015 else if (!strcmp(res->value2, "auto"))
1016 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1018 printf("Unknown parameter\n");
1022 ports[res->id].dev_conf.link_speed = link_speed;
1023 ports[res->id].dev_conf.link_duplex = link_duplex;
1025 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1029 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1030 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1032 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1033 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1035 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1036 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1037 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1038 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1040 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1041 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1042 "10#100#1000#10000#40000#auto");
1043 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1044 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1046 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1047 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1050 cmdline_parse_inst_t cmd_config_speed_specific = {
1051 .f = cmd_config_speed_specific_parsed,
1053 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1056 (void *)&cmd_config_speed_specific_port,
1057 (void *)&cmd_config_speed_specific_keyword,
1058 (void *)&cmd_config_speed_specific_id,
1059 (void *)&cmd_config_speed_specific_item1,
1060 (void *)&cmd_config_speed_specific_value1,
1061 (void *)&cmd_config_speed_specific_item2,
1062 (void *)&cmd_config_speed_specific_value2,
1067 /* *** configure txq/rxq, txd/rxd *** */
1068 struct cmd_config_rx_tx {
1069 cmdline_fixed_string_t port;
1070 cmdline_fixed_string_t keyword;
1071 cmdline_fixed_string_t all;
1072 cmdline_fixed_string_t name;
1077 cmd_config_rx_tx_parsed(void *parsed_result,
1078 __attribute__((unused)) struct cmdline *cl,
1079 __attribute__((unused)) void *data)
1081 struct cmd_config_rx_tx *res = parsed_result;
1083 if (!all_ports_stopped()) {
1084 printf("Please stop all ports first\n");
1088 if (!strcmp(res->name, "rxq")) {
1089 if (res->value <= 0) {
1090 printf("rxq %d invalid - must be > 0\n", res->value);
1093 nb_rxq = res->value;
1095 else if (!strcmp(res->name, "txq")) {
1096 if (res->value <= 0) {
1097 printf("txq %d invalid - must be > 0\n", res->value);
1100 nb_txq = res->value;
1102 else if (!strcmp(res->name, "rxd")) {
1103 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1104 printf("rxd %d invalid - must be > 0 && <= %d\n",
1105 res->value, RTE_TEST_RX_DESC_MAX);
1108 nb_rxd = res->value;
1109 } else if (!strcmp(res->name, "txd")) {
1110 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1111 printf("txd %d invalid - must be > 0 && <= %d\n",
1112 res->value, RTE_TEST_TX_DESC_MAX);
1115 nb_txd = res->value;
1117 printf("Unknown parameter\n");
1123 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1126 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1127 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1128 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1129 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1130 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1131 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1132 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1133 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1135 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1136 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1138 cmdline_parse_inst_t cmd_config_rx_tx = {
1139 .f = cmd_config_rx_tx_parsed,
1141 .help_str = "port config all rxq|txq|rxd|txd value",
1143 (void *)&cmd_config_rx_tx_port,
1144 (void *)&cmd_config_rx_tx_keyword,
1145 (void *)&cmd_config_rx_tx_all,
1146 (void *)&cmd_config_rx_tx_name,
1147 (void *)&cmd_config_rx_tx_value,
1152 /* *** config max packet length *** */
1153 struct cmd_config_max_pkt_len_result {
1154 cmdline_fixed_string_t port;
1155 cmdline_fixed_string_t keyword;
1156 cmdline_fixed_string_t all;
1157 cmdline_fixed_string_t name;
1162 cmd_config_max_pkt_len_parsed(void *parsed_result,
1163 __attribute__((unused)) struct cmdline *cl,
1164 __attribute__((unused)) void *data)
1166 struct cmd_config_max_pkt_len_result *res = parsed_result;
1168 if (!all_ports_stopped()) {
1169 printf("Please stop all ports first\n");
1173 if (!strcmp(res->name, "max-pkt-len")) {
1174 if (res->value < ETHER_MIN_LEN) {
1175 printf("max-pkt-len can not be less than %d\n",
1179 if (res->value == rx_mode.max_rx_pkt_len)
1182 rx_mode.max_rx_pkt_len = res->value;
1183 if (res->value > ETHER_MAX_LEN)
1184 rx_mode.jumbo_frame = 1;
1186 rx_mode.jumbo_frame = 0;
1188 printf("Unknown parameter\n");
1194 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1197 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1198 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1200 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1201 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1203 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1204 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1206 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1207 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1209 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1210 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1213 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1214 .f = cmd_config_max_pkt_len_parsed,
1216 .help_str = "port config all max-pkt-len value",
1218 (void *)&cmd_config_max_pkt_len_port,
1219 (void *)&cmd_config_max_pkt_len_keyword,
1220 (void *)&cmd_config_max_pkt_len_all,
1221 (void *)&cmd_config_max_pkt_len_name,
1222 (void *)&cmd_config_max_pkt_len_value,
1227 /* *** configure port MTU *** */
1228 struct cmd_config_mtu_result {
1229 cmdline_fixed_string_t port;
1230 cmdline_fixed_string_t keyword;
1231 cmdline_fixed_string_t mtu;
1237 cmd_config_mtu_parsed(void *parsed_result,
1238 __attribute__((unused)) struct cmdline *cl,
1239 __attribute__((unused)) void *data)
1241 struct cmd_config_mtu_result *res = parsed_result;
1243 if (res->value < ETHER_MIN_LEN) {
1244 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1247 port_mtu_set(res->port_id, res->value);
1250 cmdline_parse_token_string_t cmd_config_mtu_port =
1251 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1253 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1254 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1256 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1257 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1259 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1260 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1261 cmdline_parse_token_num_t cmd_config_mtu_value =
1262 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1264 cmdline_parse_inst_t cmd_config_mtu = {
1265 .f = cmd_config_mtu_parsed,
1267 .help_str = "port config mtu value",
1269 (void *)&cmd_config_mtu_port,
1270 (void *)&cmd_config_mtu_keyword,
1271 (void *)&cmd_config_mtu_mtu,
1272 (void *)&cmd_config_mtu_port_id,
1273 (void *)&cmd_config_mtu_value,
1278 /* *** configure rx mode *** */
1279 struct cmd_config_rx_mode_flag {
1280 cmdline_fixed_string_t port;
1281 cmdline_fixed_string_t keyword;
1282 cmdline_fixed_string_t all;
1283 cmdline_fixed_string_t name;
1284 cmdline_fixed_string_t value;
1288 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1289 __attribute__((unused)) struct cmdline *cl,
1290 __attribute__((unused)) void *data)
1292 struct cmd_config_rx_mode_flag *res = parsed_result;
1294 if (!all_ports_stopped()) {
1295 printf("Please stop all ports first\n");
1299 if (!strcmp(res->name, "crc-strip")) {
1300 if (!strcmp(res->value, "on"))
1301 rx_mode.hw_strip_crc = 1;
1302 else if (!strcmp(res->value, "off"))
1303 rx_mode.hw_strip_crc = 0;
1305 printf("Unknown parameter\n");
1308 } else if (!strcmp(res->name, "rx-cksum")) {
1309 if (!strcmp(res->value, "on"))
1310 rx_mode.hw_ip_checksum = 1;
1311 else if (!strcmp(res->value, "off"))
1312 rx_mode.hw_ip_checksum = 0;
1314 printf("Unknown parameter\n");
1317 } else if (!strcmp(res->name, "hw-vlan")) {
1318 if (!strcmp(res->value, "on")) {
1319 rx_mode.hw_vlan_filter = 1;
1320 rx_mode.hw_vlan_strip = 1;
1322 else if (!strcmp(res->value, "off")) {
1323 rx_mode.hw_vlan_filter = 0;
1324 rx_mode.hw_vlan_strip = 0;
1327 printf("Unknown parameter\n");
1330 } else if (!strcmp(res->name, "drop-en")) {
1331 if (!strcmp(res->value, "on"))
1333 else if (!strcmp(res->value, "off"))
1336 printf("Unknown parameter\n");
1340 printf("Unknown parameter\n");
1346 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1349 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1350 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1351 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1352 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1354 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1355 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1356 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1357 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1358 "crc-strip#rx-cksum#hw-vlan");
1359 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1360 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1363 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1364 .f = cmd_config_rx_mode_flag_parsed,
1366 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1368 (void *)&cmd_config_rx_mode_flag_port,
1369 (void *)&cmd_config_rx_mode_flag_keyword,
1370 (void *)&cmd_config_rx_mode_flag_all,
1371 (void *)&cmd_config_rx_mode_flag_name,
1372 (void *)&cmd_config_rx_mode_flag_value,
1377 /* *** configure rss *** */
1378 struct cmd_config_rss {
1379 cmdline_fixed_string_t port;
1380 cmdline_fixed_string_t keyword;
1381 cmdline_fixed_string_t all;
1382 cmdline_fixed_string_t name;
1383 cmdline_fixed_string_t value;
1387 cmd_config_rss_parsed(void *parsed_result,
1388 __attribute__((unused)) struct cmdline *cl,
1389 __attribute__((unused)) void *data)
1391 struct cmd_config_rss *res = parsed_result;
1392 struct rte_eth_rss_conf rss_conf;
1395 if (!strcmp(res->value, "ip"))
1396 rss_conf.rss_hf = ETH_RSS_IP;
1397 else if (!strcmp(res->value, "udp"))
1398 rss_conf.rss_hf = ETH_RSS_UDP;
1399 else if (!strcmp(res->value, "none"))
1400 rss_conf.rss_hf = 0;
1402 printf("Unknown parameter\n");
1405 rss_conf.rss_key = NULL;
1406 for (i = 0; i < rte_eth_dev_count(); i++)
1407 rte_eth_dev_rss_hash_update(i, &rss_conf);
1410 cmdline_parse_token_string_t cmd_config_rss_port =
1411 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1412 cmdline_parse_token_string_t cmd_config_rss_keyword =
1413 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1414 cmdline_parse_token_string_t cmd_config_rss_all =
1415 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1416 cmdline_parse_token_string_t cmd_config_rss_name =
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1418 cmdline_parse_token_string_t cmd_config_rss_value =
1419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1421 cmdline_parse_inst_t cmd_config_rss = {
1422 .f = cmd_config_rss_parsed,
1424 .help_str = "port config all rss ip|udp|none",
1426 (void *)&cmd_config_rss_port,
1427 (void *)&cmd_config_rss_keyword,
1428 (void *)&cmd_config_rss_all,
1429 (void *)&cmd_config_rss_name,
1430 (void *)&cmd_config_rss_value,
1435 /* *** configure rss hash key *** */
1436 struct cmd_config_rss_hash_key {
1437 cmdline_fixed_string_t port;
1438 cmdline_fixed_string_t config;
1440 cmdline_fixed_string_t rss_hash_key;
1441 cmdline_fixed_string_t key;
1444 #define RSS_HASH_KEY_LENGTH 40
1446 hexa_digit_to_value(char hexa_digit)
1448 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1449 return (uint8_t) (hexa_digit - '0');
1450 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1451 return (uint8_t) ((hexa_digit - 'a') + 10);
1452 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1453 return (uint8_t) ((hexa_digit - 'A') + 10);
1454 /* Invalid hexa digit */
1459 parse_and_check_key_hexa_digit(char *key, int idx)
1463 hexa_v = hexa_digit_to_value(key[idx]);
1465 printf("invalid key: character %c at position %d is not a "
1466 "valid hexa digit\n", key[idx], idx);
1471 cmd_config_rss_hash_key_parsed(void *parsed_result,
1472 __attribute__((unused)) struct cmdline *cl,
1473 __attribute__((unused)) void *data)
1475 struct cmd_config_rss_hash_key *res = parsed_result;
1476 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1481 /* Check the length of the RSS hash key */
1482 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1483 printf("key length: %d invalid - key must be a string of %d"
1484 "hexa-decimal numbers\n", (int) strlen(res->key),
1485 RSS_HASH_KEY_LENGTH * 2);
1488 /* Translate RSS hash key into binary representation */
1489 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1490 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1493 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1496 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1498 port_rss_hash_key_update(res->port_id, hash_key);
1501 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1502 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1503 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1504 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1506 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1507 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1508 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1509 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1510 rss_hash_key, "rss-hash-key");
1511 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1512 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1514 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1515 .f = cmd_config_rss_hash_key_parsed,
1517 .help_str = "port config X rss-hash-key 80 hexa digits",
1519 (void *)&cmd_config_rss_hash_key_port,
1520 (void *)&cmd_config_rss_hash_key_config,
1521 (void *)&cmd_config_rss_hash_key_port_id,
1522 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1523 (void *)&cmd_config_rss_hash_key_value,
1528 /* *** configure port rxq/txq start/stop *** */
1529 struct cmd_config_rxtx_queue {
1530 cmdline_fixed_string_t port;
1532 cmdline_fixed_string_t rxtxq;
1534 cmdline_fixed_string_t opname;
1538 cmd_config_rxtx_queue_parsed(void *parsed_result,
1539 __attribute__((unused)) struct cmdline *cl,
1540 __attribute__((unused)) void *data)
1542 struct cmd_config_rxtx_queue *res = parsed_result;
1547 if (test_done == 0) {
1548 printf("Please stop forwarding first\n");
1552 if (port_id_is_invalid(res->portid))
1555 if (port_is_started(res->portid) != 1) {
1556 printf("Please start port %u first\n", res->portid);
1560 if (!strcmp(res->rxtxq, "rxq"))
1562 else if (!strcmp(res->rxtxq, "txq"))
1565 printf("Unknown parameter\n");
1569 if (isrx && rx_queue_id_is_invalid(res->qid))
1571 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1574 if (!strcmp(res->opname, "start"))
1576 else if (!strcmp(res->opname, "stop"))
1579 printf("Unknown parameter\n");
1583 if (isstart && isrx)
1584 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1585 else if (!isstart && isrx)
1586 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1587 else if (isstart && !isrx)
1588 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1590 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1592 if (ret == -ENOTSUP)
1593 printf("Function not supported in PMD driver\n");
1596 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1597 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1598 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1599 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1600 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1601 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1602 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1603 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1604 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1605 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1608 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1609 .f = cmd_config_rxtx_queue_parsed,
1611 .help_str = "port X rxq|txq ID start|stop",
1613 (void *)&cmd_config_speed_all_port,
1614 (void *)&cmd_config_rxtx_queue_portid,
1615 (void *)&cmd_config_rxtx_queue_rxtxq,
1616 (void *)&cmd_config_rxtx_queue_qid,
1617 (void *)&cmd_config_rxtx_queue_opname,
1622 /* *** Configure RSS RETA *** */
1623 struct cmd_config_rss_reta {
1624 cmdline_fixed_string_t port;
1625 cmdline_fixed_string_t keyword;
1627 cmdline_fixed_string_t name;
1628 cmdline_fixed_string_t list_name;
1629 cmdline_fixed_string_t list_of_items;
1633 parse_reta_config(const char *str,
1634 struct rte_eth_rss_reta_entry64 *reta_conf,
1635 uint16_t nb_entries)
1639 uint16_t hash_index, idx, shift;
1642 const char *p, *p0 = str;
1649 unsigned long int_fld[_NUM_FLD];
1650 char *str_fld[_NUM_FLD];
1652 while ((p = strchr(p0,'(')) != NULL) {
1654 if((p0 = strchr(p,')')) == NULL)
1658 if(size >= sizeof(s))
1661 snprintf(s, sizeof(s), "%.*s", size, p);
1662 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1664 for (i = 0; i < _NUM_FLD; i++) {
1666 int_fld[i] = strtoul(str_fld[i], &end, 0);
1667 if (errno != 0 || end == str_fld[i] ||
1672 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1673 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1675 if (hash_index >= nb_entries) {
1676 printf("Invalid RETA hash index=%d\n", hash_index);
1680 idx = hash_index / RTE_RETA_GROUP_SIZE;
1681 shift = hash_index % RTE_RETA_GROUP_SIZE;
1682 reta_conf[idx].mask |= (1ULL << shift);
1683 reta_conf[idx].reta[shift] = nb_queue;
1690 cmd_set_rss_reta_parsed(void *parsed_result,
1691 __attribute__((unused)) struct cmdline *cl,
1692 __attribute__((unused)) void *data)
1695 struct rte_eth_dev_info dev_info;
1696 struct rte_eth_rss_reta_entry64 reta_conf[8];
1697 struct cmd_config_rss_reta *res = parsed_result;
1699 memset(&dev_info, 0, sizeof(dev_info));
1700 rte_eth_dev_info_get(res->port_id, &dev_info);
1701 if (dev_info.reta_size == 0) {
1702 printf("Redirection table size is 0 which is "
1703 "invalid for RSS\n");
1706 printf("The reta size of port %d is %u\n",
1707 res->port_id, dev_info.reta_size);
1708 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1709 printf("Currently do not support more than %u entries of "
1710 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1714 memset(reta_conf, 0, sizeof(reta_conf));
1715 if (!strcmp(res->list_name, "reta")) {
1716 if (parse_reta_config(res->list_of_items, reta_conf,
1717 dev_info.reta_size)) {
1718 printf("Invalid RSS Redirection Table "
1719 "config entered\n");
1722 ret = rte_eth_dev_rss_reta_update(res->port_id,
1723 reta_conf, dev_info.reta_size);
1725 printf("Bad redirection table parameter, "
1726 "return code = %d \n", ret);
1730 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1732 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1733 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1734 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1735 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1736 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1738 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1739 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1740 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1741 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1743 cmdline_parse_inst_t cmd_config_rss_reta = {
1744 .f = cmd_set_rss_reta_parsed,
1746 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1748 (void *)&cmd_config_rss_reta_port,
1749 (void *)&cmd_config_rss_reta_keyword,
1750 (void *)&cmd_config_rss_reta_port_id,
1751 (void *)&cmd_config_rss_reta_name,
1752 (void *)&cmd_config_rss_reta_list_name,
1753 (void *)&cmd_config_rss_reta_list_of_items,
1758 /* *** SHOW PORT RETA INFO *** */
1759 struct cmd_showport_reta {
1760 cmdline_fixed_string_t show;
1761 cmdline_fixed_string_t port;
1763 cmdline_fixed_string_t rss;
1764 cmdline_fixed_string_t reta;
1766 cmdline_fixed_string_t list_of_items;
1770 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1771 uint16_t nb_entries,
1775 const char *p, *p0 = str;
1779 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1782 p = strchr(p0, '(');
1786 p0 = strchr(p, ')');
1790 if (size >= sizeof(s)) {
1791 printf("The string size exceeds the internal buffer size\n");
1794 snprintf(s, sizeof(s), "%.*s", size, p);
1795 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1796 if (ret <= 0 || ret != num) {
1797 printf("The bits of masks do not match the number of "
1798 "reta entries: %u\n", num);
1801 for (i = 0; i < ret; i++)
1802 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1808 cmd_showport_reta_parsed(void *parsed_result,
1809 __attribute__((unused)) struct cmdline *cl,
1810 __attribute__((unused)) void *data)
1812 struct cmd_showport_reta *res = parsed_result;
1813 struct rte_eth_rss_reta_entry64 reta_conf[8];
1814 struct rte_eth_dev_info dev_info;
1816 memset(&dev_info, 0, sizeof(dev_info));
1817 rte_eth_dev_info_get(res->port_id, &dev_info);
1818 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1819 res->size > ETH_RSS_RETA_SIZE_512) {
1820 printf("Invalid redirection table size: %u\n", res->size);
1824 memset(reta_conf, 0, sizeof(reta_conf));
1825 if (showport_parse_reta_config(reta_conf, res->size,
1826 res->list_of_items) < 0) {
1827 printf("Invalid string: %s for reta masks\n",
1828 res->list_of_items);
1831 port_rss_reta_info(res->port_id, reta_conf, res->size);
1834 cmdline_parse_token_string_t cmd_showport_reta_show =
1835 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1836 cmdline_parse_token_string_t cmd_showport_reta_port =
1837 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1838 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1839 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1840 cmdline_parse_token_string_t cmd_showport_reta_rss =
1841 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1842 cmdline_parse_token_string_t cmd_showport_reta_reta =
1843 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1844 cmdline_parse_token_num_t cmd_showport_reta_size =
1845 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1846 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1847 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1848 list_of_items, NULL);
1850 cmdline_parse_inst_t cmd_showport_reta = {
1851 .f = cmd_showport_reta_parsed,
1853 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1855 (void *)&cmd_showport_reta_show,
1856 (void *)&cmd_showport_reta_port,
1857 (void *)&cmd_showport_reta_port_id,
1858 (void *)&cmd_showport_reta_rss,
1859 (void *)&cmd_showport_reta_reta,
1860 (void *)&cmd_showport_reta_size,
1861 (void *)&cmd_showport_reta_list_of_items,
1866 /* *** Show RSS hash configuration *** */
1867 struct cmd_showport_rss_hash {
1868 cmdline_fixed_string_t show;
1869 cmdline_fixed_string_t port;
1871 cmdline_fixed_string_t rss_hash;
1872 cmdline_fixed_string_t key; /* optional argument */
1875 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1876 __attribute__((unused)) struct cmdline *cl,
1879 struct cmd_showport_rss_hash *res = parsed_result;
1881 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1884 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1885 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1886 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1887 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1888 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1889 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1890 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1891 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1893 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1894 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1896 cmdline_parse_inst_t cmd_showport_rss_hash = {
1897 .f = cmd_showport_rss_hash_parsed,
1899 .help_str = "show port X rss-hash (X = port number)\n",
1901 (void *)&cmd_showport_rss_hash_show,
1902 (void *)&cmd_showport_rss_hash_port,
1903 (void *)&cmd_showport_rss_hash_port_id,
1904 (void *)&cmd_showport_rss_hash_rss_hash,
1909 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1910 .f = cmd_showport_rss_hash_parsed,
1912 .help_str = "show port X rss-hash key (X = port number)\n",
1914 (void *)&cmd_showport_rss_hash_show,
1915 (void *)&cmd_showport_rss_hash_port,
1916 (void *)&cmd_showport_rss_hash_port_id,
1917 (void *)&cmd_showport_rss_hash_rss_hash,
1918 (void *)&cmd_showport_rss_hash_rss_key,
1923 /* *** Configure DCB *** */
1924 struct cmd_config_dcb {
1925 cmdline_fixed_string_t port;
1926 cmdline_fixed_string_t config;
1928 cmdline_fixed_string_t dcb;
1929 cmdline_fixed_string_t vt;
1930 cmdline_fixed_string_t vt_en;
1932 cmdline_fixed_string_t pfc;
1933 cmdline_fixed_string_t pfc_en;
1937 cmd_config_dcb_parsed(void *parsed_result,
1938 __attribute__((unused)) struct cmdline *cl,
1939 __attribute__((unused)) void *data)
1941 struct cmd_config_dcb *res = parsed_result;
1942 struct dcb_config dcb_conf;
1943 portid_t port_id = res->port_id;
1944 struct rte_port *port;
1946 port = &ports[port_id];
1947 /** Check if the port is not started **/
1948 if (port->port_status != RTE_PORT_STOPPED) {
1949 printf("Please stop port %d first\n",port_id);
1953 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1954 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1955 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1959 /* DCB in VT mode */
1960 if (!strncmp(res->vt_en, "on",2))
1961 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1963 dcb_conf.dcb_mode = DCB_ENABLED;
1965 if (!strncmp(res->pfc_en, "on",2)) {
1966 dcb_conf.pfc_en = 1;
1969 dcb_conf.pfc_en = 0;
1971 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1972 printf("Cannot initialize network ports\n");
1976 cmd_reconfig_device_queue(port_id, 1, 1);
1979 cmdline_parse_token_string_t cmd_config_dcb_port =
1980 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1981 cmdline_parse_token_string_t cmd_config_dcb_config =
1982 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1983 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1984 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1985 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1986 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1987 cmdline_parse_token_string_t cmd_config_dcb_vt =
1988 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1989 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1990 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1991 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1992 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1993 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1994 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1995 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1996 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1998 cmdline_parse_inst_t cmd_config_dcb = {
1999 .f = cmd_config_dcb_parsed,
2001 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2003 (void *)&cmd_config_dcb_port,
2004 (void *)&cmd_config_dcb_config,
2005 (void *)&cmd_config_dcb_port_id,
2006 (void *)&cmd_config_dcb_dcb,
2007 (void *)&cmd_config_dcb_vt,
2008 (void *)&cmd_config_dcb_vt_en,
2009 (void *)&cmd_config_dcb_num_tcs,
2010 (void *)&cmd_config_dcb_pfc,
2011 (void *)&cmd_config_dcb_pfc_en,
2016 /* *** configure number of packets per burst *** */
2017 struct cmd_config_burst {
2018 cmdline_fixed_string_t port;
2019 cmdline_fixed_string_t keyword;
2020 cmdline_fixed_string_t all;
2021 cmdline_fixed_string_t name;
2026 cmd_config_burst_parsed(void *parsed_result,
2027 __attribute__((unused)) struct cmdline *cl,
2028 __attribute__((unused)) void *data)
2030 struct cmd_config_burst *res = parsed_result;
2032 if (!all_ports_stopped()) {
2033 printf("Please stop all ports first\n");
2037 if (!strcmp(res->name, "burst")) {
2038 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2039 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2042 nb_pkt_per_burst = res->value;
2044 printf("Unknown parameter\n");
2050 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2053 cmdline_parse_token_string_t cmd_config_burst_port =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2055 cmdline_parse_token_string_t cmd_config_burst_keyword =
2056 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2057 cmdline_parse_token_string_t cmd_config_burst_all =
2058 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2059 cmdline_parse_token_string_t cmd_config_burst_name =
2060 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2061 cmdline_parse_token_num_t cmd_config_burst_value =
2062 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2064 cmdline_parse_inst_t cmd_config_burst = {
2065 .f = cmd_config_burst_parsed,
2067 .help_str = "port config all burst value",
2069 (void *)&cmd_config_burst_port,
2070 (void *)&cmd_config_burst_keyword,
2071 (void *)&cmd_config_burst_all,
2072 (void *)&cmd_config_burst_name,
2073 (void *)&cmd_config_burst_value,
2078 /* *** configure rx/tx queues *** */
2079 struct cmd_config_thresh {
2080 cmdline_fixed_string_t port;
2081 cmdline_fixed_string_t keyword;
2082 cmdline_fixed_string_t all;
2083 cmdline_fixed_string_t name;
2088 cmd_config_thresh_parsed(void *parsed_result,
2089 __attribute__((unused)) struct cmdline *cl,
2090 __attribute__((unused)) void *data)
2092 struct cmd_config_thresh *res = parsed_result;
2094 if (!all_ports_stopped()) {
2095 printf("Please stop all ports first\n");
2099 if (!strcmp(res->name, "txpt"))
2100 tx_pthresh = res->value;
2101 else if(!strcmp(res->name, "txht"))
2102 tx_hthresh = res->value;
2103 else if(!strcmp(res->name, "txwt"))
2104 tx_wthresh = res->value;
2105 else if(!strcmp(res->name, "rxpt"))
2106 rx_pthresh = res->value;
2107 else if(!strcmp(res->name, "rxht"))
2108 rx_hthresh = res->value;
2109 else if(!strcmp(res->name, "rxwt"))
2110 rx_wthresh = res->value;
2112 printf("Unknown parameter\n");
2118 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2121 cmdline_parse_token_string_t cmd_config_thresh_port =
2122 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2123 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2124 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2125 cmdline_parse_token_string_t cmd_config_thresh_all =
2126 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2127 cmdline_parse_token_string_t cmd_config_thresh_name =
2128 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2129 "txpt#txht#txwt#rxpt#rxht#rxwt");
2130 cmdline_parse_token_num_t cmd_config_thresh_value =
2131 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2133 cmdline_parse_inst_t cmd_config_thresh = {
2134 .f = cmd_config_thresh_parsed,
2136 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2138 (void *)&cmd_config_thresh_port,
2139 (void *)&cmd_config_thresh_keyword,
2140 (void *)&cmd_config_thresh_all,
2141 (void *)&cmd_config_thresh_name,
2142 (void *)&cmd_config_thresh_value,
2147 /* *** configure free/rs threshold *** */
2148 struct cmd_config_threshold {
2149 cmdline_fixed_string_t port;
2150 cmdline_fixed_string_t keyword;
2151 cmdline_fixed_string_t all;
2152 cmdline_fixed_string_t name;
2157 cmd_config_threshold_parsed(void *parsed_result,
2158 __attribute__((unused)) struct cmdline *cl,
2159 __attribute__((unused)) void *data)
2161 struct cmd_config_threshold *res = parsed_result;
2163 if (!all_ports_stopped()) {
2164 printf("Please stop all ports first\n");
2168 if (!strcmp(res->name, "txfreet"))
2169 tx_free_thresh = res->value;
2170 else if (!strcmp(res->name, "txrst"))
2171 tx_rs_thresh = res->value;
2172 else if (!strcmp(res->name, "rxfreet"))
2173 rx_free_thresh = res->value;
2175 printf("Unknown parameter\n");
2181 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2184 cmdline_parse_token_string_t cmd_config_threshold_port =
2185 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2186 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2187 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2189 cmdline_parse_token_string_t cmd_config_threshold_all =
2190 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2191 cmdline_parse_token_string_t cmd_config_threshold_name =
2192 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2193 "txfreet#txrst#rxfreet");
2194 cmdline_parse_token_num_t cmd_config_threshold_value =
2195 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2197 cmdline_parse_inst_t cmd_config_threshold = {
2198 .f = cmd_config_threshold_parsed,
2200 .help_str = "port config all txfreet|txrst|rxfreet value",
2202 (void *)&cmd_config_threshold_port,
2203 (void *)&cmd_config_threshold_keyword,
2204 (void *)&cmd_config_threshold_all,
2205 (void *)&cmd_config_threshold_name,
2206 (void *)&cmd_config_threshold_value,
2212 struct cmd_stop_result {
2213 cmdline_fixed_string_t stop;
2216 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2217 __attribute__((unused)) struct cmdline *cl,
2218 __attribute__((unused)) void *data)
2220 stop_packet_forwarding();
2223 cmdline_parse_token_string_t cmd_stop_stop =
2224 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2226 cmdline_parse_inst_t cmd_stop = {
2227 .f = cmd_stop_parsed,
2229 .help_str = "stop - stop packet forwarding",
2231 (void *)&cmd_stop_stop,
2236 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2239 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2240 unsigned int *parsed_items, int check_unique_values)
2242 unsigned int nb_item;
2250 * First parse all items in the list and store their value.
2255 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2257 if ((c >= '0') && (c <= '9')) {
2258 value = (unsigned int) (value * 10 + (c - '0'));
2263 printf("character %c is not a decimal digit\n", c);
2267 printf("No valid value before comma\n");
2270 if (nb_item < max_items) {
2271 parsed_items[nb_item] = value;
2277 if (nb_item >= max_items) {
2278 printf("Number of %s = %u > %u (maximum items)\n",
2279 item_name, nb_item + 1, max_items);
2282 parsed_items[nb_item++] = value;
2283 if (! check_unique_values)
2287 * Then, check that all values in the list are differents.
2288 * No optimization here...
2290 for (i = 0; i < nb_item; i++) {
2291 for (j = i + 1; j < nb_item; j++) {
2292 if (parsed_items[j] == parsed_items[i]) {
2293 printf("duplicated %s %u at index %u and %u\n",
2294 item_name, parsed_items[i], i, j);
2302 struct cmd_set_list_result {
2303 cmdline_fixed_string_t cmd_keyword;
2304 cmdline_fixed_string_t list_name;
2305 cmdline_fixed_string_t list_of_items;
2308 static void cmd_set_list_parsed(void *parsed_result,
2309 __attribute__((unused)) struct cmdline *cl,
2310 __attribute__((unused)) void *data)
2312 struct cmd_set_list_result *res;
2314 unsigned int lcorelist[RTE_MAX_LCORE];
2315 unsigned int portlist[RTE_MAX_ETHPORTS];
2317 unsigned int nb_item;
2319 if (test_done == 0) {
2320 printf("Please stop forwarding first\n");
2324 res = parsed_result;
2325 if (!strcmp(res->list_name, "corelist")) {
2326 nb_item = parse_item_list(res->list_of_items, "core",
2328 parsed_items.lcorelist, 1);
2330 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2333 if (!strcmp(res->list_name, "portlist")) {
2334 nb_item = parse_item_list(res->list_of_items, "port",
2336 parsed_items.portlist, 1);
2338 set_fwd_ports_list(parsed_items.portlist, nb_item);
2342 cmdline_parse_token_string_t cmd_set_list_keyword =
2343 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2345 cmdline_parse_token_string_t cmd_set_list_name =
2346 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2347 "corelist#portlist");
2348 cmdline_parse_token_string_t cmd_set_list_of_items =
2349 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2352 cmdline_parse_inst_t cmd_set_fwd_list = {
2353 .f = cmd_set_list_parsed,
2355 .help_str = "set corelist|portlist x[,y]*",
2357 (void *)&cmd_set_list_keyword,
2358 (void *)&cmd_set_list_name,
2359 (void *)&cmd_set_list_of_items,
2364 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2366 struct cmd_setmask_result {
2367 cmdline_fixed_string_t set;
2368 cmdline_fixed_string_t mask;
2372 static void cmd_set_mask_parsed(void *parsed_result,
2373 __attribute__((unused)) struct cmdline *cl,
2374 __attribute__((unused)) void *data)
2376 struct cmd_setmask_result *res = parsed_result;
2378 if (test_done == 0) {
2379 printf("Please stop forwarding first\n");
2382 if (!strcmp(res->mask, "coremask"))
2383 set_fwd_lcores_mask(res->hexavalue);
2384 else if (!strcmp(res->mask, "portmask"))
2385 set_fwd_ports_mask(res->hexavalue);
2388 cmdline_parse_token_string_t cmd_setmask_set =
2389 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2390 cmdline_parse_token_string_t cmd_setmask_mask =
2391 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2392 "coremask#portmask");
2393 cmdline_parse_token_num_t cmd_setmask_value =
2394 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2396 cmdline_parse_inst_t cmd_set_fwd_mask = {
2397 .f = cmd_set_mask_parsed,
2399 .help_str = "set coremask|portmask hexadecimal value",
2401 (void *)&cmd_setmask_set,
2402 (void *)&cmd_setmask_mask,
2403 (void *)&cmd_setmask_value,
2409 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2411 struct cmd_set_result {
2412 cmdline_fixed_string_t set;
2413 cmdline_fixed_string_t what;
2417 static void cmd_set_parsed(void *parsed_result,
2418 __attribute__((unused)) struct cmdline *cl,
2419 __attribute__((unused)) void *data)
2421 struct cmd_set_result *res = parsed_result;
2422 if (!strcmp(res->what, "nbport"))
2423 set_fwd_ports_number(res->value);
2424 else if (!strcmp(res->what, "nbcore"))
2425 set_fwd_lcores_number(res->value);
2426 else if (!strcmp(res->what, "burst"))
2427 set_nb_pkt_per_burst(res->value);
2428 else if (!strcmp(res->what, "verbose"))
2429 set_verbose_level(res->value);
2432 cmdline_parse_token_string_t cmd_set_set =
2433 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2434 cmdline_parse_token_string_t cmd_set_what =
2435 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2436 "nbport#nbcore#burst#verbose");
2437 cmdline_parse_token_num_t cmd_set_value =
2438 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2440 cmdline_parse_inst_t cmd_set_numbers = {
2441 .f = cmd_set_parsed,
2443 .help_str = "set nbport|nbcore|burst|verbose value",
2445 (void *)&cmd_set_set,
2446 (void *)&cmd_set_what,
2447 (void *)&cmd_set_value,
2452 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2454 struct cmd_set_txpkts_result {
2455 cmdline_fixed_string_t cmd_keyword;
2456 cmdline_fixed_string_t txpkts;
2457 cmdline_fixed_string_t seg_lengths;
2461 cmd_set_txpkts_parsed(void *parsed_result,
2462 __attribute__((unused)) struct cmdline *cl,
2463 __attribute__((unused)) void *data)
2465 struct cmd_set_txpkts_result *res;
2466 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2467 unsigned int nb_segs;
2469 res = parsed_result;
2470 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2471 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2473 set_tx_pkt_segments(seg_lengths, nb_segs);
2476 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2477 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2478 cmd_keyword, "set");
2479 cmdline_parse_token_string_t cmd_set_txpkts_name =
2480 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2482 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2483 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2486 cmdline_parse_inst_t cmd_set_txpkts = {
2487 .f = cmd_set_txpkts_parsed,
2489 .help_str = "set txpkts x[,y]*",
2491 (void *)&cmd_set_txpkts_keyword,
2492 (void *)&cmd_set_txpkts_name,
2493 (void *)&cmd_set_txpkts_lengths,
2498 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2499 struct cmd_rx_vlan_filter_all_result {
2500 cmdline_fixed_string_t rx_vlan;
2501 cmdline_fixed_string_t what;
2502 cmdline_fixed_string_t all;
2507 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2508 __attribute__((unused)) struct cmdline *cl,
2509 __attribute__((unused)) void *data)
2511 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2513 if (!strcmp(res->what, "add"))
2514 rx_vlan_all_filter_set(res->port_id, 1);
2516 rx_vlan_all_filter_set(res->port_id, 0);
2519 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2520 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2521 rx_vlan, "rx_vlan");
2522 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2523 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2525 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2526 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2528 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2529 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2532 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2533 .f = cmd_rx_vlan_filter_all_parsed,
2535 .help_str = "add/remove all identifiers to/from the set of VLAN "
2536 "Identifiers filtered by a port",
2538 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2539 (void *)&cmd_rx_vlan_filter_all_what,
2540 (void *)&cmd_rx_vlan_filter_all_all,
2541 (void *)&cmd_rx_vlan_filter_all_portid,
2546 /* *** VLAN OFFLOAD SET ON A PORT *** */
2547 struct cmd_vlan_offload_result {
2548 cmdline_fixed_string_t vlan;
2549 cmdline_fixed_string_t set;
2550 cmdline_fixed_string_t what;
2551 cmdline_fixed_string_t on;
2552 cmdline_fixed_string_t port_id;
2556 cmd_vlan_offload_parsed(void *parsed_result,
2557 __attribute__((unused)) struct cmdline *cl,
2558 __attribute__((unused)) void *data)
2561 struct cmd_vlan_offload_result *res = parsed_result;
2564 portid_t port_id = 0;
2568 len = strnlen(str, STR_TOKEN_SIZE);
2570 /* Get port_id first */
2578 tmp = strtoul(str, NULL, 0);
2579 /* If port_id greater that what portid_t can represent, return */
2580 if(tmp >= RTE_MAX_ETHPORTS)
2582 port_id = (portid_t)tmp;
2584 if (!strcmp(res->on, "on"))
2589 if (!strcmp(res->what, "strip"))
2590 rx_vlan_strip_set(port_id, on);
2591 else if(!strcmp(res->what, "stripq")){
2592 uint16_t queue_id = 0;
2594 /* No queue_id, return */
2596 printf("must specify (port,queue_id)\n");
2599 tmp = strtoul(str + i + 1, NULL, 0);
2600 /* If queue_id greater that what 16-bits can represent, return */
2604 queue_id = (uint16_t)tmp;
2605 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2607 else if (!strcmp(res->what, "filter"))
2608 rx_vlan_filter_set(port_id, on);
2610 vlan_extend_set(port_id, on);
2615 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2616 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2618 cmdline_parse_token_string_t cmd_vlan_offload_set =
2619 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2621 cmdline_parse_token_string_t cmd_vlan_offload_what =
2622 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2623 what, "strip#filter#qinq#stripq");
2624 cmdline_parse_token_string_t cmd_vlan_offload_on =
2625 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2627 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2628 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2631 cmdline_parse_inst_t cmd_vlan_offload = {
2632 .f = cmd_vlan_offload_parsed,
2634 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2635 " qinq(extended) for both rx/tx sides ",
2637 (void *)&cmd_vlan_offload_vlan,
2638 (void *)&cmd_vlan_offload_set,
2639 (void *)&cmd_vlan_offload_what,
2640 (void *)&cmd_vlan_offload_on,
2641 (void *)&cmd_vlan_offload_portid,
2646 /* *** VLAN TPID SET ON A PORT *** */
2647 struct cmd_vlan_tpid_result {
2648 cmdline_fixed_string_t vlan;
2649 cmdline_fixed_string_t set;
2650 cmdline_fixed_string_t what;
2656 cmd_vlan_tpid_parsed(void *parsed_result,
2657 __attribute__((unused)) struct cmdline *cl,
2658 __attribute__((unused)) void *data)
2660 struct cmd_vlan_tpid_result *res = parsed_result;
2661 vlan_tpid_set(res->port_id, res->tp_id);
2665 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2666 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2668 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2669 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2671 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2672 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2674 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2675 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2677 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2678 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2681 cmdline_parse_inst_t cmd_vlan_tpid = {
2682 .f = cmd_vlan_tpid_parsed,
2684 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2686 (void *)&cmd_vlan_tpid_vlan,
2687 (void *)&cmd_vlan_tpid_set,
2688 (void *)&cmd_vlan_tpid_what,
2689 (void *)&cmd_vlan_tpid_tpid,
2690 (void *)&cmd_vlan_tpid_portid,
2695 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2696 struct cmd_rx_vlan_filter_result {
2697 cmdline_fixed_string_t rx_vlan;
2698 cmdline_fixed_string_t what;
2704 cmd_rx_vlan_filter_parsed(void *parsed_result,
2705 __attribute__((unused)) struct cmdline *cl,
2706 __attribute__((unused)) void *data)
2708 struct cmd_rx_vlan_filter_result *res = parsed_result;
2710 if (!strcmp(res->what, "add"))
2711 rx_vft_set(res->port_id, res->vlan_id, 1);
2713 rx_vft_set(res->port_id, res->vlan_id, 0);
2716 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2717 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2718 rx_vlan, "rx_vlan");
2719 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2720 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2722 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2723 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2725 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2726 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2729 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2730 .f = cmd_rx_vlan_filter_parsed,
2732 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2733 "Identifiers filtered by a port",
2735 (void *)&cmd_rx_vlan_filter_rx_vlan,
2736 (void *)&cmd_rx_vlan_filter_what,
2737 (void *)&cmd_rx_vlan_filter_vlanid,
2738 (void *)&cmd_rx_vlan_filter_portid,
2743 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2744 struct cmd_tx_vlan_set_result {
2745 cmdline_fixed_string_t tx_vlan;
2746 cmdline_fixed_string_t set;
2752 cmd_tx_vlan_set_parsed(void *parsed_result,
2753 __attribute__((unused)) struct cmdline *cl,
2754 __attribute__((unused)) void *data)
2756 struct cmd_tx_vlan_set_result *res = parsed_result;
2757 tx_vlan_set(res->port_id, res->vlan_id);
2760 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2761 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2762 tx_vlan, "tx_vlan");
2763 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2764 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2766 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2767 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2769 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2770 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2773 cmdline_parse_inst_t cmd_tx_vlan_set = {
2774 .f = cmd_tx_vlan_set_parsed,
2776 .help_str = "enable hardware insertion of a VLAN header with a given "
2777 "TAG Identifier in packets sent on a port",
2779 (void *)&cmd_tx_vlan_set_tx_vlan,
2780 (void *)&cmd_tx_vlan_set_set,
2781 (void *)&cmd_tx_vlan_set_vlanid,
2782 (void *)&cmd_tx_vlan_set_portid,
2787 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2788 struct cmd_tx_vlan_set_pvid_result {
2789 cmdline_fixed_string_t tx_vlan;
2790 cmdline_fixed_string_t set;
2791 cmdline_fixed_string_t pvid;
2794 cmdline_fixed_string_t mode;
2798 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2799 __attribute__((unused)) struct cmdline *cl,
2800 __attribute__((unused)) void *data)
2802 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2804 if (strcmp(res->mode, "on") == 0)
2805 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2807 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2810 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2811 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2812 tx_vlan, "tx_vlan");
2813 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2814 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2816 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2817 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2819 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2820 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2822 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2823 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2825 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2826 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2829 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2830 .f = cmd_tx_vlan_set_pvid_parsed,
2832 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2834 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2835 (void *)&cmd_tx_vlan_set_pvid_set,
2836 (void *)&cmd_tx_vlan_set_pvid_pvid,
2837 (void *)&cmd_tx_vlan_set_pvid_port_id,
2838 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2839 (void *)&cmd_tx_vlan_set_pvid_mode,
2844 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2845 struct cmd_tx_vlan_reset_result {
2846 cmdline_fixed_string_t tx_vlan;
2847 cmdline_fixed_string_t reset;
2852 cmd_tx_vlan_reset_parsed(void *parsed_result,
2853 __attribute__((unused)) struct cmdline *cl,
2854 __attribute__((unused)) void *data)
2856 struct cmd_tx_vlan_reset_result *res = parsed_result;
2858 tx_vlan_reset(res->port_id);
2861 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2862 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2863 tx_vlan, "tx_vlan");
2864 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2865 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2867 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2868 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2871 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2872 .f = cmd_tx_vlan_reset_parsed,
2874 .help_str = "disable hardware insertion of a VLAN header in packets "
2877 (void *)&cmd_tx_vlan_reset_tx_vlan,
2878 (void *)&cmd_tx_vlan_reset_reset,
2879 (void *)&cmd_tx_vlan_reset_portid,
2885 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2886 struct cmd_csum_result {
2887 cmdline_fixed_string_t csum;
2888 cmdline_fixed_string_t mode;
2889 cmdline_fixed_string_t proto;
2890 cmdline_fixed_string_t hwsw;
2895 csum_show(int port_id)
2897 struct rte_eth_dev_info dev_info;
2900 ol_flags = ports[port_id].tx_ol_flags;
2901 printf("IP checksum offload is %s\n",
2902 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2903 printf("UDP checksum offload is %s\n",
2904 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2905 printf("TCP checksum offload is %s\n",
2906 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2907 printf("SCTP checksum offload is %s\n",
2908 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2909 printf("VxLAN checksum offload is %s\n",
2910 (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw");
2912 /* display warnings if configuration is not supported by the NIC */
2913 rte_eth_dev_info_get(port_id, &dev_info);
2914 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2915 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2916 printf("Warning: hardware IP checksum enabled but not "
2917 "supported by port %d\n", port_id);
2919 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2920 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2921 printf("Warning: hardware UDP checksum enabled but not "
2922 "supported by port %d\n", port_id);
2924 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2925 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2926 printf("Warning: hardware TCP checksum enabled but not "
2927 "supported by port %d\n", port_id);
2929 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2930 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2931 printf("Warning: hardware SCTP checksum enabled but not "
2932 "supported by port %d\n", port_id);
2938 cmd_csum_parsed(void *parsed_result,
2939 __attribute__((unused)) struct cmdline *cl,
2940 __attribute__((unused)) void *data)
2942 struct cmd_csum_result *res = parsed_result;
2946 if (port_id_is_invalid(res->port_id)) {
2947 printf("invalid port %d\n", res->port_id);
2951 if (!strcmp(res->mode, "set")) {
2953 if (!strcmp(res->hwsw, "hw"))
2956 if (!strcmp(res->proto, "ip")) {
2957 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2958 } else if (!strcmp(res->proto, "udp")) {
2959 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2960 } else if (!strcmp(res->proto, "tcp")) {
2961 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2962 } else if (!strcmp(res->proto, "sctp")) {
2963 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2964 } else if (!strcmp(res->proto, "vxlan")) {
2965 mask = TESTPMD_TX_OFFLOAD_VXLAN_CKSUM;
2969 ports[res->port_id].tx_ol_flags |= mask;
2971 ports[res->port_id].tx_ol_flags &= (~mask);
2973 csum_show(res->port_id);
2976 cmdline_parse_token_string_t cmd_csum_csum =
2977 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2979 cmdline_parse_token_string_t cmd_csum_mode =
2980 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2982 cmdline_parse_token_string_t cmd_csum_proto =
2983 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2984 proto, "ip#tcp#udp#sctp#vxlan");
2985 cmdline_parse_token_string_t cmd_csum_hwsw =
2986 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2988 cmdline_parse_token_num_t cmd_csum_portid =
2989 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
2992 cmdline_parse_inst_t cmd_csum_set = {
2993 .f = cmd_csum_parsed,
2995 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
2996 "using csum forward engine: csum set ip|tcp|udp|sctp|vxlan hw|sw <port>",
2998 (void *)&cmd_csum_csum,
2999 (void *)&cmd_csum_mode,
3000 (void *)&cmd_csum_proto,
3001 (void *)&cmd_csum_hwsw,
3002 (void *)&cmd_csum_portid,
3007 cmdline_parse_token_string_t cmd_csum_mode_show =
3008 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3011 cmdline_parse_inst_t cmd_csum_show = {
3012 .f = cmd_csum_parsed,
3014 .help_str = "show checksum offload configuration: csum show <port>",
3016 (void *)&cmd_csum_csum,
3017 (void *)&cmd_csum_mode_show,
3018 (void *)&cmd_csum_portid,
3023 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3024 struct cmd_tso_set_result {
3025 cmdline_fixed_string_t tso;
3026 cmdline_fixed_string_t mode;
3032 cmd_tso_set_parsed(void *parsed_result,
3033 __attribute__((unused)) struct cmdline *cl,
3034 __attribute__((unused)) void *data)
3036 struct cmd_tso_set_result *res = parsed_result;
3037 struct rte_eth_dev_info dev_info;
3039 if (port_id_is_invalid(res->port_id))
3042 if (!strcmp(res->mode, "set"))
3043 ports[res->port_id].tso_segsz = res->tso_segsz;
3045 if (ports[res->port_id].tso_segsz == 0)
3046 printf("TSO is disabled\n");
3048 printf("TSO segment size is %d\n",
3049 ports[res->port_id].tso_segsz);
3051 /* display warnings if configuration is not supported by the NIC */
3052 rte_eth_dev_info_get(res->port_id, &dev_info);
3053 if ((ports[res->port_id].tso_segsz != 0) &&
3054 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3055 printf("Warning: TSO enabled but not "
3056 "supported by port %d\n", res->port_id);
3060 cmdline_parse_token_string_t cmd_tso_set_tso =
3061 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3063 cmdline_parse_token_string_t cmd_tso_set_mode =
3064 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3066 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3067 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3069 cmdline_parse_token_num_t cmd_tso_set_portid =
3070 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3073 cmdline_parse_inst_t cmd_tso_set = {
3074 .f = cmd_tso_set_parsed,
3076 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3077 "tso set <tso_segsz> <port>",
3079 (void *)&cmd_tso_set_tso,
3080 (void *)&cmd_tso_set_mode,
3081 (void *)&cmd_tso_set_tso_segsz,
3082 (void *)&cmd_tso_set_portid,
3087 cmdline_parse_token_string_t cmd_tso_show_mode =
3088 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3092 cmdline_parse_inst_t cmd_tso_show = {
3093 .f = cmd_tso_set_parsed,
3095 .help_str = "Show TSO segment size for csum engine: "
3098 (void *)&cmd_tso_set_tso,
3099 (void *)&cmd_tso_show_mode,
3100 (void *)&cmd_tso_set_portid,
3105 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3106 struct cmd_set_flush_rx {
3107 cmdline_fixed_string_t set;
3108 cmdline_fixed_string_t flush_rx;
3109 cmdline_fixed_string_t mode;
3113 cmd_set_flush_rx_parsed(void *parsed_result,
3114 __attribute__((unused)) struct cmdline *cl,
3115 __attribute__((unused)) void *data)
3117 struct cmd_set_flush_rx *res = parsed_result;
3118 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3121 cmdline_parse_token_string_t cmd_setflushrx_set =
3122 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3124 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3125 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3126 flush_rx, "flush_rx");
3127 cmdline_parse_token_string_t cmd_setflushrx_mode =
3128 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3132 cmdline_parse_inst_t cmd_set_flush_rx = {
3133 .f = cmd_set_flush_rx_parsed,
3134 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3137 (void *)&cmd_setflushrx_set,
3138 (void *)&cmd_setflushrx_flush_rx,
3139 (void *)&cmd_setflushrx_mode,
3144 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3145 struct cmd_set_link_check {
3146 cmdline_fixed_string_t set;
3147 cmdline_fixed_string_t link_check;
3148 cmdline_fixed_string_t mode;
3152 cmd_set_link_check_parsed(void *parsed_result,
3153 __attribute__((unused)) struct cmdline *cl,
3154 __attribute__((unused)) void *data)
3156 struct cmd_set_link_check *res = parsed_result;
3157 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3160 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3161 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3163 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3164 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3165 link_check, "link_check");
3166 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3167 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3171 cmdline_parse_inst_t cmd_set_link_check = {
3172 .f = cmd_set_link_check_parsed,
3173 .help_str = "set link_check on|off: enable/disable link status check "
3174 "when starting/stopping a port",
3177 (void *)&cmd_setlinkcheck_set,
3178 (void *)&cmd_setlinkcheck_link_check,
3179 (void *)&cmd_setlinkcheck_mode,
3184 #ifdef RTE_NIC_BYPASS
3185 /* *** SET NIC BYPASS MODE *** */
3186 struct cmd_set_bypass_mode_result {
3187 cmdline_fixed_string_t set;
3188 cmdline_fixed_string_t bypass;
3189 cmdline_fixed_string_t mode;
3190 cmdline_fixed_string_t value;
3195 cmd_set_bypass_mode_parsed(void *parsed_result,
3196 __attribute__((unused)) struct cmdline *cl,
3197 __attribute__((unused)) void *data)
3199 struct cmd_set_bypass_mode_result *res = parsed_result;
3200 portid_t port_id = res->port_id;
3201 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3203 if (!bypass_is_supported(port_id))
3206 if (!strcmp(res->value, "bypass"))
3207 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3208 else if (!strcmp(res->value, "isolate"))
3209 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3211 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3213 /* Set the bypass mode for the relevant port. */
3214 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3215 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3219 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3220 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3222 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3223 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3225 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3226 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3228 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3229 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3230 value, "normal#bypass#isolate");
3231 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3232 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3235 cmdline_parse_inst_t cmd_set_bypass_mode = {
3236 .f = cmd_set_bypass_mode_parsed,
3237 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3238 "Set the NIC bypass mode for port_id",
3241 (void *)&cmd_setbypass_mode_set,
3242 (void *)&cmd_setbypass_mode_bypass,
3243 (void *)&cmd_setbypass_mode_mode,
3244 (void *)&cmd_setbypass_mode_value,
3245 (void *)&cmd_setbypass_mode_port,
3250 /* *** SET NIC BYPASS EVENT *** */
3251 struct cmd_set_bypass_event_result {
3252 cmdline_fixed_string_t set;
3253 cmdline_fixed_string_t bypass;
3254 cmdline_fixed_string_t event;
3255 cmdline_fixed_string_t event_value;
3256 cmdline_fixed_string_t mode;
3257 cmdline_fixed_string_t mode_value;
3262 cmd_set_bypass_event_parsed(void *parsed_result,
3263 __attribute__((unused)) struct cmdline *cl,
3264 __attribute__((unused)) void *data)
3267 struct cmd_set_bypass_event_result *res = parsed_result;
3268 portid_t port_id = res->port_id;
3269 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3270 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3272 if (!bypass_is_supported(port_id))
3275 if (!strcmp(res->event_value, "timeout"))
3276 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3277 else if (!strcmp(res->event_value, "os_on"))
3278 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3279 else if (!strcmp(res->event_value, "os_off"))
3280 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3281 else if (!strcmp(res->event_value, "power_on"))
3282 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3283 else if (!strcmp(res->event_value, "power_off"))
3284 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3286 bypass_event = RTE_BYPASS_EVENT_NONE;
3288 if (!strcmp(res->mode_value, "bypass"))
3289 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3290 else if (!strcmp(res->mode_value, "isolate"))
3291 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3293 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3295 /* Set the watchdog timeout. */
3296 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3299 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3300 (rc = rte_eth_dev_wd_timeout_store(port_id,
3301 bypass_timeout)) != 0) {
3302 printf("Failed to set timeout value %u "
3303 "for port %d, errto code: %d.\n",
3304 bypass_timeout, port_id, rc);
3308 /* Set the bypass event to transition to bypass mode. */
3309 if (0 != rte_eth_dev_bypass_event_store(port_id,
3310 bypass_event, bypass_mode)) {
3311 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3316 cmdline_parse_token_string_t cmd_setbypass_event_set =
3317 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3319 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3320 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3322 cmdline_parse_token_string_t cmd_setbypass_event_event =
3323 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3325 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3326 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3327 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3328 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3329 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3331 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3332 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3333 mode_value, "normal#bypass#isolate");
3334 cmdline_parse_token_num_t cmd_setbypass_event_port =
3335 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3338 cmdline_parse_inst_t cmd_set_bypass_event = {
3339 .f = cmd_set_bypass_event_parsed,
3340 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3341 "mode (normal|bypass|isolate) (port_id): "
3342 "Set the NIC bypass event mode for port_id",
3345 (void *)&cmd_setbypass_event_set,
3346 (void *)&cmd_setbypass_event_bypass,
3347 (void *)&cmd_setbypass_event_event,
3348 (void *)&cmd_setbypass_event_event_value,
3349 (void *)&cmd_setbypass_event_mode,
3350 (void *)&cmd_setbypass_event_mode_value,
3351 (void *)&cmd_setbypass_event_port,
3357 /* *** SET NIC BYPASS TIMEOUT *** */
3358 struct cmd_set_bypass_timeout_result {
3359 cmdline_fixed_string_t set;
3360 cmdline_fixed_string_t bypass;
3361 cmdline_fixed_string_t timeout;
3362 cmdline_fixed_string_t value;
3366 cmd_set_bypass_timeout_parsed(void *parsed_result,
3367 __attribute__((unused)) struct cmdline *cl,
3368 __attribute__((unused)) void *data)
3370 struct cmd_set_bypass_timeout_result *res = parsed_result;
3372 if (!strcmp(res->value, "1.5"))
3373 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3374 else if (!strcmp(res->value, "2"))
3375 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3376 else if (!strcmp(res->value, "3"))
3377 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3378 else if (!strcmp(res->value, "4"))
3379 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3380 else if (!strcmp(res->value, "8"))
3381 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3382 else if (!strcmp(res->value, "16"))
3383 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3384 else if (!strcmp(res->value, "32"))
3385 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3387 bypass_timeout = RTE_BYPASS_TMT_OFF;
3390 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3391 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3393 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3394 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3396 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3397 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3398 timeout, "timeout");
3399 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3400 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3401 value, "0#1.5#2#3#4#8#16#32");
3403 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3404 .f = cmd_set_bypass_timeout_parsed,
3405 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3406 "Set the NIC bypass watchdog timeout",
3409 (void *)&cmd_setbypass_timeout_set,
3410 (void *)&cmd_setbypass_timeout_bypass,
3411 (void *)&cmd_setbypass_timeout_timeout,
3412 (void *)&cmd_setbypass_timeout_value,
3417 /* *** SHOW NIC BYPASS MODE *** */
3418 struct cmd_show_bypass_config_result {
3419 cmdline_fixed_string_t show;
3420 cmdline_fixed_string_t bypass;
3421 cmdline_fixed_string_t config;
3426 cmd_show_bypass_config_parsed(void *parsed_result,
3427 __attribute__((unused)) struct cmdline *cl,
3428 __attribute__((unused)) void *data)
3430 struct cmd_show_bypass_config_result *res = parsed_result;
3431 uint32_t event_mode;
3432 uint32_t bypass_mode;
3433 portid_t port_id = res->port_id;
3434 uint32_t timeout = bypass_timeout;
3437 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3438 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3439 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3440 {"UNKNOWN", "normal", "bypass", "isolate"};
3441 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3448 int num_events = (sizeof events) / (sizeof events[0]);
3450 if (!bypass_is_supported(port_id))
3453 /* Display the bypass mode.*/
3454 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3455 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3459 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3460 bypass_mode = RTE_BYPASS_MODE_NONE;
3462 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3465 /* Display the bypass timeout.*/
3466 if (!RTE_BYPASS_TMT_VALID(timeout))
3467 timeout = RTE_BYPASS_TMT_OFF;
3469 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3471 /* Display the bypass events and associated modes. */
3472 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3474 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3475 printf("\tFailed to get bypass mode for event = %s\n",
3478 if (!RTE_BYPASS_MODE_VALID(event_mode))
3479 event_mode = RTE_BYPASS_MODE_NONE;
3481 printf("\tbypass event: %-16s = %s\n", events[i],
3487 cmdline_parse_token_string_t cmd_showbypass_config_show =
3488 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3490 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3491 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3493 cmdline_parse_token_string_t cmd_showbypass_config_config =
3494 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3496 cmdline_parse_token_num_t cmd_showbypass_config_port =
3497 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3500 cmdline_parse_inst_t cmd_show_bypass_config = {
3501 .f = cmd_show_bypass_config_parsed,
3502 .help_str = "show bypass config (port_id): "
3503 "Show the NIC bypass config for port_id",
3506 (void *)&cmd_showbypass_config_show,
3507 (void *)&cmd_showbypass_config_bypass,
3508 (void *)&cmd_showbypass_config_config,
3509 (void *)&cmd_showbypass_config_port,
3515 #ifdef RTE_LIBRTE_PMD_BOND
3516 /* *** SET BONDING MODE *** */
3517 struct cmd_set_bonding_mode_result {
3518 cmdline_fixed_string_t set;
3519 cmdline_fixed_string_t bonding;
3520 cmdline_fixed_string_t mode;
3525 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3526 __attribute__((unused)) struct cmdline *cl,
3527 __attribute__((unused)) void *data)
3529 struct cmd_set_bonding_mode_result *res = parsed_result;
3530 portid_t port_id = res->port_id;
3532 /* Set the bonding mode for the relevant port. */
3533 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3534 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3537 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3538 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3540 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3541 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3542 bonding, "bonding");
3543 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3544 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3546 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3547 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3549 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3550 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3553 cmdline_parse_inst_t cmd_set_bonding_mode = {
3554 .f = cmd_set_bonding_mode_parsed,
3555 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3558 (void *) &cmd_setbonding_mode_set,
3559 (void *) &cmd_setbonding_mode_bonding,
3560 (void *) &cmd_setbonding_mode_mode,
3561 (void *) &cmd_setbonding_mode_value,
3562 (void *) &cmd_setbonding_mode_port,
3567 /* *** SET BALANCE XMIT POLICY *** */
3568 struct cmd_set_bonding_balance_xmit_policy_result {
3569 cmdline_fixed_string_t set;
3570 cmdline_fixed_string_t bonding;
3571 cmdline_fixed_string_t balance_xmit_policy;
3573 cmdline_fixed_string_t policy;
3576 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3577 __attribute__((unused)) struct cmdline *cl,
3578 __attribute__((unused)) void *data)
3580 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3581 portid_t port_id = res->port_id;
3584 if (!strcmp(res->policy, "l2")) {
3585 policy = BALANCE_XMIT_POLICY_LAYER2;
3586 } else if (!strcmp(res->policy, "l23")) {
3587 policy = BALANCE_XMIT_POLICY_LAYER23;
3588 } else if (!strcmp(res->policy, "l34")) {
3589 policy = BALANCE_XMIT_POLICY_LAYER34;
3591 printf("\t Invalid xmit policy selection");
3595 /* Set the bonding mode for the relevant port. */
3596 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3597 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3602 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3603 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3605 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3606 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3607 bonding, "bonding");
3608 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3609 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3610 balance_xmit_policy, "balance_xmit_policy");
3611 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3612 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3614 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3615 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3616 policy, "l2#l23#l34");
3618 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3619 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3620 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3623 (void *)&cmd_setbonding_balance_xmit_policy_set,
3624 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3625 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3626 (void *)&cmd_setbonding_balance_xmit_policy_port,
3627 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3632 /* *** SHOW NIC BONDING CONFIGURATION *** */
3633 struct cmd_show_bonding_config_result {
3634 cmdline_fixed_string_t show;
3635 cmdline_fixed_string_t bonding;
3636 cmdline_fixed_string_t config;
3640 static void cmd_show_bonding_config_parsed(void *parsed_result,
3641 __attribute__((unused)) struct cmdline *cl,
3642 __attribute__((unused)) void *data)
3644 struct cmd_show_bonding_config_result *res = parsed_result;
3646 uint8_t slaves[RTE_MAX_ETHPORTS];
3647 int num_slaves, num_active_slaves;
3650 portid_t port_id = res->port_id;
3652 /* Display the bonding mode.*/
3653 bonding_mode = rte_eth_bond_mode_get(port_id);
3654 if (bonding_mode < 0) {
3655 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3658 printf("\tBonding mode: %d\n", bonding_mode);
3660 if (bonding_mode == BONDING_MODE_BALANCE) {
3661 int balance_xmit_policy;
3663 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3664 if (balance_xmit_policy < 0) {
3665 printf("\tFailed to get balance xmit policy for port = %d\n",
3669 printf("\tBalance Xmit Policy: ");
3671 switch (balance_xmit_policy) {
3672 case BALANCE_XMIT_POLICY_LAYER2:
3673 printf("BALANCE_XMIT_POLICY_LAYER2");
3675 case BALANCE_XMIT_POLICY_LAYER23:
3676 printf("BALANCE_XMIT_POLICY_LAYER23");
3678 case BALANCE_XMIT_POLICY_LAYER34:
3679 printf("BALANCE_XMIT_POLICY_LAYER34");
3686 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3688 if (num_slaves < 0) {
3689 printf("\tFailed to get slave list for port = %d\n", port_id);
3692 if (num_slaves > 0) {
3693 printf("\tSlaves (%d): [", num_slaves);
3694 for (i = 0; i < num_slaves - 1; i++)
3695 printf("%d ", slaves[i]);
3697 printf("%d]\n", slaves[num_slaves - 1]);
3699 printf("\tSlaves: []\n");
3703 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3706 if (num_active_slaves < 0) {
3707 printf("\tFailed to get active slave list for port = %d\n", port_id);
3710 if (num_active_slaves > 0) {
3711 printf("\tActive Slaves (%d): [", num_active_slaves);
3712 for (i = 0; i < num_active_slaves - 1; i++)
3713 printf("%d ", slaves[i]);
3715 printf("%d]\n", slaves[num_active_slaves - 1]);
3718 printf("\tActive Slaves: []\n");
3722 primary_id = rte_eth_bond_primary_get(port_id);
3723 if (primary_id < 0) {
3724 printf("\tFailed to get primary slave for port = %d\n", port_id);
3727 printf("\tPrimary: [%d]\n", primary_id);
3731 cmdline_parse_token_string_t cmd_showbonding_config_show =
3732 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3734 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3735 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3736 bonding, "bonding");
3737 cmdline_parse_token_string_t cmd_showbonding_config_config =
3738 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3740 cmdline_parse_token_num_t cmd_showbonding_config_port =
3741 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3744 cmdline_parse_inst_t cmd_show_bonding_config = {
3745 .f = cmd_show_bonding_config_parsed,
3746 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3749 (void *)&cmd_showbonding_config_show,
3750 (void *)&cmd_showbonding_config_bonding,
3751 (void *)&cmd_showbonding_config_config,
3752 (void *)&cmd_showbonding_config_port,
3757 /* *** SET BONDING PRIMARY *** */
3758 struct cmd_set_bonding_primary_result {
3759 cmdline_fixed_string_t set;
3760 cmdline_fixed_string_t bonding;
3761 cmdline_fixed_string_t primary;
3766 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3767 __attribute__((unused)) struct cmdline *cl,
3768 __attribute__((unused)) void *data)
3770 struct cmd_set_bonding_primary_result *res = parsed_result;
3771 portid_t master_port_id = res->port_id;
3772 portid_t slave_port_id = res->slave_id;
3774 /* Set the primary slave for a bonded device. */
3775 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3776 printf("\t Failed to set primary slave for port = %d.\n",
3783 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3784 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3786 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3787 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3788 bonding, "bonding");
3789 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3790 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3791 primary, "primary");
3792 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3793 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3795 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3796 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3799 cmdline_parse_inst_t cmd_set_bonding_primary = {
3800 .f = cmd_set_bonding_primary_parsed,
3801 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3804 (void *)&cmd_setbonding_primary_set,
3805 (void *)&cmd_setbonding_primary_bonding,
3806 (void *)&cmd_setbonding_primary_primary,
3807 (void *)&cmd_setbonding_primary_slave,
3808 (void *)&cmd_setbonding_primary_port,
3813 /* *** ADD SLAVE *** */
3814 struct cmd_add_bonding_slave_result {
3815 cmdline_fixed_string_t add;
3816 cmdline_fixed_string_t bonding;
3817 cmdline_fixed_string_t slave;
3822 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3823 __attribute__((unused)) struct cmdline *cl,
3824 __attribute__((unused)) void *data)
3826 struct cmd_add_bonding_slave_result *res = parsed_result;
3827 portid_t master_port_id = res->port_id;
3828 portid_t slave_port_id = res->slave_id;
3830 /* Set the primary slave for a bonded device. */
3831 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3832 printf("\t Failed to add slave %d to master port = %d.\n",
3833 slave_port_id, master_port_id);
3839 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3840 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3842 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3843 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3844 bonding, "bonding");
3845 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3846 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3848 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3849 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3851 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3852 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3855 cmdline_parse_inst_t cmd_add_bonding_slave = {
3856 .f = cmd_add_bonding_slave_parsed,
3857 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3860 (void *)&cmd_addbonding_slave_add,
3861 (void *)&cmd_addbonding_slave_bonding,
3862 (void *)&cmd_addbonding_slave_slave,
3863 (void *)&cmd_addbonding_slave_slaveid,
3864 (void *)&cmd_addbonding_slave_port,
3869 /* *** REMOVE SLAVE *** */
3870 struct cmd_remove_bonding_slave_result {
3871 cmdline_fixed_string_t remove;
3872 cmdline_fixed_string_t bonding;
3873 cmdline_fixed_string_t slave;
3878 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3879 __attribute__((unused)) struct cmdline *cl,
3880 __attribute__((unused)) void *data)
3882 struct cmd_remove_bonding_slave_result *res = parsed_result;
3883 portid_t master_port_id = res->port_id;
3884 portid_t slave_port_id = res->slave_id;
3886 /* Set the primary slave for a bonded device. */
3887 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3888 printf("\t Failed to remove slave %d from master port = %d.\n",
3889 slave_port_id, master_port_id);
3895 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3896 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3898 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3899 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3900 bonding, "bonding");
3901 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3902 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3904 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3905 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3907 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3908 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3911 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3912 .f = cmd_remove_bonding_slave_parsed,
3913 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3916 (void *)&cmd_removebonding_slave_remove,
3917 (void *)&cmd_removebonding_slave_bonding,
3918 (void *)&cmd_removebonding_slave_slave,
3919 (void *)&cmd_removebonding_slave_slaveid,
3920 (void *)&cmd_removebonding_slave_port,
3925 /* *** CREATE BONDED DEVICE *** */
3926 struct cmd_create_bonded_device_result {
3927 cmdline_fixed_string_t create;
3928 cmdline_fixed_string_t bonded;
3929 cmdline_fixed_string_t device;
3934 static int bond_dev_num = 0;
3936 static void cmd_create_bonded_device_parsed(void *parsed_result,
3937 __attribute__((unused)) struct cmdline *cl,
3938 __attribute__((unused)) void *data)
3940 struct cmd_create_bonded_device_result *res = parsed_result;
3941 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3944 if (test_done == 0) {
3945 printf("Please stop forwarding first\n");
3949 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3952 /* Create a new bonded device. */
3953 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3955 printf("\t Failed to create bonded device.\n");
3958 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3961 /* Update number of ports */
3962 nb_ports = rte_eth_dev_count();
3963 reconfig(port_id, res->socket);
3964 rte_eth_promiscuous_enable(port_id);
3969 cmdline_parse_token_string_t cmd_createbonded_device_create =
3970 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3972 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3973 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3975 cmdline_parse_token_string_t cmd_createbonded_device_device =
3976 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3978 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3979 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3981 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3982 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3985 cmdline_parse_inst_t cmd_create_bonded_device = {
3986 .f = cmd_create_bonded_device_parsed,
3987 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3990 (void *)&cmd_createbonded_device_create,
3991 (void *)&cmd_createbonded_device_bonded,
3992 (void *)&cmd_createbonded_device_device,
3993 (void *)&cmd_createbonded_device_mode,
3994 (void *)&cmd_createbonded_device_socket,
3999 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4000 struct cmd_set_bond_mac_addr_result {
4001 cmdline_fixed_string_t set;
4002 cmdline_fixed_string_t bonding;
4003 cmdline_fixed_string_t mac_addr;
4005 struct ether_addr address;
4008 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4009 __attribute__((unused)) struct cmdline *cl,
4010 __attribute__((unused)) void *data)
4012 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4015 if (res->port_num >= nb_ports) {
4016 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4020 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4022 /* check the return value and print it if is < 0 */
4024 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4027 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4028 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4029 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4030 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4032 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4033 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4035 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4036 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4037 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4038 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4040 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4041 .f = cmd_set_bond_mac_addr_parsed,
4043 .help_str = "set bonding mac_addr (port_id) (address): ",
4045 (void *)&cmd_set_bond_mac_addr_set,
4046 (void *)&cmd_set_bond_mac_addr_bonding,
4047 (void *)&cmd_set_bond_mac_addr_mac,
4048 (void *)&cmd_set_bond_mac_addr_portnum,
4049 (void *)&cmd_set_bond_mac_addr_addr,
4055 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4056 struct cmd_set_bond_mon_period_result {
4057 cmdline_fixed_string_t set;
4058 cmdline_fixed_string_t bonding;
4059 cmdline_fixed_string_t mon_period;
4064 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4065 __attribute__((unused)) struct cmdline *cl,
4066 __attribute__((unused)) void *data)
4068 struct cmd_set_bond_mon_period_result *res = parsed_result;
4071 if (res->port_num >= nb_ports) {
4072 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4076 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4078 /* check the return value and print it if is < 0 */
4080 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4083 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4084 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4086 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4087 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4088 bonding, "bonding");
4089 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4090 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4091 mon_period, "mon_period");
4092 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4093 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4095 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4096 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4099 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4100 .f = cmd_set_bond_mon_period_parsed,
4102 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4104 (void *)&cmd_set_bond_mon_period_set,
4105 (void *)&cmd_set_bond_mon_period_bonding,
4106 (void *)&cmd_set_bond_mon_period_mon_period,
4107 (void *)&cmd_set_bond_mon_period_portnum,
4108 (void *)&cmd_set_bond_mon_period_period_ms,
4113 #endif /* RTE_LIBRTE_PMD_BOND */
4115 /* *** SET FORWARDING MODE *** */
4116 struct cmd_set_fwd_mode_result {
4117 cmdline_fixed_string_t set;
4118 cmdline_fixed_string_t fwd;
4119 cmdline_fixed_string_t mode;
4122 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4123 __attribute__((unused)) struct cmdline *cl,
4124 __attribute__((unused)) void *data)
4126 struct cmd_set_fwd_mode_result *res = parsed_result;
4128 set_pkt_forwarding_mode(res->mode);
4131 cmdline_parse_token_string_t cmd_setfwd_set =
4132 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4133 cmdline_parse_token_string_t cmd_setfwd_fwd =
4134 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4135 cmdline_parse_token_string_t cmd_setfwd_mode =
4136 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4137 "" /* defined at init */);
4139 cmdline_parse_inst_t cmd_set_fwd_mode = {
4140 .f = cmd_set_fwd_mode_parsed,
4142 .help_str = NULL, /* defined at init */
4144 (void *)&cmd_setfwd_set,
4145 (void *)&cmd_setfwd_fwd,
4146 (void *)&cmd_setfwd_mode,
4151 static void cmd_set_fwd_mode_init(void)
4154 static char token[128];
4155 static char help[256];
4156 cmdline_parse_token_string_t *token_struct;
4158 modes = list_pkt_forwarding_modes();
4159 snprintf(help, sizeof help, "set fwd %s - "
4160 "set packet forwarding mode", modes);
4161 cmd_set_fwd_mode.help_str = help;
4163 /* string token separator is # */
4164 for (c = token; *modes != '\0'; modes++)
4169 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4170 token_struct->string_data.str = token;
4173 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4174 struct cmd_set_burst_tx_retry_result {
4175 cmdline_fixed_string_t set;
4176 cmdline_fixed_string_t burst;
4177 cmdline_fixed_string_t tx;
4178 cmdline_fixed_string_t delay;
4180 cmdline_fixed_string_t retry;
4184 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4185 __attribute__((unused)) struct cmdline *cl,
4186 __attribute__((unused)) void *data)
4188 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4190 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4191 && !strcmp(res->tx, "tx")) {
4192 if (!strcmp(res->delay, "delay"))
4193 burst_tx_delay_time = res->time;
4194 if (!strcmp(res->retry, "retry"))
4195 burst_tx_retry_num = res->retry_num;
4200 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4201 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4202 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4203 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4205 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4206 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4207 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4208 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4209 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4210 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4211 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4212 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4213 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4214 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4216 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4217 .f = cmd_set_burst_tx_retry_parsed,
4218 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4220 (void *)&cmd_set_burst_tx_retry_set,
4221 (void *)&cmd_set_burst_tx_retry_burst,
4222 (void *)&cmd_set_burst_tx_retry_tx,
4223 (void *)&cmd_set_burst_tx_retry_delay,
4224 (void *)&cmd_set_burst_tx_retry_time,
4225 (void *)&cmd_set_burst_tx_retry_retry,
4226 (void *)&cmd_set_burst_tx_retry_retry_num,
4231 /* *** SET PROMISC MODE *** */
4232 struct cmd_set_promisc_mode_result {
4233 cmdline_fixed_string_t set;
4234 cmdline_fixed_string_t promisc;
4235 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4236 uint8_t port_num; /* valid if "allports" argument == 0 */
4237 cmdline_fixed_string_t mode;
4240 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4241 __attribute__((unused)) struct cmdline *cl,
4244 struct cmd_set_promisc_mode_result *res = parsed_result;
4248 if (!strcmp(res->mode, "on"))
4255 for (i = 0; i < nb_ports; i++) {
4257 rte_eth_promiscuous_enable(i);
4259 rte_eth_promiscuous_disable(i);
4264 rte_eth_promiscuous_enable(res->port_num);
4266 rte_eth_promiscuous_disable(res->port_num);
4270 cmdline_parse_token_string_t cmd_setpromisc_set =
4271 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4272 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4273 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4275 cmdline_parse_token_string_t cmd_setpromisc_portall =
4276 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4278 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4279 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4281 cmdline_parse_token_string_t cmd_setpromisc_mode =
4282 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4285 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4286 .f = cmd_set_promisc_mode_parsed,
4288 .help_str = "set promisc all on|off: set promisc mode for all ports",
4290 (void *)&cmd_setpromisc_set,
4291 (void *)&cmd_setpromisc_promisc,
4292 (void *)&cmd_setpromisc_portall,
4293 (void *)&cmd_setpromisc_mode,
4298 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4299 .f = cmd_set_promisc_mode_parsed,
4301 .help_str = "set promisc X on|off: set promisc mode on port X",
4303 (void *)&cmd_setpromisc_set,
4304 (void *)&cmd_setpromisc_promisc,
4305 (void *)&cmd_setpromisc_portnum,
4306 (void *)&cmd_setpromisc_mode,
4311 /* *** SET ALLMULTI MODE *** */
4312 struct cmd_set_allmulti_mode_result {
4313 cmdline_fixed_string_t set;
4314 cmdline_fixed_string_t allmulti;
4315 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4316 uint8_t port_num; /* valid if "allports" argument == 0 */
4317 cmdline_fixed_string_t mode;
4320 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4321 __attribute__((unused)) struct cmdline *cl,
4324 struct cmd_set_allmulti_mode_result *res = parsed_result;
4328 if (!strcmp(res->mode, "on"))
4335 for (i = 0; i < nb_ports; i++) {
4337 rte_eth_allmulticast_enable(i);
4339 rte_eth_allmulticast_disable(i);
4344 rte_eth_allmulticast_enable(res->port_num);
4346 rte_eth_allmulticast_disable(res->port_num);
4350 cmdline_parse_token_string_t cmd_setallmulti_set =
4351 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4352 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4353 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4355 cmdline_parse_token_string_t cmd_setallmulti_portall =
4356 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4358 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4359 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4361 cmdline_parse_token_string_t cmd_setallmulti_mode =
4362 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4365 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4366 .f = cmd_set_allmulti_mode_parsed,
4368 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4370 (void *)&cmd_setallmulti_set,
4371 (void *)&cmd_setallmulti_allmulti,
4372 (void *)&cmd_setallmulti_portall,
4373 (void *)&cmd_setallmulti_mode,
4378 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4379 .f = cmd_set_allmulti_mode_parsed,
4381 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4383 (void *)&cmd_setallmulti_set,
4384 (void *)&cmd_setallmulti_allmulti,
4385 (void *)&cmd_setallmulti_portnum,
4386 (void *)&cmd_setallmulti_mode,
4391 /* *** ADD/REMOVE A PKT FILTER *** */
4392 struct cmd_pkt_filter_result {
4393 cmdline_fixed_string_t pkt_filter;
4395 cmdline_fixed_string_t protocol;
4396 cmdline_fixed_string_t src;
4397 cmdline_ipaddr_t ip_src;
4399 cmdline_fixed_string_t dst;
4400 cmdline_ipaddr_t ip_dst;
4402 cmdline_fixed_string_t flexbytes;
4403 uint16_t flexbytes_value;
4404 cmdline_fixed_string_t vlan;
4406 cmdline_fixed_string_t queue;
4408 cmdline_fixed_string_t soft;
4413 cmd_pkt_filter_parsed(void *parsed_result,
4414 __attribute__((unused)) struct cmdline *cl,
4415 __attribute__((unused)) void *data)
4417 struct rte_fdir_filter fdir_filter;
4418 struct cmd_pkt_filter_result *res = parsed_result;
4420 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4422 if (res->ip_src.family == AF_INET)
4423 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4425 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4426 &(res->ip_src.addr.ipv6),
4427 sizeof(struct in6_addr));
4429 if (res->ip_dst.family == AF_INET)
4430 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4432 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4433 &(res->ip_dst.addr.ipv6),
4434 sizeof(struct in6_addr));
4436 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4437 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4439 if (!strcmp(res->protocol, "udp"))
4440 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4441 else if (!strcmp(res->protocol, "tcp"))
4442 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4443 else if (!strcmp(res->protocol, "sctp"))
4444 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4445 else /* default only IP */
4446 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4448 if (res->ip_dst.family == AF_INET6)
4449 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4451 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4453 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4454 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4456 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4457 fdir_add_signature_filter(res->port_id, res->queue_id,
4459 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4460 fdir_update_signature_filter(res->port_id, res->queue_id,
4462 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4463 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4464 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4465 fdir_add_perfect_filter(res->port_id, res->soft_id,
4467 (uint8_t) (res->queue_id < 0),
4469 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4470 fdir_update_perfect_filter(res->port_id, res->soft_id,
4472 (uint8_t) (res->queue_id < 0),
4474 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4475 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4481 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4482 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4484 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4485 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4486 protocol, "ip#tcp#udp#sctp");
4487 cmdline_parse_token_string_t cmd_pkt_filter_src =
4488 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4490 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4491 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4493 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4494 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4496 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4497 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4499 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4500 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4502 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4503 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4505 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4506 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4507 flexbytes, "flexbytes");
4508 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4509 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4510 flexbytes_value, UINT16);
4511 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4512 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4514 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4515 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4517 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4518 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4520 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4521 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4523 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4524 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4526 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4527 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4531 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4532 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4533 pkt_filter, "add_signature_filter");
4534 cmdline_parse_inst_t cmd_add_signature_filter = {
4535 .f = cmd_pkt_filter_parsed,
4537 .help_str = "add a signature filter",
4539 (void *)&cmd_pkt_filter_add_signature_filter,
4540 (void *)&cmd_pkt_filter_port_id,
4541 (void *)&cmd_pkt_filter_protocol,
4542 (void *)&cmd_pkt_filter_src,
4543 (void *)&cmd_pkt_filter_ip_src,
4544 (void *)&cmd_pkt_filter_port_src,
4545 (void *)&cmd_pkt_filter_dst,
4546 (void *)&cmd_pkt_filter_ip_dst,
4547 (void *)&cmd_pkt_filter_port_dst,
4548 (void *)&cmd_pkt_filter_flexbytes,
4549 (void *)&cmd_pkt_filter_flexbytes_value,
4550 (void *)&cmd_pkt_filter_vlan,
4551 (void *)&cmd_pkt_filter_vlan_id,
4552 (void *)&cmd_pkt_filter_queue,
4553 (void *)&cmd_pkt_filter_queue_id,
4559 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4560 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4561 pkt_filter, "upd_signature_filter");
4562 cmdline_parse_inst_t cmd_upd_signature_filter = {
4563 .f = cmd_pkt_filter_parsed,
4565 .help_str = "update a signature filter",
4567 (void *)&cmd_pkt_filter_upd_signature_filter,
4568 (void *)&cmd_pkt_filter_port_id,
4569 (void *)&cmd_pkt_filter_protocol,
4570 (void *)&cmd_pkt_filter_src,
4571 (void *)&cmd_pkt_filter_ip_src,
4572 (void *)&cmd_pkt_filter_port_src,
4573 (void *)&cmd_pkt_filter_dst,
4574 (void *)&cmd_pkt_filter_ip_dst,
4575 (void *)&cmd_pkt_filter_port_dst,
4576 (void *)&cmd_pkt_filter_flexbytes,
4577 (void *)&cmd_pkt_filter_flexbytes_value,
4578 (void *)&cmd_pkt_filter_vlan,
4579 (void *)&cmd_pkt_filter_vlan_id,
4580 (void *)&cmd_pkt_filter_queue,
4581 (void *)&cmd_pkt_filter_queue_id,
4587 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4588 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4589 pkt_filter, "rm_signature_filter");
4590 cmdline_parse_inst_t cmd_rm_signature_filter = {
4591 .f = cmd_pkt_filter_parsed,
4593 .help_str = "remove a signature filter",
4595 (void *)&cmd_pkt_filter_rm_signature_filter,
4596 (void *)&cmd_pkt_filter_port_id,
4597 (void *)&cmd_pkt_filter_protocol,
4598 (void *)&cmd_pkt_filter_src,
4599 (void *)&cmd_pkt_filter_ip_src,
4600 (void *)&cmd_pkt_filter_port_src,
4601 (void *)&cmd_pkt_filter_dst,
4602 (void *)&cmd_pkt_filter_ip_dst,
4603 (void *)&cmd_pkt_filter_port_dst,
4604 (void *)&cmd_pkt_filter_flexbytes,
4605 (void *)&cmd_pkt_filter_flexbytes_value,
4606 (void *)&cmd_pkt_filter_vlan,
4607 (void *)&cmd_pkt_filter_vlan_id,
4613 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4614 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4615 pkt_filter, "add_perfect_filter");
4616 cmdline_parse_inst_t cmd_add_perfect_filter = {
4617 .f = cmd_pkt_filter_parsed,
4619 .help_str = "add a perfect filter",
4621 (void *)&cmd_pkt_filter_add_perfect_filter,
4622 (void *)&cmd_pkt_filter_port_id,
4623 (void *)&cmd_pkt_filter_protocol,
4624 (void *)&cmd_pkt_filter_src,
4625 (void *)&cmd_pkt_filter_ip_src,
4626 (void *)&cmd_pkt_filter_port_src,
4627 (void *)&cmd_pkt_filter_dst,
4628 (void *)&cmd_pkt_filter_ip_dst,
4629 (void *)&cmd_pkt_filter_port_dst,
4630 (void *)&cmd_pkt_filter_flexbytes,
4631 (void *)&cmd_pkt_filter_flexbytes_value,
4632 (void *)&cmd_pkt_filter_vlan,
4633 (void *)&cmd_pkt_filter_vlan_id,
4634 (void *)&cmd_pkt_filter_queue,
4635 (void *)&cmd_pkt_filter_queue_id,
4636 (void *)&cmd_pkt_filter_soft,
4637 (void *)&cmd_pkt_filter_soft_id,
4643 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4644 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4645 pkt_filter, "upd_perfect_filter");
4646 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4647 .f = cmd_pkt_filter_parsed,
4649 .help_str = "update a perfect filter",
4651 (void *)&cmd_pkt_filter_upd_perfect_filter,
4652 (void *)&cmd_pkt_filter_port_id,
4653 (void *)&cmd_pkt_filter_protocol,
4654 (void *)&cmd_pkt_filter_src,
4655 (void *)&cmd_pkt_filter_ip_src,
4656 (void *)&cmd_pkt_filter_port_src,
4657 (void *)&cmd_pkt_filter_dst,
4658 (void *)&cmd_pkt_filter_ip_dst,
4659 (void *)&cmd_pkt_filter_port_dst,
4660 (void *)&cmd_pkt_filter_flexbytes,
4661 (void *)&cmd_pkt_filter_flexbytes_value,
4662 (void *)&cmd_pkt_filter_vlan,
4663 (void *)&cmd_pkt_filter_vlan_id,
4664 (void *)&cmd_pkt_filter_queue,
4665 (void *)&cmd_pkt_filter_queue_id,
4666 (void *)&cmd_pkt_filter_soft,
4667 (void *)&cmd_pkt_filter_soft_id,
4673 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4674 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4675 pkt_filter, "rm_perfect_filter");
4676 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4677 .f = cmd_pkt_filter_parsed,
4679 .help_str = "remove a perfect filter",
4681 (void *)&cmd_pkt_filter_rm_perfect_filter,
4682 (void *)&cmd_pkt_filter_port_id,
4683 (void *)&cmd_pkt_filter_protocol,
4684 (void *)&cmd_pkt_filter_src,
4685 (void *)&cmd_pkt_filter_ip_src,
4686 (void *)&cmd_pkt_filter_port_src,
4687 (void *)&cmd_pkt_filter_dst,
4688 (void *)&cmd_pkt_filter_ip_dst,
4689 (void *)&cmd_pkt_filter_port_dst,
4690 (void *)&cmd_pkt_filter_flexbytes,
4691 (void *)&cmd_pkt_filter_flexbytes_value,
4692 (void *)&cmd_pkt_filter_vlan,
4693 (void *)&cmd_pkt_filter_vlan_id,
4694 (void *)&cmd_pkt_filter_soft,
4695 (void *)&cmd_pkt_filter_soft_id,
4700 /* *** SETUP MASKS FILTER *** */
4701 struct cmd_pkt_filter_masks_result {
4702 cmdline_fixed_string_t filter_mask;
4704 cmdline_fixed_string_t src_mask;
4705 uint32_t ip_src_mask;
4706 uint16_t ipv6_src_mask;
4707 uint16_t port_src_mask;
4708 cmdline_fixed_string_t dst_mask;
4709 uint32_t ip_dst_mask;
4710 uint16_t ipv6_dst_mask;
4711 uint16_t port_dst_mask;
4712 cmdline_fixed_string_t flexbytes;
4713 uint8_t flexbytes_value;
4714 cmdline_fixed_string_t vlan_id;
4715 uint8_t vlan_id_value;
4716 cmdline_fixed_string_t vlan_prio;
4717 uint8_t vlan_prio_value;
4718 cmdline_fixed_string_t only_ip_flow;
4719 uint8_t only_ip_flow_value;
4720 cmdline_fixed_string_t comp_ipv6_dst;
4721 uint8_t comp_ipv6_dst_value;
4725 cmd_pkt_filter_masks_parsed(void *parsed_result,
4726 __attribute__((unused)) struct cmdline *cl,
4727 __attribute__((unused)) void *data)
4729 struct rte_fdir_masks fdir_masks;
4730 struct cmd_pkt_filter_masks_result *res = parsed_result;
4732 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4734 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4735 fdir_masks.vlan_id = res->vlan_id_value;
4736 fdir_masks.vlan_prio = res->vlan_prio_value;
4737 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4738 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4739 fdir_masks.src_port_mask = res->port_src_mask;
4740 fdir_masks.dst_port_mask = res->port_dst_mask;
4741 fdir_masks.flexbytes = res->flexbytes_value;
4743 fdir_set_masks(res->port_id, &fdir_masks);
4746 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4747 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4748 filter_mask, "set_masks_filter");
4749 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4750 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4752 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4753 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4754 only_ip_flow, "only_ip_flow");
4755 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4756 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4757 only_ip_flow_value, UINT8);
4758 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4759 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4760 src_mask, "src_mask");
4761 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4762 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4763 ip_src_mask, UINT32);
4764 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4765 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4766 port_src_mask, UINT16);
4767 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4768 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4769 dst_mask, "dst_mask");
4770 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4771 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4772 ip_dst_mask, UINT32);
4773 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4774 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4775 port_dst_mask, UINT16);
4776 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4777 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4778 flexbytes, "flexbytes");
4779 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4780 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4781 flexbytes_value, UINT8);
4782 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4783 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4784 vlan_id, "vlan_id");
4785 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4786 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4787 vlan_id_value, UINT8);
4788 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4789 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4790 vlan_prio, "vlan_prio");
4791 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4792 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4793 vlan_prio_value, UINT8);
4795 cmdline_parse_inst_t cmd_set_masks_filter = {
4796 .f = cmd_pkt_filter_masks_parsed,
4798 .help_str = "setup masks filter",
4800 (void *)&cmd_pkt_filter_masks_filter_mask,
4801 (void *)&cmd_pkt_filter_masks_port_id,
4802 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4803 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4804 (void *)&cmd_pkt_filter_masks_src_mask,
4805 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4806 (void *)&cmd_pkt_filter_masks_port_src_mask,
4807 (void *)&cmd_pkt_filter_masks_dst_mask,
4808 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4809 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4810 (void *)&cmd_pkt_filter_masks_flexbytes,
4811 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4812 (void *)&cmd_pkt_filter_masks_vlan_id,
4813 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4814 (void *)&cmd_pkt_filter_masks_vlan_prio,
4815 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4821 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4822 __attribute__((unused)) struct cmdline *cl,
4823 __attribute__((unused)) void *data)
4825 struct rte_fdir_masks fdir_masks;
4826 struct cmd_pkt_filter_masks_result *res = parsed_result;
4828 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4830 fdir_masks.set_ipv6_mask = 1;
4831 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4832 fdir_masks.vlan_id = res->vlan_id_value;
4833 fdir_masks.vlan_prio = res->vlan_prio_value;
4834 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4835 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4836 fdir_masks.src_port_mask = res->port_src_mask;
4837 fdir_masks.dst_port_mask = res->port_dst_mask;
4838 fdir_masks.flexbytes = res->flexbytes_value;
4839 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4841 fdir_set_masks(res->port_id, &fdir_masks);
4844 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4845 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4846 filter_mask, "set_ipv6_masks_filter");
4847 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4848 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4849 ipv6_src_mask, UINT16);
4850 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4851 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4852 ipv6_dst_mask, UINT16);
4854 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4855 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4856 comp_ipv6_dst, "compare_dst");
4857 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4858 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4859 comp_ipv6_dst_value, UINT8);
4861 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4862 .f = cmd_pkt_filter_masks_ipv6_parsed,
4864 .help_str = "setup ipv6 masks filter",
4866 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4867 (void *)&cmd_pkt_filter_masks_port_id,
4868 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4869 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4870 (void *)&cmd_pkt_filter_masks_src_mask,
4871 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4872 (void *)&cmd_pkt_filter_masks_port_src_mask,
4873 (void *)&cmd_pkt_filter_masks_dst_mask,
4874 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4875 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4876 (void *)&cmd_pkt_filter_masks_flexbytes,
4877 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4878 (void *)&cmd_pkt_filter_masks_vlan_id,
4879 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4880 (void *)&cmd_pkt_filter_masks_vlan_prio,
4881 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4882 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4883 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4888 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4889 struct cmd_link_flow_ctrl_set_result {
4890 cmdline_fixed_string_t set;
4891 cmdline_fixed_string_t flow_ctrl;
4892 cmdline_fixed_string_t rx;
4893 cmdline_fixed_string_t rx_lfc_mode;
4894 cmdline_fixed_string_t tx;
4895 cmdline_fixed_string_t tx_lfc_mode;
4896 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4897 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4898 cmdline_fixed_string_t autoneg_str;
4899 cmdline_fixed_string_t autoneg;
4900 cmdline_fixed_string_t hw_str;
4901 uint32_t high_water;
4902 cmdline_fixed_string_t lw_str;
4904 cmdline_fixed_string_t pt_str;
4905 uint16_t pause_time;
4906 cmdline_fixed_string_t xon_str;
4911 cmdline_parse_token_string_t cmd_lfc_set_set =
4912 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4914 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4915 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4916 flow_ctrl, "flow_ctrl");
4917 cmdline_parse_token_string_t cmd_lfc_set_rx =
4918 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4920 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4921 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4922 rx_lfc_mode, "on#off");
4923 cmdline_parse_token_string_t cmd_lfc_set_tx =
4924 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4926 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4927 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4928 tx_lfc_mode, "on#off");
4929 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4930 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4931 hw_str, "high_water");
4932 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4933 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4934 high_water, UINT32);
4935 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4936 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4937 lw_str, "low_water");
4938 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4939 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4941 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4942 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4943 pt_str, "pause_time");
4944 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4945 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4946 pause_time, UINT16);
4947 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4948 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4949 xon_str, "send_xon");
4950 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4951 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4953 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4954 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4955 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4956 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4957 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4958 mac_ctrl_frame_fwd_mode, "on#off");
4959 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4960 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4961 autoneg_str, "autoneg");
4962 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4963 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4965 cmdline_parse_token_num_t cmd_lfc_set_portid =
4966 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4969 /* forward declaration */
4971 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4974 cmdline_parse_inst_t cmd_link_flow_control_set = {
4975 .f = cmd_link_flow_ctrl_set_parsed,
4977 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4978 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4979 autoneg on|off port_id",
4981 (void *)&cmd_lfc_set_set,
4982 (void *)&cmd_lfc_set_flow_ctrl,
4983 (void *)&cmd_lfc_set_rx,
4984 (void *)&cmd_lfc_set_rx_mode,
4985 (void *)&cmd_lfc_set_tx,
4986 (void *)&cmd_lfc_set_tx_mode,
4987 (void *)&cmd_lfc_set_high_water,
4988 (void *)&cmd_lfc_set_low_water,
4989 (void *)&cmd_lfc_set_pause_time,
4990 (void *)&cmd_lfc_set_send_xon,
4991 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4992 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4993 (void *)&cmd_lfc_set_autoneg_str,
4994 (void *)&cmd_lfc_set_autoneg,
4995 (void *)&cmd_lfc_set_portid,
5000 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5001 .f = cmd_link_flow_ctrl_set_parsed,
5002 .data = (void *)&cmd_link_flow_control_set_rx,
5003 .help_str = "Change rx flow control parameter: set flow_ctrl "
5004 "rx on|off port_id",
5006 (void *)&cmd_lfc_set_set,
5007 (void *)&cmd_lfc_set_flow_ctrl,
5008 (void *)&cmd_lfc_set_rx,
5009 (void *)&cmd_lfc_set_rx_mode,
5010 (void *)&cmd_lfc_set_portid,
5015 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5016 .f = cmd_link_flow_ctrl_set_parsed,
5017 .data = (void *)&cmd_link_flow_control_set_tx,
5018 .help_str = "Change tx flow control parameter: set flow_ctrl "
5019 "tx on|off port_id",
5021 (void *)&cmd_lfc_set_set,
5022 (void *)&cmd_lfc_set_flow_ctrl,
5023 (void *)&cmd_lfc_set_tx,
5024 (void *)&cmd_lfc_set_tx_mode,
5025 (void *)&cmd_lfc_set_portid,
5030 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5031 .f = cmd_link_flow_ctrl_set_parsed,
5032 .data = (void *)&cmd_link_flow_control_set_hw,
5033 .help_str = "Change high water flow control parameter: set flow_ctrl "
5034 "high_water value port_id",
5036 (void *)&cmd_lfc_set_set,
5037 (void *)&cmd_lfc_set_flow_ctrl,
5038 (void *)&cmd_lfc_set_high_water_str,
5039 (void *)&cmd_lfc_set_high_water,
5040 (void *)&cmd_lfc_set_portid,
5045 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5046 .f = cmd_link_flow_ctrl_set_parsed,
5047 .data = (void *)&cmd_link_flow_control_set_lw,
5048 .help_str = "Change low water flow control parameter: set flow_ctrl "
5049 "low_water value port_id",
5051 (void *)&cmd_lfc_set_set,
5052 (void *)&cmd_lfc_set_flow_ctrl,
5053 (void *)&cmd_lfc_set_low_water_str,
5054 (void *)&cmd_lfc_set_low_water,
5055 (void *)&cmd_lfc_set_portid,
5060 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5061 .f = cmd_link_flow_ctrl_set_parsed,
5062 .data = (void *)&cmd_link_flow_control_set_pt,
5063 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5064 "pause_time value port_id",
5066 (void *)&cmd_lfc_set_set,
5067 (void *)&cmd_lfc_set_flow_ctrl,
5068 (void *)&cmd_lfc_set_pause_time_str,
5069 (void *)&cmd_lfc_set_pause_time,
5070 (void *)&cmd_lfc_set_portid,
5075 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5076 .f = cmd_link_flow_ctrl_set_parsed,
5077 .data = (void *)&cmd_link_flow_control_set_xon,
5078 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5079 "send_xon value port_id",
5081 (void *)&cmd_lfc_set_set,
5082 (void *)&cmd_lfc_set_flow_ctrl,
5083 (void *)&cmd_lfc_set_send_xon_str,
5084 (void *)&cmd_lfc_set_send_xon,
5085 (void *)&cmd_lfc_set_portid,
5090 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5091 .f = cmd_link_flow_ctrl_set_parsed,
5092 .data = (void *)&cmd_link_flow_control_set_macfwd,
5093 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5094 "mac_ctrl_frame_fwd on|off port_id",
5096 (void *)&cmd_lfc_set_set,
5097 (void *)&cmd_lfc_set_flow_ctrl,
5098 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5099 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5100 (void *)&cmd_lfc_set_portid,
5105 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5106 .f = cmd_link_flow_ctrl_set_parsed,
5107 .data = (void *)&cmd_link_flow_control_set_autoneg,
5108 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5109 "autoneg on|off port_id",
5111 (void *)&cmd_lfc_set_set,
5112 (void *)&cmd_lfc_set_flow_ctrl,
5113 (void *)&cmd_lfc_set_autoneg_str,
5114 (void *)&cmd_lfc_set_autoneg,
5115 (void *)&cmd_lfc_set_portid,
5121 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5122 __attribute__((unused)) struct cmdline *cl,
5125 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5126 cmdline_parse_inst_t *cmd = data;
5127 struct rte_eth_fc_conf fc_conf;
5128 int rx_fc_en, tx_fc_en;
5132 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5133 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5134 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5135 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5137 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5138 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5141 /* Partial command line, retrieve current configuration */
5143 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5145 printf("cannot get current flow ctrl parameters, return"
5146 "code = %d\n", ret);
5150 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5151 (fc_conf.mode == RTE_FC_FULL))
5153 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5154 (fc_conf.mode == RTE_FC_FULL))
5158 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5159 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5161 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5162 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5164 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5166 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5167 fc_conf.high_water = res->high_water;
5169 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5170 fc_conf.low_water = res->low_water;
5172 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5173 fc_conf.pause_time = res->pause_time;
5175 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5176 fc_conf.send_xon = res->send_xon;
5178 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5179 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5180 fc_conf.mac_ctrl_frame_fwd = 1;
5182 fc_conf.mac_ctrl_frame_fwd = 0;
5185 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5186 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5188 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5190 printf("bad flow contrl parameter, return code = %d \n", ret);
5193 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5194 struct cmd_priority_flow_ctrl_set_result {
5195 cmdline_fixed_string_t set;
5196 cmdline_fixed_string_t pfc_ctrl;
5197 cmdline_fixed_string_t rx;
5198 cmdline_fixed_string_t rx_pfc_mode;
5199 cmdline_fixed_string_t tx;
5200 cmdline_fixed_string_t tx_pfc_mode;
5201 uint32_t high_water;
5203 uint16_t pause_time;
5209 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5210 __attribute__((unused)) struct cmdline *cl,
5211 __attribute__((unused)) void *data)
5213 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5214 struct rte_eth_pfc_conf pfc_conf;
5215 int rx_fc_enable, tx_fc_enable;
5219 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5220 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5221 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5222 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5224 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5225 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5228 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5229 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5230 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5231 pfc_conf.fc.high_water = res->high_water;
5232 pfc_conf.fc.low_water = res->low_water;
5233 pfc_conf.fc.pause_time = res->pause_time;
5234 pfc_conf.priority = res->priority;
5236 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5238 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5241 cmdline_parse_token_string_t cmd_pfc_set_set =
5242 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5244 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5245 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5246 pfc_ctrl, "pfc_ctrl");
5247 cmdline_parse_token_string_t cmd_pfc_set_rx =
5248 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5250 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5251 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5252 rx_pfc_mode, "on#off");
5253 cmdline_parse_token_string_t cmd_pfc_set_tx =
5254 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5256 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5257 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5258 tx_pfc_mode, "on#off");
5259 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5260 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5261 high_water, UINT32);
5262 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5263 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5265 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5266 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5267 pause_time, UINT16);
5268 cmdline_parse_token_num_t cmd_pfc_set_priority =
5269 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5271 cmdline_parse_token_num_t cmd_pfc_set_portid =
5272 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5275 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5276 .f = cmd_priority_flow_ctrl_set_parsed,
5278 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5279 tx on|off high_water low_water pause_time priority port_id",
5281 (void *)&cmd_pfc_set_set,
5282 (void *)&cmd_pfc_set_flow_ctrl,
5283 (void *)&cmd_pfc_set_rx,
5284 (void *)&cmd_pfc_set_rx_mode,
5285 (void *)&cmd_pfc_set_tx,
5286 (void *)&cmd_pfc_set_tx_mode,
5287 (void *)&cmd_pfc_set_high_water,
5288 (void *)&cmd_pfc_set_low_water,
5289 (void *)&cmd_pfc_set_pause_time,
5290 (void *)&cmd_pfc_set_priority,
5291 (void *)&cmd_pfc_set_portid,
5296 /* *** RESET CONFIGURATION *** */
5297 struct cmd_reset_result {
5298 cmdline_fixed_string_t reset;
5299 cmdline_fixed_string_t def;
5302 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5304 __attribute__((unused)) void *data)
5306 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5307 set_def_fwd_config();
5310 cmdline_parse_token_string_t cmd_reset_set =
5311 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5312 cmdline_parse_token_string_t cmd_reset_def =
5313 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5316 cmdline_parse_inst_t cmd_reset = {
5317 .f = cmd_reset_parsed,
5319 .help_str = "set default: reset default forwarding configuration",
5321 (void *)&cmd_reset_set,
5322 (void *)&cmd_reset_def,
5327 /* *** START FORWARDING *** */
5328 struct cmd_start_result {
5329 cmdline_fixed_string_t start;
5332 cmdline_parse_token_string_t cmd_start_start =
5333 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5335 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5336 __attribute__((unused)) struct cmdline *cl,
5337 __attribute__((unused)) void *data)
5339 start_packet_forwarding(0);
5342 cmdline_parse_inst_t cmd_start = {
5343 .f = cmd_start_parsed,
5345 .help_str = "start packet forwarding",
5347 (void *)&cmd_start_start,
5352 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5353 struct cmd_start_tx_first_result {
5354 cmdline_fixed_string_t start;
5355 cmdline_fixed_string_t tx_first;
5359 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5360 __attribute__((unused)) struct cmdline *cl,
5361 __attribute__((unused)) void *data)
5363 start_packet_forwarding(1);
5366 cmdline_parse_token_string_t cmd_start_tx_first_start =
5367 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5369 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5370 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5371 tx_first, "tx_first");
5373 cmdline_parse_inst_t cmd_start_tx_first = {
5374 .f = cmd_start_tx_first_parsed,
5376 .help_str = "start packet forwarding, after sending 1 burst of packets",
5378 (void *)&cmd_start_tx_first_start,
5379 (void *)&cmd_start_tx_first_tx_first,
5384 /* *** SET LINK UP *** */
5385 struct cmd_set_link_up_result {
5386 cmdline_fixed_string_t set;
5387 cmdline_fixed_string_t link_up;
5388 cmdline_fixed_string_t port;
5392 cmdline_parse_token_string_t cmd_set_link_up_set =
5393 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5394 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5395 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5397 cmdline_parse_token_string_t cmd_set_link_up_port =
5398 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5399 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5400 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5402 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5403 __attribute__((unused)) struct cmdline *cl,
5404 __attribute__((unused)) void *data)
5406 struct cmd_set_link_up_result *res = parsed_result;
5407 dev_set_link_up(res->port_id);
5410 cmdline_parse_inst_t cmd_set_link_up = {
5411 .f = cmd_set_link_up_parsed,
5413 .help_str = "set link-up port (port id)",
5415 (void *)&cmd_set_link_up_set,
5416 (void *)&cmd_set_link_up_link_up,
5417 (void *)&cmd_set_link_up_port,
5418 (void *)&cmd_set_link_up_port_id,
5423 /* *** SET LINK DOWN *** */
5424 struct cmd_set_link_down_result {
5425 cmdline_fixed_string_t set;
5426 cmdline_fixed_string_t link_down;
5427 cmdline_fixed_string_t port;
5431 cmdline_parse_token_string_t cmd_set_link_down_set =
5432 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5433 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5434 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5436 cmdline_parse_token_string_t cmd_set_link_down_port =
5437 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5438 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5439 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5441 static void cmd_set_link_down_parsed(
5442 __attribute__((unused)) void *parsed_result,
5443 __attribute__((unused)) struct cmdline *cl,
5444 __attribute__((unused)) void *data)
5446 struct cmd_set_link_down_result *res = parsed_result;
5447 dev_set_link_down(res->port_id);
5450 cmdline_parse_inst_t cmd_set_link_down = {
5451 .f = cmd_set_link_down_parsed,
5453 .help_str = "set link-down port (port id)",
5455 (void *)&cmd_set_link_down_set,
5456 (void *)&cmd_set_link_down_link_down,
5457 (void *)&cmd_set_link_down_port,
5458 (void *)&cmd_set_link_down_port_id,
5463 /* *** SHOW CFG *** */
5464 struct cmd_showcfg_result {
5465 cmdline_fixed_string_t show;
5466 cmdline_fixed_string_t cfg;
5467 cmdline_fixed_string_t what;
5470 static void cmd_showcfg_parsed(void *parsed_result,
5471 __attribute__((unused)) struct cmdline *cl,
5472 __attribute__((unused)) void *data)
5474 struct cmd_showcfg_result *res = parsed_result;
5475 if (!strcmp(res->what, "rxtx"))
5476 rxtx_config_display();
5477 else if (!strcmp(res->what, "cores"))
5478 fwd_lcores_config_display();
5479 else if (!strcmp(res->what, "fwd"))
5480 fwd_config_display();
5483 cmdline_parse_token_string_t cmd_showcfg_show =
5484 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5485 cmdline_parse_token_string_t cmd_showcfg_port =
5486 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5487 cmdline_parse_token_string_t cmd_showcfg_what =
5488 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5491 cmdline_parse_inst_t cmd_showcfg = {
5492 .f = cmd_showcfg_parsed,
5494 .help_str = "show config rxtx|cores|fwd",
5496 (void *)&cmd_showcfg_show,
5497 (void *)&cmd_showcfg_port,
5498 (void *)&cmd_showcfg_what,
5503 /* *** SHOW ALL PORT INFO *** */
5504 struct cmd_showportall_result {
5505 cmdline_fixed_string_t show;
5506 cmdline_fixed_string_t port;
5507 cmdline_fixed_string_t what;
5508 cmdline_fixed_string_t all;
5511 static void cmd_showportall_parsed(void *parsed_result,
5512 __attribute__((unused)) struct cmdline *cl,
5513 __attribute__((unused)) void *data)
5517 struct cmd_showportall_result *res = parsed_result;
5518 if (!strcmp(res->show, "clear")) {
5519 if (!strcmp(res->what, "stats"))
5520 for (i = 0; i < nb_ports; i++)
5522 else if (!strcmp(res->what, "xstats"))
5523 for (i = 0; i < nb_ports; i++)
5524 nic_xstats_clear(i);
5525 } else if (!strcmp(res->what, "info"))
5526 for (i = 0; i < nb_ports; i++)
5527 port_infos_display(i);
5528 else if (!strcmp(res->what, "stats"))
5529 for (i = 0; i < nb_ports; i++)
5530 nic_stats_display(i);
5531 else if (!strcmp(res->what, "xstats"))
5532 for (i = 0; i < nb_ports; i++)
5533 nic_xstats_display(i);
5534 else if (!strcmp(res->what, "fdir"))
5535 for (i = 0; i < nb_ports; i++)
5537 else if (!strcmp(res->what, "stat_qmap"))
5538 for (i = 0; i < nb_ports; i++)
5539 nic_stats_mapping_display(i);
5542 cmdline_parse_token_string_t cmd_showportall_show =
5543 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5545 cmdline_parse_token_string_t cmd_showportall_port =
5546 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5547 cmdline_parse_token_string_t cmd_showportall_what =
5548 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5549 "info#stats#xstats#fdir#stat_qmap");
5550 cmdline_parse_token_string_t cmd_showportall_all =
5551 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5552 cmdline_parse_inst_t cmd_showportall = {
5553 .f = cmd_showportall_parsed,
5555 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5557 (void *)&cmd_showportall_show,
5558 (void *)&cmd_showportall_port,
5559 (void *)&cmd_showportall_what,
5560 (void *)&cmd_showportall_all,
5565 /* *** SHOW PORT INFO *** */
5566 struct cmd_showport_result {
5567 cmdline_fixed_string_t show;
5568 cmdline_fixed_string_t port;
5569 cmdline_fixed_string_t what;
5573 static void cmd_showport_parsed(void *parsed_result,
5574 __attribute__((unused)) struct cmdline *cl,
5575 __attribute__((unused)) void *data)
5577 struct cmd_showport_result *res = parsed_result;
5578 if (!strcmp(res->show, "clear")) {
5579 if (!strcmp(res->what, "stats"))
5580 nic_stats_clear(res->portnum);
5581 else if (!strcmp(res->what, "xstats"))
5582 nic_xstats_clear(res->portnum);
5583 } else if (!strcmp(res->what, "info"))
5584 port_infos_display(res->portnum);
5585 else if (!strcmp(res->what, "stats"))
5586 nic_stats_display(res->portnum);
5587 else if (!strcmp(res->what, "xstats"))
5588 nic_xstats_display(res->portnum);
5589 else if (!strcmp(res->what, "fdir"))
5590 fdir_get_infos(res->portnum);
5591 else if (!strcmp(res->what, "stat_qmap"))
5592 nic_stats_mapping_display(res->portnum);
5595 cmdline_parse_token_string_t cmd_showport_show =
5596 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5598 cmdline_parse_token_string_t cmd_showport_port =
5599 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5600 cmdline_parse_token_string_t cmd_showport_what =
5601 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5602 "info#stats#xstats#fdir#stat_qmap");
5603 cmdline_parse_token_num_t cmd_showport_portnum =
5604 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5606 cmdline_parse_inst_t cmd_showport = {
5607 .f = cmd_showport_parsed,
5609 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5611 (void *)&cmd_showport_show,
5612 (void *)&cmd_showport_port,
5613 (void *)&cmd_showport_what,
5614 (void *)&cmd_showport_portnum,
5619 /* *** READ PORT REGISTER *** */
5620 struct cmd_read_reg_result {
5621 cmdline_fixed_string_t read;
5622 cmdline_fixed_string_t reg;
5628 cmd_read_reg_parsed(void *parsed_result,
5629 __attribute__((unused)) struct cmdline *cl,
5630 __attribute__((unused)) void *data)
5632 struct cmd_read_reg_result *res = parsed_result;
5633 port_reg_display(res->port_id, res->reg_off);
5636 cmdline_parse_token_string_t cmd_read_reg_read =
5637 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5638 cmdline_parse_token_string_t cmd_read_reg_reg =
5639 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5640 cmdline_parse_token_num_t cmd_read_reg_port_id =
5641 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5642 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5643 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5645 cmdline_parse_inst_t cmd_read_reg = {
5646 .f = cmd_read_reg_parsed,
5648 .help_str = "read reg port_id reg_off",
5650 (void *)&cmd_read_reg_read,
5651 (void *)&cmd_read_reg_reg,
5652 (void *)&cmd_read_reg_port_id,
5653 (void *)&cmd_read_reg_reg_off,
5658 /* *** READ PORT REGISTER BIT FIELD *** */
5659 struct cmd_read_reg_bit_field_result {
5660 cmdline_fixed_string_t read;
5661 cmdline_fixed_string_t regfield;
5669 cmd_read_reg_bit_field_parsed(void *parsed_result,
5670 __attribute__((unused)) struct cmdline *cl,
5671 __attribute__((unused)) void *data)
5673 struct cmd_read_reg_bit_field_result *res = parsed_result;
5674 port_reg_bit_field_display(res->port_id, res->reg_off,
5675 res->bit1_pos, res->bit2_pos);
5678 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5679 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5681 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5682 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5683 regfield, "regfield");
5684 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5685 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5687 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5688 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5690 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5691 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5693 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5694 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5697 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5698 .f = cmd_read_reg_bit_field_parsed,
5700 .help_str = "read regfield port_id reg_off bit_x bit_y "
5701 "(read register bit field between bit_x and bit_y included)",
5703 (void *)&cmd_read_reg_bit_field_read,
5704 (void *)&cmd_read_reg_bit_field_regfield,
5705 (void *)&cmd_read_reg_bit_field_port_id,
5706 (void *)&cmd_read_reg_bit_field_reg_off,
5707 (void *)&cmd_read_reg_bit_field_bit1_pos,
5708 (void *)&cmd_read_reg_bit_field_bit2_pos,
5713 /* *** READ PORT REGISTER BIT *** */
5714 struct cmd_read_reg_bit_result {
5715 cmdline_fixed_string_t read;
5716 cmdline_fixed_string_t regbit;
5723 cmd_read_reg_bit_parsed(void *parsed_result,
5724 __attribute__((unused)) struct cmdline *cl,
5725 __attribute__((unused)) void *data)
5727 struct cmd_read_reg_bit_result *res = parsed_result;
5728 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5731 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5732 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5733 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5734 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5736 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5737 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5738 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5739 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5740 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5741 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5743 cmdline_parse_inst_t cmd_read_reg_bit = {
5744 .f = cmd_read_reg_bit_parsed,
5746 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5748 (void *)&cmd_read_reg_bit_read,
5749 (void *)&cmd_read_reg_bit_regbit,
5750 (void *)&cmd_read_reg_bit_port_id,
5751 (void *)&cmd_read_reg_bit_reg_off,
5752 (void *)&cmd_read_reg_bit_bit_pos,
5757 /* *** WRITE PORT REGISTER *** */
5758 struct cmd_write_reg_result {
5759 cmdline_fixed_string_t write;
5760 cmdline_fixed_string_t reg;
5767 cmd_write_reg_parsed(void *parsed_result,
5768 __attribute__((unused)) struct cmdline *cl,
5769 __attribute__((unused)) void *data)
5771 struct cmd_write_reg_result *res = parsed_result;
5772 port_reg_set(res->port_id, res->reg_off, res->value);
5775 cmdline_parse_token_string_t cmd_write_reg_write =
5776 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5777 cmdline_parse_token_string_t cmd_write_reg_reg =
5778 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5779 cmdline_parse_token_num_t cmd_write_reg_port_id =
5780 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5781 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5782 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5783 cmdline_parse_token_num_t cmd_write_reg_value =
5784 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5786 cmdline_parse_inst_t cmd_write_reg = {
5787 .f = cmd_write_reg_parsed,
5789 .help_str = "write reg port_id reg_off reg_value",
5791 (void *)&cmd_write_reg_write,
5792 (void *)&cmd_write_reg_reg,
5793 (void *)&cmd_write_reg_port_id,
5794 (void *)&cmd_write_reg_reg_off,
5795 (void *)&cmd_write_reg_value,
5800 /* *** WRITE PORT REGISTER BIT FIELD *** */
5801 struct cmd_write_reg_bit_field_result {
5802 cmdline_fixed_string_t write;
5803 cmdline_fixed_string_t regfield;
5812 cmd_write_reg_bit_field_parsed(void *parsed_result,
5813 __attribute__((unused)) struct cmdline *cl,
5814 __attribute__((unused)) void *data)
5816 struct cmd_write_reg_bit_field_result *res = parsed_result;
5817 port_reg_bit_field_set(res->port_id, res->reg_off,
5818 res->bit1_pos, res->bit2_pos, res->value);
5821 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5822 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5824 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5825 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5826 regfield, "regfield");
5827 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5828 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5830 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5831 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5833 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5834 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5836 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5837 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5839 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5840 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5843 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5844 .f = cmd_write_reg_bit_field_parsed,
5846 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5847 "(set register bit field between bit_x and bit_y included)",
5849 (void *)&cmd_write_reg_bit_field_write,
5850 (void *)&cmd_write_reg_bit_field_regfield,
5851 (void *)&cmd_write_reg_bit_field_port_id,
5852 (void *)&cmd_write_reg_bit_field_reg_off,
5853 (void *)&cmd_write_reg_bit_field_bit1_pos,
5854 (void *)&cmd_write_reg_bit_field_bit2_pos,
5855 (void *)&cmd_write_reg_bit_field_value,
5860 /* *** WRITE PORT REGISTER BIT *** */
5861 struct cmd_write_reg_bit_result {
5862 cmdline_fixed_string_t write;
5863 cmdline_fixed_string_t regbit;
5871 cmd_write_reg_bit_parsed(void *parsed_result,
5872 __attribute__((unused)) struct cmdline *cl,
5873 __attribute__((unused)) void *data)
5875 struct cmd_write_reg_bit_result *res = parsed_result;
5876 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5879 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5880 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5882 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5883 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5885 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5886 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5887 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5888 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5889 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5890 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5891 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5892 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5894 cmdline_parse_inst_t cmd_write_reg_bit = {
5895 .f = cmd_write_reg_bit_parsed,
5897 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5899 (void *)&cmd_write_reg_bit_write,
5900 (void *)&cmd_write_reg_bit_regbit,
5901 (void *)&cmd_write_reg_bit_port_id,
5902 (void *)&cmd_write_reg_bit_reg_off,
5903 (void *)&cmd_write_reg_bit_bit_pos,
5904 (void *)&cmd_write_reg_bit_value,
5909 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5910 struct cmd_read_rxd_txd_result {
5911 cmdline_fixed_string_t read;
5912 cmdline_fixed_string_t rxd_txd;
5919 cmd_read_rxd_txd_parsed(void *parsed_result,
5920 __attribute__((unused)) struct cmdline *cl,
5921 __attribute__((unused)) void *data)
5923 struct cmd_read_rxd_txd_result *res = parsed_result;
5925 if (!strcmp(res->rxd_txd, "rxd"))
5926 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5927 else if (!strcmp(res->rxd_txd, "txd"))
5928 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5931 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5932 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5933 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5934 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5936 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5937 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5938 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5939 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5940 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5941 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5943 cmdline_parse_inst_t cmd_read_rxd_txd = {
5944 .f = cmd_read_rxd_txd_parsed,
5946 .help_str = "read rxd|txd port_id queue_id rxd_id",
5948 (void *)&cmd_read_rxd_txd_read,
5949 (void *)&cmd_read_rxd_txd_rxd_txd,
5950 (void *)&cmd_read_rxd_txd_port_id,
5951 (void *)&cmd_read_rxd_txd_queue_id,
5952 (void *)&cmd_read_rxd_txd_desc_id,
5958 struct cmd_quit_result {
5959 cmdline_fixed_string_t quit;
5962 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5964 __attribute__((unused)) void *data)
5970 cmdline_parse_token_string_t cmd_quit_quit =
5971 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5973 cmdline_parse_inst_t cmd_quit = {
5974 .f = cmd_quit_parsed,
5976 .help_str = "exit application",
5978 (void *)&cmd_quit_quit,
5983 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5984 struct cmd_mac_addr_result {
5985 cmdline_fixed_string_t mac_addr_cmd;
5986 cmdline_fixed_string_t what;
5988 struct ether_addr address;
5991 static void cmd_mac_addr_parsed(void *parsed_result,
5992 __attribute__((unused)) struct cmdline *cl,
5993 __attribute__((unused)) void *data)
5995 struct cmd_mac_addr_result *res = parsed_result;
5998 if (strcmp(res->what, "add") == 0)
5999 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6001 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6003 /* check the return value and print it if is < 0 */
6005 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6009 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6010 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6012 cmdline_parse_token_string_t cmd_mac_addr_what =
6013 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6015 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6016 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6017 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6018 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6020 cmdline_parse_inst_t cmd_mac_addr = {
6021 .f = cmd_mac_addr_parsed,
6023 .help_str = "mac_addr add|remove X <address>: "
6024 "add/remove MAC address on port X",
6026 (void *)&cmd_mac_addr_cmd,
6027 (void *)&cmd_mac_addr_what,
6028 (void *)&cmd_mac_addr_portnum,
6029 (void *)&cmd_mac_addr_addr,
6035 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6036 struct cmd_set_qmap_result {
6037 cmdline_fixed_string_t set;
6038 cmdline_fixed_string_t qmap;
6039 cmdline_fixed_string_t what;
6046 cmd_set_qmap_parsed(void *parsed_result,
6047 __attribute__((unused)) struct cmdline *cl,
6048 __attribute__((unused)) void *data)
6050 struct cmd_set_qmap_result *res = parsed_result;
6051 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6053 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6056 cmdline_parse_token_string_t cmd_setqmap_set =
6057 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6059 cmdline_parse_token_string_t cmd_setqmap_qmap =
6060 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6062 cmdline_parse_token_string_t cmd_setqmap_what =
6063 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6065 cmdline_parse_token_num_t cmd_setqmap_portid =
6066 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6068 cmdline_parse_token_num_t cmd_setqmap_queueid =
6069 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6071 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6072 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6075 cmdline_parse_inst_t cmd_set_qmap = {
6076 .f = cmd_set_qmap_parsed,
6078 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6080 (void *)&cmd_setqmap_set,
6081 (void *)&cmd_setqmap_qmap,
6082 (void *)&cmd_setqmap_what,
6083 (void *)&cmd_setqmap_portid,
6084 (void *)&cmd_setqmap_queueid,
6085 (void *)&cmd_setqmap_mapvalue,
6090 /* *** CONFIGURE UNICAST HASH TABLE *** */
6091 struct cmd_set_uc_hash_table {
6092 cmdline_fixed_string_t set;
6093 cmdline_fixed_string_t port;
6095 cmdline_fixed_string_t what;
6096 struct ether_addr address;
6097 cmdline_fixed_string_t mode;
6101 cmd_set_uc_hash_parsed(void *parsed_result,
6102 __attribute__((unused)) struct cmdline *cl,
6103 __attribute__((unused)) void *data)
6106 struct cmd_set_uc_hash_table *res = parsed_result;
6108 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6110 if (strcmp(res->what, "uta") == 0)
6111 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6112 &res->address,(uint8_t)is_on);
6114 printf("bad unicast hash table parameter, return code = %d \n", ret);
6118 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6119 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6121 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6122 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6124 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6125 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6127 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6128 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6130 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6131 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6133 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6134 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6137 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6138 .f = cmd_set_uc_hash_parsed,
6140 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6142 (void *)&cmd_set_uc_hash_set,
6143 (void *)&cmd_set_uc_hash_port,
6144 (void *)&cmd_set_uc_hash_portid,
6145 (void *)&cmd_set_uc_hash_what,
6146 (void *)&cmd_set_uc_hash_mac,
6147 (void *)&cmd_set_uc_hash_mode,
6152 struct cmd_set_uc_all_hash_table {
6153 cmdline_fixed_string_t set;
6154 cmdline_fixed_string_t port;
6156 cmdline_fixed_string_t what;
6157 cmdline_fixed_string_t value;
6158 cmdline_fixed_string_t mode;
6162 cmd_set_uc_all_hash_parsed(void *parsed_result,
6163 __attribute__((unused)) struct cmdline *cl,
6164 __attribute__((unused)) void *data)
6167 struct cmd_set_uc_all_hash_table *res = parsed_result;
6169 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6171 if ((strcmp(res->what, "uta") == 0) &&
6172 (strcmp(res->value, "all") == 0))
6173 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6175 printf("bad unicast hash table parameter,"
6176 "return code = %d \n", ret);
6179 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6180 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6182 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6183 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6185 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6186 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6188 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6189 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6191 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6192 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6194 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6195 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6198 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6199 .f = cmd_set_uc_all_hash_parsed,
6201 .help_str = "set port X uta all on|off (X = port number)",
6203 (void *)&cmd_set_uc_all_hash_set,
6204 (void *)&cmd_set_uc_all_hash_port,
6205 (void *)&cmd_set_uc_all_hash_portid,
6206 (void *)&cmd_set_uc_all_hash_what,
6207 (void *)&cmd_set_uc_all_hash_value,
6208 (void *)&cmd_set_uc_all_hash_mode,
6213 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6214 struct cmd_set_vf_macvlan_filter {
6215 cmdline_fixed_string_t set;
6216 cmdline_fixed_string_t port;
6218 cmdline_fixed_string_t vf;
6220 struct ether_addr address;
6221 cmdline_fixed_string_t filter_type;
6222 cmdline_fixed_string_t mode;
6226 cmd_set_vf_macvlan_parsed(void *parsed_result,
6227 __attribute__((unused)) struct cmdline *cl,
6228 __attribute__((unused)) void *data)
6231 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6232 struct rte_eth_mac_filter filter;
6234 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6236 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6238 /* set VF MAC filter */
6242 filter.dst_id = res->vf_id;
6244 if (!strcmp(res->filter_type, "exact-mac"))
6245 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6246 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6247 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6248 else if (!strcmp(res->filter_type, "hashmac"))
6249 filter.filter_type = RTE_MAC_HASH_MATCH;
6250 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6251 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6253 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6256 ret = rte_eth_dev_filter_ctrl(res->port_id,
6257 RTE_ETH_FILTER_MACVLAN,
6261 ret = rte_eth_dev_filter_ctrl(res->port_id,
6262 RTE_ETH_FILTER_MACVLAN,
6263 RTE_ETH_FILTER_DELETE,
6267 printf("bad set MAC hash parameter, return code = %d\n", ret);
6271 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6272 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6274 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6275 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6277 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6278 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6280 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6281 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6283 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6284 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6286 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6287 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6289 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6290 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6291 filter_type, "exact-mac#exact-mac-vlan"
6292 "#hashmac#hashmac-vlan");
6293 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6294 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6297 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6298 .f = cmd_set_vf_macvlan_parsed,
6300 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6301 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6303 "exact match rule:exact match of MAC or MAC and VLAN; "
6304 "hash match rule: hash match of MAC and exact match "
6307 (void *)&cmd_set_vf_macvlan_set,
6308 (void *)&cmd_set_vf_macvlan_port,
6309 (void *)&cmd_set_vf_macvlan_portid,
6310 (void *)&cmd_set_vf_macvlan_vf,
6311 (void *)&cmd_set_vf_macvlan_vf_id,
6312 (void *)&cmd_set_vf_macvlan_mac,
6313 (void *)&cmd_set_vf_macvlan_filter_type,
6314 (void *)&cmd_set_vf_macvlan_mode,
6319 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6320 struct cmd_set_vf_traffic {
6321 cmdline_fixed_string_t set;
6322 cmdline_fixed_string_t port;
6324 cmdline_fixed_string_t vf;
6326 cmdline_fixed_string_t what;
6327 cmdline_fixed_string_t mode;
6331 cmd_set_vf_traffic_parsed(void *parsed_result,
6332 __attribute__((unused)) struct cmdline *cl,
6333 __attribute__((unused)) void *data)
6335 struct cmd_set_vf_traffic *res = parsed_result;
6336 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6337 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6339 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6342 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6343 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6345 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6346 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6348 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6349 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6351 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6352 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6354 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6355 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6357 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6358 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6360 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6361 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6364 cmdline_parse_inst_t cmd_set_vf_traffic = {
6365 .f = cmd_set_vf_traffic_parsed,
6367 .help_str = "set port X vf Y rx|tx on|off"
6368 "(X = port number,Y = vf id)",
6370 (void *)&cmd_setvf_traffic_set,
6371 (void *)&cmd_setvf_traffic_port,
6372 (void *)&cmd_setvf_traffic_portid,
6373 (void *)&cmd_setvf_traffic_vf,
6374 (void *)&cmd_setvf_traffic_vfid,
6375 (void *)&cmd_setvf_traffic_what,
6376 (void *)&cmd_setvf_traffic_mode,
6381 /* *** CONFIGURE VF RECEIVE MODE *** */
6382 struct cmd_set_vf_rxmode {
6383 cmdline_fixed_string_t set;
6384 cmdline_fixed_string_t port;
6386 cmdline_fixed_string_t vf;
6388 cmdline_fixed_string_t what;
6389 cmdline_fixed_string_t mode;
6390 cmdline_fixed_string_t on;
6394 cmd_set_vf_rxmode_parsed(void *parsed_result,
6395 __attribute__((unused)) struct cmdline *cl,
6396 __attribute__((unused)) void *data)
6399 uint16_t rx_mode = 0;
6400 struct cmd_set_vf_rxmode *res = parsed_result;
6402 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6403 if (!strcmp(res->what,"rxmode")) {
6404 if (!strcmp(res->mode, "AUPE"))
6405 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6406 else if (!strcmp(res->mode, "ROPE"))
6407 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6408 else if (!strcmp(res->mode, "BAM"))
6409 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6410 else if (!strncmp(res->mode, "MPE",3))
6411 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6414 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6416 printf("bad VF receive mode parameter, return code = %d \n",
6420 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6421 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6423 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6424 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6426 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6427 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6429 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6430 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6432 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6433 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6435 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6436 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6438 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6439 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6440 mode, "AUPE#ROPE#BAM#MPE");
6441 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6442 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6445 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6446 .f = cmd_set_vf_rxmode_parsed,
6448 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6450 (void *)&cmd_set_vf_rxmode_set,
6451 (void *)&cmd_set_vf_rxmode_port,
6452 (void *)&cmd_set_vf_rxmode_portid,
6453 (void *)&cmd_set_vf_rxmode_vf,
6454 (void *)&cmd_set_vf_rxmode_vfid,
6455 (void *)&cmd_set_vf_rxmode_what,
6456 (void *)&cmd_set_vf_rxmode_mode,
6457 (void *)&cmd_set_vf_rxmode_on,
6462 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6463 struct cmd_vf_mac_addr_result {
6464 cmdline_fixed_string_t mac_addr_cmd;
6465 cmdline_fixed_string_t what;
6466 cmdline_fixed_string_t port;
6468 cmdline_fixed_string_t vf;
6470 struct ether_addr address;
6473 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6474 __attribute__((unused)) struct cmdline *cl,
6475 __attribute__((unused)) void *data)
6477 struct cmd_vf_mac_addr_result *res = parsed_result;
6480 if (strcmp(res->what, "add") == 0)
6481 ret = rte_eth_dev_mac_addr_add(res->port_num,
6482 &res->address, res->vf_num);
6484 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6488 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6489 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6490 mac_addr_cmd,"mac_addr");
6491 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6492 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6494 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6495 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6497 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6498 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6500 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6501 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6503 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6504 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6506 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6507 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6510 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6511 .f = cmd_vf_mac_addr_parsed,
6513 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6514 "Y = VF number)add MAC address filtering for a VF on port X",
6516 (void *)&cmd_vf_mac_addr_cmd,
6517 (void *)&cmd_vf_mac_addr_what,
6518 (void *)&cmd_vf_mac_addr_port,
6519 (void *)&cmd_vf_mac_addr_portnum,
6520 (void *)&cmd_vf_mac_addr_vf,
6521 (void *)&cmd_vf_mac_addr_vfnum,
6522 (void *)&cmd_vf_mac_addr_addr,
6527 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6528 struct cmd_vf_rx_vlan_filter {
6529 cmdline_fixed_string_t rx_vlan;
6530 cmdline_fixed_string_t what;
6532 cmdline_fixed_string_t port;
6534 cmdline_fixed_string_t vf;
6539 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6540 __attribute__((unused)) struct cmdline *cl,
6541 __attribute__((unused)) void *data)
6543 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6545 if (!strcmp(res->what, "add"))
6546 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6548 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6551 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6552 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6553 rx_vlan, "rx_vlan");
6554 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6555 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6557 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6558 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6560 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6561 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6563 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6564 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6566 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6567 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6569 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6570 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6573 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6574 .f = cmd_vf_rx_vlan_filter_parsed,
6576 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6577 "Y = port number,Z = hexadecimal VF mask)",
6579 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6580 (void *)&cmd_vf_rx_vlan_filter_what,
6581 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6582 (void *)&cmd_vf_rx_vlan_filter_port,
6583 (void *)&cmd_vf_rx_vlan_filter_portid,
6584 (void *)&cmd_vf_rx_vlan_filter_vf,
6585 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6590 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6591 struct cmd_queue_rate_limit_result {
6592 cmdline_fixed_string_t set;
6593 cmdline_fixed_string_t port;
6595 cmdline_fixed_string_t queue;
6597 cmdline_fixed_string_t rate;
6601 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6602 __attribute__((unused)) struct cmdline *cl,
6603 __attribute__((unused)) void *data)
6605 struct cmd_queue_rate_limit_result *res = parsed_result;
6608 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6609 && (strcmp(res->queue, "queue") == 0)
6610 && (strcmp(res->rate, "rate") == 0))
6611 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6614 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6618 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6619 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6621 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6622 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6624 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6625 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6627 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6628 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6630 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6631 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6633 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6634 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6636 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6637 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6640 cmdline_parse_inst_t cmd_queue_rate_limit = {
6641 .f = cmd_queue_rate_limit_parsed,
6643 .help_str = "set port X queue Y rate Z:(X = port number,"
6644 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6646 (void *)&cmd_queue_rate_limit_set,
6647 (void *)&cmd_queue_rate_limit_port,
6648 (void *)&cmd_queue_rate_limit_portnum,
6649 (void *)&cmd_queue_rate_limit_queue,
6650 (void *)&cmd_queue_rate_limit_queuenum,
6651 (void *)&cmd_queue_rate_limit_rate,
6652 (void *)&cmd_queue_rate_limit_ratenum,
6657 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6658 struct cmd_vf_rate_limit_result {
6659 cmdline_fixed_string_t set;
6660 cmdline_fixed_string_t port;
6662 cmdline_fixed_string_t vf;
6664 cmdline_fixed_string_t rate;
6666 cmdline_fixed_string_t q_msk;
6670 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6671 __attribute__((unused)) struct cmdline *cl,
6672 __attribute__((unused)) void *data)
6674 struct cmd_vf_rate_limit_result *res = parsed_result;
6677 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6678 && (strcmp(res->vf, "vf") == 0)
6679 && (strcmp(res->rate, "rate") == 0)
6680 && (strcmp(res->q_msk, "queue_mask") == 0))
6681 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6682 res->rate_num, res->q_msk_val);
6684 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6688 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6689 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6691 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6692 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6694 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6695 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6697 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6698 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6700 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6701 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6703 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6704 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6706 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6707 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6709 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6710 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6711 q_msk, "queue_mask");
6712 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6713 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6716 cmdline_parse_inst_t cmd_vf_rate_limit = {
6717 .f = cmd_vf_rate_limit_parsed,
6719 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6720 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6721 "for queues of VF on port X",
6723 (void *)&cmd_vf_rate_limit_set,
6724 (void *)&cmd_vf_rate_limit_port,
6725 (void *)&cmd_vf_rate_limit_portnum,
6726 (void *)&cmd_vf_rate_limit_vf,
6727 (void *)&cmd_vf_rate_limit_vfnum,
6728 (void *)&cmd_vf_rate_limit_rate,
6729 (void *)&cmd_vf_rate_limit_ratenum,
6730 (void *)&cmd_vf_rate_limit_q_msk,
6731 (void *)&cmd_vf_rate_limit_q_msk_val,
6736 /* *** ADD TUNNEL FILTER OF A PORT *** */
6737 struct cmd_tunnel_filter_result {
6738 cmdline_fixed_string_t cmd;
6739 cmdline_fixed_string_t what;
6741 struct ether_addr outer_mac;
6742 struct ether_addr inner_mac;
6743 cmdline_ipaddr_t ip_value;
6744 uint16_t inner_vlan;
6745 cmdline_fixed_string_t tunnel_type;
6746 cmdline_fixed_string_t filter_type;
6752 cmd_tunnel_filter_parsed(void *parsed_result,
6753 __attribute__((unused)) struct cmdline *cl,
6754 __attribute__((unused)) void *data)
6756 struct cmd_tunnel_filter_result *res = parsed_result;
6757 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6760 tunnel_filter_conf.outer_mac = &res->outer_mac;
6761 tunnel_filter_conf.inner_mac = &res->inner_mac;
6762 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6764 if (res->ip_value.family == AF_INET) {
6765 tunnel_filter_conf.ip_addr.ipv4_addr =
6766 res->ip_value.addr.ipv4.s_addr;
6767 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6769 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6770 &(res->ip_value.addr.ipv6),
6771 sizeof(struct in6_addr));
6772 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6775 if (!strcmp(res->filter_type, "imac-ivlan"))
6776 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6777 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6778 tunnel_filter_conf.filter_type =
6779 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6780 else if (!strcmp(res->filter_type, "imac-tenid"))
6781 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6782 else if (!strcmp(res->filter_type, "imac"))
6783 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6784 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6785 tunnel_filter_conf.filter_type =
6786 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6788 printf("The filter type is not supported");
6792 if (!strcmp(res->tunnel_type, "vxlan"))
6793 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6795 printf("Only VXLAN is supported now.\n");
6799 tunnel_filter_conf.tenant_id = res->tenant_id;
6800 tunnel_filter_conf.queue_id = res->queue_num;
6801 if (!strcmp(res->what, "add"))
6802 ret = rte_eth_dev_filter_ctrl(res->port_id,
6803 RTE_ETH_FILTER_TUNNEL,
6805 &tunnel_filter_conf);
6807 ret = rte_eth_dev_filter_ctrl(res->port_id,
6808 RTE_ETH_FILTER_TUNNEL,
6809 RTE_ETH_FILTER_DELETE,
6810 &tunnel_filter_conf);
6812 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6816 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6817 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6818 cmd, "tunnel_filter");
6819 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6820 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6822 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6823 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6825 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6826 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6828 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6829 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6831 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6832 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6833 inner_vlan, UINT16);
6834 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6835 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6837 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6838 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6839 tunnel_type, "vxlan");
6841 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6842 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6843 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6844 "imac#omac-imac-tenid");
6845 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6846 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6848 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6849 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6852 cmdline_parse_inst_t cmd_tunnel_filter = {
6853 .f = cmd_tunnel_filter_parsed,
6855 .help_str = "add/rm tunnel filter of a port: "
6856 "tunnel_filter add port_id outer_mac inner_mac ip "
6857 "inner_vlan tunnel_type(vxlan) filter_type "
6858 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6859 "imac|omac-imac-tenid) "
6860 "tenant_id queue_num",
6862 (void *)&cmd_tunnel_filter_cmd,
6863 (void *)&cmd_tunnel_filter_what,
6864 (void *)&cmd_tunnel_filter_port_id,
6865 (void *)&cmd_tunnel_filter_outer_mac,
6866 (void *)&cmd_tunnel_filter_inner_mac,
6867 (void *)&cmd_tunnel_filter_ip_value,
6868 (void *)&cmd_tunnel_filter_innner_vlan,
6869 (void *)&cmd_tunnel_filter_tunnel_type,
6870 (void *)&cmd_tunnel_filter_filter_type,
6871 (void *)&cmd_tunnel_filter_tenant_id,
6872 (void *)&cmd_tunnel_filter_queue_num,
6877 /* *** CONFIGURE TUNNEL UDP PORT *** */
6878 struct cmd_tunnel_udp_config {
6879 cmdline_fixed_string_t cmd;
6880 cmdline_fixed_string_t what;
6886 cmd_tunnel_udp_config_parsed(void *parsed_result,
6887 __attribute__((unused)) struct cmdline *cl,
6888 __attribute__((unused)) void *data)
6890 struct cmd_tunnel_udp_config *res = parsed_result;
6891 struct rte_eth_udp_tunnel tunnel_udp;
6894 tunnel_udp.udp_port = res->udp_port;
6896 if (!strcmp(res->cmd, "rx_vxlan_port"))
6897 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6899 if (!strcmp(res->what, "add"))
6900 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6902 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6905 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6908 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6909 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6910 cmd, "rx_vxlan_port");
6911 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6912 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6914 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6915 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6917 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6918 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6921 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6922 .f = cmd_tunnel_udp_config_parsed,
6924 .help_str = "add/rm an tunneling UDP port filter: "
6925 "rx_vxlan_port add udp_port port_id",
6927 (void *)&cmd_tunnel_udp_config_cmd,
6928 (void *)&cmd_tunnel_udp_config_what,
6929 (void *)&cmd_tunnel_udp_config_udp_port,
6930 (void *)&cmd_tunnel_udp_config_port_id,
6935 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6936 struct cmd_set_mirror_mask_result {
6937 cmdline_fixed_string_t set;
6938 cmdline_fixed_string_t port;
6940 cmdline_fixed_string_t mirror;
6942 cmdline_fixed_string_t what;
6943 cmdline_fixed_string_t value;
6944 cmdline_fixed_string_t dstpool;
6946 cmdline_fixed_string_t on;
6949 cmdline_parse_token_string_t cmd_mirror_mask_set =
6950 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6952 cmdline_parse_token_string_t cmd_mirror_mask_port =
6953 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6955 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6956 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6958 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6959 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6960 mirror, "mirror-rule");
6961 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6962 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6964 cmdline_parse_token_string_t cmd_mirror_mask_what =
6965 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6966 what, "pool-mirror#vlan-mirror");
6967 cmdline_parse_token_string_t cmd_mirror_mask_value =
6968 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6970 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6971 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6972 dstpool, "dst-pool");
6973 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6974 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6976 cmdline_parse_token_string_t cmd_mirror_mask_on =
6977 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6981 cmd_set_mirror_mask_parsed(void *parsed_result,
6982 __attribute__((unused)) struct cmdline *cl,
6983 __attribute__((unused)) void *data)
6986 struct cmd_set_mirror_mask_result *res = parsed_result;
6987 struct rte_eth_vmdq_mirror_conf mr_conf;
6989 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6991 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6993 mr_conf.dst_pool = res->dstpool_id;
6995 if (!strcmp(res->what, "pool-mirror")) {
6996 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6997 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6998 } else if(!strcmp(res->what, "vlan-mirror")) {
6999 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
7000 nb_item = parse_item_list(res->value, "core",
7001 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
7005 for(i=0; i < nb_item; i++) {
7006 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7007 printf("Invalid vlan_id: must be < 4096\n");
7011 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7012 mr_conf.vlan.vlan_mask |= 1ULL << i;
7016 if(!strcmp(res->on, "on"))
7017 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7020 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7023 printf("mirror rule add error: (%s)\n", strerror(-ret));
7026 cmdline_parse_inst_t cmd_set_mirror_mask = {
7027 .f = cmd_set_mirror_mask_parsed,
7029 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
7030 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7032 (void *)&cmd_mirror_mask_set,
7033 (void *)&cmd_mirror_mask_port,
7034 (void *)&cmd_mirror_mask_portid,
7035 (void *)&cmd_mirror_mask_mirror,
7036 (void *)&cmd_mirror_mask_ruleid,
7037 (void *)&cmd_mirror_mask_what,
7038 (void *)&cmd_mirror_mask_value,
7039 (void *)&cmd_mirror_mask_dstpool,
7040 (void *)&cmd_mirror_mask_poolid,
7041 (void *)&cmd_mirror_mask_on,
7046 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7047 struct cmd_set_mirror_link_result {
7048 cmdline_fixed_string_t set;
7049 cmdline_fixed_string_t port;
7051 cmdline_fixed_string_t mirror;
7053 cmdline_fixed_string_t what;
7054 cmdline_fixed_string_t dstpool;
7056 cmdline_fixed_string_t on;
7059 cmdline_parse_token_string_t cmd_mirror_link_set =
7060 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7062 cmdline_parse_token_string_t cmd_mirror_link_port =
7063 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7065 cmdline_parse_token_num_t cmd_mirror_link_portid =
7066 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7068 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7069 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7070 mirror, "mirror-rule");
7071 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7072 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7074 cmdline_parse_token_string_t cmd_mirror_link_what =
7075 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7076 what, "uplink-mirror#downlink-mirror");
7077 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7078 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7079 dstpool, "dst-pool");
7080 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7081 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7083 cmdline_parse_token_string_t cmd_mirror_link_on =
7084 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7088 cmd_set_mirror_link_parsed(void *parsed_result,
7089 __attribute__((unused)) struct cmdline *cl,
7090 __attribute__((unused)) void *data)
7093 struct cmd_set_mirror_link_result *res = parsed_result;
7094 struct rte_eth_vmdq_mirror_conf mr_conf;
7096 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
7097 if(!strcmp(res->what, "uplink-mirror")) {
7098 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
7099 }else if(!strcmp(res->what, "downlink-mirror"))
7100 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
7102 mr_conf.dst_pool = res->dstpool_id;
7104 if(!strcmp(res->on, "on"))
7105 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7108 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7111 /* check the return value and print it if is < 0 */
7113 printf("mirror rule add error: (%s)\n", strerror(-ret));
7117 cmdline_parse_inst_t cmd_set_mirror_link = {
7118 .f = cmd_set_mirror_link_parsed,
7120 .help_str = "set port X mirror-rule Y uplink-mirror|"
7121 "downlink-mirror dst-pool Z on|off",
7123 (void *)&cmd_mirror_link_set,
7124 (void *)&cmd_mirror_link_port,
7125 (void *)&cmd_mirror_link_portid,
7126 (void *)&cmd_mirror_link_mirror,
7127 (void *)&cmd_mirror_link_ruleid,
7128 (void *)&cmd_mirror_link_what,
7129 (void *)&cmd_mirror_link_dstpool,
7130 (void *)&cmd_mirror_link_poolid,
7131 (void *)&cmd_mirror_link_on,
7136 /* *** RESET VM MIRROR RULE *** */
7137 struct cmd_rm_mirror_rule_result {
7138 cmdline_fixed_string_t reset;
7139 cmdline_fixed_string_t port;
7141 cmdline_fixed_string_t mirror;
7145 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7146 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7148 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7149 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7151 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7152 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7154 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7155 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7156 mirror, "mirror-rule");
7157 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7158 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7162 cmd_reset_mirror_rule_parsed(void *parsed_result,
7163 __attribute__((unused)) struct cmdline *cl,
7164 __attribute__((unused)) void *data)
7167 struct cmd_set_mirror_link_result *res = parsed_result;
7169 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7171 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7174 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7175 .f = cmd_reset_mirror_rule_parsed,
7177 .help_str = "reset port X mirror-rule Y",
7179 (void *)&cmd_rm_mirror_rule_reset,
7180 (void *)&cmd_rm_mirror_rule_port,
7181 (void *)&cmd_rm_mirror_rule_portid,
7182 (void *)&cmd_rm_mirror_rule_mirror,
7183 (void *)&cmd_rm_mirror_rule_ruleid,
7188 /* ******************************************************************************** */
7190 struct cmd_dump_result {
7191 cmdline_fixed_string_t dump;
7195 dump_struct_sizes(void)
7197 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7198 DUMP_SIZE(struct rte_mbuf);
7199 DUMP_SIZE(struct rte_mempool);
7200 DUMP_SIZE(struct rte_ring);
7204 static void cmd_dump_parsed(void *parsed_result,
7205 __attribute__((unused)) struct cmdline *cl,
7206 __attribute__((unused)) void *data)
7208 struct cmd_dump_result *res = parsed_result;
7210 if (!strcmp(res->dump, "dump_physmem"))
7211 rte_dump_physmem_layout(stdout);
7212 else if (!strcmp(res->dump, "dump_memzone"))
7213 rte_memzone_dump(stdout);
7214 else if (!strcmp(res->dump, "dump_log_history"))
7215 rte_log_dump_history(stdout);
7216 else if (!strcmp(res->dump, "dump_struct_sizes"))
7217 dump_struct_sizes();
7218 else if (!strcmp(res->dump, "dump_ring"))
7219 rte_ring_list_dump(stdout);
7220 else if (!strcmp(res->dump, "dump_mempool"))
7221 rte_mempool_list_dump(stdout);
7222 else if (!strcmp(res->dump, "dump_devargs"))
7223 rte_eal_devargs_dump(stdout);
7226 cmdline_parse_token_string_t cmd_dump_dump =
7227 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7231 "dump_struct_sizes#"
7236 cmdline_parse_inst_t cmd_dump = {
7237 .f = cmd_dump_parsed, /* function to call */
7238 .data = NULL, /* 2nd arg of func */
7239 .help_str = "dump status",
7240 .tokens = { /* token list, NULL terminated */
7241 (void *)&cmd_dump_dump,
7246 /* ******************************************************************************** */
7248 struct cmd_dump_one_result {
7249 cmdline_fixed_string_t dump;
7250 cmdline_fixed_string_t name;
7253 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7254 __attribute__((unused)) void *data)
7256 struct cmd_dump_one_result *res = parsed_result;
7258 if (!strcmp(res->dump, "dump_ring")) {
7260 r = rte_ring_lookup(res->name);
7262 cmdline_printf(cl, "Cannot find ring\n");
7265 rte_ring_dump(stdout, r);
7266 } else if (!strcmp(res->dump, "dump_mempool")) {
7267 struct rte_mempool *mp;
7268 mp = rte_mempool_lookup(res->name);
7270 cmdline_printf(cl, "Cannot find mempool\n");
7273 rte_mempool_dump(stdout, mp);
7277 cmdline_parse_token_string_t cmd_dump_one_dump =
7278 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7279 "dump_ring#dump_mempool");
7281 cmdline_parse_token_string_t cmd_dump_one_name =
7282 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7284 cmdline_parse_inst_t cmd_dump_one = {
7285 .f = cmd_dump_one_parsed, /* function to call */
7286 .data = NULL, /* 2nd arg of func */
7287 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7288 .tokens = { /* token list, NULL terminated */
7289 (void *)&cmd_dump_one_dump,
7290 (void *)&cmd_dump_one_name,
7295 /* *** set SYN filter *** */
7296 struct cmd_set_syn_filter_result {
7297 cmdline_fixed_string_t filter;
7299 cmdline_fixed_string_t priority;
7300 cmdline_fixed_string_t high;
7301 cmdline_fixed_string_t queue;
7306 cmd_set_syn_filter_parsed(void *parsed_result,
7307 __attribute__((unused)) struct cmdline *cl,
7308 __attribute__((unused)) void *data)
7311 struct cmd_set_syn_filter_result *res = parsed_result;
7312 struct rte_syn_filter filter;
7314 if (!strcmp(res->filter, "add_syn_filter")) {
7315 if (!strcmp(res->high, "high"))
7319 ret = rte_eth_dev_add_syn_filter(res->port_id,
7320 &filter, res->queue_id);
7321 } else if (!strcmp(res->filter, "remove_syn_filter"))
7322 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7323 else if (!strcmp(res->filter, "get_syn_filter"))
7324 get_syn_filter(res->port_id);
7326 printf("syn filter setting error: (%s)\n", strerror(-ret));
7329 cmdline_parse_token_num_t cmd_syn_filter_portid =
7330 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7332 cmdline_parse_token_string_t cmd_syn_filter_priority =
7333 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7334 priority, "priority");
7335 cmdline_parse_token_string_t cmd_syn_filter_high =
7336 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7338 cmdline_parse_token_string_t cmd_syn_filter_queue =
7339 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7341 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7342 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7344 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7345 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7346 filter, "add_syn_filter");
7347 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7348 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7349 filter, "remove_syn_filter");
7350 cmdline_parse_inst_t cmd_add_syn_filter = {
7351 .f = cmd_set_syn_filter_parsed,
7353 .help_str = "add syn filter",
7355 (void *)&cmd_syn_filter_add_filter,
7356 (void *)&cmd_syn_filter_portid,
7357 (void *)&cmd_syn_filter_priority,
7358 (void *)&cmd_syn_filter_high,
7359 (void *)&cmd_syn_filter_queue,
7360 (void *)&cmd_syn_filter_queue_id,
7364 cmdline_parse_inst_t cmd_remove_syn_filter = {
7365 .f = cmd_set_syn_filter_parsed,
7367 .help_str = "remove syn filter",
7369 (void *)&cmd_syn_filter_remove_filter,
7370 (void *)&cmd_syn_filter_portid,
7375 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7376 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7377 filter, "get_syn_filter");
7379 cmdline_parse_inst_t cmd_get_syn_filter = {
7380 .f = cmd_set_syn_filter_parsed,
7382 .help_str = "get syn filter",
7384 (void *)&cmd_syn_filter_get_filter,
7385 (void *)&cmd_syn_filter_portid,
7390 /* *** ADD/REMOVE A 2tuple FILTER *** */
7391 struct cmd_2tuple_filter_result {
7392 cmdline_fixed_string_t filter;
7394 cmdline_fixed_string_t protocol;
7395 uint8_t protocol_value;
7396 uint8_t protocol_mask;
7397 cmdline_fixed_string_t dst_port;
7398 uint16_t dst_port_value;
7399 uint16_t dst_port_mask;
7400 cmdline_fixed_string_t flags;
7401 uint8_t flags_value;
7402 cmdline_fixed_string_t priority;
7403 uint8_t priority_value;
7404 cmdline_fixed_string_t queue;
7406 cmdline_fixed_string_t index;
7407 uint16_t index_value;
7411 cmd_2tuple_filter_parsed(void *parsed_result,
7412 __attribute__((unused)) struct cmdline *cl,
7413 __attribute__((unused)) void *data)
7416 struct rte_2tuple_filter filter;
7417 struct cmd_2tuple_filter_result *res = parsed_result;
7419 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7421 if (!strcmp(res->filter, "add_2tuple_filter")) {
7422 /* need convert to big endian. */
7423 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7424 filter.protocol = res->protocol_value;
7425 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7426 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7427 filter.priority = res->priority_value;
7428 filter.tcp_flags = res->flags_value;
7429 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7430 res->index_value, &filter, res->queue_id);
7431 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7432 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7434 else if (!strcmp(res->filter, "get_2tuple_filter"))
7435 get_2tuple_filter(res->port_id, res->index_value);
7438 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7441 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7442 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7444 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7445 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7446 protocol, "protocol");
7447 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7448 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7449 protocol_value, UINT8);
7450 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7451 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7452 protocol_mask, UINT8);
7453 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7454 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7455 dst_port, "dst_port");
7456 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7457 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7458 dst_port_value, UINT16);
7459 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7460 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7461 dst_port_mask, UINT16);
7462 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7463 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7465 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7466 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7467 flags_value, UINT8);
7468 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7469 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7470 priority, "priority");
7471 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7472 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7473 priority_value, UINT8);
7474 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7475 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7477 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7478 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7480 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7481 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7483 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7484 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7485 index_value, UINT16);
7486 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7487 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7488 filter, "add_2tuple_filter");
7489 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7490 .f = cmd_2tuple_filter_parsed,
7492 .help_str = "add a 2tuple filter",
7494 (void *)&cmd_2tuple_filter_add_filter,
7495 (void *)&cmd_2tuple_filter_port_id,
7496 (void *)&cmd_2tuple_filter_protocol,
7497 (void *)&cmd_2tuple_filter_protocol_value,
7498 (void *)&cmd_2tuple_filter_protocol_mask,
7499 (void *)&cmd_2tuple_filter_dst_port,
7500 (void *)&cmd_2tuple_filter_dst_port_value,
7501 (void *)&cmd_2tuple_filter_dst_port_mask,
7502 (void *)&cmd_2tuple_filter_flags,
7503 (void *)&cmd_2tuple_filter_flags_value,
7504 (void *)&cmd_2tuple_filter_priority,
7505 (void *)&cmd_2tuple_filter_priority_value,
7506 (void *)&cmd_2tuple_filter_queue,
7507 (void *)&cmd_2tuple_filter_queue_id,
7508 (void *)&cmd_2tuple_filter_index,
7509 (void *)&cmd_2tuple_filter_index_value,
7514 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7515 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7516 filter, "remove_2tuple_filter");
7517 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7518 .f = cmd_2tuple_filter_parsed,
7520 .help_str = "remove a 2tuple filter",
7522 (void *)&cmd_2tuple_filter_remove_filter,
7523 (void *)&cmd_2tuple_filter_port_id,
7524 (void *)&cmd_2tuple_filter_index,
7525 (void *)&cmd_2tuple_filter_index_value,
7529 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7530 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7531 filter, "get_2tuple_filter");
7532 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7533 .f = cmd_2tuple_filter_parsed,
7535 .help_str = "get a 2tuple filter",
7537 (void *)&cmd_2tuple_filter_get_filter,
7538 (void *)&cmd_2tuple_filter_port_id,
7539 (void *)&cmd_2tuple_filter_index,
7540 (void *)&cmd_2tuple_filter_index_value,
7545 /* *** ADD/REMOVE A 5tuple FILTER *** */
7546 struct cmd_5tuple_filter_result {
7547 cmdline_fixed_string_t filter;
7549 cmdline_fixed_string_t dst_ip;
7550 cmdline_ipaddr_t dst_ip_value;
7551 cmdline_fixed_string_t src_ip;
7552 cmdline_ipaddr_t src_ip_value;
7553 cmdline_fixed_string_t dst_port;
7554 uint16_t dst_port_value;
7555 cmdline_fixed_string_t src_port;
7556 uint16_t src_port_value;
7557 cmdline_fixed_string_t protocol;
7558 uint8_t protocol_value;
7559 cmdline_fixed_string_t mask;
7561 cmdline_fixed_string_t flags;
7562 uint8_t flags_value;
7563 cmdline_fixed_string_t priority;
7564 uint8_t priority_value;
7565 cmdline_fixed_string_t queue;
7567 cmdline_fixed_string_t index;
7568 uint16_t index_value;
7572 cmd_5tuple_filter_parsed(void *parsed_result,
7573 __attribute__((unused)) struct cmdline *cl,
7574 __attribute__((unused)) void *data)
7577 struct rte_5tuple_filter filter;
7578 struct cmd_5tuple_filter_result *res = parsed_result;
7580 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7582 if (!strcmp(res->filter, "add_5tuple_filter")) {
7583 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7584 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7585 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7586 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7587 filter.protocol = res->protocol_value;
7588 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7589 filter.priority = res->priority_value;
7590 filter.tcp_flags = res->flags_value;
7592 if (res->dst_ip_value.family == AF_INET)
7593 /* no need to convert, already big endian. */
7594 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7596 if (filter.dst_ip_mask == 0) {
7597 printf("can not support ipv6 involved compare.\n");
7603 if (res->src_ip_value.family == AF_INET)
7604 /* no need to convert, already big endian. */
7605 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7607 if (filter.src_ip_mask == 0) {
7608 printf("can not support ipv6 involved compare.\n");
7613 /* need convert to big endian. */
7614 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7615 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7617 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7618 res->index_value, &filter, res->queue_id);
7619 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7620 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7622 else if (!strcmp(res->filter, "get_5tuple_filter"))
7623 get_5tuple_filter(res->port_id, res->index_value);
7625 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7629 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7630 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7632 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7633 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7635 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7636 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7638 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7639 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7641 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7642 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7644 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7645 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7646 dst_port, "dst_port");
7647 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7648 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7649 dst_port_value, UINT16);
7650 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7651 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7652 src_port, "src_port");
7653 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7654 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7655 src_port_value, UINT16);
7656 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7657 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7658 protocol, "protocol");
7659 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7660 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7661 protocol_value, UINT8);
7662 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7663 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7665 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7666 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7668 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7669 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7671 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7672 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7673 flags_value, UINT8);
7674 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7675 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7676 priority, "priority");
7677 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7678 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7679 priority_value, UINT8);
7680 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7681 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7683 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7684 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7686 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7687 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7689 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7690 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7691 index_value, UINT16);
7693 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7694 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7695 filter, "add_5tuple_filter");
7696 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7697 .f = cmd_5tuple_filter_parsed,
7699 .help_str = "add a 5tuple filter",
7701 (void *)&cmd_5tuple_filter_add_filter,
7702 (void *)&cmd_5tuple_filter_port_id,
7703 (void *)&cmd_5tuple_filter_dst_ip,
7704 (void *)&cmd_5tuple_filter_dst_ip_value,
7705 (void *)&cmd_5tuple_filter_src_ip,
7706 (void *)&cmd_5tuple_filter_src_ip_value,
7707 (void *)&cmd_5tuple_filter_dst_port,
7708 (void *)&cmd_5tuple_filter_dst_port_value,
7709 (void *)&cmd_5tuple_filter_src_port,
7710 (void *)&cmd_5tuple_filter_src_port_value,
7711 (void *)&cmd_5tuple_filter_protocol,
7712 (void *)&cmd_5tuple_filter_protocol_value,
7713 (void *)&cmd_5tuple_filter_mask,
7714 (void *)&cmd_5tuple_filter_mask_value,
7715 (void *)&cmd_5tuple_filter_flags,
7716 (void *)&cmd_5tuple_filter_flags_value,
7717 (void *)&cmd_5tuple_filter_priority,
7718 (void *)&cmd_5tuple_filter_priority_value,
7719 (void *)&cmd_5tuple_filter_queue,
7720 (void *)&cmd_5tuple_filter_queue_id,
7721 (void *)&cmd_5tuple_filter_index,
7722 (void *)&cmd_5tuple_filter_index_value,
7727 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7728 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7729 filter, "remove_5tuple_filter");
7730 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7731 .f = cmd_5tuple_filter_parsed,
7733 .help_str = "remove a 5tuple filter",
7735 (void *)&cmd_5tuple_filter_remove_filter,
7736 (void *)&cmd_5tuple_filter_port_id,
7737 (void *)&cmd_5tuple_filter_index,
7738 (void *)&cmd_5tuple_filter_index_value,
7743 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7744 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7745 filter, "get_5tuple_filter");
7746 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7747 .f = cmd_5tuple_filter_parsed,
7749 .help_str = "get a 5tuple filter",
7751 (void *)&cmd_5tuple_filter_get_filter,
7752 (void *)&cmd_5tuple_filter_port_id,
7753 (void *)&cmd_5tuple_filter_index,
7754 (void *)&cmd_5tuple_filter_index_value,
7759 /* *** ADD/REMOVE A flex FILTER *** */
7760 struct cmd_flex_filter_result {
7761 cmdline_fixed_string_t filter;
7763 cmdline_fixed_string_t len;
7765 cmdline_fixed_string_t bytes;
7766 cmdline_fixed_string_t bytes_value;
7767 cmdline_fixed_string_t mask;
7768 cmdline_fixed_string_t mask_value;
7769 cmdline_fixed_string_t priority;
7770 uint8_t priority_value;
7771 cmdline_fixed_string_t queue;
7773 cmdline_fixed_string_t index;
7774 uint16_t index_value;
7777 static int xdigit2val(unsigned char c)
7782 else if (isupper(c))
7790 cmd_flex_filter_parsed(void *parsed_result,
7791 __attribute__((unused)) struct cmdline *cl,
7792 __attribute__((unused)) void *data)
7795 struct rte_flex_filter filter;
7796 struct cmd_flex_filter_result *res = parsed_result;
7797 char *bytes_ptr, *mask_ptr;
7805 if (!strcmp(res->filter, "add_flex_filter")) {
7806 if (res->len_value > 128) {
7807 printf("the len exceed the max length 128\n");
7810 memset(&filter, 0, sizeof(struct rte_flex_filter));
7811 filter.len = res->len_value;
7812 filter.priority = res->priority_value;
7813 bytes_ptr = res->bytes_value;
7814 mask_ptr = res->mask_value;
7817 /* translate bytes string to uint_32 array. */
7818 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7819 (bytes_ptr[1] == 'X')))
7821 len = strnlen(bytes_ptr, res->len_value * 2);
7822 if (len == 0 || (len % 8 != 0)) {
7823 printf("please check len and bytes input\n");
7826 for (i = 0; i < len; i++) {
7828 if (isxdigit(c) == 0) {
7829 /* invalid characters. */
7830 printf("invalid input\n");
7833 val = xdigit2val(c);
7837 dword |= byte << (4 * mod - 4);
7842 filter.dwords[j] = dword;
7843 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7849 /* translate mask string to uint8_t array. */
7851 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7852 (mask_ptr[1] == 'X')))
7854 len = strnlen(mask_ptr, (res->len_value+3)/4);
7856 printf("invalid input\n");
7859 for (i = 0; i < len; i++) {
7861 if (isxdigit(c) == 0) {
7862 /* invalid characters. */
7863 printf("invalid input\n");
7866 val = xdigit2val(c);
7867 hex |= (uint8_t)(val & 0x8) >> 3;
7868 hex |= (uint8_t)(val & 0x4) >> 1;
7869 hex |= (uint8_t)(val & 0x2) << 1;
7870 hex |= (uint8_t)(val & 0x1) << 3;
7873 filter.mask[j] = byte;
7874 printf("mask[%d]:%02x ", j, filter.mask[j]);
7882 printf("call function rte_eth_dev_add_flex_filter: "
7883 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7884 res->index_value, res->queue_id,
7885 filter.len, filter.priority);
7886 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7887 &filter, res->queue_id);
7889 } else if (!strcmp(res->filter, "remove_flex_filter"))
7890 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7892 else if (!strcmp(res->filter, "get_flex_filter"))
7893 get_flex_filter(res->port_id, res->index_value);
7896 printf("flex filter setting error: (%s)\n", strerror(-ret));
7899 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7900 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7902 cmdline_parse_token_string_t cmd_flex_filter_len =
7903 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7905 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7906 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7908 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7909 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7911 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7912 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7914 cmdline_parse_token_string_t cmd_flex_filter_mask =
7915 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7917 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7918 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7920 cmdline_parse_token_string_t cmd_flex_filter_priority =
7921 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7922 priority, "priority");
7923 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7924 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7925 priority_value, UINT8);
7926 cmdline_parse_token_string_t cmd_flex_filter_queue =
7927 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7929 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7930 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7932 cmdline_parse_token_string_t cmd_flex_filter_index =
7933 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7935 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7936 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7937 index_value, UINT16);
7938 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7939 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7940 filter, "add_flex_filter");
7941 cmdline_parse_inst_t cmd_add_flex_filter = {
7942 .f = cmd_flex_filter_parsed,
7944 .help_str = "add a flex filter",
7946 (void *)&cmd_flex_filter_add_filter,
7947 (void *)&cmd_flex_filter_port_id,
7948 (void *)&cmd_flex_filter_len,
7949 (void *)&cmd_flex_filter_len_value,
7950 (void *)&cmd_flex_filter_bytes,
7951 (void *)&cmd_flex_filter_bytes_value,
7952 (void *)&cmd_flex_filter_mask,
7953 (void *)&cmd_flex_filter_mask_value,
7954 (void *)&cmd_flex_filter_priority,
7955 (void *)&cmd_flex_filter_priority_value,
7956 (void *)&cmd_flex_filter_queue,
7957 (void *)&cmd_flex_filter_queue_id,
7958 (void *)&cmd_flex_filter_index,
7959 (void *)&cmd_flex_filter_index_value,
7964 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7965 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7966 filter, "remove_flex_filter");
7967 cmdline_parse_inst_t cmd_remove_flex_filter = {
7968 .f = cmd_flex_filter_parsed,
7970 .help_str = "remove a flex filter",
7972 (void *)&cmd_flex_filter_remove_filter,
7973 (void *)&cmd_flex_filter_port_id,
7974 (void *)&cmd_flex_filter_index,
7975 (void *)&cmd_flex_filter_index_value,
7980 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7981 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7982 filter, "get_flex_filter");
7983 cmdline_parse_inst_t cmd_get_flex_filter = {
7984 .f = cmd_flex_filter_parsed,
7986 .help_str = "get a flex filter",
7988 (void *)&cmd_flex_filter_get_filter,
7989 (void *)&cmd_flex_filter_port_id,
7990 (void *)&cmd_flex_filter_index,
7991 (void *)&cmd_flex_filter_index_value,
7996 /* *** Filters Control *** */
7998 /* *** deal with ethertype filter *** */
7999 struct cmd_ethertype_filter_result {
8000 cmdline_fixed_string_t filter;
8002 cmdline_fixed_string_t ops;
8003 cmdline_fixed_string_t mac;
8004 struct ether_addr mac_addr;
8005 cmdline_fixed_string_t ethertype;
8006 uint16_t ethertype_value;
8007 cmdline_fixed_string_t drop;
8008 cmdline_fixed_string_t queue;
8012 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8013 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8014 filter, "ethertype_filter");
8015 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8016 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8018 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8019 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8021 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8022 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8023 mac, "mac_addr#mac_ignr");
8024 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8025 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8027 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8028 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8029 ethertype, "ethertype");
8030 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8031 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8032 ethertype_value, UINT16);
8033 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8034 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8036 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8037 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8039 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8040 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8044 cmd_ethertype_filter_parsed(void *parsed_result,
8045 __attribute__((unused)) struct cmdline *cl,
8046 __attribute__((unused)) void *data)
8048 struct cmd_ethertype_filter_result *res = parsed_result;
8049 struct rte_eth_ethertype_filter filter;
8052 ret = rte_eth_dev_filter_supported(res->port_id,
8053 RTE_ETH_FILTER_ETHERTYPE);
8055 printf("ethertype filter is not supported on port %u.\n",
8060 memset(&filter, 0, sizeof(filter));
8061 if (!strcmp(res->mac, "mac_addr")) {
8062 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8063 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8064 sizeof(struct ether_addr));
8066 if (!strcmp(res->drop, "drop"))
8067 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8068 filter.ether_type = res->ethertype_value;
8069 filter.queue = res->queue_id;
8071 if (!strcmp(res->ops, "add"))
8072 ret = rte_eth_dev_filter_ctrl(res->port_id,
8073 RTE_ETH_FILTER_ETHERTYPE,
8077 ret = rte_eth_dev_filter_ctrl(res->port_id,
8078 RTE_ETH_FILTER_ETHERTYPE,
8079 RTE_ETH_FILTER_DELETE,
8082 printf("ethertype filter programming error: (%s)\n",
8086 cmdline_parse_inst_t cmd_ethertype_filter = {
8087 .f = cmd_ethertype_filter_parsed,
8089 .help_str = "add or delete an ethertype filter entry",
8091 (void *)&cmd_ethertype_filter_filter,
8092 (void *)&cmd_ethertype_filter_port_id,
8093 (void *)&cmd_ethertype_filter_ops,
8094 (void *)&cmd_ethertype_filter_mac,
8095 (void *)&cmd_ethertype_filter_mac_addr,
8096 (void *)&cmd_ethertype_filter_ethertype,
8097 (void *)&cmd_ethertype_filter_ethertype_value,
8098 (void *)&cmd_ethertype_filter_drop,
8099 (void *)&cmd_ethertype_filter_queue,
8100 (void *)&cmd_ethertype_filter_queue_id,
8105 /* *** deal with flow director filter *** */
8106 struct cmd_flow_director_result {
8107 cmdline_fixed_string_t flow_director_filter;
8109 cmdline_fixed_string_t ops;
8110 cmdline_fixed_string_t flow;
8111 cmdline_fixed_string_t flow_type;
8112 cmdline_fixed_string_t src;
8113 cmdline_ipaddr_t ip_src;
8115 cmdline_fixed_string_t dst;
8116 cmdline_ipaddr_t ip_dst;
8118 cmdline_fixed_string_t verify_tag;
8119 uint32_t verify_tag_value;
8120 cmdline_fixed_string_t flexbytes;
8121 cmdline_fixed_string_t flexbytes_value;
8122 cmdline_fixed_string_t drop;
8123 cmdline_fixed_string_t queue;
8125 cmdline_fixed_string_t fd_id;
8126 uint32_t fd_id_value;
8130 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8133 const char *p, *p0 = q_arg;
8135 unsigned long int_fld;
8136 char *str_fld[max_num];
8141 p = strchr(p0, '(');
8145 p0 = strchr(p, ')');
8150 if (size >= sizeof(s))
8153 snprintf(s, sizeof(s), "%.*s", size, p);
8154 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8155 if (ret < 0 || ret > max_num)
8157 for (i = 0; i < ret; i++) {
8159 int_fld = strtoul(str_fld[i], &end, 0);
8160 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8162 flexbytes[i] = (uint8_t)int_fld;
8167 static enum rte_eth_flow_type
8168 str2flowtype(char *string)
8171 static const struct {
8173 enum rte_eth_flow_type type;
8174 } flowtype_str[] = {
8175 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8176 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8177 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8178 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8179 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8180 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8181 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8182 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8183 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8184 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8187 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8188 if (!strcmp(flowtype_str[i].str, string))
8189 return flowtype_str[i].type;
8191 return RTE_ETH_FLOW_TYPE_NONE;
8194 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8196 if ((ip_addr).family == AF_INET) \
8197 (ip) = (ip_addr).addr.ipv4.s_addr; \
8199 printf("invalid parameter.\n"); \
8204 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8206 if ((ip_addr).family == AF_INET6) \
8207 (void)rte_memcpy(&(ip), \
8208 &((ip_addr).addr.ipv6), \
8209 sizeof(struct in6_addr)); \
8211 printf("invalid parameter.\n"); \
8217 cmd_flow_director_filter_parsed(void *parsed_result,
8218 __attribute__((unused)) struct cmdline *cl,
8219 __attribute__((unused)) void *data)
8221 struct cmd_flow_director_result *res = parsed_result;
8222 struct rte_eth_fdir_filter entry;
8223 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8226 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8228 printf("flow director is not supported on port %u.\n",
8232 memset(flexbytes, 0, sizeof(flexbytes));
8233 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8234 ret = parse_flexbytes(res->flexbytes_value,
8236 RTE_ETH_FDIR_MAX_FLEXLEN);
8238 printf("error: Cannot parse flexbytes input.\n");
8242 entry.input.flow_type = str2flowtype(res->flow_type);
8243 switch (entry.input.flow_type) {
8244 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
8245 case RTE_ETH_FLOW_TYPE_UDPV4:
8246 case RTE_ETH_FLOW_TYPE_TCPV4:
8247 IPV4_ADDR_TO_UINT(res->ip_dst,
8248 entry.input.flow.ip4_flow.dst_ip);
8249 IPV4_ADDR_TO_UINT(res->ip_src,
8250 entry.input.flow.ip4_flow.src_ip);
8251 /* need convert to big endian. */
8252 entry.input.flow.udp4_flow.dst_port =
8253 rte_cpu_to_be_16(res->port_dst);
8254 entry.input.flow.udp4_flow.src_port =
8255 rte_cpu_to_be_16(res->port_src);
8257 case RTE_ETH_FLOW_TYPE_SCTPV4:
8258 IPV4_ADDR_TO_UINT(res->ip_dst,
8259 entry.input.flow.sctp4_flow.ip.dst_ip);
8260 IPV4_ADDR_TO_UINT(res->ip_src,
8261 entry.input.flow.sctp4_flow.ip.src_ip);
8262 /* need convert to big endian. */
8263 entry.input.flow.sctp4_flow.verify_tag =
8264 rte_cpu_to_be_32(res->verify_tag_value);
8266 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
8267 case RTE_ETH_FLOW_TYPE_UDPV6:
8268 case RTE_ETH_FLOW_TYPE_TCPV6:
8269 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8270 entry.input.flow.ipv6_flow.dst_ip);
8271 IPV6_ADDR_TO_ARRAY(res->ip_src,
8272 entry.input.flow.ipv6_flow.src_ip);
8273 /* need convert to big endian. */
8274 entry.input.flow.udp6_flow.dst_port =
8275 rte_cpu_to_be_16(res->port_dst);
8276 entry.input.flow.udp6_flow.src_port =
8277 rte_cpu_to_be_16(res->port_src);
8279 case RTE_ETH_FLOW_TYPE_SCTPV6:
8280 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8281 entry.input.flow.sctp6_flow.ip.dst_ip);
8282 IPV6_ADDR_TO_ARRAY(res->ip_src,
8283 entry.input.flow.sctp6_flow.ip.src_ip);
8284 /* need convert to big endian. */
8285 entry.input.flow.sctp6_flow.verify_tag =
8286 rte_cpu_to_be_32(res->verify_tag_value);
8289 printf("invalid parameter.\n");
8292 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8294 RTE_ETH_FDIR_MAX_FLEXLEN);
8296 entry.action.flex_off = 0; /*use 0 by default */
8297 if (!strcmp(res->drop, "drop"))
8298 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8300 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8301 /* set to report FD ID by default */
8302 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8303 entry.action.rx_queue = res->queue_id;
8304 entry.soft_id = res->fd_id_value;
8305 if (!strcmp(res->ops, "add"))
8306 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8307 RTE_ETH_FILTER_ADD, &entry);
8309 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8310 RTE_ETH_FILTER_DELETE, &entry);
8312 printf("flow director programming error: (%s)\n",
8316 cmdline_parse_token_string_t cmd_flow_director_filter =
8317 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8318 flow_director_filter, "flow_director_filter");
8319 cmdline_parse_token_num_t cmd_flow_director_port_id =
8320 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8322 cmdline_parse_token_string_t cmd_flow_director_ops =
8323 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8325 cmdline_parse_token_string_t cmd_flow_director_flow =
8326 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8328 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8331 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8332 "ip6#ip6-frag#tcp6#udp6#sctp6");
8333 cmdline_parse_token_string_t cmd_flow_director_src =
8334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8336 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8337 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8339 cmdline_parse_token_num_t cmd_flow_director_port_src =
8340 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8342 cmdline_parse_token_string_t cmd_flow_director_dst =
8343 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8345 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8346 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8348 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8349 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8351 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8353 verify_tag, "verify_tag");
8354 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8355 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8356 verify_tag_value, UINT32);
8357 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8358 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8359 flexbytes, "flexbytes");
8360 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8361 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8362 flexbytes_value, NULL);
8363 cmdline_parse_token_string_t cmd_flow_director_drop =
8364 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8366 cmdline_parse_token_string_t cmd_flow_director_queue =
8367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8369 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8370 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8372 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8373 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8375 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8376 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8377 fd_id_value, UINT32);
8379 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8380 .f = cmd_flow_director_filter_parsed,
8382 .help_str = "add or delete an ip flow director entry on NIC",
8384 (void *)&cmd_flow_director_filter,
8385 (void *)&cmd_flow_director_port_id,
8386 (void *)&cmd_flow_director_ops,
8387 (void *)&cmd_flow_director_flow,
8388 (void *)&cmd_flow_director_flow_type,
8389 (void *)&cmd_flow_director_src,
8390 (void *)&cmd_flow_director_ip_src,
8391 (void *)&cmd_flow_director_dst,
8392 (void *)&cmd_flow_director_ip_dst,
8393 (void *)&cmd_flow_director_flexbytes,
8394 (void *)&cmd_flow_director_flexbytes_value,
8395 (void *)&cmd_flow_director_drop,
8396 (void *)&cmd_flow_director_queue,
8397 (void *)&cmd_flow_director_queue_id,
8398 (void *)&cmd_flow_director_fd_id,
8399 (void *)&cmd_flow_director_fd_id_value,
8404 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8405 .f = cmd_flow_director_filter_parsed,
8407 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8409 (void *)&cmd_flow_director_filter,
8410 (void *)&cmd_flow_director_port_id,
8411 (void *)&cmd_flow_director_ops,
8412 (void *)&cmd_flow_director_flow,
8413 (void *)&cmd_flow_director_flow_type,
8414 (void *)&cmd_flow_director_src,
8415 (void *)&cmd_flow_director_ip_src,
8416 (void *)&cmd_flow_director_port_src,
8417 (void *)&cmd_flow_director_dst,
8418 (void *)&cmd_flow_director_ip_dst,
8419 (void *)&cmd_flow_director_port_dst,
8420 (void *)&cmd_flow_director_flexbytes,
8421 (void *)&cmd_flow_director_flexbytes_value,
8422 (void *)&cmd_flow_director_drop,
8423 (void *)&cmd_flow_director_queue,
8424 (void *)&cmd_flow_director_queue_id,
8425 (void *)&cmd_flow_director_fd_id,
8426 (void *)&cmd_flow_director_fd_id_value,
8431 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8432 .f = cmd_flow_director_filter_parsed,
8434 .help_str = "add or delete a sctp flow director entry on NIC",
8436 (void *)&cmd_flow_director_filter,
8437 (void *)&cmd_flow_director_port_id,
8438 (void *)&cmd_flow_director_ops,
8439 (void *)&cmd_flow_director_flow,
8440 (void *)&cmd_flow_director_flow_type,
8441 (void *)&cmd_flow_director_src,
8442 (void *)&cmd_flow_director_ip_src,
8443 (void *)&cmd_flow_director_dst,
8444 (void *)&cmd_flow_director_ip_dst,
8445 (void *)&cmd_flow_director_verify_tag,
8446 (void *)&cmd_flow_director_verify_tag_value,
8447 (void *)&cmd_flow_director_flexbytes,
8448 (void *)&cmd_flow_director_flexbytes_value,
8449 (void *)&cmd_flow_director_drop,
8450 (void *)&cmd_flow_director_queue,
8451 (void *)&cmd_flow_director_queue_id,
8452 (void *)&cmd_flow_director_fd_id,
8453 (void *)&cmd_flow_director_fd_id_value,
8458 struct cmd_flush_flow_director_result {
8459 cmdline_fixed_string_t flush_flow_director;
8463 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8464 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8465 flush_flow_director, "flush_flow_director");
8466 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8467 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8471 cmd_flush_flow_director_parsed(void *parsed_result,
8472 __attribute__((unused)) struct cmdline *cl,
8473 __attribute__((unused)) void *data)
8475 struct cmd_flow_director_result *res = parsed_result;
8478 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8480 printf("flow director is not supported on port %u.\n",
8485 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8486 RTE_ETH_FILTER_FLUSH, NULL);
8488 printf("flow director table flushing error: (%s)\n",
8492 cmdline_parse_inst_t cmd_flush_flow_director = {
8493 .f = cmd_flush_flow_director_parsed,
8495 .help_str = "flush all flow director entries of a device on NIC",
8497 (void *)&cmd_flush_flow_director_flush,
8498 (void *)&cmd_flush_flow_director_port_id,
8503 /* *** deal with flow director mask on flexible payload *** */
8504 struct cmd_flow_director_flex_mask_result {
8505 cmdline_fixed_string_t flow_director_flexmask;
8507 cmdline_fixed_string_t flow;
8508 cmdline_fixed_string_t flow_type;
8509 cmdline_fixed_string_t mask;
8513 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8514 __attribute__((unused)) struct cmdline *cl,
8515 __attribute__((unused)) void *data)
8517 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8518 struct rte_eth_fdir_flex_mask flex_mask;
8519 struct rte_port *port;
8520 enum rte_eth_flow_type i;
8523 if (res->port_id > nb_ports) {
8524 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8528 port = &ports[res->port_id];
8529 /** Check if the port is not started **/
8530 if (port->port_status != RTE_PORT_STOPPED) {
8531 printf("Please stop port %d first\n", res->port_id);
8535 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8536 ret = parse_flexbytes(res->mask,
8538 RTE_ETH_FDIR_MAX_FLEXLEN);
8540 printf("error: Cannot parse mask input.\n");
8543 if (!strcmp(res->flow_type, "all")) {
8544 for (i = RTE_ETH_FLOW_TYPE_UDPV4;
8545 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8547 flex_mask.flow_type = i;
8548 fdir_set_flex_mask(res->port_id, &flex_mask);
8550 cmd_reconfig_device_queue(res->port_id, 1, 0);
8553 flex_mask.flow_type = str2flowtype(res->flow_type);
8554 fdir_set_flex_mask(res->port_id, &flex_mask);
8555 cmd_reconfig_device_queue(res->port_id, 1, 1);
8558 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8559 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8560 flow_director_flexmask,
8561 "flow_director_flex_mask");
8562 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8563 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8565 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8568 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8569 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8571 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8572 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8573 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8574 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8577 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8578 .f = cmd_flow_director_flex_mask_parsed,
8580 .help_str = "set flow director's flex mask on NIC",
8582 (void *)&cmd_flow_director_flexmask,
8583 (void *)&cmd_flow_director_flexmask_port_id,
8584 (void *)&cmd_flow_director_flexmask_flow,
8585 (void *)&cmd_flow_director_flexmask_flow_type,
8586 (void *)&cmd_flow_director_flexmask_mask,
8591 /* *** deal with flow director flexible payload configuration *** */
8592 struct cmd_flow_director_flexpayload_result {
8593 cmdline_fixed_string_t flow_director_flexpayload;
8595 cmdline_fixed_string_t payload_layer;
8596 cmdline_fixed_string_t payload_cfg;
8600 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8603 const char *p, *p0 = q_arg;
8605 unsigned long int_fld;
8606 char *str_fld[max_num];
8611 p = strchr(p0, '(');
8615 p0 = strchr(p, ')');
8620 if (size >= sizeof(s))
8623 snprintf(s, sizeof(s), "%.*s", size, p);
8624 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8625 if (ret < 0 || ret > max_num)
8627 for (i = 0; i < ret; i++) {
8629 int_fld = strtoul(str_fld[i], &end, 0);
8630 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8632 offsets[i] = (uint16_t)int_fld;
8638 cmd_flow_director_flxpld_parsed(void *parsed_result,
8639 __attribute__((unused)) struct cmdline *cl,
8640 __attribute__((unused)) void *data)
8642 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8643 struct rte_eth_flex_payload_cfg flex_cfg;
8644 struct rte_port *port;
8647 if (res->port_id > nb_ports) {
8648 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8652 port = &ports[res->port_id];
8653 /** Check if the port is not started **/
8654 if (port->port_status != RTE_PORT_STOPPED) {
8655 printf("Please stop port %d first\n", res->port_id);
8659 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8661 if (!strcmp(res->payload_layer, "l2"))
8662 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8663 else if (!strcmp(res->payload_layer, "l3"))
8664 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8665 else if (!strcmp(res->payload_layer, "l4"))
8666 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8668 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8669 RTE_ETH_FDIR_MAX_FLEXLEN);
8671 printf("error: Cannot parse flex payload input.\n");
8675 fdir_set_flex_payload(res->port_id, &flex_cfg);
8676 cmd_reconfig_device_queue(res->port_id, 1, 1);
8679 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8680 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8681 flow_director_flexpayload,
8682 "flow_director_flex_payload");
8683 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8684 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8686 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8687 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8688 payload_layer, "l2#l3#l4");
8689 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8693 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8694 .f = cmd_flow_director_flxpld_parsed,
8696 .help_str = "set flow director's flex payload on NIC",
8698 (void *)&cmd_flow_director_flexpayload,
8699 (void *)&cmd_flow_director_flexpayload_port_id,
8700 (void *)&cmd_flow_director_flexpayload_payload_layer,
8701 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8706 /* *** Classification Filters Control *** */
8707 /* *** Get symmetric hash enable per port *** */
8708 struct cmd_get_sym_hash_ena_per_port_result {
8709 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8714 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8715 __rte_unused struct cmdline *cl,
8716 __rte_unused void *data)
8718 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8719 struct rte_eth_hash_filter_info info;
8722 if (rte_eth_dev_filter_supported(res->port_id,
8723 RTE_ETH_FILTER_HASH) < 0) {
8724 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8729 memset(&info, 0, sizeof(info));
8730 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8731 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8732 RTE_ETH_FILTER_GET, &info);
8735 printf("Cannot get symmetric hash enable per port "
8736 "on port %u\n", res->port_id);
8740 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8741 "enabled" : "disabled", res->port_id);
8744 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8745 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8746 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8747 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8748 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8751 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8752 .f = cmd_get_sym_hash_per_port_parsed,
8754 .help_str = "get_sym_hash_ena_per_port port_id",
8756 (void *)&cmd_get_sym_hash_ena_per_port_all,
8757 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8762 /* *** Set symmetric hash enable per port *** */
8763 struct cmd_set_sym_hash_ena_per_port_result {
8764 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8765 cmdline_fixed_string_t enable;
8770 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8771 __rte_unused struct cmdline *cl,
8772 __rte_unused void *data)
8774 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8775 struct rte_eth_hash_filter_info info;
8778 if (rte_eth_dev_filter_supported(res->port_id,
8779 RTE_ETH_FILTER_HASH) < 0) {
8780 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8785 memset(&info, 0, sizeof(info));
8786 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8787 if (!strcmp(res->enable, "enable"))
8788 info.info.enable = 1;
8789 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8790 RTE_ETH_FILTER_SET, &info);
8792 printf("Cannot set symmetric hash enable per port on "
8793 "port %u\n", res->port_id);
8796 printf("Symmetric hash has been set to %s on port %u\n",
8797 res->enable, res->port_id);
8800 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8801 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8802 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8803 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8804 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8806 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8807 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8808 enable, "enable#disable");
8810 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8811 .f = cmd_set_sym_hash_per_port_parsed,
8813 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8815 (void *)&cmd_set_sym_hash_ena_per_port_all,
8816 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8817 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8822 /* Get global config of hash function */
8823 struct cmd_get_hash_global_config_result {
8824 cmdline_fixed_string_t get_hash_global_config;
8829 flowtype_to_str(enum rte_eth_flow_type ftype)
8834 enum rte_eth_flow_type ftype;
8836 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8837 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8838 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8839 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8840 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8841 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8842 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8843 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8844 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8845 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8848 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8849 if (ftype_table[i].ftype == ftype)
8850 return ftype_table[i].str;
8857 cmd_get_hash_global_config_parsed(void *parsed_result,
8858 __rte_unused struct cmdline *cl,
8859 __rte_unused void *data)
8861 struct cmd_get_hash_global_config_result *res = parsed_result;
8862 struct rte_eth_hash_filter_info info;
8863 uint32_t idx, offset, i;
8867 if (rte_eth_dev_filter_supported(res->port_id,
8868 RTE_ETH_FILTER_HASH) < 0) {
8869 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8874 memset(&info, 0, sizeof(info));
8875 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8876 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8877 RTE_ETH_FILTER_GET, &info);
8879 printf("Cannot get hash global configurations by port %d\n",
8884 switch (info.info.global_conf.hash_func) {
8885 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8886 printf("Hash function is Toeplitz\n");
8888 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8889 printf("Hash function is Simple XOR\n");
8892 printf("Unknown hash function\n");
8896 for (i = 0; i < RTE_ETH_FLOW_TYPE_MAX; i++) {
8897 idx = i / UINT32_BIT;
8898 offset = i % UINT32_BIT;
8899 if (!(info.info.global_conf.valid_bit_mask[idx] &
8902 str = flowtype_to_str((enum rte_eth_flow_type)i);
8905 printf("Symmetric hash is %s globally for flow type %s "
8907 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8908 (1UL << offset)) ? "enabled" : "disabled"), str,
8913 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8914 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8915 get_hash_global_config, "get_hash_global_config");
8916 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8917 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8920 cmdline_parse_inst_t cmd_get_hash_global_config = {
8921 .f = cmd_get_hash_global_config_parsed,
8923 .help_str = "get_hash_global_config port_id",
8925 (void *)&cmd_get_hash_global_config_all,
8926 (void *)&cmd_get_hash_global_config_port_id,
8931 /* Set global config of hash function */
8932 struct cmd_set_hash_global_config_result {
8933 cmdline_fixed_string_t set_hash_global_config;
8935 cmdline_fixed_string_t hash_func;
8936 cmdline_fixed_string_t flow_type;
8937 cmdline_fixed_string_t enable;
8941 cmd_set_hash_global_config_parsed(void *parsed_result,
8942 __rte_unused struct cmdline *cl,
8943 __rte_unused void *data)
8945 struct cmd_set_hash_global_config_result *res = parsed_result;
8946 struct rte_eth_hash_filter_info info;
8947 uint32_t ftype, idx, offset;
8950 if (rte_eth_dev_filter_supported(res->port_id,
8951 RTE_ETH_FILTER_HASH) < 0) {
8952 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8956 memset(&info, 0, sizeof(info));
8957 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8958 if (!strcmp(res->hash_func, "toeplitz"))
8959 info.info.global_conf.hash_func =
8960 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8961 else if (!strcmp(res->hash_func, "simple_xor"))
8962 info.info.global_conf.hash_func =
8963 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8964 else if (!strcmp(res->hash_func, "default"))
8965 info.info.global_conf.hash_func =
8966 RTE_ETH_HASH_FUNCTION_DEFAULT;
8968 ftype = str2flowtype(res->flow_type);
8969 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8970 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8971 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8972 if (!strcmp(res->enable, "enable"))
8973 info.info.global_conf.sym_hash_enable_mask[idx] |=
8975 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8976 RTE_ETH_FILTER_SET, &info);
8978 printf("Cannot set global hash configurations by port %d\n",
8981 printf("Global hash configurations have been set "
8982 "succcessfully by port %d\n", res->port_id);
8985 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8986 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8987 set_hash_global_config, "set_hash_global_config");
8988 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8989 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8991 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8992 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8993 hash_func, "toeplitz#simple_xor#default");
8994 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8995 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8997 "ip4#ip4-frag#tcp4#udp4#sctp4#ip6#ip6-frag#tcp6#udp6#sctp6");
8998 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8999 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9000 enable, "enable#disable");
9002 cmdline_parse_inst_t cmd_set_hash_global_config = {
9003 .f = cmd_set_hash_global_config_parsed,
9005 .help_str = "set_hash_global_config port_id "
9006 "toeplitz|simple_xor|default "
9007 "ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6 "
9010 (void *)&cmd_set_hash_global_config_all,
9011 (void *)&cmd_set_hash_global_config_port_id,
9012 (void *)&cmd_set_hash_global_config_hash_func,
9013 (void *)&cmd_set_hash_global_config_flow_type,
9014 (void *)&cmd_set_hash_global_config_enable,
9019 /* ******************************************************************************** */
9021 /* list of instructions */
9022 cmdline_parse_ctx_t main_ctx[] = {
9023 (cmdline_parse_inst_t *)&cmd_help_brief,
9024 (cmdline_parse_inst_t *)&cmd_help_long,
9025 (cmdline_parse_inst_t *)&cmd_quit,
9026 (cmdline_parse_inst_t *)&cmd_showport,
9027 (cmdline_parse_inst_t *)&cmd_showportall,
9028 (cmdline_parse_inst_t *)&cmd_showcfg,
9029 (cmdline_parse_inst_t *)&cmd_start,
9030 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9031 (cmdline_parse_inst_t *)&cmd_set_link_up,
9032 (cmdline_parse_inst_t *)&cmd_set_link_down,
9033 (cmdline_parse_inst_t *)&cmd_reset,
9034 (cmdline_parse_inst_t *)&cmd_set_numbers,
9035 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9036 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9037 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9038 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9039 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9040 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9041 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9042 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9043 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9044 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9045 (cmdline_parse_inst_t *)&cmd_set_link_check,
9046 #ifdef RTE_NIC_BYPASS
9047 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9048 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9049 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9050 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9052 #ifdef RTE_LIBRTE_PMD_BOND
9053 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9054 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9055 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9056 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9057 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9058 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9059 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9060 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9061 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9063 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9064 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9065 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9066 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9067 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9068 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9069 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9070 (cmdline_parse_inst_t *)&cmd_csum_set,
9071 (cmdline_parse_inst_t *)&cmd_csum_show,
9072 (cmdline_parse_inst_t *)&cmd_tso_set,
9073 (cmdline_parse_inst_t *)&cmd_tso_show,
9074 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9075 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9076 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9077 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9078 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9079 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9080 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9081 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9082 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9083 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9084 (cmdline_parse_inst_t *)&cmd_config_dcb,
9085 (cmdline_parse_inst_t *)&cmd_read_reg,
9086 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9087 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9088 (cmdline_parse_inst_t *)&cmd_write_reg,
9089 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9090 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9091 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9092 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
9093 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
9094 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
9095 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
9096 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
9097 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
9098 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
9099 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
9100 (cmdline_parse_inst_t *)&cmd_stop,
9101 (cmdline_parse_inst_t *)&cmd_mac_addr,
9102 (cmdline_parse_inst_t *)&cmd_set_qmap,
9103 (cmdline_parse_inst_t *)&cmd_operate_port,
9104 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9105 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9106 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9107 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9108 (cmdline_parse_inst_t *)&cmd_config_mtu,
9109 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9110 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9111 (cmdline_parse_inst_t *)&cmd_config_rss,
9112 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9113 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9114 (cmdline_parse_inst_t *)&cmd_showport_reta,
9115 (cmdline_parse_inst_t *)&cmd_config_burst,
9116 (cmdline_parse_inst_t *)&cmd_config_thresh,
9117 (cmdline_parse_inst_t *)&cmd_config_threshold,
9118 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9119 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9120 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9121 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9122 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9123 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9124 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9125 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9126 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9127 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9128 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9129 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9130 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9131 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9132 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9133 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9134 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9135 (cmdline_parse_inst_t *)&cmd_dump,
9136 (cmdline_parse_inst_t *)&cmd_dump_one,
9137 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9138 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
9139 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
9140 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
9141 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
9142 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
9143 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
9144 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
9145 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
9146 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
9147 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
9148 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
9149 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
9150 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9151 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9152 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9153 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9154 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9155 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9156 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9157 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9158 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9159 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9163 /* prompt function, called from main on MASTER lcore */
9169 /* initialize non-constant commands */
9170 cmd_set_fwd_mode_init();
9172 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9176 cmdline_interact(cl);
9177 cmdline_stdin_exit(cl);
9181 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9183 if (id < nb_ports) {
9184 /* check if need_reconfig has been set to 1 */
9185 if (ports[id].need_reconfig == 0)
9186 ports[id].need_reconfig = dev;
9187 /* check if need_reconfig_queues has been set to 1 */
9188 if (ports[id].need_reconfig_queues == 0)
9189 ports[id].need_reconfig_queues = queue;
9193 for (pid = 0; pid < nb_ports; pid++) {
9194 /* check if need_reconfig has been set to 1 */
9195 if (ports[pid].need_reconfig == 0)
9196 ports[pid].need_reconfig = dev;
9197 /* check if need_reconfig_queues has been set to 1 */
9198 if (ports[pid].need_reconfig_queues == 0)
9199 ports[pid].need_reconfig_queues = queue;
9204 #ifdef RTE_NIC_BYPASS
9206 bypass_is_supported(portid_t port_id)
9208 struct rte_port *port;
9209 struct rte_pci_id *pci_id;
9211 if (port_id >= nb_ports) {
9212 printf("\tPort id must be less than %d.\n", nb_ports);
9216 /* Get the device id. */
9217 port = &ports[port_id];
9218 pci_id = &port->dev_info.pci_dev->id;
9220 /* Check if NIC supports bypass. */
9221 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9225 printf("\tBypass not supported for port_id = %d.\n", port_id);