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 "tx_cksum 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 "tx_checksum 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_thresh.pthresh = res->value;
2101 else if(!strcmp(res->name, "txht"))
2102 tx_thresh.hthresh = res->value;
2103 else if(!strcmp(res->name, "txwt"))
2104 tx_thresh.wthresh = res->value;
2105 else if(!strcmp(res->name, "rxpt"))
2106 rx_thresh.pthresh = res->value;
2107 else if(!strcmp(res->name, "rxht"))
2108 rx_thresh.hthresh = res->value;
2109 else if(!strcmp(res->name, "rxwt"))
2110 rx_thresh.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 res = parsed_result;
2320 if (!strcmp(res->list_name, "corelist")) {
2321 nb_item = parse_item_list(res->list_of_items, "core",
2323 parsed_items.lcorelist, 1);
2325 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2328 if (!strcmp(res->list_name, "portlist")) {
2329 nb_item = parse_item_list(res->list_of_items, "port",
2331 parsed_items.portlist, 1);
2333 set_fwd_ports_list(parsed_items.portlist, nb_item);
2337 cmdline_parse_token_string_t cmd_set_list_keyword =
2338 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2340 cmdline_parse_token_string_t cmd_set_list_name =
2341 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2342 "corelist#portlist");
2343 cmdline_parse_token_string_t cmd_set_list_of_items =
2344 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2347 cmdline_parse_inst_t cmd_set_fwd_list = {
2348 .f = cmd_set_list_parsed,
2350 .help_str = "set corelist|portlist x[,y]*",
2352 (void *)&cmd_set_list_keyword,
2353 (void *)&cmd_set_list_name,
2354 (void *)&cmd_set_list_of_items,
2359 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2361 struct cmd_setmask_result {
2362 cmdline_fixed_string_t set;
2363 cmdline_fixed_string_t mask;
2367 static void cmd_set_mask_parsed(void *parsed_result,
2368 __attribute__((unused)) struct cmdline *cl,
2369 __attribute__((unused)) void *data)
2371 struct cmd_setmask_result *res = parsed_result;
2373 if (!strcmp(res->mask, "coremask"))
2374 set_fwd_lcores_mask(res->hexavalue);
2375 else if (!strcmp(res->mask, "portmask"))
2376 set_fwd_ports_mask(res->hexavalue);
2379 cmdline_parse_token_string_t cmd_setmask_set =
2380 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2381 cmdline_parse_token_string_t cmd_setmask_mask =
2382 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2383 "coremask#portmask");
2384 cmdline_parse_token_num_t cmd_setmask_value =
2385 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2387 cmdline_parse_inst_t cmd_set_fwd_mask = {
2388 .f = cmd_set_mask_parsed,
2390 .help_str = "set coremask|portmask hexadecimal value",
2392 (void *)&cmd_setmask_set,
2393 (void *)&cmd_setmask_mask,
2394 (void *)&cmd_setmask_value,
2400 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2402 struct cmd_set_result {
2403 cmdline_fixed_string_t set;
2404 cmdline_fixed_string_t what;
2408 static void cmd_set_parsed(void *parsed_result,
2409 __attribute__((unused)) struct cmdline *cl,
2410 __attribute__((unused)) void *data)
2412 struct cmd_set_result *res = parsed_result;
2413 if (!strcmp(res->what, "nbport"))
2414 set_fwd_ports_number(res->value);
2415 else if (!strcmp(res->what, "nbcore"))
2416 set_fwd_lcores_number(res->value);
2417 else if (!strcmp(res->what, "burst"))
2418 set_nb_pkt_per_burst(res->value);
2419 else if (!strcmp(res->what, "verbose"))
2420 set_verbose_level(res->value);
2423 cmdline_parse_token_string_t cmd_set_set =
2424 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2425 cmdline_parse_token_string_t cmd_set_what =
2426 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2427 "nbport#nbcore#burst#verbose");
2428 cmdline_parse_token_num_t cmd_set_value =
2429 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2431 cmdline_parse_inst_t cmd_set_numbers = {
2432 .f = cmd_set_parsed,
2434 .help_str = "set nbport|nbcore|burst|verbose value",
2436 (void *)&cmd_set_set,
2437 (void *)&cmd_set_what,
2438 (void *)&cmd_set_value,
2443 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2445 struct cmd_set_txpkts_result {
2446 cmdline_fixed_string_t cmd_keyword;
2447 cmdline_fixed_string_t txpkts;
2448 cmdline_fixed_string_t seg_lengths;
2452 cmd_set_txpkts_parsed(void *parsed_result,
2453 __attribute__((unused)) struct cmdline *cl,
2454 __attribute__((unused)) void *data)
2456 struct cmd_set_txpkts_result *res;
2457 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2458 unsigned int nb_segs;
2460 res = parsed_result;
2461 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2462 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2464 set_tx_pkt_segments(seg_lengths, nb_segs);
2467 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2468 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2469 cmd_keyword, "set");
2470 cmdline_parse_token_string_t cmd_set_txpkts_name =
2471 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2473 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2474 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2477 cmdline_parse_inst_t cmd_set_txpkts = {
2478 .f = cmd_set_txpkts_parsed,
2480 .help_str = "set txpkts x[,y]*",
2482 (void *)&cmd_set_txpkts_keyword,
2483 (void *)&cmd_set_txpkts_name,
2484 (void *)&cmd_set_txpkts_lengths,
2489 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2490 struct cmd_rx_vlan_filter_all_result {
2491 cmdline_fixed_string_t rx_vlan;
2492 cmdline_fixed_string_t what;
2493 cmdline_fixed_string_t all;
2498 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2499 __attribute__((unused)) struct cmdline *cl,
2500 __attribute__((unused)) void *data)
2502 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2504 if (!strcmp(res->what, "add"))
2505 rx_vlan_all_filter_set(res->port_id, 1);
2507 rx_vlan_all_filter_set(res->port_id, 0);
2510 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2511 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2512 rx_vlan, "rx_vlan");
2513 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2514 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2516 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2517 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2519 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2520 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2523 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2524 .f = cmd_rx_vlan_filter_all_parsed,
2526 .help_str = "add/remove all identifiers to/from the set of VLAN "
2527 "Identifiers filtered by a port",
2529 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2530 (void *)&cmd_rx_vlan_filter_all_what,
2531 (void *)&cmd_rx_vlan_filter_all_all,
2532 (void *)&cmd_rx_vlan_filter_all_portid,
2537 /* *** VLAN OFFLOAD SET ON A PORT *** */
2538 struct cmd_vlan_offload_result {
2539 cmdline_fixed_string_t vlan;
2540 cmdline_fixed_string_t set;
2541 cmdline_fixed_string_t what;
2542 cmdline_fixed_string_t on;
2543 cmdline_fixed_string_t port_id;
2547 cmd_vlan_offload_parsed(void *parsed_result,
2548 __attribute__((unused)) struct cmdline *cl,
2549 __attribute__((unused)) void *data)
2552 struct cmd_vlan_offload_result *res = parsed_result;
2555 portid_t port_id = 0;
2559 len = strnlen(str, STR_TOKEN_SIZE);
2561 /* Get port_id first */
2569 tmp = strtoul(str, NULL, 0);
2570 /* If port_id greater that what portid_t can represent, return */
2571 if(tmp >= RTE_MAX_ETHPORTS)
2573 port_id = (portid_t)tmp;
2575 if (!strcmp(res->on, "on"))
2580 if (!strcmp(res->what, "strip"))
2581 rx_vlan_strip_set(port_id, on);
2582 else if(!strcmp(res->what, "stripq")){
2583 uint16_t queue_id = 0;
2585 /* No queue_id, return */
2587 printf("must specify (port,queue_id)\n");
2590 tmp = strtoul(str + i + 1, NULL, 0);
2591 /* If queue_id greater that what 16-bits can represent, return */
2595 queue_id = (uint16_t)tmp;
2596 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2598 else if (!strcmp(res->what, "filter"))
2599 rx_vlan_filter_set(port_id, on);
2601 vlan_extend_set(port_id, on);
2606 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2607 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2609 cmdline_parse_token_string_t cmd_vlan_offload_set =
2610 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2612 cmdline_parse_token_string_t cmd_vlan_offload_what =
2613 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2614 what, "strip#filter#qinq#stripq");
2615 cmdline_parse_token_string_t cmd_vlan_offload_on =
2616 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2618 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2619 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2622 cmdline_parse_inst_t cmd_vlan_offload = {
2623 .f = cmd_vlan_offload_parsed,
2625 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2626 " qinq(extended) for both rx/tx sides ",
2628 (void *)&cmd_vlan_offload_vlan,
2629 (void *)&cmd_vlan_offload_set,
2630 (void *)&cmd_vlan_offload_what,
2631 (void *)&cmd_vlan_offload_on,
2632 (void *)&cmd_vlan_offload_portid,
2637 /* *** VLAN TPID SET ON A PORT *** */
2638 struct cmd_vlan_tpid_result {
2639 cmdline_fixed_string_t vlan;
2640 cmdline_fixed_string_t set;
2641 cmdline_fixed_string_t what;
2647 cmd_vlan_tpid_parsed(void *parsed_result,
2648 __attribute__((unused)) struct cmdline *cl,
2649 __attribute__((unused)) void *data)
2651 struct cmd_vlan_tpid_result *res = parsed_result;
2652 vlan_tpid_set(res->port_id, res->tp_id);
2656 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2657 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2659 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2660 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2662 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2663 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2665 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2666 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2668 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2669 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2672 cmdline_parse_inst_t cmd_vlan_tpid = {
2673 .f = cmd_vlan_tpid_parsed,
2675 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2677 (void *)&cmd_vlan_tpid_vlan,
2678 (void *)&cmd_vlan_tpid_set,
2679 (void *)&cmd_vlan_tpid_what,
2680 (void *)&cmd_vlan_tpid_tpid,
2681 (void *)&cmd_vlan_tpid_portid,
2686 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2687 struct cmd_rx_vlan_filter_result {
2688 cmdline_fixed_string_t rx_vlan;
2689 cmdline_fixed_string_t what;
2695 cmd_rx_vlan_filter_parsed(void *parsed_result,
2696 __attribute__((unused)) struct cmdline *cl,
2697 __attribute__((unused)) void *data)
2699 struct cmd_rx_vlan_filter_result *res = parsed_result;
2701 if (!strcmp(res->what, "add"))
2702 rx_vft_set(res->port_id, res->vlan_id, 1);
2704 rx_vft_set(res->port_id, res->vlan_id, 0);
2707 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2708 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2709 rx_vlan, "rx_vlan");
2710 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2711 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2713 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2714 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2716 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2717 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2720 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2721 .f = cmd_rx_vlan_filter_parsed,
2723 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2724 "Identifiers filtered by a port",
2726 (void *)&cmd_rx_vlan_filter_rx_vlan,
2727 (void *)&cmd_rx_vlan_filter_what,
2728 (void *)&cmd_rx_vlan_filter_vlanid,
2729 (void *)&cmd_rx_vlan_filter_portid,
2734 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2735 struct cmd_tx_vlan_set_result {
2736 cmdline_fixed_string_t tx_vlan;
2737 cmdline_fixed_string_t set;
2743 cmd_tx_vlan_set_parsed(void *parsed_result,
2744 __attribute__((unused)) struct cmdline *cl,
2745 __attribute__((unused)) void *data)
2747 struct cmd_tx_vlan_set_result *res = parsed_result;
2748 tx_vlan_set(res->port_id, res->vlan_id);
2751 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2752 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2753 tx_vlan, "tx_vlan");
2754 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2755 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2757 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2758 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2760 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2761 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2764 cmdline_parse_inst_t cmd_tx_vlan_set = {
2765 .f = cmd_tx_vlan_set_parsed,
2767 .help_str = "enable hardware insertion of a VLAN header with a given "
2768 "TAG Identifier in packets sent on a port",
2770 (void *)&cmd_tx_vlan_set_tx_vlan,
2771 (void *)&cmd_tx_vlan_set_set,
2772 (void *)&cmd_tx_vlan_set_vlanid,
2773 (void *)&cmd_tx_vlan_set_portid,
2778 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2779 struct cmd_tx_vlan_set_pvid_result {
2780 cmdline_fixed_string_t tx_vlan;
2781 cmdline_fixed_string_t set;
2782 cmdline_fixed_string_t pvid;
2785 cmdline_fixed_string_t mode;
2789 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2790 __attribute__((unused)) struct cmdline *cl,
2791 __attribute__((unused)) void *data)
2793 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2795 if (strcmp(res->mode, "on") == 0)
2796 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2798 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2801 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2802 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2803 tx_vlan, "tx_vlan");
2804 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2805 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2807 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2808 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2810 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2811 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2813 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2814 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2816 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2817 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2820 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2821 .f = cmd_tx_vlan_set_pvid_parsed,
2823 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2825 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2826 (void *)&cmd_tx_vlan_set_pvid_set,
2827 (void *)&cmd_tx_vlan_set_pvid_pvid,
2828 (void *)&cmd_tx_vlan_set_pvid_port_id,
2829 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2830 (void *)&cmd_tx_vlan_set_pvid_mode,
2835 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2836 struct cmd_tx_vlan_reset_result {
2837 cmdline_fixed_string_t tx_vlan;
2838 cmdline_fixed_string_t reset;
2843 cmd_tx_vlan_reset_parsed(void *parsed_result,
2844 __attribute__((unused)) struct cmdline *cl,
2845 __attribute__((unused)) void *data)
2847 struct cmd_tx_vlan_reset_result *res = parsed_result;
2849 tx_vlan_reset(res->port_id);
2852 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2853 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2854 tx_vlan, "tx_vlan");
2855 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2856 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2858 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2859 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2862 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2863 .f = cmd_tx_vlan_reset_parsed,
2865 .help_str = "disable hardware insertion of a VLAN header in packets "
2868 (void *)&cmd_tx_vlan_reset_tx_vlan,
2869 (void *)&cmd_tx_vlan_reset_reset,
2870 (void *)&cmd_tx_vlan_reset_portid,
2876 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2877 struct cmd_tx_cksum_result {
2878 cmdline_fixed_string_t tx_cksum;
2879 cmdline_fixed_string_t mode;
2880 cmdline_fixed_string_t proto;
2881 cmdline_fixed_string_t hwsw;
2886 cmd_tx_cksum_parsed(void *parsed_result,
2887 __attribute__((unused)) struct cmdline *cl,
2888 __attribute__((unused)) void *data)
2890 struct cmd_tx_cksum_result *res = parsed_result;
2892 uint16_t ol_flags, mask = 0;
2893 struct rte_eth_dev_info dev_info;
2895 if (port_id_is_invalid(res->port_id)) {
2896 printf("invalid port %d\n", res->port_id);
2900 if (!strcmp(res->mode, "set")) {
2902 if (!strcmp(res->hwsw, "hw"))
2905 if (!strcmp(res->proto, "ip")) {
2906 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2907 } else if (!strcmp(res->proto, "udp")) {
2908 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2909 } else if (!strcmp(res->proto, "tcp")) {
2910 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2911 } else if (!strcmp(res->proto, "sctp")) {
2912 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2913 } else if (!strcmp(res->proto, "vxlan")) {
2914 mask = TESTPMD_TX_OFFLOAD_VXLAN_CKSUM;
2918 ports[res->port_id].tx_ol_flags |= mask;
2920 ports[res->port_id].tx_ol_flags &= (~mask);
2923 ol_flags = ports[res->port_id].tx_ol_flags;
2924 printf("IP checksum offload is %s\n",
2925 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2926 printf("UDP checksum offload is %s\n",
2927 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2928 printf("TCP checksum offload is %s\n",
2929 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2930 printf("SCTP checksum offload is %s\n",
2931 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2932 printf("VxLAN checksum offload is %s\n",
2933 (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw");
2935 /* display warnings if configuration is not supported by the NIC */
2936 rte_eth_dev_info_get(res->port_id, &dev_info);
2937 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2938 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2939 printf("Warning: hardware IP checksum enabled but not "
2940 "supported by port %d\n", res->port_id);
2942 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2943 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2944 printf("Warning: hardware UDP checksum enabled but not "
2945 "supported by port %d\n", res->port_id);
2947 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2948 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2949 printf("Warning: hardware TCP checksum enabled but not "
2950 "supported by port %d\n", res->port_id);
2952 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2953 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2954 printf("Warning: hardware SCTP checksum enabled but not "
2955 "supported by port %d\n", res->port_id);
2959 cmdline_parse_token_string_t cmd_tx_cksum_tx_cksum =
2960 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2961 tx_cksum, "tx_checksum");
2962 cmdline_parse_token_string_t cmd_tx_cksum_mode =
2963 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2965 cmdline_parse_token_string_t cmd_tx_cksum_proto =
2966 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2967 proto, "ip#tcp#udp#sctp#vxlan");
2968 cmdline_parse_token_string_t cmd_tx_cksum_hwsw =
2969 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2971 cmdline_parse_token_num_t cmd_tx_cksum_portid =
2972 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_result,
2975 cmdline_parse_inst_t cmd_tx_cksum_set = {
2976 .f = cmd_tx_cksum_parsed,
2978 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
2979 "using csum forward engine: tx_cksum set ip|tcp|udp|sctp|vxlan hw|sw <port>",
2981 (void *)&cmd_tx_cksum_tx_cksum,
2982 (void *)&cmd_tx_cksum_mode,
2983 (void *)&cmd_tx_cksum_proto,
2984 (void *)&cmd_tx_cksum_hwsw,
2985 (void *)&cmd_tx_cksum_portid,
2990 cmdline_parse_token_string_t cmd_tx_cksum_mode_show =
2991 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2994 cmdline_parse_inst_t cmd_tx_cksum_show = {
2995 .f = cmd_tx_cksum_parsed,
2997 .help_str = "show checksum offload configuration: tx_cksum show <port>",
2999 (void *)&cmd_tx_cksum_tx_cksum,
3000 (void *)&cmd_tx_cksum_mode_show,
3001 (void *)&cmd_tx_cksum_portid,
3006 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3007 struct cmd_tso_set_result {
3008 cmdline_fixed_string_t tso;
3009 cmdline_fixed_string_t mode;
3015 cmd_tso_set_parsed(void *parsed_result,
3016 __attribute__((unused)) struct cmdline *cl,
3017 __attribute__((unused)) void *data)
3019 struct cmd_tso_set_result *res = parsed_result;
3020 struct rte_eth_dev_info dev_info;
3022 if (port_id_is_invalid(res->port_id))
3025 if (!strcmp(res->mode, "set"))
3026 ports[res->port_id].tso_segsz = res->tso_segsz;
3028 if (ports[res->port_id].tso_segsz == 0)
3029 printf("TSO is disabled\n");
3031 printf("TSO segment size is %d\n",
3032 ports[res->port_id].tso_segsz);
3034 /* display warnings if configuration is not supported by the NIC */
3035 rte_eth_dev_info_get(res->port_id, &dev_info);
3036 if ((ports[res->port_id].tso_segsz != 0) &&
3037 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3038 printf("Warning: TSO enabled but not "
3039 "supported by port %d\n", res->port_id);
3043 cmdline_parse_token_string_t cmd_tso_set_tso =
3044 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3046 cmdline_parse_token_string_t cmd_tso_set_mode =
3047 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3049 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3050 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3052 cmdline_parse_token_num_t cmd_tso_set_portid =
3053 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3056 cmdline_parse_inst_t cmd_tso_set = {
3057 .f = cmd_tso_set_parsed,
3059 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3060 "tso set <tso_segsz> <port>",
3062 (void *)&cmd_tso_set_tso,
3063 (void *)&cmd_tso_set_mode,
3064 (void *)&cmd_tso_set_tso_segsz,
3065 (void *)&cmd_tso_set_portid,
3070 cmdline_parse_token_string_t cmd_tso_show_mode =
3071 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3075 cmdline_parse_inst_t cmd_tso_show = {
3076 .f = cmd_tso_set_parsed,
3078 .help_str = "Show TSO segment size for csum engine: "
3081 (void *)&cmd_tso_set_tso,
3082 (void *)&cmd_tso_show_mode,
3083 (void *)&cmd_tso_set_portid,
3088 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3089 struct cmd_set_flush_rx {
3090 cmdline_fixed_string_t set;
3091 cmdline_fixed_string_t flush_rx;
3092 cmdline_fixed_string_t mode;
3096 cmd_set_flush_rx_parsed(void *parsed_result,
3097 __attribute__((unused)) struct cmdline *cl,
3098 __attribute__((unused)) void *data)
3100 struct cmd_set_flush_rx *res = parsed_result;
3101 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3104 cmdline_parse_token_string_t cmd_setflushrx_set =
3105 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3107 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3108 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3109 flush_rx, "flush_rx");
3110 cmdline_parse_token_string_t cmd_setflushrx_mode =
3111 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3115 cmdline_parse_inst_t cmd_set_flush_rx = {
3116 .f = cmd_set_flush_rx_parsed,
3117 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3120 (void *)&cmd_setflushrx_set,
3121 (void *)&cmd_setflushrx_flush_rx,
3122 (void *)&cmd_setflushrx_mode,
3127 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3128 struct cmd_set_link_check {
3129 cmdline_fixed_string_t set;
3130 cmdline_fixed_string_t link_check;
3131 cmdline_fixed_string_t mode;
3135 cmd_set_link_check_parsed(void *parsed_result,
3136 __attribute__((unused)) struct cmdline *cl,
3137 __attribute__((unused)) void *data)
3139 struct cmd_set_link_check *res = parsed_result;
3140 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3143 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3144 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3146 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3147 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3148 link_check, "link_check");
3149 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3150 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3154 cmdline_parse_inst_t cmd_set_link_check = {
3155 .f = cmd_set_link_check_parsed,
3156 .help_str = "set link_check on|off: enable/disable link status check "
3157 "when starting/stopping a port",
3160 (void *)&cmd_setlinkcheck_set,
3161 (void *)&cmd_setlinkcheck_link_check,
3162 (void *)&cmd_setlinkcheck_mode,
3167 #ifdef RTE_NIC_BYPASS
3168 /* *** SET NIC BYPASS MODE *** */
3169 struct cmd_set_bypass_mode_result {
3170 cmdline_fixed_string_t set;
3171 cmdline_fixed_string_t bypass;
3172 cmdline_fixed_string_t mode;
3173 cmdline_fixed_string_t value;
3178 cmd_set_bypass_mode_parsed(void *parsed_result,
3179 __attribute__((unused)) struct cmdline *cl,
3180 __attribute__((unused)) void *data)
3182 struct cmd_set_bypass_mode_result *res = parsed_result;
3183 portid_t port_id = res->port_id;
3184 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3186 if (!bypass_is_supported(port_id))
3189 if (!strcmp(res->value, "bypass"))
3190 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3191 else if (!strcmp(res->value, "isolate"))
3192 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3194 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3196 /* Set the bypass mode for the relevant port. */
3197 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3198 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3202 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3203 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3205 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3206 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3208 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3209 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3211 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3212 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3213 value, "normal#bypass#isolate");
3214 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3215 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3218 cmdline_parse_inst_t cmd_set_bypass_mode = {
3219 .f = cmd_set_bypass_mode_parsed,
3220 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3221 "Set the NIC bypass mode for port_id",
3224 (void *)&cmd_setbypass_mode_set,
3225 (void *)&cmd_setbypass_mode_bypass,
3226 (void *)&cmd_setbypass_mode_mode,
3227 (void *)&cmd_setbypass_mode_value,
3228 (void *)&cmd_setbypass_mode_port,
3233 /* *** SET NIC BYPASS EVENT *** */
3234 struct cmd_set_bypass_event_result {
3235 cmdline_fixed_string_t set;
3236 cmdline_fixed_string_t bypass;
3237 cmdline_fixed_string_t event;
3238 cmdline_fixed_string_t event_value;
3239 cmdline_fixed_string_t mode;
3240 cmdline_fixed_string_t mode_value;
3245 cmd_set_bypass_event_parsed(void *parsed_result,
3246 __attribute__((unused)) struct cmdline *cl,
3247 __attribute__((unused)) void *data)
3250 struct cmd_set_bypass_event_result *res = parsed_result;
3251 portid_t port_id = res->port_id;
3252 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3253 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3255 if (!bypass_is_supported(port_id))
3258 if (!strcmp(res->event_value, "timeout"))
3259 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3260 else if (!strcmp(res->event_value, "os_on"))
3261 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3262 else if (!strcmp(res->event_value, "os_off"))
3263 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3264 else if (!strcmp(res->event_value, "power_on"))
3265 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3266 else if (!strcmp(res->event_value, "power_off"))
3267 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3269 bypass_event = RTE_BYPASS_EVENT_NONE;
3271 if (!strcmp(res->mode_value, "bypass"))
3272 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3273 else if (!strcmp(res->mode_value, "isolate"))
3274 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3276 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3278 /* Set the watchdog timeout. */
3279 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3282 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3283 (rc = rte_eth_dev_wd_timeout_store(port_id,
3284 bypass_timeout)) != 0) {
3285 printf("Failed to set timeout value %u "
3286 "for port %d, errto code: %d.\n",
3287 bypass_timeout, port_id, rc);
3291 /* Set the bypass event to transition to bypass mode. */
3292 if (0 != rte_eth_dev_bypass_event_store(port_id,
3293 bypass_event, bypass_mode)) {
3294 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3299 cmdline_parse_token_string_t cmd_setbypass_event_set =
3300 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3302 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3303 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3305 cmdline_parse_token_string_t cmd_setbypass_event_event =
3306 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3308 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3309 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3310 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3311 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3312 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3314 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3315 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3316 mode_value, "normal#bypass#isolate");
3317 cmdline_parse_token_num_t cmd_setbypass_event_port =
3318 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3321 cmdline_parse_inst_t cmd_set_bypass_event = {
3322 .f = cmd_set_bypass_event_parsed,
3323 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3324 "mode (normal|bypass|isolate) (port_id): "
3325 "Set the NIC bypass event mode for port_id",
3328 (void *)&cmd_setbypass_event_set,
3329 (void *)&cmd_setbypass_event_bypass,
3330 (void *)&cmd_setbypass_event_event,
3331 (void *)&cmd_setbypass_event_event_value,
3332 (void *)&cmd_setbypass_event_mode,
3333 (void *)&cmd_setbypass_event_mode_value,
3334 (void *)&cmd_setbypass_event_port,
3340 /* *** SET NIC BYPASS TIMEOUT *** */
3341 struct cmd_set_bypass_timeout_result {
3342 cmdline_fixed_string_t set;
3343 cmdline_fixed_string_t bypass;
3344 cmdline_fixed_string_t timeout;
3345 cmdline_fixed_string_t value;
3349 cmd_set_bypass_timeout_parsed(void *parsed_result,
3350 __attribute__((unused)) struct cmdline *cl,
3351 __attribute__((unused)) void *data)
3353 struct cmd_set_bypass_timeout_result *res = parsed_result;
3355 if (!strcmp(res->value, "1.5"))
3356 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3357 else if (!strcmp(res->value, "2"))
3358 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3359 else if (!strcmp(res->value, "3"))
3360 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3361 else if (!strcmp(res->value, "4"))
3362 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3363 else if (!strcmp(res->value, "8"))
3364 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3365 else if (!strcmp(res->value, "16"))
3366 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3367 else if (!strcmp(res->value, "32"))
3368 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3370 bypass_timeout = RTE_BYPASS_TMT_OFF;
3373 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3374 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3376 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3377 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3379 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3380 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3381 timeout, "timeout");
3382 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3383 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3384 value, "0#1.5#2#3#4#8#16#32");
3386 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3387 .f = cmd_set_bypass_timeout_parsed,
3388 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3389 "Set the NIC bypass watchdog timeout",
3392 (void *)&cmd_setbypass_timeout_set,
3393 (void *)&cmd_setbypass_timeout_bypass,
3394 (void *)&cmd_setbypass_timeout_timeout,
3395 (void *)&cmd_setbypass_timeout_value,
3400 /* *** SHOW NIC BYPASS MODE *** */
3401 struct cmd_show_bypass_config_result {
3402 cmdline_fixed_string_t show;
3403 cmdline_fixed_string_t bypass;
3404 cmdline_fixed_string_t config;
3409 cmd_show_bypass_config_parsed(void *parsed_result,
3410 __attribute__((unused)) struct cmdline *cl,
3411 __attribute__((unused)) void *data)
3413 struct cmd_show_bypass_config_result *res = parsed_result;
3414 uint32_t event_mode;
3415 uint32_t bypass_mode;
3416 portid_t port_id = res->port_id;
3417 uint32_t timeout = bypass_timeout;
3420 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3421 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3422 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3423 {"UNKNOWN", "normal", "bypass", "isolate"};
3424 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3431 int num_events = (sizeof events) / (sizeof events[0]);
3433 if (!bypass_is_supported(port_id))
3436 /* Display the bypass mode.*/
3437 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3438 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3442 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3443 bypass_mode = RTE_BYPASS_MODE_NONE;
3445 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3448 /* Display the bypass timeout.*/
3449 if (!RTE_BYPASS_TMT_VALID(timeout))
3450 timeout = RTE_BYPASS_TMT_OFF;
3452 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3454 /* Display the bypass events and associated modes. */
3455 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3457 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3458 printf("\tFailed to get bypass mode for event = %s\n",
3461 if (!RTE_BYPASS_MODE_VALID(event_mode))
3462 event_mode = RTE_BYPASS_MODE_NONE;
3464 printf("\tbypass event: %-16s = %s\n", events[i],
3470 cmdline_parse_token_string_t cmd_showbypass_config_show =
3471 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3473 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3474 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3476 cmdline_parse_token_string_t cmd_showbypass_config_config =
3477 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3479 cmdline_parse_token_num_t cmd_showbypass_config_port =
3480 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3483 cmdline_parse_inst_t cmd_show_bypass_config = {
3484 .f = cmd_show_bypass_config_parsed,
3485 .help_str = "show bypass config (port_id): "
3486 "Show the NIC bypass config for port_id",
3489 (void *)&cmd_showbypass_config_show,
3490 (void *)&cmd_showbypass_config_bypass,
3491 (void *)&cmd_showbypass_config_config,
3492 (void *)&cmd_showbypass_config_port,
3498 #ifdef RTE_LIBRTE_PMD_BOND
3499 /* *** SET BONDING MODE *** */
3500 struct cmd_set_bonding_mode_result {
3501 cmdline_fixed_string_t set;
3502 cmdline_fixed_string_t bonding;
3503 cmdline_fixed_string_t mode;
3508 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3509 __attribute__((unused)) struct cmdline *cl,
3510 __attribute__((unused)) void *data)
3512 struct cmd_set_bonding_mode_result *res = parsed_result;
3513 portid_t port_id = res->port_id;
3515 /* Set the bonding mode for the relevant port. */
3516 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3517 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3520 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3521 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3523 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3524 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3525 bonding, "bonding");
3526 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3527 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3529 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3530 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3532 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3533 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3536 cmdline_parse_inst_t cmd_set_bonding_mode = {
3537 .f = cmd_set_bonding_mode_parsed,
3538 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3541 (void *) &cmd_setbonding_mode_set,
3542 (void *) &cmd_setbonding_mode_bonding,
3543 (void *) &cmd_setbonding_mode_mode,
3544 (void *) &cmd_setbonding_mode_value,
3545 (void *) &cmd_setbonding_mode_port,
3550 /* *** SET BALANCE XMIT POLICY *** */
3551 struct cmd_set_bonding_balance_xmit_policy_result {
3552 cmdline_fixed_string_t set;
3553 cmdline_fixed_string_t bonding;
3554 cmdline_fixed_string_t balance_xmit_policy;
3556 cmdline_fixed_string_t policy;
3559 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3560 __attribute__((unused)) struct cmdline *cl,
3561 __attribute__((unused)) void *data)
3563 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3564 portid_t port_id = res->port_id;
3567 if (!strcmp(res->policy, "l2")) {
3568 policy = BALANCE_XMIT_POLICY_LAYER2;
3569 } else if (!strcmp(res->policy, "l23")) {
3570 policy = BALANCE_XMIT_POLICY_LAYER23;
3571 } else if (!strcmp(res->policy, "l34")) {
3572 policy = BALANCE_XMIT_POLICY_LAYER34;
3574 printf("\t Invalid xmit policy selection");
3578 /* Set the bonding mode for the relevant port. */
3579 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3580 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3585 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3586 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3588 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3589 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3590 bonding, "bonding");
3591 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3592 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3593 balance_xmit_policy, "balance_xmit_policy");
3594 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3595 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3597 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3598 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3599 policy, "l2#l23#l34");
3601 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3602 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3603 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3606 (void *)&cmd_setbonding_balance_xmit_policy_set,
3607 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3608 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3609 (void *)&cmd_setbonding_balance_xmit_policy_port,
3610 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3615 /* *** SHOW NIC BONDING CONFIGURATION *** */
3616 struct cmd_show_bonding_config_result {
3617 cmdline_fixed_string_t show;
3618 cmdline_fixed_string_t bonding;
3619 cmdline_fixed_string_t config;
3623 static void cmd_show_bonding_config_parsed(void *parsed_result,
3624 __attribute__((unused)) struct cmdline *cl,
3625 __attribute__((unused)) void *data)
3627 struct cmd_show_bonding_config_result *res = parsed_result;
3629 uint8_t slaves[RTE_MAX_ETHPORTS];
3630 int num_slaves, num_active_slaves;
3633 portid_t port_id = res->port_id;
3635 /* Display the bonding mode.*/
3636 bonding_mode = rte_eth_bond_mode_get(port_id);
3637 if (bonding_mode < 0) {
3638 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3641 printf("\tBonding mode: %d\n", bonding_mode);
3643 if (bonding_mode == BONDING_MODE_BALANCE) {
3644 int balance_xmit_policy;
3646 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3647 if (balance_xmit_policy < 0) {
3648 printf("\tFailed to get balance xmit policy for port = %d\n",
3652 printf("\tBalance Xmit Policy: ");
3654 switch (balance_xmit_policy) {
3655 case BALANCE_XMIT_POLICY_LAYER2:
3656 printf("BALANCE_XMIT_POLICY_LAYER2");
3658 case BALANCE_XMIT_POLICY_LAYER23:
3659 printf("BALANCE_XMIT_POLICY_LAYER23");
3661 case BALANCE_XMIT_POLICY_LAYER34:
3662 printf("BALANCE_XMIT_POLICY_LAYER34");
3669 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3671 if (num_slaves < 0) {
3672 printf("\tFailed to get slave list for port = %d\n", port_id);
3675 if (num_slaves > 0) {
3676 printf("\tSlaves (%d): [", num_slaves);
3677 for (i = 0; i < num_slaves - 1; i++)
3678 printf("%d ", slaves[i]);
3680 printf("%d]\n", slaves[num_slaves - 1]);
3682 printf("\tSlaves: []\n");
3686 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3689 if (num_active_slaves < 0) {
3690 printf("\tFailed to get active slave list for port = %d\n", port_id);
3693 if (num_active_slaves > 0) {
3694 printf("\tActive Slaves (%d): [", num_active_slaves);
3695 for (i = 0; i < num_active_slaves - 1; i++)
3696 printf("%d ", slaves[i]);
3698 printf("%d]\n", slaves[num_active_slaves - 1]);
3701 printf("\tActive Slaves: []\n");
3705 primary_id = rte_eth_bond_primary_get(port_id);
3706 if (primary_id < 0) {
3707 printf("\tFailed to get primary slave for port = %d\n", port_id);
3710 printf("\tPrimary: [%d]\n", primary_id);
3714 cmdline_parse_token_string_t cmd_showbonding_config_show =
3715 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3717 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3718 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3719 bonding, "bonding");
3720 cmdline_parse_token_string_t cmd_showbonding_config_config =
3721 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3723 cmdline_parse_token_num_t cmd_showbonding_config_port =
3724 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3727 cmdline_parse_inst_t cmd_show_bonding_config = {
3728 .f = cmd_show_bonding_config_parsed,
3729 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3732 (void *)&cmd_showbonding_config_show,
3733 (void *)&cmd_showbonding_config_bonding,
3734 (void *)&cmd_showbonding_config_config,
3735 (void *)&cmd_showbonding_config_port,
3740 /* *** SET BONDING PRIMARY *** */
3741 struct cmd_set_bonding_primary_result {
3742 cmdline_fixed_string_t set;
3743 cmdline_fixed_string_t bonding;
3744 cmdline_fixed_string_t primary;
3749 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3750 __attribute__((unused)) struct cmdline *cl,
3751 __attribute__((unused)) void *data)
3753 struct cmd_set_bonding_primary_result *res = parsed_result;
3754 portid_t master_port_id = res->port_id;
3755 portid_t slave_port_id = res->slave_id;
3757 /* Set the primary slave for a bonded device. */
3758 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3759 printf("\t Failed to set primary slave for port = %d.\n",
3766 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3767 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3769 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3770 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3771 bonding, "bonding");
3772 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3773 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3774 primary, "primary");
3775 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3776 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3778 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3779 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3782 cmdline_parse_inst_t cmd_set_bonding_primary = {
3783 .f = cmd_set_bonding_primary_parsed,
3784 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3787 (void *)&cmd_setbonding_primary_set,
3788 (void *)&cmd_setbonding_primary_bonding,
3789 (void *)&cmd_setbonding_primary_primary,
3790 (void *)&cmd_setbonding_primary_slave,
3791 (void *)&cmd_setbonding_primary_port,
3796 /* *** ADD SLAVE *** */
3797 struct cmd_add_bonding_slave_result {
3798 cmdline_fixed_string_t add;
3799 cmdline_fixed_string_t bonding;
3800 cmdline_fixed_string_t slave;
3805 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3806 __attribute__((unused)) struct cmdline *cl,
3807 __attribute__((unused)) void *data)
3809 struct cmd_add_bonding_slave_result *res = parsed_result;
3810 portid_t master_port_id = res->port_id;
3811 portid_t slave_port_id = res->slave_id;
3813 /* Set the primary slave for a bonded device. */
3814 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3815 printf("\t Failed to add slave %d to master port = %d.\n",
3816 slave_port_id, master_port_id);
3822 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3823 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3825 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3826 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3827 bonding, "bonding");
3828 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3829 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3831 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3832 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3834 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3835 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3838 cmdline_parse_inst_t cmd_add_bonding_slave = {
3839 .f = cmd_add_bonding_slave_parsed,
3840 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3843 (void *)&cmd_addbonding_slave_add,
3844 (void *)&cmd_addbonding_slave_bonding,
3845 (void *)&cmd_addbonding_slave_slave,
3846 (void *)&cmd_addbonding_slave_slaveid,
3847 (void *)&cmd_addbonding_slave_port,
3852 /* *** REMOVE SLAVE *** */
3853 struct cmd_remove_bonding_slave_result {
3854 cmdline_fixed_string_t remove;
3855 cmdline_fixed_string_t bonding;
3856 cmdline_fixed_string_t slave;
3861 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3862 __attribute__((unused)) struct cmdline *cl,
3863 __attribute__((unused)) void *data)
3865 struct cmd_remove_bonding_slave_result *res = parsed_result;
3866 portid_t master_port_id = res->port_id;
3867 portid_t slave_port_id = res->slave_id;
3869 /* Set the primary slave for a bonded device. */
3870 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3871 printf("\t Failed to remove slave %d from master port = %d.\n",
3872 slave_port_id, master_port_id);
3878 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3879 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3881 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3882 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3883 bonding, "bonding");
3884 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3885 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3887 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3888 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3890 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3891 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3894 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3895 .f = cmd_remove_bonding_slave_parsed,
3896 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3899 (void *)&cmd_removebonding_slave_remove,
3900 (void *)&cmd_removebonding_slave_bonding,
3901 (void *)&cmd_removebonding_slave_slave,
3902 (void *)&cmd_removebonding_slave_slaveid,
3903 (void *)&cmd_removebonding_slave_port,
3908 /* *** CREATE BONDED DEVICE *** */
3909 struct cmd_create_bonded_device_result {
3910 cmdline_fixed_string_t create;
3911 cmdline_fixed_string_t bonded;
3912 cmdline_fixed_string_t device;
3917 static int bond_dev_num = 0;
3919 static void cmd_create_bonded_device_parsed(void *parsed_result,
3920 __attribute__((unused)) struct cmdline *cl,
3921 __attribute__((unused)) void *data)
3923 struct cmd_create_bonded_device_result *res = parsed_result;
3924 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3927 if (test_done == 0) {
3928 printf("Please stop forwarding first\n");
3932 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3935 /* Create a new bonded device. */
3936 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3938 printf("\t Failed to create bonded device.\n");
3941 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3944 /* Update number of ports */
3945 nb_ports = rte_eth_dev_count();
3946 reconfig(port_id, res->socket);
3947 rte_eth_promiscuous_enable(port_id);
3952 cmdline_parse_token_string_t cmd_createbonded_device_create =
3953 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3955 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3956 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3958 cmdline_parse_token_string_t cmd_createbonded_device_device =
3959 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3961 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3962 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3964 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3965 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3968 cmdline_parse_inst_t cmd_create_bonded_device = {
3969 .f = cmd_create_bonded_device_parsed,
3970 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3973 (void *)&cmd_createbonded_device_create,
3974 (void *)&cmd_createbonded_device_bonded,
3975 (void *)&cmd_createbonded_device_device,
3976 (void *)&cmd_createbonded_device_mode,
3977 (void *)&cmd_createbonded_device_socket,
3982 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3983 struct cmd_set_bond_mac_addr_result {
3984 cmdline_fixed_string_t set;
3985 cmdline_fixed_string_t bonding;
3986 cmdline_fixed_string_t mac_addr;
3988 struct ether_addr address;
3991 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3992 __attribute__((unused)) struct cmdline *cl,
3993 __attribute__((unused)) void *data)
3995 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3998 if (res->port_num >= nb_ports) {
3999 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4003 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4005 /* check the return value and print it if is < 0 */
4007 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4010 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4011 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4012 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4013 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4015 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4016 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4018 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4019 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4020 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4021 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4023 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4024 .f = cmd_set_bond_mac_addr_parsed,
4026 .help_str = "set bonding mac_addr (port_id) (address): ",
4028 (void *)&cmd_set_bond_mac_addr_set,
4029 (void *)&cmd_set_bond_mac_addr_bonding,
4030 (void *)&cmd_set_bond_mac_addr_mac,
4031 (void *)&cmd_set_bond_mac_addr_portnum,
4032 (void *)&cmd_set_bond_mac_addr_addr,
4038 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4039 struct cmd_set_bond_mon_period_result {
4040 cmdline_fixed_string_t set;
4041 cmdline_fixed_string_t bonding;
4042 cmdline_fixed_string_t mon_period;
4047 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4048 __attribute__((unused)) struct cmdline *cl,
4049 __attribute__((unused)) void *data)
4051 struct cmd_set_bond_mon_period_result *res = parsed_result;
4054 if (res->port_num >= nb_ports) {
4055 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4059 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4061 /* check the return value and print it if is < 0 */
4063 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4066 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4067 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4069 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4070 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4071 bonding, "bonding");
4072 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4073 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4074 mon_period, "mon_period");
4075 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4076 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4078 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4079 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4082 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4083 .f = cmd_set_bond_mon_period_parsed,
4085 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4087 (void *)&cmd_set_bond_mon_period_set,
4088 (void *)&cmd_set_bond_mon_period_bonding,
4089 (void *)&cmd_set_bond_mon_period_mon_period,
4090 (void *)&cmd_set_bond_mon_period_portnum,
4091 (void *)&cmd_set_bond_mon_period_period_ms,
4096 #endif /* RTE_LIBRTE_PMD_BOND */
4098 /* *** SET FORWARDING MODE *** */
4099 struct cmd_set_fwd_mode_result {
4100 cmdline_fixed_string_t set;
4101 cmdline_fixed_string_t fwd;
4102 cmdline_fixed_string_t mode;
4105 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4106 __attribute__((unused)) struct cmdline *cl,
4107 __attribute__((unused)) void *data)
4109 struct cmd_set_fwd_mode_result *res = parsed_result;
4111 set_pkt_forwarding_mode(res->mode);
4114 cmdline_parse_token_string_t cmd_setfwd_set =
4115 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4116 cmdline_parse_token_string_t cmd_setfwd_fwd =
4117 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4118 cmdline_parse_token_string_t cmd_setfwd_mode =
4119 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4120 "" /* defined at init */);
4122 cmdline_parse_inst_t cmd_set_fwd_mode = {
4123 .f = cmd_set_fwd_mode_parsed,
4125 .help_str = NULL, /* defined at init */
4127 (void *)&cmd_setfwd_set,
4128 (void *)&cmd_setfwd_fwd,
4129 (void *)&cmd_setfwd_mode,
4134 static void cmd_set_fwd_mode_init(void)
4137 static char token[128];
4138 static char help[256];
4139 cmdline_parse_token_string_t *token_struct;
4141 modes = list_pkt_forwarding_modes();
4142 snprintf(help, sizeof help, "set fwd %s - "
4143 "set packet forwarding mode", modes);
4144 cmd_set_fwd_mode.help_str = help;
4146 /* string token separator is # */
4147 for (c = token; *modes != '\0'; modes++)
4152 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4153 token_struct->string_data.str = token;
4156 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4157 struct cmd_set_burst_tx_retry_result {
4158 cmdline_fixed_string_t set;
4159 cmdline_fixed_string_t burst;
4160 cmdline_fixed_string_t tx;
4161 cmdline_fixed_string_t delay;
4163 cmdline_fixed_string_t retry;
4167 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4168 __attribute__((unused)) struct cmdline *cl,
4169 __attribute__((unused)) void *data)
4171 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4173 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4174 && !strcmp(res->tx, "tx")) {
4175 if (!strcmp(res->delay, "delay"))
4176 burst_tx_delay_time = res->time;
4177 if (!strcmp(res->retry, "retry"))
4178 burst_tx_retry_num = res->retry_num;
4183 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4184 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4185 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4186 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4188 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4189 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4190 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4191 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4192 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4193 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4194 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4195 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4196 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4197 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4199 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4200 .f = cmd_set_burst_tx_retry_parsed,
4201 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4203 (void *)&cmd_set_burst_tx_retry_set,
4204 (void *)&cmd_set_burst_tx_retry_burst,
4205 (void *)&cmd_set_burst_tx_retry_tx,
4206 (void *)&cmd_set_burst_tx_retry_delay,
4207 (void *)&cmd_set_burst_tx_retry_time,
4208 (void *)&cmd_set_burst_tx_retry_retry,
4209 (void *)&cmd_set_burst_tx_retry_retry_num,
4214 /* *** SET PROMISC MODE *** */
4215 struct cmd_set_promisc_mode_result {
4216 cmdline_fixed_string_t set;
4217 cmdline_fixed_string_t promisc;
4218 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4219 uint8_t port_num; /* valid if "allports" argument == 0 */
4220 cmdline_fixed_string_t mode;
4223 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4224 __attribute__((unused)) struct cmdline *cl,
4227 struct cmd_set_promisc_mode_result *res = parsed_result;
4231 if (!strcmp(res->mode, "on"))
4238 for (i = 0; i < nb_ports; i++) {
4240 rte_eth_promiscuous_enable(i);
4242 rte_eth_promiscuous_disable(i);
4247 rte_eth_promiscuous_enable(res->port_num);
4249 rte_eth_promiscuous_disable(res->port_num);
4253 cmdline_parse_token_string_t cmd_setpromisc_set =
4254 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4255 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4256 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4258 cmdline_parse_token_string_t cmd_setpromisc_portall =
4259 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4261 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4262 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4264 cmdline_parse_token_string_t cmd_setpromisc_mode =
4265 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4268 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4269 .f = cmd_set_promisc_mode_parsed,
4271 .help_str = "set promisc all on|off: set promisc mode for all ports",
4273 (void *)&cmd_setpromisc_set,
4274 (void *)&cmd_setpromisc_promisc,
4275 (void *)&cmd_setpromisc_portall,
4276 (void *)&cmd_setpromisc_mode,
4281 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4282 .f = cmd_set_promisc_mode_parsed,
4284 .help_str = "set promisc X on|off: set promisc mode on port X",
4286 (void *)&cmd_setpromisc_set,
4287 (void *)&cmd_setpromisc_promisc,
4288 (void *)&cmd_setpromisc_portnum,
4289 (void *)&cmd_setpromisc_mode,
4294 /* *** SET ALLMULTI MODE *** */
4295 struct cmd_set_allmulti_mode_result {
4296 cmdline_fixed_string_t set;
4297 cmdline_fixed_string_t allmulti;
4298 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4299 uint8_t port_num; /* valid if "allports" argument == 0 */
4300 cmdline_fixed_string_t mode;
4303 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4304 __attribute__((unused)) struct cmdline *cl,
4307 struct cmd_set_allmulti_mode_result *res = parsed_result;
4311 if (!strcmp(res->mode, "on"))
4318 for (i = 0; i < nb_ports; i++) {
4320 rte_eth_allmulticast_enable(i);
4322 rte_eth_allmulticast_disable(i);
4327 rte_eth_allmulticast_enable(res->port_num);
4329 rte_eth_allmulticast_disable(res->port_num);
4333 cmdline_parse_token_string_t cmd_setallmulti_set =
4334 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4335 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4336 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4338 cmdline_parse_token_string_t cmd_setallmulti_portall =
4339 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4341 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4342 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4344 cmdline_parse_token_string_t cmd_setallmulti_mode =
4345 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4348 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4349 .f = cmd_set_allmulti_mode_parsed,
4351 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4353 (void *)&cmd_setallmulti_set,
4354 (void *)&cmd_setallmulti_allmulti,
4355 (void *)&cmd_setallmulti_portall,
4356 (void *)&cmd_setallmulti_mode,
4361 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4362 .f = cmd_set_allmulti_mode_parsed,
4364 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4366 (void *)&cmd_setallmulti_set,
4367 (void *)&cmd_setallmulti_allmulti,
4368 (void *)&cmd_setallmulti_portnum,
4369 (void *)&cmd_setallmulti_mode,
4374 /* *** ADD/REMOVE A PKT FILTER *** */
4375 struct cmd_pkt_filter_result {
4376 cmdline_fixed_string_t pkt_filter;
4378 cmdline_fixed_string_t protocol;
4379 cmdline_fixed_string_t src;
4380 cmdline_ipaddr_t ip_src;
4382 cmdline_fixed_string_t dst;
4383 cmdline_ipaddr_t ip_dst;
4385 cmdline_fixed_string_t flexbytes;
4386 uint16_t flexbytes_value;
4387 cmdline_fixed_string_t vlan;
4389 cmdline_fixed_string_t queue;
4391 cmdline_fixed_string_t soft;
4396 cmd_pkt_filter_parsed(void *parsed_result,
4397 __attribute__((unused)) struct cmdline *cl,
4398 __attribute__((unused)) void *data)
4400 struct rte_fdir_filter fdir_filter;
4401 struct cmd_pkt_filter_result *res = parsed_result;
4403 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4405 if (res->ip_src.family == AF_INET)
4406 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4408 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4409 &(res->ip_src.addr.ipv6),
4410 sizeof(struct in6_addr));
4412 if (res->ip_dst.family == AF_INET)
4413 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4415 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4416 &(res->ip_dst.addr.ipv6),
4417 sizeof(struct in6_addr));
4419 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4420 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4422 if (!strcmp(res->protocol, "udp"))
4423 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4424 else if (!strcmp(res->protocol, "tcp"))
4425 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4426 else if (!strcmp(res->protocol, "sctp"))
4427 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4428 else /* default only IP */
4429 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4431 if (res->ip_dst.family == AF_INET6)
4432 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4434 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4436 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4437 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4439 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4440 fdir_add_signature_filter(res->port_id, res->queue_id,
4442 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4443 fdir_update_signature_filter(res->port_id, res->queue_id,
4445 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4446 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4447 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4448 fdir_add_perfect_filter(res->port_id, res->soft_id,
4450 (uint8_t) (res->queue_id < 0),
4452 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4453 fdir_update_perfect_filter(res->port_id, res->soft_id,
4455 (uint8_t) (res->queue_id < 0),
4457 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4458 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4464 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4465 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4467 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4468 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4469 protocol, "ip#tcp#udp#sctp");
4470 cmdline_parse_token_string_t cmd_pkt_filter_src =
4471 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4473 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4474 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4476 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4477 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4479 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4480 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4482 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4483 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4485 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4486 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4488 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4489 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4490 flexbytes, "flexbytes");
4491 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4492 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4493 flexbytes_value, UINT16);
4494 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4495 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4497 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4498 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4500 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4501 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4503 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4504 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4506 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4507 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4509 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4510 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4514 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4515 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4516 pkt_filter, "add_signature_filter");
4517 cmdline_parse_inst_t cmd_add_signature_filter = {
4518 .f = cmd_pkt_filter_parsed,
4520 .help_str = "add a signature filter",
4522 (void *)&cmd_pkt_filter_add_signature_filter,
4523 (void *)&cmd_pkt_filter_port_id,
4524 (void *)&cmd_pkt_filter_protocol,
4525 (void *)&cmd_pkt_filter_src,
4526 (void *)&cmd_pkt_filter_ip_src,
4527 (void *)&cmd_pkt_filter_port_src,
4528 (void *)&cmd_pkt_filter_dst,
4529 (void *)&cmd_pkt_filter_ip_dst,
4530 (void *)&cmd_pkt_filter_port_dst,
4531 (void *)&cmd_pkt_filter_flexbytes,
4532 (void *)&cmd_pkt_filter_flexbytes_value,
4533 (void *)&cmd_pkt_filter_vlan,
4534 (void *)&cmd_pkt_filter_vlan_id,
4535 (void *)&cmd_pkt_filter_queue,
4536 (void *)&cmd_pkt_filter_queue_id,
4542 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4543 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4544 pkt_filter, "upd_signature_filter");
4545 cmdline_parse_inst_t cmd_upd_signature_filter = {
4546 .f = cmd_pkt_filter_parsed,
4548 .help_str = "update a signature filter",
4550 (void *)&cmd_pkt_filter_upd_signature_filter,
4551 (void *)&cmd_pkt_filter_port_id,
4552 (void *)&cmd_pkt_filter_protocol,
4553 (void *)&cmd_pkt_filter_src,
4554 (void *)&cmd_pkt_filter_ip_src,
4555 (void *)&cmd_pkt_filter_port_src,
4556 (void *)&cmd_pkt_filter_dst,
4557 (void *)&cmd_pkt_filter_ip_dst,
4558 (void *)&cmd_pkt_filter_port_dst,
4559 (void *)&cmd_pkt_filter_flexbytes,
4560 (void *)&cmd_pkt_filter_flexbytes_value,
4561 (void *)&cmd_pkt_filter_vlan,
4562 (void *)&cmd_pkt_filter_vlan_id,
4563 (void *)&cmd_pkt_filter_queue,
4564 (void *)&cmd_pkt_filter_queue_id,
4570 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4571 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4572 pkt_filter, "rm_signature_filter");
4573 cmdline_parse_inst_t cmd_rm_signature_filter = {
4574 .f = cmd_pkt_filter_parsed,
4576 .help_str = "remove a signature filter",
4578 (void *)&cmd_pkt_filter_rm_signature_filter,
4579 (void *)&cmd_pkt_filter_port_id,
4580 (void *)&cmd_pkt_filter_protocol,
4581 (void *)&cmd_pkt_filter_src,
4582 (void *)&cmd_pkt_filter_ip_src,
4583 (void *)&cmd_pkt_filter_port_src,
4584 (void *)&cmd_pkt_filter_dst,
4585 (void *)&cmd_pkt_filter_ip_dst,
4586 (void *)&cmd_pkt_filter_port_dst,
4587 (void *)&cmd_pkt_filter_flexbytes,
4588 (void *)&cmd_pkt_filter_flexbytes_value,
4589 (void *)&cmd_pkt_filter_vlan,
4590 (void *)&cmd_pkt_filter_vlan_id,
4596 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4597 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4598 pkt_filter, "add_perfect_filter");
4599 cmdline_parse_inst_t cmd_add_perfect_filter = {
4600 .f = cmd_pkt_filter_parsed,
4602 .help_str = "add a perfect filter",
4604 (void *)&cmd_pkt_filter_add_perfect_filter,
4605 (void *)&cmd_pkt_filter_port_id,
4606 (void *)&cmd_pkt_filter_protocol,
4607 (void *)&cmd_pkt_filter_src,
4608 (void *)&cmd_pkt_filter_ip_src,
4609 (void *)&cmd_pkt_filter_port_src,
4610 (void *)&cmd_pkt_filter_dst,
4611 (void *)&cmd_pkt_filter_ip_dst,
4612 (void *)&cmd_pkt_filter_port_dst,
4613 (void *)&cmd_pkt_filter_flexbytes,
4614 (void *)&cmd_pkt_filter_flexbytes_value,
4615 (void *)&cmd_pkt_filter_vlan,
4616 (void *)&cmd_pkt_filter_vlan_id,
4617 (void *)&cmd_pkt_filter_queue,
4618 (void *)&cmd_pkt_filter_queue_id,
4619 (void *)&cmd_pkt_filter_soft,
4620 (void *)&cmd_pkt_filter_soft_id,
4626 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4627 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4628 pkt_filter, "upd_perfect_filter");
4629 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4630 .f = cmd_pkt_filter_parsed,
4632 .help_str = "update a perfect filter",
4634 (void *)&cmd_pkt_filter_upd_perfect_filter,
4635 (void *)&cmd_pkt_filter_port_id,
4636 (void *)&cmd_pkt_filter_protocol,
4637 (void *)&cmd_pkt_filter_src,
4638 (void *)&cmd_pkt_filter_ip_src,
4639 (void *)&cmd_pkt_filter_port_src,
4640 (void *)&cmd_pkt_filter_dst,
4641 (void *)&cmd_pkt_filter_ip_dst,
4642 (void *)&cmd_pkt_filter_port_dst,
4643 (void *)&cmd_pkt_filter_flexbytes,
4644 (void *)&cmd_pkt_filter_flexbytes_value,
4645 (void *)&cmd_pkt_filter_vlan,
4646 (void *)&cmd_pkt_filter_vlan_id,
4647 (void *)&cmd_pkt_filter_queue,
4648 (void *)&cmd_pkt_filter_queue_id,
4649 (void *)&cmd_pkt_filter_soft,
4650 (void *)&cmd_pkt_filter_soft_id,
4656 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4657 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4658 pkt_filter, "rm_perfect_filter");
4659 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4660 .f = cmd_pkt_filter_parsed,
4662 .help_str = "remove a perfect filter",
4664 (void *)&cmd_pkt_filter_rm_perfect_filter,
4665 (void *)&cmd_pkt_filter_port_id,
4666 (void *)&cmd_pkt_filter_protocol,
4667 (void *)&cmd_pkt_filter_src,
4668 (void *)&cmd_pkt_filter_ip_src,
4669 (void *)&cmd_pkt_filter_port_src,
4670 (void *)&cmd_pkt_filter_dst,
4671 (void *)&cmd_pkt_filter_ip_dst,
4672 (void *)&cmd_pkt_filter_port_dst,
4673 (void *)&cmd_pkt_filter_flexbytes,
4674 (void *)&cmd_pkt_filter_flexbytes_value,
4675 (void *)&cmd_pkt_filter_vlan,
4676 (void *)&cmd_pkt_filter_vlan_id,
4677 (void *)&cmd_pkt_filter_soft,
4678 (void *)&cmd_pkt_filter_soft_id,
4683 /* *** SETUP MASKS FILTER *** */
4684 struct cmd_pkt_filter_masks_result {
4685 cmdline_fixed_string_t filter_mask;
4687 cmdline_fixed_string_t src_mask;
4688 uint32_t ip_src_mask;
4689 uint16_t ipv6_src_mask;
4690 uint16_t port_src_mask;
4691 cmdline_fixed_string_t dst_mask;
4692 uint32_t ip_dst_mask;
4693 uint16_t ipv6_dst_mask;
4694 uint16_t port_dst_mask;
4695 cmdline_fixed_string_t flexbytes;
4696 uint8_t flexbytes_value;
4697 cmdline_fixed_string_t vlan_id;
4698 uint8_t vlan_id_value;
4699 cmdline_fixed_string_t vlan_prio;
4700 uint8_t vlan_prio_value;
4701 cmdline_fixed_string_t only_ip_flow;
4702 uint8_t only_ip_flow_value;
4703 cmdline_fixed_string_t comp_ipv6_dst;
4704 uint8_t comp_ipv6_dst_value;
4708 cmd_pkt_filter_masks_parsed(void *parsed_result,
4709 __attribute__((unused)) struct cmdline *cl,
4710 __attribute__((unused)) void *data)
4712 struct rte_fdir_masks fdir_masks;
4713 struct cmd_pkt_filter_masks_result *res = parsed_result;
4715 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4717 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4718 fdir_masks.vlan_id = res->vlan_id_value;
4719 fdir_masks.vlan_prio = res->vlan_prio_value;
4720 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4721 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4722 fdir_masks.src_port_mask = res->port_src_mask;
4723 fdir_masks.dst_port_mask = res->port_dst_mask;
4724 fdir_masks.flexbytes = res->flexbytes_value;
4726 fdir_set_masks(res->port_id, &fdir_masks);
4729 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4730 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4731 filter_mask, "set_masks_filter");
4732 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4733 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4735 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4736 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4737 only_ip_flow, "only_ip_flow");
4738 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4739 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4740 only_ip_flow_value, UINT8);
4741 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4742 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4743 src_mask, "src_mask");
4744 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4745 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4746 ip_src_mask, UINT32);
4747 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4748 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4749 port_src_mask, UINT16);
4750 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4751 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4752 dst_mask, "dst_mask");
4753 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4754 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4755 ip_dst_mask, UINT32);
4756 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4757 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4758 port_dst_mask, UINT16);
4759 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4760 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4761 flexbytes, "flexbytes");
4762 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4763 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4764 flexbytes_value, UINT8);
4765 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4766 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4767 vlan_id, "vlan_id");
4768 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4769 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4770 vlan_id_value, UINT8);
4771 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4772 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4773 vlan_prio, "vlan_prio");
4774 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4775 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4776 vlan_prio_value, UINT8);
4778 cmdline_parse_inst_t cmd_set_masks_filter = {
4779 .f = cmd_pkt_filter_masks_parsed,
4781 .help_str = "setup masks filter",
4783 (void *)&cmd_pkt_filter_masks_filter_mask,
4784 (void *)&cmd_pkt_filter_masks_port_id,
4785 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4786 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4787 (void *)&cmd_pkt_filter_masks_src_mask,
4788 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4789 (void *)&cmd_pkt_filter_masks_port_src_mask,
4790 (void *)&cmd_pkt_filter_masks_dst_mask,
4791 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4792 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4793 (void *)&cmd_pkt_filter_masks_flexbytes,
4794 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4795 (void *)&cmd_pkt_filter_masks_vlan_id,
4796 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4797 (void *)&cmd_pkt_filter_masks_vlan_prio,
4798 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4804 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4805 __attribute__((unused)) struct cmdline *cl,
4806 __attribute__((unused)) void *data)
4808 struct rte_fdir_masks fdir_masks;
4809 struct cmd_pkt_filter_masks_result *res = parsed_result;
4811 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4813 fdir_masks.set_ipv6_mask = 1;
4814 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4815 fdir_masks.vlan_id = res->vlan_id_value;
4816 fdir_masks.vlan_prio = res->vlan_prio_value;
4817 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4818 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4819 fdir_masks.src_port_mask = res->port_src_mask;
4820 fdir_masks.dst_port_mask = res->port_dst_mask;
4821 fdir_masks.flexbytes = res->flexbytes_value;
4822 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4824 fdir_set_masks(res->port_id, &fdir_masks);
4827 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4828 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4829 filter_mask, "set_ipv6_masks_filter");
4830 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4831 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4832 ipv6_src_mask, UINT16);
4833 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4834 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4835 ipv6_dst_mask, UINT16);
4837 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4838 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4839 comp_ipv6_dst, "compare_dst");
4840 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4841 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4842 comp_ipv6_dst_value, UINT8);
4844 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4845 .f = cmd_pkt_filter_masks_ipv6_parsed,
4847 .help_str = "setup ipv6 masks filter",
4849 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4850 (void *)&cmd_pkt_filter_masks_port_id,
4851 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4852 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4853 (void *)&cmd_pkt_filter_masks_src_mask,
4854 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4855 (void *)&cmd_pkt_filter_masks_port_src_mask,
4856 (void *)&cmd_pkt_filter_masks_dst_mask,
4857 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4858 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4859 (void *)&cmd_pkt_filter_masks_flexbytes,
4860 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4861 (void *)&cmd_pkt_filter_masks_vlan_id,
4862 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4863 (void *)&cmd_pkt_filter_masks_vlan_prio,
4864 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4865 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4866 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4871 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4872 struct cmd_link_flow_ctrl_set_result {
4873 cmdline_fixed_string_t set;
4874 cmdline_fixed_string_t flow_ctrl;
4875 cmdline_fixed_string_t rx;
4876 cmdline_fixed_string_t rx_lfc_mode;
4877 cmdline_fixed_string_t tx;
4878 cmdline_fixed_string_t tx_lfc_mode;
4879 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4880 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4881 cmdline_fixed_string_t autoneg_str;
4882 cmdline_fixed_string_t autoneg;
4883 cmdline_fixed_string_t hw_str;
4884 uint32_t high_water;
4885 cmdline_fixed_string_t lw_str;
4887 cmdline_fixed_string_t pt_str;
4888 uint16_t pause_time;
4889 cmdline_fixed_string_t xon_str;
4894 cmdline_parse_token_string_t cmd_lfc_set_set =
4895 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4897 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4898 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4899 flow_ctrl, "flow_ctrl");
4900 cmdline_parse_token_string_t cmd_lfc_set_rx =
4901 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4903 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4904 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4905 rx_lfc_mode, "on#off");
4906 cmdline_parse_token_string_t cmd_lfc_set_tx =
4907 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4909 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4910 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4911 tx_lfc_mode, "on#off");
4912 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4913 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4914 hw_str, "high_water");
4915 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4916 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4917 high_water, UINT32);
4918 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4919 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4920 lw_str, "low_water");
4921 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4922 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4924 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4925 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4926 pt_str, "pause_time");
4927 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4928 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4929 pause_time, UINT16);
4930 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4931 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4932 xon_str, "send_xon");
4933 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4934 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4936 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4937 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4938 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4939 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4940 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4941 mac_ctrl_frame_fwd_mode, "on#off");
4942 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4943 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4944 autoneg_str, "autoneg");
4945 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4946 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4948 cmdline_parse_token_num_t cmd_lfc_set_portid =
4949 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4952 /* forward declaration */
4954 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4957 cmdline_parse_inst_t cmd_link_flow_control_set = {
4958 .f = cmd_link_flow_ctrl_set_parsed,
4960 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4961 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4962 autoneg on|off port_id",
4964 (void *)&cmd_lfc_set_set,
4965 (void *)&cmd_lfc_set_flow_ctrl,
4966 (void *)&cmd_lfc_set_rx,
4967 (void *)&cmd_lfc_set_rx_mode,
4968 (void *)&cmd_lfc_set_tx,
4969 (void *)&cmd_lfc_set_tx_mode,
4970 (void *)&cmd_lfc_set_high_water,
4971 (void *)&cmd_lfc_set_low_water,
4972 (void *)&cmd_lfc_set_pause_time,
4973 (void *)&cmd_lfc_set_send_xon,
4974 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4975 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4976 (void *)&cmd_lfc_set_autoneg_str,
4977 (void *)&cmd_lfc_set_autoneg,
4978 (void *)&cmd_lfc_set_portid,
4983 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4984 .f = cmd_link_flow_ctrl_set_parsed,
4985 .data = (void *)&cmd_link_flow_control_set_rx,
4986 .help_str = "Change rx flow control parameter: set flow_ctrl "
4987 "rx on|off port_id",
4989 (void *)&cmd_lfc_set_set,
4990 (void *)&cmd_lfc_set_flow_ctrl,
4991 (void *)&cmd_lfc_set_rx,
4992 (void *)&cmd_lfc_set_rx_mode,
4993 (void *)&cmd_lfc_set_portid,
4998 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4999 .f = cmd_link_flow_ctrl_set_parsed,
5000 .data = (void *)&cmd_link_flow_control_set_tx,
5001 .help_str = "Change tx flow control parameter: set flow_ctrl "
5002 "tx on|off port_id",
5004 (void *)&cmd_lfc_set_set,
5005 (void *)&cmd_lfc_set_flow_ctrl,
5006 (void *)&cmd_lfc_set_tx,
5007 (void *)&cmd_lfc_set_tx_mode,
5008 (void *)&cmd_lfc_set_portid,
5013 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5014 .f = cmd_link_flow_ctrl_set_parsed,
5015 .data = (void *)&cmd_link_flow_control_set_hw,
5016 .help_str = "Change high water flow control parameter: set flow_ctrl "
5017 "high_water value port_id",
5019 (void *)&cmd_lfc_set_set,
5020 (void *)&cmd_lfc_set_flow_ctrl,
5021 (void *)&cmd_lfc_set_high_water_str,
5022 (void *)&cmd_lfc_set_high_water,
5023 (void *)&cmd_lfc_set_portid,
5028 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5029 .f = cmd_link_flow_ctrl_set_parsed,
5030 .data = (void *)&cmd_link_flow_control_set_lw,
5031 .help_str = "Change low water flow control parameter: set flow_ctrl "
5032 "low_water value port_id",
5034 (void *)&cmd_lfc_set_set,
5035 (void *)&cmd_lfc_set_flow_ctrl,
5036 (void *)&cmd_lfc_set_low_water_str,
5037 (void *)&cmd_lfc_set_low_water,
5038 (void *)&cmd_lfc_set_portid,
5043 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5044 .f = cmd_link_flow_ctrl_set_parsed,
5045 .data = (void *)&cmd_link_flow_control_set_pt,
5046 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5047 "pause_time value port_id",
5049 (void *)&cmd_lfc_set_set,
5050 (void *)&cmd_lfc_set_flow_ctrl,
5051 (void *)&cmd_lfc_set_pause_time_str,
5052 (void *)&cmd_lfc_set_pause_time,
5053 (void *)&cmd_lfc_set_portid,
5058 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5059 .f = cmd_link_flow_ctrl_set_parsed,
5060 .data = (void *)&cmd_link_flow_control_set_xon,
5061 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5062 "send_xon value port_id",
5064 (void *)&cmd_lfc_set_set,
5065 (void *)&cmd_lfc_set_flow_ctrl,
5066 (void *)&cmd_lfc_set_send_xon_str,
5067 (void *)&cmd_lfc_set_send_xon,
5068 (void *)&cmd_lfc_set_portid,
5073 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5074 .f = cmd_link_flow_ctrl_set_parsed,
5075 .data = (void *)&cmd_link_flow_control_set_macfwd,
5076 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5077 "mac_ctrl_frame_fwd on|off port_id",
5079 (void *)&cmd_lfc_set_set,
5080 (void *)&cmd_lfc_set_flow_ctrl,
5081 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5082 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5083 (void *)&cmd_lfc_set_portid,
5088 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5089 .f = cmd_link_flow_ctrl_set_parsed,
5090 .data = (void *)&cmd_link_flow_control_set_autoneg,
5091 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5092 "autoneg on|off port_id",
5094 (void *)&cmd_lfc_set_set,
5095 (void *)&cmd_lfc_set_flow_ctrl,
5096 (void *)&cmd_lfc_set_autoneg_str,
5097 (void *)&cmd_lfc_set_autoneg,
5098 (void *)&cmd_lfc_set_portid,
5104 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5105 __attribute__((unused)) struct cmdline *cl,
5108 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5109 cmdline_parse_inst_t *cmd = data;
5110 struct rte_eth_fc_conf fc_conf;
5111 int rx_fc_en, tx_fc_en;
5115 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5116 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5117 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5118 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5120 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5121 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5124 /* Partial command line, retrieve current configuration */
5126 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5128 printf("cannot get current flow ctrl parameters, return"
5129 "code = %d\n", ret);
5133 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5134 (fc_conf.mode == RTE_FC_FULL))
5136 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5137 (fc_conf.mode == RTE_FC_FULL))
5141 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5142 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5144 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5145 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5147 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5149 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5150 fc_conf.high_water = res->high_water;
5152 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5153 fc_conf.low_water = res->low_water;
5155 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5156 fc_conf.pause_time = res->pause_time;
5158 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5159 fc_conf.send_xon = res->send_xon;
5161 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5162 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5163 fc_conf.mac_ctrl_frame_fwd = 1;
5165 fc_conf.mac_ctrl_frame_fwd = 0;
5168 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5169 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5171 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5173 printf("bad flow contrl parameter, return code = %d \n", ret);
5176 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5177 struct cmd_priority_flow_ctrl_set_result {
5178 cmdline_fixed_string_t set;
5179 cmdline_fixed_string_t pfc_ctrl;
5180 cmdline_fixed_string_t rx;
5181 cmdline_fixed_string_t rx_pfc_mode;
5182 cmdline_fixed_string_t tx;
5183 cmdline_fixed_string_t tx_pfc_mode;
5184 uint32_t high_water;
5186 uint16_t pause_time;
5192 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5193 __attribute__((unused)) struct cmdline *cl,
5194 __attribute__((unused)) void *data)
5196 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5197 struct rte_eth_pfc_conf pfc_conf;
5198 int rx_fc_enable, tx_fc_enable;
5202 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5203 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5204 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5205 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5207 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5208 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5211 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5212 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5213 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5214 pfc_conf.fc.high_water = res->high_water;
5215 pfc_conf.fc.low_water = res->low_water;
5216 pfc_conf.fc.pause_time = res->pause_time;
5217 pfc_conf.priority = res->priority;
5219 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5221 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5224 cmdline_parse_token_string_t cmd_pfc_set_set =
5225 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5227 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5228 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5229 pfc_ctrl, "pfc_ctrl");
5230 cmdline_parse_token_string_t cmd_pfc_set_rx =
5231 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5233 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5234 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5235 rx_pfc_mode, "on#off");
5236 cmdline_parse_token_string_t cmd_pfc_set_tx =
5237 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5239 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5240 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5241 tx_pfc_mode, "on#off");
5242 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5243 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5244 high_water, UINT32);
5245 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5246 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5248 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5249 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5250 pause_time, UINT16);
5251 cmdline_parse_token_num_t cmd_pfc_set_priority =
5252 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5254 cmdline_parse_token_num_t cmd_pfc_set_portid =
5255 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5258 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5259 .f = cmd_priority_flow_ctrl_set_parsed,
5261 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5262 tx on|off high_water low_water pause_time priority port_id",
5264 (void *)&cmd_pfc_set_set,
5265 (void *)&cmd_pfc_set_flow_ctrl,
5266 (void *)&cmd_pfc_set_rx,
5267 (void *)&cmd_pfc_set_rx_mode,
5268 (void *)&cmd_pfc_set_tx,
5269 (void *)&cmd_pfc_set_tx_mode,
5270 (void *)&cmd_pfc_set_high_water,
5271 (void *)&cmd_pfc_set_low_water,
5272 (void *)&cmd_pfc_set_pause_time,
5273 (void *)&cmd_pfc_set_priority,
5274 (void *)&cmd_pfc_set_portid,
5279 /* *** RESET CONFIGURATION *** */
5280 struct cmd_reset_result {
5281 cmdline_fixed_string_t reset;
5282 cmdline_fixed_string_t def;
5285 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5287 __attribute__((unused)) void *data)
5289 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5290 set_def_fwd_config();
5293 cmdline_parse_token_string_t cmd_reset_set =
5294 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5295 cmdline_parse_token_string_t cmd_reset_def =
5296 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5299 cmdline_parse_inst_t cmd_reset = {
5300 .f = cmd_reset_parsed,
5302 .help_str = "set default: reset default forwarding configuration",
5304 (void *)&cmd_reset_set,
5305 (void *)&cmd_reset_def,
5310 /* *** START FORWARDING *** */
5311 struct cmd_start_result {
5312 cmdline_fixed_string_t start;
5315 cmdline_parse_token_string_t cmd_start_start =
5316 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5318 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5319 __attribute__((unused)) struct cmdline *cl,
5320 __attribute__((unused)) void *data)
5322 start_packet_forwarding(0);
5325 cmdline_parse_inst_t cmd_start = {
5326 .f = cmd_start_parsed,
5328 .help_str = "start packet forwarding",
5330 (void *)&cmd_start_start,
5335 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5336 struct cmd_start_tx_first_result {
5337 cmdline_fixed_string_t start;
5338 cmdline_fixed_string_t tx_first;
5342 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5343 __attribute__((unused)) struct cmdline *cl,
5344 __attribute__((unused)) void *data)
5346 start_packet_forwarding(1);
5349 cmdline_parse_token_string_t cmd_start_tx_first_start =
5350 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5352 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5353 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5354 tx_first, "tx_first");
5356 cmdline_parse_inst_t cmd_start_tx_first = {
5357 .f = cmd_start_tx_first_parsed,
5359 .help_str = "start packet forwarding, after sending 1 burst of packets",
5361 (void *)&cmd_start_tx_first_start,
5362 (void *)&cmd_start_tx_first_tx_first,
5367 /* *** SET LINK UP *** */
5368 struct cmd_set_link_up_result {
5369 cmdline_fixed_string_t set;
5370 cmdline_fixed_string_t link_up;
5371 cmdline_fixed_string_t port;
5375 cmdline_parse_token_string_t cmd_set_link_up_set =
5376 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5377 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5378 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5380 cmdline_parse_token_string_t cmd_set_link_up_port =
5381 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5382 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5383 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5385 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5386 __attribute__((unused)) struct cmdline *cl,
5387 __attribute__((unused)) void *data)
5389 struct cmd_set_link_up_result *res = parsed_result;
5390 dev_set_link_up(res->port_id);
5393 cmdline_parse_inst_t cmd_set_link_up = {
5394 .f = cmd_set_link_up_parsed,
5396 .help_str = "set link-up port (port id)",
5398 (void *)&cmd_set_link_up_set,
5399 (void *)&cmd_set_link_up_link_up,
5400 (void *)&cmd_set_link_up_port,
5401 (void *)&cmd_set_link_up_port_id,
5406 /* *** SET LINK DOWN *** */
5407 struct cmd_set_link_down_result {
5408 cmdline_fixed_string_t set;
5409 cmdline_fixed_string_t link_down;
5410 cmdline_fixed_string_t port;
5414 cmdline_parse_token_string_t cmd_set_link_down_set =
5415 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5416 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5417 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5419 cmdline_parse_token_string_t cmd_set_link_down_port =
5420 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5421 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5422 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5424 static void cmd_set_link_down_parsed(
5425 __attribute__((unused)) void *parsed_result,
5426 __attribute__((unused)) struct cmdline *cl,
5427 __attribute__((unused)) void *data)
5429 struct cmd_set_link_down_result *res = parsed_result;
5430 dev_set_link_down(res->port_id);
5433 cmdline_parse_inst_t cmd_set_link_down = {
5434 .f = cmd_set_link_down_parsed,
5436 .help_str = "set link-down port (port id)",
5438 (void *)&cmd_set_link_down_set,
5439 (void *)&cmd_set_link_down_link_down,
5440 (void *)&cmd_set_link_down_port,
5441 (void *)&cmd_set_link_down_port_id,
5446 /* *** SHOW CFG *** */
5447 struct cmd_showcfg_result {
5448 cmdline_fixed_string_t show;
5449 cmdline_fixed_string_t cfg;
5450 cmdline_fixed_string_t what;
5453 static void cmd_showcfg_parsed(void *parsed_result,
5454 __attribute__((unused)) struct cmdline *cl,
5455 __attribute__((unused)) void *data)
5457 struct cmd_showcfg_result *res = parsed_result;
5458 if (!strcmp(res->what, "rxtx"))
5459 rxtx_config_display();
5460 else if (!strcmp(res->what, "cores"))
5461 fwd_lcores_config_display();
5462 else if (!strcmp(res->what, "fwd"))
5463 fwd_config_display();
5466 cmdline_parse_token_string_t cmd_showcfg_show =
5467 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5468 cmdline_parse_token_string_t cmd_showcfg_port =
5469 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5470 cmdline_parse_token_string_t cmd_showcfg_what =
5471 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5474 cmdline_parse_inst_t cmd_showcfg = {
5475 .f = cmd_showcfg_parsed,
5477 .help_str = "show config rxtx|cores|fwd",
5479 (void *)&cmd_showcfg_show,
5480 (void *)&cmd_showcfg_port,
5481 (void *)&cmd_showcfg_what,
5486 /* *** SHOW ALL PORT INFO *** */
5487 struct cmd_showportall_result {
5488 cmdline_fixed_string_t show;
5489 cmdline_fixed_string_t port;
5490 cmdline_fixed_string_t what;
5491 cmdline_fixed_string_t all;
5494 static void cmd_showportall_parsed(void *parsed_result,
5495 __attribute__((unused)) struct cmdline *cl,
5496 __attribute__((unused)) void *data)
5500 struct cmd_showportall_result *res = parsed_result;
5501 if (!strcmp(res->show, "clear")) {
5502 if (!strcmp(res->what, "stats"))
5503 for (i = 0; i < nb_ports; i++)
5505 else if (!strcmp(res->what, "xstats"))
5506 for (i = 0; i < nb_ports; i++)
5507 nic_xstats_clear(i);
5508 } else if (!strcmp(res->what, "info"))
5509 for (i = 0; i < nb_ports; i++)
5510 port_infos_display(i);
5511 else if (!strcmp(res->what, "stats"))
5512 for (i = 0; i < nb_ports; i++)
5513 nic_stats_display(i);
5514 else if (!strcmp(res->what, "xstats"))
5515 for (i = 0; i < nb_ports; i++)
5516 nic_xstats_display(i);
5517 else if (!strcmp(res->what, "fdir"))
5518 for (i = 0; i < nb_ports; i++)
5520 else if (!strcmp(res->what, "stat_qmap"))
5521 for (i = 0; i < nb_ports; i++)
5522 nic_stats_mapping_display(i);
5525 cmdline_parse_token_string_t cmd_showportall_show =
5526 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5528 cmdline_parse_token_string_t cmd_showportall_port =
5529 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5530 cmdline_parse_token_string_t cmd_showportall_what =
5531 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5532 "info#stats#xstats#fdir#stat_qmap");
5533 cmdline_parse_token_string_t cmd_showportall_all =
5534 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5535 cmdline_parse_inst_t cmd_showportall = {
5536 .f = cmd_showportall_parsed,
5538 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5540 (void *)&cmd_showportall_show,
5541 (void *)&cmd_showportall_port,
5542 (void *)&cmd_showportall_what,
5543 (void *)&cmd_showportall_all,
5548 /* *** SHOW PORT INFO *** */
5549 struct cmd_showport_result {
5550 cmdline_fixed_string_t show;
5551 cmdline_fixed_string_t port;
5552 cmdline_fixed_string_t what;
5556 static void cmd_showport_parsed(void *parsed_result,
5557 __attribute__((unused)) struct cmdline *cl,
5558 __attribute__((unused)) void *data)
5560 struct cmd_showport_result *res = parsed_result;
5561 if (!strcmp(res->show, "clear")) {
5562 if (!strcmp(res->what, "stats"))
5563 nic_stats_clear(res->portnum);
5564 else if (!strcmp(res->what, "xstats"))
5565 nic_xstats_clear(res->portnum);
5566 } else if (!strcmp(res->what, "info"))
5567 port_infos_display(res->portnum);
5568 else if (!strcmp(res->what, "stats"))
5569 nic_stats_display(res->portnum);
5570 else if (!strcmp(res->what, "xstats"))
5571 nic_xstats_display(res->portnum);
5572 else if (!strcmp(res->what, "fdir"))
5573 fdir_get_infos(res->portnum);
5574 else if (!strcmp(res->what, "stat_qmap"))
5575 nic_stats_mapping_display(res->portnum);
5578 cmdline_parse_token_string_t cmd_showport_show =
5579 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5581 cmdline_parse_token_string_t cmd_showport_port =
5582 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5583 cmdline_parse_token_string_t cmd_showport_what =
5584 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5585 "info#stats#xstats#fdir#stat_qmap");
5586 cmdline_parse_token_num_t cmd_showport_portnum =
5587 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5589 cmdline_parse_inst_t cmd_showport = {
5590 .f = cmd_showport_parsed,
5592 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5594 (void *)&cmd_showport_show,
5595 (void *)&cmd_showport_port,
5596 (void *)&cmd_showport_what,
5597 (void *)&cmd_showport_portnum,
5602 /* *** READ PORT REGISTER *** */
5603 struct cmd_read_reg_result {
5604 cmdline_fixed_string_t read;
5605 cmdline_fixed_string_t reg;
5611 cmd_read_reg_parsed(void *parsed_result,
5612 __attribute__((unused)) struct cmdline *cl,
5613 __attribute__((unused)) void *data)
5615 struct cmd_read_reg_result *res = parsed_result;
5616 port_reg_display(res->port_id, res->reg_off);
5619 cmdline_parse_token_string_t cmd_read_reg_read =
5620 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5621 cmdline_parse_token_string_t cmd_read_reg_reg =
5622 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5623 cmdline_parse_token_num_t cmd_read_reg_port_id =
5624 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5625 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5626 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5628 cmdline_parse_inst_t cmd_read_reg = {
5629 .f = cmd_read_reg_parsed,
5631 .help_str = "read reg port_id reg_off",
5633 (void *)&cmd_read_reg_read,
5634 (void *)&cmd_read_reg_reg,
5635 (void *)&cmd_read_reg_port_id,
5636 (void *)&cmd_read_reg_reg_off,
5641 /* *** READ PORT REGISTER BIT FIELD *** */
5642 struct cmd_read_reg_bit_field_result {
5643 cmdline_fixed_string_t read;
5644 cmdline_fixed_string_t regfield;
5652 cmd_read_reg_bit_field_parsed(void *parsed_result,
5653 __attribute__((unused)) struct cmdline *cl,
5654 __attribute__((unused)) void *data)
5656 struct cmd_read_reg_bit_field_result *res = parsed_result;
5657 port_reg_bit_field_display(res->port_id, res->reg_off,
5658 res->bit1_pos, res->bit2_pos);
5661 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5662 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5664 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5665 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5666 regfield, "regfield");
5667 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5668 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5670 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5671 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5673 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5674 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5676 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5677 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5680 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5681 .f = cmd_read_reg_bit_field_parsed,
5683 .help_str = "read regfield port_id reg_off bit_x bit_y "
5684 "(read register bit field between bit_x and bit_y included)",
5686 (void *)&cmd_read_reg_bit_field_read,
5687 (void *)&cmd_read_reg_bit_field_regfield,
5688 (void *)&cmd_read_reg_bit_field_port_id,
5689 (void *)&cmd_read_reg_bit_field_reg_off,
5690 (void *)&cmd_read_reg_bit_field_bit1_pos,
5691 (void *)&cmd_read_reg_bit_field_bit2_pos,
5696 /* *** READ PORT REGISTER BIT *** */
5697 struct cmd_read_reg_bit_result {
5698 cmdline_fixed_string_t read;
5699 cmdline_fixed_string_t regbit;
5706 cmd_read_reg_bit_parsed(void *parsed_result,
5707 __attribute__((unused)) struct cmdline *cl,
5708 __attribute__((unused)) void *data)
5710 struct cmd_read_reg_bit_result *res = parsed_result;
5711 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5714 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5715 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5716 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5717 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5719 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5720 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5721 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5722 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5723 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5724 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5726 cmdline_parse_inst_t cmd_read_reg_bit = {
5727 .f = cmd_read_reg_bit_parsed,
5729 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5731 (void *)&cmd_read_reg_bit_read,
5732 (void *)&cmd_read_reg_bit_regbit,
5733 (void *)&cmd_read_reg_bit_port_id,
5734 (void *)&cmd_read_reg_bit_reg_off,
5735 (void *)&cmd_read_reg_bit_bit_pos,
5740 /* *** WRITE PORT REGISTER *** */
5741 struct cmd_write_reg_result {
5742 cmdline_fixed_string_t write;
5743 cmdline_fixed_string_t reg;
5750 cmd_write_reg_parsed(void *parsed_result,
5751 __attribute__((unused)) struct cmdline *cl,
5752 __attribute__((unused)) void *data)
5754 struct cmd_write_reg_result *res = parsed_result;
5755 port_reg_set(res->port_id, res->reg_off, res->value);
5758 cmdline_parse_token_string_t cmd_write_reg_write =
5759 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5760 cmdline_parse_token_string_t cmd_write_reg_reg =
5761 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5762 cmdline_parse_token_num_t cmd_write_reg_port_id =
5763 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5764 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5765 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5766 cmdline_parse_token_num_t cmd_write_reg_value =
5767 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5769 cmdline_parse_inst_t cmd_write_reg = {
5770 .f = cmd_write_reg_parsed,
5772 .help_str = "write reg port_id reg_off reg_value",
5774 (void *)&cmd_write_reg_write,
5775 (void *)&cmd_write_reg_reg,
5776 (void *)&cmd_write_reg_port_id,
5777 (void *)&cmd_write_reg_reg_off,
5778 (void *)&cmd_write_reg_value,
5783 /* *** WRITE PORT REGISTER BIT FIELD *** */
5784 struct cmd_write_reg_bit_field_result {
5785 cmdline_fixed_string_t write;
5786 cmdline_fixed_string_t regfield;
5795 cmd_write_reg_bit_field_parsed(void *parsed_result,
5796 __attribute__((unused)) struct cmdline *cl,
5797 __attribute__((unused)) void *data)
5799 struct cmd_write_reg_bit_field_result *res = parsed_result;
5800 port_reg_bit_field_set(res->port_id, res->reg_off,
5801 res->bit1_pos, res->bit2_pos, res->value);
5804 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5805 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5807 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5808 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5809 regfield, "regfield");
5810 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5811 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5813 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5814 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5816 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5817 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5819 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5820 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5822 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5823 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5826 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5827 .f = cmd_write_reg_bit_field_parsed,
5829 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5830 "(set register bit field between bit_x and bit_y included)",
5832 (void *)&cmd_write_reg_bit_field_write,
5833 (void *)&cmd_write_reg_bit_field_regfield,
5834 (void *)&cmd_write_reg_bit_field_port_id,
5835 (void *)&cmd_write_reg_bit_field_reg_off,
5836 (void *)&cmd_write_reg_bit_field_bit1_pos,
5837 (void *)&cmd_write_reg_bit_field_bit2_pos,
5838 (void *)&cmd_write_reg_bit_field_value,
5843 /* *** WRITE PORT REGISTER BIT *** */
5844 struct cmd_write_reg_bit_result {
5845 cmdline_fixed_string_t write;
5846 cmdline_fixed_string_t regbit;
5854 cmd_write_reg_bit_parsed(void *parsed_result,
5855 __attribute__((unused)) struct cmdline *cl,
5856 __attribute__((unused)) void *data)
5858 struct cmd_write_reg_bit_result *res = parsed_result;
5859 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5862 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5863 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5865 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5866 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5868 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5869 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5870 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5871 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5872 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5873 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5874 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5875 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5877 cmdline_parse_inst_t cmd_write_reg_bit = {
5878 .f = cmd_write_reg_bit_parsed,
5880 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5882 (void *)&cmd_write_reg_bit_write,
5883 (void *)&cmd_write_reg_bit_regbit,
5884 (void *)&cmd_write_reg_bit_port_id,
5885 (void *)&cmd_write_reg_bit_reg_off,
5886 (void *)&cmd_write_reg_bit_bit_pos,
5887 (void *)&cmd_write_reg_bit_value,
5892 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5893 struct cmd_read_rxd_txd_result {
5894 cmdline_fixed_string_t read;
5895 cmdline_fixed_string_t rxd_txd;
5902 cmd_read_rxd_txd_parsed(void *parsed_result,
5903 __attribute__((unused)) struct cmdline *cl,
5904 __attribute__((unused)) void *data)
5906 struct cmd_read_rxd_txd_result *res = parsed_result;
5908 if (!strcmp(res->rxd_txd, "rxd"))
5909 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5910 else if (!strcmp(res->rxd_txd, "txd"))
5911 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5914 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5915 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5916 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5917 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5919 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5920 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5921 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5922 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5923 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5924 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5926 cmdline_parse_inst_t cmd_read_rxd_txd = {
5927 .f = cmd_read_rxd_txd_parsed,
5929 .help_str = "read rxd|txd port_id queue_id rxd_id",
5931 (void *)&cmd_read_rxd_txd_read,
5932 (void *)&cmd_read_rxd_txd_rxd_txd,
5933 (void *)&cmd_read_rxd_txd_port_id,
5934 (void *)&cmd_read_rxd_txd_queue_id,
5935 (void *)&cmd_read_rxd_txd_desc_id,
5941 struct cmd_quit_result {
5942 cmdline_fixed_string_t quit;
5945 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5947 __attribute__((unused)) void *data)
5953 cmdline_parse_token_string_t cmd_quit_quit =
5954 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5956 cmdline_parse_inst_t cmd_quit = {
5957 .f = cmd_quit_parsed,
5959 .help_str = "exit application",
5961 (void *)&cmd_quit_quit,
5966 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5967 struct cmd_mac_addr_result {
5968 cmdline_fixed_string_t mac_addr_cmd;
5969 cmdline_fixed_string_t what;
5971 struct ether_addr address;
5974 static void cmd_mac_addr_parsed(void *parsed_result,
5975 __attribute__((unused)) struct cmdline *cl,
5976 __attribute__((unused)) void *data)
5978 struct cmd_mac_addr_result *res = parsed_result;
5981 if (strcmp(res->what, "add") == 0)
5982 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5984 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5986 /* check the return value and print it if is < 0 */
5988 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5992 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5993 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5995 cmdline_parse_token_string_t cmd_mac_addr_what =
5996 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5998 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5999 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6000 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6001 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6003 cmdline_parse_inst_t cmd_mac_addr = {
6004 .f = cmd_mac_addr_parsed,
6006 .help_str = "mac_addr add|remove X <address>: "
6007 "add/remove MAC address on port X",
6009 (void *)&cmd_mac_addr_cmd,
6010 (void *)&cmd_mac_addr_what,
6011 (void *)&cmd_mac_addr_portnum,
6012 (void *)&cmd_mac_addr_addr,
6018 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6019 struct cmd_set_qmap_result {
6020 cmdline_fixed_string_t set;
6021 cmdline_fixed_string_t qmap;
6022 cmdline_fixed_string_t what;
6029 cmd_set_qmap_parsed(void *parsed_result,
6030 __attribute__((unused)) struct cmdline *cl,
6031 __attribute__((unused)) void *data)
6033 struct cmd_set_qmap_result *res = parsed_result;
6034 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6036 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6039 cmdline_parse_token_string_t cmd_setqmap_set =
6040 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6042 cmdline_parse_token_string_t cmd_setqmap_qmap =
6043 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6045 cmdline_parse_token_string_t cmd_setqmap_what =
6046 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6048 cmdline_parse_token_num_t cmd_setqmap_portid =
6049 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6051 cmdline_parse_token_num_t cmd_setqmap_queueid =
6052 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6054 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6055 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6058 cmdline_parse_inst_t cmd_set_qmap = {
6059 .f = cmd_set_qmap_parsed,
6061 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6063 (void *)&cmd_setqmap_set,
6064 (void *)&cmd_setqmap_qmap,
6065 (void *)&cmd_setqmap_what,
6066 (void *)&cmd_setqmap_portid,
6067 (void *)&cmd_setqmap_queueid,
6068 (void *)&cmd_setqmap_mapvalue,
6073 /* *** CONFIGURE UNICAST HASH TABLE *** */
6074 struct cmd_set_uc_hash_table {
6075 cmdline_fixed_string_t set;
6076 cmdline_fixed_string_t port;
6078 cmdline_fixed_string_t what;
6079 struct ether_addr address;
6080 cmdline_fixed_string_t mode;
6084 cmd_set_uc_hash_parsed(void *parsed_result,
6085 __attribute__((unused)) struct cmdline *cl,
6086 __attribute__((unused)) void *data)
6089 struct cmd_set_uc_hash_table *res = parsed_result;
6091 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6093 if (strcmp(res->what, "uta") == 0)
6094 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6095 &res->address,(uint8_t)is_on);
6097 printf("bad unicast hash table parameter, return code = %d \n", ret);
6101 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6102 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6104 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6105 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6107 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6108 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6110 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6111 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6113 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6114 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6116 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6117 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6120 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6121 .f = cmd_set_uc_hash_parsed,
6123 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6125 (void *)&cmd_set_uc_hash_set,
6126 (void *)&cmd_set_uc_hash_port,
6127 (void *)&cmd_set_uc_hash_portid,
6128 (void *)&cmd_set_uc_hash_what,
6129 (void *)&cmd_set_uc_hash_mac,
6130 (void *)&cmd_set_uc_hash_mode,
6135 struct cmd_set_uc_all_hash_table {
6136 cmdline_fixed_string_t set;
6137 cmdline_fixed_string_t port;
6139 cmdline_fixed_string_t what;
6140 cmdline_fixed_string_t value;
6141 cmdline_fixed_string_t mode;
6145 cmd_set_uc_all_hash_parsed(void *parsed_result,
6146 __attribute__((unused)) struct cmdline *cl,
6147 __attribute__((unused)) void *data)
6150 struct cmd_set_uc_all_hash_table *res = parsed_result;
6152 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6154 if ((strcmp(res->what, "uta") == 0) &&
6155 (strcmp(res->value, "all") == 0))
6156 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6158 printf("bad unicast hash table parameter,"
6159 "return code = %d \n", ret);
6162 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6163 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6165 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6166 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6168 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6169 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6171 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6172 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6174 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6175 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6177 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6178 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6181 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6182 .f = cmd_set_uc_all_hash_parsed,
6184 .help_str = "set port X uta all on|off (X = port number)",
6186 (void *)&cmd_set_uc_all_hash_set,
6187 (void *)&cmd_set_uc_all_hash_port,
6188 (void *)&cmd_set_uc_all_hash_portid,
6189 (void *)&cmd_set_uc_all_hash_what,
6190 (void *)&cmd_set_uc_all_hash_value,
6191 (void *)&cmd_set_uc_all_hash_mode,
6196 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6197 struct cmd_set_vf_macvlan_filter {
6198 cmdline_fixed_string_t set;
6199 cmdline_fixed_string_t port;
6201 cmdline_fixed_string_t vf;
6203 struct ether_addr address;
6204 cmdline_fixed_string_t filter_type;
6205 cmdline_fixed_string_t mode;
6209 cmd_set_vf_macvlan_parsed(void *parsed_result,
6210 __attribute__((unused)) struct cmdline *cl,
6211 __attribute__((unused)) void *data)
6214 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6215 struct rte_eth_mac_filter filter;
6217 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6219 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6221 /* set VF MAC filter */
6225 filter.dst_id = res->vf_id;
6227 if (!strcmp(res->filter_type, "exact-mac"))
6228 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6229 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6230 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6231 else if (!strcmp(res->filter_type, "hashmac"))
6232 filter.filter_type = RTE_MAC_HASH_MATCH;
6233 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6234 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6236 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6239 ret = rte_eth_dev_filter_ctrl(res->port_id,
6240 RTE_ETH_FILTER_MACVLAN,
6244 ret = rte_eth_dev_filter_ctrl(res->port_id,
6245 RTE_ETH_FILTER_MACVLAN,
6246 RTE_ETH_FILTER_DELETE,
6250 printf("bad set MAC hash parameter, return code = %d\n", ret);
6254 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6255 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6257 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6258 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6260 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6261 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6263 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6264 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6266 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6267 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6269 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6270 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6272 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6273 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6274 filter_type, "exact-mac#exact-mac-vlan"
6275 "#hashmac#hashmac-vlan");
6276 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6277 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6280 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6281 .f = cmd_set_vf_macvlan_parsed,
6283 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6284 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6286 "exact match rule:exact match of MAC or MAC and VLAN; "
6287 "hash match rule: hash match of MAC and exact match "
6290 (void *)&cmd_set_vf_macvlan_set,
6291 (void *)&cmd_set_vf_macvlan_port,
6292 (void *)&cmd_set_vf_macvlan_portid,
6293 (void *)&cmd_set_vf_macvlan_vf,
6294 (void *)&cmd_set_vf_macvlan_vf_id,
6295 (void *)&cmd_set_vf_macvlan_mac,
6296 (void *)&cmd_set_vf_macvlan_filter_type,
6297 (void *)&cmd_set_vf_macvlan_mode,
6302 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6303 struct cmd_set_vf_traffic {
6304 cmdline_fixed_string_t set;
6305 cmdline_fixed_string_t port;
6307 cmdline_fixed_string_t vf;
6309 cmdline_fixed_string_t what;
6310 cmdline_fixed_string_t mode;
6314 cmd_set_vf_traffic_parsed(void *parsed_result,
6315 __attribute__((unused)) struct cmdline *cl,
6316 __attribute__((unused)) void *data)
6318 struct cmd_set_vf_traffic *res = parsed_result;
6319 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6320 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6322 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6325 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6326 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6328 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6329 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6331 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6332 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6334 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6335 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6337 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6338 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6340 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6341 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6343 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6344 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6347 cmdline_parse_inst_t cmd_set_vf_traffic = {
6348 .f = cmd_set_vf_traffic_parsed,
6350 .help_str = "set port X vf Y rx|tx on|off"
6351 "(X = port number,Y = vf id)",
6353 (void *)&cmd_setvf_traffic_set,
6354 (void *)&cmd_setvf_traffic_port,
6355 (void *)&cmd_setvf_traffic_portid,
6356 (void *)&cmd_setvf_traffic_vf,
6357 (void *)&cmd_setvf_traffic_vfid,
6358 (void *)&cmd_setvf_traffic_what,
6359 (void *)&cmd_setvf_traffic_mode,
6364 /* *** CONFIGURE VF RECEIVE MODE *** */
6365 struct cmd_set_vf_rxmode {
6366 cmdline_fixed_string_t set;
6367 cmdline_fixed_string_t port;
6369 cmdline_fixed_string_t vf;
6371 cmdline_fixed_string_t what;
6372 cmdline_fixed_string_t mode;
6373 cmdline_fixed_string_t on;
6377 cmd_set_vf_rxmode_parsed(void *parsed_result,
6378 __attribute__((unused)) struct cmdline *cl,
6379 __attribute__((unused)) void *data)
6382 uint16_t rx_mode = 0;
6383 struct cmd_set_vf_rxmode *res = parsed_result;
6385 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6386 if (!strcmp(res->what,"rxmode")) {
6387 if (!strcmp(res->mode, "AUPE"))
6388 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6389 else if (!strcmp(res->mode, "ROPE"))
6390 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6391 else if (!strcmp(res->mode, "BAM"))
6392 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6393 else if (!strncmp(res->mode, "MPE",3))
6394 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6397 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6399 printf("bad VF receive mode parameter, return code = %d \n",
6403 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6404 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6406 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6407 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6409 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6410 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6412 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6413 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6415 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6416 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6418 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6419 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6421 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6422 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6423 mode, "AUPE#ROPE#BAM#MPE");
6424 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6425 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6428 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6429 .f = cmd_set_vf_rxmode_parsed,
6431 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6433 (void *)&cmd_set_vf_rxmode_set,
6434 (void *)&cmd_set_vf_rxmode_port,
6435 (void *)&cmd_set_vf_rxmode_portid,
6436 (void *)&cmd_set_vf_rxmode_vf,
6437 (void *)&cmd_set_vf_rxmode_vfid,
6438 (void *)&cmd_set_vf_rxmode_what,
6439 (void *)&cmd_set_vf_rxmode_mode,
6440 (void *)&cmd_set_vf_rxmode_on,
6445 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6446 struct cmd_vf_mac_addr_result {
6447 cmdline_fixed_string_t mac_addr_cmd;
6448 cmdline_fixed_string_t what;
6449 cmdline_fixed_string_t port;
6451 cmdline_fixed_string_t vf;
6453 struct ether_addr address;
6456 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6457 __attribute__((unused)) struct cmdline *cl,
6458 __attribute__((unused)) void *data)
6460 struct cmd_vf_mac_addr_result *res = parsed_result;
6463 if (strcmp(res->what, "add") == 0)
6464 ret = rte_eth_dev_mac_addr_add(res->port_num,
6465 &res->address, res->vf_num);
6467 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6471 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6472 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6473 mac_addr_cmd,"mac_addr");
6474 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6475 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6477 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6478 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6480 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6481 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6483 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6484 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6486 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6487 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6489 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6490 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6493 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6494 .f = cmd_vf_mac_addr_parsed,
6496 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6497 "Y = VF number)add MAC address filtering for a VF on port X",
6499 (void *)&cmd_vf_mac_addr_cmd,
6500 (void *)&cmd_vf_mac_addr_what,
6501 (void *)&cmd_vf_mac_addr_port,
6502 (void *)&cmd_vf_mac_addr_portnum,
6503 (void *)&cmd_vf_mac_addr_vf,
6504 (void *)&cmd_vf_mac_addr_vfnum,
6505 (void *)&cmd_vf_mac_addr_addr,
6510 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6511 struct cmd_vf_rx_vlan_filter {
6512 cmdline_fixed_string_t rx_vlan;
6513 cmdline_fixed_string_t what;
6515 cmdline_fixed_string_t port;
6517 cmdline_fixed_string_t vf;
6522 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6523 __attribute__((unused)) struct cmdline *cl,
6524 __attribute__((unused)) void *data)
6526 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6528 if (!strcmp(res->what, "add"))
6529 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6531 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6534 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6535 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6536 rx_vlan, "rx_vlan");
6537 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6538 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6540 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6541 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6543 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6544 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6546 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6547 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6549 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6550 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6552 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6553 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6556 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6557 .f = cmd_vf_rx_vlan_filter_parsed,
6559 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6560 "Y = port number,Z = hexadecimal VF mask)",
6562 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6563 (void *)&cmd_vf_rx_vlan_filter_what,
6564 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6565 (void *)&cmd_vf_rx_vlan_filter_port,
6566 (void *)&cmd_vf_rx_vlan_filter_portid,
6567 (void *)&cmd_vf_rx_vlan_filter_vf,
6568 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6573 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6574 struct cmd_queue_rate_limit_result {
6575 cmdline_fixed_string_t set;
6576 cmdline_fixed_string_t port;
6578 cmdline_fixed_string_t queue;
6580 cmdline_fixed_string_t rate;
6584 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6585 __attribute__((unused)) struct cmdline *cl,
6586 __attribute__((unused)) void *data)
6588 struct cmd_queue_rate_limit_result *res = parsed_result;
6591 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6592 && (strcmp(res->queue, "queue") == 0)
6593 && (strcmp(res->rate, "rate") == 0))
6594 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6597 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6601 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6602 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6604 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6605 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6607 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6608 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6610 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6611 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6613 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6614 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6616 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6617 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6619 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6620 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6623 cmdline_parse_inst_t cmd_queue_rate_limit = {
6624 .f = cmd_queue_rate_limit_parsed,
6626 .help_str = "set port X queue Y rate Z:(X = port number,"
6627 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6629 (void *)&cmd_queue_rate_limit_set,
6630 (void *)&cmd_queue_rate_limit_port,
6631 (void *)&cmd_queue_rate_limit_portnum,
6632 (void *)&cmd_queue_rate_limit_queue,
6633 (void *)&cmd_queue_rate_limit_queuenum,
6634 (void *)&cmd_queue_rate_limit_rate,
6635 (void *)&cmd_queue_rate_limit_ratenum,
6640 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6641 struct cmd_vf_rate_limit_result {
6642 cmdline_fixed_string_t set;
6643 cmdline_fixed_string_t port;
6645 cmdline_fixed_string_t vf;
6647 cmdline_fixed_string_t rate;
6649 cmdline_fixed_string_t q_msk;
6653 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6654 __attribute__((unused)) struct cmdline *cl,
6655 __attribute__((unused)) void *data)
6657 struct cmd_vf_rate_limit_result *res = parsed_result;
6660 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6661 && (strcmp(res->vf, "vf") == 0)
6662 && (strcmp(res->rate, "rate") == 0)
6663 && (strcmp(res->q_msk, "queue_mask") == 0))
6664 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6665 res->rate_num, res->q_msk_val);
6667 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6671 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6672 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6674 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6675 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6677 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6678 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6680 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6681 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6683 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6684 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6686 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6687 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6689 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6690 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6692 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6693 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6694 q_msk, "queue_mask");
6695 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6696 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6699 cmdline_parse_inst_t cmd_vf_rate_limit = {
6700 .f = cmd_vf_rate_limit_parsed,
6702 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6703 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6704 "for queues of VF on port X",
6706 (void *)&cmd_vf_rate_limit_set,
6707 (void *)&cmd_vf_rate_limit_port,
6708 (void *)&cmd_vf_rate_limit_portnum,
6709 (void *)&cmd_vf_rate_limit_vf,
6710 (void *)&cmd_vf_rate_limit_vfnum,
6711 (void *)&cmd_vf_rate_limit_rate,
6712 (void *)&cmd_vf_rate_limit_ratenum,
6713 (void *)&cmd_vf_rate_limit_q_msk,
6714 (void *)&cmd_vf_rate_limit_q_msk_val,
6719 /* *** ADD TUNNEL FILTER OF A PORT *** */
6720 struct cmd_tunnel_filter_result {
6721 cmdline_fixed_string_t cmd;
6722 cmdline_fixed_string_t what;
6724 struct ether_addr outer_mac;
6725 struct ether_addr inner_mac;
6726 cmdline_ipaddr_t ip_value;
6727 uint16_t inner_vlan;
6728 cmdline_fixed_string_t tunnel_type;
6729 cmdline_fixed_string_t filter_type;
6735 cmd_tunnel_filter_parsed(void *parsed_result,
6736 __attribute__((unused)) struct cmdline *cl,
6737 __attribute__((unused)) void *data)
6739 struct cmd_tunnel_filter_result *res = parsed_result;
6740 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6743 tunnel_filter_conf.outer_mac = &res->outer_mac;
6744 tunnel_filter_conf.inner_mac = &res->inner_mac;
6745 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6747 if (res->ip_value.family == AF_INET) {
6748 tunnel_filter_conf.ip_addr.ipv4_addr =
6749 res->ip_value.addr.ipv4.s_addr;
6750 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6752 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6753 &(res->ip_value.addr.ipv6),
6754 sizeof(struct in6_addr));
6755 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6758 if (!strcmp(res->filter_type, "imac-ivlan"))
6759 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6760 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6761 tunnel_filter_conf.filter_type =
6762 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6763 else if (!strcmp(res->filter_type, "imac-tenid"))
6764 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6765 else if (!strcmp(res->filter_type, "imac"))
6766 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6767 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6768 tunnel_filter_conf.filter_type =
6769 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6771 printf("The filter type is not supported");
6775 if (!strcmp(res->tunnel_type, "vxlan"))
6776 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6778 printf("Only VXLAN is supported now.\n");
6782 tunnel_filter_conf.tenant_id = res->tenant_id;
6783 tunnel_filter_conf.queue_id = res->queue_num;
6784 if (!strcmp(res->what, "add"))
6785 ret = rte_eth_dev_filter_ctrl(res->port_id,
6786 RTE_ETH_FILTER_TUNNEL,
6788 &tunnel_filter_conf);
6790 ret = rte_eth_dev_filter_ctrl(res->port_id,
6791 RTE_ETH_FILTER_TUNNEL,
6792 RTE_ETH_FILTER_DELETE,
6793 &tunnel_filter_conf);
6795 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6799 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6800 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6801 cmd, "tunnel_filter");
6802 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6803 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6805 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6806 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6808 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6809 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6811 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6812 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6814 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6815 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6816 inner_vlan, UINT16);
6817 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6818 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6820 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6821 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6822 tunnel_type, "vxlan");
6824 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6825 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6826 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6827 "imac#omac-imac-tenid");
6828 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6829 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6831 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6832 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6835 cmdline_parse_inst_t cmd_tunnel_filter = {
6836 .f = cmd_tunnel_filter_parsed,
6838 .help_str = "add/rm tunnel filter of a port: "
6839 "tunnel_filter add port_id outer_mac inner_mac ip "
6840 "inner_vlan tunnel_type(vxlan) filter_type "
6841 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6842 "imac|omac-imac-tenid) "
6843 "tenant_id queue_num",
6845 (void *)&cmd_tunnel_filter_cmd,
6846 (void *)&cmd_tunnel_filter_what,
6847 (void *)&cmd_tunnel_filter_port_id,
6848 (void *)&cmd_tunnel_filter_outer_mac,
6849 (void *)&cmd_tunnel_filter_inner_mac,
6850 (void *)&cmd_tunnel_filter_ip_value,
6851 (void *)&cmd_tunnel_filter_innner_vlan,
6852 (void *)&cmd_tunnel_filter_tunnel_type,
6853 (void *)&cmd_tunnel_filter_filter_type,
6854 (void *)&cmd_tunnel_filter_tenant_id,
6855 (void *)&cmd_tunnel_filter_queue_num,
6860 /* *** CONFIGURE TUNNEL UDP PORT *** */
6861 struct cmd_tunnel_udp_config {
6862 cmdline_fixed_string_t cmd;
6863 cmdline_fixed_string_t what;
6869 cmd_tunnel_udp_config_parsed(void *parsed_result,
6870 __attribute__((unused)) struct cmdline *cl,
6871 __attribute__((unused)) void *data)
6873 struct cmd_tunnel_udp_config *res = parsed_result;
6874 struct rte_eth_udp_tunnel tunnel_udp;
6877 tunnel_udp.udp_port = res->udp_port;
6879 if (!strcmp(res->cmd, "rx_vxlan_port"))
6880 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6882 if (!strcmp(res->what, "add"))
6883 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6885 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6888 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6891 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6892 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6893 cmd, "rx_vxlan_port");
6894 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6895 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6897 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6898 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6900 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6901 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6904 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6905 .f = cmd_tunnel_udp_config_parsed,
6907 .help_str = "add/rm an tunneling UDP port filter: "
6908 "rx_vxlan_port add udp_port port_id",
6910 (void *)&cmd_tunnel_udp_config_cmd,
6911 (void *)&cmd_tunnel_udp_config_what,
6912 (void *)&cmd_tunnel_udp_config_udp_port,
6913 (void *)&cmd_tunnel_udp_config_port_id,
6918 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6919 struct cmd_set_mirror_mask_result {
6920 cmdline_fixed_string_t set;
6921 cmdline_fixed_string_t port;
6923 cmdline_fixed_string_t mirror;
6925 cmdline_fixed_string_t what;
6926 cmdline_fixed_string_t value;
6927 cmdline_fixed_string_t dstpool;
6929 cmdline_fixed_string_t on;
6932 cmdline_parse_token_string_t cmd_mirror_mask_set =
6933 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6935 cmdline_parse_token_string_t cmd_mirror_mask_port =
6936 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6938 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6939 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6941 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6942 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6943 mirror, "mirror-rule");
6944 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6945 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6947 cmdline_parse_token_string_t cmd_mirror_mask_what =
6948 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6949 what, "pool-mirror#vlan-mirror");
6950 cmdline_parse_token_string_t cmd_mirror_mask_value =
6951 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6953 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6954 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6955 dstpool, "dst-pool");
6956 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6957 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6959 cmdline_parse_token_string_t cmd_mirror_mask_on =
6960 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6964 cmd_set_mirror_mask_parsed(void *parsed_result,
6965 __attribute__((unused)) struct cmdline *cl,
6966 __attribute__((unused)) void *data)
6969 struct cmd_set_mirror_mask_result *res = parsed_result;
6970 struct rte_eth_vmdq_mirror_conf mr_conf;
6972 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6974 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6976 mr_conf.dst_pool = res->dstpool_id;
6978 if (!strcmp(res->what, "pool-mirror")) {
6979 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6980 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6981 } else if(!strcmp(res->what, "vlan-mirror")) {
6982 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6983 nb_item = parse_item_list(res->value, "core",
6984 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6988 for(i=0; i < nb_item; i++) {
6989 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6990 printf("Invalid vlan_id: must be < 4096\n");
6994 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6995 mr_conf.vlan.vlan_mask |= 1ULL << i;
6999 if(!strcmp(res->on, "on"))
7000 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7003 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7006 printf("mirror rule add error: (%s)\n", strerror(-ret));
7009 cmdline_parse_inst_t cmd_set_mirror_mask = {
7010 .f = cmd_set_mirror_mask_parsed,
7012 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
7013 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7015 (void *)&cmd_mirror_mask_set,
7016 (void *)&cmd_mirror_mask_port,
7017 (void *)&cmd_mirror_mask_portid,
7018 (void *)&cmd_mirror_mask_mirror,
7019 (void *)&cmd_mirror_mask_ruleid,
7020 (void *)&cmd_mirror_mask_what,
7021 (void *)&cmd_mirror_mask_value,
7022 (void *)&cmd_mirror_mask_dstpool,
7023 (void *)&cmd_mirror_mask_poolid,
7024 (void *)&cmd_mirror_mask_on,
7029 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7030 struct cmd_set_mirror_link_result {
7031 cmdline_fixed_string_t set;
7032 cmdline_fixed_string_t port;
7034 cmdline_fixed_string_t mirror;
7036 cmdline_fixed_string_t what;
7037 cmdline_fixed_string_t dstpool;
7039 cmdline_fixed_string_t on;
7042 cmdline_parse_token_string_t cmd_mirror_link_set =
7043 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7045 cmdline_parse_token_string_t cmd_mirror_link_port =
7046 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7048 cmdline_parse_token_num_t cmd_mirror_link_portid =
7049 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7051 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7052 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7053 mirror, "mirror-rule");
7054 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7055 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7057 cmdline_parse_token_string_t cmd_mirror_link_what =
7058 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7059 what, "uplink-mirror#downlink-mirror");
7060 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7061 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7062 dstpool, "dst-pool");
7063 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7064 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7066 cmdline_parse_token_string_t cmd_mirror_link_on =
7067 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7071 cmd_set_mirror_link_parsed(void *parsed_result,
7072 __attribute__((unused)) struct cmdline *cl,
7073 __attribute__((unused)) void *data)
7076 struct cmd_set_mirror_link_result *res = parsed_result;
7077 struct rte_eth_vmdq_mirror_conf mr_conf;
7079 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
7080 if(!strcmp(res->what, "uplink-mirror")) {
7081 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
7082 }else if(!strcmp(res->what, "downlink-mirror"))
7083 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
7085 mr_conf.dst_pool = res->dstpool_id;
7087 if(!strcmp(res->on, "on"))
7088 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7091 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
7094 /* check the return value and print it if is < 0 */
7096 printf("mirror rule add error: (%s)\n", strerror(-ret));
7100 cmdline_parse_inst_t cmd_set_mirror_link = {
7101 .f = cmd_set_mirror_link_parsed,
7103 .help_str = "set port X mirror-rule Y uplink-mirror|"
7104 "downlink-mirror dst-pool Z on|off",
7106 (void *)&cmd_mirror_link_set,
7107 (void *)&cmd_mirror_link_port,
7108 (void *)&cmd_mirror_link_portid,
7109 (void *)&cmd_mirror_link_mirror,
7110 (void *)&cmd_mirror_link_ruleid,
7111 (void *)&cmd_mirror_link_what,
7112 (void *)&cmd_mirror_link_dstpool,
7113 (void *)&cmd_mirror_link_poolid,
7114 (void *)&cmd_mirror_link_on,
7119 /* *** RESET VM MIRROR RULE *** */
7120 struct cmd_rm_mirror_rule_result {
7121 cmdline_fixed_string_t reset;
7122 cmdline_fixed_string_t port;
7124 cmdline_fixed_string_t mirror;
7128 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7129 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7131 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7132 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7134 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7135 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7137 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7138 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7139 mirror, "mirror-rule");
7140 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7141 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7145 cmd_reset_mirror_rule_parsed(void *parsed_result,
7146 __attribute__((unused)) struct cmdline *cl,
7147 __attribute__((unused)) void *data)
7150 struct cmd_set_mirror_link_result *res = parsed_result;
7152 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7154 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7157 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7158 .f = cmd_reset_mirror_rule_parsed,
7160 .help_str = "reset port X mirror-rule Y",
7162 (void *)&cmd_rm_mirror_rule_reset,
7163 (void *)&cmd_rm_mirror_rule_port,
7164 (void *)&cmd_rm_mirror_rule_portid,
7165 (void *)&cmd_rm_mirror_rule_mirror,
7166 (void *)&cmd_rm_mirror_rule_ruleid,
7171 /* ******************************************************************************** */
7173 struct cmd_dump_result {
7174 cmdline_fixed_string_t dump;
7178 dump_struct_sizes(void)
7180 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7181 DUMP_SIZE(struct rte_mbuf);
7182 DUMP_SIZE(struct rte_mempool);
7183 DUMP_SIZE(struct rte_ring);
7187 static void cmd_dump_parsed(void *parsed_result,
7188 __attribute__((unused)) struct cmdline *cl,
7189 __attribute__((unused)) void *data)
7191 struct cmd_dump_result *res = parsed_result;
7193 if (!strcmp(res->dump, "dump_physmem"))
7194 rte_dump_physmem_layout(stdout);
7195 else if (!strcmp(res->dump, "dump_memzone"))
7196 rte_memzone_dump(stdout);
7197 else if (!strcmp(res->dump, "dump_log_history"))
7198 rte_log_dump_history(stdout);
7199 else if (!strcmp(res->dump, "dump_struct_sizes"))
7200 dump_struct_sizes();
7201 else if (!strcmp(res->dump, "dump_ring"))
7202 rte_ring_list_dump(stdout);
7203 else if (!strcmp(res->dump, "dump_mempool"))
7204 rte_mempool_list_dump(stdout);
7205 else if (!strcmp(res->dump, "dump_devargs"))
7206 rte_eal_devargs_dump(stdout);
7209 cmdline_parse_token_string_t cmd_dump_dump =
7210 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7214 "dump_struct_sizes#"
7219 cmdline_parse_inst_t cmd_dump = {
7220 .f = cmd_dump_parsed, /* function to call */
7221 .data = NULL, /* 2nd arg of func */
7222 .help_str = "dump status",
7223 .tokens = { /* token list, NULL terminated */
7224 (void *)&cmd_dump_dump,
7229 /* ******************************************************************************** */
7231 struct cmd_dump_one_result {
7232 cmdline_fixed_string_t dump;
7233 cmdline_fixed_string_t name;
7236 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7237 __attribute__((unused)) void *data)
7239 struct cmd_dump_one_result *res = parsed_result;
7241 if (!strcmp(res->dump, "dump_ring")) {
7243 r = rte_ring_lookup(res->name);
7245 cmdline_printf(cl, "Cannot find ring\n");
7248 rte_ring_dump(stdout, r);
7249 } else if (!strcmp(res->dump, "dump_mempool")) {
7250 struct rte_mempool *mp;
7251 mp = rte_mempool_lookup(res->name);
7253 cmdline_printf(cl, "Cannot find mempool\n");
7256 rte_mempool_dump(stdout, mp);
7260 cmdline_parse_token_string_t cmd_dump_one_dump =
7261 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7262 "dump_ring#dump_mempool");
7264 cmdline_parse_token_string_t cmd_dump_one_name =
7265 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7267 cmdline_parse_inst_t cmd_dump_one = {
7268 .f = cmd_dump_one_parsed, /* function to call */
7269 .data = NULL, /* 2nd arg of func */
7270 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7271 .tokens = { /* token list, NULL terminated */
7272 (void *)&cmd_dump_one_dump,
7273 (void *)&cmd_dump_one_name,
7278 /* *** set SYN filter *** */
7279 struct cmd_set_syn_filter_result {
7280 cmdline_fixed_string_t filter;
7282 cmdline_fixed_string_t priority;
7283 cmdline_fixed_string_t high;
7284 cmdline_fixed_string_t queue;
7289 cmd_set_syn_filter_parsed(void *parsed_result,
7290 __attribute__((unused)) struct cmdline *cl,
7291 __attribute__((unused)) void *data)
7294 struct cmd_set_syn_filter_result *res = parsed_result;
7295 struct rte_syn_filter filter;
7297 if (!strcmp(res->filter, "add_syn_filter")) {
7298 if (!strcmp(res->high, "high"))
7302 ret = rte_eth_dev_add_syn_filter(res->port_id,
7303 &filter, res->queue_id);
7304 } else if (!strcmp(res->filter, "remove_syn_filter"))
7305 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7306 else if (!strcmp(res->filter, "get_syn_filter"))
7307 get_syn_filter(res->port_id);
7309 printf("syn filter setting error: (%s)\n", strerror(-ret));
7312 cmdline_parse_token_num_t cmd_syn_filter_portid =
7313 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7315 cmdline_parse_token_string_t cmd_syn_filter_priority =
7316 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7317 priority, "priority");
7318 cmdline_parse_token_string_t cmd_syn_filter_high =
7319 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7321 cmdline_parse_token_string_t cmd_syn_filter_queue =
7322 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7324 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7325 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7327 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7328 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7329 filter, "add_syn_filter");
7330 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7331 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7332 filter, "remove_syn_filter");
7333 cmdline_parse_inst_t cmd_add_syn_filter = {
7334 .f = cmd_set_syn_filter_parsed,
7336 .help_str = "add syn filter",
7338 (void *)&cmd_syn_filter_add_filter,
7339 (void *)&cmd_syn_filter_portid,
7340 (void *)&cmd_syn_filter_priority,
7341 (void *)&cmd_syn_filter_high,
7342 (void *)&cmd_syn_filter_queue,
7343 (void *)&cmd_syn_filter_queue_id,
7347 cmdline_parse_inst_t cmd_remove_syn_filter = {
7348 .f = cmd_set_syn_filter_parsed,
7350 .help_str = "remove syn filter",
7352 (void *)&cmd_syn_filter_remove_filter,
7353 (void *)&cmd_syn_filter_portid,
7358 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7359 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7360 filter, "get_syn_filter");
7362 cmdline_parse_inst_t cmd_get_syn_filter = {
7363 .f = cmd_set_syn_filter_parsed,
7365 .help_str = "get syn filter",
7367 (void *)&cmd_syn_filter_get_filter,
7368 (void *)&cmd_syn_filter_portid,
7373 /* *** ADD/REMOVE A 2tuple FILTER *** */
7374 struct cmd_2tuple_filter_result {
7375 cmdline_fixed_string_t filter;
7377 cmdline_fixed_string_t protocol;
7378 uint8_t protocol_value;
7379 uint8_t protocol_mask;
7380 cmdline_fixed_string_t dst_port;
7381 uint16_t dst_port_value;
7382 uint16_t dst_port_mask;
7383 cmdline_fixed_string_t flags;
7384 uint8_t flags_value;
7385 cmdline_fixed_string_t priority;
7386 uint8_t priority_value;
7387 cmdline_fixed_string_t queue;
7389 cmdline_fixed_string_t index;
7390 uint16_t index_value;
7394 cmd_2tuple_filter_parsed(void *parsed_result,
7395 __attribute__((unused)) struct cmdline *cl,
7396 __attribute__((unused)) void *data)
7399 struct rte_2tuple_filter filter;
7400 struct cmd_2tuple_filter_result *res = parsed_result;
7402 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7404 if (!strcmp(res->filter, "add_2tuple_filter")) {
7405 /* need convert to big endian. */
7406 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7407 filter.protocol = res->protocol_value;
7408 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7409 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7410 filter.priority = res->priority_value;
7411 filter.tcp_flags = res->flags_value;
7412 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7413 res->index_value, &filter, res->queue_id);
7414 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7415 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7417 else if (!strcmp(res->filter, "get_2tuple_filter"))
7418 get_2tuple_filter(res->port_id, res->index_value);
7421 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7424 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7425 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7427 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7428 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7429 protocol, "protocol");
7430 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7431 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7432 protocol_value, UINT8);
7433 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7434 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7435 protocol_mask, UINT8);
7436 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7437 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7438 dst_port, "dst_port");
7439 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7440 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7441 dst_port_value, UINT16);
7442 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7443 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7444 dst_port_mask, UINT16);
7445 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7446 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7448 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7449 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7450 flags_value, UINT8);
7451 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7452 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7453 priority, "priority");
7454 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7455 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7456 priority_value, UINT8);
7457 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7458 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7460 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7461 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7463 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7464 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7466 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7467 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7468 index_value, UINT16);
7469 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7470 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7471 filter, "add_2tuple_filter");
7472 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7473 .f = cmd_2tuple_filter_parsed,
7475 .help_str = "add a 2tuple filter",
7477 (void *)&cmd_2tuple_filter_add_filter,
7478 (void *)&cmd_2tuple_filter_port_id,
7479 (void *)&cmd_2tuple_filter_protocol,
7480 (void *)&cmd_2tuple_filter_protocol_value,
7481 (void *)&cmd_2tuple_filter_protocol_mask,
7482 (void *)&cmd_2tuple_filter_dst_port,
7483 (void *)&cmd_2tuple_filter_dst_port_value,
7484 (void *)&cmd_2tuple_filter_dst_port_mask,
7485 (void *)&cmd_2tuple_filter_flags,
7486 (void *)&cmd_2tuple_filter_flags_value,
7487 (void *)&cmd_2tuple_filter_priority,
7488 (void *)&cmd_2tuple_filter_priority_value,
7489 (void *)&cmd_2tuple_filter_queue,
7490 (void *)&cmd_2tuple_filter_queue_id,
7491 (void *)&cmd_2tuple_filter_index,
7492 (void *)&cmd_2tuple_filter_index_value,
7497 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7498 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7499 filter, "remove_2tuple_filter");
7500 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7501 .f = cmd_2tuple_filter_parsed,
7503 .help_str = "remove a 2tuple filter",
7505 (void *)&cmd_2tuple_filter_remove_filter,
7506 (void *)&cmd_2tuple_filter_port_id,
7507 (void *)&cmd_2tuple_filter_index,
7508 (void *)&cmd_2tuple_filter_index_value,
7512 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7513 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7514 filter, "get_2tuple_filter");
7515 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7516 .f = cmd_2tuple_filter_parsed,
7518 .help_str = "get a 2tuple filter",
7520 (void *)&cmd_2tuple_filter_get_filter,
7521 (void *)&cmd_2tuple_filter_port_id,
7522 (void *)&cmd_2tuple_filter_index,
7523 (void *)&cmd_2tuple_filter_index_value,
7528 /* *** ADD/REMOVE A 5tuple FILTER *** */
7529 struct cmd_5tuple_filter_result {
7530 cmdline_fixed_string_t filter;
7532 cmdline_fixed_string_t dst_ip;
7533 cmdline_ipaddr_t dst_ip_value;
7534 cmdline_fixed_string_t src_ip;
7535 cmdline_ipaddr_t src_ip_value;
7536 cmdline_fixed_string_t dst_port;
7537 uint16_t dst_port_value;
7538 cmdline_fixed_string_t src_port;
7539 uint16_t src_port_value;
7540 cmdline_fixed_string_t protocol;
7541 uint8_t protocol_value;
7542 cmdline_fixed_string_t mask;
7544 cmdline_fixed_string_t flags;
7545 uint8_t flags_value;
7546 cmdline_fixed_string_t priority;
7547 uint8_t priority_value;
7548 cmdline_fixed_string_t queue;
7550 cmdline_fixed_string_t index;
7551 uint16_t index_value;
7555 cmd_5tuple_filter_parsed(void *parsed_result,
7556 __attribute__((unused)) struct cmdline *cl,
7557 __attribute__((unused)) void *data)
7560 struct rte_5tuple_filter filter;
7561 struct cmd_5tuple_filter_result *res = parsed_result;
7563 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7565 if (!strcmp(res->filter, "add_5tuple_filter")) {
7566 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7567 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7568 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7569 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7570 filter.protocol = res->protocol_value;
7571 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7572 filter.priority = res->priority_value;
7573 filter.tcp_flags = res->flags_value;
7575 if (res->dst_ip_value.family == AF_INET)
7576 /* no need to convert, already big endian. */
7577 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7579 if (filter.dst_ip_mask == 0) {
7580 printf("can not support ipv6 involved compare.\n");
7586 if (res->src_ip_value.family == AF_INET)
7587 /* no need to convert, already big endian. */
7588 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7590 if (filter.src_ip_mask == 0) {
7591 printf("can not support ipv6 involved compare.\n");
7596 /* need convert to big endian. */
7597 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7598 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7600 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7601 res->index_value, &filter, res->queue_id);
7602 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7603 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7605 else if (!strcmp(res->filter, "get_5tuple_filter"))
7606 get_5tuple_filter(res->port_id, res->index_value);
7608 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7612 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7613 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7615 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7616 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7618 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7619 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7621 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7622 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7624 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7625 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7627 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7628 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7629 dst_port, "dst_port");
7630 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7631 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7632 dst_port_value, UINT16);
7633 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7634 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7635 src_port, "src_port");
7636 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7637 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7638 src_port_value, UINT16);
7639 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7640 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7641 protocol, "protocol");
7642 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7643 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7644 protocol_value, UINT8);
7645 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7646 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7648 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7649 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7651 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7652 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7654 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7655 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7656 flags_value, UINT8);
7657 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7658 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7659 priority, "priority");
7660 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7661 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7662 priority_value, UINT8);
7663 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7664 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7666 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7667 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7669 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7670 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7672 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7673 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7674 index_value, UINT16);
7676 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7677 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7678 filter, "add_5tuple_filter");
7679 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7680 .f = cmd_5tuple_filter_parsed,
7682 .help_str = "add a 5tuple filter",
7684 (void *)&cmd_5tuple_filter_add_filter,
7685 (void *)&cmd_5tuple_filter_port_id,
7686 (void *)&cmd_5tuple_filter_dst_ip,
7687 (void *)&cmd_5tuple_filter_dst_ip_value,
7688 (void *)&cmd_5tuple_filter_src_ip,
7689 (void *)&cmd_5tuple_filter_src_ip_value,
7690 (void *)&cmd_5tuple_filter_dst_port,
7691 (void *)&cmd_5tuple_filter_dst_port_value,
7692 (void *)&cmd_5tuple_filter_src_port,
7693 (void *)&cmd_5tuple_filter_src_port_value,
7694 (void *)&cmd_5tuple_filter_protocol,
7695 (void *)&cmd_5tuple_filter_protocol_value,
7696 (void *)&cmd_5tuple_filter_mask,
7697 (void *)&cmd_5tuple_filter_mask_value,
7698 (void *)&cmd_5tuple_filter_flags,
7699 (void *)&cmd_5tuple_filter_flags_value,
7700 (void *)&cmd_5tuple_filter_priority,
7701 (void *)&cmd_5tuple_filter_priority_value,
7702 (void *)&cmd_5tuple_filter_queue,
7703 (void *)&cmd_5tuple_filter_queue_id,
7704 (void *)&cmd_5tuple_filter_index,
7705 (void *)&cmd_5tuple_filter_index_value,
7710 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7711 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7712 filter, "remove_5tuple_filter");
7713 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7714 .f = cmd_5tuple_filter_parsed,
7716 .help_str = "remove a 5tuple filter",
7718 (void *)&cmd_5tuple_filter_remove_filter,
7719 (void *)&cmd_5tuple_filter_port_id,
7720 (void *)&cmd_5tuple_filter_index,
7721 (void *)&cmd_5tuple_filter_index_value,
7726 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7727 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7728 filter, "get_5tuple_filter");
7729 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7730 .f = cmd_5tuple_filter_parsed,
7732 .help_str = "get a 5tuple filter",
7734 (void *)&cmd_5tuple_filter_get_filter,
7735 (void *)&cmd_5tuple_filter_port_id,
7736 (void *)&cmd_5tuple_filter_index,
7737 (void *)&cmd_5tuple_filter_index_value,
7742 /* *** ADD/REMOVE A flex FILTER *** */
7743 struct cmd_flex_filter_result {
7744 cmdline_fixed_string_t filter;
7746 cmdline_fixed_string_t len;
7748 cmdline_fixed_string_t bytes;
7749 cmdline_fixed_string_t bytes_value;
7750 cmdline_fixed_string_t mask;
7751 cmdline_fixed_string_t mask_value;
7752 cmdline_fixed_string_t priority;
7753 uint8_t priority_value;
7754 cmdline_fixed_string_t queue;
7756 cmdline_fixed_string_t index;
7757 uint16_t index_value;
7760 static int xdigit2val(unsigned char c)
7765 else if (isupper(c))
7773 cmd_flex_filter_parsed(void *parsed_result,
7774 __attribute__((unused)) struct cmdline *cl,
7775 __attribute__((unused)) void *data)
7778 struct rte_flex_filter filter;
7779 struct cmd_flex_filter_result *res = parsed_result;
7780 char *bytes_ptr, *mask_ptr;
7788 if (!strcmp(res->filter, "add_flex_filter")) {
7789 if (res->len_value > 128) {
7790 printf("the len exceed the max length 128\n");
7793 memset(&filter, 0, sizeof(struct rte_flex_filter));
7794 filter.len = res->len_value;
7795 filter.priority = res->priority_value;
7796 bytes_ptr = res->bytes_value;
7797 mask_ptr = res->mask_value;
7800 /* translate bytes string to uint_32 array. */
7801 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7802 (bytes_ptr[1] == 'X')))
7804 len = strnlen(bytes_ptr, res->len_value * 2);
7805 if (len == 0 || (len % 8 != 0)) {
7806 printf("please check len and bytes input\n");
7809 for (i = 0; i < len; i++) {
7811 if (isxdigit(c) == 0) {
7812 /* invalid characters. */
7813 printf("invalid input\n");
7816 val = xdigit2val(c);
7820 dword |= byte << (4 * mod - 4);
7825 filter.dwords[j] = dword;
7826 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7832 /* translate mask string to uint8_t array. */
7834 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7835 (mask_ptr[1] == 'X')))
7837 len = strnlen(mask_ptr, (res->len_value+3)/4);
7839 printf("invalid input\n");
7842 for (i = 0; i < len; i++) {
7844 if (isxdigit(c) == 0) {
7845 /* invalid characters. */
7846 printf("invalid input\n");
7849 val = xdigit2val(c);
7850 hex |= (uint8_t)(val & 0x8) >> 3;
7851 hex |= (uint8_t)(val & 0x4) >> 1;
7852 hex |= (uint8_t)(val & 0x2) << 1;
7853 hex |= (uint8_t)(val & 0x1) << 3;
7856 filter.mask[j] = byte;
7857 printf("mask[%d]:%02x ", j, filter.mask[j]);
7865 printf("call function rte_eth_dev_add_flex_filter: "
7866 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7867 res->index_value, res->queue_id,
7868 filter.len, filter.priority);
7869 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7870 &filter, res->queue_id);
7872 } else if (!strcmp(res->filter, "remove_flex_filter"))
7873 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7875 else if (!strcmp(res->filter, "get_flex_filter"))
7876 get_flex_filter(res->port_id, res->index_value);
7879 printf("flex filter setting error: (%s)\n", strerror(-ret));
7882 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7883 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7885 cmdline_parse_token_string_t cmd_flex_filter_len =
7886 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7888 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7889 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7891 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7892 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7894 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7895 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7897 cmdline_parse_token_string_t cmd_flex_filter_mask =
7898 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7900 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7901 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7903 cmdline_parse_token_string_t cmd_flex_filter_priority =
7904 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7905 priority, "priority");
7906 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7907 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7908 priority_value, UINT8);
7909 cmdline_parse_token_string_t cmd_flex_filter_queue =
7910 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7912 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7913 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7915 cmdline_parse_token_string_t cmd_flex_filter_index =
7916 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7918 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7919 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7920 index_value, UINT16);
7921 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7922 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7923 filter, "add_flex_filter");
7924 cmdline_parse_inst_t cmd_add_flex_filter = {
7925 .f = cmd_flex_filter_parsed,
7927 .help_str = "add a flex filter",
7929 (void *)&cmd_flex_filter_add_filter,
7930 (void *)&cmd_flex_filter_port_id,
7931 (void *)&cmd_flex_filter_len,
7932 (void *)&cmd_flex_filter_len_value,
7933 (void *)&cmd_flex_filter_bytes,
7934 (void *)&cmd_flex_filter_bytes_value,
7935 (void *)&cmd_flex_filter_mask,
7936 (void *)&cmd_flex_filter_mask_value,
7937 (void *)&cmd_flex_filter_priority,
7938 (void *)&cmd_flex_filter_priority_value,
7939 (void *)&cmd_flex_filter_queue,
7940 (void *)&cmd_flex_filter_queue_id,
7941 (void *)&cmd_flex_filter_index,
7942 (void *)&cmd_flex_filter_index_value,
7947 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7948 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7949 filter, "remove_flex_filter");
7950 cmdline_parse_inst_t cmd_remove_flex_filter = {
7951 .f = cmd_flex_filter_parsed,
7953 .help_str = "remove a flex filter",
7955 (void *)&cmd_flex_filter_remove_filter,
7956 (void *)&cmd_flex_filter_port_id,
7957 (void *)&cmd_flex_filter_index,
7958 (void *)&cmd_flex_filter_index_value,
7963 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7964 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7965 filter, "get_flex_filter");
7966 cmdline_parse_inst_t cmd_get_flex_filter = {
7967 .f = cmd_flex_filter_parsed,
7969 .help_str = "get a flex filter",
7971 (void *)&cmd_flex_filter_get_filter,
7972 (void *)&cmd_flex_filter_port_id,
7973 (void *)&cmd_flex_filter_index,
7974 (void *)&cmd_flex_filter_index_value,
7979 /* *** Filters Control *** */
7981 /* *** deal with ethertype filter *** */
7982 struct cmd_ethertype_filter_result {
7983 cmdline_fixed_string_t filter;
7985 cmdline_fixed_string_t ops;
7986 cmdline_fixed_string_t mac;
7987 struct ether_addr mac_addr;
7988 cmdline_fixed_string_t ethertype;
7989 uint16_t ethertype_value;
7990 cmdline_fixed_string_t drop;
7991 cmdline_fixed_string_t queue;
7995 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7996 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7997 filter, "ethertype_filter");
7998 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7999 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8001 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8002 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8004 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8005 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8006 mac, "mac_addr#mac_ignr");
8007 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8008 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8010 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8011 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8012 ethertype, "ethertype");
8013 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8014 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8015 ethertype_value, UINT16);
8016 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8017 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8019 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8020 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8022 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8023 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8027 cmd_ethertype_filter_parsed(void *parsed_result,
8028 __attribute__((unused)) struct cmdline *cl,
8029 __attribute__((unused)) void *data)
8031 struct cmd_ethertype_filter_result *res = parsed_result;
8032 struct rte_eth_ethertype_filter filter;
8035 ret = rte_eth_dev_filter_supported(res->port_id,
8036 RTE_ETH_FILTER_ETHERTYPE);
8038 printf("ethertype filter is not supported on port %u.\n",
8043 memset(&filter, 0, sizeof(filter));
8044 if (!strcmp(res->mac, "mac_addr")) {
8045 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8046 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8047 sizeof(struct ether_addr));
8049 if (!strcmp(res->drop, "drop"))
8050 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8051 filter.ether_type = res->ethertype_value;
8052 filter.queue = res->queue_id;
8054 if (!strcmp(res->ops, "add"))
8055 ret = rte_eth_dev_filter_ctrl(res->port_id,
8056 RTE_ETH_FILTER_ETHERTYPE,
8060 ret = rte_eth_dev_filter_ctrl(res->port_id,
8061 RTE_ETH_FILTER_ETHERTYPE,
8062 RTE_ETH_FILTER_DELETE,
8065 printf("ethertype filter programming error: (%s)\n",
8069 cmdline_parse_inst_t cmd_ethertype_filter = {
8070 .f = cmd_ethertype_filter_parsed,
8072 .help_str = "add or delete an ethertype filter entry",
8074 (void *)&cmd_ethertype_filter_filter,
8075 (void *)&cmd_ethertype_filter_port_id,
8076 (void *)&cmd_ethertype_filter_ops,
8077 (void *)&cmd_ethertype_filter_mac,
8078 (void *)&cmd_ethertype_filter_mac_addr,
8079 (void *)&cmd_ethertype_filter_ethertype,
8080 (void *)&cmd_ethertype_filter_ethertype_value,
8081 (void *)&cmd_ethertype_filter_drop,
8082 (void *)&cmd_ethertype_filter_queue,
8083 (void *)&cmd_ethertype_filter_queue_id,
8088 /* *** deal with flow director filter *** */
8089 struct cmd_flow_director_result {
8090 cmdline_fixed_string_t flow_director_filter;
8092 cmdline_fixed_string_t ops;
8093 cmdline_fixed_string_t flow;
8094 cmdline_fixed_string_t flow_type;
8095 cmdline_fixed_string_t src;
8096 cmdline_ipaddr_t ip_src;
8098 cmdline_fixed_string_t dst;
8099 cmdline_ipaddr_t ip_dst;
8101 cmdline_fixed_string_t verify_tag;
8102 uint32_t verify_tag_value;
8103 cmdline_fixed_string_t flexbytes;
8104 cmdline_fixed_string_t flexbytes_value;
8105 cmdline_fixed_string_t drop;
8106 cmdline_fixed_string_t queue;
8108 cmdline_fixed_string_t fd_id;
8109 uint32_t fd_id_value;
8113 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8116 const char *p, *p0 = q_arg;
8118 unsigned long int_fld;
8119 char *str_fld[max_num];
8124 p = strchr(p0, '(');
8128 p0 = strchr(p, ')');
8133 if (size >= sizeof(s))
8136 snprintf(s, sizeof(s), "%.*s", size, p);
8137 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8138 if (ret < 0 || ret > max_num)
8140 for (i = 0; i < ret; i++) {
8142 int_fld = strtoul(str_fld[i], &end, 0);
8143 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8145 flexbytes[i] = (uint8_t)int_fld;
8150 static enum rte_eth_flow_type
8151 str2flowtype(char *string)
8154 static const struct {
8156 enum rte_eth_flow_type type;
8157 } flowtype_str[] = {
8158 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8159 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8160 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8161 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8162 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8163 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8164 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8165 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8166 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8167 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8170 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8171 if (!strcmp(flowtype_str[i].str, string))
8172 return flowtype_str[i].type;
8174 return RTE_ETH_FLOW_TYPE_NONE;
8177 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8179 if ((ip_addr).family == AF_INET) \
8180 (ip) = (ip_addr).addr.ipv4.s_addr; \
8182 printf("invalid parameter.\n"); \
8187 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8189 if ((ip_addr).family == AF_INET6) \
8190 (void)rte_memcpy(&(ip), \
8191 &((ip_addr).addr.ipv6), \
8192 sizeof(struct in6_addr)); \
8194 printf("invalid parameter.\n"); \
8200 cmd_flow_director_filter_parsed(void *parsed_result,
8201 __attribute__((unused)) struct cmdline *cl,
8202 __attribute__((unused)) void *data)
8204 struct cmd_flow_director_result *res = parsed_result;
8205 struct rte_eth_fdir_filter entry;
8206 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8209 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8211 printf("flow director is not supported on port %u.\n",
8215 memset(flexbytes, 0, sizeof(flexbytes));
8216 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8217 ret = parse_flexbytes(res->flexbytes_value,
8219 RTE_ETH_FDIR_MAX_FLEXLEN);
8221 printf("error: Cannot parse flexbytes input.\n");
8225 entry.input.flow_type = str2flowtype(res->flow_type);
8226 switch (entry.input.flow_type) {
8227 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
8228 case RTE_ETH_FLOW_TYPE_UDPV4:
8229 case RTE_ETH_FLOW_TYPE_TCPV4:
8230 IPV4_ADDR_TO_UINT(res->ip_dst,
8231 entry.input.flow.ip4_flow.dst_ip);
8232 IPV4_ADDR_TO_UINT(res->ip_src,
8233 entry.input.flow.ip4_flow.src_ip);
8234 /* need convert to big endian. */
8235 entry.input.flow.udp4_flow.dst_port =
8236 rte_cpu_to_be_16(res->port_dst);
8237 entry.input.flow.udp4_flow.src_port =
8238 rte_cpu_to_be_16(res->port_src);
8240 case RTE_ETH_FLOW_TYPE_SCTPV4:
8241 IPV4_ADDR_TO_UINT(res->ip_dst,
8242 entry.input.flow.sctp4_flow.ip.dst_ip);
8243 IPV4_ADDR_TO_UINT(res->ip_src,
8244 entry.input.flow.sctp4_flow.ip.src_ip);
8245 /* need convert to big endian. */
8246 entry.input.flow.sctp4_flow.verify_tag =
8247 rte_cpu_to_be_32(res->verify_tag_value);
8249 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
8250 case RTE_ETH_FLOW_TYPE_UDPV6:
8251 case RTE_ETH_FLOW_TYPE_TCPV6:
8252 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8253 entry.input.flow.ipv6_flow.dst_ip);
8254 IPV6_ADDR_TO_ARRAY(res->ip_src,
8255 entry.input.flow.ipv6_flow.src_ip);
8256 /* need convert to big endian. */
8257 entry.input.flow.udp6_flow.dst_port =
8258 rte_cpu_to_be_16(res->port_dst);
8259 entry.input.flow.udp6_flow.src_port =
8260 rte_cpu_to_be_16(res->port_src);
8262 case RTE_ETH_FLOW_TYPE_SCTPV6:
8263 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8264 entry.input.flow.sctp6_flow.ip.dst_ip);
8265 IPV6_ADDR_TO_ARRAY(res->ip_src,
8266 entry.input.flow.sctp6_flow.ip.src_ip);
8267 /* need convert to big endian. */
8268 entry.input.flow.sctp6_flow.verify_tag =
8269 rte_cpu_to_be_32(res->verify_tag_value);
8272 printf("invalid parameter.\n");
8275 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8277 RTE_ETH_FDIR_MAX_FLEXLEN);
8279 entry.action.flex_off = 0; /*use 0 by default */
8280 if (!strcmp(res->drop, "drop"))
8281 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8283 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8284 /* set to report FD ID by default */
8285 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8286 entry.action.rx_queue = res->queue_id;
8287 entry.soft_id = res->fd_id_value;
8288 if (!strcmp(res->ops, "add"))
8289 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8290 RTE_ETH_FILTER_ADD, &entry);
8292 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8293 RTE_ETH_FILTER_DELETE, &entry);
8295 printf("flow director programming error: (%s)\n",
8299 cmdline_parse_token_string_t cmd_flow_director_filter =
8300 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8301 flow_director_filter, "flow_director_filter");
8302 cmdline_parse_token_num_t cmd_flow_director_port_id =
8303 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8305 cmdline_parse_token_string_t cmd_flow_director_ops =
8306 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8308 cmdline_parse_token_string_t cmd_flow_director_flow =
8309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8311 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8312 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8314 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8315 "ip6#ip6-frag#tcp6#udp6#sctp6");
8316 cmdline_parse_token_string_t cmd_flow_director_src =
8317 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8319 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8320 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8322 cmdline_parse_token_num_t cmd_flow_director_port_src =
8323 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8325 cmdline_parse_token_string_t cmd_flow_director_dst =
8326 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8328 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8329 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8331 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8332 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8334 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8335 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8336 verify_tag, "verify_tag");
8337 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8338 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8339 verify_tag_value, UINT32);
8340 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8342 flexbytes, "flexbytes");
8343 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8344 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8345 flexbytes_value, NULL);
8346 cmdline_parse_token_string_t cmd_flow_director_drop =
8347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8349 cmdline_parse_token_string_t cmd_flow_director_queue =
8350 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8352 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8353 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8355 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8358 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8359 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8360 fd_id_value, UINT32);
8362 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8363 .f = cmd_flow_director_filter_parsed,
8365 .help_str = "add or delete an ip flow director entry on NIC",
8367 (void *)&cmd_flow_director_filter,
8368 (void *)&cmd_flow_director_port_id,
8369 (void *)&cmd_flow_director_ops,
8370 (void *)&cmd_flow_director_flow,
8371 (void *)&cmd_flow_director_flow_type,
8372 (void *)&cmd_flow_director_src,
8373 (void *)&cmd_flow_director_ip_src,
8374 (void *)&cmd_flow_director_dst,
8375 (void *)&cmd_flow_director_ip_dst,
8376 (void *)&cmd_flow_director_flexbytes,
8377 (void *)&cmd_flow_director_flexbytes_value,
8378 (void *)&cmd_flow_director_drop,
8379 (void *)&cmd_flow_director_queue,
8380 (void *)&cmd_flow_director_queue_id,
8381 (void *)&cmd_flow_director_fd_id,
8382 (void *)&cmd_flow_director_fd_id_value,
8387 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8388 .f = cmd_flow_director_filter_parsed,
8390 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8392 (void *)&cmd_flow_director_filter,
8393 (void *)&cmd_flow_director_port_id,
8394 (void *)&cmd_flow_director_ops,
8395 (void *)&cmd_flow_director_flow,
8396 (void *)&cmd_flow_director_flow_type,
8397 (void *)&cmd_flow_director_src,
8398 (void *)&cmd_flow_director_ip_src,
8399 (void *)&cmd_flow_director_port_src,
8400 (void *)&cmd_flow_director_dst,
8401 (void *)&cmd_flow_director_ip_dst,
8402 (void *)&cmd_flow_director_port_dst,
8403 (void *)&cmd_flow_director_flexbytes,
8404 (void *)&cmd_flow_director_flexbytes_value,
8405 (void *)&cmd_flow_director_drop,
8406 (void *)&cmd_flow_director_queue,
8407 (void *)&cmd_flow_director_queue_id,
8408 (void *)&cmd_flow_director_fd_id,
8409 (void *)&cmd_flow_director_fd_id_value,
8414 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8415 .f = cmd_flow_director_filter_parsed,
8417 .help_str = "add or delete a sctp flow director entry on NIC",
8419 (void *)&cmd_flow_director_filter,
8420 (void *)&cmd_flow_director_port_id,
8421 (void *)&cmd_flow_director_ops,
8422 (void *)&cmd_flow_director_flow,
8423 (void *)&cmd_flow_director_flow_type,
8424 (void *)&cmd_flow_director_src,
8425 (void *)&cmd_flow_director_ip_src,
8426 (void *)&cmd_flow_director_dst,
8427 (void *)&cmd_flow_director_ip_dst,
8428 (void *)&cmd_flow_director_verify_tag,
8429 (void *)&cmd_flow_director_verify_tag_value,
8430 (void *)&cmd_flow_director_flexbytes,
8431 (void *)&cmd_flow_director_flexbytes_value,
8432 (void *)&cmd_flow_director_drop,
8433 (void *)&cmd_flow_director_queue,
8434 (void *)&cmd_flow_director_queue_id,
8435 (void *)&cmd_flow_director_fd_id,
8436 (void *)&cmd_flow_director_fd_id_value,
8441 struct cmd_flush_flow_director_result {
8442 cmdline_fixed_string_t flush_flow_director;
8446 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8447 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8448 flush_flow_director, "flush_flow_director");
8449 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8450 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8454 cmd_flush_flow_director_parsed(void *parsed_result,
8455 __attribute__((unused)) struct cmdline *cl,
8456 __attribute__((unused)) void *data)
8458 struct cmd_flow_director_result *res = parsed_result;
8461 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8463 printf("flow director is not supported on port %u.\n",
8468 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8469 RTE_ETH_FILTER_FLUSH, NULL);
8471 printf("flow director table flushing error: (%s)\n",
8475 cmdline_parse_inst_t cmd_flush_flow_director = {
8476 .f = cmd_flush_flow_director_parsed,
8478 .help_str = "flush all flow director entries of a device on NIC",
8480 (void *)&cmd_flush_flow_director_flush,
8481 (void *)&cmd_flush_flow_director_port_id,
8486 /* *** deal with flow director mask on flexible payload *** */
8487 struct cmd_flow_director_flex_mask_result {
8488 cmdline_fixed_string_t flow_director_flexmask;
8490 cmdline_fixed_string_t flow;
8491 cmdline_fixed_string_t flow_type;
8492 cmdline_fixed_string_t mask;
8496 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8497 __attribute__((unused)) struct cmdline *cl,
8498 __attribute__((unused)) void *data)
8500 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8501 struct rte_eth_fdir_flex_mask flex_mask;
8502 struct rte_port *port;
8503 enum rte_eth_flow_type i;
8506 if (res->port_id > nb_ports) {
8507 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8511 port = &ports[res->port_id];
8512 /** Check if the port is not started **/
8513 if (port->port_status != RTE_PORT_STOPPED) {
8514 printf("Please stop port %d first\n", res->port_id);
8518 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8519 ret = parse_flexbytes(res->mask,
8521 RTE_ETH_FDIR_MAX_FLEXLEN);
8523 printf("error: Cannot parse mask input.\n");
8526 if (!strcmp(res->flow_type, "all")) {
8527 for (i = RTE_ETH_FLOW_TYPE_UDPV4;
8528 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8530 flex_mask.flow_type = i;
8531 fdir_set_flex_mask(res->port_id, &flex_mask);
8533 cmd_reconfig_device_queue(res->port_id, 1, 0);
8536 flex_mask.flow_type = str2flowtype(res->flow_type);
8537 fdir_set_flex_mask(res->port_id, &flex_mask);
8538 cmd_reconfig_device_queue(res->port_id, 1, 1);
8541 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8542 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8543 flow_director_flexmask,
8544 "flow_director_flex_mask");
8545 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8546 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8548 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8549 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8551 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8552 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8554 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8555 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8556 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8560 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8561 .f = cmd_flow_director_flex_mask_parsed,
8563 .help_str = "set flow director's flex mask on NIC",
8565 (void *)&cmd_flow_director_flexmask,
8566 (void *)&cmd_flow_director_flexmask_port_id,
8567 (void *)&cmd_flow_director_flexmask_flow,
8568 (void *)&cmd_flow_director_flexmask_flow_type,
8569 (void *)&cmd_flow_director_flexmask_mask,
8574 /* *** deal with flow director flexible payload configuration *** */
8575 struct cmd_flow_director_flexpayload_result {
8576 cmdline_fixed_string_t flow_director_flexpayload;
8578 cmdline_fixed_string_t payload_layer;
8579 cmdline_fixed_string_t payload_cfg;
8583 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8586 const char *p, *p0 = q_arg;
8588 unsigned long int_fld;
8589 char *str_fld[max_num];
8594 p = strchr(p0, '(');
8598 p0 = strchr(p, ')');
8603 if (size >= sizeof(s))
8606 snprintf(s, sizeof(s), "%.*s", size, p);
8607 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8608 if (ret < 0 || ret > max_num)
8610 for (i = 0; i < ret; i++) {
8612 int_fld = strtoul(str_fld[i], &end, 0);
8613 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8615 offsets[i] = (uint16_t)int_fld;
8621 cmd_flow_director_flxpld_parsed(void *parsed_result,
8622 __attribute__((unused)) struct cmdline *cl,
8623 __attribute__((unused)) void *data)
8625 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8626 struct rte_eth_flex_payload_cfg flex_cfg;
8627 struct rte_port *port;
8630 if (res->port_id > nb_ports) {
8631 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8635 port = &ports[res->port_id];
8636 /** Check if the port is not started **/
8637 if (port->port_status != RTE_PORT_STOPPED) {
8638 printf("Please stop port %d first\n", res->port_id);
8642 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8644 if (!strcmp(res->payload_layer, "l2"))
8645 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8646 else if (!strcmp(res->payload_layer, "l3"))
8647 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8648 else if (!strcmp(res->payload_layer, "l4"))
8649 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8651 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8652 RTE_ETH_FDIR_MAX_FLEXLEN);
8654 printf("error: Cannot parse flex payload input.\n");
8658 fdir_set_flex_payload(res->port_id, &flex_cfg);
8659 cmd_reconfig_device_queue(res->port_id, 1, 1);
8662 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8663 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8664 flow_director_flexpayload,
8665 "flow_director_flex_payload");
8666 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8667 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8669 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8670 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8671 payload_layer, "l2#l3#l4");
8672 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8673 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8676 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8677 .f = cmd_flow_director_flxpld_parsed,
8679 .help_str = "set flow director's flex payload on NIC",
8681 (void *)&cmd_flow_director_flexpayload,
8682 (void *)&cmd_flow_director_flexpayload_port_id,
8683 (void *)&cmd_flow_director_flexpayload_payload_layer,
8684 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8689 /* *** Classification Filters Control *** */
8690 /* *** Get symmetric hash enable per port *** */
8691 struct cmd_get_sym_hash_ena_per_port_result {
8692 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8697 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8698 __rte_unused struct cmdline *cl,
8699 __rte_unused void *data)
8701 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8702 struct rte_eth_hash_filter_info info;
8705 if (rte_eth_dev_filter_supported(res->port_id,
8706 RTE_ETH_FILTER_HASH) < 0) {
8707 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8712 memset(&info, 0, sizeof(info));
8713 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8714 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8715 RTE_ETH_FILTER_GET, &info);
8718 printf("Cannot get symmetric hash enable per port "
8719 "on port %u\n", res->port_id);
8723 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8724 "enabled" : "disabled", res->port_id);
8727 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8728 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8729 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8730 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8731 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8734 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8735 .f = cmd_get_sym_hash_per_port_parsed,
8737 .help_str = "get_sym_hash_ena_per_port port_id",
8739 (void *)&cmd_get_sym_hash_ena_per_port_all,
8740 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8745 /* *** Set symmetric hash enable per port *** */
8746 struct cmd_set_sym_hash_ena_per_port_result {
8747 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8748 cmdline_fixed_string_t enable;
8753 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8754 __rte_unused struct cmdline *cl,
8755 __rte_unused void *data)
8757 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8758 struct rte_eth_hash_filter_info info;
8761 if (rte_eth_dev_filter_supported(res->port_id,
8762 RTE_ETH_FILTER_HASH) < 0) {
8763 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8768 memset(&info, 0, sizeof(info));
8769 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8770 if (!strcmp(res->enable, "enable"))
8771 info.info.enable = 1;
8772 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8773 RTE_ETH_FILTER_SET, &info);
8775 printf("Cannot set symmetric hash enable per port on "
8776 "port %u\n", res->port_id);
8779 printf("Symmetric hash has been set to %s on port %u\n",
8780 res->enable, res->port_id);
8783 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8784 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8785 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8786 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8787 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8789 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8790 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8791 enable, "enable#disable");
8793 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8794 .f = cmd_set_sym_hash_per_port_parsed,
8796 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8798 (void *)&cmd_set_sym_hash_ena_per_port_all,
8799 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8800 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8805 /* Get global config of hash function */
8806 struct cmd_get_hash_global_config_result {
8807 cmdline_fixed_string_t get_hash_global_config;
8812 flowtype_to_str(enum rte_eth_flow_type ftype)
8817 enum rte_eth_flow_type ftype;
8819 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8820 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8821 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8822 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8823 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8824 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8825 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8826 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8827 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8828 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8831 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8832 if (ftype_table[i].ftype == ftype)
8833 return ftype_table[i].str;
8840 cmd_get_hash_global_config_parsed(void *parsed_result,
8841 __rte_unused struct cmdline *cl,
8842 __rte_unused void *data)
8844 struct cmd_get_hash_global_config_result *res = parsed_result;
8845 struct rte_eth_hash_filter_info info;
8846 uint32_t idx, offset, i;
8850 if (rte_eth_dev_filter_supported(res->port_id,
8851 RTE_ETH_FILTER_HASH) < 0) {
8852 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8857 memset(&info, 0, sizeof(info));
8858 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8859 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8860 RTE_ETH_FILTER_GET, &info);
8862 printf("Cannot get hash global configurations by port %d\n",
8867 switch (info.info.global_conf.hash_func) {
8868 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8869 printf("Hash function is Toeplitz\n");
8871 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8872 printf("Hash function is Simple XOR\n");
8875 printf("Unknown hash function\n");
8879 for (i = 0; i < RTE_ETH_FLOW_TYPE_MAX; i++) {
8880 idx = i / UINT32_BIT;
8881 offset = i % UINT32_BIT;
8882 if (!(info.info.global_conf.valid_bit_mask[idx] &
8885 str = flowtype_to_str((enum rte_eth_flow_type)i);
8888 printf("Symmetric hash is %s globally for flow type %s "
8890 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8891 (1UL << offset)) ? "enabled" : "disabled"), str,
8896 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8897 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8898 get_hash_global_config, "get_hash_global_config");
8899 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8900 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8903 cmdline_parse_inst_t cmd_get_hash_global_config = {
8904 .f = cmd_get_hash_global_config_parsed,
8906 .help_str = "get_hash_global_config port_id",
8908 (void *)&cmd_get_hash_global_config_all,
8909 (void *)&cmd_get_hash_global_config_port_id,
8914 /* Set global config of hash function */
8915 struct cmd_set_hash_global_config_result {
8916 cmdline_fixed_string_t set_hash_global_config;
8918 cmdline_fixed_string_t hash_func;
8919 cmdline_fixed_string_t flow_type;
8920 cmdline_fixed_string_t enable;
8924 cmd_set_hash_global_config_parsed(void *parsed_result,
8925 __rte_unused struct cmdline *cl,
8926 __rte_unused void *data)
8928 struct cmd_set_hash_global_config_result *res = parsed_result;
8929 struct rte_eth_hash_filter_info info;
8930 uint32_t ftype, idx, offset;
8933 if (rte_eth_dev_filter_supported(res->port_id,
8934 RTE_ETH_FILTER_HASH) < 0) {
8935 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8939 memset(&info, 0, sizeof(info));
8940 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8941 if (!strcmp(res->hash_func, "toeplitz"))
8942 info.info.global_conf.hash_func =
8943 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8944 else if (!strcmp(res->hash_func, "simple_xor"))
8945 info.info.global_conf.hash_func =
8946 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8947 else if (!strcmp(res->hash_func, "default"))
8948 info.info.global_conf.hash_func =
8949 RTE_ETH_HASH_FUNCTION_DEFAULT;
8951 ftype = str2flowtype(res->flow_type);
8952 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8953 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8954 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8955 if (!strcmp(res->enable, "enable"))
8956 info.info.global_conf.sym_hash_enable_mask[idx] |=
8958 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8959 RTE_ETH_FILTER_SET, &info);
8961 printf("Cannot set global hash configurations by port %d\n",
8964 printf("Global hash configurations have been set "
8965 "succcessfully by port %d\n", res->port_id);
8968 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8969 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8970 set_hash_global_config, "set_hash_global_config");
8971 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8972 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8974 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8975 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8976 hash_func, "toeplitz#simple_xor#default");
8977 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8978 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8980 "ip4#ip4-frag#tcp4#udp4#sctp4#ip6#ip6-frag#tcp6#udp6#sctp6");
8981 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8982 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8983 enable, "enable#disable");
8985 cmdline_parse_inst_t cmd_set_hash_global_config = {
8986 .f = cmd_set_hash_global_config_parsed,
8988 .help_str = "set_hash_global_config port_id "
8989 "toeplitz|simple_xor|default "
8990 "ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6 "
8993 (void *)&cmd_set_hash_global_config_all,
8994 (void *)&cmd_set_hash_global_config_port_id,
8995 (void *)&cmd_set_hash_global_config_hash_func,
8996 (void *)&cmd_set_hash_global_config_flow_type,
8997 (void *)&cmd_set_hash_global_config_enable,
9002 /* ******************************************************************************** */
9004 /* list of instructions */
9005 cmdline_parse_ctx_t main_ctx[] = {
9006 (cmdline_parse_inst_t *)&cmd_help_brief,
9007 (cmdline_parse_inst_t *)&cmd_help_long,
9008 (cmdline_parse_inst_t *)&cmd_quit,
9009 (cmdline_parse_inst_t *)&cmd_showport,
9010 (cmdline_parse_inst_t *)&cmd_showportall,
9011 (cmdline_parse_inst_t *)&cmd_showcfg,
9012 (cmdline_parse_inst_t *)&cmd_start,
9013 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9014 (cmdline_parse_inst_t *)&cmd_set_link_up,
9015 (cmdline_parse_inst_t *)&cmd_set_link_down,
9016 (cmdline_parse_inst_t *)&cmd_reset,
9017 (cmdline_parse_inst_t *)&cmd_set_numbers,
9018 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9019 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9020 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9021 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9022 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9023 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9024 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9025 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9026 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9027 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9028 (cmdline_parse_inst_t *)&cmd_set_link_check,
9029 #ifdef RTE_NIC_BYPASS
9030 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9031 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9032 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9033 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9035 #ifdef RTE_LIBRTE_PMD_BOND
9036 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9037 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9038 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9039 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9040 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9041 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9042 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9043 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9044 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9046 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9047 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9048 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9049 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9050 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9051 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9052 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9053 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
9054 (cmdline_parse_inst_t *)&cmd_tx_cksum_show,
9055 (cmdline_parse_inst_t *)&cmd_tso_set,
9056 (cmdline_parse_inst_t *)&cmd_tso_show,
9057 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9058 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9059 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9060 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9061 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9062 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9063 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9064 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9065 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9066 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9067 (cmdline_parse_inst_t *)&cmd_config_dcb,
9068 (cmdline_parse_inst_t *)&cmd_read_reg,
9069 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9070 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9071 (cmdline_parse_inst_t *)&cmd_write_reg,
9072 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9073 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9074 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9075 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
9076 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
9077 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
9078 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
9079 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
9080 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
9081 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
9082 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
9083 (cmdline_parse_inst_t *)&cmd_stop,
9084 (cmdline_parse_inst_t *)&cmd_mac_addr,
9085 (cmdline_parse_inst_t *)&cmd_set_qmap,
9086 (cmdline_parse_inst_t *)&cmd_operate_port,
9087 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9088 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9089 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9090 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9091 (cmdline_parse_inst_t *)&cmd_config_mtu,
9092 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9093 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9094 (cmdline_parse_inst_t *)&cmd_config_rss,
9095 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9096 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9097 (cmdline_parse_inst_t *)&cmd_showport_reta,
9098 (cmdline_parse_inst_t *)&cmd_config_burst,
9099 (cmdline_parse_inst_t *)&cmd_config_thresh,
9100 (cmdline_parse_inst_t *)&cmd_config_threshold,
9101 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9102 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9103 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9104 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9105 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9106 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9107 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9108 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9109 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9110 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9111 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9112 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9113 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9114 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9115 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9116 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9117 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9118 (cmdline_parse_inst_t *)&cmd_dump,
9119 (cmdline_parse_inst_t *)&cmd_dump_one,
9120 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9121 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
9122 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
9123 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
9124 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
9125 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
9126 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
9127 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
9128 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
9129 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
9130 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
9131 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
9132 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
9133 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9134 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9135 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9136 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9137 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9138 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9139 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9140 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9141 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9142 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9146 /* prompt function, called from main on MASTER lcore */
9152 /* initialize non-constant commands */
9153 cmd_set_fwd_mode_init();
9155 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9159 cmdline_interact(cl);
9160 cmdline_stdin_exit(cl);
9164 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9166 if (id < nb_ports) {
9167 /* check if need_reconfig has been set to 1 */
9168 if (ports[id].need_reconfig == 0)
9169 ports[id].need_reconfig = dev;
9170 /* check if need_reconfig_queues has been set to 1 */
9171 if (ports[id].need_reconfig_queues == 0)
9172 ports[id].need_reconfig_queues = queue;
9176 for (pid = 0; pid < nb_ports; pid++) {
9177 /* check if need_reconfig has been set to 1 */
9178 if (ports[pid].need_reconfig == 0)
9179 ports[pid].need_reconfig = dev;
9180 /* check if need_reconfig_queues has been set to 1 */
9181 if (ports[pid].need_reconfig_queues == 0)
9182 ports[pid].need_reconfig_queues = queue;
9187 #ifdef RTE_NIC_BYPASS
9189 bypass_is_supported(portid_t port_id)
9191 struct rte_port *port;
9192 struct rte_pci_id *pci_id;
9194 if (port_id >= nb_ports) {
9195 printf("\tPort id must be less than %d.\n", nb_ports);
9199 /* Get the device id. */
9200 port = &ports[port_id];
9201 pci_id = &port->dev_info.pci_dev->id;
9203 /* Check if NIC supports bypass. */
9204 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9208 printf("\tBypass not supported for port_id = %d.\n", port_id);