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 cmd_csum_parsed(void *parsed_result,
2896 __attribute__((unused)) struct cmdline *cl,
2897 __attribute__((unused)) void *data)
2899 struct cmd_csum_result *res = parsed_result;
2901 uint16_t ol_flags, mask = 0;
2902 struct rte_eth_dev_info dev_info;
2904 if (port_id_is_invalid(res->port_id)) {
2905 printf("invalid port %d\n", res->port_id);
2909 if (!strcmp(res->mode, "set")) {
2911 if (!strcmp(res->hwsw, "hw"))
2914 if (!strcmp(res->proto, "ip")) {
2915 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2916 } else if (!strcmp(res->proto, "udp")) {
2917 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2918 } else if (!strcmp(res->proto, "tcp")) {
2919 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2920 } else if (!strcmp(res->proto, "sctp")) {
2921 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2922 } else if (!strcmp(res->proto, "vxlan")) {
2923 mask = TESTPMD_TX_OFFLOAD_VXLAN_CKSUM;
2927 ports[res->port_id].tx_ol_flags |= mask;
2929 ports[res->port_id].tx_ol_flags &= (~mask);
2932 ol_flags = ports[res->port_id].tx_ol_flags;
2933 printf("IP checksum offload is %s\n",
2934 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2935 printf("UDP checksum offload is %s\n",
2936 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2937 printf("TCP checksum offload is %s\n",
2938 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2939 printf("SCTP checksum offload is %s\n",
2940 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2941 printf("VxLAN checksum offload is %s\n",
2942 (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw");
2944 /* display warnings if configuration is not supported by the NIC */
2945 rte_eth_dev_info_get(res->port_id, &dev_info);
2946 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2947 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2948 printf("Warning: hardware IP checksum enabled but not "
2949 "supported by port %d\n", res->port_id);
2951 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2952 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2953 printf("Warning: hardware UDP checksum enabled but not "
2954 "supported by port %d\n", res->port_id);
2956 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2957 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2958 printf("Warning: hardware TCP checksum enabled but not "
2959 "supported by port %d\n", res->port_id);
2961 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2962 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2963 printf("Warning: hardware SCTP checksum enabled but not "
2964 "supported by port %d\n", res->port_id);
2968 cmdline_parse_token_string_t cmd_csum_csum =
2969 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2971 cmdline_parse_token_string_t cmd_csum_mode =
2972 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2974 cmdline_parse_token_string_t cmd_csum_proto =
2975 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2976 proto, "ip#tcp#udp#sctp#vxlan");
2977 cmdline_parse_token_string_t cmd_csum_hwsw =
2978 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2980 cmdline_parse_token_num_t cmd_csum_portid =
2981 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
2984 cmdline_parse_inst_t cmd_csum_set = {
2985 .f = cmd_csum_parsed,
2987 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
2988 "using csum forward engine: csum set ip|tcp|udp|sctp|vxlan hw|sw <port>",
2990 (void *)&cmd_csum_csum,
2991 (void *)&cmd_csum_mode,
2992 (void *)&cmd_csum_proto,
2993 (void *)&cmd_csum_hwsw,
2994 (void *)&cmd_csum_portid,
2999 cmdline_parse_token_string_t cmd_csum_mode_show =
3000 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3003 cmdline_parse_inst_t cmd_csum_show = {
3004 .f = cmd_csum_parsed,
3006 .help_str = "show checksum offload configuration: csum show <port>",
3008 (void *)&cmd_csum_csum,
3009 (void *)&cmd_csum_mode_show,
3010 (void *)&cmd_csum_portid,
3015 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3016 struct cmd_tso_set_result {
3017 cmdline_fixed_string_t tso;
3018 cmdline_fixed_string_t mode;
3024 cmd_tso_set_parsed(void *parsed_result,
3025 __attribute__((unused)) struct cmdline *cl,
3026 __attribute__((unused)) void *data)
3028 struct cmd_tso_set_result *res = parsed_result;
3029 struct rte_eth_dev_info dev_info;
3031 if (port_id_is_invalid(res->port_id))
3034 if (!strcmp(res->mode, "set"))
3035 ports[res->port_id].tso_segsz = res->tso_segsz;
3037 if (ports[res->port_id].tso_segsz == 0)
3038 printf("TSO is disabled\n");
3040 printf("TSO segment size is %d\n",
3041 ports[res->port_id].tso_segsz);
3043 /* display warnings if configuration is not supported by the NIC */
3044 rte_eth_dev_info_get(res->port_id, &dev_info);
3045 if ((ports[res->port_id].tso_segsz != 0) &&
3046 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3047 printf("Warning: TSO enabled but not "
3048 "supported by port %d\n", res->port_id);
3052 cmdline_parse_token_string_t cmd_tso_set_tso =
3053 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3055 cmdline_parse_token_string_t cmd_tso_set_mode =
3056 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3058 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3059 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3061 cmdline_parse_token_num_t cmd_tso_set_portid =
3062 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3065 cmdline_parse_inst_t cmd_tso_set = {
3066 .f = cmd_tso_set_parsed,
3068 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3069 "tso set <tso_segsz> <port>",
3071 (void *)&cmd_tso_set_tso,
3072 (void *)&cmd_tso_set_mode,
3073 (void *)&cmd_tso_set_tso_segsz,
3074 (void *)&cmd_tso_set_portid,
3079 cmdline_parse_token_string_t cmd_tso_show_mode =
3080 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3084 cmdline_parse_inst_t cmd_tso_show = {
3085 .f = cmd_tso_set_parsed,
3087 .help_str = "Show TSO segment size for csum engine: "
3090 (void *)&cmd_tso_set_tso,
3091 (void *)&cmd_tso_show_mode,
3092 (void *)&cmd_tso_set_portid,
3097 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3098 struct cmd_set_flush_rx {
3099 cmdline_fixed_string_t set;
3100 cmdline_fixed_string_t flush_rx;
3101 cmdline_fixed_string_t mode;
3105 cmd_set_flush_rx_parsed(void *parsed_result,
3106 __attribute__((unused)) struct cmdline *cl,
3107 __attribute__((unused)) void *data)
3109 struct cmd_set_flush_rx *res = parsed_result;
3110 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3113 cmdline_parse_token_string_t cmd_setflushrx_set =
3114 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3116 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3117 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3118 flush_rx, "flush_rx");
3119 cmdline_parse_token_string_t cmd_setflushrx_mode =
3120 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3124 cmdline_parse_inst_t cmd_set_flush_rx = {
3125 .f = cmd_set_flush_rx_parsed,
3126 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3129 (void *)&cmd_setflushrx_set,
3130 (void *)&cmd_setflushrx_flush_rx,
3131 (void *)&cmd_setflushrx_mode,
3136 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3137 struct cmd_set_link_check {
3138 cmdline_fixed_string_t set;
3139 cmdline_fixed_string_t link_check;
3140 cmdline_fixed_string_t mode;
3144 cmd_set_link_check_parsed(void *parsed_result,
3145 __attribute__((unused)) struct cmdline *cl,
3146 __attribute__((unused)) void *data)
3148 struct cmd_set_link_check *res = parsed_result;
3149 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3152 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3153 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3155 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3156 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3157 link_check, "link_check");
3158 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3159 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3163 cmdline_parse_inst_t cmd_set_link_check = {
3164 .f = cmd_set_link_check_parsed,
3165 .help_str = "set link_check on|off: enable/disable link status check "
3166 "when starting/stopping a port",
3169 (void *)&cmd_setlinkcheck_set,
3170 (void *)&cmd_setlinkcheck_link_check,
3171 (void *)&cmd_setlinkcheck_mode,
3176 #ifdef RTE_NIC_BYPASS
3177 /* *** SET NIC BYPASS MODE *** */
3178 struct cmd_set_bypass_mode_result {
3179 cmdline_fixed_string_t set;
3180 cmdline_fixed_string_t bypass;
3181 cmdline_fixed_string_t mode;
3182 cmdline_fixed_string_t value;
3187 cmd_set_bypass_mode_parsed(void *parsed_result,
3188 __attribute__((unused)) struct cmdline *cl,
3189 __attribute__((unused)) void *data)
3191 struct cmd_set_bypass_mode_result *res = parsed_result;
3192 portid_t port_id = res->port_id;
3193 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3195 if (!bypass_is_supported(port_id))
3198 if (!strcmp(res->value, "bypass"))
3199 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3200 else if (!strcmp(res->value, "isolate"))
3201 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3203 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3205 /* Set the bypass mode for the relevant port. */
3206 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3207 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3211 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3212 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3214 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3215 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3217 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3218 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3220 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3221 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3222 value, "normal#bypass#isolate");
3223 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3224 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3227 cmdline_parse_inst_t cmd_set_bypass_mode = {
3228 .f = cmd_set_bypass_mode_parsed,
3229 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3230 "Set the NIC bypass mode for port_id",
3233 (void *)&cmd_setbypass_mode_set,
3234 (void *)&cmd_setbypass_mode_bypass,
3235 (void *)&cmd_setbypass_mode_mode,
3236 (void *)&cmd_setbypass_mode_value,
3237 (void *)&cmd_setbypass_mode_port,
3242 /* *** SET NIC BYPASS EVENT *** */
3243 struct cmd_set_bypass_event_result {
3244 cmdline_fixed_string_t set;
3245 cmdline_fixed_string_t bypass;
3246 cmdline_fixed_string_t event;
3247 cmdline_fixed_string_t event_value;
3248 cmdline_fixed_string_t mode;
3249 cmdline_fixed_string_t mode_value;
3254 cmd_set_bypass_event_parsed(void *parsed_result,
3255 __attribute__((unused)) struct cmdline *cl,
3256 __attribute__((unused)) void *data)
3259 struct cmd_set_bypass_event_result *res = parsed_result;
3260 portid_t port_id = res->port_id;
3261 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3262 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3264 if (!bypass_is_supported(port_id))
3267 if (!strcmp(res->event_value, "timeout"))
3268 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3269 else if (!strcmp(res->event_value, "os_on"))
3270 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3271 else if (!strcmp(res->event_value, "os_off"))
3272 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3273 else if (!strcmp(res->event_value, "power_on"))
3274 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3275 else if (!strcmp(res->event_value, "power_off"))
3276 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3278 bypass_event = RTE_BYPASS_EVENT_NONE;
3280 if (!strcmp(res->mode_value, "bypass"))
3281 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3282 else if (!strcmp(res->mode_value, "isolate"))
3283 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3285 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3287 /* Set the watchdog timeout. */
3288 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3291 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3292 (rc = rte_eth_dev_wd_timeout_store(port_id,
3293 bypass_timeout)) != 0) {
3294 printf("Failed to set timeout value %u "
3295 "for port %d, errto code: %d.\n",
3296 bypass_timeout, port_id, rc);
3300 /* Set the bypass event to transition to bypass mode. */
3301 if (0 != rte_eth_dev_bypass_event_store(port_id,
3302 bypass_event, bypass_mode)) {
3303 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3308 cmdline_parse_token_string_t cmd_setbypass_event_set =
3309 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3311 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3312 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3314 cmdline_parse_token_string_t cmd_setbypass_event_event =
3315 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3317 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3318 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3319 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3320 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3321 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3323 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3324 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3325 mode_value, "normal#bypass#isolate");
3326 cmdline_parse_token_num_t cmd_setbypass_event_port =
3327 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3330 cmdline_parse_inst_t cmd_set_bypass_event = {
3331 .f = cmd_set_bypass_event_parsed,
3332 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3333 "mode (normal|bypass|isolate) (port_id): "
3334 "Set the NIC bypass event mode for port_id",
3337 (void *)&cmd_setbypass_event_set,
3338 (void *)&cmd_setbypass_event_bypass,
3339 (void *)&cmd_setbypass_event_event,
3340 (void *)&cmd_setbypass_event_event_value,
3341 (void *)&cmd_setbypass_event_mode,
3342 (void *)&cmd_setbypass_event_mode_value,
3343 (void *)&cmd_setbypass_event_port,
3349 /* *** SET NIC BYPASS TIMEOUT *** */
3350 struct cmd_set_bypass_timeout_result {
3351 cmdline_fixed_string_t set;
3352 cmdline_fixed_string_t bypass;
3353 cmdline_fixed_string_t timeout;
3354 cmdline_fixed_string_t value;
3358 cmd_set_bypass_timeout_parsed(void *parsed_result,
3359 __attribute__((unused)) struct cmdline *cl,
3360 __attribute__((unused)) void *data)
3362 struct cmd_set_bypass_timeout_result *res = parsed_result;
3364 if (!strcmp(res->value, "1.5"))
3365 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3366 else if (!strcmp(res->value, "2"))
3367 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3368 else if (!strcmp(res->value, "3"))
3369 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3370 else if (!strcmp(res->value, "4"))
3371 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3372 else if (!strcmp(res->value, "8"))
3373 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3374 else if (!strcmp(res->value, "16"))
3375 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3376 else if (!strcmp(res->value, "32"))
3377 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3379 bypass_timeout = RTE_BYPASS_TMT_OFF;
3382 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3383 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3385 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3386 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3388 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3389 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3390 timeout, "timeout");
3391 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3392 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3393 value, "0#1.5#2#3#4#8#16#32");
3395 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3396 .f = cmd_set_bypass_timeout_parsed,
3397 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3398 "Set the NIC bypass watchdog timeout",
3401 (void *)&cmd_setbypass_timeout_set,
3402 (void *)&cmd_setbypass_timeout_bypass,
3403 (void *)&cmd_setbypass_timeout_timeout,
3404 (void *)&cmd_setbypass_timeout_value,
3409 /* *** SHOW NIC BYPASS MODE *** */
3410 struct cmd_show_bypass_config_result {
3411 cmdline_fixed_string_t show;
3412 cmdline_fixed_string_t bypass;
3413 cmdline_fixed_string_t config;
3418 cmd_show_bypass_config_parsed(void *parsed_result,
3419 __attribute__((unused)) struct cmdline *cl,
3420 __attribute__((unused)) void *data)
3422 struct cmd_show_bypass_config_result *res = parsed_result;
3423 uint32_t event_mode;
3424 uint32_t bypass_mode;
3425 portid_t port_id = res->port_id;
3426 uint32_t timeout = bypass_timeout;
3429 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3430 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3431 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3432 {"UNKNOWN", "normal", "bypass", "isolate"};
3433 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3440 int num_events = (sizeof events) / (sizeof events[0]);
3442 if (!bypass_is_supported(port_id))
3445 /* Display the bypass mode.*/
3446 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3447 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3451 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3452 bypass_mode = RTE_BYPASS_MODE_NONE;
3454 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3457 /* Display the bypass timeout.*/
3458 if (!RTE_BYPASS_TMT_VALID(timeout))
3459 timeout = RTE_BYPASS_TMT_OFF;
3461 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3463 /* Display the bypass events and associated modes. */
3464 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3466 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3467 printf("\tFailed to get bypass mode for event = %s\n",
3470 if (!RTE_BYPASS_MODE_VALID(event_mode))
3471 event_mode = RTE_BYPASS_MODE_NONE;
3473 printf("\tbypass event: %-16s = %s\n", events[i],
3479 cmdline_parse_token_string_t cmd_showbypass_config_show =
3480 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3482 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3483 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3485 cmdline_parse_token_string_t cmd_showbypass_config_config =
3486 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3488 cmdline_parse_token_num_t cmd_showbypass_config_port =
3489 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3492 cmdline_parse_inst_t cmd_show_bypass_config = {
3493 .f = cmd_show_bypass_config_parsed,
3494 .help_str = "show bypass config (port_id): "
3495 "Show the NIC bypass config for port_id",
3498 (void *)&cmd_showbypass_config_show,
3499 (void *)&cmd_showbypass_config_bypass,
3500 (void *)&cmd_showbypass_config_config,
3501 (void *)&cmd_showbypass_config_port,
3507 #ifdef RTE_LIBRTE_PMD_BOND
3508 /* *** SET BONDING MODE *** */
3509 struct cmd_set_bonding_mode_result {
3510 cmdline_fixed_string_t set;
3511 cmdline_fixed_string_t bonding;
3512 cmdline_fixed_string_t mode;
3517 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3518 __attribute__((unused)) struct cmdline *cl,
3519 __attribute__((unused)) void *data)
3521 struct cmd_set_bonding_mode_result *res = parsed_result;
3522 portid_t port_id = res->port_id;
3524 /* Set the bonding mode for the relevant port. */
3525 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3526 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3529 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3530 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3532 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3533 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3534 bonding, "bonding");
3535 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3536 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3538 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3539 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3541 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3542 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3545 cmdline_parse_inst_t cmd_set_bonding_mode = {
3546 .f = cmd_set_bonding_mode_parsed,
3547 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3550 (void *) &cmd_setbonding_mode_set,
3551 (void *) &cmd_setbonding_mode_bonding,
3552 (void *) &cmd_setbonding_mode_mode,
3553 (void *) &cmd_setbonding_mode_value,
3554 (void *) &cmd_setbonding_mode_port,
3559 /* *** SET BALANCE XMIT POLICY *** */
3560 struct cmd_set_bonding_balance_xmit_policy_result {
3561 cmdline_fixed_string_t set;
3562 cmdline_fixed_string_t bonding;
3563 cmdline_fixed_string_t balance_xmit_policy;
3565 cmdline_fixed_string_t policy;
3568 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3569 __attribute__((unused)) struct cmdline *cl,
3570 __attribute__((unused)) void *data)
3572 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3573 portid_t port_id = res->port_id;
3576 if (!strcmp(res->policy, "l2")) {
3577 policy = BALANCE_XMIT_POLICY_LAYER2;
3578 } else if (!strcmp(res->policy, "l23")) {
3579 policy = BALANCE_XMIT_POLICY_LAYER23;
3580 } else if (!strcmp(res->policy, "l34")) {
3581 policy = BALANCE_XMIT_POLICY_LAYER34;
3583 printf("\t Invalid xmit policy selection");
3587 /* Set the bonding mode for the relevant port. */
3588 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3589 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3594 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3595 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3597 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3598 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3599 bonding, "bonding");
3600 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3601 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3602 balance_xmit_policy, "balance_xmit_policy");
3603 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3604 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3606 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3607 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3608 policy, "l2#l23#l34");
3610 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3611 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3612 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3615 (void *)&cmd_setbonding_balance_xmit_policy_set,
3616 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3617 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3618 (void *)&cmd_setbonding_balance_xmit_policy_port,
3619 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3624 /* *** SHOW NIC BONDING CONFIGURATION *** */
3625 struct cmd_show_bonding_config_result {
3626 cmdline_fixed_string_t show;
3627 cmdline_fixed_string_t bonding;
3628 cmdline_fixed_string_t config;
3632 static void cmd_show_bonding_config_parsed(void *parsed_result,
3633 __attribute__((unused)) struct cmdline *cl,
3634 __attribute__((unused)) void *data)
3636 struct cmd_show_bonding_config_result *res = parsed_result;
3638 uint8_t slaves[RTE_MAX_ETHPORTS];
3639 int num_slaves, num_active_slaves;
3642 portid_t port_id = res->port_id;
3644 /* Display the bonding mode.*/
3645 bonding_mode = rte_eth_bond_mode_get(port_id);
3646 if (bonding_mode < 0) {
3647 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3650 printf("\tBonding mode: %d\n", bonding_mode);
3652 if (bonding_mode == BONDING_MODE_BALANCE) {
3653 int balance_xmit_policy;
3655 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3656 if (balance_xmit_policy < 0) {
3657 printf("\tFailed to get balance xmit policy for port = %d\n",
3661 printf("\tBalance Xmit Policy: ");
3663 switch (balance_xmit_policy) {
3664 case BALANCE_XMIT_POLICY_LAYER2:
3665 printf("BALANCE_XMIT_POLICY_LAYER2");
3667 case BALANCE_XMIT_POLICY_LAYER23:
3668 printf("BALANCE_XMIT_POLICY_LAYER23");
3670 case BALANCE_XMIT_POLICY_LAYER34:
3671 printf("BALANCE_XMIT_POLICY_LAYER34");
3678 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3680 if (num_slaves < 0) {
3681 printf("\tFailed to get slave list for port = %d\n", port_id);
3684 if (num_slaves > 0) {
3685 printf("\tSlaves (%d): [", num_slaves);
3686 for (i = 0; i < num_slaves - 1; i++)
3687 printf("%d ", slaves[i]);
3689 printf("%d]\n", slaves[num_slaves - 1]);
3691 printf("\tSlaves: []\n");
3695 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3698 if (num_active_slaves < 0) {
3699 printf("\tFailed to get active slave list for port = %d\n", port_id);
3702 if (num_active_slaves > 0) {
3703 printf("\tActive Slaves (%d): [", num_active_slaves);
3704 for (i = 0; i < num_active_slaves - 1; i++)
3705 printf("%d ", slaves[i]);
3707 printf("%d]\n", slaves[num_active_slaves - 1]);
3710 printf("\tActive Slaves: []\n");
3714 primary_id = rte_eth_bond_primary_get(port_id);
3715 if (primary_id < 0) {
3716 printf("\tFailed to get primary slave for port = %d\n", port_id);
3719 printf("\tPrimary: [%d]\n", primary_id);
3723 cmdline_parse_token_string_t cmd_showbonding_config_show =
3724 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3726 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3727 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3728 bonding, "bonding");
3729 cmdline_parse_token_string_t cmd_showbonding_config_config =
3730 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3732 cmdline_parse_token_num_t cmd_showbonding_config_port =
3733 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3736 cmdline_parse_inst_t cmd_show_bonding_config = {
3737 .f = cmd_show_bonding_config_parsed,
3738 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3741 (void *)&cmd_showbonding_config_show,
3742 (void *)&cmd_showbonding_config_bonding,
3743 (void *)&cmd_showbonding_config_config,
3744 (void *)&cmd_showbonding_config_port,
3749 /* *** SET BONDING PRIMARY *** */
3750 struct cmd_set_bonding_primary_result {
3751 cmdline_fixed_string_t set;
3752 cmdline_fixed_string_t bonding;
3753 cmdline_fixed_string_t primary;
3758 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3759 __attribute__((unused)) struct cmdline *cl,
3760 __attribute__((unused)) void *data)
3762 struct cmd_set_bonding_primary_result *res = parsed_result;
3763 portid_t master_port_id = res->port_id;
3764 portid_t slave_port_id = res->slave_id;
3766 /* Set the primary slave for a bonded device. */
3767 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3768 printf("\t Failed to set primary slave for port = %d.\n",
3775 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3776 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3778 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3779 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3780 bonding, "bonding");
3781 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3782 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3783 primary, "primary");
3784 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3785 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3787 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3788 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3791 cmdline_parse_inst_t cmd_set_bonding_primary = {
3792 .f = cmd_set_bonding_primary_parsed,
3793 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3796 (void *)&cmd_setbonding_primary_set,
3797 (void *)&cmd_setbonding_primary_bonding,
3798 (void *)&cmd_setbonding_primary_primary,
3799 (void *)&cmd_setbonding_primary_slave,
3800 (void *)&cmd_setbonding_primary_port,
3805 /* *** ADD SLAVE *** */
3806 struct cmd_add_bonding_slave_result {
3807 cmdline_fixed_string_t add;
3808 cmdline_fixed_string_t bonding;
3809 cmdline_fixed_string_t slave;
3814 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3815 __attribute__((unused)) struct cmdline *cl,
3816 __attribute__((unused)) void *data)
3818 struct cmd_add_bonding_slave_result *res = parsed_result;
3819 portid_t master_port_id = res->port_id;
3820 portid_t slave_port_id = res->slave_id;
3822 /* Set the primary slave for a bonded device. */
3823 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3824 printf("\t Failed to add slave %d to master port = %d.\n",
3825 slave_port_id, master_port_id);
3831 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3832 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3834 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3835 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3836 bonding, "bonding");
3837 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3838 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3840 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3841 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3843 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3844 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3847 cmdline_parse_inst_t cmd_add_bonding_slave = {
3848 .f = cmd_add_bonding_slave_parsed,
3849 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3852 (void *)&cmd_addbonding_slave_add,
3853 (void *)&cmd_addbonding_slave_bonding,
3854 (void *)&cmd_addbonding_slave_slave,
3855 (void *)&cmd_addbonding_slave_slaveid,
3856 (void *)&cmd_addbonding_slave_port,
3861 /* *** REMOVE SLAVE *** */
3862 struct cmd_remove_bonding_slave_result {
3863 cmdline_fixed_string_t remove;
3864 cmdline_fixed_string_t bonding;
3865 cmdline_fixed_string_t slave;
3870 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3871 __attribute__((unused)) struct cmdline *cl,
3872 __attribute__((unused)) void *data)
3874 struct cmd_remove_bonding_slave_result *res = parsed_result;
3875 portid_t master_port_id = res->port_id;
3876 portid_t slave_port_id = res->slave_id;
3878 /* Set the primary slave for a bonded device. */
3879 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3880 printf("\t Failed to remove slave %d from master port = %d.\n",
3881 slave_port_id, master_port_id);
3887 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3888 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3890 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3891 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3892 bonding, "bonding");
3893 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3894 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3896 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3897 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3899 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3900 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3903 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3904 .f = cmd_remove_bonding_slave_parsed,
3905 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3908 (void *)&cmd_removebonding_slave_remove,
3909 (void *)&cmd_removebonding_slave_bonding,
3910 (void *)&cmd_removebonding_slave_slave,
3911 (void *)&cmd_removebonding_slave_slaveid,
3912 (void *)&cmd_removebonding_slave_port,
3917 /* *** CREATE BONDED DEVICE *** */
3918 struct cmd_create_bonded_device_result {
3919 cmdline_fixed_string_t create;
3920 cmdline_fixed_string_t bonded;
3921 cmdline_fixed_string_t device;
3926 static int bond_dev_num = 0;
3928 static void cmd_create_bonded_device_parsed(void *parsed_result,
3929 __attribute__((unused)) struct cmdline *cl,
3930 __attribute__((unused)) void *data)
3932 struct cmd_create_bonded_device_result *res = parsed_result;
3933 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3936 if (test_done == 0) {
3937 printf("Please stop forwarding first\n");
3941 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3944 /* Create a new bonded device. */
3945 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3947 printf("\t Failed to create bonded device.\n");
3950 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3953 /* Update number of ports */
3954 nb_ports = rte_eth_dev_count();
3955 reconfig(port_id, res->socket);
3956 rte_eth_promiscuous_enable(port_id);
3961 cmdline_parse_token_string_t cmd_createbonded_device_create =
3962 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3964 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3965 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3967 cmdline_parse_token_string_t cmd_createbonded_device_device =
3968 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3970 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3971 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3973 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3974 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3977 cmdline_parse_inst_t cmd_create_bonded_device = {
3978 .f = cmd_create_bonded_device_parsed,
3979 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3982 (void *)&cmd_createbonded_device_create,
3983 (void *)&cmd_createbonded_device_bonded,
3984 (void *)&cmd_createbonded_device_device,
3985 (void *)&cmd_createbonded_device_mode,
3986 (void *)&cmd_createbonded_device_socket,
3991 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3992 struct cmd_set_bond_mac_addr_result {
3993 cmdline_fixed_string_t set;
3994 cmdline_fixed_string_t bonding;
3995 cmdline_fixed_string_t mac_addr;
3997 struct ether_addr address;
4000 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4001 __attribute__((unused)) struct cmdline *cl,
4002 __attribute__((unused)) void *data)
4004 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4007 if (res->port_num >= nb_ports) {
4008 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4012 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4014 /* check the return value and print it if is < 0 */
4016 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4019 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4020 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4021 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4024 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4025 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4027 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4028 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4029 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4030 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4032 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4033 .f = cmd_set_bond_mac_addr_parsed,
4035 .help_str = "set bonding mac_addr (port_id) (address): ",
4037 (void *)&cmd_set_bond_mac_addr_set,
4038 (void *)&cmd_set_bond_mac_addr_bonding,
4039 (void *)&cmd_set_bond_mac_addr_mac,
4040 (void *)&cmd_set_bond_mac_addr_portnum,
4041 (void *)&cmd_set_bond_mac_addr_addr,
4047 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4048 struct cmd_set_bond_mon_period_result {
4049 cmdline_fixed_string_t set;
4050 cmdline_fixed_string_t bonding;
4051 cmdline_fixed_string_t mon_period;
4056 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4057 __attribute__((unused)) struct cmdline *cl,
4058 __attribute__((unused)) void *data)
4060 struct cmd_set_bond_mon_period_result *res = parsed_result;
4063 if (res->port_num >= nb_ports) {
4064 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4068 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4070 /* check the return value and print it if is < 0 */
4072 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4075 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4076 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4078 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4079 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4080 bonding, "bonding");
4081 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4082 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4083 mon_period, "mon_period");
4084 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4085 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4087 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4088 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4091 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4092 .f = cmd_set_bond_mon_period_parsed,
4094 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4096 (void *)&cmd_set_bond_mon_period_set,
4097 (void *)&cmd_set_bond_mon_period_bonding,
4098 (void *)&cmd_set_bond_mon_period_mon_period,
4099 (void *)&cmd_set_bond_mon_period_portnum,
4100 (void *)&cmd_set_bond_mon_period_period_ms,
4105 #endif /* RTE_LIBRTE_PMD_BOND */
4107 /* *** SET FORWARDING MODE *** */
4108 struct cmd_set_fwd_mode_result {
4109 cmdline_fixed_string_t set;
4110 cmdline_fixed_string_t fwd;
4111 cmdline_fixed_string_t mode;
4114 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4115 __attribute__((unused)) struct cmdline *cl,
4116 __attribute__((unused)) void *data)
4118 struct cmd_set_fwd_mode_result *res = parsed_result;
4120 set_pkt_forwarding_mode(res->mode);
4123 cmdline_parse_token_string_t cmd_setfwd_set =
4124 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4125 cmdline_parse_token_string_t cmd_setfwd_fwd =
4126 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4127 cmdline_parse_token_string_t cmd_setfwd_mode =
4128 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4129 "" /* defined at init */);
4131 cmdline_parse_inst_t cmd_set_fwd_mode = {
4132 .f = cmd_set_fwd_mode_parsed,
4134 .help_str = NULL, /* defined at init */
4136 (void *)&cmd_setfwd_set,
4137 (void *)&cmd_setfwd_fwd,
4138 (void *)&cmd_setfwd_mode,
4143 static void cmd_set_fwd_mode_init(void)
4146 static char token[128];
4147 static char help[256];
4148 cmdline_parse_token_string_t *token_struct;
4150 modes = list_pkt_forwarding_modes();
4151 snprintf(help, sizeof help, "set fwd %s - "
4152 "set packet forwarding mode", modes);
4153 cmd_set_fwd_mode.help_str = help;
4155 /* string token separator is # */
4156 for (c = token; *modes != '\0'; modes++)
4161 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4162 token_struct->string_data.str = token;
4165 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4166 struct cmd_set_burst_tx_retry_result {
4167 cmdline_fixed_string_t set;
4168 cmdline_fixed_string_t burst;
4169 cmdline_fixed_string_t tx;
4170 cmdline_fixed_string_t delay;
4172 cmdline_fixed_string_t retry;
4176 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4177 __attribute__((unused)) struct cmdline *cl,
4178 __attribute__((unused)) void *data)
4180 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4182 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4183 && !strcmp(res->tx, "tx")) {
4184 if (!strcmp(res->delay, "delay"))
4185 burst_tx_delay_time = res->time;
4186 if (!strcmp(res->retry, "retry"))
4187 burst_tx_retry_num = res->retry_num;
4192 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4193 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4194 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4195 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4197 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4198 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4199 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4200 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4201 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4202 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4203 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4204 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4205 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4206 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4208 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4209 .f = cmd_set_burst_tx_retry_parsed,
4210 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4212 (void *)&cmd_set_burst_tx_retry_set,
4213 (void *)&cmd_set_burst_tx_retry_burst,
4214 (void *)&cmd_set_burst_tx_retry_tx,
4215 (void *)&cmd_set_burst_tx_retry_delay,
4216 (void *)&cmd_set_burst_tx_retry_time,
4217 (void *)&cmd_set_burst_tx_retry_retry,
4218 (void *)&cmd_set_burst_tx_retry_retry_num,
4223 /* *** SET PROMISC MODE *** */
4224 struct cmd_set_promisc_mode_result {
4225 cmdline_fixed_string_t set;
4226 cmdline_fixed_string_t promisc;
4227 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4228 uint8_t port_num; /* valid if "allports" argument == 0 */
4229 cmdline_fixed_string_t mode;
4232 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4233 __attribute__((unused)) struct cmdline *cl,
4236 struct cmd_set_promisc_mode_result *res = parsed_result;
4240 if (!strcmp(res->mode, "on"))
4247 for (i = 0; i < nb_ports; i++) {
4249 rte_eth_promiscuous_enable(i);
4251 rte_eth_promiscuous_disable(i);
4256 rte_eth_promiscuous_enable(res->port_num);
4258 rte_eth_promiscuous_disable(res->port_num);
4262 cmdline_parse_token_string_t cmd_setpromisc_set =
4263 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4264 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4265 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4267 cmdline_parse_token_string_t cmd_setpromisc_portall =
4268 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4270 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4271 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4273 cmdline_parse_token_string_t cmd_setpromisc_mode =
4274 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4277 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4278 .f = cmd_set_promisc_mode_parsed,
4280 .help_str = "set promisc all on|off: set promisc mode for all ports",
4282 (void *)&cmd_setpromisc_set,
4283 (void *)&cmd_setpromisc_promisc,
4284 (void *)&cmd_setpromisc_portall,
4285 (void *)&cmd_setpromisc_mode,
4290 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4291 .f = cmd_set_promisc_mode_parsed,
4293 .help_str = "set promisc X on|off: set promisc mode on port X",
4295 (void *)&cmd_setpromisc_set,
4296 (void *)&cmd_setpromisc_promisc,
4297 (void *)&cmd_setpromisc_portnum,
4298 (void *)&cmd_setpromisc_mode,
4303 /* *** SET ALLMULTI MODE *** */
4304 struct cmd_set_allmulti_mode_result {
4305 cmdline_fixed_string_t set;
4306 cmdline_fixed_string_t allmulti;
4307 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4308 uint8_t port_num; /* valid if "allports" argument == 0 */
4309 cmdline_fixed_string_t mode;
4312 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4313 __attribute__((unused)) struct cmdline *cl,
4316 struct cmd_set_allmulti_mode_result *res = parsed_result;
4320 if (!strcmp(res->mode, "on"))
4327 for (i = 0; i < nb_ports; i++) {
4329 rte_eth_allmulticast_enable(i);
4331 rte_eth_allmulticast_disable(i);
4336 rte_eth_allmulticast_enable(res->port_num);
4338 rte_eth_allmulticast_disable(res->port_num);
4342 cmdline_parse_token_string_t cmd_setallmulti_set =
4343 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4344 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4345 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4347 cmdline_parse_token_string_t cmd_setallmulti_portall =
4348 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4350 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4351 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4353 cmdline_parse_token_string_t cmd_setallmulti_mode =
4354 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4357 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4358 .f = cmd_set_allmulti_mode_parsed,
4360 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4362 (void *)&cmd_setallmulti_set,
4363 (void *)&cmd_setallmulti_allmulti,
4364 (void *)&cmd_setallmulti_portall,
4365 (void *)&cmd_setallmulti_mode,
4370 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4371 .f = cmd_set_allmulti_mode_parsed,
4373 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4375 (void *)&cmd_setallmulti_set,
4376 (void *)&cmd_setallmulti_allmulti,
4377 (void *)&cmd_setallmulti_portnum,
4378 (void *)&cmd_setallmulti_mode,
4383 /* *** ADD/REMOVE A PKT FILTER *** */
4384 struct cmd_pkt_filter_result {
4385 cmdline_fixed_string_t pkt_filter;
4387 cmdline_fixed_string_t protocol;
4388 cmdline_fixed_string_t src;
4389 cmdline_ipaddr_t ip_src;
4391 cmdline_fixed_string_t dst;
4392 cmdline_ipaddr_t ip_dst;
4394 cmdline_fixed_string_t flexbytes;
4395 uint16_t flexbytes_value;
4396 cmdline_fixed_string_t vlan;
4398 cmdline_fixed_string_t queue;
4400 cmdline_fixed_string_t soft;
4405 cmd_pkt_filter_parsed(void *parsed_result,
4406 __attribute__((unused)) struct cmdline *cl,
4407 __attribute__((unused)) void *data)
4409 struct rte_fdir_filter fdir_filter;
4410 struct cmd_pkt_filter_result *res = parsed_result;
4412 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4414 if (res->ip_src.family == AF_INET)
4415 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4417 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4418 &(res->ip_src.addr.ipv6),
4419 sizeof(struct in6_addr));
4421 if (res->ip_dst.family == AF_INET)
4422 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4424 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4425 &(res->ip_dst.addr.ipv6),
4426 sizeof(struct in6_addr));
4428 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4429 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4431 if (!strcmp(res->protocol, "udp"))
4432 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4433 else if (!strcmp(res->protocol, "tcp"))
4434 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4435 else if (!strcmp(res->protocol, "sctp"))
4436 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4437 else /* default only IP */
4438 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4440 if (res->ip_dst.family == AF_INET6)
4441 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4443 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4445 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4446 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4448 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4449 fdir_add_signature_filter(res->port_id, res->queue_id,
4451 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4452 fdir_update_signature_filter(res->port_id, res->queue_id,
4454 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4455 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4456 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4457 fdir_add_perfect_filter(res->port_id, res->soft_id,
4459 (uint8_t) (res->queue_id < 0),
4461 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4462 fdir_update_perfect_filter(res->port_id, res->soft_id,
4464 (uint8_t) (res->queue_id < 0),
4466 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4467 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4473 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4474 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4476 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4477 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4478 protocol, "ip#tcp#udp#sctp");
4479 cmdline_parse_token_string_t cmd_pkt_filter_src =
4480 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4482 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4483 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4485 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4486 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4488 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4489 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4491 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4492 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4494 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4495 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4497 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4498 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4499 flexbytes, "flexbytes");
4500 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4501 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4502 flexbytes_value, UINT16);
4503 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4504 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4506 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4507 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4509 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4510 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4512 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4513 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4515 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4516 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4518 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4519 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4523 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4524 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4525 pkt_filter, "add_signature_filter");
4526 cmdline_parse_inst_t cmd_add_signature_filter = {
4527 .f = cmd_pkt_filter_parsed,
4529 .help_str = "add a signature filter",
4531 (void *)&cmd_pkt_filter_add_signature_filter,
4532 (void *)&cmd_pkt_filter_port_id,
4533 (void *)&cmd_pkt_filter_protocol,
4534 (void *)&cmd_pkt_filter_src,
4535 (void *)&cmd_pkt_filter_ip_src,
4536 (void *)&cmd_pkt_filter_port_src,
4537 (void *)&cmd_pkt_filter_dst,
4538 (void *)&cmd_pkt_filter_ip_dst,
4539 (void *)&cmd_pkt_filter_port_dst,
4540 (void *)&cmd_pkt_filter_flexbytes,
4541 (void *)&cmd_pkt_filter_flexbytes_value,
4542 (void *)&cmd_pkt_filter_vlan,
4543 (void *)&cmd_pkt_filter_vlan_id,
4544 (void *)&cmd_pkt_filter_queue,
4545 (void *)&cmd_pkt_filter_queue_id,
4551 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4552 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4553 pkt_filter, "upd_signature_filter");
4554 cmdline_parse_inst_t cmd_upd_signature_filter = {
4555 .f = cmd_pkt_filter_parsed,
4557 .help_str = "update a signature filter",
4559 (void *)&cmd_pkt_filter_upd_signature_filter,
4560 (void *)&cmd_pkt_filter_port_id,
4561 (void *)&cmd_pkt_filter_protocol,
4562 (void *)&cmd_pkt_filter_src,
4563 (void *)&cmd_pkt_filter_ip_src,
4564 (void *)&cmd_pkt_filter_port_src,
4565 (void *)&cmd_pkt_filter_dst,
4566 (void *)&cmd_pkt_filter_ip_dst,
4567 (void *)&cmd_pkt_filter_port_dst,
4568 (void *)&cmd_pkt_filter_flexbytes,
4569 (void *)&cmd_pkt_filter_flexbytes_value,
4570 (void *)&cmd_pkt_filter_vlan,
4571 (void *)&cmd_pkt_filter_vlan_id,
4572 (void *)&cmd_pkt_filter_queue,
4573 (void *)&cmd_pkt_filter_queue_id,
4579 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4580 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4581 pkt_filter, "rm_signature_filter");
4582 cmdline_parse_inst_t cmd_rm_signature_filter = {
4583 .f = cmd_pkt_filter_parsed,
4585 .help_str = "remove a signature filter",
4587 (void *)&cmd_pkt_filter_rm_signature_filter,
4588 (void *)&cmd_pkt_filter_port_id,
4589 (void *)&cmd_pkt_filter_protocol,
4590 (void *)&cmd_pkt_filter_src,
4591 (void *)&cmd_pkt_filter_ip_src,
4592 (void *)&cmd_pkt_filter_port_src,
4593 (void *)&cmd_pkt_filter_dst,
4594 (void *)&cmd_pkt_filter_ip_dst,
4595 (void *)&cmd_pkt_filter_port_dst,
4596 (void *)&cmd_pkt_filter_flexbytes,
4597 (void *)&cmd_pkt_filter_flexbytes_value,
4598 (void *)&cmd_pkt_filter_vlan,
4599 (void *)&cmd_pkt_filter_vlan_id,
4605 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4606 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4607 pkt_filter, "add_perfect_filter");
4608 cmdline_parse_inst_t cmd_add_perfect_filter = {
4609 .f = cmd_pkt_filter_parsed,
4611 .help_str = "add a perfect filter",
4613 (void *)&cmd_pkt_filter_add_perfect_filter,
4614 (void *)&cmd_pkt_filter_port_id,
4615 (void *)&cmd_pkt_filter_protocol,
4616 (void *)&cmd_pkt_filter_src,
4617 (void *)&cmd_pkt_filter_ip_src,
4618 (void *)&cmd_pkt_filter_port_src,
4619 (void *)&cmd_pkt_filter_dst,
4620 (void *)&cmd_pkt_filter_ip_dst,
4621 (void *)&cmd_pkt_filter_port_dst,
4622 (void *)&cmd_pkt_filter_flexbytes,
4623 (void *)&cmd_pkt_filter_flexbytes_value,
4624 (void *)&cmd_pkt_filter_vlan,
4625 (void *)&cmd_pkt_filter_vlan_id,
4626 (void *)&cmd_pkt_filter_queue,
4627 (void *)&cmd_pkt_filter_queue_id,
4628 (void *)&cmd_pkt_filter_soft,
4629 (void *)&cmd_pkt_filter_soft_id,
4635 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4636 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4637 pkt_filter, "upd_perfect_filter");
4638 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4639 .f = cmd_pkt_filter_parsed,
4641 .help_str = "update a perfect filter",
4643 (void *)&cmd_pkt_filter_upd_perfect_filter,
4644 (void *)&cmd_pkt_filter_port_id,
4645 (void *)&cmd_pkt_filter_protocol,
4646 (void *)&cmd_pkt_filter_src,
4647 (void *)&cmd_pkt_filter_ip_src,
4648 (void *)&cmd_pkt_filter_port_src,
4649 (void *)&cmd_pkt_filter_dst,
4650 (void *)&cmd_pkt_filter_ip_dst,
4651 (void *)&cmd_pkt_filter_port_dst,
4652 (void *)&cmd_pkt_filter_flexbytes,
4653 (void *)&cmd_pkt_filter_flexbytes_value,
4654 (void *)&cmd_pkt_filter_vlan,
4655 (void *)&cmd_pkt_filter_vlan_id,
4656 (void *)&cmd_pkt_filter_queue,
4657 (void *)&cmd_pkt_filter_queue_id,
4658 (void *)&cmd_pkt_filter_soft,
4659 (void *)&cmd_pkt_filter_soft_id,
4665 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4666 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4667 pkt_filter, "rm_perfect_filter");
4668 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4669 .f = cmd_pkt_filter_parsed,
4671 .help_str = "remove a perfect filter",
4673 (void *)&cmd_pkt_filter_rm_perfect_filter,
4674 (void *)&cmd_pkt_filter_port_id,
4675 (void *)&cmd_pkt_filter_protocol,
4676 (void *)&cmd_pkt_filter_src,
4677 (void *)&cmd_pkt_filter_ip_src,
4678 (void *)&cmd_pkt_filter_port_src,
4679 (void *)&cmd_pkt_filter_dst,
4680 (void *)&cmd_pkt_filter_ip_dst,
4681 (void *)&cmd_pkt_filter_port_dst,
4682 (void *)&cmd_pkt_filter_flexbytes,
4683 (void *)&cmd_pkt_filter_flexbytes_value,
4684 (void *)&cmd_pkt_filter_vlan,
4685 (void *)&cmd_pkt_filter_vlan_id,
4686 (void *)&cmd_pkt_filter_soft,
4687 (void *)&cmd_pkt_filter_soft_id,
4692 /* *** SETUP MASKS FILTER *** */
4693 struct cmd_pkt_filter_masks_result {
4694 cmdline_fixed_string_t filter_mask;
4696 cmdline_fixed_string_t src_mask;
4697 uint32_t ip_src_mask;
4698 uint16_t ipv6_src_mask;
4699 uint16_t port_src_mask;
4700 cmdline_fixed_string_t dst_mask;
4701 uint32_t ip_dst_mask;
4702 uint16_t ipv6_dst_mask;
4703 uint16_t port_dst_mask;
4704 cmdline_fixed_string_t flexbytes;
4705 uint8_t flexbytes_value;
4706 cmdline_fixed_string_t vlan_id;
4707 uint8_t vlan_id_value;
4708 cmdline_fixed_string_t vlan_prio;
4709 uint8_t vlan_prio_value;
4710 cmdline_fixed_string_t only_ip_flow;
4711 uint8_t only_ip_flow_value;
4712 cmdline_fixed_string_t comp_ipv6_dst;
4713 uint8_t comp_ipv6_dst_value;
4717 cmd_pkt_filter_masks_parsed(void *parsed_result,
4718 __attribute__((unused)) struct cmdline *cl,
4719 __attribute__((unused)) void *data)
4721 struct rte_fdir_masks fdir_masks;
4722 struct cmd_pkt_filter_masks_result *res = parsed_result;
4724 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4726 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4727 fdir_masks.vlan_id = res->vlan_id_value;
4728 fdir_masks.vlan_prio = res->vlan_prio_value;
4729 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4730 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4731 fdir_masks.src_port_mask = res->port_src_mask;
4732 fdir_masks.dst_port_mask = res->port_dst_mask;
4733 fdir_masks.flexbytes = res->flexbytes_value;
4735 fdir_set_masks(res->port_id, &fdir_masks);
4738 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4739 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4740 filter_mask, "set_masks_filter");
4741 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4742 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4744 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4745 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4746 only_ip_flow, "only_ip_flow");
4747 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4748 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4749 only_ip_flow_value, UINT8);
4750 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4751 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4752 src_mask, "src_mask");
4753 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4754 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4755 ip_src_mask, UINT32);
4756 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4757 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4758 port_src_mask, UINT16);
4759 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4760 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4761 dst_mask, "dst_mask");
4762 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4763 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4764 ip_dst_mask, UINT32);
4765 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4766 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4767 port_dst_mask, UINT16);
4768 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4769 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4770 flexbytes, "flexbytes");
4771 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4772 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4773 flexbytes_value, UINT8);
4774 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4775 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4776 vlan_id, "vlan_id");
4777 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4778 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4779 vlan_id_value, UINT8);
4780 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4781 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4782 vlan_prio, "vlan_prio");
4783 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4784 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4785 vlan_prio_value, UINT8);
4787 cmdline_parse_inst_t cmd_set_masks_filter = {
4788 .f = cmd_pkt_filter_masks_parsed,
4790 .help_str = "setup masks filter",
4792 (void *)&cmd_pkt_filter_masks_filter_mask,
4793 (void *)&cmd_pkt_filter_masks_port_id,
4794 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4795 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4796 (void *)&cmd_pkt_filter_masks_src_mask,
4797 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4798 (void *)&cmd_pkt_filter_masks_port_src_mask,
4799 (void *)&cmd_pkt_filter_masks_dst_mask,
4800 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4801 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4802 (void *)&cmd_pkt_filter_masks_flexbytes,
4803 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4804 (void *)&cmd_pkt_filter_masks_vlan_id,
4805 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4806 (void *)&cmd_pkt_filter_masks_vlan_prio,
4807 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4813 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4814 __attribute__((unused)) struct cmdline *cl,
4815 __attribute__((unused)) void *data)
4817 struct rte_fdir_masks fdir_masks;
4818 struct cmd_pkt_filter_masks_result *res = parsed_result;
4820 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4822 fdir_masks.set_ipv6_mask = 1;
4823 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4824 fdir_masks.vlan_id = res->vlan_id_value;
4825 fdir_masks.vlan_prio = res->vlan_prio_value;
4826 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4827 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4828 fdir_masks.src_port_mask = res->port_src_mask;
4829 fdir_masks.dst_port_mask = res->port_dst_mask;
4830 fdir_masks.flexbytes = res->flexbytes_value;
4831 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4833 fdir_set_masks(res->port_id, &fdir_masks);
4836 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4837 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4838 filter_mask, "set_ipv6_masks_filter");
4839 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4840 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4841 ipv6_src_mask, UINT16);
4842 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4843 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4844 ipv6_dst_mask, UINT16);
4846 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4847 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4848 comp_ipv6_dst, "compare_dst");
4849 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4850 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4851 comp_ipv6_dst_value, UINT8);
4853 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4854 .f = cmd_pkt_filter_masks_ipv6_parsed,
4856 .help_str = "setup ipv6 masks filter",
4858 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4859 (void *)&cmd_pkt_filter_masks_port_id,
4860 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4861 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4862 (void *)&cmd_pkt_filter_masks_src_mask,
4863 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4864 (void *)&cmd_pkt_filter_masks_port_src_mask,
4865 (void *)&cmd_pkt_filter_masks_dst_mask,
4866 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4867 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4868 (void *)&cmd_pkt_filter_masks_flexbytes,
4869 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4870 (void *)&cmd_pkt_filter_masks_vlan_id,
4871 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4872 (void *)&cmd_pkt_filter_masks_vlan_prio,
4873 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4874 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4875 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4880 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4881 struct cmd_link_flow_ctrl_set_result {
4882 cmdline_fixed_string_t set;
4883 cmdline_fixed_string_t flow_ctrl;
4884 cmdline_fixed_string_t rx;
4885 cmdline_fixed_string_t rx_lfc_mode;
4886 cmdline_fixed_string_t tx;
4887 cmdline_fixed_string_t tx_lfc_mode;
4888 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4889 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4890 cmdline_fixed_string_t autoneg_str;
4891 cmdline_fixed_string_t autoneg;
4892 cmdline_fixed_string_t hw_str;
4893 uint32_t high_water;
4894 cmdline_fixed_string_t lw_str;
4896 cmdline_fixed_string_t pt_str;
4897 uint16_t pause_time;
4898 cmdline_fixed_string_t xon_str;
4903 cmdline_parse_token_string_t cmd_lfc_set_set =
4904 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4906 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4907 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4908 flow_ctrl, "flow_ctrl");
4909 cmdline_parse_token_string_t cmd_lfc_set_rx =
4910 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4912 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4913 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4914 rx_lfc_mode, "on#off");
4915 cmdline_parse_token_string_t cmd_lfc_set_tx =
4916 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4918 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4919 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4920 tx_lfc_mode, "on#off");
4921 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4922 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4923 hw_str, "high_water");
4924 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4925 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4926 high_water, UINT32);
4927 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4928 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4929 lw_str, "low_water");
4930 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4931 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4933 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4934 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4935 pt_str, "pause_time");
4936 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4937 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4938 pause_time, UINT16);
4939 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4940 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4941 xon_str, "send_xon");
4942 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4943 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4945 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4946 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4947 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4948 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4949 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4950 mac_ctrl_frame_fwd_mode, "on#off");
4951 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4952 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4953 autoneg_str, "autoneg");
4954 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4955 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4957 cmdline_parse_token_num_t cmd_lfc_set_portid =
4958 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4961 /* forward declaration */
4963 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4966 cmdline_parse_inst_t cmd_link_flow_control_set = {
4967 .f = cmd_link_flow_ctrl_set_parsed,
4969 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4970 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4971 autoneg on|off port_id",
4973 (void *)&cmd_lfc_set_set,
4974 (void *)&cmd_lfc_set_flow_ctrl,
4975 (void *)&cmd_lfc_set_rx,
4976 (void *)&cmd_lfc_set_rx_mode,
4977 (void *)&cmd_lfc_set_tx,
4978 (void *)&cmd_lfc_set_tx_mode,
4979 (void *)&cmd_lfc_set_high_water,
4980 (void *)&cmd_lfc_set_low_water,
4981 (void *)&cmd_lfc_set_pause_time,
4982 (void *)&cmd_lfc_set_send_xon,
4983 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4984 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4985 (void *)&cmd_lfc_set_autoneg_str,
4986 (void *)&cmd_lfc_set_autoneg,
4987 (void *)&cmd_lfc_set_portid,
4992 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4993 .f = cmd_link_flow_ctrl_set_parsed,
4994 .data = (void *)&cmd_link_flow_control_set_rx,
4995 .help_str = "Change rx flow control parameter: set flow_ctrl "
4996 "rx on|off port_id",
4998 (void *)&cmd_lfc_set_set,
4999 (void *)&cmd_lfc_set_flow_ctrl,
5000 (void *)&cmd_lfc_set_rx,
5001 (void *)&cmd_lfc_set_rx_mode,
5002 (void *)&cmd_lfc_set_portid,
5007 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5008 .f = cmd_link_flow_ctrl_set_parsed,
5009 .data = (void *)&cmd_link_flow_control_set_tx,
5010 .help_str = "Change tx flow control parameter: set flow_ctrl "
5011 "tx on|off port_id",
5013 (void *)&cmd_lfc_set_set,
5014 (void *)&cmd_lfc_set_flow_ctrl,
5015 (void *)&cmd_lfc_set_tx,
5016 (void *)&cmd_lfc_set_tx_mode,
5017 (void *)&cmd_lfc_set_portid,
5022 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5023 .f = cmd_link_flow_ctrl_set_parsed,
5024 .data = (void *)&cmd_link_flow_control_set_hw,
5025 .help_str = "Change high water flow control parameter: set flow_ctrl "
5026 "high_water value port_id",
5028 (void *)&cmd_lfc_set_set,
5029 (void *)&cmd_lfc_set_flow_ctrl,
5030 (void *)&cmd_lfc_set_high_water_str,
5031 (void *)&cmd_lfc_set_high_water,
5032 (void *)&cmd_lfc_set_portid,
5037 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5038 .f = cmd_link_flow_ctrl_set_parsed,
5039 .data = (void *)&cmd_link_flow_control_set_lw,
5040 .help_str = "Change low water flow control parameter: set flow_ctrl "
5041 "low_water value port_id",
5043 (void *)&cmd_lfc_set_set,
5044 (void *)&cmd_lfc_set_flow_ctrl,
5045 (void *)&cmd_lfc_set_low_water_str,
5046 (void *)&cmd_lfc_set_low_water,
5047 (void *)&cmd_lfc_set_portid,
5052 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5053 .f = cmd_link_flow_ctrl_set_parsed,
5054 .data = (void *)&cmd_link_flow_control_set_pt,
5055 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5056 "pause_time value port_id",
5058 (void *)&cmd_lfc_set_set,
5059 (void *)&cmd_lfc_set_flow_ctrl,
5060 (void *)&cmd_lfc_set_pause_time_str,
5061 (void *)&cmd_lfc_set_pause_time,
5062 (void *)&cmd_lfc_set_portid,
5067 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5068 .f = cmd_link_flow_ctrl_set_parsed,
5069 .data = (void *)&cmd_link_flow_control_set_xon,
5070 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5071 "send_xon value port_id",
5073 (void *)&cmd_lfc_set_set,
5074 (void *)&cmd_lfc_set_flow_ctrl,
5075 (void *)&cmd_lfc_set_send_xon_str,
5076 (void *)&cmd_lfc_set_send_xon,
5077 (void *)&cmd_lfc_set_portid,
5082 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5083 .f = cmd_link_flow_ctrl_set_parsed,
5084 .data = (void *)&cmd_link_flow_control_set_macfwd,
5085 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5086 "mac_ctrl_frame_fwd on|off port_id",
5088 (void *)&cmd_lfc_set_set,
5089 (void *)&cmd_lfc_set_flow_ctrl,
5090 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5091 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5092 (void *)&cmd_lfc_set_portid,
5097 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5098 .f = cmd_link_flow_ctrl_set_parsed,
5099 .data = (void *)&cmd_link_flow_control_set_autoneg,
5100 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5101 "autoneg on|off port_id",
5103 (void *)&cmd_lfc_set_set,
5104 (void *)&cmd_lfc_set_flow_ctrl,
5105 (void *)&cmd_lfc_set_autoneg_str,
5106 (void *)&cmd_lfc_set_autoneg,
5107 (void *)&cmd_lfc_set_portid,
5113 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5114 __attribute__((unused)) struct cmdline *cl,
5117 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5118 cmdline_parse_inst_t *cmd = data;
5119 struct rte_eth_fc_conf fc_conf;
5120 int rx_fc_en, tx_fc_en;
5124 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5125 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5126 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5127 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5129 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5130 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5133 /* Partial command line, retrieve current configuration */
5135 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5137 printf("cannot get current flow ctrl parameters, return"
5138 "code = %d\n", ret);
5142 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5143 (fc_conf.mode == RTE_FC_FULL))
5145 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5146 (fc_conf.mode == RTE_FC_FULL))
5150 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5151 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5153 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5154 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5156 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5158 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5159 fc_conf.high_water = res->high_water;
5161 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5162 fc_conf.low_water = res->low_water;
5164 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5165 fc_conf.pause_time = res->pause_time;
5167 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5168 fc_conf.send_xon = res->send_xon;
5170 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5171 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5172 fc_conf.mac_ctrl_frame_fwd = 1;
5174 fc_conf.mac_ctrl_frame_fwd = 0;
5177 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5178 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5180 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5182 printf("bad flow contrl parameter, return code = %d \n", ret);
5185 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5186 struct cmd_priority_flow_ctrl_set_result {
5187 cmdline_fixed_string_t set;
5188 cmdline_fixed_string_t pfc_ctrl;
5189 cmdline_fixed_string_t rx;
5190 cmdline_fixed_string_t rx_pfc_mode;
5191 cmdline_fixed_string_t tx;
5192 cmdline_fixed_string_t tx_pfc_mode;
5193 uint32_t high_water;
5195 uint16_t pause_time;
5201 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5202 __attribute__((unused)) struct cmdline *cl,
5203 __attribute__((unused)) void *data)
5205 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5206 struct rte_eth_pfc_conf pfc_conf;
5207 int rx_fc_enable, tx_fc_enable;
5211 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5212 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5213 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5214 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5216 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5217 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5220 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5221 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5222 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5223 pfc_conf.fc.high_water = res->high_water;
5224 pfc_conf.fc.low_water = res->low_water;
5225 pfc_conf.fc.pause_time = res->pause_time;
5226 pfc_conf.priority = res->priority;
5228 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5230 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5233 cmdline_parse_token_string_t cmd_pfc_set_set =
5234 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5236 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5237 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5238 pfc_ctrl, "pfc_ctrl");
5239 cmdline_parse_token_string_t cmd_pfc_set_rx =
5240 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5242 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5243 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5244 rx_pfc_mode, "on#off");
5245 cmdline_parse_token_string_t cmd_pfc_set_tx =
5246 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5248 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5249 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5250 tx_pfc_mode, "on#off");
5251 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5252 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5253 high_water, UINT32);
5254 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5255 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5257 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5258 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5259 pause_time, UINT16);
5260 cmdline_parse_token_num_t cmd_pfc_set_priority =
5261 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5263 cmdline_parse_token_num_t cmd_pfc_set_portid =
5264 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5267 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5268 .f = cmd_priority_flow_ctrl_set_parsed,
5270 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5271 tx on|off high_water low_water pause_time priority port_id",
5273 (void *)&cmd_pfc_set_set,
5274 (void *)&cmd_pfc_set_flow_ctrl,
5275 (void *)&cmd_pfc_set_rx,
5276 (void *)&cmd_pfc_set_rx_mode,
5277 (void *)&cmd_pfc_set_tx,
5278 (void *)&cmd_pfc_set_tx_mode,
5279 (void *)&cmd_pfc_set_high_water,
5280 (void *)&cmd_pfc_set_low_water,
5281 (void *)&cmd_pfc_set_pause_time,
5282 (void *)&cmd_pfc_set_priority,
5283 (void *)&cmd_pfc_set_portid,
5288 /* *** RESET CONFIGURATION *** */
5289 struct cmd_reset_result {
5290 cmdline_fixed_string_t reset;
5291 cmdline_fixed_string_t def;
5294 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5296 __attribute__((unused)) void *data)
5298 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5299 set_def_fwd_config();
5302 cmdline_parse_token_string_t cmd_reset_set =
5303 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5304 cmdline_parse_token_string_t cmd_reset_def =
5305 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5308 cmdline_parse_inst_t cmd_reset = {
5309 .f = cmd_reset_parsed,
5311 .help_str = "set default: reset default forwarding configuration",
5313 (void *)&cmd_reset_set,
5314 (void *)&cmd_reset_def,
5319 /* *** START FORWARDING *** */
5320 struct cmd_start_result {
5321 cmdline_fixed_string_t start;
5324 cmdline_parse_token_string_t cmd_start_start =
5325 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5327 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5328 __attribute__((unused)) struct cmdline *cl,
5329 __attribute__((unused)) void *data)
5331 start_packet_forwarding(0);
5334 cmdline_parse_inst_t cmd_start = {
5335 .f = cmd_start_parsed,
5337 .help_str = "start packet forwarding",
5339 (void *)&cmd_start_start,
5344 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5345 struct cmd_start_tx_first_result {
5346 cmdline_fixed_string_t start;
5347 cmdline_fixed_string_t tx_first;
5351 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5352 __attribute__((unused)) struct cmdline *cl,
5353 __attribute__((unused)) void *data)
5355 start_packet_forwarding(1);
5358 cmdline_parse_token_string_t cmd_start_tx_first_start =
5359 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5361 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5362 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5363 tx_first, "tx_first");
5365 cmdline_parse_inst_t cmd_start_tx_first = {
5366 .f = cmd_start_tx_first_parsed,
5368 .help_str = "start packet forwarding, after sending 1 burst of packets",
5370 (void *)&cmd_start_tx_first_start,
5371 (void *)&cmd_start_tx_first_tx_first,
5376 /* *** SET LINK UP *** */
5377 struct cmd_set_link_up_result {
5378 cmdline_fixed_string_t set;
5379 cmdline_fixed_string_t link_up;
5380 cmdline_fixed_string_t port;
5384 cmdline_parse_token_string_t cmd_set_link_up_set =
5385 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5386 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5387 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5389 cmdline_parse_token_string_t cmd_set_link_up_port =
5390 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5391 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5392 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5394 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5395 __attribute__((unused)) struct cmdline *cl,
5396 __attribute__((unused)) void *data)
5398 struct cmd_set_link_up_result *res = parsed_result;
5399 dev_set_link_up(res->port_id);
5402 cmdline_parse_inst_t cmd_set_link_up = {
5403 .f = cmd_set_link_up_parsed,
5405 .help_str = "set link-up port (port id)",
5407 (void *)&cmd_set_link_up_set,
5408 (void *)&cmd_set_link_up_link_up,
5409 (void *)&cmd_set_link_up_port,
5410 (void *)&cmd_set_link_up_port_id,
5415 /* *** SET LINK DOWN *** */
5416 struct cmd_set_link_down_result {
5417 cmdline_fixed_string_t set;
5418 cmdline_fixed_string_t link_down;
5419 cmdline_fixed_string_t port;
5423 cmdline_parse_token_string_t cmd_set_link_down_set =
5424 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5425 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5426 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5428 cmdline_parse_token_string_t cmd_set_link_down_port =
5429 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5430 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5431 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5433 static void cmd_set_link_down_parsed(
5434 __attribute__((unused)) void *parsed_result,
5435 __attribute__((unused)) struct cmdline *cl,
5436 __attribute__((unused)) void *data)
5438 struct cmd_set_link_down_result *res = parsed_result;
5439 dev_set_link_down(res->port_id);
5442 cmdline_parse_inst_t cmd_set_link_down = {
5443 .f = cmd_set_link_down_parsed,
5445 .help_str = "set link-down port (port id)",
5447 (void *)&cmd_set_link_down_set,
5448 (void *)&cmd_set_link_down_link_down,
5449 (void *)&cmd_set_link_down_port,
5450 (void *)&cmd_set_link_down_port_id,
5455 /* *** SHOW CFG *** */
5456 struct cmd_showcfg_result {
5457 cmdline_fixed_string_t show;
5458 cmdline_fixed_string_t cfg;
5459 cmdline_fixed_string_t what;
5462 static void cmd_showcfg_parsed(void *parsed_result,
5463 __attribute__((unused)) struct cmdline *cl,
5464 __attribute__((unused)) void *data)
5466 struct cmd_showcfg_result *res = parsed_result;
5467 if (!strcmp(res->what, "rxtx"))
5468 rxtx_config_display();
5469 else if (!strcmp(res->what, "cores"))
5470 fwd_lcores_config_display();
5471 else if (!strcmp(res->what, "fwd"))
5472 fwd_config_display();
5475 cmdline_parse_token_string_t cmd_showcfg_show =
5476 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5477 cmdline_parse_token_string_t cmd_showcfg_port =
5478 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5479 cmdline_parse_token_string_t cmd_showcfg_what =
5480 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5483 cmdline_parse_inst_t cmd_showcfg = {
5484 .f = cmd_showcfg_parsed,
5486 .help_str = "show config rxtx|cores|fwd",
5488 (void *)&cmd_showcfg_show,
5489 (void *)&cmd_showcfg_port,
5490 (void *)&cmd_showcfg_what,
5495 /* *** SHOW ALL PORT INFO *** */
5496 struct cmd_showportall_result {
5497 cmdline_fixed_string_t show;
5498 cmdline_fixed_string_t port;
5499 cmdline_fixed_string_t what;
5500 cmdline_fixed_string_t all;
5503 static void cmd_showportall_parsed(void *parsed_result,
5504 __attribute__((unused)) struct cmdline *cl,
5505 __attribute__((unused)) void *data)
5509 struct cmd_showportall_result *res = parsed_result;
5510 if (!strcmp(res->show, "clear")) {
5511 if (!strcmp(res->what, "stats"))
5512 for (i = 0; i < nb_ports; i++)
5514 else if (!strcmp(res->what, "xstats"))
5515 for (i = 0; i < nb_ports; i++)
5516 nic_xstats_clear(i);
5517 } else if (!strcmp(res->what, "info"))
5518 for (i = 0; i < nb_ports; i++)
5519 port_infos_display(i);
5520 else if (!strcmp(res->what, "stats"))
5521 for (i = 0; i < nb_ports; i++)
5522 nic_stats_display(i);
5523 else if (!strcmp(res->what, "xstats"))
5524 for (i = 0; i < nb_ports; i++)
5525 nic_xstats_display(i);
5526 else if (!strcmp(res->what, "fdir"))
5527 for (i = 0; i < nb_ports; i++)
5529 else if (!strcmp(res->what, "stat_qmap"))
5530 for (i = 0; i < nb_ports; i++)
5531 nic_stats_mapping_display(i);
5534 cmdline_parse_token_string_t cmd_showportall_show =
5535 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5537 cmdline_parse_token_string_t cmd_showportall_port =
5538 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5539 cmdline_parse_token_string_t cmd_showportall_what =
5540 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5541 "info#stats#xstats#fdir#stat_qmap");
5542 cmdline_parse_token_string_t cmd_showportall_all =
5543 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5544 cmdline_parse_inst_t cmd_showportall = {
5545 .f = cmd_showportall_parsed,
5547 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5549 (void *)&cmd_showportall_show,
5550 (void *)&cmd_showportall_port,
5551 (void *)&cmd_showportall_what,
5552 (void *)&cmd_showportall_all,
5557 /* *** SHOW PORT INFO *** */
5558 struct cmd_showport_result {
5559 cmdline_fixed_string_t show;
5560 cmdline_fixed_string_t port;
5561 cmdline_fixed_string_t what;
5565 static void cmd_showport_parsed(void *parsed_result,
5566 __attribute__((unused)) struct cmdline *cl,
5567 __attribute__((unused)) void *data)
5569 struct cmd_showport_result *res = parsed_result;
5570 if (!strcmp(res->show, "clear")) {
5571 if (!strcmp(res->what, "stats"))
5572 nic_stats_clear(res->portnum);
5573 else if (!strcmp(res->what, "xstats"))
5574 nic_xstats_clear(res->portnum);
5575 } else if (!strcmp(res->what, "info"))
5576 port_infos_display(res->portnum);
5577 else if (!strcmp(res->what, "stats"))
5578 nic_stats_display(res->portnum);
5579 else if (!strcmp(res->what, "xstats"))
5580 nic_xstats_display(res->portnum);
5581 else if (!strcmp(res->what, "fdir"))
5582 fdir_get_infos(res->portnum);
5583 else if (!strcmp(res->what, "stat_qmap"))
5584 nic_stats_mapping_display(res->portnum);
5587 cmdline_parse_token_string_t cmd_showport_show =
5588 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5590 cmdline_parse_token_string_t cmd_showport_port =
5591 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5592 cmdline_parse_token_string_t cmd_showport_what =
5593 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5594 "info#stats#xstats#fdir#stat_qmap");
5595 cmdline_parse_token_num_t cmd_showport_portnum =
5596 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5598 cmdline_parse_inst_t cmd_showport = {
5599 .f = cmd_showport_parsed,
5601 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5603 (void *)&cmd_showport_show,
5604 (void *)&cmd_showport_port,
5605 (void *)&cmd_showport_what,
5606 (void *)&cmd_showport_portnum,
5611 /* *** READ PORT REGISTER *** */
5612 struct cmd_read_reg_result {
5613 cmdline_fixed_string_t read;
5614 cmdline_fixed_string_t reg;
5620 cmd_read_reg_parsed(void *parsed_result,
5621 __attribute__((unused)) struct cmdline *cl,
5622 __attribute__((unused)) void *data)
5624 struct cmd_read_reg_result *res = parsed_result;
5625 port_reg_display(res->port_id, res->reg_off);
5628 cmdline_parse_token_string_t cmd_read_reg_read =
5629 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5630 cmdline_parse_token_string_t cmd_read_reg_reg =
5631 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5632 cmdline_parse_token_num_t cmd_read_reg_port_id =
5633 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5634 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5635 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5637 cmdline_parse_inst_t cmd_read_reg = {
5638 .f = cmd_read_reg_parsed,
5640 .help_str = "read reg port_id reg_off",
5642 (void *)&cmd_read_reg_read,
5643 (void *)&cmd_read_reg_reg,
5644 (void *)&cmd_read_reg_port_id,
5645 (void *)&cmd_read_reg_reg_off,
5650 /* *** READ PORT REGISTER BIT FIELD *** */
5651 struct cmd_read_reg_bit_field_result {
5652 cmdline_fixed_string_t read;
5653 cmdline_fixed_string_t regfield;
5661 cmd_read_reg_bit_field_parsed(void *parsed_result,
5662 __attribute__((unused)) struct cmdline *cl,
5663 __attribute__((unused)) void *data)
5665 struct cmd_read_reg_bit_field_result *res = parsed_result;
5666 port_reg_bit_field_display(res->port_id, res->reg_off,
5667 res->bit1_pos, res->bit2_pos);
5670 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5671 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5673 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5674 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5675 regfield, "regfield");
5676 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5677 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5679 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5680 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5682 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5683 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5685 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5686 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5689 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5690 .f = cmd_read_reg_bit_field_parsed,
5692 .help_str = "read regfield port_id reg_off bit_x bit_y "
5693 "(read register bit field between bit_x and bit_y included)",
5695 (void *)&cmd_read_reg_bit_field_read,
5696 (void *)&cmd_read_reg_bit_field_regfield,
5697 (void *)&cmd_read_reg_bit_field_port_id,
5698 (void *)&cmd_read_reg_bit_field_reg_off,
5699 (void *)&cmd_read_reg_bit_field_bit1_pos,
5700 (void *)&cmd_read_reg_bit_field_bit2_pos,
5705 /* *** READ PORT REGISTER BIT *** */
5706 struct cmd_read_reg_bit_result {
5707 cmdline_fixed_string_t read;
5708 cmdline_fixed_string_t regbit;
5715 cmd_read_reg_bit_parsed(void *parsed_result,
5716 __attribute__((unused)) struct cmdline *cl,
5717 __attribute__((unused)) void *data)
5719 struct cmd_read_reg_bit_result *res = parsed_result;
5720 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5723 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5724 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5725 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5726 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5728 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5729 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5730 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5731 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5732 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5733 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5735 cmdline_parse_inst_t cmd_read_reg_bit = {
5736 .f = cmd_read_reg_bit_parsed,
5738 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5740 (void *)&cmd_read_reg_bit_read,
5741 (void *)&cmd_read_reg_bit_regbit,
5742 (void *)&cmd_read_reg_bit_port_id,
5743 (void *)&cmd_read_reg_bit_reg_off,
5744 (void *)&cmd_read_reg_bit_bit_pos,
5749 /* *** WRITE PORT REGISTER *** */
5750 struct cmd_write_reg_result {
5751 cmdline_fixed_string_t write;
5752 cmdline_fixed_string_t reg;
5759 cmd_write_reg_parsed(void *parsed_result,
5760 __attribute__((unused)) struct cmdline *cl,
5761 __attribute__((unused)) void *data)
5763 struct cmd_write_reg_result *res = parsed_result;
5764 port_reg_set(res->port_id, res->reg_off, res->value);
5767 cmdline_parse_token_string_t cmd_write_reg_write =
5768 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5769 cmdline_parse_token_string_t cmd_write_reg_reg =
5770 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5771 cmdline_parse_token_num_t cmd_write_reg_port_id =
5772 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5773 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5774 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5775 cmdline_parse_token_num_t cmd_write_reg_value =
5776 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5778 cmdline_parse_inst_t cmd_write_reg = {
5779 .f = cmd_write_reg_parsed,
5781 .help_str = "write reg port_id reg_off reg_value",
5783 (void *)&cmd_write_reg_write,
5784 (void *)&cmd_write_reg_reg,
5785 (void *)&cmd_write_reg_port_id,
5786 (void *)&cmd_write_reg_reg_off,
5787 (void *)&cmd_write_reg_value,
5792 /* *** WRITE PORT REGISTER BIT FIELD *** */
5793 struct cmd_write_reg_bit_field_result {
5794 cmdline_fixed_string_t write;
5795 cmdline_fixed_string_t regfield;
5804 cmd_write_reg_bit_field_parsed(void *parsed_result,
5805 __attribute__((unused)) struct cmdline *cl,
5806 __attribute__((unused)) void *data)
5808 struct cmd_write_reg_bit_field_result *res = parsed_result;
5809 port_reg_bit_field_set(res->port_id, res->reg_off,
5810 res->bit1_pos, res->bit2_pos, res->value);
5813 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5814 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5816 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5817 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5818 regfield, "regfield");
5819 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5820 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5822 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5823 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5825 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5826 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5828 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5829 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5831 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5832 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5835 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5836 .f = cmd_write_reg_bit_field_parsed,
5838 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5839 "(set register bit field between bit_x and bit_y included)",
5841 (void *)&cmd_write_reg_bit_field_write,
5842 (void *)&cmd_write_reg_bit_field_regfield,
5843 (void *)&cmd_write_reg_bit_field_port_id,
5844 (void *)&cmd_write_reg_bit_field_reg_off,
5845 (void *)&cmd_write_reg_bit_field_bit1_pos,
5846 (void *)&cmd_write_reg_bit_field_bit2_pos,
5847 (void *)&cmd_write_reg_bit_field_value,
5852 /* *** WRITE PORT REGISTER BIT *** */
5853 struct cmd_write_reg_bit_result {
5854 cmdline_fixed_string_t write;
5855 cmdline_fixed_string_t regbit;
5863 cmd_write_reg_bit_parsed(void *parsed_result,
5864 __attribute__((unused)) struct cmdline *cl,
5865 __attribute__((unused)) void *data)
5867 struct cmd_write_reg_bit_result *res = parsed_result;
5868 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5871 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5872 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5874 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5875 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5877 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5878 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5879 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5880 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5881 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5882 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5883 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5884 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5886 cmdline_parse_inst_t cmd_write_reg_bit = {
5887 .f = cmd_write_reg_bit_parsed,
5889 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5891 (void *)&cmd_write_reg_bit_write,
5892 (void *)&cmd_write_reg_bit_regbit,
5893 (void *)&cmd_write_reg_bit_port_id,
5894 (void *)&cmd_write_reg_bit_reg_off,
5895 (void *)&cmd_write_reg_bit_bit_pos,
5896 (void *)&cmd_write_reg_bit_value,
5901 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5902 struct cmd_read_rxd_txd_result {
5903 cmdline_fixed_string_t read;
5904 cmdline_fixed_string_t rxd_txd;
5911 cmd_read_rxd_txd_parsed(void *parsed_result,
5912 __attribute__((unused)) struct cmdline *cl,
5913 __attribute__((unused)) void *data)
5915 struct cmd_read_rxd_txd_result *res = parsed_result;
5917 if (!strcmp(res->rxd_txd, "rxd"))
5918 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5919 else if (!strcmp(res->rxd_txd, "txd"))
5920 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5923 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5924 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5925 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5926 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5928 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5929 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5930 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5931 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5932 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5933 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5935 cmdline_parse_inst_t cmd_read_rxd_txd = {
5936 .f = cmd_read_rxd_txd_parsed,
5938 .help_str = "read rxd|txd port_id queue_id rxd_id",
5940 (void *)&cmd_read_rxd_txd_read,
5941 (void *)&cmd_read_rxd_txd_rxd_txd,
5942 (void *)&cmd_read_rxd_txd_port_id,
5943 (void *)&cmd_read_rxd_txd_queue_id,
5944 (void *)&cmd_read_rxd_txd_desc_id,
5950 struct cmd_quit_result {
5951 cmdline_fixed_string_t quit;
5954 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5956 __attribute__((unused)) void *data)
5962 cmdline_parse_token_string_t cmd_quit_quit =
5963 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5965 cmdline_parse_inst_t cmd_quit = {
5966 .f = cmd_quit_parsed,
5968 .help_str = "exit application",
5970 (void *)&cmd_quit_quit,
5975 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5976 struct cmd_mac_addr_result {
5977 cmdline_fixed_string_t mac_addr_cmd;
5978 cmdline_fixed_string_t what;
5980 struct ether_addr address;
5983 static void cmd_mac_addr_parsed(void *parsed_result,
5984 __attribute__((unused)) struct cmdline *cl,
5985 __attribute__((unused)) void *data)
5987 struct cmd_mac_addr_result *res = parsed_result;
5990 if (strcmp(res->what, "add") == 0)
5991 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5993 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5995 /* check the return value and print it if is < 0 */
5997 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6001 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6002 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6004 cmdline_parse_token_string_t cmd_mac_addr_what =
6005 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6007 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6008 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6009 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6010 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6012 cmdline_parse_inst_t cmd_mac_addr = {
6013 .f = cmd_mac_addr_parsed,
6015 .help_str = "mac_addr add|remove X <address>: "
6016 "add/remove MAC address on port X",
6018 (void *)&cmd_mac_addr_cmd,
6019 (void *)&cmd_mac_addr_what,
6020 (void *)&cmd_mac_addr_portnum,
6021 (void *)&cmd_mac_addr_addr,
6027 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6028 struct cmd_set_qmap_result {
6029 cmdline_fixed_string_t set;
6030 cmdline_fixed_string_t qmap;
6031 cmdline_fixed_string_t what;
6038 cmd_set_qmap_parsed(void *parsed_result,
6039 __attribute__((unused)) struct cmdline *cl,
6040 __attribute__((unused)) void *data)
6042 struct cmd_set_qmap_result *res = parsed_result;
6043 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6045 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6048 cmdline_parse_token_string_t cmd_setqmap_set =
6049 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6051 cmdline_parse_token_string_t cmd_setqmap_qmap =
6052 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6054 cmdline_parse_token_string_t cmd_setqmap_what =
6055 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6057 cmdline_parse_token_num_t cmd_setqmap_portid =
6058 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6060 cmdline_parse_token_num_t cmd_setqmap_queueid =
6061 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6063 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6064 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6067 cmdline_parse_inst_t cmd_set_qmap = {
6068 .f = cmd_set_qmap_parsed,
6070 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6072 (void *)&cmd_setqmap_set,
6073 (void *)&cmd_setqmap_qmap,
6074 (void *)&cmd_setqmap_what,
6075 (void *)&cmd_setqmap_portid,
6076 (void *)&cmd_setqmap_queueid,
6077 (void *)&cmd_setqmap_mapvalue,
6082 /* *** CONFIGURE UNICAST HASH TABLE *** */
6083 struct cmd_set_uc_hash_table {
6084 cmdline_fixed_string_t set;
6085 cmdline_fixed_string_t port;
6087 cmdline_fixed_string_t what;
6088 struct ether_addr address;
6089 cmdline_fixed_string_t mode;
6093 cmd_set_uc_hash_parsed(void *parsed_result,
6094 __attribute__((unused)) struct cmdline *cl,
6095 __attribute__((unused)) void *data)
6098 struct cmd_set_uc_hash_table *res = parsed_result;
6100 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6102 if (strcmp(res->what, "uta") == 0)
6103 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6104 &res->address,(uint8_t)is_on);
6106 printf("bad unicast hash table parameter, return code = %d \n", ret);
6110 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6111 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6113 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6114 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6116 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6117 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6119 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6120 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6122 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6123 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6125 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6126 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6129 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6130 .f = cmd_set_uc_hash_parsed,
6132 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6134 (void *)&cmd_set_uc_hash_set,
6135 (void *)&cmd_set_uc_hash_port,
6136 (void *)&cmd_set_uc_hash_portid,
6137 (void *)&cmd_set_uc_hash_what,
6138 (void *)&cmd_set_uc_hash_mac,
6139 (void *)&cmd_set_uc_hash_mode,
6144 struct cmd_set_uc_all_hash_table {
6145 cmdline_fixed_string_t set;
6146 cmdline_fixed_string_t port;
6148 cmdline_fixed_string_t what;
6149 cmdline_fixed_string_t value;
6150 cmdline_fixed_string_t mode;
6154 cmd_set_uc_all_hash_parsed(void *parsed_result,
6155 __attribute__((unused)) struct cmdline *cl,
6156 __attribute__((unused)) void *data)
6159 struct cmd_set_uc_all_hash_table *res = parsed_result;
6161 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6163 if ((strcmp(res->what, "uta") == 0) &&
6164 (strcmp(res->value, "all") == 0))
6165 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6167 printf("bad unicast hash table parameter,"
6168 "return code = %d \n", ret);
6171 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6172 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6174 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6175 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6177 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6178 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6180 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6181 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6183 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6184 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6186 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6187 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6190 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6191 .f = cmd_set_uc_all_hash_parsed,
6193 .help_str = "set port X uta all on|off (X = port number)",
6195 (void *)&cmd_set_uc_all_hash_set,
6196 (void *)&cmd_set_uc_all_hash_port,
6197 (void *)&cmd_set_uc_all_hash_portid,
6198 (void *)&cmd_set_uc_all_hash_what,
6199 (void *)&cmd_set_uc_all_hash_value,
6200 (void *)&cmd_set_uc_all_hash_mode,
6205 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6206 struct cmd_set_vf_macvlan_filter {
6207 cmdline_fixed_string_t set;
6208 cmdline_fixed_string_t port;
6210 cmdline_fixed_string_t vf;
6212 struct ether_addr address;
6213 cmdline_fixed_string_t filter_type;
6214 cmdline_fixed_string_t mode;
6218 cmd_set_vf_macvlan_parsed(void *parsed_result,
6219 __attribute__((unused)) struct cmdline *cl,
6220 __attribute__((unused)) void *data)
6223 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6224 struct rte_eth_mac_filter filter;
6226 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6228 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6230 /* set VF MAC filter */
6234 filter.dst_id = res->vf_id;
6236 if (!strcmp(res->filter_type, "exact-mac"))
6237 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6238 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6239 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6240 else if (!strcmp(res->filter_type, "hashmac"))
6241 filter.filter_type = RTE_MAC_HASH_MATCH;
6242 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6243 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6245 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6248 ret = rte_eth_dev_filter_ctrl(res->port_id,
6249 RTE_ETH_FILTER_MACVLAN,
6253 ret = rte_eth_dev_filter_ctrl(res->port_id,
6254 RTE_ETH_FILTER_MACVLAN,
6255 RTE_ETH_FILTER_DELETE,
6259 printf("bad set MAC hash parameter, return code = %d\n", ret);
6263 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6264 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6266 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6267 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6269 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6270 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6272 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6273 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6275 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6276 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6278 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6279 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6281 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6282 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6283 filter_type, "exact-mac#exact-mac-vlan"
6284 "#hashmac#hashmac-vlan");
6285 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6286 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6289 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6290 .f = cmd_set_vf_macvlan_parsed,
6292 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6293 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6295 "exact match rule:exact match of MAC or MAC and VLAN; "
6296 "hash match rule: hash match of MAC and exact match "
6299 (void *)&cmd_set_vf_macvlan_set,
6300 (void *)&cmd_set_vf_macvlan_port,
6301 (void *)&cmd_set_vf_macvlan_portid,
6302 (void *)&cmd_set_vf_macvlan_vf,
6303 (void *)&cmd_set_vf_macvlan_vf_id,
6304 (void *)&cmd_set_vf_macvlan_mac,
6305 (void *)&cmd_set_vf_macvlan_filter_type,
6306 (void *)&cmd_set_vf_macvlan_mode,
6311 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6312 struct cmd_set_vf_traffic {
6313 cmdline_fixed_string_t set;
6314 cmdline_fixed_string_t port;
6316 cmdline_fixed_string_t vf;
6318 cmdline_fixed_string_t what;
6319 cmdline_fixed_string_t mode;
6323 cmd_set_vf_traffic_parsed(void *parsed_result,
6324 __attribute__((unused)) struct cmdline *cl,
6325 __attribute__((unused)) void *data)
6327 struct cmd_set_vf_traffic *res = parsed_result;
6328 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6329 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6331 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6334 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6335 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6337 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6338 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6340 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6341 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6343 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6344 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6346 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6347 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6349 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6350 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6352 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6353 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6356 cmdline_parse_inst_t cmd_set_vf_traffic = {
6357 .f = cmd_set_vf_traffic_parsed,
6359 .help_str = "set port X vf Y rx|tx on|off"
6360 "(X = port number,Y = vf id)",
6362 (void *)&cmd_setvf_traffic_set,
6363 (void *)&cmd_setvf_traffic_port,
6364 (void *)&cmd_setvf_traffic_portid,
6365 (void *)&cmd_setvf_traffic_vf,
6366 (void *)&cmd_setvf_traffic_vfid,
6367 (void *)&cmd_setvf_traffic_what,
6368 (void *)&cmd_setvf_traffic_mode,
6373 /* *** CONFIGURE VF RECEIVE MODE *** */
6374 struct cmd_set_vf_rxmode {
6375 cmdline_fixed_string_t set;
6376 cmdline_fixed_string_t port;
6378 cmdline_fixed_string_t vf;
6380 cmdline_fixed_string_t what;
6381 cmdline_fixed_string_t mode;
6382 cmdline_fixed_string_t on;
6386 cmd_set_vf_rxmode_parsed(void *parsed_result,
6387 __attribute__((unused)) struct cmdline *cl,
6388 __attribute__((unused)) void *data)
6391 uint16_t rx_mode = 0;
6392 struct cmd_set_vf_rxmode *res = parsed_result;
6394 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6395 if (!strcmp(res->what,"rxmode")) {
6396 if (!strcmp(res->mode, "AUPE"))
6397 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6398 else if (!strcmp(res->mode, "ROPE"))
6399 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6400 else if (!strcmp(res->mode, "BAM"))
6401 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6402 else if (!strncmp(res->mode, "MPE",3))
6403 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6406 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6408 printf("bad VF receive mode parameter, return code = %d \n",
6412 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6413 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6415 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6416 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6418 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6419 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6421 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6422 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6424 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6425 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6427 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6428 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6430 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6431 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6432 mode, "AUPE#ROPE#BAM#MPE");
6433 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6434 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6437 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6438 .f = cmd_set_vf_rxmode_parsed,
6440 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6442 (void *)&cmd_set_vf_rxmode_set,
6443 (void *)&cmd_set_vf_rxmode_port,
6444 (void *)&cmd_set_vf_rxmode_portid,
6445 (void *)&cmd_set_vf_rxmode_vf,
6446 (void *)&cmd_set_vf_rxmode_vfid,
6447 (void *)&cmd_set_vf_rxmode_what,
6448 (void *)&cmd_set_vf_rxmode_mode,
6449 (void *)&cmd_set_vf_rxmode_on,
6454 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6455 struct cmd_vf_mac_addr_result {
6456 cmdline_fixed_string_t mac_addr_cmd;
6457 cmdline_fixed_string_t what;
6458 cmdline_fixed_string_t port;
6460 cmdline_fixed_string_t vf;
6462 struct ether_addr address;
6465 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6466 __attribute__((unused)) struct cmdline *cl,
6467 __attribute__((unused)) void *data)
6469 struct cmd_vf_mac_addr_result *res = parsed_result;
6472 if (strcmp(res->what, "add") == 0)
6473 ret = rte_eth_dev_mac_addr_add(res->port_num,
6474 &res->address, res->vf_num);
6476 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6480 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6481 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6482 mac_addr_cmd,"mac_addr");
6483 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6484 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6486 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6487 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6489 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6490 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6492 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6493 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6495 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6496 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6498 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6499 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6502 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6503 .f = cmd_vf_mac_addr_parsed,
6505 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6506 "Y = VF number)add MAC address filtering for a VF on port X",
6508 (void *)&cmd_vf_mac_addr_cmd,
6509 (void *)&cmd_vf_mac_addr_what,
6510 (void *)&cmd_vf_mac_addr_port,
6511 (void *)&cmd_vf_mac_addr_portnum,
6512 (void *)&cmd_vf_mac_addr_vf,
6513 (void *)&cmd_vf_mac_addr_vfnum,
6514 (void *)&cmd_vf_mac_addr_addr,
6519 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6520 struct cmd_vf_rx_vlan_filter {
6521 cmdline_fixed_string_t rx_vlan;
6522 cmdline_fixed_string_t what;
6524 cmdline_fixed_string_t port;
6526 cmdline_fixed_string_t vf;
6531 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6532 __attribute__((unused)) struct cmdline *cl,
6533 __attribute__((unused)) void *data)
6535 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6537 if (!strcmp(res->what, "add"))
6538 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6540 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6543 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6544 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6545 rx_vlan, "rx_vlan");
6546 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6547 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6549 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6550 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6552 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6553 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6555 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6556 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6558 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6559 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6561 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6562 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6565 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6566 .f = cmd_vf_rx_vlan_filter_parsed,
6568 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6569 "Y = port number,Z = hexadecimal VF mask)",
6571 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6572 (void *)&cmd_vf_rx_vlan_filter_what,
6573 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6574 (void *)&cmd_vf_rx_vlan_filter_port,
6575 (void *)&cmd_vf_rx_vlan_filter_portid,
6576 (void *)&cmd_vf_rx_vlan_filter_vf,
6577 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6582 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6583 struct cmd_queue_rate_limit_result {
6584 cmdline_fixed_string_t set;
6585 cmdline_fixed_string_t port;
6587 cmdline_fixed_string_t queue;
6589 cmdline_fixed_string_t rate;
6593 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6594 __attribute__((unused)) struct cmdline *cl,
6595 __attribute__((unused)) void *data)
6597 struct cmd_queue_rate_limit_result *res = parsed_result;
6600 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6601 && (strcmp(res->queue, "queue") == 0)
6602 && (strcmp(res->rate, "rate") == 0))
6603 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6606 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6610 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6611 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6613 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6614 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6616 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6617 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6619 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6620 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6622 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6623 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6625 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6626 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6628 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6629 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6632 cmdline_parse_inst_t cmd_queue_rate_limit = {
6633 .f = cmd_queue_rate_limit_parsed,
6635 .help_str = "set port X queue Y rate Z:(X = port number,"
6636 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6638 (void *)&cmd_queue_rate_limit_set,
6639 (void *)&cmd_queue_rate_limit_port,
6640 (void *)&cmd_queue_rate_limit_portnum,
6641 (void *)&cmd_queue_rate_limit_queue,
6642 (void *)&cmd_queue_rate_limit_queuenum,
6643 (void *)&cmd_queue_rate_limit_rate,
6644 (void *)&cmd_queue_rate_limit_ratenum,
6649 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6650 struct cmd_vf_rate_limit_result {
6651 cmdline_fixed_string_t set;
6652 cmdline_fixed_string_t port;
6654 cmdline_fixed_string_t vf;
6656 cmdline_fixed_string_t rate;
6658 cmdline_fixed_string_t q_msk;
6662 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6663 __attribute__((unused)) struct cmdline *cl,
6664 __attribute__((unused)) void *data)
6666 struct cmd_vf_rate_limit_result *res = parsed_result;
6669 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6670 && (strcmp(res->vf, "vf") == 0)
6671 && (strcmp(res->rate, "rate") == 0)
6672 && (strcmp(res->q_msk, "queue_mask") == 0))
6673 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6674 res->rate_num, res->q_msk_val);
6676 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6680 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6681 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6683 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6684 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6686 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6687 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6689 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6690 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6692 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6693 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6695 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6696 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6698 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6699 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6701 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6702 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6703 q_msk, "queue_mask");
6704 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6705 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6708 cmdline_parse_inst_t cmd_vf_rate_limit = {
6709 .f = cmd_vf_rate_limit_parsed,
6711 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6712 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6713 "for queues of VF on port X",
6715 (void *)&cmd_vf_rate_limit_set,
6716 (void *)&cmd_vf_rate_limit_port,
6717 (void *)&cmd_vf_rate_limit_portnum,
6718 (void *)&cmd_vf_rate_limit_vf,
6719 (void *)&cmd_vf_rate_limit_vfnum,
6720 (void *)&cmd_vf_rate_limit_rate,
6721 (void *)&cmd_vf_rate_limit_ratenum,
6722 (void *)&cmd_vf_rate_limit_q_msk,
6723 (void *)&cmd_vf_rate_limit_q_msk_val,
6728 /* *** ADD TUNNEL FILTER OF A PORT *** */
6729 struct cmd_tunnel_filter_result {
6730 cmdline_fixed_string_t cmd;
6731 cmdline_fixed_string_t what;
6733 struct ether_addr outer_mac;
6734 struct ether_addr inner_mac;
6735 cmdline_ipaddr_t ip_value;
6736 uint16_t inner_vlan;
6737 cmdline_fixed_string_t tunnel_type;
6738 cmdline_fixed_string_t filter_type;
6744 cmd_tunnel_filter_parsed(void *parsed_result,
6745 __attribute__((unused)) struct cmdline *cl,
6746 __attribute__((unused)) void *data)
6748 struct cmd_tunnel_filter_result *res = parsed_result;
6749 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6752 tunnel_filter_conf.outer_mac = &res->outer_mac;
6753 tunnel_filter_conf.inner_mac = &res->inner_mac;
6754 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6756 if (res->ip_value.family == AF_INET) {
6757 tunnel_filter_conf.ip_addr.ipv4_addr =
6758 res->ip_value.addr.ipv4.s_addr;
6759 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6761 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6762 &(res->ip_value.addr.ipv6),
6763 sizeof(struct in6_addr));
6764 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6767 if (!strcmp(res->filter_type, "imac-ivlan"))
6768 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6769 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6770 tunnel_filter_conf.filter_type =
6771 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6772 else if (!strcmp(res->filter_type, "imac-tenid"))
6773 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6774 else if (!strcmp(res->filter_type, "imac"))
6775 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6776 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6777 tunnel_filter_conf.filter_type =
6778 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6780 printf("The filter type is not supported");
6784 if (!strcmp(res->tunnel_type, "vxlan"))
6785 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6787 printf("Only VXLAN is supported now.\n");
6791 tunnel_filter_conf.tenant_id = res->tenant_id;
6792 tunnel_filter_conf.queue_id = res->queue_num;
6793 if (!strcmp(res->what, "add"))
6794 ret = rte_eth_dev_filter_ctrl(res->port_id,
6795 RTE_ETH_FILTER_TUNNEL,
6797 &tunnel_filter_conf);
6799 ret = rte_eth_dev_filter_ctrl(res->port_id,
6800 RTE_ETH_FILTER_TUNNEL,
6801 RTE_ETH_FILTER_DELETE,
6802 &tunnel_filter_conf);
6804 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6808 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6809 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6810 cmd, "tunnel_filter");
6811 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6812 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6814 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6815 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6817 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6818 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6820 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6821 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6823 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6824 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6825 inner_vlan, UINT16);
6826 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6827 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6829 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6830 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6831 tunnel_type, "vxlan");
6833 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6834 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6835 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6836 "imac#omac-imac-tenid");
6837 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6838 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6840 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6841 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6844 cmdline_parse_inst_t cmd_tunnel_filter = {
6845 .f = cmd_tunnel_filter_parsed,
6847 .help_str = "add/rm tunnel filter of a port: "
6848 "tunnel_filter add port_id outer_mac inner_mac ip "
6849 "inner_vlan tunnel_type(vxlan) filter_type "
6850 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6851 "imac|omac-imac-tenid) "
6852 "tenant_id queue_num",
6854 (void *)&cmd_tunnel_filter_cmd,
6855 (void *)&cmd_tunnel_filter_what,
6856 (void *)&cmd_tunnel_filter_port_id,
6857 (void *)&cmd_tunnel_filter_outer_mac,
6858 (void *)&cmd_tunnel_filter_inner_mac,
6859 (void *)&cmd_tunnel_filter_ip_value,
6860 (void *)&cmd_tunnel_filter_innner_vlan,
6861 (void *)&cmd_tunnel_filter_tunnel_type,
6862 (void *)&cmd_tunnel_filter_filter_type,
6863 (void *)&cmd_tunnel_filter_tenant_id,
6864 (void *)&cmd_tunnel_filter_queue_num,
6869 /* *** CONFIGURE TUNNEL UDP PORT *** */
6870 struct cmd_tunnel_udp_config {
6871 cmdline_fixed_string_t cmd;
6872 cmdline_fixed_string_t what;
6878 cmd_tunnel_udp_config_parsed(void *parsed_result,
6879 __attribute__((unused)) struct cmdline *cl,
6880 __attribute__((unused)) void *data)
6882 struct cmd_tunnel_udp_config *res = parsed_result;
6883 struct rte_eth_udp_tunnel tunnel_udp;
6886 tunnel_udp.udp_port = res->udp_port;
6888 if (!strcmp(res->cmd, "rx_vxlan_port"))
6889 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6891 if (!strcmp(res->what, "add"))
6892 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6894 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6897 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6900 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6901 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6902 cmd, "rx_vxlan_port");
6903 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6904 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6906 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6907 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6909 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6910 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6913 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6914 .f = cmd_tunnel_udp_config_parsed,
6916 .help_str = "add/rm an tunneling UDP port filter: "
6917 "rx_vxlan_port add udp_port port_id",
6919 (void *)&cmd_tunnel_udp_config_cmd,
6920 (void *)&cmd_tunnel_udp_config_what,
6921 (void *)&cmd_tunnel_udp_config_udp_port,
6922 (void *)&cmd_tunnel_udp_config_port_id,
6927 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6928 struct cmd_set_mirror_mask_result {
6929 cmdline_fixed_string_t set;
6930 cmdline_fixed_string_t port;
6932 cmdline_fixed_string_t mirror;
6934 cmdline_fixed_string_t what;
6935 cmdline_fixed_string_t value;
6936 cmdline_fixed_string_t dstpool;
6938 cmdline_fixed_string_t on;
6941 cmdline_parse_token_string_t cmd_mirror_mask_set =
6942 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6944 cmdline_parse_token_string_t cmd_mirror_mask_port =
6945 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6947 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6948 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6950 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6951 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6952 mirror, "mirror-rule");
6953 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6954 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6956 cmdline_parse_token_string_t cmd_mirror_mask_what =
6957 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6958 what, "pool-mirror#vlan-mirror");
6959 cmdline_parse_token_string_t cmd_mirror_mask_value =
6960 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6962 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6963 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6964 dstpool, "dst-pool");
6965 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6966 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6968 cmdline_parse_token_string_t cmd_mirror_mask_on =
6969 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6973 cmd_set_mirror_mask_parsed(void *parsed_result,
6974 __attribute__((unused)) struct cmdline *cl,
6975 __attribute__((unused)) void *data)
6978 struct cmd_set_mirror_mask_result *res = parsed_result;
6979 struct rte_eth_vmdq_mirror_conf mr_conf;
6981 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6983 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6985 mr_conf.dst_pool = res->dstpool_id;
6987 if (!strcmp(res->what, "pool-mirror")) {
6988 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6989 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6990 } else if(!strcmp(res->what, "vlan-mirror")) {
6991 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6992 nb_item = parse_item_list(res->value, "core",
6993 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6997 for(i=0; i < nb_item; i++) {
6998 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6999 printf("Invalid vlan_id: must be < 4096\n");
7003 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7004 mr_conf.vlan.vlan_mask |= 1ULL << i;
7008 if(!strcmp(res->on, "on"))
7009 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7012 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7015 printf("mirror rule add error: (%s)\n", strerror(-ret));
7018 cmdline_parse_inst_t cmd_set_mirror_mask = {
7019 .f = cmd_set_mirror_mask_parsed,
7021 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
7022 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7024 (void *)&cmd_mirror_mask_set,
7025 (void *)&cmd_mirror_mask_port,
7026 (void *)&cmd_mirror_mask_portid,
7027 (void *)&cmd_mirror_mask_mirror,
7028 (void *)&cmd_mirror_mask_ruleid,
7029 (void *)&cmd_mirror_mask_what,
7030 (void *)&cmd_mirror_mask_value,
7031 (void *)&cmd_mirror_mask_dstpool,
7032 (void *)&cmd_mirror_mask_poolid,
7033 (void *)&cmd_mirror_mask_on,
7038 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7039 struct cmd_set_mirror_link_result {
7040 cmdline_fixed_string_t set;
7041 cmdline_fixed_string_t port;
7043 cmdline_fixed_string_t mirror;
7045 cmdline_fixed_string_t what;
7046 cmdline_fixed_string_t dstpool;
7048 cmdline_fixed_string_t on;
7051 cmdline_parse_token_string_t cmd_mirror_link_set =
7052 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7054 cmdline_parse_token_string_t cmd_mirror_link_port =
7055 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7057 cmdline_parse_token_num_t cmd_mirror_link_portid =
7058 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7060 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7061 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7062 mirror, "mirror-rule");
7063 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7064 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7066 cmdline_parse_token_string_t cmd_mirror_link_what =
7067 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7068 what, "uplink-mirror#downlink-mirror");
7069 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7070 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7071 dstpool, "dst-pool");
7072 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7073 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7075 cmdline_parse_token_string_t cmd_mirror_link_on =
7076 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7080 cmd_set_mirror_link_parsed(void *parsed_result,
7081 __attribute__((unused)) struct cmdline *cl,
7082 __attribute__((unused)) void *data)
7085 struct cmd_set_mirror_link_result *res = parsed_result;
7086 struct rte_eth_vmdq_mirror_conf mr_conf;
7088 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
7089 if(!strcmp(res->what, "uplink-mirror")) {
7090 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
7091 }else if(!strcmp(res->what, "downlink-mirror"))
7092 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
7094 mr_conf.dst_pool = res->dstpool_id;
7096 if(!strcmp(res->on, "on"))
7097 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7100 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7103 /* check the return value and print it if is < 0 */
7105 printf("mirror rule add error: (%s)\n", strerror(-ret));
7109 cmdline_parse_inst_t cmd_set_mirror_link = {
7110 .f = cmd_set_mirror_link_parsed,
7112 .help_str = "set port X mirror-rule Y uplink-mirror|"
7113 "downlink-mirror dst-pool Z on|off",
7115 (void *)&cmd_mirror_link_set,
7116 (void *)&cmd_mirror_link_port,
7117 (void *)&cmd_mirror_link_portid,
7118 (void *)&cmd_mirror_link_mirror,
7119 (void *)&cmd_mirror_link_ruleid,
7120 (void *)&cmd_mirror_link_what,
7121 (void *)&cmd_mirror_link_dstpool,
7122 (void *)&cmd_mirror_link_poolid,
7123 (void *)&cmd_mirror_link_on,
7128 /* *** RESET VM MIRROR RULE *** */
7129 struct cmd_rm_mirror_rule_result {
7130 cmdline_fixed_string_t reset;
7131 cmdline_fixed_string_t port;
7133 cmdline_fixed_string_t mirror;
7137 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7138 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7140 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7141 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7143 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7144 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7146 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7147 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7148 mirror, "mirror-rule");
7149 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7150 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7154 cmd_reset_mirror_rule_parsed(void *parsed_result,
7155 __attribute__((unused)) struct cmdline *cl,
7156 __attribute__((unused)) void *data)
7159 struct cmd_set_mirror_link_result *res = parsed_result;
7161 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7163 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7166 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7167 .f = cmd_reset_mirror_rule_parsed,
7169 .help_str = "reset port X mirror-rule Y",
7171 (void *)&cmd_rm_mirror_rule_reset,
7172 (void *)&cmd_rm_mirror_rule_port,
7173 (void *)&cmd_rm_mirror_rule_portid,
7174 (void *)&cmd_rm_mirror_rule_mirror,
7175 (void *)&cmd_rm_mirror_rule_ruleid,
7180 /* ******************************************************************************** */
7182 struct cmd_dump_result {
7183 cmdline_fixed_string_t dump;
7187 dump_struct_sizes(void)
7189 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7190 DUMP_SIZE(struct rte_mbuf);
7191 DUMP_SIZE(struct rte_mempool);
7192 DUMP_SIZE(struct rte_ring);
7196 static void cmd_dump_parsed(void *parsed_result,
7197 __attribute__((unused)) struct cmdline *cl,
7198 __attribute__((unused)) void *data)
7200 struct cmd_dump_result *res = parsed_result;
7202 if (!strcmp(res->dump, "dump_physmem"))
7203 rte_dump_physmem_layout(stdout);
7204 else if (!strcmp(res->dump, "dump_memzone"))
7205 rte_memzone_dump(stdout);
7206 else if (!strcmp(res->dump, "dump_log_history"))
7207 rte_log_dump_history(stdout);
7208 else if (!strcmp(res->dump, "dump_struct_sizes"))
7209 dump_struct_sizes();
7210 else if (!strcmp(res->dump, "dump_ring"))
7211 rte_ring_list_dump(stdout);
7212 else if (!strcmp(res->dump, "dump_mempool"))
7213 rte_mempool_list_dump(stdout);
7214 else if (!strcmp(res->dump, "dump_devargs"))
7215 rte_eal_devargs_dump(stdout);
7218 cmdline_parse_token_string_t cmd_dump_dump =
7219 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7223 "dump_struct_sizes#"
7228 cmdline_parse_inst_t cmd_dump = {
7229 .f = cmd_dump_parsed, /* function to call */
7230 .data = NULL, /* 2nd arg of func */
7231 .help_str = "dump status",
7232 .tokens = { /* token list, NULL terminated */
7233 (void *)&cmd_dump_dump,
7238 /* ******************************************************************************** */
7240 struct cmd_dump_one_result {
7241 cmdline_fixed_string_t dump;
7242 cmdline_fixed_string_t name;
7245 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7246 __attribute__((unused)) void *data)
7248 struct cmd_dump_one_result *res = parsed_result;
7250 if (!strcmp(res->dump, "dump_ring")) {
7252 r = rte_ring_lookup(res->name);
7254 cmdline_printf(cl, "Cannot find ring\n");
7257 rte_ring_dump(stdout, r);
7258 } else if (!strcmp(res->dump, "dump_mempool")) {
7259 struct rte_mempool *mp;
7260 mp = rte_mempool_lookup(res->name);
7262 cmdline_printf(cl, "Cannot find mempool\n");
7265 rte_mempool_dump(stdout, mp);
7269 cmdline_parse_token_string_t cmd_dump_one_dump =
7270 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7271 "dump_ring#dump_mempool");
7273 cmdline_parse_token_string_t cmd_dump_one_name =
7274 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7276 cmdline_parse_inst_t cmd_dump_one = {
7277 .f = cmd_dump_one_parsed, /* function to call */
7278 .data = NULL, /* 2nd arg of func */
7279 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7280 .tokens = { /* token list, NULL terminated */
7281 (void *)&cmd_dump_one_dump,
7282 (void *)&cmd_dump_one_name,
7287 /* *** set SYN filter *** */
7288 struct cmd_set_syn_filter_result {
7289 cmdline_fixed_string_t filter;
7291 cmdline_fixed_string_t priority;
7292 cmdline_fixed_string_t high;
7293 cmdline_fixed_string_t queue;
7298 cmd_set_syn_filter_parsed(void *parsed_result,
7299 __attribute__((unused)) struct cmdline *cl,
7300 __attribute__((unused)) void *data)
7303 struct cmd_set_syn_filter_result *res = parsed_result;
7304 struct rte_syn_filter filter;
7306 if (!strcmp(res->filter, "add_syn_filter")) {
7307 if (!strcmp(res->high, "high"))
7311 ret = rte_eth_dev_add_syn_filter(res->port_id,
7312 &filter, res->queue_id);
7313 } else if (!strcmp(res->filter, "remove_syn_filter"))
7314 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7315 else if (!strcmp(res->filter, "get_syn_filter"))
7316 get_syn_filter(res->port_id);
7318 printf("syn filter setting error: (%s)\n", strerror(-ret));
7321 cmdline_parse_token_num_t cmd_syn_filter_portid =
7322 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7324 cmdline_parse_token_string_t cmd_syn_filter_priority =
7325 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7326 priority, "priority");
7327 cmdline_parse_token_string_t cmd_syn_filter_high =
7328 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7330 cmdline_parse_token_string_t cmd_syn_filter_queue =
7331 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7333 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7334 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7336 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7337 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7338 filter, "add_syn_filter");
7339 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7340 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7341 filter, "remove_syn_filter");
7342 cmdline_parse_inst_t cmd_add_syn_filter = {
7343 .f = cmd_set_syn_filter_parsed,
7345 .help_str = "add syn filter",
7347 (void *)&cmd_syn_filter_add_filter,
7348 (void *)&cmd_syn_filter_portid,
7349 (void *)&cmd_syn_filter_priority,
7350 (void *)&cmd_syn_filter_high,
7351 (void *)&cmd_syn_filter_queue,
7352 (void *)&cmd_syn_filter_queue_id,
7356 cmdline_parse_inst_t cmd_remove_syn_filter = {
7357 .f = cmd_set_syn_filter_parsed,
7359 .help_str = "remove syn filter",
7361 (void *)&cmd_syn_filter_remove_filter,
7362 (void *)&cmd_syn_filter_portid,
7367 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7368 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7369 filter, "get_syn_filter");
7371 cmdline_parse_inst_t cmd_get_syn_filter = {
7372 .f = cmd_set_syn_filter_parsed,
7374 .help_str = "get syn filter",
7376 (void *)&cmd_syn_filter_get_filter,
7377 (void *)&cmd_syn_filter_portid,
7382 /* *** ADD/REMOVE A 2tuple FILTER *** */
7383 struct cmd_2tuple_filter_result {
7384 cmdline_fixed_string_t filter;
7386 cmdline_fixed_string_t protocol;
7387 uint8_t protocol_value;
7388 uint8_t protocol_mask;
7389 cmdline_fixed_string_t dst_port;
7390 uint16_t dst_port_value;
7391 uint16_t dst_port_mask;
7392 cmdline_fixed_string_t flags;
7393 uint8_t flags_value;
7394 cmdline_fixed_string_t priority;
7395 uint8_t priority_value;
7396 cmdline_fixed_string_t queue;
7398 cmdline_fixed_string_t index;
7399 uint16_t index_value;
7403 cmd_2tuple_filter_parsed(void *parsed_result,
7404 __attribute__((unused)) struct cmdline *cl,
7405 __attribute__((unused)) void *data)
7408 struct rte_2tuple_filter filter;
7409 struct cmd_2tuple_filter_result *res = parsed_result;
7411 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7413 if (!strcmp(res->filter, "add_2tuple_filter")) {
7414 /* need convert to big endian. */
7415 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7416 filter.protocol = res->protocol_value;
7417 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7418 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7419 filter.priority = res->priority_value;
7420 filter.tcp_flags = res->flags_value;
7421 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7422 res->index_value, &filter, res->queue_id);
7423 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7424 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7426 else if (!strcmp(res->filter, "get_2tuple_filter"))
7427 get_2tuple_filter(res->port_id, res->index_value);
7430 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7433 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7434 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7436 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7437 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7438 protocol, "protocol");
7439 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7440 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7441 protocol_value, UINT8);
7442 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7443 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7444 protocol_mask, UINT8);
7445 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7446 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7447 dst_port, "dst_port");
7448 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7449 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7450 dst_port_value, UINT16);
7451 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7452 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7453 dst_port_mask, UINT16);
7454 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7455 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7457 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7458 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7459 flags_value, UINT8);
7460 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7461 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7462 priority, "priority");
7463 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7464 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7465 priority_value, UINT8);
7466 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7467 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7469 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7470 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7472 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7473 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7475 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7476 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7477 index_value, UINT16);
7478 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7479 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7480 filter, "add_2tuple_filter");
7481 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7482 .f = cmd_2tuple_filter_parsed,
7484 .help_str = "add a 2tuple filter",
7486 (void *)&cmd_2tuple_filter_add_filter,
7487 (void *)&cmd_2tuple_filter_port_id,
7488 (void *)&cmd_2tuple_filter_protocol,
7489 (void *)&cmd_2tuple_filter_protocol_value,
7490 (void *)&cmd_2tuple_filter_protocol_mask,
7491 (void *)&cmd_2tuple_filter_dst_port,
7492 (void *)&cmd_2tuple_filter_dst_port_value,
7493 (void *)&cmd_2tuple_filter_dst_port_mask,
7494 (void *)&cmd_2tuple_filter_flags,
7495 (void *)&cmd_2tuple_filter_flags_value,
7496 (void *)&cmd_2tuple_filter_priority,
7497 (void *)&cmd_2tuple_filter_priority_value,
7498 (void *)&cmd_2tuple_filter_queue,
7499 (void *)&cmd_2tuple_filter_queue_id,
7500 (void *)&cmd_2tuple_filter_index,
7501 (void *)&cmd_2tuple_filter_index_value,
7506 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7507 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7508 filter, "remove_2tuple_filter");
7509 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7510 .f = cmd_2tuple_filter_parsed,
7512 .help_str = "remove a 2tuple filter",
7514 (void *)&cmd_2tuple_filter_remove_filter,
7515 (void *)&cmd_2tuple_filter_port_id,
7516 (void *)&cmd_2tuple_filter_index,
7517 (void *)&cmd_2tuple_filter_index_value,
7521 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7522 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7523 filter, "get_2tuple_filter");
7524 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7525 .f = cmd_2tuple_filter_parsed,
7527 .help_str = "get a 2tuple filter",
7529 (void *)&cmd_2tuple_filter_get_filter,
7530 (void *)&cmd_2tuple_filter_port_id,
7531 (void *)&cmd_2tuple_filter_index,
7532 (void *)&cmd_2tuple_filter_index_value,
7537 /* *** ADD/REMOVE A 5tuple FILTER *** */
7538 struct cmd_5tuple_filter_result {
7539 cmdline_fixed_string_t filter;
7541 cmdline_fixed_string_t dst_ip;
7542 cmdline_ipaddr_t dst_ip_value;
7543 cmdline_fixed_string_t src_ip;
7544 cmdline_ipaddr_t src_ip_value;
7545 cmdline_fixed_string_t dst_port;
7546 uint16_t dst_port_value;
7547 cmdline_fixed_string_t src_port;
7548 uint16_t src_port_value;
7549 cmdline_fixed_string_t protocol;
7550 uint8_t protocol_value;
7551 cmdline_fixed_string_t mask;
7553 cmdline_fixed_string_t flags;
7554 uint8_t flags_value;
7555 cmdline_fixed_string_t priority;
7556 uint8_t priority_value;
7557 cmdline_fixed_string_t queue;
7559 cmdline_fixed_string_t index;
7560 uint16_t index_value;
7564 cmd_5tuple_filter_parsed(void *parsed_result,
7565 __attribute__((unused)) struct cmdline *cl,
7566 __attribute__((unused)) void *data)
7569 struct rte_5tuple_filter filter;
7570 struct cmd_5tuple_filter_result *res = parsed_result;
7572 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7574 if (!strcmp(res->filter, "add_5tuple_filter")) {
7575 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7576 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7577 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7578 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7579 filter.protocol = res->protocol_value;
7580 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7581 filter.priority = res->priority_value;
7582 filter.tcp_flags = res->flags_value;
7584 if (res->dst_ip_value.family == AF_INET)
7585 /* no need to convert, already big endian. */
7586 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7588 if (filter.dst_ip_mask == 0) {
7589 printf("can not support ipv6 involved compare.\n");
7595 if (res->src_ip_value.family == AF_INET)
7596 /* no need to convert, already big endian. */
7597 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7599 if (filter.src_ip_mask == 0) {
7600 printf("can not support ipv6 involved compare.\n");
7605 /* need convert to big endian. */
7606 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7607 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7609 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7610 res->index_value, &filter, res->queue_id);
7611 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7612 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7614 else if (!strcmp(res->filter, "get_5tuple_filter"))
7615 get_5tuple_filter(res->port_id, res->index_value);
7617 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7621 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7622 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7624 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7625 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7627 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7628 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7630 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7631 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7633 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7634 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7636 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7637 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7638 dst_port, "dst_port");
7639 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7640 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7641 dst_port_value, UINT16);
7642 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7643 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7644 src_port, "src_port");
7645 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7646 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7647 src_port_value, UINT16);
7648 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7649 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7650 protocol, "protocol");
7651 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7652 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7653 protocol_value, UINT8);
7654 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7655 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7657 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7658 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7660 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7661 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7663 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7664 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7665 flags_value, UINT8);
7666 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7667 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7668 priority, "priority");
7669 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7670 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7671 priority_value, UINT8);
7672 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7673 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7675 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7676 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7678 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7679 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7681 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7682 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7683 index_value, UINT16);
7685 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7686 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7687 filter, "add_5tuple_filter");
7688 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7689 .f = cmd_5tuple_filter_parsed,
7691 .help_str = "add a 5tuple filter",
7693 (void *)&cmd_5tuple_filter_add_filter,
7694 (void *)&cmd_5tuple_filter_port_id,
7695 (void *)&cmd_5tuple_filter_dst_ip,
7696 (void *)&cmd_5tuple_filter_dst_ip_value,
7697 (void *)&cmd_5tuple_filter_src_ip,
7698 (void *)&cmd_5tuple_filter_src_ip_value,
7699 (void *)&cmd_5tuple_filter_dst_port,
7700 (void *)&cmd_5tuple_filter_dst_port_value,
7701 (void *)&cmd_5tuple_filter_src_port,
7702 (void *)&cmd_5tuple_filter_src_port_value,
7703 (void *)&cmd_5tuple_filter_protocol,
7704 (void *)&cmd_5tuple_filter_protocol_value,
7705 (void *)&cmd_5tuple_filter_mask,
7706 (void *)&cmd_5tuple_filter_mask_value,
7707 (void *)&cmd_5tuple_filter_flags,
7708 (void *)&cmd_5tuple_filter_flags_value,
7709 (void *)&cmd_5tuple_filter_priority,
7710 (void *)&cmd_5tuple_filter_priority_value,
7711 (void *)&cmd_5tuple_filter_queue,
7712 (void *)&cmd_5tuple_filter_queue_id,
7713 (void *)&cmd_5tuple_filter_index,
7714 (void *)&cmd_5tuple_filter_index_value,
7719 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7720 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7721 filter, "remove_5tuple_filter");
7722 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7723 .f = cmd_5tuple_filter_parsed,
7725 .help_str = "remove a 5tuple filter",
7727 (void *)&cmd_5tuple_filter_remove_filter,
7728 (void *)&cmd_5tuple_filter_port_id,
7729 (void *)&cmd_5tuple_filter_index,
7730 (void *)&cmd_5tuple_filter_index_value,
7735 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7736 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7737 filter, "get_5tuple_filter");
7738 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7739 .f = cmd_5tuple_filter_parsed,
7741 .help_str = "get a 5tuple filter",
7743 (void *)&cmd_5tuple_filter_get_filter,
7744 (void *)&cmd_5tuple_filter_port_id,
7745 (void *)&cmd_5tuple_filter_index,
7746 (void *)&cmd_5tuple_filter_index_value,
7751 /* *** ADD/REMOVE A flex FILTER *** */
7752 struct cmd_flex_filter_result {
7753 cmdline_fixed_string_t filter;
7755 cmdline_fixed_string_t len;
7757 cmdline_fixed_string_t bytes;
7758 cmdline_fixed_string_t bytes_value;
7759 cmdline_fixed_string_t mask;
7760 cmdline_fixed_string_t mask_value;
7761 cmdline_fixed_string_t priority;
7762 uint8_t priority_value;
7763 cmdline_fixed_string_t queue;
7765 cmdline_fixed_string_t index;
7766 uint16_t index_value;
7769 static int xdigit2val(unsigned char c)
7774 else if (isupper(c))
7782 cmd_flex_filter_parsed(void *parsed_result,
7783 __attribute__((unused)) struct cmdline *cl,
7784 __attribute__((unused)) void *data)
7787 struct rte_flex_filter filter;
7788 struct cmd_flex_filter_result *res = parsed_result;
7789 char *bytes_ptr, *mask_ptr;
7797 if (!strcmp(res->filter, "add_flex_filter")) {
7798 if (res->len_value > 128) {
7799 printf("the len exceed the max length 128\n");
7802 memset(&filter, 0, sizeof(struct rte_flex_filter));
7803 filter.len = res->len_value;
7804 filter.priority = res->priority_value;
7805 bytes_ptr = res->bytes_value;
7806 mask_ptr = res->mask_value;
7809 /* translate bytes string to uint_32 array. */
7810 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7811 (bytes_ptr[1] == 'X')))
7813 len = strnlen(bytes_ptr, res->len_value * 2);
7814 if (len == 0 || (len % 8 != 0)) {
7815 printf("please check len and bytes input\n");
7818 for (i = 0; i < len; i++) {
7820 if (isxdigit(c) == 0) {
7821 /* invalid characters. */
7822 printf("invalid input\n");
7825 val = xdigit2val(c);
7829 dword |= byte << (4 * mod - 4);
7834 filter.dwords[j] = dword;
7835 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7841 /* translate mask string to uint8_t array. */
7843 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7844 (mask_ptr[1] == 'X')))
7846 len = strnlen(mask_ptr, (res->len_value+3)/4);
7848 printf("invalid input\n");
7851 for (i = 0; i < len; i++) {
7853 if (isxdigit(c) == 0) {
7854 /* invalid characters. */
7855 printf("invalid input\n");
7858 val = xdigit2val(c);
7859 hex |= (uint8_t)(val & 0x8) >> 3;
7860 hex |= (uint8_t)(val & 0x4) >> 1;
7861 hex |= (uint8_t)(val & 0x2) << 1;
7862 hex |= (uint8_t)(val & 0x1) << 3;
7865 filter.mask[j] = byte;
7866 printf("mask[%d]:%02x ", j, filter.mask[j]);
7874 printf("call function rte_eth_dev_add_flex_filter: "
7875 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7876 res->index_value, res->queue_id,
7877 filter.len, filter.priority);
7878 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7879 &filter, res->queue_id);
7881 } else if (!strcmp(res->filter, "remove_flex_filter"))
7882 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7884 else if (!strcmp(res->filter, "get_flex_filter"))
7885 get_flex_filter(res->port_id, res->index_value);
7888 printf("flex filter setting error: (%s)\n", strerror(-ret));
7891 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7892 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7894 cmdline_parse_token_string_t cmd_flex_filter_len =
7895 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7897 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7898 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7900 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7901 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7903 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7904 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7906 cmdline_parse_token_string_t cmd_flex_filter_mask =
7907 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7909 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7910 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7912 cmdline_parse_token_string_t cmd_flex_filter_priority =
7913 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7914 priority, "priority");
7915 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7916 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7917 priority_value, UINT8);
7918 cmdline_parse_token_string_t cmd_flex_filter_queue =
7919 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7921 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7922 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7924 cmdline_parse_token_string_t cmd_flex_filter_index =
7925 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7927 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7928 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7929 index_value, UINT16);
7930 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7931 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7932 filter, "add_flex_filter");
7933 cmdline_parse_inst_t cmd_add_flex_filter = {
7934 .f = cmd_flex_filter_parsed,
7936 .help_str = "add a flex filter",
7938 (void *)&cmd_flex_filter_add_filter,
7939 (void *)&cmd_flex_filter_port_id,
7940 (void *)&cmd_flex_filter_len,
7941 (void *)&cmd_flex_filter_len_value,
7942 (void *)&cmd_flex_filter_bytes,
7943 (void *)&cmd_flex_filter_bytes_value,
7944 (void *)&cmd_flex_filter_mask,
7945 (void *)&cmd_flex_filter_mask_value,
7946 (void *)&cmd_flex_filter_priority,
7947 (void *)&cmd_flex_filter_priority_value,
7948 (void *)&cmd_flex_filter_queue,
7949 (void *)&cmd_flex_filter_queue_id,
7950 (void *)&cmd_flex_filter_index,
7951 (void *)&cmd_flex_filter_index_value,
7956 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7957 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7958 filter, "remove_flex_filter");
7959 cmdline_parse_inst_t cmd_remove_flex_filter = {
7960 .f = cmd_flex_filter_parsed,
7962 .help_str = "remove a flex filter",
7964 (void *)&cmd_flex_filter_remove_filter,
7965 (void *)&cmd_flex_filter_port_id,
7966 (void *)&cmd_flex_filter_index,
7967 (void *)&cmd_flex_filter_index_value,
7972 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7973 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7974 filter, "get_flex_filter");
7975 cmdline_parse_inst_t cmd_get_flex_filter = {
7976 .f = cmd_flex_filter_parsed,
7978 .help_str = "get a flex filter",
7980 (void *)&cmd_flex_filter_get_filter,
7981 (void *)&cmd_flex_filter_port_id,
7982 (void *)&cmd_flex_filter_index,
7983 (void *)&cmd_flex_filter_index_value,
7988 /* *** Filters Control *** */
7990 /* *** deal with ethertype filter *** */
7991 struct cmd_ethertype_filter_result {
7992 cmdline_fixed_string_t filter;
7994 cmdline_fixed_string_t ops;
7995 cmdline_fixed_string_t mac;
7996 struct ether_addr mac_addr;
7997 cmdline_fixed_string_t ethertype;
7998 uint16_t ethertype_value;
7999 cmdline_fixed_string_t drop;
8000 cmdline_fixed_string_t queue;
8004 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8005 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8006 filter, "ethertype_filter");
8007 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8008 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8010 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8011 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8013 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8014 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8015 mac, "mac_addr#mac_ignr");
8016 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8017 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8019 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8020 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8021 ethertype, "ethertype");
8022 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8023 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8024 ethertype_value, UINT16);
8025 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8026 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8028 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8029 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8031 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8032 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8036 cmd_ethertype_filter_parsed(void *parsed_result,
8037 __attribute__((unused)) struct cmdline *cl,
8038 __attribute__((unused)) void *data)
8040 struct cmd_ethertype_filter_result *res = parsed_result;
8041 struct rte_eth_ethertype_filter filter;
8044 ret = rte_eth_dev_filter_supported(res->port_id,
8045 RTE_ETH_FILTER_ETHERTYPE);
8047 printf("ethertype filter is not supported on port %u.\n",
8052 memset(&filter, 0, sizeof(filter));
8053 if (!strcmp(res->mac, "mac_addr")) {
8054 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8055 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8056 sizeof(struct ether_addr));
8058 if (!strcmp(res->drop, "drop"))
8059 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8060 filter.ether_type = res->ethertype_value;
8061 filter.queue = res->queue_id;
8063 if (!strcmp(res->ops, "add"))
8064 ret = rte_eth_dev_filter_ctrl(res->port_id,
8065 RTE_ETH_FILTER_ETHERTYPE,
8069 ret = rte_eth_dev_filter_ctrl(res->port_id,
8070 RTE_ETH_FILTER_ETHERTYPE,
8071 RTE_ETH_FILTER_DELETE,
8074 printf("ethertype filter programming error: (%s)\n",
8078 cmdline_parse_inst_t cmd_ethertype_filter = {
8079 .f = cmd_ethertype_filter_parsed,
8081 .help_str = "add or delete an ethertype filter entry",
8083 (void *)&cmd_ethertype_filter_filter,
8084 (void *)&cmd_ethertype_filter_port_id,
8085 (void *)&cmd_ethertype_filter_ops,
8086 (void *)&cmd_ethertype_filter_mac,
8087 (void *)&cmd_ethertype_filter_mac_addr,
8088 (void *)&cmd_ethertype_filter_ethertype,
8089 (void *)&cmd_ethertype_filter_ethertype_value,
8090 (void *)&cmd_ethertype_filter_drop,
8091 (void *)&cmd_ethertype_filter_queue,
8092 (void *)&cmd_ethertype_filter_queue_id,
8097 /* *** deal with flow director filter *** */
8098 struct cmd_flow_director_result {
8099 cmdline_fixed_string_t flow_director_filter;
8101 cmdline_fixed_string_t ops;
8102 cmdline_fixed_string_t flow;
8103 cmdline_fixed_string_t flow_type;
8104 cmdline_fixed_string_t src;
8105 cmdline_ipaddr_t ip_src;
8107 cmdline_fixed_string_t dst;
8108 cmdline_ipaddr_t ip_dst;
8110 cmdline_fixed_string_t verify_tag;
8111 uint32_t verify_tag_value;
8112 cmdline_fixed_string_t flexbytes;
8113 cmdline_fixed_string_t flexbytes_value;
8114 cmdline_fixed_string_t drop;
8115 cmdline_fixed_string_t queue;
8117 cmdline_fixed_string_t fd_id;
8118 uint32_t fd_id_value;
8122 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8125 const char *p, *p0 = q_arg;
8127 unsigned long int_fld;
8128 char *str_fld[max_num];
8133 p = strchr(p0, '(');
8137 p0 = strchr(p, ')');
8142 if (size >= sizeof(s))
8145 snprintf(s, sizeof(s), "%.*s", size, p);
8146 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8147 if (ret < 0 || ret > max_num)
8149 for (i = 0; i < ret; i++) {
8151 int_fld = strtoul(str_fld[i], &end, 0);
8152 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8154 flexbytes[i] = (uint8_t)int_fld;
8159 static enum rte_eth_flow_type
8160 str2flowtype(char *string)
8163 static const struct {
8165 enum rte_eth_flow_type type;
8166 } flowtype_str[] = {
8167 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8168 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8169 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8170 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8171 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8172 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8173 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8174 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8175 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8176 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8179 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8180 if (!strcmp(flowtype_str[i].str, string))
8181 return flowtype_str[i].type;
8183 return RTE_ETH_FLOW_TYPE_NONE;
8186 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8188 if ((ip_addr).family == AF_INET) \
8189 (ip) = (ip_addr).addr.ipv4.s_addr; \
8191 printf("invalid parameter.\n"); \
8196 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8198 if ((ip_addr).family == AF_INET6) \
8199 (void)rte_memcpy(&(ip), \
8200 &((ip_addr).addr.ipv6), \
8201 sizeof(struct in6_addr)); \
8203 printf("invalid parameter.\n"); \
8209 cmd_flow_director_filter_parsed(void *parsed_result,
8210 __attribute__((unused)) struct cmdline *cl,
8211 __attribute__((unused)) void *data)
8213 struct cmd_flow_director_result *res = parsed_result;
8214 struct rte_eth_fdir_filter entry;
8215 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8218 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8220 printf("flow director is not supported on port %u.\n",
8224 memset(flexbytes, 0, sizeof(flexbytes));
8225 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8226 ret = parse_flexbytes(res->flexbytes_value,
8228 RTE_ETH_FDIR_MAX_FLEXLEN);
8230 printf("error: Cannot parse flexbytes input.\n");
8234 entry.input.flow_type = str2flowtype(res->flow_type);
8235 switch (entry.input.flow_type) {
8236 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
8237 case RTE_ETH_FLOW_TYPE_UDPV4:
8238 case RTE_ETH_FLOW_TYPE_TCPV4:
8239 IPV4_ADDR_TO_UINT(res->ip_dst,
8240 entry.input.flow.ip4_flow.dst_ip);
8241 IPV4_ADDR_TO_UINT(res->ip_src,
8242 entry.input.flow.ip4_flow.src_ip);
8243 /* need convert to big endian. */
8244 entry.input.flow.udp4_flow.dst_port =
8245 rte_cpu_to_be_16(res->port_dst);
8246 entry.input.flow.udp4_flow.src_port =
8247 rte_cpu_to_be_16(res->port_src);
8249 case RTE_ETH_FLOW_TYPE_SCTPV4:
8250 IPV4_ADDR_TO_UINT(res->ip_dst,
8251 entry.input.flow.sctp4_flow.ip.dst_ip);
8252 IPV4_ADDR_TO_UINT(res->ip_src,
8253 entry.input.flow.sctp4_flow.ip.src_ip);
8254 /* need convert to big endian. */
8255 entry.input.flow.sctp4_flow.verify_tag =
8256 rte_cpu_to_be_32(res->verify_tag_value);
8258 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
8259 case RTE_ETH_FLOW_TYPE_UDPV6:
8260 case RTE_ETH_FLOW_TYPE_TCPV6:
8261 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8262 entry.input.flow.ipv6_flow.dst_ip);
8263 IPV6_ADDR_TO_ARRAY(res->ip_src,
8264 entry.input.flow.ipv6_flow.src_ip);
8265 /* need convert to big endian. */
8266 entry.input.flow.udp6_flow.dst_port =
8267 rte_cpu_to_be_16(res->port_dst);
8268 entry.input.flow.udp6_flow.src_port =
8269 rte_cpu_to_be_16(res->port_src);
8271 case RTE_ETH_FLOW_TYPE_SCTPV6:
8272 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8273 entry.input.flow.sctp6_flow.ip.dst_ip);
8274 IPV6_ADDR_TO_ARRAY(res->ip_src,
8275 entry.input.flow.sctp6_flow.ip.src_ip);
8276 /* need convert to big endian. */
8277 entry.input.flow.sctp6_flow.verify_tag =
8278 rte_cpu_to_be_32(res->verify_tag_value);
8281 printf("invalid parameter.\n");
8284 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8286 RTE_ETH_FDIR_MAX_FLEXLEN);
8288 entry.action.flex_off = 0; /*use 0 by default */
8289 if (!strcmp(res->drop, "drop"))
8290 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8292 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8293 /* set to report FD ID by default */
8294 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8295 entry.action.rx_queue = res->queue_id;
8296 entry.soft_id = res->fd_id_value;
8297 if (!strcmp(res->ops, "add"))
8298 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8299 RTE_ETH_FILTER_ADD, &entry);
8301 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8302 RTE_ETH_FILTER_DELETE, &entry);
8304 printf("flow director programming error: (%s)\n",
8308 cmdline_parse_token_string_t cmd_flow_director_filter =
8309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8310 flow_director_filter, "flow_director_filter");
8311 cmdline_parse_token_num_t cmd_flow_director_port_id =
8312 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8314 cmdline_parse_token_string_t cmd_flow_director_ops =
8315 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8317 cmdline_parse_token_string_t cmd_flow_director_flow =
8318 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8320 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8321 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8323 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8324 "ip6#ip6-frag#tcp6#udp6#sctp6");
8325 cmdline_parse_token_string_t cmd_flow_director_src =
8326 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8328 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8329 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8331 cmdline_parse_token_num_t cmd_flow_director_port_src =
8332 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8334 cmdline_parse_token_string_t cmd_flow_director_dst =
8335 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8337 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8338 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8340 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8341 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8343 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8344 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8345 verify_tag, "verify_tag");
8346 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8347 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8348 verify_tag_value, UINT32);
8349 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8350 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8351 flexbytes, "flexbytes");
8352 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8354 flexbytes_value, NULL);
8355 cmdline_parse_token_string_t cmd_flow_director_drop =
8356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8358 cmdline_parse_token_string_t cmd_flow_director_queue =
8359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8361 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8362 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8364 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8367 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8368 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8369 fd_id_value, UINT32);
8371 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8372 .f = cmd_flow_director_filter_parsed,
8374 .help_str = "add or delete an ip flow director entry on NIC",
8376 (void *)&cmd_flow_director_filter,
8377 (void *)&cmd_flow_director_port_id,
8378 (void *)&cmd_flow_director_ops,
8379 (void *)&cmd_flow_director_flow,
8380 (void *)&cmd_flow_director_flow_type,
8381 (void *)&cmd_flow_director_src,
8382 (void *)&cmd_flow_director_ip_src,
8383 (void *)&cmd_flow_director_dst,
8384 (void *)&cmd_flow_director_ip_dst,
8385 (void *)&cmd_flow_director_flexbytes,
8386 (void *)&cmd_flow_director_flexbytes_value,
8387 (void *)&cmd_flow_director_drop,
8388 (void *)&cmd_flow_director_queue,
8389 (void *)&cmd_flow_director_queue_id,
8390 (void *)&cmd_flow_director_fd_id,
8391 (void *)&cmd_flow_director_fd_id_value,
8396 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8397 .f = cmd_flow_director_filter_parsed,
8399 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8401 (void *)&cmd_flow_director_filter,
8402 (void *)&cmd_flow_director_port_id,
8403 (void *)&cmd_flow_director_ops,
8404 (void *)&cmd_flow_director_flow,
8405 (void *)&cmd_flow_director_flow_type,
8406 (void *)&cmd_flow_director_src,
8407 (void *)&cmd_flow_director_ip_src,
8408 (void *)&cmd_flow_director_port_src,
8409 (void *)&cmd_flow_director_dst,
8410 (void *)&cmd_flow_director_ip_dst,
8411 (void *)&cmd_flow_director_port_dst,
8412 (void *)&cmd_flow_director_flexbytes,
8413 (void *)&cmd_flow_director_flexbytes_value,
8414 (void *)&cmd_flow_director_drop,
8415 (void *)&cmd_flow_director_queue,
8416 (void *)&cmd_flow_director_queue_id,
8417 (void *)&cmd_flow_director_fd_id,
8418 (void *)&cmd_flow_director_fd_id_value,
8423 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8424 .f = cmd_flow_director_filter_parsed,
8426 .help_str = "add or delete a sctp flow director entry on NIC",
8428 (void *)&cmd_flow_director_filter,
8429 (void *)&cmd_flow_director_port_id,
8430 (void *)&cmd_flow_director_ops,
8431 (void *)&cmd_flow_director_flow,
8432 (void *)&cmd_flow_director_flow_type,
8433 (void *)&cmd_flow_director_src,
8434 (void *)&cmd_flow_director_ip_src,
8435 (void *)&cmd_flow_director_dst,
8436 (void *)&cmd_flow_director_ip_dst,
8437 (void *)&cmd_flow_director_verify_tag,
8438 (void *)&cmd_flow_director_verify_tag_value,
8439 (void *)&cmd_flow_director_flexbytes,
8440 (void *)&cmd_flow_director_flexbytes_value,
8441 (void *)&cmd_flow_director_drop,
8442 (void *)&cmd_flow_director_queue,
8443 (void *)&cmd_flow_director_queue_id,
8444 (void *)&cmd_flow_director_fd_id,
8445 (void *)&cmd_flow_director_fd_id_value,
8450 struct cmd_flush_flow_director_result {
8451 cmdline_fixed_string_t flush_flow_director;
8455 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8456 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8457 flush_flow_director, "flush_flow_director");
8458 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8459 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8463 cmd_flush_flow_director_parsed(void *parsed_result,
8464 __attribute__((unused)) struct cmdline *cl,
8465 __attribute__((unused)) void *data)
8467 struct cmd_flow_director_result *res = parsed_result;
8470 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8472 printf("flow director is not supported on port %u.\n",
8477 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8478 RTE_ETH_FILTER_FLUSH, NULL);
8480 printf("flow director table flushing error: (%s)\n",
8484 cmdline_parse_inst_t cmd_flush_flow_director = {
8485 .f = cmd_flush_flow_director_parsed,
8487 .help_str = "flush all flow director entries of a device on NIC",
8489 (void *)&cmd_flush_flow_director_flush,
8490 (void *)&cmd_flush_flow_director_port_id,
8495 /* *** deal with flow director mask on flexible payload *** */
8496 struct cmd_flow_director_flex_mask_result {
8497 cmdline_fixed_string_t flow_director_flexmask;
8499 cmdline_fixed_string_t flow;
8500 cmdline_fixed_string_t flow_type;
8501 cmdline_fixed_string_t mask;
8505 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8506 __attribute__((unused)) struct cmdline *cl,
8507 __attribute__((unused)) void *data)
8509 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8510 struct rte_eth_fdir_flex_mask flex_mask;
8511 struct rte_port *port;
8512 enum rte_eth_flow_type i;
8515 if (res->port_id > nb_ports) {
8516 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8520 port = &ports[res->port_id];
8521 /** Check if the port is not started **/
8522 if (port->port_status != RTE_PORT_STOPPED) {
8523 printf("Please stop port %d first\n", res->port_id);
8527 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8528 ret = parse_flexbytes(res->mask,
8530 RTE_ETH_FDIR_MAX_FLEXLEN);
8532 printf("error: Cannot parse mask input.\n");
8535 if (!strcmp(res->flow_type, "all")) {
8536 for (i = RTE_ETH_FLOW_TYPE_UDPV4;
8537 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8539 flex_mask.flow_type = i;
8540 fdir_set_flex_mask(res->port_id, &flex_mask);
8542 cmd_reconfig_device_queue(res->port_id, 1, 0);
8545 flex_mask.flow_type = str2flowtype(res->flow_type);
8546 fdir_set_flex_mask(res->port_id, &flex_mask);
8547 cmd_reconfig_device_queue(res->port_id, 1, 1);
8550 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8551 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8552 flow_director_flexmask,
8553 "flow_director_flex_mask");
8554 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8555 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8557 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8558 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8560 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8561 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8563 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8564 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8565 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8569 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8570 .f = cmd_flow_director_flex_mask_parsed,
8572 .help_str = "set flow director's flex mask on NIC",
8574 (void *)&cmd_flow_director_flexmask,
8575 (void *)&cmd_flow_director_flexmask_port_id,
8576 (void *)&cmd_flow_director_flexmask_flow,
8577 (void *)&cmd_flow_director_flexmask_flow_type,
8578 (void *)&cmd_flow_director_flexmask_mask,
8583 /* *** deal with flow director flexible payload configuration *** */
8584 struct cmd_flow_director_flexpayload_result {
8585 cmdline_fixed_string_t flow_director_flexpayload;
8587 cmdline_fixed_string_t payload_layer;
8588 cmdline_fixed_string_t payload_cfg;
8592 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8595 const char *p, *p0 = q_arg;
8597 unsigned long int_fld;
8598 char *str_fld[max_num];
8603 p = strchr(p0, '(');
8607 p0 = strchr(p, ')');
8612 if (size >= sizeof(s))
8615 snprintf(s, sizeof(s), "%.*s", size, p);
8616 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8617 if (ret < 0 || ret > max_num)
8619 for (i = 0; i < ret; i++) {
8621 int_fld = strtoul(str_fld[i], &end, 0);
8622 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8624 offsets[i] = (uint16_t)int_fld;
8630 cmd_flow_director_flxpld_parsed(void *parsed_result,
8631 __attribute__((unused)) struct cmdline *cl,
8632 __attribute__((unused)) void *data)
8634 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8635 struct rte_eth_flex_payload_cfg flex_cfg;
8636 struct rte_port *port;
8639 if (res->port_id > nb_ports) {
8640 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8644 port = &ports[res->port_id];
8645 /** Check if the port is not started **/
8646 if (port->port_status != RTE_PORT_STOPPED) {
8647 printf("Please stop port %d first\n", res->port_id);
8651 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8653 if (!strcmp(res->payload_layer, "l2"))
8654 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8655 else if (!strcmp(res->payload_layer, "l3"))
8656 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8657 else if (!strcmp(res->payload_layer, "l4"))
8658 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8660 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8661 RTE_ETH_FDIR_MAX_FLEXLEN);
8663 printf("error: Cannot parse flex payload input.\n");
8667 fdir_set_flex_payload(res->port_id, &flex_cfg);
8668 cmd_reconfig_device_queue(res->port_id, 1, 1);
8671 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8672 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8673 flow_director_flexpayload,
8674 "flow_director_flex_payload");
8675 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8676 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8678 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8679 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8680 payload_layer, "l2#l3#l4");
8681 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8682 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8685 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8686 .f = cmd_flow_director_flxpld_parsed,
8688 .help_str = "set flow director's flex payload on NIC",
8690 (void *)&cmd_flow_director_flexpayload,
8691 (void *)&cmd_flow_director_flexpayload_port_id,
8692 (void *)&cmd_flow_director_flexpayload_payload_layer,
8693 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8698 /* *** Classification Filters Control *** */
8699 /* *** Get symmetric hash enable per port *** */
8700 struct cmd_get_sym_hash_ena_per_port_result {
8701 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8706 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8707 __rte_unused struct cmdline *cl,
8708 __rte_unused void *data)
8710 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8711 struct rte_eth_hash_filter_info info;
8714 if (rte_eth_dev_filter_supported(res->port_id,
8715 RTE_ETH_FILTER_HASH) < 0) {
8716 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8721 memset(&info, 0, sizeof(info));
8722 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8723 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8724 RTE_ETH_FILTER_GET, &info);
8727 printf("Cannot get symmetric hash enable per port "
8728 "on port %u\n", res->port_id);
8732 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8733 "enabled" : "disabled", res->port_id);
8736 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8737 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8738 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8739 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8740 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8743 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8744 .f = cmd_get_sym_hash_per_port_parsed,
8746 .help_str = "get_sym_hash_ena_per_port port_id",
8748 (void *)&cmd_get_sym_hash_ena_per_port_all,
8749 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8754 /* *** Set symmetric hash enable per port *** */
8755 struct cmd_set_sym_hash_ena_per_port_result {
8756 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8757 cmdline_fixed_string_t enable;
8762 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8763 __rte_unused struct cmdline *cl,
8764 __rte_unused void *data)
8766 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8767 struct rte_eth_hash_filter_info info;
8770 if (rte_eth_dev_filter_supported(res->port_id,
8771 RTE_ETH_FILTER_HASH) < 0) {
8772 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8777 memset(&info, 0, sizeof(info));
8778 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8779 if (!strcmp(res->enable, "enable"))
8780 info.info.enable = 1;
8781 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8782 RTE_ETH_FILTER_SET, &info);
8784 printf("Cannot set symmetric hash enable per port on "
8785 "port %u\n", res->port_id);
8788 printf("Symmetric hash has been set to %s on port %u\n",
8789 res->enable, res->port_id);
8792 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8793 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8794 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8795 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8796 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8798 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8799 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8800 enable, "enable#disable");
8802 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8803 .f = cmd_set_sym_hash_per_port_parsed,
8805 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8807 (void *)&cmd_set_sym_hash_ena_per_port_all,
8808 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8809 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8814 /* Get global config of hash function */
8815 struct cmd_get_hash_global_config_result {
8816 cmdline_fixed_string_t get_hash_global_config;
8821 flowtype_to_str(enum rte_eth_flow_type ftype)
8826 enum rte_eth_flow_type ftype;
8828 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8829 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8830 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8831 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8832 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8833 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8834 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8835 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8836 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8837 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8840 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8841 if (ftype_table[i].ftype == ftype)
8842 return ftype_table[i].str;
8849 cmd_get_hash_global_config_parsed(void *parsed_result,
8850 __rte_unused struct cmdline *cl,
8851 __rte_unused void *data)
8853 struct cmd_get_hash_global_config_result *res = parsed_result;
8854 struct rte_eth_hash_filter_info info;
8855 uint32_t idx, offset, i;
8859 if (rte_eth_dev_filter_supported(res->port_id,
8860 RTE_ETH_FILTER_HASH) < 0) {
8861 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8866 memset(&info, 0, sizeof(info));
8867 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8868 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8869 RTE_ETH_FILTER_GET, &info);
8871 printf("Cannot get hash global configurations by port %d\n",
8876 switch (info.info.global_conf.hash_func) {
8877 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8878 printf("Hash function is Toeplitz\n");
8880 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8881 printf("Hash function is Simple XOR\n");
8884 printf("Unknown hash function\n");
8888 for (i = 0; i < RTE_ETH_FLOW_TYPE_MAX; i++) {
8889 idx = i / UINT32_BIT;
8890 offset = i % UINT32_BIT;
8891 if (!(info.info.global_conf.valid_bit_mask[idx] &
8894 str = flowtype_to_str((enum rte_eth_flow_type)i);
8897 printf("Symmetric hash is %s globally for flow type %s "
8899 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8900 (1UL << offset)) ? "enabled" : "disabled"), str,
8905 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8906 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8907 get_hash_global_config, "get_hash_global_config");
8908 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8909 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8912 cmdline_parse_inst_t cmd_get_hash_global_config = {
8913 .f = cmd_get_hash_global_config_parsed,
8915 .help_str = "get_hash_global_config port_id",
8917 (void *)&cmd_get_hash_global_config_all,
8918 (void *)&cmd_get_hash_global_config_port_id,
8923 /* Set global config of hash function */
8924 struct cmd_set_hash_global_config_result {
8925 cmdline_fixed_string_t set_hash_global_config;
8927 cmdline_fixed_string_t hash_func;
8928 cmdline_fixed_string_t flow_type;
8929 cmdline_fixed_string_t enable;
8933 cmd_set_hash_global_config_parsed(void *parsed_result,
8934 __rte_unused struct cmdline *cl,
8935 __rte_unused void *data)
8937 struct cmd_set_hash_global_config_result *res = parsed_result;
8938 struct rte_eth_hash_filter_info info;
8939 uint32_t ftype, idx, offset;
8942 if (rte_eth_dev_filter_supported(res->port_id,
8943 RTE_ETH_FILTER_HASH) < 0) {
8944 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8948 memset(&info, 0, sizeof(info));
8949 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8950 if (!strcmp(res->hash_func, "toeplitz"))
8951 info.info.global_conf.hash_func =
8952 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8953 else if (!strcmp(res->hash_func, "simple_xor"))
8954 info.info.global_conf.hash_func =
8955 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8956 else if (!strcmp(res->hash_func, "default"))
8957 info.info.global_conf.hash_func =
8958 RTE_ETH_HASH_FUNCTION_DEFAULT;
8960 ftype = str2flowtype(res->flow_type);
8961 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8962 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8963 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8964 if (!strcmp(res->enable, "enable"))
8965 info.info.global_conf.sym_hash_enable_mask[idx] |=
8967 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8968 RTE_ETH_FILTER_SET, &info);
8970 printf("Cannot set global hash configurations by port %d\n",
8973 printf("Global hash configurations have been set "
8974 "succcessfully by port %d\n", res->port_id);
8977 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8978 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8979 set_hash_global_config, "set_hash_global_config");
8980 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8981 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8983 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8984 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8985 hash_func, "toeplitz#simple_xor#default");
8986 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8987 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8989 "ip4#ip4-frag#tcp4#udp4#sctp4#ip6#ip6-frag#tcp6#udp6#sctp6");
8990 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8991 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8992 enable, "enable#disable");
8994 cmdline_parse_inst_t cmd_set_hash_global_config = {
8995 .f = cmd_set_hash_global_config_parsed,
8997 .help_str = "set_hash_global_config port_id "
8998 "toeplitz|simple_xor|default "
8999 "ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6 "
9002 (void *)&cmd_set_hash_global_config_all,
9003 (void *)&cmd_set_hash_global_config_port_id,
9004 (void *)&cmd_set_hash_global_config_hash_func,
9005 (void *)&cmd_set_hash_global_config_flow_type,
9006 (void *)&cmd_set_hash_global_config_enable,
9011 /* ******************************************************************************** */
9013 /* list of instructions */
9014 cmdline_parse_ctx_t main_ctx[] = {
9015 (cmdline_parse_inst_t *)&cmd_help_brief,
9016 (cmdline_parse_inst_t *)&cmd_help_long,
9017 (cmdline_parse_inst_t *)&cmd_quit,
9018 (cmdline_parse_inst_t *)&cmd_showport,
9019 (cmdline_parse_inst_t *)&cmd_showportall,
9020 (cmdline_parse_inst_t *)&cmd_showcfg,
9021 (cmdline_parse_inst_t *)&cmd_start,
9022 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9023 (cmdline_parse_inst_t *)&cmd_set_link_up,
9024 (cmdline_parse_inst_t *)&cmd_set_link_down,
9025 (cmdline_parse_inst_t *)&cmd_reset,
9026 (cmdline_parse_inst_t *)&cmd_set_numbers,
9027 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9028 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9029 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9030 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9031 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9032 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9033 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9034 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9035 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9036 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9037 (cmdline_parse_inst_t *)&cmd_set_link_check,
9038 #ifdef RTE_NIC_BYPASS
9039 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9040 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9041 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9042 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9044 #ifdef RTE_LIBRTE_PMD_BOND
9045 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9046 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9047 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9048 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9049 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9050 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9051 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9052 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9053 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9055 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9056 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9057 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9058 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9059 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9060 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9061 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9062 (cmdline_parse_inst_t *)&cmd_csum_set,
9063 (cmdline_parse_inst_t *)&cmd_csum_show,
9064 (cmdline_parse_inst_t *)&cmd_tso_set,
9065 (cmdline_parse_inst_t *)&cmd_tso_show,
9066 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9067 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9068 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9069 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9070 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9071 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9072 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9073 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9074 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9075 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9076 (cmdline_parse_inst_t *)&cmd_config_dcb,
9077 (cmdline_parse_inst_t *)&cmd_read_reg,
9078 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9079 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9080 (cmdline_parse_inst_t *)&cmd_write_reg,
9081 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9082 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9083 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9084 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
9085 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
9086 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
9087 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
9088 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
9089 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
9090 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
9091 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
9092 (cmdline_parse_inst_t *)&cmd_stop,
9093 (cmdline_parse_inst_t *)&cmd_mac_addr,
9094 (cmdline_parse_inst_t *)&cmd_set_qmap,
9095 (cmdline_parse_inst_t *)&cmd_operate_port,
9096 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9097 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9098 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9099 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9100 (cmdline_parse_inst_t *)&cmd_config_mtu,
9101 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9102 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9103 (cmdline_parse_inst_t *)&cmd_config_rss,
9104 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9105 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9106 (cmdline_parse_inst_t *)&cmd_showport_reta,
9107 (cmdline_parse_inst_t *)&cmd_config_burst,
9108 (cmdline_parse_inst_t *)&cmd_config_thresh,
9109 (cmdline_parse_inst_t *)&cmd_config_threshold,
9110 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9111 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9112 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9113 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9114 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9115 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9116 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9117 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9118 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9119 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9120 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9121 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9122 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9123 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9124 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9125 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9126 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9127 (cmdline_parse_inst_t *)&cmd_dump,
9128 (cmdline_parse_inst_t *)&cmd_dump_one,
9129 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9130 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
9131 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
9132 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
9133 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
9134 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
9135 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
9136 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
9137 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
9138 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
9139 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
9140 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
9141 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
9142 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9143 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9144 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9145 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9146 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9147 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9148 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9149 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9150 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9151 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9155 /* prompt function, called from main on MASTER lcore */
9161 /* initialize non-constant commands */
9162 cmd_set_fwd_mode_init();
9164 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9168 cmdline_interact(cl);
9169 cmdline_stdin_exit(cl);
9173 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9175 if (id < nb_ports) {
9176 /* check if need_reconfig has been set to 1 */
9177 if (ports[id].need_reconfig == 0)
9178 ports[id].need_reconfig = dev;
9179 /* check if need_reconfig_queues has been set to 1 */
9180 if (ports[id].need_reconfig_queues == 0)
9181 ports[id].need_reconfig_queues = queue;
9185 for (pid = 0; pid < nb_ports; pid++) {
9186 /* check if need_reconfig has been set to 1 */
9187 if (ports[pid].need_reconfig == 0)
9188 ports[pid].need_reconfig = dev;
9189 /* check if need_reconfig_queues has been set to 1 */
9190 if (ports[pid].need_reconfig_queues == 0)
9191 ports[pid].need_reconfig_queues = queue;
9196 #ifdef RTE_NIC_BYPASS
9198 bypass_is_supported(portid_t port_id)
9200 struct rte_port *port;
9201 struct rte_pci_id *pci_id;
9203 if (port_id >= nb_ports) {
9204 printf("\tPort id must be less than %d.\n", nb_ports);
9208 /* Get the device id. */
9209 port = &ports[port_id];
9210 pci_id = &port->dev_info.pci_dev->id;
9212 /* Check if NIC supports bypass. */
9213 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9217 printf("\tBypass not supported for port_id = %d.\n", port_id);