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>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
77 #include <rte_eth_ctrl.h>
79 #include <cmdline_rdline.h>
80 #include <cmdline_parse.h>
81 #include <cmdline_parse_num.h>
82 #include <cmdline_parse_string.h>
83 #include <cmdline_parse_ipaddr.h>
84 #include <cmdline_parse_etheraddr.h>
85 #include <cmdline_socket.h>
87 #include <rte_pci_dev_ids.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
94 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
97 uint8_t bypass_is_supported(portid_t port_id);
100 /* *** Help command with introduction. *** */
101 struct cmd_help_brief_result {
102 cmdline_fixed_string_t help;
105 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
107 __attribute__((unused)) void *data)
112 "Help is available for the following sections:\n\n"
113 " help control : Start and stop forwarding.\n"
114 " help display : Displaying port, stats and config "
116 " help config : Configuration information.\n"
117 " help ports : Configuring ports.\n"
118 " help registers : Reading and setting port registers.\n"
119 " help filters : Filters configuration help.\n"
120 " help all : All of the above sections.\n\n"
125 cmdline_parse_token_string_t cmd_help_brief_help =
126 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
128 cmdline_parse_inst_t cmd_help_brief = {
129 .f = cmd_help_brief_parsed,
131 .help_str = "show help",
133 (void *)&cmd_help_brief_help,
138 /* *** Help command with help sections. *** */
139 struct cmd_help_long_result {
140 cmdline_fixed_string_t help;
141 cmdline_fixed_string_t section;
144 static void cmd_help_long_parsed(void *parsed_result,
146 __attribute__((unused)) void *data)
149 struct cmd_help_long_result *res = parsed_result;
151 if (!strcmp(res->section, "all"))
154 if (show_all || !strcmp(res->section, "control")) {
159 "Control forwarding:\n"
160 "-------------------\n\n"
163 " Start packet forwarding with current configuration.\n\n"
166 " Start packet forwarding with current config"
167 " after sending one burst of packets.\n\n"
170 " Stop packet forwarding, and display accumulated"
174 " Quit to prompt.\n\n"
178 if (show_all || !strcmp(res->section, "display")) {
186 "show port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
187 " Display information for port_id, or all.\n\n"
189 "show port X rss reta (size) (mask0,mask1,...)\n"
190 " Display the rss redirection table entry indicated"
191 " by masks on port X. size is used to indicate the"
192 " hardware supported reta size\n\n"
194 "show port rss-hash [key]\n"
195 " Display the RSS hash functions and RSS hash key"
198 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
199 " Clear information for port_id, or all.\n\n"
201 "show config (rxtx|cores|fwd)\n"
202 " Display the given configuration.\n\n"
204 "read rxd (port_id) (queue_id) (rxd_id)\n"
205 " Display an RX descriptor of a port RX queue.\n\n"
207 "read txd (port_id) (queue_id) (txd_id)\n"
208 " Display a TX descriptor of a port TX queue.\n\n"
212 if (show_all || !strcmp(res->section, "config")) {
218 "Configuration changes only become active when"
219 " forwarding is started/restarted.\n\n"
222 " Reset forwarding to the default configuration.\n\n"
224 "set verbose (level)\n"
225 " Set the debug verbosity level X.\n\n"
228 " Set number of ports.\n\n"
231 " Set number of cores.\n\n"
233 "set coremask (mask)\n"
234 " Set the forwarding cores hexadecimal mask.\n\n"
236 "set portmask (mask)\n"
237 " Set the forwarding ports hexadecimal mask.\n\n"
240 " Set number of packets per burst.\n\n"
242 "set burst tx delay (microseconds) retry (num)\n"
243 " Set the transmit delay time and number of retries"
244 " in mac_retry forwarding mode.\n\n"
246 "set txpkts (x[,y]*)\n"
247 " Set the length of each segment of TXONLY"
250 "set corelist (x[,y]*)\n"
251 " Set the list of forwarding cores.\n\n"
253 "set portlist (x[,y]*)\n"
254 " Set the list of forwarding ports.\n\n"
256 "vlan set strip (on|off) (port_id)\n"
257 " Set the VLAN strip on a port.\n\n"
259 "vlan set stripq (on|off) (port_id,queue_id)\n"
260 " Set the VLAN strip for a queue on a port.\n\n"
262 "vlan set filter (on|off) (port_id)\n"
263 " Set the VLAN filter on a port.\n\n"
265 "vlan set qinq (on|off) (port_id)\n"
266 " Set the VLAN QinQ (extended queue in queue)"
269 "vlan set tpid (value) (port_id)\n"
270 " Set the outer VLAN TPID for Packet Filtering on"
273 "rx_vlan add (vlan_id|all) (port_id)\n"
274 " Add a vlan_id, or all identifiers, to the set"
275 " of VLAN identifiers filtered by port_id.\n\n"
277 "rx_vlan rm (vlan_id|all) (port_id)\n"
278 " Remove a vlan_id, or all identifiers, from the set"
279 " of VLAN identifiers filtered by port_id.\n\n"
281 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
282 " Add a vlan_id, to the set of VLAN identifiers"
283 "filtered for VF(s) from port_id.\n\n"
285 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
286 " Remove a vlan_id, to the set of VLAN identifiers"
287 "filtered for VF(s) from port_id.\n\n"
289 "rx_vlan set tpid (value) (port_id)\n"
290 " Set the outer VLAN TPID for Packet Filtering on"
293 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
294 "(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) (queue_id)\n"
295 " add a tunnel filter of a port.\n\n"
297 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
298 "(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) (queue_id)\n"
299 " remove a tunnel filter of a port.\n\n"
301 "rx_vxlan_port add (udp_port) (port_id)\n"
302 " Add an UDP port for VXLAN packet filter on a port\n\n"
304 "rx_vxlan_port rm (udp_port) (port_id)\n"
305 " Remove an UDP port for VXLAN packet filter on a port\n\n"
307 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
308 " Set hardware insertion of VLAN IDs (single or double VLAN "
309 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
311 "tx_vlan set pvid port_id vlan_id (on|off)\n"
312 " Set port based TX VLAN insertion.\n\n"
314 "tx_vlan reset (port_id)\n"
315 " Disable hardware insertion of a VLAN header in"
316 " packets sent on a port.\n\n"
318 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
319 " Select hardware or software calculation of the"
320 " checksum when transmitting a packet using the"
321 " csum forward engine.\n"
322 " ip|udp|tcp|sctp always concern the inner layer.\n"
323 " outer-ip concerns the outer IP layer in"
324 " case the packet is recognized as a tunnel packet by"
325 " the forward engine (vxlan, gre and ipip are supported)\n"
326 " Please check the NIC datasheet for HW limits.\n\n"
328 "csum parse-tunnel (on|off) (tx_port_id)\n"
329 " If disabled, treat tunnel packets as non-tunneled"
330 " packets (treat inner headers as payload). The port\n"
331 " argument is the port used for TX in csum forward"
334 "csum show (port_id)\n"
335 " Display tx checksum offload configuration\n\n"
337 "tso set (segsize) (portid)\n"
338 " Enable TCP Segmentation Offload in csum forward"
340 " Please check the NIC datasheet for HW limits.\n\n"
343 " Display the status of TCP Segmentation Offload.\n\n"
346 " Set packet forwarding mode.\n\n"
348 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
349 " Add a MAC address on port_id.\n\n"
351 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
352 " Remove a MAC address from port_id.\n\n"
354 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
355 " Add a MAC address for a VF on the port.\n\n"
357 "set port (port_id) uta (mac_address|all) (on|off)\n"
358 " Add/Remove a or all unicast hash filter(s)"
361 "set promisc (port_id|all) (on|off)\n"
362 " Set the promiscuous mode on port_id, or all.\n\n"
364 "set allmulti (port_id|all) (on|off)\n"
365 " Set the allmulti mode on port_id, or all.\n\n"
367 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
368 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
369 " (on|off) autoneg (on|off) (port_id)\n"
370 "set flow_ctrl rx (on|off) (portid)\n"
371 "set flow_ctrl tx (on|off) (portid)\n"
372 "set flow_ctrl high_water (high_water) (portid)\n"
373 "set flow_ctrl low_water (low_water) (portid)\n"
374 "set flow_ctrl pause_time (pause_time) (portid)\n"
375 "set flow_ctrl send_xon (send_xon) (portid)\n"
376 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
377 "set flow_ctrl autoneg (on|off) (port_id)\n"
378 " Set the link flow control parameter on a port.\n\n"
380 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
381 " (low_water) (pause_time) (priority) (port_id)\n"
382 " Set the priority flow control parameter on a"
385 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
386 " Set statistics mapping (qmapping 0..15) for RX/TX"
388 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
389 " on port 0 to mapping 5.\n\n"
391 "set port (port_id) vf (vf_id) rx|tx on|off\n"
392 " Enable/Disable a VF receive/tranmit from a port\n\n"
394 "set port (port_id) vf (vf_id) (mac_addr)"
395 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
396 " Add/Remove unicast or multicast MAC addr filter"
399 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
401 " AUPE:accepts untagged VLAN;"
402 "ROPE:accept unicast hash\n\n"
403 " BAM:accepts broadcast packets;"
404 "MPE:accepts all multicast packets\n\n"
405 " Enable/Disable a VF receive mode of a port\n\n"
407 "set port (port_id) queue (queue_id) rate (rate_num)\n"
408 " Set rate limit for a queue of a port\n\n"
410 "set port (port_id) vf (vf_id) rate (rate_num) "
411 "queue_mask (queue_mask_value)\n"
412 " Set rate limit for queues in VF of a port\n\n"
414 "set port (port_id) mirror-rule (rule_id)"
415 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
416 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
417 " Set pool or vlan type mirror rule on a port.\n"
418 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
419 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
422 "set port (port_id) mirror-rule (rule_id)"
423 " (uplink-mirror|downlink-mirror) dst-pool"
424 " (pool_id) (on|off)\n"
425 " Set uplink or downlink type mirror rule on a port.\n"
426 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
427 " 0 on' enable mirror income traffic to pool 0.\n\n"
429 "reset port (port_id) mirror-rule (rule_id)\n"
430 " Reset a mirror rule.\n\n"
432 "set flush_rx (on|off)\n"
433 " Flush (default) or don't flush RX streams before"
434 " forwarding. Mainly used with PCAP drivers.\n\n"
436 #ifdef RTE_NIC_BYPASS
437 "set bypass mode (normal|bypass|isolate) (port_id)\n"
438 " Set the bypass mode for the lowest port on bypass enabled"
441 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
442 "mode (normal|bypass|isolate) (port_id)\n"
443 " Set the event required to initiate specified bypass mode for"
444 " the lowest port on a bypass enabled NIC where:\n"
445 " timeout = enable bypass after watchdog timeout.\n"
446 " os_on = enable bypass when OS/board is powered on.\n"
447 " os_off = enable bypass when OS/board is powered off.\n"
448 " power_on = enable bypass when power supply is turned on.\n"
449 " power_off = enable bypass when power supply is turned off."
452 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
453 " Set the bypass watchdog timeout to 'n' seconds"
454 " where 0 = instant.\n\n"
456 "show bypass config (port_id)\n"
457 " Show the bypass configuration for a bypass enabled NIC"
458 " using the lowest port on the NIC.\n\n"
460 #ifdef RTE_LIBRTE_PMD_BOND
461 "create bonded device (mode) (socket)\n"
462 " Create a new bonded device with specific bonding mode and socket.\n\n"
464 "add bonding slave (slave_id) (port_id)\n"
465 " Add a slave device to a bonded device.\n\n"
467 "remove bonding slave (slave_id) (port_id)\n"
468 " Remove a slave device from a bonded device.\n\n"
470 "set bonding mode (value) (port_id)\n"
471 " Set the bonding mode on a bonded device.\n\n"
473 "set bonding primary (slave_id) (port_id)\n"
474 " Set the primary slave for a bonded device.\n\n"
476 "show bonding config (port_id)\n"
477 " Show the bonding config for port_id.\n\n"
479 "set bonding mac_addr (port_id) (address)\n"
480 " Set the MAC address of a bonded device.\n\n"
482 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
483 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
485 "set bonding mon_period (port_id) (value)\n"
486 " Set the bonding link status monitoring polling period in ms.\n\n"
488 "set link-up port (port_id)\n"
489 " Set link up for a port.\n\n"
491 "set link-down port (port_id)\n"
492 " Set link down for a port.\n\n"
494 , list_pkt_forwarding_modes()
498 if (show_all || !strcmp(res->section, "ports")) {
504 "----------------\n\n"
506 "port start (port_id|all)\n"
507 " Start all ports or port_id.\n\n"
509 "port stop (port_id|all)\n"
510 " Stop all ports or port_id.\n\n"
512 "port close (port_id|all)\n"
513 " Close all ports or port_id.\n\n"
515 "port attach (ident)\n"
516 " Attach physical or virtual dev by pci address or virtual device name\n\n"
518 "port detach (port_id)\n"
519 " Detach physical or virtual dev by port_id\n\n"
521 "port config (port_id|all)"
522 " speed (10|100|1000|10000|40000|auto)"
523 " duplex (half|full|auto)\n"
524 " Set speed and duplex for all ports or port_id\n\n"
526 "port config all (rxq|txq|rxd|txd) (value)\n"
527 " Set number for rxq/txq/rxd/txd.\n\n"
529 "port config all max-pkt-len (value)\n"
530 " Set the max packet length.\n\n"
532 "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
533 "hw-vlan-strip|hw-vlan-extend|drop-en)"
535 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
538 "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
539 " Set the RSS mode.\n\n"
541 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
542 " Set the RSS redirection table.\n\n"
544 "port config (port_id) dcb vt (on|off) (traffic_class)"
546 " Set the DCB mode.\n\n"
548 "port config all burst (value)\n"
549 " Set the number of packets per burst.\n\n"
551 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
553 " Set the ring prefetch/host/writeback threshold"
554 " for tx/rx queue.\n\n"
556 "port config all (txfreet|txrst|rxfreet) (value)\n"
557 " Set free threshold for rx/tx, or set"
558 " tx rs bit threshold.\n\n"
559 "port config mtu X value\n"
560 " Set the MTU of port X to a given value\n\n"
562 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
563 " Start/stop a rx/tx queue of port X. Only take effect"
564 " when port X is started\n"
568 if (show_all || !strcmp(res->section, "registers")) {
576 "read reg (port_id) (address)\n"
577 " Display value of a port register.\n\n"
579 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
580 " Display a port register bit field.\n\n"
582 "read regbit (port_id) (address) (bit_x)\n"
583 " Display a single port register bit.\n\n"
585 "write reg (port_id) (address) (value)\n"
586 " Set value of a port register.\n\n"
588 "write regfield (port_id) (address) (bit_x) (bit_y)"
590 " Set bit field of a port register.\n\n"
592 "write regbit (port_id) (address) (bit_x) (value)\n"
593 " Set single bit value of a port register.\n\n"
596 if (show_all || !strcmp(res->section, "filters")) {
604 "ethertype_filter (port_id) (add|del)"
605 " (mac_addr|mac_ignr) (mac_address) ethertype"
606 " (ether_type) (drop|fwd) queue (queue_id)\n"
607 " Add/Del an ethertype filter.\n\n"
609 "2tuple_filter (port_id) (add|del)"
610 " dst_port (dst_port_value) protocol (protocol_value)"
611 " mask (mask_value) tcp_flags (tcp_flags_value)"
612 " priority (prio_value) queue (queue_id)\n"
613 " Add/Del a 2tuple filter.\n\n"
615 "5tuple_filter (port_id) (add|del)"
616 " dst_ip (dst_address) src_ip (src_address)"
617 " dst_port (dst_port_value) src_port (src_port_value)"
618 " protocol (protocol_value)"
619 " mask (mask_value) tcp_flags (tcp_flags_value)"
620 " priority (prio_value) queue (queue_id)\n"
621 " Add/Del a 5tuple filter.\n\n"
623 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
624 " Add/Del syn filter.\n\n"
626 "flex_filter (port_id) (add|del) len (len_value)"
627 " bytes (bytes_value) mask (mask_value)"
628 " priority (prio_value) queue (queue_id)\n"
629 " Add/Del a flex filter.\n\n"
631 "flow_director_filter (port_id) (add|del|update)"
632 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
633 " src (src_ip_address) dst (dst_ip_address)"
634 " vlan (vlan_value) flexbytes (flexbytes_value)"
635 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
636 " Add/Del an IP type flow director filter.\n\n"
638 "flow_director_filter (port_id) (add|del|update)"
639 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
640 " src (src_ip_address) (src_port)"
641 " dst (dst_ip_address) (dst_port)"
642 " vlan (vlan_value) flexbytes (flexbytes_value)"
643 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
644 " Add/Del an UDP/TCP type flow director filter.\n\n"
646 "flow_director_filter (port_id) (add|del|update)"
647 " flow (ipv4-sctp|ipv6-sctp)"
648 " src (src_ip_address) (src_port)"
649 " dst (dst_ip_address) (dst_port)"
650 " tag (verification_tag) vlan (vlan_value)"
651 " flexbytes (flexbytes_value) (drop|fwd)"
652 " queue (queue_id) fd_id (fd_id_value)\n"
653 " Add/Del a SCTP type flow director filter.\n\n"
655 "flow_director_filter (port_id) (add|del|update)"
656 " flow l2_payload ether (ethertype)"
657 " flexbytes (flexbytes_value) (drop|fwd)"
658 " queue (queue_id) fd_id (fd_id_value)\n"
659 " Add/Del a l2 payload type flow director filter.\n\n"
661 "flush_flow_director (port_id)\n"
662 " Flush all flow director entries of a device.\n\n"
664 "flow_director_mask (port_id) vlan (vlan_value)"
665 " src_mask (ipv4_src) (ipv6_src) (src_port)"
666 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
667 " Set flow director mask.\n\n"
669 "flow_director_flex_mask (port_id)"
670 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
671 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
673 " Configure mask of flex payload.\n\n"
675 "flow_director_flex_payload (port_id)"
676 " (raw|l2|l3|l4) (config)\n"
677 " Configure flex payload selection.\n\n"
679 "get_sym_hash_ena_per_port (port_id)\n"
680 " get symmetric hash enable configuration per port.\n\n"
682 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
683 " set symmetric hash enable configuration per port"
684 " to enable or disable.\n\n"
686 "get_hash_global_config (port_id)\n"
687 " Get the global configurations of hash filters.\n\n"
689 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
690 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
691 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
692 " (enable|disable)\n"
693 " Set the global configurations of hash filters.\n\n"
698 cmdline_parse_token_string_t cmd_help_long_help =
699 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
701 cmdline_parse_token_string_t cmd_help_long_section =
702 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
703 "all#control#display#config#"
704 "ports#registers#filters");
706 cmdline_parse_inst_t cmd_help_long = {
707 .f = cmd_help_long_parsed,
709 .help_str = "show help",
711 (void *)&cmd_help_long_help,
712 (void *)&cmd_help_long_section,
718 /* *** start/stop/close all ports *** */
719 struct cmd_operate_port_result {
720 cmdline_fixed_string_t keyword;
721 cmdline_fixed_string_t name;
722 cmdline_fixed_string_t value;
725 static void cmd_operate_port_parsed(void *parsed_result,
726 __attribute__((unused)) struct cmdline *cl,
727 __attribute__((unused)) void *data)
729 struct cmd_operate_port_result *res = parsed_result;
731 if (!strcmp(res->name, "start"))
732 start_port(RTE_PORT_ALL);
733 else if (!strcmp(res->name, "stop"))
734 stop_port(RTE_PORT_ALL);
735 else if (!strcmp(res->name, "close"))
736 close_port(RTE_PORT_ALL);
738 printf("Unknown parameter\n");
741 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
742 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
744 cmdline_parse_token_string_t cmd_operate_port_all_port =
745 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
747 cmdline_parse_token_string_t cmd_operate_port_all_all =
748 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
750 cmdline_parse_inst_t cmd_operate_port = {
751 .f = cmd_operate_port_parsed,
753 .help_str = "port start|stop|close all: start/stop/close all ports",
755 (void *)&cmd_operate_port_all_cmd,
756 (void *)&cmd_operate_port_all_port,
757 (void *)&cmd_operate_port_all_all,
762 /* *** start/stop/close specific port *** */
763 struct cmd_operate_specific_port_result {
764 cmdline_fixed_string_t keyword;
765 cmdline_fixed_string_t name;
769 static void cmd_operate_specific_port_parsed(void *parsed_result,
770 __attribute__((unused)) struct cmdline *cl,
771 __attribute__((unused)) void *data)
773 struct cmd_operate_specific_port_result *res = parsed_result;
775 if (!strcmp(res->name, "start"))
776 start_port(res->value);
777 else if (!strcmp(res->name, "stop"))
778 stop_port(res->value);
779 else if (!strcmp(res->name, "close"))
780 close_port(res->value);
782 printf("Unknown parameter\n");
785 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
786 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
788 cmdline_parse_token_string_t cmd_operate_specific_port_port =
789 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
790 name, "start#stop#close");
791 cmdline_parse_token_num_t cmd_operate_specific_port_id =
792 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
795 cmdline_parse_inst_t cmd_operate_specific_port = {
796 .f = cmd_operate_specific_port_parsed,
798 .help_str = "port start|stop|close X: start/stop/close port X",
800 (void *)&cmd_operate_specific_port_cmd,
801 (void *)&cmd_operate_specific_port_port,
802 (void *)&cmd_operate_specific_port_id,
807 /* *** attach a specified port *** */
808 struct cmd_operate_attach_port_result {
809 cmdline_fixed_string_t port;
810 cmdline_fixed_string_t keyword;
811 cmdline_fixed_string_t identifier;
814 static void cmd_operate_attach_port_parsed(void *parsed_result,
815 __attribute__((unused)) struct cmdline *cl,
816 __attribute__((unused)) void *data)
818 struct cmd_operate_attach_port_result *res = parsed_result;
820 if (!strcmp(res->keyword, "attach"))
821 attach_port(res->identifier);
823 printf("Unknown parameter\n");
826 cmdline_parse_token_string_t cmd_operate_attach_port_port =
827 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
829 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
830 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
832 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
833 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
836 cmdline_parse_inst_t cmd_operate_attach_port = {
837 .f = cmd_operate_attach_port_parsed,
839 .help_str = "port attach identifier, "
840 "identifier: pci address or virtual dev name",
842 (void *)&cmd_operate_attach_port_port,
843 (void *)&cmd_operate_attach_port_keyword,
844 (void *)&cmd_operate_attach_port_identifier,
849 /* *** detach a specified port *** */
850 struct cmd_operate_detach_port_result {
851 cmdline_fixed_string_t port;
852 cmdline_fixed_string_t keyword;
856 static void cmd_operate_detach_port_parsed(void *parsed_result,
857 __attribute__((unused)) struct cmdline *cl,
858 __attribute__((unused)) void *data)
860 struct cmd_operate_detach_port_result *res = parsed_result;
862 if (!strcmp(res->keyword, "detach"))
863 detach_port(res->port_id);
865 printf("Unknown parameter\n");
868 cmdline_parse_token_string_t cmd_operate_detach_port_port =
869 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
871 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
872 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
874 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
875 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
878 cmdline_parse_inst_t cmd_operate_detach_port = {
879 .f = cmd_operate_detach_port_parsed,
881 .help_str = "port detach port_id",
883 (void *)&cmd_operate_detach_port_port,
884 (void *)&cmd_operate_detach_port_keyword,
885 (void *)&cmd_operate_detach_port_port_id,
890 /* *** configure speed for all ports *** */
891 struct cmd_config_speed_all {
892 cmdline_fixed_string_t port;
893 cmdline_fixed_string_t keyword;
894 cmdline_fixed_string_t all;
895 cmdline_fixed_string_t item1;
896 cmdline_fixed_string_t item2;
897 cmdline_fixed_string_t value1;
898 cmdline_fixed_string_t value2;
902 cmd_config_speed_all_parsed(void *parsed_result,
903 __attribute__((unused)) struct cmdline *cl,
904 __attribute__((unused)) void *data)
906 struct cmd_config_speed_all *res = parsed_result;
907 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
908 uint16_t link_duplex = 0;
911 if (!all_ports_stopped()) {
912 printf("Please stop all ports first\n");
916 if (!strcmp(res->value1, "10"))
917 link_speed = ETH_LINK_SPEED_10;
918 else if (!strcmp(res->value1, "100"))
919 link_speed = ETH_LINK_SPEED_100;
920 else if (!strcmp(res->value1, "1000"))
921 link_speed = ETH_LINK_SPEED_1000;
922 else if (!strcmp(res->value1, "10000"))
923 link_speed = ETH_LINK_SPEED_10G;
924 else if (!strcmp(res->value1, "40000"))
925 link_speed = ETH_LINK_SPEED_40G;
926 else if (!strcmp(res->value1, "auto"))
927 link_speed = ETH_LINK_SPEED_AUTONEG;
929 printf("Unknown parameter\n");
933 if (!strcmp(res->value2, "half"))
934 link_duplex = ETH_LINK_HALF_DUPLEX;
935 else if (!strcmp(res->value2, "full"))
936 link_duplex = ETH_LINK_FULL_DUPLEX;
937 else if (!strcmp(res->value2, "auto"))
938 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
940 printf("Unknown parameter\n");
944 FOREACH_PORT(pid, ports) {
945 ports[pid].dev_conf.link_speed = link_speed;
946 ports[pid].dev_conf.link_duplex = link_duplex;
949 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
952 cmdline_parse_token_string_t cmd_config_speed_all_port =
953 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
954 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
955 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
957 cmdline_parse_token_string_t cmd_config_speed_all_all =
958 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
959 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
960 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
961 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
962 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
963 "10#100#1000#10000#40000#auto");
964 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
965 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
966 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
967 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
970 cmdline_parse_inst_t cmd_config_speed_all = {
971 .f = cmd_config_speed_all_parsed,
973 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
976 (void *)&cmd_config_speed_all_port,
977 (void *)&cmd_config_speed_all_keyword,
978 (void *)&cmd_config_speed_all_all,
979 (void *)&cmd_config_speed_all_item1,
980 (void *)&cmd_config_speed_all_value1,
981 (void *)&cmd_config_speed_all_item2,
982 (void *)&cmd_config_speed_all_value2,
987 /* *** configure speed for specific port *** */
988 struct cmd_config_speed_specific {
989 cmdline_fixed_string_t port;
990 cmdline_fixed_string_t keyword;
992 cmdline_fixed_string_t item1;
993 cmdline_fixed_string_t item2;
994 cmdline_fixed_string_t value1;
995 cmdline_fixed_string_t value2;
999 cmd_config_speed_specific_parsed(void *parsed_result,
1000 __attribute__((unused)) struct cmdline *cl,
1001 __attribute__((unused)) void *data)
1003 struct cmd_config_speed_specific *res = parsed_result;
1004 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1005 uint16_t link_duplex = 0;
1007 if (!all_ports_stopped()) {
1008 printf("Please stop all ports first\n");
1012 if (port_id_is_invalid(res->id, ENABLED_WARN))
1015 if (!strcmp(res->value1, "10"))
1016 link_speed = ETH_LINK_SPEED_10;
1017 else if (!strcmp(res->value1, "100"))
1018 link_speed = ETH_LINK_SPEED_100;
1019 else if (!strcmp(res->value1, "1000"))
1020 link_speed = ETH_LINK_SPEED_1000;
1021 else if (!strcmp(res->value1, "10000"))
1022 link_speed = ETH_LINK_SPEED_10000;
1023 else if (!strcmp(res->value1, "40000"))
1024 link_speed = ETH_LINK_SPEED_40G;
1025 else if (!strcmp(res->value1, "auto"))
1026 link_speed = ETH_LINK_SPEED_AUTONEG;
1028 printf("Unknown parameter\n");
1032 if (!strcmp(res->value2, "half"))
1033 link_duplex = ETH_LINK_HALF_DUPLEX;
1034 else if (!strcmp(res->value2, "full"))
1035 link_duplex = ETH_LINK_FULL_DUPLEX;
1036 else if (!strcmp(res->value2, "auto"))
1037 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1039 printf("Unknown parameter\n");
1043 ports[res->id].dev_conf.link_speed = link_speed;
1044 ports[res->id].dev_conf.link_duplex = link_duplex;
1046 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1050 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1051 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1053 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1054 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1056 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1057 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1058 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1059 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1061 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1062 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1063 "10#100#1000#10000#40000#auto");
1064 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1065 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1067 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1068 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1071 cmdline_parse_inst_t cmd_config_speed_specific = {
1072 .f = cmd_config_speed_specific_parsed,
1074 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1077 (void *)&cmd_config_speed_specific_port,
1078 (void *)&cmd_config_speed_specific_keyword,
1079 (void *)&cmd_config_speed_specific_id,
1080 (void *)&cmd_config_speed_specific_item1,
1081 (void *)&cmd_config_speed_specific_value1,
1082 (void *)&cmd_config_speed_specific_item2,
1083 (void *)&cmd_config_speed_specific_value2,
1088 /* *** configure txq/rxq, txd/rxd *** */
1089 struct cmd_config_rx_tx {
1090 cmdline_fixed_string_t port;
1091 cmdline_fixed_string_t keyword;
1092 cmdline_fixed_string_t all;
1093 cmdline_fixed_string_t name;
1098 cmd_config_rx_tx_parsed(void *parsed_result,
1099 __attribute__((unused)) struct cmdline *cl,
1100 __attribute__((unused)) void *data)
1102 struct cmd_config_rx_tx *res = parsed_result;
1104 if (!all_ports_stopped()) {
1105 printf("Please stop all ports first\n");
1109 if (!strcmp(res->name, "rxq")) {
1110 if (res->value <= 0) {
1111 printf("rxq %d invalid - must be > 0\n", res->value);
1114 nb_rxq = res->value;
1116 else if (!strcmp(res->name, "txq")) {
1117 if (res->value <= 0) {
1118 printf("txq %d invalid - must be > 0\n", res->value);
1121 nb_txq = res->value;
1123 else if (!strcmp(res->name, "rxd")) {
1124 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1125 printf("rxd %d invalid - must be > 0 && <= %d\n",
1126 res->value, RTE_TEST_RX_DESC_MAX);
1129 nb_rxd = res->value;
1130 } else if (!strcmp(res->name, "txd")) {
1131 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1132 printf("txd %d invalid - must be > 0 && <= %d\n",
1133 res->value, RTE_TEST_TX_DESC_MAX);
1136 nb_txd = res->value;
1138 printf("Unknown parameter\n");
1144 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1147 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1148 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1149 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1151 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1152 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1153 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1154 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1156 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1157 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1159 cmdline_parse_inst_t cmd_config_rx_tx = {
1160 .f = cmd_config_rx_tx_parsed,
1162 .help_str = "port config all rxq|txq|rxd|txd value",
1164 (void *)&cmd_config_rx_tx_port,
1165 (void *)&cmd_config_rx_tx_keyword,
1166 (void *)&cmd_config_rx_tx_all,
1167 (void *)&cmd_config_rx_tx_name,
1168 (void *)&cmd_config_rx_tx_value,
1173 /* *** config max packet length *** */
1174 struct cmd_config_max_pkt_len_result {
1175 cmdline_fixed_string_t port;
1176 cmdline_fixed_string_t keyword;
1177 cmdline_fixed_string_t all;
1178 cmdline_fixed_string_t name;
1183 cmd_config_max_pkt_len_parsed(void *parsed_result,
1184 __attribute__((unused)) struct cmdline *cl,
1185 __attribute__((unused)) void *data)
1187 struct cmd_config_max_pkt_len_result *res = parsed_result;
1189 if (!all_ports_stopped()) {
1190 printf("Please stop all ports first\n");
1194 if (!strcmp(res->name, "max-pkt-len")) {
1195 if (res->value < ETHER_MIN_LEN) {
1196 printf("max-pkt-len can not be less than %d\n",
1200 if (res->value == rx_mode.max_rx_pkt_len)
1203 rx_mode.max_rx_pkt_len = res->value;
1204 if (res->value > ETHER_MAX_LEN)
1205 rx_mode.jumbo_frame = 1;
1207 rx_mode.jumbo_frame = 0;
1209 printf("Unknown parameter\n");
1215 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1218 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1219 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1221 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1222 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1224 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1225 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1227 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1228 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1230 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1231 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1234 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1235 .f = cmd_config_max_pkt_len_parsed,
1237 .help_str = "port config all max-pkt-len value",
1239 (void *)&cmd_config_max_pkt_len_port,
1240 (void *)&cmd_config_max_pkt_len_keyword,
1241 (void *)&cmd_config_max_pkt_len_all,
1242 (void *)&cmd_config_max_pkt_len_name,
1243 (void *)&cmd_config_max_pkt_len_value,
1248 /* *** configure port MTU *** */
1249 struct cmd_config_mtu_result {
1250 cmdline_fixed_string_t port;
1251 cmdline_fixed_string_t keyword;
1252 cmdline_fixed_string_t mtu;
1258 cmd_config_mtu_parsed(void *parsed_result,
1259 __attribute__((unused)) struct cmdline *cl,
1260 __attribute__((unused)) void *data)
1262 struct cmd_config_mtu_result *res = parsed_result;
1264 if (res->value < ETHER_MIN_LEN) {
1265 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1268 port_mtu_set(res->port_id, res->value);
1271 cmdline_parse_token_string_t cmd_config_mtu_port =
1272 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1274 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1275 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1277 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1278 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1280 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1281 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1282 cmdline_parse_token_num_t cmd_config_mtu_value =
1283 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1285 cmdline_parse_inst_t cmd_config_mtu = {
1286 .f = cmd_config_mtu_parsed,
1288 .help_str = "port config mtu value",
1290 (void *)&cmd_config_mtu_port,
1291 (void *)&cmd_config_mtu_keyword,
1292 (void *)&cmd_config_mtu_mtu,
1293 (void *)&cmd_config_mtu_port_id,
1294 (void *)&cmd_config_mtu_value,
1299 /* *** configure rx mode *** */
1300 struct cmd_config_rx_mode_flag {
1301 cmdline_fixed_string_t port;
1302 cmdline_fixed_string_t keyword;
1303 cmdline_fixed_string_t all;
1304 cmdline_fixed_string_t name;
1305 cmdline_fixed_string_t value;
1309 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1310 __attribute__((unused)) struct cmdline *cl,
1311 __attribute__((unused)) void *data)
1313 struct cmd_config_rx_mode_flag *res = parsed_result;
1315 if (!all_ports_stopped()) {
1316 printf("Please stop all ports first\n");
1320 if (!strcmp(res->name, "crc-strip")) {
1321 if (!strcmp(res->value, "on"))
1322 rx_mode.hw_strip_crc = 1;
1323 else if (!strcmp(res->value, "off"))
1324 rx_mode.hw_strip_crc = 0;
1326 printf("Unknown parameter\n");
1329 } else if (!strcmp(res->name, "rx-cksum")) {
1330 if (!strcmp(res->value, "on"))
1331 rx_mode.hw_ip_checksum = 1;
1332 else if (!strcmp(res->value, "off"))
1333 rx_mode.hw_ip_checksum = 0;
1335 printf("Unknown parameter\n");
1338 } else if (!strcmp(res->name, "hw-vlan")) {
1339 if (!strcmp(res->value, "on")) {
1340 rx_mode.hw_vlan_filter = 1;
1341 rx_mode.hw_vlan_strip = 1;
1343 else if (!strcmp(res->value, "off")) {
1344 rx_mode.hw_vlan_filter = 0;
1345 rx_mode.hw_vlan_strip = 0;
1348 printf("Unknown parameter\n");
1351 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1352 if (!strcmp(res->value, "on"))
1353 rx_mode.hw_vlan_filter = 1;
1354 else if (!strcmp(res->value, "off"))
1355 rx_mode.hw_vlan_filter = 0;
1357 printf("Unknown parameter\n");
1360 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1361 if (!strcmp(res->value, "on"))
1362 rx_mode.hw_vlan_strip = 1;
1363 else if (!strcmp(res->value, "off"))
1364 rx_mode.hw_vlan_strip = 0;
1366 printf("Unknown parameter\n");
1369 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1370 if (!strcmp(res->value, "on"))
1371 rx_mode.hw_vlan_extend = 1;
1372 else if (!strcmp(res->value, "off"))
1373 rx_mode.hw_vlan_extend = 0;
1375 printf("Unknown parameter\n");
1378 } else if (!strcmp(res->name, "drop-en")) {
1379 if (!strcmp(res->value, "on"))
1381 else if (!strcmp(res->value, "off"))
1384 printf("Unknown parameter\n");
1388 printf("Unknown parameter\n");
1394 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1397 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1398 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1399 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1400 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1402 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1403 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1404 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1406 "crc-strip#rx-cksum#hw-vlan#"
1407 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1408 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1409 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1412 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1413 .f = cmd_config_rx_mode_flag_parsed,
1415 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1416 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1418 (void *)&cmd_config_rx_mode_flag_port,
1419 (void *)&cmd_config_rx_mode_flag_keyword,
1420 (void *)&cmd_config_rx_mode_flag_all,
1421 (void *)&cmd_config_rx_mode_flag_name,
1422 (void *)&cmd_config_rx_mode_flag_value,
1427 /* *** configure rss *** */
1428 struct cmd_config_rss {
1429 cmdline_fixed_string_t port;
1430 cmdline_fixed_string_t keyword;
1431 cmdline_fixed_string_t all;
1432 cmdline_fixed_string_t name;
1433 cmdline_fixed_string_t value;
1437 cmd_config_rss_parsed(void *parsed_result,
1438 __attribute__((unused)) struct cmdline *cl,
1439 __attribute__((unused)) void *data)
1441 struct cmd_config_rss *res = parsed_result;
1442 struct rte_eth_rss_conf rss_conf;
1445 if (!strcmp(res->value, "all"))
1446 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1447 ETH_RSS_UDP | ETH_RSS_SCTP |
1449 else if (!strcmp(res->value, "ip"))
1450 rss_conf.rss_hf = ETH_RSS_IP;
1451 else if (!strcmp(res->value, "udp"))
1452 rss_conf.rss_hf = ETH_RSS_UDP;
1453 else if (!strcmp(res->value, "tcp"))
1454 rss_conf.rss_hf = ETH_RSS_TCP;
1455 else if (!strcmp(res->value, "sctp"))
1456 rss_conf.rss_hf = ETH_RSS_SCTP;
1457 else if (!strcmp(res->value, "ether"))
1458 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1459 else if (!strcmp(res->value, "none"))
1460 rss_conf.rss_hf = 0;
1462 printf("Unknown parameter\n");
1465 rss_conf.rss_key = NULL;
1466 for (i = 0; i < rte_eth_dev_count(); i++)
1467 rte_eth_dev_rss_hash_update(i, &rss_conf);
1470 cmdline_parse_token_string_t cmd_config_rss_port =
1471 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1472 cmdline_parse_token_string_t cmd_config_rss_keyword =
1473 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1474 cmdline_parse_token_string_t cmd_config_rss_all =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1476 cmdline_parse_token_string_t cmd_config_rss_name =
1477 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1478 cmdline_parse_token_string_t cmd_config_rss_value =
1479 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1480 "all#ip#tcp#udp#sctp#ether#none");
1482 cmdline_parse_inst_t cmd_config_rss = {
1483 .f = cmd_config_rss_parsed,
1485 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1487 (void *)&cmd_config_rss_port,
1488 (void *)&cmd_config_rss_keyword,
1489 (void *)&cmd_config_rss_all,
1490 (void *)&cmd_config_rss_name,
1491 (void *)&cmd_config_rss_value,
1496 /* *** configure rss hash key *** */
1497 struct cmd_config_rss_hash_key {
1498 cmdline_fixed_string_t port;
1499 cmdline_fixed_string_t config;
1501 cmdline_fixed_string_t rss_hash_key;
1502 cmdline_fixed_string_t key;
1505 #define RSS_HASH_KEY_LENGTH 40
1507 hexa_digit_to_value(char hexa_digit)
1509 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1510 return (uint8_t) (hexa_digit - '0');
1511 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1512 return (uint8_t) ((hexa_digit - 'a') + 10);
1513 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1514 return (uint8_t) ((hexa_digit - 'A') + 10);
1515 /* Invalid hexa digit */
1520 parse_and_check_key_hexa_digit(char *key, int idx)
1524 hexa_v = hexa_digit_to_value(key[idx]);
1526 printf("invalid key: character %c at position %d is not a "
1527 "valid hexa digit\n", key[idx], idx);
1532 cmd_config_rss_hash_key_parsed(void *parsed_result,
1533 __attribute__((unused)) struct cmdline *cl,
1534 __attribute__((unused)) void *data)
1536 struct cmd_config_rss_hash_key *res = parsed_result;
1537 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1542 /* Check the length of the RSS hash key */
1543 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1544 printf("key length: %d invalid - key must be a string of %d"
1545 "hexa-decimal numbers\n", (int) strlen(res->key),
1546 RSS_HASH_KEY_LENGTH * 2);
1549 /* Translate RSS hash key into binary representation */
1550 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1551 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1554 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1557 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1559 port_rss_hash_key_update(res->port_id, hash_key);
1562 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1564 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1565 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1567 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1568 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1569 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1571 rss_hash_key, "rss-hash-key");
1572 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1573 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1575 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1576 .f = cmd_config_rss_hash_key_parsed,
1578 .help_str = "port config X rss-hash-key 80 hexa digits",
1580 (void *)&cmd_config_rss_hash_key_port,
1581 (void *)&cmd_config_rss_hash_key_config,
1582 (void *)&cmd_config_rss_hash_key_port_id,
1583 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1584 (void *)&cmd_config_rss_hash_key_value,
1589 /* *** configure port rxq/txq start/stop *** */
1590 struct cmd_config_rxtx_queue {
1591 cmdline_fixed_string_t port;
1593 cmdline_fixed_string_t rxtxq;
1595 cmdline_fixed_string_t opname;
1599 cmd_config_rxtx_queue_parsed(void *parsed_result,
1600 __attribute__((unused)) struct cmdline *cl,
1601 __attribute__((unused)) void *data)
1603 struct cmd_config_rxtx_queue *res = parsed_result;
1608 if (test_done == 0) {
1609 printf("Please stop forwarding first\n");
1613 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1616 if (port_is_started(res->portid) != 1) {
1617 printf("Please start port %u first\n", res->portid);
1621 if (!strcmp(res->rxtxq, "rxq"))
1623 else if (!strcmp(res->rxtxq, "txq"))
1626 printf("Unknown parameter\n");
1630 if (isrx && rx_queue_id_is_invalid(res->qid))
1632 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1635 if (!strcmp(res->opname, "start"))
1637 else if (!strcmp(res->opname, "stop"))
1640 printf("Unknown parameter\n");
1644 if (isstart && isrx)
1645 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1646 else if (!isstart && isrx)
1647 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1648 else if (isstart && !isrx)
1649 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1651 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1653 if (ret == -ENOTSUP)
1654 printf("Function not supported in PMD driver\n");
1657 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1659 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1660 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1661 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1663 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1664 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1665 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1669 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1670 .f = cmd_config_rxtx_queue_parsed,
1672 .help_str = "port X rxq|txq ID start|stop",
1674 (void *)&cmd_config_speed_all_port,
1675 (void *)&cmd_config_rxtx_queue_portid,
1676 (void *)&cmd_config_rxtx_queue_rxtxq,
1677 (void *)&cmd_config_rxtx_queue_qid,
1678 (void *)&cmd_config_rxtx_queue_opname,
1683 /* *** Configure RSS RETA *** */
1684 struct cmd_config_rss_reta {
1685 cmdline_fixed_string_t port;
1686 cmdline_fixed_string_t keyword;
1688 cmdline_fixed_string_t name;
1689 cmdline_fixed_string_t list_name;
1690 cmdline_fixed_string_t list_of_items;
1694 parse_reta_config(const char *str,
1695 struct rte_eth_rss_reta_entry64 *reta_conf,
1696 uint16_t nb_entries)
1700 uint16_t hash_index, idx, shift;
1703 const char *p, *p0 = str;
1710 unsigned long int_fld[_NUM_FLD];
1711 char *str_fld[_NUM_FLD];
1713 while ((p = strchr(p0,'(')) != NULL) {
1715 if((p0 = strchr(p,')')) == NULL)
1719 if(size >= sizeof(s))
1722 snprintf(s, sizeof(s), "%.*s", size, p);
1723 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1725 for (i = 0; i < _NUM_FLD; i++) {
1727 int_fld[i] = strtoul(str_fld[i], &end, 0);
1728 if (errno != 0 || end == str_fld[i] ||
1733 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1734 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1736 if (hash_index >= nb_entries) {
1737 printf("Invalid RETA hash index=%d\n", hash_index);
1741 idx = hash_index / RTE_RETA_GROUP_SIZE;
1742 shift = hash_index % RTE_RETA_GROUP_SIZE;
1743 reta_conf[idx].mask |= (1ULL << shift);
1744 reta_conf[idx].reta[shift] = nb_queue;
1751 cmd_set_rss_reta_parsed(void *parsed_result,
1752 __attribute__((unused)) struct cmdline *cl,
1753 __attribute__((unused)) void *data)
1756 struct rte_eth_dev_info dev_info;
1757 struct rte_eth_rss_reta_entry64 reta_conf[8];
1758 struct cmd_config_rss_reta *res = parsed_result;
1760 memset(&dev_info, 0, sizeof(dev_info));
1761 rte_eth_dev_info_get(res->port_id, &dev_info);
1762 if (dev_info.reta_size == 0) {
1763 printf("Redirection table size is 0 which is "
1764 "invalid for RSS\n");
1767 printf("The reta size of port %d is %u\n",
1768 res->port_id, dev_info.reta_size);
1769 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1770 printf("Currently do not support more than %u entries of "
1771 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1775 memset(reta_conf, 0, sizeof(reta_conf));
1776 if (!strcmp(res->list_name, "reta")) {
1777 if (parse_reta_config(res->list_of_items, reta_conf,
1778 dev_info.reta_size)) {
1779 printf("Invalid RSS Redirection Table "
1780 "config entered\n");
1783 ret = rte_eth_dev_rss_reta_update(res->port_id,
1784 reta_conf, dev_info.reta_size);
1786 printf("Bad redirection table parameter, "
1787 "return code = %d \n", ret);
1791 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1792 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1793 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1795 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1796 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1797 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1798 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1799 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1801 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1802 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1804 cmdline_parse_inst_t cmd_config_rss_reta = {
1805 .f = cmd_set_rss_reta_parsed,
1807 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1809 (void *)&cmd_config_rss_reta_port,
1810 (void *)&cmd_config_rss_reta_keyword,
1811 (void *)&cmd_config_rss_reta_port_id,
1812 (void *)&cmd_config_rss_reta_name,
1813 (void *)&cmd_config_rss_reta_list_name,
1814 (void *)&cmd_config_rss_reta_list_of_items,
1819 /* *** SHOW PORT RETA INFO *** */
1820 struct cmd_showport_reta {
1821 cmdline_fixed_string_t show;
1822 cmdline_fixed_string_t port;
1824 cmdline_fixed_string_t rss;
1825 cmdline_fixed_string_t reta;
1827 cmdline_fixed_string_t list_of_items;
1831 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1832 uint16_t nb_entries,
1836 const char *p, *p0 = str;
1840 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1843 p = strchr(p0, '(');
1847 p0 = strchr(p, ')');
1851 if (size >= sizeof(s)) {
1852 printf("The string size exceeds the internal buffer size\n");
1855 snprintf(s, sizeof(s), "%.*s", size, p);
1856 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1857 if (ret <= 0 || ret != num) {
1858 printf("The bits of masks do not match the number of "
1859 "reta entries: %u\n", num);
1862 for (i = 0; i < ret; i++)
1863 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1869 cmd_showport_reta_parsed(void *parsed_result,
1870 __attribute__((unused)) struct cmdline *cl,
1871 __attribute__((unused)) void *data)
1873 struct cmd_showport_reta *res = parsed_result;
1874 struct rte_eth_rss_reta_entry64 reta_conf[8];
1875 struct rte_eth_dev_info dev_info;
1877 memset(&dev_info, 0, sizeof(dev_info));
1878 rte_eth_dev_info_get(res->port_id, &dev_info);
1879 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1880 res->size > ETH_RSS_RETA_SIZE_512) {
1881 printf("Invalid redirection table size: %u\n", res->size);
1885 memset(reta_conf, 0, sizeof(reta_conf));
1886 if (showport_parse_reta_config(reta_conf, res->size,
1887 res->list_of_items) < 0) {
1888 printf("Invalid string: %s for reta masks\n",
1889 res->list_of_items);
1892 port_rss_reta_info(res->port_id, reta_conf, res->size);
1895 cmdline_parse_token_string_t cmd_showport_reta_show =
1896 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1897 cmdline_parse_token_string_t cmd_showport_reta_port =
1898 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1899 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1900 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1901 cmdline_parse_token_string_t cmd_showport_reta_rss =
1902 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1903 cmdline_parse_token_string_t cmd_showport_reta_reta =
1904 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1905 cmdline_parse_token_num_t cmd_showport_reta_size =
1906 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1907 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1908 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1909 list_of_items, NULL);
1911 cmdline_parse_inst_t cmd_showport_reta = {
1912 .f = cmd_showport_reta_parsed,
1914 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1916 (void *)&cmd_showport_reta_show,
1917 (void *)&cmd_showport_reta_port,
1918 (void *)&cmd_showport_reta_port_id,
1919 (void *)&cmd_showport_reta_rss,
1920 (void *)&cmd_showport_reta_reta,
1921 (void *)&cmd_showport_reta_size,
1922 (void *)&cmd_showport_reta_list_of_items,
1927 /* *** Show RSS hash configuration *** */
1928 struct cmd_showport_rss_hash {
1929 cmdline_fixed_string_t show;
1930 cmdline_fixed_string_t port;
1932 cmdline_fixed_string_t rss_hash;
1933 cmdline_fixed_string_t key; /* optional argument */
1936 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1937 __attribute__((unused)) struct cmdline *cl,
1940 struct cmd_showport_rss_hash *res = parsed_result;
1942 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1945 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1946 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1947 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1948 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1949 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1950 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1951 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1952 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1954 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1955 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1957 cmdline_parse_inst_t cmd_showport_rss_hash = {
1958 .f = cmd_showport_rss_hash_parsed,
1960 .help_str = "show port X rss-hash (X = port number)\n",
1962 (void *)&cmd_showport_rss_hash_show,
1963 (void *)&cmd_showport_rss_hash_port,
1964 (void *)&cmd_showport_rss_hash_port_id,
1965 (void *)&cmd_showport_rss_hash_rss_hash,
1970 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1971 .f = cmd_showport_rss_hash_parsed,
1973 .help_str = "show port X rss-hash key (X = port number)\n",
1975 (void *)&cmd_showport_rss_hash_show,
1976 (void *)&cmd_showport_rss_hash_port,
1977 (void *)&cmd_showport_rss_hash_port_id,
1978 (void *)&cmd_showport_rss_hash_rss_hash,
1979 (void *)&cmd_showport_rss_hash_rss_key,
1984 /* *** Configure DCB *** */
1985 struct cmd_config_dcb {
1986 cmdline_fixed_string_t port;
1987 cmdline_fixed_string_t config;
1989 cmdline_fixed_string_t dcb;
1990 cmdline_fixed_string_t vt;
1991 cmdline_fixed_string_t vt_en;
1993 cmdline_fixed_string_t pfc;
1994 cmdline_fixed_string_t pfc_en;
1998 cmd_config_dcb_parsed(void *parsed_result,
1999 __attribute__((unused)) struct cmdline *cl,
2000 __attribute__((unused)) void *data)
2002 struct cmd_config_dcb *res = parsed_result;
2003 struct dcb_config dcb_conf;
2004 portid_t port_id = res->port_id;
2005 struct rte_port *port;
2007 port = &ports[port_id];
2008 /** Check if the port is not started **/
2009 if (port->port_status != RTE_PORT_STOPPED) {
2010 printf("Please stop port %d first\n",port_id);
2014 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
2015 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
2016 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
2020 /* DCB in VT mode */
2021 if (!strncmp(res->vt_en, "on",2))
2022 dcb_conf.dcb_mode = DCB_VT_ENABLED;
2024 dcb_conf.dcb_mode = DCB_ENABLED;
2026 if (!strncmp(res->pfc_en, "on",2)) {
2027 dcb_conf.pfc_en = 1;
2030 dcb_conf.pfc_en = 0;
2032 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
2033 printf("Cannot initialize network ports\n");
2037 cmd_reconfig_device_queue(port_id, 1, 1);
2040 cmdline_parse_token_string_t cmd_config_dcb_port =
2041 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2042 cmdline_parse_token_string_t cmd_config_dcb_config =
2043 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2044 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2045 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2046 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2047 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2048 cmdline_parse_token_string_t cmd_config_dcb_vt =
2049 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2050 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2051 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2052 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2053 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2054 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2055 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2056 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2059 cmdline_parse_inst_t cmd_config_dcb = {
2060 .f = cmd_config_dcb_parsed,
2062 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2064 (void *)&cmd_config_dcb_port,
2065 (void *)&cmd_config_dcb_config,
2066 (void *)&cmd_config_dcb_port_id,
2067 (void *)&cmd_config_dcb_dcb,
2068 (void *)&cmd_config_dcb_vt,
2069 (void *)&cmd_config_dcb_vt_en,
2070 (void *)&cmd_config_dcb_num_tcs,
2071 (void *)&cmd_config_dcb_pfc,
2072 (void *)&cmd_config_dcb_pfc_en,
2077 /* *** configure number of packets per burst *** */
2078 struct cmd_config_burst {
2079 cmdline_fixed_string_t port;
2080 cmdline_fixed_string_t keyword;
2081 cmdline_fixed_string_t all;
2082 cmdline_fixed_string_t name;
2087 cmd_config_burst_parsed(void *parsed_result,
2088 __attribute__((unused)) struct cmdline *cl,
2089 __attribute__((unused)) void *data)
2091 struct cmd_config_burst *res = parsed_result;
2093 if (!all_ports_stopped()) {
2094 printf("Please stop all ports first\n");
2098 if (!strcmp(res->name, "burst")) {
2099 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2100 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2103 nb_pkt_per_burst = res->value;
2105 printf("Unknown parameter\n");
2111 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2114 cmdline_parse_token_string_t cmd_config_burst_port =
2115 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2116 cmdline_parse_token_string_t cmd_config_burst_keyword =
2117 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2118 cmdline_parse_token_string_t cmd_config_burst_all =
2119 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2120 cmdline_parse_token_string_t cmd_config_burst_name =
2121 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2122 cmdline_parse_token_num_t cmd_config_burst_value =
2123 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2125 cmdline_parse_inst_t cmd_config_burst = {
2126 .f = cmd_config_burst_parsed,
2128 .help_str = "port config all burst value",
2130 (void *)&cmd_config_burst_port,
2131 (void *)&cmd_config_burst_keyword,
2132 (void *)&cmd_config_burst_all,
2133 (void *)&cmd_config_burst_name,
2134 (void *)&cmd_config_burst_value,
2139 /* *** configure rx/tx queues *** */
2140 struct cmd_config_thresh {
2141 cmdline_fixed_string_t port;
2142 cmdline_fixed_string_t keyword;
2143 cmdline_fixed_string_t all;
2144 cmdline_fixed_string_t name;
2149 cmd_config_thresh_parsed(void *parsed_result,
2150 __attribute__((unused)) struct cmdline *cl,
2151 __attribute__((unused)) void *data)
2153 struct cmd_config_thresh *res = parsed_result;
2155 if (!all_ports_stopped()) {
2156 printf("Please stop all ports first\n");
2160 if (!strcmp(res->name, "txpt"))
2161 tx_pthresh = res->value;
2162 else if(!strcmp(res->name, "txht"))
2163 tx_hthresh = res->value;
2164 else if(!strcmp(res->name, "txwt"))
2165 tx_wthresh = res->value;
2166 else if(!strcmp(res->name, "rxpt"))
2167 rx_pthresh = res->value;
2168 else if(!strcmp(res->name, "rxht"))
2169 rx_hthresh = res->value;
2170 else if(!strcmp(res->name, "rxwt"))
2171 rx_wthresh = res->value;
2173 printf("Unknown parameter\n");
2179 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2182 cmdline_parse_token_string_t cmd_config_thresh_port =
2183 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2184 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2185 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2186 cmdline_parse_token_string_t cmd_config_thresh_all =
2187 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2188 cmdline_parse_token_string_t cmd_config_thresh_name =
2189 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2190 "txpt#txht#txwt#rxpt#rxht#rxwt");
2191 cmdline_parse_token_num_t cmd_config_thresh_value =
2192 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2194 cmdline_parse_inst_t cmd_config_thresh = {
2195 .f = cmd_config_thresh_parsed,
2197 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2199 (void *)&cmd_config_thresh_port,
2200 (void *)&cmd_config_thresh_keyword,
2201 (void *)&cmd_config_thresh_all,
2202 (void *)&cmd_config_thresh_name,
2203 (void *)&cmd_config_thresh_value,
2208 /* *** configure free/rs threshold *** */
2209 struct cmd_config_threshold {
2210 cmdline_fixed_string_t port;
2211 cmdline_fixed_string_t keyword;
2212 cmdline_fixed_string_t all;
2213 cmdline_fixed_string_t name;
2218 cmd_config_threshold_parsed(void *parsed_result,
2219 __attribute__((unused)) struct cmdline *cl,
2220 __attribute__((unused)) void *data)
2222 struct cmd_config_threshold *res = parsed_result;
2224 if (!all_ports_stopped()) {
2225 printf("Please stop all ports first\n");
2229 if (!strcmp(res->name, "txfreet"))
2230 tx_free_thresh = res->value;
2231 else if (!strcmp(res->name, "txrst"))
2232 tx_rs_thresh = res->value;
2233 else if (!strcmp(res->name, "rxfreet"))
2234 rx_free_thresh = res->value;
2236 printf("Unknown parameter\n");
2242 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2245 cmdline_parse_token_string_t cmd_config_threshold_port =
2246 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2247 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2248 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2250 cmdline_parse_token_string_t cmd_config_threshold_all =
2251 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2252 cmdline_parse_token_string_t cmd_config_threshold_name =
2253 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2254 "txfreet#txrst#rxfreet");
2255 cmdline_parse_token_num_t cmd_config_threshold_value =
2256 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2258 cmdline_parse_inst_t cmd_config_threshold = {
2259 .f = cmd_config_threshold_parsed,
2261 .help_str = "port config all txfreet|txrst|rxfreet value",
2263 (void *)&cmd_config_threshold_port,
2264 (void *)&cmd_config_threshold_keyword,
2265 (void *)&cmd_config_threshold_all,
2266 (void *)&cmd_config_threshold_name,
2267 (void *)&cmd_config_threshold_value,
2273 struct cmd_stop_result {
2274 cmdline_fixed_string_t stop;
2277 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2278 __attribute__((unused)) struct cmdline *cl,
2279 __attribute__((unused)) void *data)
2281 stop_packet_forwarding();
2284 cmdline_parse_token_string_t cmd_stop_stop =
2285 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2287 cmdline_parse_inst_t cmd_stop = {
2288 .f = cmd_stop_parsed,
2290 .help_str = "stop - stop packet forwarding",
2292 (void *)&cmd_stop_stop,
2297 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2300 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2301 unsigned int *parsed_items, int check_unique_values)
2303 unsigned int nb_item;
2311 * First parse all items in the list and store their value.
2316 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2318 if ((c >= '0') && (c <= '9')) {
2319 value = (unsigned int) (value * 10 + (c - '0'));
2324 printf("character %c is not a decimal digit\n", c);
2328 printf("No valid value before comma\n");
2331 if (nb_item < max_items) {
2332 parsed_items[nb_item] = value;
2338 if (nb_item >= max_items) {
2339 printf("Number of %s = %u > %u (maximum items)\n",
2340 item_name, nb_item + 1, max_items);
2343 parsed_items[nb_item++] = value;
2344 if (! check_unique_values)
2348 * Then, check that all values in the list are differents.
2349 * No optimization here...
2351 for (i = 0; i < nb_item; i++) {
2352 for (j = i + 1; j < nb_item; j++) {
2353 if (parsed_items[j] == parsed_items[i]) {
2354 printf("duplicated %s %u at index %u and %u\n",
2355 item_name, parsed_items[i], i, j);
2363 struct cmd_set_list_result {
2364 cmdline_fixed_string_t cmd_keyword;
2365 cmdline_fixed_string_t list_name;
2366 cmdline_fixed_string_t list_of_items;
2369 static void cmd_set_list_parsed(void *parsed_result,
2370 __attribute__((unused)) struct cmdline *cl,
2371 __attribute__((unused)) void *data)
2373 struct cmd_set_list_result *res;
2375 unsigned int lcorelist[RTE_MAX_LCORE];
2376 unsigned int portlist[RTE_MAX_ETHPORTS];
2378 unsigned int nb_item;
2380 if (test_done == 0) {
2381 printf("Please stop forwarding first\n");
2385 res = parsed_result;
2386 if (!strcmp(res->list_name, "corelist")) {
2387 nb_item = parse_item_list(res->list_of_items, "core",
2389 parsed_items.lcorelist, 1);
2391 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2394 if (!strcmp(res->list_name, "portlist")) {
2395 nb_item = parse_item_list(res->list_of_items, "port",
2397 parsed_items.portlist, 1);
2399 set_fwd_ports_list(parsed_items.portlist, nb_item);
2403 cmdline_parse_token_string_t cmd_set_list_keyword =
2404 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2406 cmdline_parse_token_string_t cmd_set_list_name =
2407 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2408 "corelist#portlist");
2409 cmdline_parse_token_string_t cmd_set_list_of_items =
2410 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2413 cmdline_parse_inst_t cmd_set_fwd_list = {
2414 .f = cmd_set_list_parsed,
2416 .help_str = "set corelist|portlist x[,y]*",
2418 (void *)&cmd_set_list_keyword,
2419 (void *)&cmd_set_list_name,
2420 (void *)&cmd_set_list_of_items,
2425 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2427 struct cmd_setmask_result {
2428 cmdline_fixed_string_t set;
2429 cmdline_fixed_string_t mask;
2433 static void cmd_set_mask_parsed(void *parsed_result,
2434 __attribute__((unused)) struct cmdline *cl,
2435 __attribute__((unused)) void *data)
2437 struct cmd_setmask_result *res = parsed_result;
2439 if (test_done == 0) {
2440 printf("Please stop forwarding first\n");
2443 if (!strcmp(res->mask, "coremask"))
2444 set_fwd_lcores_mask(res->hexavalue);
2445 else if (!strcmp(res->mask, "portmask"))
2446 set_fwd_ports_mask(res->hexavalue);
2449 cmdline_parse_token_string_t cmd_setmask_set =
2450 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2451 cmdline_parse_token_string_t cmd_setmask_mask =
2452 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2453 "coremask#portmask");
2454 cmdline_parse_token_num_t cmd_setmask_value =
2455 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2457 cmdline_parse_inst_t cmd_set_fwd_mask = {
2458 .f = cmd_set_mask_parsed,
2460 .help_str = "set coremask|portmask hexadecimal value",
2462 (void *)&cmd_setmask_set,
2463 (void *)&cmd_setmask_mask,
2464 (void *)&cmd_setmask_value,
2470 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2472 struct cmd_set_result {
2473 cmdline_fixed_string_t set;
2474 cmdline_fixed_string_t what;
2478 static void cmd_set_parsed(void *parsed_result,
2479 __attribute__((unused)) struct cmdline *cl,
2480 __attribute__((unused)) void *data)
2482 struct cmd_set_result *res = parsed_result;
2483 if (!strcmp(res->what, "nbport"))
2484 set_fwd_ports_number(res->value);
2485 else if (!strcmp(res->what, "nbcore"))
2486 set_fwd_lcores_number(res->value);
2487 else if (!strcmp(res->what, "burst"))
2488 set_nb_pkt_per_burst(res->value);
2489 else if (!strcmp(res->what, "verbose"))
2490 set_verbose_level(res->value);
2493 cmdline_parse_token_string_t cmd_set_set =
2494 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2495 cmdline_parse_token_string_t cmd_set_what =
2496 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2497 "nbport#nbcore#burst#verbose");
2498 cmdline_parse_token_num_t cmd_set_value =
2499 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2501 cmdline_parse_inst_t cmd_set_numbers = {
2502 .f = cmd_set_parsed,
2504 .help_str = "set nbport|nbcore|burst|verbose value",
2506 (void *)&cmd_set_set,
2507 (void *)&cmd_set_what,
2508 (void *)&cmd_set_value,
2513 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2515 struct cmd_set_txpkts_result {
2516 cmdline_fixed_string_t cmd_keyword;
2517 cmdline_fixed_string_t txpkts;
2518 cmdline_fixed_string_t seg_lengths;
2522 cmd_set_txpkts_parsed(void *parsed_result,
2523 __attribute__((unused)) struct cmdline *cl,
2524 __attribute__((unused)) void *data)
2526 struct cmd_set_txpkts_result *res;
2527 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2528 unsigned int nb_segs;
2530 res = parsed_result;
2531 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2532 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2534 set_tx_pkt_segments(seg_lengths, nb_segs);
2537 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2538 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2539 cmd_keyword, "set");
2540 cmdline_parse_token_string_t cmd_set_txpkts_name =
2541 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2543 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2544 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2547 cmdline_parse_inst_t cmd_set_txpkts = {
2548 .f = cmd_set_txpkts_parsed,
2550 .help_str = "set txpkts x[,y]*",
2552 (void *)&cmd_set_txpkts_keyword,
2553 (void *)&cmd_set_txpkts_name,
2554 (void *)&cmd_set_txpkts_lengths,
2559 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2560 struct cmd_rx_vlan_filter_all_result {
2561 cmdline_fixed_string_t rx_vlan;
2562 cmdline_fixed_string_t what;
2563 cmdline_fixed_string_t all;
2568 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2569 __attribute__((unused)) struct cmdline *cl,
2570 __attribute__((unused)) void *data)
2572 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2574 if (!strcmp(res->what, "add"))
2575 rx_vlan_all_filter_set(res->port_id, 1);
2577 rx_vlan_all_filter_set(res->port_id, 0);
2580 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2581 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2582 rx_vlan, "rx_vlan");
2583 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2584 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2586 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2587 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2589 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2590 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2593 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2594 .f = cmd_rx_vlan_filter_all_parsed,
2596 .help_str = "add/remove all identifiers to/from the set of VLAN "
2597 "Identifiers filtered by a port",
2599 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2600 (void *)&cmd_rx_vlan_filter_all_what,
2601 (void *)&cmd_rx_vlan_filter_all_all,
2602 (void *)&cmd_rx_vlan_filter_all_portid,
2607 /* *** VLAN OFFLOAD SET ON A PORT *** */
2608 struct cmd_vlan_offload_result {
2609 cmdline_fixed_string_t vlan;
2610 cmdline_fixed_string_t set;
2611 cmdline_fixed_string_t what;
2612 cmdline_fixed_string_t on;
2613 cmdline_fixed_string_t port_id;
2617 cmd_vlan_offload_parsed(void *parsed_result,
2618 __attribute__((unused)) struct cmdline *cl,
2619 __attribute__((unused)) void *data)
2622 struct cmd_vlan_offload_result *res = parsed_result;
2625 portid_t port_id = 0;
2629 len = strnlen(str, STR_TOKEN_SIZE);
2631 /* Get port_id first */
2639 tmp = strtoul(str, NULL, 0);
2640 /* If port_id greater that what portid_t can represent, return */
2641 if(tmp >= RTE_MAX_ETHPORTS)
2643 port_id = (portid_t)tmp;
2645 if (!strcmp(res->on, "on"))
2650 if (!strcmp(res->what, "strip"))
2651 rx_vlan_strip_set(port_id, on);
2652 else if(!strcmp(res->what, "stripq")){
2653 uint16_t queue_id = 0;
2655 /* No queue_id, return */
2657 printf("must specify (port,queue_id)\n");
2660 tmp = strtoul(str + i + 1, NULL, 0);
2661 /* If queue_id greater that what 16-bits can represent, return */
2665 queue_id = (uint16_t)tmp;
2666 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2668 else if (!strcmp(res->what, "filter"))
2669 rx_vlan_filter_set(port_id, on);
2671 vlan_extend_set(port_id, on);
2676 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2677 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2679 cmdline_parse_token_string_t cmd_vlan_offload_set =
2680 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2682 cmdline_parse_token_string_t cmd_vlan_offload_what =
2683 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2684 what, "strip#filter#qinq#stripq");
2685 cmdline_parse_token_string_t cmd_vlan_offload_on =
2686 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2688 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2689 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2692 cmdline_parse_inst_t cmd_vlan_offload = {
2693 .f = cmd_vlan_offload_parsed,
2695 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2696 " qinq(extended) for both rx/tx sides ",
2698 (void *)&cmd_vlan_offload_vlan,
2699 (void *)&cmd_vlan_offload_set,
2700 (void *)&cmd_vlan_offload_what,
2701 (void *)&cmd_vlan_offload_on,
2702 (void *)&cmd_vlan_offload_portid,
2707 /* *** VLAN TPID SET ON A PORT *** */
2708 struct cmd_vlan_tpid_result {
2709 cmdline_fixed_string_t vlan;
2710 cmdline_fixed_string_t set;
2711 cmdline_fixed_string_t what;
2717 cmd_vlan_tpid_parsed(void *parsed_result,
2718 __attribute__((unused)) struct cmdline *cl,
2719 __attribute__((unused)) void *data)
2721 struct cmd_vlan_tpid_result *res = parsed_result;
2722 vlan_tpid_set(res->port_id, res->tp_id);
2726 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2727 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2729 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2730 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2732 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2733 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2735 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2736 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2738 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2739 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2742 cmdline_parse_inst_t cmd_vlan_tpid = {
2743 .f = cmd_vlan_tpid_parsed,
2745 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2747 (void *)&cmd_vlan_tpid_vlan,
2748 (void *)&cmd_vlan_tpid_set,
2749 (void *)&cmd_vlan_tpid_what,
2750 (void *)&cmd_vlan_tpid_tpid,
2751 (void *)&cmd_vlan_tpid_portid,
2756 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2757 struct cmd_rx_vlan_filter_result {
2758 cmdline_fixed_string_t rx_vlan;
2759 cmdline_fixed_string_t what;
2765 cmd_rx_vlan_filter_parsed(void *parsed_result,
2766 __attribute__((unused)) struct cmdline *cl,
2767 __attribute__((unused)) void *data)
2769 struct cmd_rx_vlan_filter_result *res = parsed_result;
2771 if (!strcmp(res->what, "add"))
2772 rx_vft_set(res->port_id, res->vlan_id, 1);
2774 rx_vft_set(res->port_id, res->vlan_id, 0);
2777 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2778 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2779 rx_vlan, "rx_vlan");
2780 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2781 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2783 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2784 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2786 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2787 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2790 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2791 .f = cmd_rx_vlan_filter_parsed,
2793 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2794 "Identifiers filtered by a port",
2796 (void *)&cmd_rx_vlan_filter_rx_vlan,
2797 (void *)&cmd_rx_vlan_filter_what,
2798 (void *)&cmd_rx_vlan_filter_vlanid,
2799 (void *)&cmd_rx_vlan_filter_portid,
2804 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2805 struct cmd_tx_vlan_set_result {
2806 cmdline_fixed_string_t tx_vlan;
2807 cmdline_fixed_string_t set;
2813 cmd_tx_vlan_set_parsed(void *parsed_result,
2814 __attribute__((unused)) struct cmdline *cl,
2815 __attribute__((unused)) void *data)
2817 struct cmd_tx_vlan_set_result *res = parsed_result;
2818 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2820 if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD) {
2821 printf("Error, as QinQ has been enabled.\n");
2825 tx_vlan_set(res->port_id, res->vlan_id);
2828 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2829 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2830 tx_vlan, "tx_vlan");
2831 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2832 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2834 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2835 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2837 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2838 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2841 cmdline_parse_inst_t cmd_tx_vlan_set = {
2842 .f = cmd_tx_vlan_set_parsed,
2844 .help_str = "enable hardware insertion of a single VLAN header "
2845 "with a given TAG Identifier in packets sent on a port",
2847 (void *)&cmd_tx_vlan_set_tx_vlan,
2848 (void *)&cmd_tx_vlan_set_set,
2849 (void *)&cmd_tx_vlan_set_portid,
2850 (void *)&cmd_tx_vlan_set_vlanid,
2855 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
2856 struct cmd_tx_vlan_set_qinq_result {
2857 cmdline_fixed_string_t tx_vlan;
2858 cmdline_fixed_string_t set;
2861 uint16_t vlan_id_outer;
2865 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
2866 __attribute__((unused)) struct cmdline *cl,
2867 __attribute__((unused)) void *data)
2869 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
2870 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2872 if (!(vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)) {
2873 printf("Error, as QinQ hasn't been enabled.\n");
2877 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
2880 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
2881 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2882 tx_vlan, "tx_vlan");
2883 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
2884 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2886 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
2887 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2889 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
2890 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2892 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
2893 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2894 vlan_id_outer, UINT16);
2896 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
2897 .f = cmd_tx_vlan_set_qinq_parsed,
2899 .help_str = "enable hardware insertion of double VLAN header "
2900 "with given TAG Identifiers in packets sent on a port",
2902 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
2903 (void *)&cmd_tx_vlan_set_qinq_set,
2904 (void *)&cmd_tx_vlan_set_qinq_portid,
2905 (void *)&cmd_tx_vlan_set_qinq_vlanid,
2906 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
2911 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2912 struct cmd_tx_vlan_set_pvid_result {
2913 cmdline_fixed_string_t tx_vlan;
2914 cmdline_fixed_string_t set;
2915 cmdline_fixed_string_t pvid;
2918 cmdline_fixed_string_t mode;
2922 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2923 __attribute__((unused)) struct cmdline *cl,
2924 __attribute__((unused)) void *data)
2926 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2928 if (strcmp(res->mode, "on") == 0)
2929 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2931 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2934 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2935 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2936 tx_vlan, "tx_vlan");
2937 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2938 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2940 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2941 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2943 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2944 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2946 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2947 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2949 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2950 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2953 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2954 .f = cmd_tx_vlan_set_pvid_parsed,
2956 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2958 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2959 (void *)&cmd_tx_vlan_set_pvid_set,
2960 (void *)&cmd_tx_vlan_set_pvid_pvid,
2961 (void *)&cmd_tx_vlan_set_pvid_port_id,
2962 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2963 (void *)&cmd_tx_vlan_set_pvid_mode,
2968 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2969 struct cmd_tx_vlan_reset_result {
2970 cmdline_fixed_string_t tx_vlan;
2971 cmdline_fixed_string_t reset;
2976 cmd_tx_vlan_reset_parsed(void *parsed_result,
2977 __attribute__((unused)) struct cmdline *cl,
2978 __attribute__((unused)) void *data)
2980 struct cmd_tx_vlan_reset_result *res = parsed_result;
2982 tx_vlan_reset(res->port_id);
2985 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2986 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2987 tx_vlan, "tx_vlan");
2988 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2989 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2991 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2992 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2995 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2996 .f = cmd_tx_vlan_reset_parsed,
2998 .help_str = "disable hardware insertion of a VLAN header in packets "
3001 (void *)&cmd_tx_vlan_reset_tx_vlan,
3002 (void *)&cmd_tx_vlan_reset_reset,
3003 (void *)&cmd_tx_vlan_reset_portid,
3009 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3010 struct cmd_csum_result {
3011 cmdline_fixed_string_t csum;
3012 cmdline_fixed_string_t mode;
3013 cmdline_fixed_string_t proto;
3014 cmdline_fixed_string_t hwsw;
3019 csum_show(int port_id)
3021 struct rte_eth_dev_info dev_info;
3024 ol_flags = ports[port_id].tx_ol_flags;
3025 printf("Parse tunnel is %s\n",
3026 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3027 printf("IP checksum offload is %s\n",
3028 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3029 printf("UDP checksum offload is %s\n",
3030 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3031 printf("TCP checksum offload is %s\n",
3032 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3033 printf("SCTP checksum offload is %s\n",
3034 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3035 printf("Outer-Ip checksum offload is %s\n",
3036 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3038 /* display warnings if configuration is not supported by the NIC */
3039 rte_eth_dev_info_get(port_id, &dev_info);
3040 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3041 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3042 printf("Warning: hardware IP checksum enabled but not "
3043 "supported by port %d\n", port_id);
3045 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3046 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3047 printf("Warning: hardware UDP checksum enabled but not "
3048 "supported by port %d\n", port_id);
3050 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3051 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3052 printf("Warning: hardware TCP checksum enabled but not "
3053 "supported by port %d\n", port_id);
3055 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3056 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3057 printf("Warning: hardware SCTP checksum enabled but not "
3058 "supported by port %d\n", port_id);
3060 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3061 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3062 printf("Warning: hardware outer IP checksum enabled but not "
3063 "supported by port %d\n", port_id);
3068 cmd_csum_parsed(void *parsed_result,
3069 __attribute__((unused)) struct cmdline *cl,
3070 __attribute__((unused)) void *data)
3072 struct cmd_csum_result *res = parsed_result;
3076 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3077 printf("invalid port %d\n", res->port_id);
3081 if (!strcmp(res->mode, "set")) {
3083 if (!strcmp(res->hwsw, "hw"))
3086 if (!strcmp(res->proto, "ip")) {
3087 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3088 } else if (!strcmp(res->proto, "udp")) {
3089 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3090 } else if (!strcmp(res->proto, "tcp")) {
3091 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3092 } else if (!strcmp(res->proto, "sctp")) {
3093 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3094 } else if (!strcmp(res->proto, "outer-ip")) {
3095 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3099 ports[res->port_id].tx_ol_flags |= mask;
3101 ports[res->port_id].tx_ol_flags &= (~mask);
3103 csum_show(res->port_id);
3106 cmdline_parse_token_string_t cmd_csum_csum =
3107 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3109 cmdline_parse_token_string_t cmd_csum_mode =
3110 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3112 cmdline_parse_token_string_t cmd_csum_proto =
3113 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3114 proto, "ip#tcp#udp#sctp#outer-ip");
3115 cmdline_parse_token_string_t cmd_csum_hwsw =
3116 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3118 cmdline_parse_token_num_t cmd_csum_portid =
3119 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3122 cmdline_parse_inst_t cmd_csum_set = {
3123 .f = cmd_csum_parsed,
3125 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3126 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3128 (void *)&cmd_csum_csum,
3129 (void *)&cmd_csum_mode,
3130 (void *)&cmd_csum_proto,
3131 (void *)&cmd_csum_hwsw,
3132 (void *)&cmd_csum_portid,
3137 cmdline_parse_token_string_t cmd_csum_mode_show =
3138 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3141 cmdline_parse_inst_t cmd_csum_show = {
3142 .f = cmd_csum_parsed,
3144 .help_str = "show checksum offload configuration: csum show <port>",
3146 (void *)&cmd_csum_csum,
3147 (void *)&cmd_csum_mode_show,
3148 (void *)&cmd_csum_portid,
3153 /* Enable/disable tunnel parsing */
3154 struct cmd_csum_tunnel_result {
3155 cmdline_fixed_string_t csum;
3156 cmdline_fixed_string_t parse;
3157 cmdline_fixed_string_t onoff;
3162 cmd_csum_tunnel_parsed(void *parsed_result,
3163 __attribute__((unused)) struct cmdline *cl,
3164 __attribute__((unused)) void *data)
3166 struct cmd_csum_tunnel_result *res = parsed_result;
3168 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3171 if (!strcmp(res->onoff, "on"))
3172 ports[res->port_id].tx_ol_flags |=
3173 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3175 ports[res->port_id].tx_ol_flags &=
3176 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3178 csum_show(res->port_id);
3181 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3182 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3184 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3185 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3186 parse, "parse_tunnel");
3187 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3188 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3190 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3191 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3194 cmdline_parse_inst_t cmd_csum_tunnel = {
3195 .f = cmd_csum_tunnel_parsed,
3197 .help_str = "enable/disable parsing of tunnels for csum engine: "
3198 "csum parse_tunnel on|off <tx-port>",
3200 (void *)&cmd_csum_tunnel_csum,
3201 (void *)&cmd_csum_tunnel_parse,
3202 (void *)&cmd_csum_tunnel_onoff,
3203 (void *)&cmd_csum_tunnel_portid,
3208 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3209 struct cmd_tso_set_result {
3210 cmdline_fixed_string_t tso;
3211 cmdline_fixed_string_t mode;
3217 cmd_tso_set_parsed(void *parsed_result,
3218 __attribute__((unused)) struct cmdline *cl,
3219 __attribute__((unused)) void *data)
3221 struct cmd_tso_set_result *res = parsed_result;
3222 struct rte_eth_dev_info dev_info;
3224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3227 if (!strcmp(res->mode, "set"))
3228 ports[res->port_id].tso_segsz = res->tso_segsz;
3230 if (ports[res->port_id].tso_segsz == 0)
3231 printf("TSO is disabled\n");
3233 printf("TSO segment size is %d\n",
3234 ports[res->port_id].tso_segsz);
3236 /* display warnings if configuration is not supported by the NIC */
3237 rte_eth_dev_info_get(res->port_id, &dev_info);
3238 if ((ports[res->port_id].tso_segsz != 0) &&
3239 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3240 printf("Warning: TSO enabled but not "
3241 "supported by port %d\n", res->port_id);
3245 cmdline_parse_token_string_t cmd_tso_set_tso =
3246 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3248 cmdline_parse_token_string_t cmd_tso_set_mode =
3249 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3251 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3252 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3254 cmdline_parse_token_num_t cmd_tso_set_portid =
3255 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3258 cmdline_parse_inst_t cmd_tso_set = {
3259 .f = cmd_tso_set_parsed,
3261 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3262 "tso set <tso_segsz> <port>",
3264 (void *)&cmd_tso_set_tso,
3265 (void *)&cmd_tso_set_mode,
3266 (void *)&cmd_tso_set_tso_segsz,
3267 (void *)&cmd_tso_set_portid,
3272 cmdline_parse_token_string_t cmd_tso_show_mode =
3273 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3277 cmdline_parse_inst_t cmd_tso_show = {
3278 .f = cmd_tso_set_parsed,
3280 .help_str = "Show TSO segment size for csum engine: "
3283 (void *)&cmd_tso_set_tso,
3284 (void *)&cmd_tso_show_mode,
3285 (void *)&cmd_tso_set_portid,
3290 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3291 struct cmd_set_flush_rx {
3292 cmdline_fixed_string_t set;
3293 cmdline_fixed_string_t flush_rx;
3294 cmdline_fixed_string_t mode;
3298 cmd_set_flush_rx_parsed(void *parsed_result,
3299 __attribute__((unused)) struct cmdline *cl,
3300 __attribute__((unused)) void *data)
3302 struct cmd_set_flush_rx *res = parsed_result;
3303 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3306 cmdline_parse_token_string_t cmd_setflushrx_set =
3307 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3309 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3310 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3311 flush_rx, "flush_rx");
3312 cmdline_parse_token_string_t cmd_setflushrx_mode =
3313 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3317 cmdline_parse_inst_t cmd_set_flush_rx = {
3318 .f = cmd_set_flush_rx_parsed,
3319 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3322 (void *)&cmd_setflushrx_set,
3323 (void *)&cmd_setflushrx_flush_rx,
3324 (void *)&cmd_setflushrx_mode,
3329 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3330 struct cmd_set_link_check {
3331 cmdline_fixed_string_t set;
3332 cmdline_fixed_string_t link_check;
3333 cmdline_fixed_string_t mode;
3337 cmd_set_link_check_parsed(void *parsed_result,
3338 __attribute__((unused)) struct cmdline *cl,
3339 __attribute__((unused)) void *data)
3341 struct cmd_set_link_check *res = parsed_result;
3342 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3345 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3346 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3348 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3349 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3350 link_check, "link_check");
3351 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3352 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3356 cmdline_parse_inst_t cmd_set_link_check = {
3357 .f = cmd_set_link_check_parsed,
3358 .help_str = "set link_check on|off: enable/disable link status check "
3359 "when starting/stopping a port",
3362 (void *)&cmd_setlinkcheck_set,
3363 (void *)&cmd_setlinkcheck_link_check,
3364 (void *)&cmd_setlinkcheck_mode,
3369 #ifdef RTE_NIC_BYPASS
3370 /* *** SET NIC BYPASS MODE *** */
3371 struct cmd_set_bypass_mode_result {
3372 cmdline_fixed_string_t set;
3373 cmdline_fixed_string_t bypass;
3374 cmdline_fixed_string_t mode;
3375 cmdline_fixed_string_t value;
3380 cmd_set_bypass_mode_parsed(void *parsed_result,
3381 __attribute__((unused)) struct cmdline *cl,
3382 __attribute__((unused)) void *data)
3384 struct cmd_set_bypass_mode_result *res = parsed_result;
3385 portid_t port_id = res->port_id;
3386 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3388 if (!bypass_is_supported(port_id))
3391 if (!strcmp(res->value, "bypass"))
3392 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3393 else if (!strcmp(res->value, "isolate"))
3394 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3396 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3398 /* Set the bypass mode for the relevant port. */
3399 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3400 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3404 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3405 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3407 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3408 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3410 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3411 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3413 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3414 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3415 value, "normal#bypass#isolate");
3416 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3417 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3420 cmdline_parse_inst_t cmd_set_bypass_mode = {
3421 .f = cmd_set_bypass_mode_parsed,
3422 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3423 "Set the NIC bypass mode for port_id",
3426 (void *)&cmd_setbypass_mode_set,
3427 (void *)&cmd_setbypass_mode_bypass,
3428 (void *)&cmd_setbypass_mode_mode,
3429 (void *)&cmd_setbypass_mode_value,
3430 (void *)&cmd_setbypass_mode_port,
3435 /* *** SET NIC BYPASS EVENT *** */
3436 struct cmd_set_bypass_event_result {
3437 cmdline_fixed_string_t set;
3438 cmdline_fixed_string_t bypass;
3439 cmdline_fixed_string_t event;
3440 cmdline_fixed_string_t event_value;
3441 cmdline_fixed_string_t mode;
3442 cmdline_fixed_string_t mode_value;
3447 cmd_set_bypass_event_parsed(void *parsed_result,
3448 __attribute__((unused)) struct cmdline *cl,
3449 __attribute__((unused)) void *data)
3452 struct cmd_set_bypass_event_result *res = parsed_result;
3453 portid_t port_id = res->port_id;
3454 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3455 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3457 if (!bypass_is_supported(port_id))
3460 if (!strcmp(res->event_value, "timeout"))
3461 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3462 else if (!strcmp(res->event_value, "os_on"))
3463 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3464 else if (!strcmp(res->event_value, "os_off"))
3465 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3466 else if (!strcmp(res->event_value, "power_on"))
3467 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3468 else if (!strcmp(res->event_value, "power_off"))
3469 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3471 bypass_event = RTE_BYPASS_EVENT_NONE;
3473 if (!strcmp(res->mode_value, "bypass"))
3474 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3475 else if (!strcmp(res->mode_value, "isolate"))
3476 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3478 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3480 /* Set the watchdog timeout. */
3481 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3484 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3485 (rc = rte_eth_dev_wd_timeout_store(port_id,
3486 bypass_timeout)) != 0) {
3487 printf("Failed to set timeout value %u "
3488 "for port %d, errto code: %d.\n",
3489 bypass_timeout, port_id, rc);
3493 /* Set the bypass event to transition to bypass mode. */
3494 if (0 != rte_eth_dev_bypass_event_store(port_id,
3495 bypass_event, bypass_mode)) {
3496 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3501 cmdline_parse_token_string_t cmd_setbypass_event_set =
3502 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3504 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3505 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3507 cmdline_parse_token_string_t cmd_setbypass_event_event =
3508 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3510 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3511 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3512 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3513 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3514 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3516 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3517 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3518 mode_value, "normal#bypass#isolate");
3519 cmdline_parse_token_num_t cmd_setbypass_event_port =
3520 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3523 cmdline_parse_inst_t cmd_set_bypass_event = {
3524 .f = cmd_set_bypass_event_parsed,
3525 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3526 "mode (normal|bypass|isolate) (port_id): "
3527 "Set the NIC bypass event mode for port_id",
3530 (void *)&cmd_setbypass_event_set,
3531 (void *)&cmd_setbypass_event_bypass,
3532 (void *)&cmd_setbypass_event_event,
3533 (void *)&cmd_setbypass_event_event_value,
3534 (void *)&cmd_setbypass_event_mode,
3535 (void *)&cmd_setbypass_event_mode_value,
3536 (void *)&cmd_setbypass_event_port,
3542 /* *** SET NIC BYPASS TIMEOUT *** */
3543 struct cmd_set_bypass_timeout_result {
3544 cmdline_fixed_string_t set;
3545 cmdline_fixed_string_t bypass;
3546 cmdline_fixed_string_t timeout;
3547 cmdline_fixed_string_t value;
3551 cmd_set_bypass_timeout_parsed(void *parsed_result,
3552 __attribute__((unused)) struct cmdline *cl,
3553 __attribute__((unused)) void *data)
3555 struct cmd_set_bypass_timeout_result *res = parsed_result;
3557 if (!strcmp(res->value, "1.5"))
3558 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3559 else if (!strcmp(res->value, "2"))
3560 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3561 else if (!strcmp(res->value, "3"))
3562 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3563 else if (!strcmp(res->value, "4"))
3564 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3565 else if (!strcmp(res->value, "8"))
3566 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3567 else if (!strcmp(res->value, "16"))
3568 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3569 else if (!strcmp(res->value, "32"))
3570 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3572 bypass_timeout = RTE_BYPASS_TMT_OFF;
3575 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3576 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3578 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3579 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3581 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3582 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3583 timeout, "timeout");
3584 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3585 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3586 value, "0#1.5#2#3#4#8#16#32");
3588 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3589 .f = cmd_set_bypass_timeout_parsed,
3590 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3591 "Set the NIC bypass watchdog timeout",
3594 (void *)&cmd_setbypass_timeout_set,
3595 (void *)&cmd_setbypass_timeout_bypass,
3596 (void *)&cmd_setbypass_timeout_timeout,
3597 (void *)&cmd_setbypass_timeout_value,
3602 /* *** SHOW NIC BYPASS MODE *** */
3603 struct cmd_show_bypass_config_result {
3604 cmdline_fixed_string_t show;
3605 cmdline_fixed_string_t bypass;
3606 cmdline_fixed_string_t config;
3611 cmd_show_bypass_config_parsed(void *parsed_result,
3612 __attribute__((unused)) struct cmdline *cl,
3613 __attribute__((unused)) void *data)
3615 struct cmd_show_bypass_config_result *res = parsed_result;
3616 uint32_t event_mode;
3617 uint32_t bypass_mode;
3618 portid_t port_id = res->port_id;
3619 uint32_t timeout = bypass_timeout;
3622 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3623 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3624 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3625 {"UNKNOWN", "normal", "bypass", "isolate"};
3626 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3633 int num_events = (sizeof events) / (sizeof events[0]);
3635 if (!bypass_is_supported(port_id))
3638 /* Display the bypass mode.*/
3639 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3640 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3644 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3645 bypass_mode = RTE_BYPASS_MODE_NONE;
3647 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3650 /* Display the bypass timeout.*/
3651 if (!RTE_BYPASS_TMT_VALID(timeout))
3652 timeout = RTE_BYPASS_TMT_OFF;
3654 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3656 /* Display the bypass events and associated modes. */
3657 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3659 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3660 printf("\tFailed to get bypass mode for event = %s\n",
3663 if (!RTE_BYPASS_MODE_VALID(event_mode))
3664 event_mode = RTE_BYPASS_MODE_NONE;
3666 printf("\tbypass event: %-16s = %s\n", events[i],
3672 cmdline_parse_token_string_t cmd_showbypass_config_show =
3673 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3675 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3676 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3678 cmdline_parse_token_string_t cmd_showbypass_config_config =
3679 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3681 cmdline_parse_token_num_t cmd_showbypass_config_port =
3682 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3685 cmdline_parse_inst_t cmd_show_bypass_config = {
3686 .f = cmd_show_bypass_config_parsed,
3687 .help_str = "show bypass config (port_id): "
3688 "Show the NIC bypass config for port_id",
3691 (void *)&cmd_showbypass_config_show,
3692 (void *)&cmd_showbypass_config_bypass,
3693 (void *)&cmd_showbypass_config_config,
3694 (void *)&cmd_showbypass_config_port,
3700 #ifdef RTE_LIBRTE_PMD_BOND
3701 /* *** SET BONDING MODE *** */
3702 struct cmd_set_bonding_mode_result {
3703 cmdline_fixed_string_t set;
3704 cmdline_fixed_string_t bonding;
3705 cmdline_fixed_string_t mode;
3710 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3711 __attribute__((unused)) struct cmdline *cl,
3712 __attribute__((unused)) void *data)
3714 struct cmd_set_bonding_mode_result *res = parsed_result;
3715 portid_t port_id = res->port_id;
3717 /* Set the bonding mode for the relevant port. */
3718 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3719 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3722 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3723 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3725 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3726 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3727 bonding, "bonding");
3728 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3729 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3731 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3732 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3734 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3735 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3738 cmdline_parse_inst_t cmd_set_bonding_mode = {
3739 .f = cmd_set_bonding_mode_parsed,
3740 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3743 (void *) &cmd_setbonding_mode_set,
3744 (void *) &cmd_setbonding_mode_bonding,
3745 (void *) &cmd_setbonding_mode_mode,
3746 (void *) &cmd_setbonding_mode_value,
3747 (void *) &cmd_setbonding_mode_port,
3752 /* *** SET BALANCE XMIT POLICY *** */
3753 struct cmd_set_bonding_balance_xmit_policy_result {
3754 cmdline_fixed_string_t set;
3755 cmdline_fixed_string_t bonding;
3756 cmdline_fixed_string_t balance_xmit_policy;
3758 cmdline_fixed_string_t policy;
3761 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3762 __attribute__((unused)) struct cmdline *cl,
3763 __attribute__((unused)) void *data)
3765 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3766 portid_t port_id = res->port_id;
3769 if (!strcmp(res->policy, "l2")) {
3770 policy = BALANCE_XMIT_POLICY_LAYER2;
3771 } else if (!strcmp(res->policy, "l23")) {
3772 policy = BALANCE_XMIT_POLICY_LAYER23;
3773 } else if (!strcmp(res->policy, "l34")) {
3774 policy = BALANCE_XMIT_POLICY_LAYER34;
3776 printf("\t Invalid xmit policy selection");
3780 /* Set the bonding mode for the relevant port. */
3781 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3782 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3787 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3788 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3790 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3791 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3792 bonding, "bonding");
3793 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3794 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3795 balance_xmit_policy, "balance_xmit_policy");
3796 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3797 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3799 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3800 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3801 policy, "l2#l23#l34");
3803 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3804 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3805 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3808 (void *)&cmd_setbonding_balance_xmit_policy_set,
3809 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3810 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3811 (void *)&cmd_setbonding_balance_xmit_policy_port,
3812 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3817 /* *** SHOW NIC BONDING CONFIGURATION *** */
3818 struct cmd_show_bonding_config_result {
3819 cmdline_fixed_string_t show;
3820 cmdline_fixed_string_t bonding;
3821 cmdline_fixed_string_t config;
3825 static void cmd_show_bonding_config_parsed(void *parsed_result,
3826 __attribute__((unused)) struct cmdline *cl,
3827 __attribute__((unused)) void *data)
3829 struct cmd_show_bonding_config_result *res = parsed_result;
3831 uint8_t slaves[RTE_MAX_ETHPORTS];
3832 int num_slaves, num_active_slaves;
3835 portid_t port_id = res->port_id;
3837 /* Display the bonding mode.*/
3838 bonding_mode = rte_eth_bond_mode_get(port_id);
3839 if (bonding_mode < 0) {
3840 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3843 printf("\tBonding mode: %d\n", bonding_mode);
3845 if (bonding_mode == BONDING_MODE_BALANCE) {
3846 int balance_xmit_policy;
3848 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3849 if (balance_xmit_policy < 0) {
3850 printf("\tFailed to get balance xmit policy for port = %d\n",
3854 printf("\tBalance Xmit Policy: ");
3856 switch (balance_xmit_policy) {
3857 case BALANCE_XMIT_POLICY_LAYER2:
3858 printf("BALANCE_XMIT_POLICY_LAYER2");
3860 case BALANCE_XMIT_POLICY_LAYER23:
3861 printf("BALANCE_XMIT_POLICY_LAYER23");
3863 case BALANCE_XMIT_POLICY_LAYER34:
3864 printf("BALANCE_XMIT_POLICY_LAYER34");
3871 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3873 if (num_slaves < 0) {
3874 printf("\tFailed to get slave list for port = %d\n", port_id);
3877 if (num_slaves > 0) {
3878 printf("\tSlaves (%d): [", num_slaves);
3879 for (i = 0; i < num_slaves - 1; i++)
3880 printf("%d ", slaves[i]);
3882 printf("%d]\n", slaves[num_slaves - 1]);
3884 printf("\tSlaves: []\n");
3888 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3891 if (num_active_slaves < 0) {
3892 printf("\tFailed to get active slave list for port = %d\n", port_id);
3895 if (num_active_slaves > 0) {
3896 printf("\tActive Slaves (%d): [", num_active_slaves);
3897 for (i = 0; i < num_active_slaves - 1; i++)
3898 printf("%d ", slaves[i]);
3900 printf("%d]\n", slaves[num_active_slaves - 1]);
3903 printf("\tActive Slaves: []\n");
3907 primary_id = rte_eth_bond_primary_get(port_id);
3908 if (primary_id < 0) {
3909 printf("\tFailed to get primary slave for port = %d\n", port_id);
3912 printf("\tPrimary: [%d]\n", primary_id);
3916 cmdline_parse_token_string_t cmd_showbonding_config_show =
3917 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3919 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3920 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3921 bonding, "bonding");
3922 cmdline_parse_token_string_t cmd_showbonding_config_config =
3923 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3925 cmdline_parse_token_num_t cmd_showbonding_config_port =
3926 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3929 cmdline_parse_inst_t cmd_show_bonding_config = {
3930 .f = cmd_show_bonding_config_parsed,
3931 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3934 (void *)&cmd_showbonding_config_show,
3935 (void *)&cmd_showbonding_config_bonding,
3936 (void *)&cmd_showbonding_config_config,
3937 (void *)&cmd_showbonding_config_port,
3942 /* *** SET BONDING PRIMARY *** */
3943 struct cmd_set_bonding_primary_result {
3944 cmdline_fixed_string_t set;
3945 cmdline_fixed_string_t bonding;
3946 cmdline_fixed_string_t primary;
3951 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3952 __attribute__((unused)) struct cmdline *cl,
3953 __attribute__((unused)) void *data)
3955 struct cmd_set_bonding_primary_result *res = parsed_result;
3956 portid_t master_port_id = res->port_id;
3957 portid_t slave_port_id = res->slave_id;
3959 /* Set the primary slave for a bonded device. */
3960 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3961 printf("\t Failed to set primary slave for port = %d.\n",
3968 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3969 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3971 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3972 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3973 bonding, "bonding");
3974 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3975 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3976 primary, "primary");
3977 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3978 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3980 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3981 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3984 cmdline_parse_inst_t cmd_set_bonding_primary = {
3985 .f = cmd_set_bonding_primary_parsed,
3986 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3989 (void *)&cmd_setbonding_primary_set,
3990 (void *)&cmd_setbonding_primary_bonding,
3991 (void *)&cmd_setbonding_primary_primary,
3992 (void *)&cmd_setbonding_primary_slave,
3993 (void *)&cmd_setbonding_primary_port,
3998 /* *** ADD SLAVE *** */
3999 struct cmd_add_bonding_slave_result {
4000 cmdline_fixed_string_t add;
4001 cmdline_fixed_string_t bonding;
4002 cmdline_fixed_string_t slave;
4007 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4008 __attribute__((unused)) struct cmdline *cl,
4009 __attribute__((unused)) void *data)
4011 struct cmd_add_bonding_slave_result *res = parsed_result;
4012 portid_t master_port_id = res->port_id;
4013 portid_t slave_port_id = res->slave_id;
4015 /* Set the primary slave for a bonded device. */
4016 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4017 printf("\t Failed to add slave %d to master port = %d.\n",
4018 slave_port_id, master_port_id);
4024 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4025 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4027 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4028 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4029 bonding, "bonding");
4030 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4031 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4033 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4034 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4036 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4037 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4040 cmdline_parse_inst_t cmd_add_bonding_slave = {
4041 .f = cmd_add_bonding_slave_parsed,
4042 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4045 (void *)&cmd_addbonding_slave_add,
4046 (void *)&cmd_addbonding_slave_bonding,
4047 (void *)&cmd_addbonding_slave_slave,
4048 (void *)&cmd_addbonding_slave_slaveid,
4049 (void *)&cmd_addbonding_slave_port,
4054 /* *** REMOVE SLAVE *** */
4055 struct cmd_remove_bonding_slave_result {
4056 cmdline_fixed_string_t remove;
4057 cmdline_fixed_string_t bonding;
4058 cmdline_fixed_string_t slave;
4063 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4064 __attribute__((unused)) struct cmdline *cl,
4065 __attribute__((unused)) void *data)
4067 struct cmd_remove_bonding_slave_result *res = parsed_result;
4068 portid_t master_port_id = res->port_id;
4069 portid_t slave_port_id = res->slave_id;
4071 /* Set the primary slave for a bonded device. */
4072 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4073 printf("\t Failed to remove slave %d from master port = %d.\n",
4074 slave_port_id, master_port_id);
4080 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4081 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4083 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4084 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4085 bonding, "bonding");
4086 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4087 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4089 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4090 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4092 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4093 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4096 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4097 .f = cmd_remove_bonding_slave_parsed,
4098 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4101 (void *)&cmd_removebonding_slave_remove,
4102 (void *)&cmd_removebonding_slave_bonding,
4103 (void *)&cmd_removebonding_slave_slave,
4104 (void *)&cmd_removebonding_slave_slaveid,
4105 (void *)&cmd_removebonding_slave_port,
4110 /* *** CREATE BONDED DEVICE *** */
4111 struct cmd_create_bonded_device_result {
4112 cmdline_fixed_string_t create;
4113 cmdline_fixed_string_t bonded;
4114 cmdline_fixed_string_t device;
4119 static int bond_dev_num = 0;
4121 static void cmd_create_bonded_device_parsed(void *parsed_result,
4122 __attribute__((unused)) struct cmdline *cl,
4123 __attribute__((unused)) void *data)
4125 struct cmd_create_bonded_device_result *res = parsed_result;
4126 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4129 if (test_done == 0) {
4130 printf("Please stop forwarding first\n");
4134 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4137 /* Create a new bonded device. */
4138 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4140 printf("\t Failed to create bonded device.\n");
4143 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4146 /* Update number of ports */
4147 nb_ports = rte_eth_dev_count();
4148 reconfig(port_id, res->socket);
4149 rte_eth_promiscuous_enable(port_id);
4150 ports[port_id].enabled = 1;
4155 cmdline_parse_token_string_t cmd_createbonded_device_create =
4156 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4158 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4159 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4161 cmdline_parse_token_string_t cmd_createbonded_device_device =
4162 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4164 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4165 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4167 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4168 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4171 cmdline_parse_inst_t cmd_create_bonded_device = {
4172 .f = cmd_create_bonded_device_parsed,
4173 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4176 (void *)&cmd_createbonded_device_create,
4177 (void *)&cmd_createbonded_device_bonded,
4178 (void *)&cmd_createbonded_device_device,
4179 (void *)&cmd_createbonded_device_mode,
4180 (void *)&cmd_createbonded_device_socket,
4185 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4186 struct cmd_set_bond_mac_addr_result {
4187 cmdline_fixed_string_t set;
4188 cmdline_fixed_string_t bonding;
4189 cmdline_fixed_string_t mac_addr;
4191 struct ether_addr address;
4194 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4195 __attribute__((unused)) struct cmdline *cl,
4196 __attribute__((unused)) void *data)
4198 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4201 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4204 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4206 /* check the return value and print it if is < 0 */
4208 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4211 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4212 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4213 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4214 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4216 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4217 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4219 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4220 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4221 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4222 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4224 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4225 .f = cmd_set_bond_mac_addr_parsed,
4227 .help_str = "set bonding mac_addr (port_id) (address): ",
4229 (void *)&cmd_set_bond_mac_addr_set,
4230 (void *)&cmd_set_bond_mac_addr_bonding,
4231 (void *)&cmd_set_bond_mac_addr_mac,
4232 (void *)&cmd_set_bond_mac_addr_portnum,
4233 (void *)&cmd_set_bond_mac_addr_addr,
4239 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4240 struct cmd_set_bond_mon_period_result {
4241 cmdline_fixed_string_t set;
4242 cmdline_fixed_string_t bonding;
4243 cmdline_fixed_string_t mon_period;
4248 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4249 __attribute__((unused)) struct cmdline *cl,
4250 __attribute__((unused)) void *data)
4252 struct cmd_set_bond_mon_period_result *res = parsed_result;
4255 if (res->port_num >= nb_ports) {
4256 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4260 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4262 /* check the return value and print it if is < 0 */
4264 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4267 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4268 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4270 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4271 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4272 bonding, "bonding");
4273 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4274 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4275 mon_period, "mon_period");
4276 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4277 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4279 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4280 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4283 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4284 .f = cmd_set_bond_mon_period_parsed,
4286 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4288 (void *)&cmd_set_bond_mon_period_set,
4289 (void *)&cmd_set_bond_mon_period_bonding,
4290 (void *)&cmd_set_bond_mon_period_mon_period,
4291 (void *)&cmd_set_bond_mon_period_portnum,
4292 (void *)&cmd_set_bond_mon_period_period_ms,
4297 #endif /* RTE_LIBRTE_PMD_BOND */
4299 /* *** SET FORWARDING MODE *** */
4300 struct cmd_set_fwd_mode_result {
4301 cmdline_fixed_string_t set;
4302 cmdline_fixed_string_t fwd;
4303 cmdline_fixed_string_t mode;
4306 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4307 __attribute__((unused)) struct cmdline *cl,
4308 __attribute__((unused)) void *data)
4310 struct cmd_set_fwd_mode_result *res = parsed_result;
4312 set_pkt_forwarding_mode(res->mode);
4315 cmdline_parse_token_string_t cmd_setfwd_set =
4316 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4317 cmdline_parse_token_string_t cmd_setfwd_fwd =
4318 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4319 cmdline_parse_token_string_t cmd_setfwd_mode =
4320 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4321 "" /* defined at init */);
4323 cmdline_parse_inst_t cmd_set_fwd_mode = {
4324 .f = cmd_set_fwd_mode_parsed,
4326 .help_str = NULL, /* defined at init */
4328 (void *)&cmd_setfwd_set,
4329 (void *)&cmd_setfwd_fwd,
4330 (void *)&cmd_setfwd_mode,
4335 static void cmd_set_fwd_mode_init(void)
4338 static char token[128];
4339 static char help[256];
4340 cmdline_parse_token_string_t *token_struct;
4342 modes = list_pkt_forwarding_modes();
4343 snprintf(help, sizeof help, "set fwd %s - "
4344 "set packet forwarding mode", modes);
4345 cmd_set_fwd_mode.help_str = help;
4347 /* string token separator is # */
4348 for (c = token; *modes != '\0'; modes++)
4353 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4354 token_struct->string_data.str = token;
4357 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4358 struct cmd_set_burst_tx_retry_result {
4359 cmdline_fixed_string_t set;
4360 cmdline_fixed_string_t burst;
4361 cmdline_fixed_string_t tx;
4362 cmdline_fixed_string_t delay;
4364 cmdline_fixed_string_t retry;
4368 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4369 __attribute__((unused)) struct cmdline *cl,
4370 __attribute__((unused)) void *data)
4372 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4374 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4375 && !strcmp(res->tx, "tx")) {
4376 if (!strcmp(res->delay, "delay"))
4377 burst_tx_delay_time = res->time;
4378 if (!strcmp(res->retry, "retry"))
4379 burst_tx_retry_num = res->retry_num;
4384 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4385 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4386 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4387 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4389 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4390 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4391 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4392 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4393 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4394 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4395 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4396 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4397 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4398 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4400 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4401 .f = cmd_set_burst_tx_retry_parsed,
4402 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4404 (void *)&cmd_set_burst_tx_retry_set,
4405 (void *)&cmd_set_burst_tx_retry_burst,
4406 (void *)&cmd_set_burst_tx_retry_tx,
4407 (void *)&cmd_set_burst_tx_retry_delay,
4408 (void *)&cmd_set_burst_tx_retry_time,
4409 (void *)&cmd_set_burst_tx_retry_retry,
4410 (void *)&cmd_set_burst_tx_retry_retry_num,
4415 /* *** SET PROMISC MODE *** */
4416 struct cmd_set_promisc_mode_result {
4417 cmdline_fixed_string_t set;
4418 cmdline_fixed_string_t promisc;
4419 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4420 uint8_t port_num; /* valid if "allports" argument == 0 */
4421 cmdline_fixed_string_t mode;
4424 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4425 __attribute__((unused)) struct cmdline *cl,
4428 struct cmd_set_promisc_mode_result *res = parsed_result;
4432 if (!strcmp(res->mode, "on"))
4439 FOREACH_PORT(i, ports) {
4441 rte_eth_promiscuous_enable(i);
4443 rte_eth_promiscuous_disable(i);
4448 rte_eth_promiscuous_enable(res->port_num);
4450 rte_eth_promiscuous_disable(res->port_num);
4454 cmdline_parse_token_string_t cmd_setpromisc_set =
4455 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4456 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4457 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4459 cmdline_parse_token_string_t cmd_setpromisc_portall =
4460 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4462 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4463 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4465 cmdline_parse_token_string_t cmd_setpromisc_mode =
4466 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4469 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4470 .f = cmd_set_promisc_mode_parsed,
4472 .help_str = "set promisc all on|off: set promisc mode for all ports",
4474 (void *)&cmd_setpromisc_set,
4475 (void *)&cmd_setpromisc_promisc,
4476 (void *)&cmd_setpromisc_portall,
4477 (void *)&cmd_setpromisc_mode,
4482 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4483 .f = cmd_set_promisc_mode_parsed,
4485 .help_str = "set promisc X on|off: set promisc mode on port X",
4487 (void *)&cmd_setpromisc_set,
4488 (void *)&cmd_setpromisc_promisc,
4489 (void *)&cmd_setpromisc_portnum,
4490 (void *)&cmd_setpromisc_mode,
4495 /* *** SET ALLMULTI MODE *** */
4496 struct cmd_set_allmulti_mode_result {
4497 cmdline_fixed_string_t set;
4498 cmdline_fixed_string_t allmulti;
4499 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4500 uint8_t port_num; /* valid if "allports" argument == 0 */
4501 cmdline_fixed_string_t mode;
4504 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4505 __attribute__((unused)) struct cmdline *cl,
4508 struct cmd_set_allmulti_mode_result *res = parsed_result;
4512 if (!strcmp(res->mode, "on"))
4519 FOREACH_PORT(i, ports) {
4521 rte_eth_allmulticast_enable(i);
4523 rte_eth_allmulticast_disable(i);
4528 rte_eth_allmulticast_enable(res->port_num);
4530 rte_eth_allmulticast_disable(res->port_num);
4534 cmdline_parse_token_string_t cmd_setallmulti_set =
4535 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4536 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4537 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4539 cmdline_parse_token_string_t cmd_setallmulti_portall =
4540 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4542 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4543 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4545 cmdline_parse_token_string_t cmd_setallmulti_mode =
4546 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4549 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4550 .f = cmd_set_allmulti_mode_parsed,
4552 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4554 (void *)&cmd_setallmulti_set,
4555 (void *)&cmd_setallmulti_allmulti,
4556 (void *)&cmd_setallmulti_portall,
4557 (void *)&cmd_setallmulti_mode,
4562 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4563 .f = cmd_set_allmulti_mode_parsed,
4565 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4567 (void *)&cmd_setallmulti_set,
4568 (void *)&cmd_setallmulti_allmulti,
4569 (void *)&cmd_setallmulti_portnum,
4570 (void *)&cmd_setallmulti_mode,
4575 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4576 struct cmd_link_flow_ctrl_set_result {
4577 cmdline_fixed_string_t set;
4578 cmdline_fixed_string_t flow_ctrl;
4579 cmdline_fixed_string_t rx;
4580 cmdline_fixed_string_t rx_lfc_mode;
4581 cmdline_fixed_string_t tx;
4582 cmdline_fixed_string_t tx_lfc_mode;
4583 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4584 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4585 cmdline_fixed_string_t autoneg_str;
4586 cmdline_fixed_string_t autoneg;
4587 cmdline_fixed_string_t hw_str;
4588 uint32_t high_water;
4589 cmdline_fixed_string_t lw_str;
4591 cmdline_fixed_string_t pt_str;
4592 uint16_t pause_time;
4593 cmdline_fixed_string_t xon_str;
4598 cmdline_parse_token_string_t cmd_lfc_set_set =
4599 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4601 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4602 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4603 flow_ctrl, "flow_ctrl");
4604 cmdline_parse_token_string_t cmd_lfc_set_rx =
4605 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4607 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4608 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4609 rx_lfc_mode, "on#off");
4610 cmdline_parse_token_string_t cmd_lfc_set_tx =
4611 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4613 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4614 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4615 tx_lfc_mode, "on#off");
4616 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4617 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4618 hw_str, "high_water");
4619 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4620 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4621 high_water, UINT32);
4622 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4623 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4624 lw_str, "low_water");
4625 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4626 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4628 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4629 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4630 pt_str, "pause_time");
4631 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4632 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4633 pause_time, UINT16);
4634 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4635 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4636 xon_str, "send_xon");
4637 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4638 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4640 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4641 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4642 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4643 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4644 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4645 mac_ctrl_frame_fwd_mode, "on#off");
4646 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4647 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4648 autoneg_str, "autoneg");
4649 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4650 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4652 cmdline_parse_token_num_t cmd_lfc_set_portid =
4653 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4656 /* forward declaration */
4658 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4661 cmdline_parse_inst_t cmd_link_flow_control_set = {
4662 .f = cmd_link_flow_ctrl_set_parsed,
4664 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4665 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4666 autoneg on|off port_id",
4668 (void *)&cmd_lfc_set_set,
4669 (void *)&cmd_lfc_set_flow_ctrl,
4670 (void *)&cmd_lfc_set_rx,
4671 (void *)&cmd_lfc_set_rx_mode,
4672 (void *)&cmd_lfc_set_tx,
4673 (void *)&cmd_lfc_set_tx_mode,
4674 (void *)&cmd_lfc_set_high_water,
4675 (void *)&cmd_lfc_set_low_water,
4676 (void *)&cmd_lfc_set_pause_time,
4677 (void *)&cmd_lfc_set_send_xon,
4678 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4679 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4680 (void *)&cmd_lfc_set_autoneg_str,
4681 (void *)&cmd_lfc_set_autoneg,
4682 (void *)&cmd_lfc_set_portid,
4687 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4688 .f = cmd_link_flow_ctrl_set_parsed,
4689 .data = (void *)&cmd_link_flow_control_set_rx,
4690 .help_str = "Change rx flow control parameter: set flow_ctrl "
4691 "rx on|off port_id",
4693 (void *)&cmd_lfc_set_set,
4694 (void *)&cmd_lfc_set_flow_ctrl,
4695 (void *)&cmd_lfc_set_rx,
4696 (void *)&cmd_lfc_set_rx_mode,
4697 (void *)&cmd_lfc_set_portid,
4702 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4703 .f = cmd_link_flow_ctrl_set_parsed,
4704 .data = (void *)&cmd_link_flow_control_set_tx,
4705 .help_str = "Change tx flow control parameter: set flow_ctrl "
4706 "tx on|off port_id",
4708 (void *)&cmd_lfc_set_set,
4709 (void *)&cmd_lfc_set_flow_ctrl,
4710 (void *)&cmd_lfc_set_tx,
4711 (void *)&cmd_lfc_set_tx_mode,
4712 (void *)&cmd_lfc_set_portid,
4717 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4718 .f = cmd_link_flow_ctrl_set_parsed,
4719 .data = (void *)&cmd_link_flow_control_set_hw,
4720 .help_str = "Change high water flow control parameter: set flow_ctrl "
4721 "high_water value port_id",
4723 (void *)&cmd_lfc_set_set,
4724 (void *)&cmd_lfc_set_flow_ctrl,
4725 (void *)&cmd_lfc_set_high_water_str,
4726 (void *)&cmd_lfc_set_high_water,
4727 (void *)&cmd_lfc_set_portid,
4732 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4733 .f = cmd_link_flow_ctrl_set_parsed,
4734 .data = (void *)&cmd_link_flow_control_set_lw,
4735 .help_str = "Change low water flow control parameter: set flow_ctrl "
4736 "low_water value port_id",
4738 (void *)&cmd_lfc_set_set,
4739 (void *)&cmd_lfc_set_flow_ctrl,
4740 (void *)&cmd_lfc_set_low_water_str,
4741 (void *)&cmd_lfc_set_low_water,
4742 (void *)&cmd_lfc_set_portid,
4747 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4748 .f = cmd_link_flow_ctrl_set_parsed,
4749 .data = (void *)&cmd_link_flow_control_set_pt,
4750 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4751 "pause_time value port_id",
4753 (void *)&cmd_lfc_set_set,
4754 (void *)&cmd_lfc_set_flow_ctrl,
4755 (void *)&cmd_lfc_set_pause_time_str,
4756 (void *)&cmd_lfc_set_pause_time,
4757 (void *)&cmd_lfc_set_portid,
4762 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4763 .f = cmd_link_flow_ctrl_set_parsed,
4764 .data = (void *)&cmd_link_flow_control_set_xon,
4765 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4766 "send_xon value port_id",
4768 (void *)&cmd_lfc_set_set,
4769 (void *)&cmd_lfc_set_flow_ctrl,
4770 (void *)&cmd_lfc_set_send_xon_str,
4771 (void *)&cmd_lfc_set_send_xon,
4772 (void *)&cmd_lfc_set_portid,
4777 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4778 .f = cmd_link_flow_ctrl_set_parsed,
4779 .data = (void *)&cmd_link_flow_control_set_macfwd,
4780 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4781 "mac_ctrl_frame_fwd on|off port_id",
4783 (void *)&cmd_lfc_set_set,
4784 (void *)&cmd_lfc_set_flow_ctrl,
4785 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4786 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4787 (void *)&cmd_lfc_set_portid,
4792 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4793 .f = cmd_link_flow_ctrl_set_parsed,
4794 .data = (void *)&cmd_link_flow_control_set_autoneg,
4795 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4796 "autoneg on|off port_id",
4798 (void *)&cmd_lfc_set_set,
4799 (void *)&cmd_lfc_set_flow_ctrl,
4800 (void *)&cmd_lfc_set_autoneg_str,
4801 (void *)&cmd_lfc_set_autoneg,
4802 (void *)&cmd_lfc_set_portid,
4808 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4809 __attribute__((unused)) struct cmdline *cl,
4812 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4813 cmdline_parse_inst_t *cmd = data;
4814 struct rte_eth_fc_conf fc_conf;
4820 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4821 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4822 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4823 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4825 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4826 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4829 /* Partial command line, retrieve current configuration */
4831 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4833 printf("cannot get current flow ctrl parameters, return"
4834 "code = %d\n", ret);
4838 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4839 (fc_conf.mode == RTE_FC_FULL))
4841 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4842 (fc_conf.mode == RTE_FC_FULL))
4846 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4847 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4849 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4850 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4852 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4854 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4855 fc_conf.high_water = res->high_water;
4857 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4858 fc_conf.low_water = res->low_water;
4860 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4861 fc_conf.pause_time = res->pause_time;
4863 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4864 fc_conf.send_xon = res->send_xon;
4866 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4867 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4868 fc_conf.mac_ctrl_frame_fwd = 1;
4870 fc_conf.mac_ctrl_frame_fwd = 0;
4873 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4874 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4876 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4878 printf("bad flow contrl parameter, return code = %d \n", ret);
4881 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4882 struct cmd_priority_flow_ctrl_set_result {
4883 cmdline_fixed_string_t set;
4884 cmdline_fixed_string_t pfc_ctrl;
4885 cmdline_fixed_string_t rx;
4886 cmdline_fixed_string_t rx_pfc_mode;
4887 cmdline_fixed_string_t tx;
4888 cmdline_fixed_string_t tx_pfc_mode;
4889 uint32_t high_water;
4891 uint16_t pause_time;
4897 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4898 __attribute__((unused)) struct cmdline *cl,
4899 __attribute__((unused)) void *data)
4901 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4902 struct rte_eth_pfc_conf pfc_conf;
4903 int rx_fc_enable, tx_fc_enable;
4907 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4908 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4909 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4910 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4912 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4913 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4916 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4917 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4918 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4919 pfc_conf.fc.high_water = res->high_water;
4920 pfc_conf.fc.low_water = res->low_water;
4921 pfc_conf.fc.pause_time = res->pause_time;
4922 pfc_conf.priority = res->priority;
4924 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4926 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4929 cmdline_parse_token_string_t cmd_pfc_set_set =
4930 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4932 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4933 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4934 pfc_ctrl, "pfc_ctrl");
4935 cmdline_parse_token_string_t cmd_pfc_set_rx =
4936 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4938 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4939 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4940 rx_pfc_mode, "on#off");
4941 cmdline_parse_token_string_t cmd_pfc_set_tx =
4942 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4944 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4945 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4946 tx_pfc_mode, "on#off");
4947 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4948 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4949 high_water, UINT32);
4950 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4951 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4953 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4954 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4955 pause_time, UINT16);
4956 cmdline_parse_token_num_t cmd_pfc_set_priority =
4957 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4959 cmdline_parse_token_num_t cmd_pfc_set_portid =
4960 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4963 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4964 .f = cmd_priority_flow_ctrl_set_parsed,
4966 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4967 tx on|off high_water low_water pause_time priority port_id",
4969 (void *)&cmd_pfc_set_set,
4970 (void *)&cmd_pfc_set_flow_ctrl,
4971 (void *)&cmd_pfc_set_rx,
4972 (void *)&cmd_pfc_set_rx_mode,
4973 (void *)&cmd_pfc_set_tx,
4974 (void *)&cmd_pfc_set_tx_mode,
4975 (void *)&cmd_pfc_set_high_water,
4976 (void *)&cmd_pfc_set_low_water,
4977 (void *)&cmd_pfc_set_pause_time,
4978 (void *)&cmd_pfc_set_priority,
4979 (void *)&cmd_pfc_set_portid,
4984 /* *** RESET CONFIGURATION *** */
4985 struct cmd_reset_result {
4986 cmdline_fixed_string_t reset;
4987 cmdline_fixed_string_t def;
4990 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4992 __attribute__((unused)) void *data)
4994 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4995 set_def_fwd_config();
4998 cmdline_parse_token_string_t cmd_reset_set =
4999 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5000 cmdline_parse_token_string_t cmd_reset_def =
5001 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5004 cmdline_parse_inst_t cmd_reset = {
5005 .f = cmd_reset_parsed,
5007 .help_str = "set default: reset default forwarding configuration",
5009 (void *)&cmd_reset_set,
5010 (void *)&cmd_reset_def,
5015 /* *** START FORWARDING *** */
5016 struct cmd_start_result {
5017 cmdline_fixed_string_t start;
5020 cmdline_parse_token_string_t cmd_start_start =
5021 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5023 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5024 __attribute__((unused)) struct cmdline *cl,
5025 __attribute__((unused)) void *data)
5027 start_packet_forwarding(0);
5030 cmdline_parse_inst_t cmd_start = {
5031 .f = cmd_start_parsed,
5033 .help_str = "start packet forwarding",
5035 (void *)&cmd_start_start,
5040 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5041 struct cmd_start_tx_first_result {
5042 cmdline_fixed_string_t start;
5043 cmdline_fixed_string_t tx_first;
5047 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5048 __attribute__((unused)) struct cmdline *cl,
5049 __attribute__((unused)) void *data)
5051 start_packet_forwarding(1);
5054 cmdline_parse_token_string_t cmd_start_tx_first_start =
5055 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5057 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5058 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5059 tx_first, "tx_first");
5061 cmdline_parse_inst_t cmd_start_tx_first = {
5062 .f = cmd_start_tx_first_parsed,
5064 .help_str = "start packet forwarding, after sending 1 burst of packets",
5066 (void *)&cmd_start_tx_first_start,
5067 (void *)&cmd_start_tx_first_tx_first,
5072 /* *** SET LINK UP *** */
5073 struct cmd_set_link_up_result {
5074 cmdline_fixed_string_t set;
5075 cmdline_fixed_string_t link_up;
5076 cmdline_fixed_string_t port;
5080 cmdline_parse_token_string_t cmd_set_link_up_set =
5081 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5082 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5083 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5085 cmdline_parse_token_string_t cmd_set_link_up_port =
5086 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5087 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5088 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5090 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5091 __attribute__((unused)) struct cmdline *cl,
5092 __attribute__((unused)) void *data)
5094 struct cmd_set_link_up_result *res = parsed_result;
5095 dev_set_link_up(res->port_id);
5098 cmdline_parse_inst_t cmd_set_link_up = {
5099 .f = cmd_set_link_up_parsed,
5101 .help_str = "set link-up port (port id)",
5103 (void *)&cmd_set_link_up_set,
5104 (void *)&cmd_set_link_up_link_up,
5105 (void *)&cmd_set_link_up_port,
5106 (void *)&cmd_set_link_up_port_id,
5111 /* *** SET LINK DOWN *** */
5112 struct cmd_set_link_down_result {
5113 cmdline_fixed_string_t set;
5114 cmdline_fixed_string_t link_down;
5115 cmdline_fixed_string_t port;
5119 cmdline_parse_token_string_t cmd_set_link_down_set =
5120 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5121 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5122 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5124 cmdline_parse_token_string_t cmd_set_link_down_port =
5125 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5126 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5127 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5129 static void cmd_set_link_down_parsed(
5130 __attribute__((unused)) void *parsed_result,
5131 __attribute__((unused)) struct cmdline *cl,
5132 __attribute__((unused)) void *data)
5134 struct cmd_set_link_down_result *res = parsed_result;
5135 dev_set_link_down(res->port_id);
5138 cmdline_parse_inst_t cmd_set_link_down = {
5139 .f = cmd_set_link_down_parsed,
5141 .help_str = "set link-down port (port id)",
5143 (void *)&cmd_set_link_down_set,
5144 (void *)&cmd_set_link_down_link_down,
5145 (void *)&cmd_set_link_down_port,
5146 (void *)&cmd_set_link_down_port_id,
5151 /* *** SHOW CFG *** */
5152 struct cmd_showcfg_result {
5153 cmdline_fixed_string_t show;
5154 cmdline_fixed_string_t cfg;
5155 cmdline_fixed_string_t what;
5158 static void cmd_showcfg_parsed(void *parsed_result,
5159 __attribute__((unused)) struct cmdline *cl,
5160 __attribute__((unused)) void *data)
5162 struct cmd_showcfg_result *res = parsed_result;
5163 if (!strcmp(res->what, "rxtx"))
5164 rxtx_config_display();
5165 else if (!strcmp(res->what, "cores"))
5166 fwd_lcores_config_display();
5167 else if (!strcmp(res->what, "fwd"))
5168 fwd_config_display();
5171 cmdline_parse_token_string_t cmd_showcfg_show =
5172 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5173 cmdline_parse_token_string_t cmd_showcfg_port =
5174 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5175 cmdline_parse_token_string_t cmd_showcfg_what =
5176 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5179 cmdline_parse_inst_t cmd_showcfg = {
5180 .f = cmd_showcfg_parsed,
5182 .help_str = "show config rxtx|cores|fwd",
5184 (void *)&cmd_showcfg_show,
5185 (void *)&cmd_showcfg_port,
5186 (void *)&cmd_showcfg_what,
5191 /* *** SHOW ALL PORT INFO *** */
5192 struct cmd_showportall_result {
5193 cmdline_fixed_string_t show;
5194 cmdline_fixed_string_t port;
5195 cmdline_fixed_string_t what;
5196 cmdline_fixed_string_t all;
5199 static void cmd_showportall_parsed(void *parsed_result,
5200 __attribute__((unused)) struct cmdline *cl,
5201 __attribute__((unused)) void *data)
5205 struct cmd_showportall_result *res = parsed_result;
5206 if (!strcmp(res->show, "clear")) {
5207 if (!strcmp(res->what, "stats"))
5208 FOREACH_PORT(i, ports)
5210 else if (!strcmp(res->what, "xstats"))
5211 FOREACH_PORT(i, ports)
5212 nic_xstats_clear(i);
5213 } else if (!strcmp(res->what, "info"))
5214 FOREACH_PORT(i, ports)
5215 port_infos_display(i);
5216 else if (!strcmp(res->what, "stats"))
5217 FOREACH_PORT(i, ports)
5218 nic_stats_display(i);
5219 else if (!strcmp(res->what, "xstats"))
5220 FOREACH_PORT(i, ports)
5221 nic_xstats_display(i);
5222 else if (!strcmp(res->what, "fdir"))
5223 FOREACH_PORT(i, ports)
5225 else if (!strcmp(res->what, "stat_qmap"))
5226 FOREACH_PORT(i, ports)
5227 nic_stats_mapping_display(i);
5230 cmdline_parse_token_string_t cmd_showportall_show =
5231 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5233 cmdline_parse_token_string_t cmd_showportall_port =
5234 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5235 cmdline_parse_token_string_t cmd_showportall_what =
5236 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5237 "info#stats#xstats#fdir#stat_qmap");
5238 cmdline_parse_token_string_t cmd_showportall_all =
5239 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5240 cmdline_parse_inst_t cmd_showportall = {
5241 .f = cmd_showportall_parsed,
5243 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5245 (void *)&cmd_showportall_show,
5246 (void *)&cmd_showportall_port,
5247 (void *)&cmd_showportall_what,
5248 (void *)&cmd_showportall_all,
5253 /* *** SHOW PORT INFO *** */
5254 struct cmd_showport_result {
5255 cmdline_fixed_string_t show;
5256 cmdline_fixed_string_t port;
5257 cmdline_fixed_string_t what;
5261 static void cmd_showport_parsed(void *parsed_result,
5262 __attribute__((unused)) struct cmdline *cl,
5263 __attribute__((unused)) void *data)
5265 struct cmd_showport_result *res = parsed_result;
5266 if (!strcmp(res->show, "clear")) {
5267 if (!strcmp(res->what, "stats"))
5268 nic_stats_clear(res->portnum);
5269 else if (!strcmp(res->what, "xstats"))
5270 nic_xstats_clear(res->portnum);
5271 } else if (!strcmp(res->what, "info"))
5272 port_infos_display(res->portnum);
5273 else if (!strcmp(res->what, "stats"))
5274 nic_stats_display(res->portnum);
5275 else if (!strcmp(res->what, "xstats"))
5276 nic_xstats_display(res->portnum);
5277 else if (!strcmp(res->what, "fdir"))
5278 fdir_get_infos(res->portnum);
5279 else if (!strcmp(res->what, "stat_qmap"))
5280 nic_stats_mapping_display(res->portnum);
5283 cmdline_parse_token_string_t cmd_showport_show =
5284 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5286 cmdline_parse_token_string_t cmd_showport_port =
5287 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5288 cmdline_parse_token_string_t cmd_showport_what =
5289 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5290 "info#stats#xstats#fdir#stat_qmap");
5291 cmdline_parse_token_num_t cmd_showport_portnum =
5292 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5294 cmdline_parse_inst_t cmd_showport = {
5295 .f = cmd_showport_parsed,
5297 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5299 (void *)&cmd_showport_show,
5300 (void *)&cmd_showport_port,
5301 (void *)&cmd_showport_what,
5302 (void *)&cmd_showport_portnum,
5307 /* *** READ PORT REGISTER *** */
5308 struct cmd_read_reg_result {
5309 cmdline_fixed_string_t read;
5310 cmdline_fixed_string_t reg;
5316 cmd_read_reg_parsed(void *parsed_result,
5317 __attribute__((unused)) struct cmdline *cl,
5318 __attribute__((unused)) void *data)
5320 struct cmd_read_reg_result *res = parsed_result;
5321 port_reg_display(res->port_id, res->reg_off);
5324 cmdline_parse_token_string_t cmd_read_reg_read =
5325 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5326 cmdline_parse_token_string_t cmd_read_reg_reg =
5327 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5328 cmdline_parse_token_num_t cmd_read_reg_port_id =
5329 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5330 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5331 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5333 cmdline_parse_inst_t cmd_read_reg = {
5334 .f = cmd_read_reg_parsed,
5336 .help_str = "read reg port_id reg_off",
5338 (void *)&cmd_read_reg_read,
5339 (void *)&cmd_read_reg_reg,
5340 (void *)&cmd_read_reg_port_id,
5341 (void *)&cmd_read_reg_reg_off,
5346 /* *** READ PORT REGISTER BIT FIELD *** */
5347 struct cmd_read_reg_bit_field_result {
5348 cmdline_fixed_string_t read;
5349 cmdline_fixed_string_t regfield;
5357 cmd_read_reg_bit_field_parsed(void *parsed_result,
5358 __attribute__((unused)) struct cmdline *cl,
5359 __attribute__((unused)) void *data)
5361 struct cmd_read_reg_bit_field_result *res = parsed_result;
5362 port_reg_bit_field_display(res->port_id, res->reg_off,
5363 res->bit1_pos, res->bit2_pos);
5366 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5367 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5369 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5370 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5371 regfield, "regfield");
5372 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5373 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5375 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5376 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5378 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5379 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5381 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5382 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5385 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5386 .f = cmd_read_reg_bit_field_parsed,
5388 .help_str = "read regfield port_id reg_off bit_x bit_y "
5389 "(read register bit field between bit_x and bit_y included)",
5391 (void *)&cmd_read_reg_bit_field_read,
5392 (void *)&cmd_read_reg_bit_field_regfield,
5393 (void *)&cmd_read_reg_bit_field_port_id,
5394 (void *)&cmd_read_reg_bit_field_reg_off,
5395 (void *)&cmd_read_reg_bit_field_bit1_pos,
5396 (void *)&cmd_read_reg_bit_field_bit2_pos,
5401 /* *** READ PORT REGISTER BIT *** */
5402 struct cmd_read_reg_bit_result {
5403 cmdline_fixed_string_t read;
5404 cmdline_fixed_string_t regbit;
5411 cmd_read_reg_bit_parsed(void *parsed_result,
5412 __attribute__((unused)) struct cmdline *cl,
5413 __attribute__((unused)) void *data)
5415 struct cmd_read_reg_bit_result *res = parsed_result;
5416 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5419 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5420 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5421 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5422 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5424 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5425 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5426 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5427 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5428 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5429 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5431 cmdline_parse_inst_t cmd_read_reg_bit = {
5432 .f = cmd_read_reg_bit_parsed,
5434 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5436 (void *)&cmd_read_reg_bit_read,
5437 (void *)&cmd_read_reg_bit_regbit,
5438 (void *)&cmd_read_reg_bit_port_id,
5439 (void *)&cmd_read_reg_bit_reg_off,
5440 (void *)&cmd_read_reg_bit_bit_pos,
5445 /* *** WRITE PORT REGISTER *** */
5446 struct cmd_write_reg_result {
5447 cmdline_fixed_string_t write;
5448 cmdline_fixed_string_t reg;
5455 cmd_write_reg_parsed(void *parsed_result,
5456 __attribute__((unused)) struct cmdline *cl,
5457 __attribute__((unused)) void *data)
5459 struct cmd_write_reg_result *res = parsed_result;
5460 port_reg_set(res->port_id, res->reg_off, res->value);
5463 cmdline_parse_token_string_t cmd_write_reg_write =
5464 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5465 cmdline_parse_token_string_t cmd_write_reg_reg =
5466 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5467 cmdline_parse_token_num_t cmd_write_reg_port_id =
5468 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5469 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5470 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5471 cmdline_parse_token_num_t cmd_write_reg_value =
5472 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5474 cmdline_parse_inst_t cmd_write_reg = {
5475 .f = cmd_write_reg_parsed,
5477 .help_str = "write reg port_id reg_off reg_value",
5479 (void *)&cmd_write_reg_write,
5480 (void *)&cmd_write_reg_reg,
5481 (void *)&cmd_write_reg_port_id,
5482 (void *)&cmd_write_reg_reg_off,
5483 (void *)&cmd_write_reg_value,
5488 /* *** WRITE PORT REGISTER BIT FIELD *** */
5489 struct cmd_write_reg_bit_field_result {
5490 cmdline_fixed_string_t write;
5491 cmdline_fixed_string_t regfield;
5500 cmd_write_reg_bit_field_parsed(void *parsed_result,
5501 __attribute__((unused)) struct cmdline *cl,
5502 __attribute__((unused)) void *data)
5504 struct cmd_write_reg_bit_field_result *res = parsed_result;
5505 port_reg_bit_field_set(res->port_id, res->reg_off,
5506 res->bit1_pos, res->bit2_pos, res->value);
5509 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5510 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5512 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5513 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5514 regfield, "regfield");
5515 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5516 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5518 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5519 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5521 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5522 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5524 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5525 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5527 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5528 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5531 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5532 .f = cmd_write_reg_bit_field_parsed,
5534 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5535 "(set register bit field between bit_x and bit_y included)",
5537 (void *)&cmd_write_reg_bit_field_write,
5538 (void *)&cmd_write_reg_bit_field_regfield,
5539 (void *)&cmd_write_reg_bit_field_port_id,
5540 (void *)&cmd_write_reg_bit_field_reg_off,
5541 (void *)&cmd_write_reg_bit_field_bit1_pos,
5542 (void *)&cmd_write_reg_bit_field_bit2_pos,
5543 (void *)&cmd_write_reg_bit_field_value,
5548 /* *** WRITE PORT REGISTER BIT *** */
5549 struct cmd_write_reg_bit_result {
5550 cmdline_fixed_string_t write;
5551 cmdline_fixed_string_t regbit;
5559 cmd_write_reg_bit_parsed(void *parsed_result,
5560 __attribute__((unused)) struct cmdline *cl,
5561 __attribute__((unused)) void *data)
5563 struct cmd_write_reg_bit_result *res = parsed_result;
5564 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5567 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5568 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5570 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5571 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5573 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5574 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5575 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5576 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5577 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5578 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5579 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5580 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5582 cmdline_parse_inst_t cmd_write_reg_bit = {
5583 .f = cmd_write_reg_bit_parsed,
5585 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5587 (void *)&cmd_write_reg_bit_write,
5588 (void *)&cmd_write_reg_bit_regbit,
5589 (void *)&cmd_write_reg_bit_port_id,
5590 (void *)&cmd_write_reg_bit_reg_off,
5591 (void *)&cmd_write_reg_bit_bit_pos,
5592 (void *)&cmd_write_reg_bit_value,
5597 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5598 struct cmd_read_rxd_txd_result {
5599 cmdline_fixed_string_t read;
5600 cmdline_fixed_string_t rxd_txd;
5607 cmd_read_rxd_txd_parsed(void *parsed_result,
5608 __attribute__((unused)) struct cmdline *cl,
5609 __attribute__((unused)) void *data)
5611 struct cmd_read_rxd_txd_result *res = parsed_result;
5613 if (!strcmp(res->rxd_txd, "rxd"))
5614 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5615 else if (!strcmp(res->rxd_txd, "txd"))
5616 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5619 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5620 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5621 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5622 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5624 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5625 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5626 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5627 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5628 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5629 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5631 cmdline_parse_inst_t cmd_read_rxd_txd = {
5632 .f = cmd_read_rxd_txd_parsed,
5634 .help_str = "read rxd|txd port_id queue_id rxd_id",
5636 (void *)&cmd_read_rxd_txd_read,
5637 (void *)&cmd_read_rxd_txd_rxd_txd,
5638 (void *)&cmd_read_rxd_txd_port_id,
5639 (void *)&cmd_read_rxd_txd_queue_id,
5640 (void *)&cmd_read_rxd_txd_desc_id,
5646 struct cmd_quit_result {
5647 cmdline_fixed_string_t quit;
5650 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5652 __attribute__((unused)) void *data)
5658 cmdline_parse_token_string_t cmd_quit_quit =
5659 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5661 cmdline_parse_inst_t cmd_quit = {
5662 .f = cmd_quit_parsed,
5664 .help_str = "exit application",
5666 (void *)&cmd_quit_quit,
5671 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5672 struct cmd_mac_addr_result {
5673 cmdline_fixed_string_t mac_addr_cmd;
5674 cmdline_fixed_string_t what;
5676 struct ether_addr address;
5679 static void cmd_mac_addr_parsed(void *parsed_result,
5680 __attribute__((unused)) struct cmdline *cl,
5681 __attribute__((unused)) void *data)
5683 struct cmd_mac_addr_result *res = parsed_result;
5686 if (strcmp(res->what, "add") == 0)
5687 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5689 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5691 /* check the return value and print it if is < 0 */
5693 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5697 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5698 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5700 cmdline_parse_token_string_t cmd_mac_addr_what =
5701 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5703 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5704 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5705 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5706 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5708 cmdline_parse_inst_t cmd_mac_addr = {
5709 .f = cmd_mac_addr_parsed,
5711 .help_str = "mac_addr add|remove X <address>: "
5712 "add/remove MAC address on port X",
5714 (void *)&cmd_mac_addr_cmd,
5715 (void *)&cmd_mac_addr_what,
5716 (void *)&cmd_mac_addr_portnum,
5717 (void *)&cmd_mac_addr_addr,
5723 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5724 struct cmd_set_qmap_result {
5725 cmdline_fixed_string_t set;
5726 cmdline_fixed_string_t qmap;
5727 cmdline_fixed_string_t what;
5734 cmd_set_qmap_parsed(void *parsed_result,
5735 __attribute__((unused)) struct cmdline *cl,
5736 __attribute__((unused)) void *data)
5738 struct cmd_set_qmap_result *res = parsed_result;
5739 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5741 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5744 cmdline_parse_token_string_t cmd_setqmap_set =
5745 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5747 cmdline_parse_token_string_t cmd_setqmap_qmap =
5748 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5750 cmdline_parse_token_string_t cmd_setqmap_what =
5751 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5753 cmdline_parse_token_num_t cmd_setqmap_portid =
5754 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5756 cmdline_parse_token_num_t cmd_setqmap_queueid =
5757 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5759 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5760 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5763 cmdline_parse_inst_t cmd_set_qmap = {
5764 .f = cmd_set_qmap_parsed,
5766 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5768 (void *)&cmd_setqmap_set,
5769 (void *)&cmd_setqmap_qmap,
5770 (void *)&cmd_setqmap_what,
5771 (void *)&cmd_setqmap_portid,
5772 (void *)&cmd_setqmap_queueid,
5773 (void *)&cmd_setqmap_mapvalue,
5778 /* *** CONFIGURE UNICAST HASH TABLE *** */
5779 struct cmd_set_uc_hash_table {
5780 cmdline_fixed_string_t set;
5781 cmdline_fixed_string_t port;
5783 cmdline_fixed_string_t what;
5784 struct ether_addr address;
5785 cmdline_fixed_string_t mode;
5789 cmd_set_uc_hash_parsed(void *parsed_result,
5790 __attribute__((unused)) struct cmdline *cl,
5791 __attribute__((unused)) void *data)
5794 struct cmd_set_uc_hash_table *res = parsed_result;
5796 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5798 if (strcmp(res->what, "uta") == 0)
5799 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5800 &res->address,(uint8_t)is_on);
5802 printf("bad unicast hash table parameter, return code = %d \n", ret);
5806 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5807 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5809 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5810 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5812 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5813 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5815 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5816 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5818 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5819 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5821 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5822 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5825 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5826 .f = cmd_set_uc_hash_parsed,
5828 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5830 (void *)&cmd_set_uc_hash_set,
5831 (void *)&cmd_set_uc_hash_port,
5832 (void *)&cmd_set_uc_hash_portid,
5833 (void *)&cmd_set_uc_hash_what,
5834 (void *)&cmd_set_uc_hash_mac,
5835 (void *)&cmd_set_uc_hash_mode,
5840 struct cmd_set_uc_all_hash_table {
5841 cmdline_fixed_string_t set;
5842 cmdline_fixed_string_t port;
5844 cmdline_fixed_string_t what;
5845 cmdline_fixed_string_t value;
5846 cmdline_fixed_string_t mode;
5850 cmd_set_uc_all_hash_parsed(void *parsed_result,
5851 __attribute__((unused)) struct cmdline *cl,
5852 __attribute__((unused)) void *data)
5855 struct cmd_set_uc_all_hash_table *res = parsed_result;
5857 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5859 if ((strcmp(res->what, "uta") == 0) &&
5860 (strcmp(res->value, "all") == 0))
5861 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5863 printf("bad unicast hash table parameter,"
5864 "return code = %d \n", ret);
5867 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5868 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5870 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5871 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5873 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5874 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5876 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5877 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5879 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5880 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5882 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5883 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5886 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5887 .f = cmd_set_uc_all_hash_parsed,
5889 .help_str = "set port X uta all on|off (X = port number)",
5891 (void *)&cmd_set_uc_all_hash_set,
5892 (void *)&cmd_set_uc_all_hash_port,
5893 (void *)&cmd_set_uc_all_hash_portid,
5894 (void *)&cmd_set_uc_all_hash_what,
5895 (void *)&cmd_set_uc_all_hash_value,
5896 (void *)&cmd_set_uc_all_hash_mode,
5901 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5902 struct cmd_set_vf_macvlan_filter {
5903 cmdline_fixed_string_t set;
5904 cmdline_fixed_string_t port;
5906 cmdline_fixed_string_t vf;
5908 struct ether_addr address;
5909 cmdline_fixed_string_t filter_type;
5910 cmdline_fixed_string_t mode;
5914 cmd_set_vf_macvlan_parsed(void *parsed_result,
5915 __attribute__((unused)) struct cmdline *cl,
5916 __attribute__((unused)) void *data)
5919 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5920 struct rte_eth_mac_filter filter;
5922 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5924 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5926 /* set VF MAC filter */
5930 filter.dst_id = res->vf_id;
5932 if (!strcmp(res->filter_type, "exact-mac"))
5933 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5934 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5935 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5936 else if (!strcmp(res->filter_type, "hashmac"))
5937 filter.filter_type = RTE_MAC_HASH_MATCH;
5938 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5939 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5941 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5944 ret = rte_eth_dev_filter_ctrl(res->port_id,
5945 RTE_ETH_FILTER_MACVLAN,
5949 ret = rte_eth_dev_filter_ctrl(res->port_id,
5950 RTE_ETH_FILTER_MACVLAN,
5951 RTE_ETH_FILTER_DELETE,
5955 printf("bad set MAC hash parameter, return code = %d\n", ret);
5959 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5960 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5962 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5963 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5965 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5966 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5968 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5969 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5971 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5972 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5974 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5975 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5977 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5978 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5979 filter_type, "exact-mac#exact-mac-vlan"
5980 "#hashmac#hashmac-vlan");
5981 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5982 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5985 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5986 .f = cmd_set_vf_macvlan_parsed,
5988 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5989 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5991 "exact match rule:exact match of MAC or MAC and VLAN; "
5992 "hash match rule: hash match of MAC and exact match "
5995 (void *)&cmd_set_vf_macvlan_set,
5996 (void *)&cmd_set_vf_macvlan_port,
5997 (void *)&cmd_set_vf_macvlan_portid,
5998 (void *)&cmd_set_vf_macvlan_vf,
5999 (void *)&cmd_set_vf_macvlan_vf_id,
6000 (void *)&cmd_set_vf_macvlan_mac,
6001 (void *)&cmd_set_vf_macvlan_filter_type,
6002 (void *)&cmd_set_vf_macvlan_mode,
6007 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6008 struct cmd_set_vf_traffic {
6009 cmdline_fixed_string_t set;
6010 cmdline_fixed_string_t port;
6012 cmdline_fixed_string_t vf;
6014 cmdline_fixed_string_t what;
6015 cmdline_fixed_string_t mode;
6019 cmd_set_vf_traffic_parsed(void *parsed_result,
6020 __attribute__((unused)) struct cmdline *cl,
6021 __attribute__((unused)) void *data)
6023 struct cmd_set_vf_traffic *res = parsed_result;
6024 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6025 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6027 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6030 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6031 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6033 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6034 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6036 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6037 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6039 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6040 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6042 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6043 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6045 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6046 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6048 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6049 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6052 cmdline_parse_inst_t cmd_set_vf_traffic = {
6053 .f = cmd_set_vf_traffic_parsed,
6055 .help_str = "set port X vf Y rx|tx on|off"
6056 "(X = port number,Y = vf id)",
6058 (void *)&cmd_setvf_traffic_set,
6059 (void *)&cmd_setvf_traffic_port,
6060 (void *)&cmd_setvf_traffic_portid,
6061 (void *)&cmd_setvf_traffic_vf,
6062 (void *)&cmd_setvf_traffic_vfid,
6063 (void *)&cmd_setvf_traffic_what,
6064 (void *)&cmd_setvf_traffic_mode,
6069 /* *** CONFIGURE VF RECEIVE MODE *** */
6070 struct cmd_set_vf_rxmode {
6071 cmdline_fixed_string_t set;
6072 cmdline_fixed_string_t port;
6074 cmdline_fixed_string_t vf;
6076 cmdline_fixed_string_t what;
6077 cmdline_fixed_string_t mode;
6078 cmdline_fixed_string_t on;
6082 cmd_set_vf_rxmode_parsed(void *parsed_result,
6083 __attribute__((unused)) struct cmdline *cl,
6084 __attribute__((unused)) void *data)
6087 uint16_t rx_mode = 0;
6088 struct cmd_set_vf_rxmode *res = parsed_result;
6090 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6091 if (!strcmp(res->what,"rxmode")) {
6092 if (!strcmp(res->mode, "AUPE"))
6093 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6094 else if (!strcmp(res->mode, "ROPE"))
6095 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6096 else if (!strcmp(res->mode, "BAM"))
6097 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6098 else if (!strncmp(res->mode, "MPE",3))
6099 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6102 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6104 printf("bad VF receive mode parameter, return code = %d \n",
6108 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6109 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6111 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6112 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6114 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6115 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6117 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6118 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6120 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6121 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6123 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6124 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6126 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6127 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6128 mode, "AUPE#ROPE#BAM#MPE");
6129 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6130 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6133 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6134 .f = cmd_set_vf_rxmode_parsed,
6136 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6138 (void *)&cmd_set_vf_rxmode_set,
6139 (void *)&cmd_set_vf_rxmode_port,
6140 (void *)&cmd_set_vf_rxmode_portid,
6141 (void *)&cmd_set_vf_rxmode_vf,
6142 (void *)&cmd_set_vf_rxmode_vfid,
6143 (void *)&cmd_set_vf_rxmode_what,
6144 (void *)&cmd_set_vf_rxmode_mode,
6145 (void *)&cmd_set_vf_rxmode_on,
6150 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6151 struct cmd_vf_mac_addr_result {
6152 cmdline_fixed_string_t mac_addr_cmd;
6153 cmdline_fixed_string_t what;
6154 cmdline_fixed_string_t port;
6156 cmdline_fixed_string_t vf;
6158 struct ether_addr address;
6161 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6162 __attribute__((unused)) struct cmdline *cl,
6163 __attribute__((unused)) void *data)
6165 struct cmd_vf_mac_addr_result *res = parsed_result;
6168 if (strcmp(res->what, "add") == 0)
6169 ret = rte_eth_dev_mac_addr_add(res->port_num,
6170 &res->address, res->vf_num);
6172 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6176 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6177 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6178 mac_addr_cmd,"mac_addr");
6179 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6180 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6182 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6183 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6185 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6186 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6188 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6189 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6191 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6192 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6194 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6195 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6198 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6199 .f = cmd_vf_mac_addr_parsed,
6201 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6202 "Y = VF number)add MAC address filtering for a VF on port X",
6204 (void *)&cmd_vf_mac_addr_cmd,
6205 (void *)&cmd_vf_mac_addr_what,
6206 (void *)&cmd_vf_mac_addr_port,
6207 (void *)&cmd_vf_mac_addr_portnum,
6208 (void *)&cmd_vf_mac_addr_vf,
6209 (void *)&cmd_vf_mac_addr_vfnum,
6210 (void *)&cmd_vf_mac_addr_addr,
6215 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6216 struct cmd_vf_rx_vlan_filter {
6217 cmdline_fixed_string_t rx_vlan;
6218 cmdline_fixed_string_t what;
6220 cmdline_fixed_string_t port;
6222 cmdline_fixed_string_t vf;
6227 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6228 __attribute__((unused)) struct cmdline *cl,
6229 __attribute__((unused)) void *data)
6231 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6233 if (!strcmp(res->what, "add"))
6234 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6236 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6239 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6240 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6241 rx_vlan, "rx_vlan");
6242 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6243 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6245 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6246 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6248 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6249 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6251 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6252 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6254 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6255 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6257 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6258 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6261 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6262 .f = cmd_vf_rx_vlan_filter_parsed,
6264 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6265 "Y = port number,Z = hexadecimal VF mask)",
6267 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6268 (void *)&cmd_vf_rx_vlan_filter_what,
6269 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6270 (void *)&cmd_vf_rx_vlan_filter_port,
6271 (void *)&cmd_vf_rx_vlan_filter_portid,
6272 (void *)&cmd_vf_rx_vlan_filter_vf,
6273 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6278 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6279 struct cmd_queue_rate_limit_result {
6280 cmdline_fixed_string_t set;
6281 cmdline_fixed_string_t port;
6283 cmdline_fixed_string_t queue;
6285 cmdline_fixed_string_t rate;
6289 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6290 __attribute__((unused)) struct cmdline *cl,
6291 __attribute__((unused)) void *data)
6293 struct cmd_queue_rate_limit_result *res = parsed_result;
6296 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6297 && (strcmp(res->queue, "queue") == 0)
6298 && (strcmp(res->rate, "rate") == 0))
6299 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6302 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6306 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6307 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6309 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6310 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6312 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6313 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6315 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6316 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6318 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6319 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6321 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6322 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6324 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6325 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6328 cmdline_parse_inst_t cmd_queue_rate_limit = {
6329 .f = cmd_queue_rate_limit_parsed,
6331 .help_str = "set port X queue Y rate Z:(X = port number,"
6332 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6334 (void *)&cmd_queue_rate_limit_set,
6335 (void *)&cmd_queue_rate_limit_port,
6336 (void *)&cmd_queue_rate_limit_portnum,
6337 (void *)&cmd_queue_rate_limit_queue,
6338 (void *)&cmd_queue_rate_limit_queuenum,
6339 (void *)&cmd_queue_rate_limit_rate,
6340 (void *)&cmd_queue_rate_limit_ratenum,
6345 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6346 struct cmd_vf_rate_limit_result {
6347 cmdline_fixed_string_t set;
6348 cmdline_fixed_string_t port;
6350 cmdline_fixed_string_t vf;
6352 cmdline_fixed_string_t rate;
6354 cmdline_fixed_string_t q_msk;
6358 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6359 __attribute__((unused)) struct cmdline *cl,
6360 __attribute__((unused)) void *data)
6362 struct cmd_vf_rate_limit_result *res = parsed_result;
6365 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6366 && (strcmp(res->vf, "vf") == 0)
6367 && (strcmp(res->rate, "rate") == 0)
6368 && (strcmp(res->q_msk, "queue_mask") == 0))
6369 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6370 res->rate_num, res->q_msk_val);
6372 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6376 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6377 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6379 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6380 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6382 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6383 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6385 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6386 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6388 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6389 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6391 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6392 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6394 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6395 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6397 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6398 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6399 q_msk, "queue_mask");
6400 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6401 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6404 cmdline_parse_inst_t cmd_vf_rate_limit = {
6405 .f = cmd_vf_rate_limit_parsed,
6407 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6408 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6409 "for queues of VF on port X",
6411 (void *)&cmd_vf_rate_limit_set,
6412 (void *)&cmd_vf_rate_limit_port,
6413 (void *)&cmd_vf_rate_limit_portnum,
6414 (void *)&cmd_vf_rate_limit_vf,
6415 (void *)&cmd_vf_rate_limit_vfnum,
6416 (void *)&cmd_vf_rate_limit_rate,
6417 (void *)&cmd_vf_rate_limit_ratenum,
6418 (void *)&cmd_vf_rate_limit_q_msk,
6419 (void *)&cmd_vf_rate_limit_q_msk_val,
6424 /* *** ADD TUNNEL FILTER OF A PORT *** */
6425 struct cmd_tunnel_filter_result {
6426 cmdline_fixed_string_t cmd;
6427 cmdline_fixed_string_t what;
6429 struct ether_addr outer_mac;
6430 struct ether_addr inner_mac;
6431 cmdline_ipaddr_t ip_value;
6432 uint16_t inner_vlan;
6433 cmdline_fixed_string_t tunnel_type;
6434 cmdline_fixed_string_t filter_type;
6440 cmd_tunnel_filter_parsed(void *parsed_result,
6441 __attribute__((unused)) struct cmdline *cl,
6442 __attribute__((unused)) void *data)
6444 struct cmd_tunnel_filter_result *res = parsed_result;
6445 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6448 tunnel_filter_conf.outer_mac = &res->outer_mac;
6449 tunnel_filter_conf.inner_mac = &res->inner_mac;
6450 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6452 if (res->ip_value.family == AF_INET) {
6453 tunnel_filter_conf.ip_addr.ipv4_addr =
6454 res->ip_value.addr.ipv4.s_addr;
6455 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6457 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6458 &(res->ip_value.addr.ipv6),
6459 sizeof(struct in6_addr));
6460 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6463 if (!strcmp(res->filter_type, "imac-ivlan"))
6464 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6465 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6466 tunnel_filter_conf.filter_type =
6467 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6468 else if (!strcmp(res->filter_type, "imac-tenid"))
6469 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6470 else if (!strcmp(res->filter_type, "imac"))
6471 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6472 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6473 tunnel_filter_conf.filter_type =
6474 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6476 printf("The filter type is not supported");
6480 if (!strcmp(res->tunnel_type, "vxlan"))
6481 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6482 else if (!strcmp(res->tunnel_type, "nvgre"))
6483 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6485 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6489 tunnel_filter_conf.tenant_id = res->tenant_id;
6490 tunnel_filter_conf.queue_id = res->queue_num;
6491 if (!strcmp(res->what, "add"))
6492 ret = rte_eth_dev_filter_ctrl(res->port_id,
6493 RTE_ETH_FILTER_TUNNEL,
6495 &tunnel_filter_conf);
6497 ret = rte_eth_dev_filter_ctrl(res->port_id,
6498 RTE_ETH_FILTER_TUNNEL,
6499 RTE_ETH_FILTER_DELETE,
6500 &tunnel_filter_conf);
6502 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6506 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6507 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6508 cmd, "tunnel_filter");
6509 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6510 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6512 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6513 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6515 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6516 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6518 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6519 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6521 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6522 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6523 inner_vlan, UINT16);
6524 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6525 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6527 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6528 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6529 tunnel_type, "vxlan#nvgre");
6531 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6532 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6533 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6534 "imac#omac-imac-tenid");
6535 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6536 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6538 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6539 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6542 cmdline_parse_inst_t cmd_tunnel_filter = {
6543 .f = cmd_tunnel_filter_parsed,
6545 .help_str = "add/rm tunnel filter of a port: "
6546 "tunnel_filter add port_id outer_mac inner_mac ip "
6547 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6548 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6549 "imac|omac-imac-tenid) "
6550 "tenant_id queue_num",
6552 (void *)&cmd_tunnel_filter_cmd,
6553 (void *)&cmd_tunnel_filter_what,
6554 (void *)&cmd_tunnel_filter_port_id,
6555 (void *)&cmd_tunnel_filter_outer_mac,
6556 (void *)&cmd_tunnel_filter_inner_mac,
6557 (void *)&cmd_tunnel_filter_ip_value,
6558 (void *)&cmd_tunnel_filter_innner_vlan,
6559 (void *)&cmd_tunnel_filter_tunnel_type,
6560 (void *)&cmd_tunnel_filter_filter_type,
6561 (void *)&cmd_tunnel_filter_tenant_id,
6562 (void *)&cmd_tunnel_filter_queue_num,
6567 /* *** CONFIGURE TUNNEL UDP PORT *** */
6568 struct cmd_tunnel_udp_config {
6569 cmdline_fixed_string_t cmd;
6570 cmdline_fixed_string_t what;
6576 cmd_tunnel_udp_config_parsed(void *parsed_result,
6577 __attribute__((unused)) struct cmdline *cl,
6578 __attribute__((unused)) void *data)
6580 struct cmd_tunnel_udp_config *res = parsed_result;
6581 struct rte_eth_udp_tunnel tunnel_udp;
6584 tunnel_udp.udp_port = res->udp_port;
6586 if (!strcmp(res->cmd, "rx_vxlan_port"))
6587 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6589 if (!strcmp(res->what, "add"))
6590 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6592 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6595 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6598 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6599 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6600 cmd, "rx_vxlan_port");
6601 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6602 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6604 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6605 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6607 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6608 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6611 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6612 .f = cmd_tunnel_udp_config_parsed,
6614 .help_str = "add/rm an tunneling UDP port filter: "
6615 "rx_vxlan_port add udp_port port_id",
6617 (void *)&cmd_tunnel_udp_config_cmd,
6618 (void *)&cmd_tunnel_udp_config_what,
6619 (void *)&cmd_tunnel_udp_config_udp_port,
6620 (void *)&cmd_tunnel_udp_config_port_id,
6625 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6626 struct cmd_set_mirror_mask_result {
6627 cmdline_fixed_string_t set;
6628 cmdline_fixed_string_t port;
6630 cmdline_fixed_string_t mirror;
6632 cmdline_fixed_string_t what;
6633 cmdline_fixed_string_t value;
6634 cmdline_fixed_string_t dstpool;
6636 cmdline_fixed_string_t on;
6639 cmdline_parse_token_string_t cmd_mirror_mask_set =
6640 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6642 cmdline_parse_token_string_t cmd_mirror_mask_port =
6643 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6645 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6646 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6648 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6649 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6650 mirror, "mirror-rule");
6651 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6652 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6654 cmdline_parse_token_string_t cmd_mirror_mask_what =
6655 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6656 what, "pool-mirror-up#pool-mirror-down"
6658 cmdline_parse_token_string_t cmd_mirror_mask_value =
6659 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6661 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6662 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6663 dstpool, "dst-pool");
6664 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6665 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6667 cmdline_parse_token_string_t cmd_mirror_mask_on =
6668 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6672 cmd_set_mirror_mask_parsed(void *parsed_result,
6673 __attribute__((unused)) struct cmdline *cl,
6674 __attribute__((unused)) void *data)
6677 struct cmd_set_mirror_mask_result *res = parsed_result;
6678 struct rte_eth_mirror_conf mr_conf;
6680 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6682 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6684 mr_conf.dst_pool = res->dstpool_id;
6686 if (!strcmp(res->what, "pool-mirror-up")) {
6687 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6688 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6689 } else if (!strcmp(res->what, "pool-mirror-down")) {
6690 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6691 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6692 } else if (!strcmp(res->what, "vlan-mirror")) {
6693 mr_conf.rule_type = ETH_MIRROR_VLAN;
6694 nb_item = parse_item_list(res->value, "vlan",
6695 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6699 for (i = 0; i < nb_item; i++) {
6700 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6701 printf("Invalid vlan_id: must be < 4096\n");
6705 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6706 mr_conf.vlan.vlan_mask |= 1ULL << i;
6710 if (!strcmp(res->on, "on"))
6711 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6714 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6717 printf("mirror rule add error: (%s)\n", strerror(-ret));
6720 cmdline_parse_inst_t cmd_set_mirror_mask = {
6721 .f = cmd_set_mirror_mask_parsed,
6723 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
6724 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6726 (void *)&cmd_mirror_mask_set,
6727 (void *)&cmd_mirror_mask_port,
6728 (void *)&cmd_mirror_mask_portid,
6729 (void *)&cmd_mirror_mask_mirror,
6730 (void *)&cmd_mirror_mask_ruleid,
6731 (void *)&cmd_mirror_mask_what,
6732 (void *)&cmd_mirror_mask_value,
6733 (void *)&cmd_mirror_mask_dstpool,
6734 (void *)&cmd_mirror_mask_poolid,
6735 (void *)&cmd_mirror_mask_on,
6740 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6741 struct cmd_set_mirror_link_result {
6742 cmdline_fixed_string_t set;
6743 cmdline_fixed_string_t port;
6745 cmdline_fixed_string_t mirror;
6747 cmdline_fixed_string_t what;
6748 cmdline_fixed_string_t dstpool;
6750 cmdline_fixed_string_t on;
6753 cmdline_parse_token_string_t cmd_mirror_link_set =
6754 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6756 cmdline_parse_token_string_t cmd_mirror_link_port =
6757 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6759 cmdline_parse_token_num_t cmd_mirror_link_portid =
6760 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6762 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6763 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6764 mirror, "mirror-rule");
6765 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6766 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6768 cmdline_parse_token_string_t cmd_mirror_link_what =
6769 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6770 what, "uplink-mirror#downlink-mirror");
6771 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6772 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6773 dstpool, "dst-pool");
6774 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6775 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6777 cmdline_parse_token_string_t cmd_mirror_link_on =
6778 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6782 cmd_set_mirror_link_parsed(void *parsed_result,
6783 __attribute__((unused)) struct cmdline *cl,
6784 __attribute__((unused)) void *data)
6787 struct cmd_set_mirror_link_result *res = parsed_result;
6788 struct rte_eth_mirror_conf mr_conf;
6790 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6791 if (!strcmp(res->what, "uplink-mirror"))
6792 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
6794 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
6796 mr_conf.dst_pool = res->dstpool_id;
6798 if (!strcmp(res->on, "on"))
6799 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6802 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6805 /* check the return value and print it if is < 0 */
6807 printf("mirror rule add error: (%s)\n", strerror(-ret));
6811 cmdline_parse_inst_t cmd_set_mirror_link = {
6812 .f = cmd_set_mirror_link_parsed,
6814 .help_str = "set port X mirror-rule Y uplink-mirror|"
6815 "downlink-mirror dst-pool Z on|off",
6817 (void *)&cmd_mirror_link_set,
6818 (void *)&cmd_mirror_link_port,
6819 (void *)&cmd_mirror_link_portid,
6820 (void *)&cmd_mirror_link_mirror,
6821 (void *)&cmd_mirror_link_ruleid,
6822 (void *)&cmd_mirror_link_what,
6823 (void *)&cmd_mirror_link_dstpool,
6824 (void *)&cmd_mirror_link_poolid,
6825 (void *)&cmd_mirror_link_on,
6830 /* *** RESET VM MIRROR RULE *** */
6831 struct cmd_rm_mirror_rule_result {
6832 cmdline_fixed_string_t reset;
6833 cmdline_fixed_string_t port;
6835 cmdline_fixed_string_t mirror;
6839 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6840 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6842 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6843 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6845 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6846 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6848 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6849 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6850 mirror, "mirror-rule");
6851 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6852 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6856 cmd_reset_mirror_rule_parsed(void *parsed_result,
6857 __attribute__((unused)) struct cmdline *cl,
6858 __attribute__((unused)) void *data)
6861 struct cmd_set_mirror_link_result *res = parsed_result;
6863 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6865 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6868 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6869 .f = cmd_reset_mirror_rule_parsed,
6871 .help_str = "reset port X mirror-rule Y",
6873 (void *)&cmd_rm_mirror_rule_reset,
6874 (void *)&cmd_rm_mirror_rule_port,
6875 (void *)&cmd_rm_mirror_rule_portid,
6876 (void *)&cmd_rm_mirror_rule_mirror,
6877 (void *)&cmd_rm_mirror_rule_ruleid,
6882 /* ******************************************************************************** */
6884 struct cmd_dump_result {
6885 cmdline_fixed_string_t dump;
6889 dump_struct_sizes(void)
6891 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6892 DUMP_SIZE(struct rte_mbuf);
6893 DUMP_SIZE(struct rte_mempool);
6894 DUMP_SIZE(struct rte_ring);
6898 static void cmd_dump_parsed(void *parsed_result,
6899 __attribute__((unused)) struct cmdline *cl,
6900 __attribute__((unused)) void *data)
6902 struct cmd_dump_result *res = parsed_result;
6904 if (!strcmp(res->dump, "dump_physmem"))
6905 rte_dump_physmem_layout(stdout);
6906 else if (!strcmp(res->dump, "dump_memzone"))
6907 rte_memzone_dump(stdout);
6908 else if (!strcmp(res->dump, "dump_log_history"))
6909 rte_log_dump_history(stdout);
6910 else if (!strcmp(res->dump, "dump_struct_sizes"))
6911 dump_struct_sizes();
6912 else if (!strcmp(res->dump, "dump_ring"))
6913 rte_ring_list_dump(stdout);
6914 else if (!strcmp(res->dump, "dump_mempool"))
6915 rte_mempool_list_dump(stdout);
6916 else if (!strcmp(res->dump, "dump_devargs"))
6917 rte_eal_devargs_dump(stdout);
6920 cmdline_parse_token_string_t cmd_dump_dump =
6921 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6925 "dump_struct_sizes#"
6930 cmdline_parse_inst_t cmd_dump = {
6931 .f = cmd_dump_parsed, /* function to call */
6932 .data = NULL, /* 2nd arg of func */
6933 .help_str = "dump status",
6934 .tokens = { /* token list, NULL terminated */
6935 (void *)&cmd_dump_dump,
6940 /* ******************************************************************************** */
6942 struct cmd_dump_one_result {
6943 cmdline_fixed_string_t dump;
6944 cmdline_fixed_string_t name;
6947 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6948 __attribute__((unused)) void *data)
6950 struct cmd_dump_one_result *res = parsed_result;
6952 if (!strcmp(res->dump, "dump_ring")) {
6954 r = rte_ring_lookup(res->name);
6956 cmdline_printf(cl, "Cannot find ring\n");
6959 rte_ring_dump(stdout, r);
6960 } else if (!strcmp(res->dump, "dump_mempool")) {
6961 struct rte_mempool *mp;
6962 mp = rte_mempool_lookup(res->name);
6964 cmdline_printf(cl, "Cannot find mempool\n");
6967 rte_mempool_dump(stdout, mp);
6971 cmdline_parse_token_string_t cmd_dump_one_dump =
6972 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6973 "dump_ring#dump_mempool");
6975 cmdline_parse_token_string_t cmd_dump_one_name =
6976 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6978 cmdline_parse_inst_t cmd_dump_one = {
6979 .f = cmd_dump_one_parsed, /* function to call */
6980 .data = NULL, /* 2nd arg of func */
6981 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6982 .tokens = { /* token list, NULL terminated */
6983 (void *)&cmd_dump_one_dump,
6984 (void *)&cmd_dump_one_name,
6989 /* *** Add/Del syn filter *** */
6990 struct cmd_syn_filter_result {
6991 cmdline_fixed_string_t filter;
6993 cmdline_fixed_string_t ops;
6994 cmdline_fixed_string_t priority;
6995 cmdline_fixed_string_t high;
6996 cmdline_fixed_string_t queue;
7001 cmd_syn_filter_parsed(void *parsed_result,
7002 __attribute__((unused)) struct cmdline *cl,
7003 __attribute__((unused)) void *data)
7005 struct cmd_syn_filter_result *res = parsed_result;
7006 struct rte_eth_syn_filter syn_filter;
7009 ret = rte_eth_dev_filter_supported(res->port_id,
7010 RTE_ETH_FILTER_SYN);
7012 printf("syn filter is not supported on port %u.\n",
7017 memset(&syn_filter, 0, sizeof(syn_filter));
7019 if (!strcmp(res->ops, "add")) {
7020 if (!strcmp(res->high, "high"))
7021 syn_filter.hig_pri = 1;
7023 syn_filter.hig_pri = 0;
7025 syn_filter.queue = res->queue_id;
7026 ret = rte_eth_dev_filter_ctrl(res->port_id,
7031 ret = rte_eth_dev_filter_ctrl(res->port_id,
7033 RTE_ETH_FILTER_DELETE,
7037 printf("syn filter programming error: (%s)\n",
7041 cmdline_parse_token_string_t cmd_syn_filter_filter =
7042 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7043 filter, "syn_filter");
7044 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7045 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7047 cmdline_parse_token_string_t cmd_syn_filter_ops =
7048 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7050 cmdline_parse_token_string_t cmd_syn_filter_priority =
7051 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7052 priority, "priority");
7053 cmdline_parse_token_string_t cmd_syn_filter_high =
7054 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7056 cmdline_parse_token_string_t cmd_syn_filter_queue =
7057 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7059 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7060 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7063 cmdline_parse_inst_t cmd_syn_filter = {
7064 .f = cmd_syn_filter_parsed,
7066 .help_str = "add/delete syn filter",
7068 (void *)&cmd_syn_filter_filter,
7069 (void *)&cmd_syn_filter_port_id,
7070 (void *)&cmd_syn_filter_ops,
7071 (void *)&cmd_syn_filter_priority,
7072 (void *)&cmd_syn_filter_high,
7073 (void *)&cmd_syn_filter_queue,
7074 (void *)&cmd_syn_filter_queue_id,
7079 /* *** ADD/REMOVE A 2tuple FILTER *** */
7080 struct cmd_2tuple_filter_result {
7081 cmdline_fixed_string_t filter;
7083 cmdline_fixed_string_t ops;
7084 cmdline_fixed_string_t dst_port;
7085 uint16_t dst_port_value;
7086 cmdline_fixed_string_t protocol;
7087 uint8_t protocol_value;
7088 cmdline_fixed_string_t mask;
7090 cmdline_fixed_string_t tcp_flags;
7091 uint8_t tcp_flags_value;
7092 cmdline_fixed_string_t priority;
7093 uint8_t priority_value;
7094 cmdline_fixed_string_t queue;
7099 cmd_2tuple_filter_parsed(void *parsed_result,
7100 __attribute__((unused)) struct cmdline *cl,
7101 __attribute__((unused)) void *data)
7103 struct rte_eth_ntuple_filter filter;
7104 struct cmd_2tuple_filter_result *res = parsed_result;
7107 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7109 printf("ntuple filter is not supported on port %u.\n",
7114 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7116 filter.flags = RTE_2TUPLE_FLAGS;
7117 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7118 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7119 filter.proto = res->protocol_value;
7120 filter.priority = res->priority_value;
7121 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7122 printf("nonzero tcp_flags is only meaningful"
7123 " when protocol is TCP.\n");
7126 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7127 printf("invalid TCP flags.\n");
7131 if (res->tcp_flags_value != 0) {
7132 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7133 filter.tcp_flags = res->tcp_flags_value;
7136 /* need convert to big endian. */
7137 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7138 filter.queue = res->queue_id;
7140 if (!strcmp(res->ops, "add"))
7141 ret = rte_eth_dev_filter_ctrl(res->port_id,
7142 RTE_ETH_FILTER_NTUPLE,
7146 ret = rte_eth_dev_filter_ctrl(res->port_id,
7147 RTE_ETH_FILTER_NTUPLE,
7148 RTE_ETH_FILTER_DELETE,
7151 printf("2tuple filter programming error: (%s)\n",
7156 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7157 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7158 filter, "2tuple_filter");
7159 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7160 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7162 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7163 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7165 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7166 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7167 dst_port, "dst_port");
7168 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7169 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7170 dst_port_value, UINT16);
7171 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7172 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7173 protocol, "protocol");
7174 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7175 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7176 protocol_value, UINT8);
7177 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7178 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7180 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7181 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7183 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7184 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7185 tcp_flags, "tcp_flags");
7186 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7187 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7188 tcp_flags_value, UINT8);
7189 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7190 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7191 priority, "priority");
7192 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7193 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7194 priority_value, UINT8);
7195 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7196 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7198 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7199 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7202 cmdline_parse_inst_t cmd_2tuple_filter = {
7203 .f = cmd_2tuple_filter_parsed,
7205 .help_str = "add a 2tuple filter",
7207 (void *)&cmd_2tuple_filter_filter,
7208 (void *)&cmd_2tuple_filter_port_id,
7209 (void *)&cmd_2tuple_filter_ops,
7210 (void *)&cmd_2tuple_filter_dst_port,
7211 (void *)&cmd_2tuple_filter_dst_port_value,
7212 (void *)&cmd_2tuple_filter_protocol,
7213 (void *)&cmd_2tuple_filter_protocol_value,
7214 (void *)&cmd_2tuple_filter_mask,
7215 (void *)&cmd_2tuple_filter_mask_value,
7216 (void *)&cmd_2tuple_filter_tcp_flags,
7217 (void *)&cmd_2tuple_filter_tcp_flags_value,
7218 (void *)&cmd_2tuple_filter_priority,
7219 (void *)&cmd_2tuple_filter_priority_value,
7220 (void *)&cmd_2tuple_filter_queue,
7221 (void *)&cmd_2tuple_filter_queue_id,
7226 /* *** ADD/REMOVE A 5tuple FILTER *** */
7227 struct cmd_5tuple_filter_result {
7228 cmdline_fixed_string_t filter;
7230 cmdline_fixed_string_t ops;
7231 cmdline_fixed_string_t dst_ip;
7232 cmdline_ipaddr_t dst_ip_value;
7233 cmdline_fixed_string_t src_ip;
7234 cmdline_ipaddr_t src_ip_value;
7235 cmdline_fixed_string_t dst_port;
7236 uint16_t dst_port_value;
7237 cmdline_fixed_string_t src_port;
7238 uint16_t src_port_value;
7239 cmdline_fixed_string_t protocol;
7240 uint8_t protocol_value;
7241 cmdline_fixed_string_t mask;
7243 cmdline_fixed_string_t tcp_flags;
7244 uint8_t tcp_flags_value;
7245 cmdline_fixed_string_t priority;
7246 uint8_t priority_value;
7247 cmdline_fixed_string_t queue;
7252 cmd_5tuple_filter_parsed(void *parsed_result,
7253 __attribute__((unused)) struct cmdline *cl,
7254 __attribute__((unused)) void *data)
7256 struct rte_eth_ntuple_filter filter;
7257 struct cmd_5tuple_filter_result *res = parsed_result;
7260 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7262 printf("ntuple filter is not supported on port %u.\n",
7267 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7269 filter.flags = RTE_5TUPLE_FLAGS;
7270 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7271 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7272 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7273 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7274 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7275 filter.proto = res->protocol_value;
7276 filter.priority = res->priority_value;
7277 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7278 printf("nonzero tcp_flags is only meaningful"
7279 " when protocol is TCP.\n");
7282 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7283 printf("invalid TCP flags.\n");
7287 if (res->tcp_flags_value != 0) {
7288 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7289 filter.tcp_flags = res->tcp_flags_value;
7292 if (res->dst_ip_value.family == AF_INET)
7293 /* no need to convert, already big endian. */
7294 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7296 if (filter.dst_ip_mask == 0) {
7297 printf("can not support ipv6 involved compare.\n");
7303 if (res->src_ip_value.family == AF_INET)
7304 /* no need to convert, already big endian. */
7305 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7307 if (filter.src_ip_mask == 0) {
7308 printf("can not support ipv6 involved compare.\n");
7313 /* need convert to big endian. */
7314 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7315 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7316 filter.queue = res->queue_id;
7318 if (!strcmp(res->ops, "add"))
7319 ret = rte_eth_dev_filter_ctrl(res->port_id,
7320 RTE_ETH_FILTER_NTUPLE,
7324 ret = rte_eth_dev_filter_ctrl(res->port_id,
7325 RTE_ETH_FILTER_NTUPLE,
7326 RTE_ETH_FILTER_DELETE,
7329 printf("5tuple filter programming error: (%s)\n",
7333 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7334 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7335 filter, "5tuple_filter");
7336 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7337 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7339 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7340 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7342 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7343 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7345 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7346 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7348 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7349 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7351 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7352 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7354 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7355 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7356 dst_port, "dst_port");
7357 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7358 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7359 dst_port_value, UINT16);
7360 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7361 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7362 src_port, "src_port");
7363 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7364 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7365 src_port_value, UINT16);
7366 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7367 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7368 protocol, "protocol");
7369 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7370 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7371 protocol_value, UINT8);
7372 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7373 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7375 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7376 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7378 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7379 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7380 tcp_flags, "tcp_flags");
7381 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7382 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7383 tcp_flags_value, UINT8);
7384 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7385 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7386 priority, "priority");
7387 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7388 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7389 priority_value, UINT8);
7390 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7391 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7393 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7394 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7397 cmdline_parse_inst_t cmd_5tuple_filter = {
7398 .f = cmd_5tuple_filter_parsed,
7400 .help_str = "add/del a 5tuple filter",
7402 (void *)&cmd_5tuple_filter_filter,
7403 (void *)&cmd_5tuple_filter_port_id,
7404 (void *)&cmd_5tuple_filter_ops,
7405 (void *)&cmd_5tuple_filter_dst_ip,
7406 (void *)&cmd_5tuple_filter_dst_ip_value,
7407 (void *)&cmd_5tuple_filter_src_ip,
7408 (void *)&cmd_5tuple_filter_src_ip_value,
7409 (void *)&cmd_5tuple_filter_dst_port,
7410 (void *)&cmd_5tuple_filter_dst_port_value,
7411 (void *)&cmd_5tuple_filter_src_port,
7412 (void *)&cmd_5tuple_filter_src_port_value,
7413 (void *)&cmd_5tuple_filter_protocol,
7414 (void *)&cmd_5tuple_filter_protocol_value,
7415 (void *)&cmd_5tuple_filter_mask,
7416 (void *)&cmd_5tuple_filter_mask_value,
7417 (void *)&cmd_5tuple_filter_tcp_flags,
7418 (void *)&cmd_5tuple_filter_tcp_flags_value,
7419 (void *)&cmd_5tuple_filter_priority,
7420 (void *)&cmd_5tuple_filter_priority_value,
7421 (void *)&cmd_5tuple_filter_queue,
7422 (void *)&cmd_5tuple_filter_queue_id,
7427 /* *** ADD/REMOVE A flex FILTER *** */
7428 struct cmd_flex_filter_result {
7429 cmdline_fixed_string_t filter;
7430 cmdline_fixed_string_t ops;
7432 cmdline_fixed_string_t len;
7434 cmdline_fixed_string_t bytes;
7435 cmdline_fixed_string_t bytes_value;
7436 cmdline_fixed_string_t mask;
7437 cmdline_fixed_string_t mask_value;
7438 cmdline_fixed_string_t priority;
7439 uint8_t priority_value;
7440 cmdline_fixed_string_t queue;
7444 static int xdigit2val(unsigned char c)
7449 else if (isupper(c))
7457 cmd_flex_filter_parsed(void *parsed_result,
7458 __attribute__((unused)) struct cmdline *cl,
7459 __attribute__((unused)) void *data)
7462 struct rte_eth_flex_filter filter;
7463 struct cmd_flex_filter_result *res = parsed_result;
7464 char *bytes_ptr, *mask_ptr;
7465 uint16_t len, i, j = 0;
7470 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7471 printf("the len exceed the max length 128\n");
7474 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7475 filter.len = res->len_value;
7476 filter.priority = res->priority_value;
7477 filter.queue = res->queue_id;
7478 bytes_ptr = res->bytes_value;
7479 mask_ptr = res->mask_value;
7481 /* translate bytes string to array. */
7482 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7483 (bytes_ptr[1] == 'X')))
7485 len = strnlen(bytes_ptr, res->len_value * 2);
7486 if (len == 0 || (len % 8 != 0)) {
7487 printf("please check len and bytes input\n");
7490 for (i = 0; i < len; i++) {
7492 if (isxdigit(c) == 0) {
7493 /* invalid characters. */
7494 printf("invalid input\n");
7497 val = xdigit2val(c);
7500 filter.bytes[j] = byte;
7501 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7508 /* translate mask string to uint8_t array. */
7509 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7510 (mask_ptr[1] == 'X')))
7512 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7514 printf("invalid input\n");
7519 for (i = 0; i < len; i++) {
7521 if (isxdigit(c) == 0) {
7522 /* invalid characters. */
7523 printf("invalid input\n");
7526 val = xdigit2val(c);
7529 filter.mask[j] = byte;
7530 printf("mask[%d]:%02x ", j, filter.mask[j]);
7538 if (!strcmp(res->ops, "add"))
7539 ret = rte_eth_dev_filter_ctrl(res->port_id,
7540 RTE_ETH_FILTER_FLEXIBLE,
7544 ret = rte_eth_dev_filter_ctrl(res->port_id,
7545 RTE_ETH_FILTER_FLEXIBLE,
7546 RTE_ETH_FILTER_DELETE,
7550 printf("flex filter setting error: (%s)\n", strerror(-ret));
7553 cmdline_parse_token_string_t cmd_flex_filter_filter =
7554 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7555 filter, "flex_filter");
7556 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7557 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7559 cmdline_parse_token_string_t cmd_flex_filter_ops =
7560 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7562 cmdline_parse_token_string_t cmd_flex_filter_len =
7563 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7565 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7566 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7568 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7569 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7571 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7572 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7574 cmdline_parse_token_string_t cmd_flex_filter_mask =
7575 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7577 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7578 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7580 cmdline_parse_token_string_t cmd_flex_filter_priority =
7581 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7582 priority, "priority");
7583 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7584 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7585 priority_value, UINT8);
7586 cmdline_parse_token_string_t cmd_flex_filter_queue =
7587 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7589 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7590 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7592 cmdline_parse_inst_t cmd_flex_filter = {
7593 .f = cmd_flex_filter_parsed,
7595 .help_str = "add/del a flex filter",
7597 (void *)&cmd_flex_filter_filter,
7598 (void *)&cmd_flex_filter_port_id,
7599 (void *)&cmd_flex_filter_ops,
7600 (void *)&cmd_flex_filter_len,
7601 (void *)&cmd_flex_filter_len_value,
7602 (void *)&cmd_flex_filter_bytes,
7603 (void *)&cmd_flex_filter_bytes_value,
7604 (void *)&cmd_flex_filter_mask,
7605 (void *)&cmd_flex_filter_mask_value,
7606 (void *)&cmd_flex_filter_priority,
7607 (void *)&cmd_flex_filter_priority_value,
7608 (void *)&cmd_flex_filter_queue,
7609 (void *)&cmd_flex_filter_queue_id,
7614 /* *** Filters Control *** */
7616 /* *** deal with ethertype filter *** */
7617 struct cmd_ethertype_filter_result {
7618 cmdline_fixed_string_t filter;
7620 cmdline_fixed_string_t ops;
7621 cmdline_fixed_string_t mac;
7622 struct ether_addr mac_addr;
7623 cmdline_fixed_string_t ethertype;
7624 uint16_t ethertype_value;
7625 cmdline_fixed_string_t drop;
7626 cmdline_fixed_string_t queue;
7630 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7631 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7632 filter, "ethertype_filter");
7633 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7634 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7636 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7637 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7639 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7640 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7641 mac, "mac_addr#mac_ignr");
7642 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7643 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7645 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7646 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7647 ethertype, "ethertype");
7648 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7649 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7650 ethertype_value, UINT16);
7651 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7652 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7654 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7655 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7657 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7658 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7662 cmd_ethertype_filter_parsed(void *parsed_result,
7663 __attribute__((unused)) struct cmdline *cl,
7664 __attribute__((unused)) void *data)
7666 struct cmd_ethertype_filter_result *res = parsed_result;
7667 struct rte_eth_ethertype_filter filter;
7670 ret = rte_eth_dev_filter_supported(res->port_id,
7671 RTE_ETH_FILTER_ETHERTYPE);
7673 printf("ethertype filter is not supported on port %u.\n",
7678 memset(&filter, 0, sizeof(filter));
7679 if (!strcmp(res->mac, "mac_addr")) {
7680 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7681 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7682 sizeof(struct ether_addr));
7684 if (!strcmp(res->drop, "drop"))
7685 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7686 filter.ether_type = res->ethertype_value;
7687 filter.queue = res->queue_id;
7689 if (!strcmp(res->ops, "add"))
7690 ret = rte_eth_dev_filter_ctrl(res->port_id,
7691 RTE_ETH_FILTER_ETHERTYPE,
7695 ret = rte_eth_dev_filter_ctrl(res->port_id,
7696 RTE_ETH_FILTER_ETHERTYPE,
7697 RTE_ETH_FILTER_DELETE,
7700 printf("ethertype filter programming error: (%s)\n",
7704 cmdline_parse_inst_t cmd_ethertype_filter = {
7705 .f = cmd_ethertype_filter_parsed,
7707 .help_str = "add or delete an ethertype filter entry",
7709 (void *)&cmd_ethertype_filter_filter,
7710 (void *)&cmd_ethertype_filter_port_id,
7711 (void *)&cmd_ethertype_filter_ops,
7712 (void *)&cmd_ethertype_filter_mac,
7713 (void *)&cmd_ethertype_filter_mac_addr,
7714 (void *)&cmd_ethertype_filter_ethertype,
7715 (void *)&cmd_ethertype_filter_ethertype_value,
7716 (void *)&cmd_ethertype_filter_drop,
7717 (void *)&cmd_ethertype_filter_queue,
7718 (void *)&cmd_ethertype_filter_queue_id,
7723 /* *** deal with flow director filter *** */
7724 struct cmd_flow_director_result {
7725 cmdline_fixed_string_t flow_director_filter;
7727 cmdline_fixed_string_t ops;
7728 cmdline_fixed_string_t flow;
7729 cmdline_fixed_string_t flow_type;
7730 cmdline_fixed_string_t ether;
7731 uint16_t ether_type;
7732 cmdline_fixed_string_t src;
7733 cmdline_ipaddr_t ip_src;
7735 cmdline_fixed_string_t dst;
7736 cmdline_ipaddr_t ip_dst;
7738 cmdline_fixed_string_t verify_tag;
7739 uint32_t verify_tag_value;
7740 cmdline_fixed_string_t vlan;
7741 uint16_t vlan_value;
7742 cmdline_fixed_string_t flexbytes;
7743 cmdline_fixed_string_t flexbytes_value;
7744 cmdline_fixed_string_t drop;
7745 cmdline_fixed_string_t queue;
7747 cmdline_fixed_string_t fd_id;
7748 uint32_t fd_id_value;
7752 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7755 const char *p, *p0 = q_arg;
7757 unsigned long int_fld;
7758 char *str_fld[max_num];
7763 p = strchr(p0, '(');
7767 p0 = strchr(p, ')');
7772 if (size >= sizeof(s))
7775 snprintf(s, sizeof(s), "%.*s", size, p);
7776 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7777 if (ret < 0 || ret > max_num)
7779 for (i = 0; i < ret; i++) {
7781 int_fld = strtoul(str_fld[i], &end, 0);
7782 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7784 flexbytes[i] = (uint8_t)int_fld;
7790 str2flowtype(char *string)
7793 static const struct {
7796 } flowtype_str[] = {
7797 {"raw", RTE_ETH_FLOW_RAW},
7798 {"ipv4", RTE_ETH_FLOW_IPV4},
7799 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
7800 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
7801 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
7802 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
7803 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
7804 {"ipv6", RTE_ETH_FLOW_IPV6},
7805 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
7806 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
7807 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
7808 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
7809 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
7810 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
7813 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7814 if (!strcmp(flowtype_str[i].str, string))
7815 return flowtype_str[i].type;
7817 return RTE_ETH_FLOW_UNKNOWN;
7820 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
7822 if ((ip_addr).family == AF_INET) \
7823 (ip) = (ip_addr).addr.ipv4.s_addr; \
7825 printf("invalid parameter.\n"); \
7830 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
7832 if ((ip_addr).family == AF_INET6) \
7833 (void)rte_memcpy(&(ip), \
7834 &((ip_addr).addr.ipv6), \
7835 sizeof(struct in6_addr)); \
7837 printf("invalid parameter.\n"); \
7843 cmd_flow_director_filter_parsed(void *parsed_result,
7844 __attribute__((unused)) struct cmdline *cl,
7845 __attribute__((unused)) void *data)
7847 struct cmd_flow_director_result *res = parsed_result;
7848 struct rte_eth_fdir_filter entry;
7849 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
7852 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7854 printf("flow director is not supported on port %u.\n",
7858 memset(flexbytes, 0, sizeof(flexbytes));
7859 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
7860 ret = parse_flexbytes(res->flexbytes_value,
7862 RTE_ETH_FDIR_MAX_FLEXLEN);
7864 printf("error: Cannot parse flexbytes input.\n");
7868 entry.input.flow_type = str2flowtype(res->flow_type);
7869 switch (entry.input.flow_type) {
7870 case RTE_ETH_FLOW_FRAG_IPV4:
7871 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
7872 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
7873 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
7874 IPV4_ADDR_TO_UINT(res->ip_dst,
7875 entry.input.flow.ip4_flow.dst_ip);
7876 IPV4_ADDR_TO_UINT(res->ip_src,
7877 entry.input.flow.ip4_flow.src_ip);
7878 /* need convert to big endian. */
7879 entry.input.flow.udp4_flow.dst_port =
7880 rte_cpu_to_be_16(res->port_dst);
7881 entry.input.flow.udp4_flow.src_port =
7882 rte_cpu_to_be_16(res->port_src);
7884 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
7885 IPV4_ADDR_TO_UINT(res->ip_dst,
7886 entry.input.flow.sctp4_flow.ip.dst_ip);
7887 IPV4_ADDR_TO_UINT(res->ip_src,
7888 entry.input.flow.sctp4_flow.ip.src_ip);
7889 /* need convert to big endian. */
7891 entry.input.flow.sctp4_flow.dst_port =
7892 rte_cpu_to_be_16(res->port_dst);
7893 entry.input.flow.sctp4_flow.src_port =
7894 rte_cpu_to_be_16(res->port_src);
7896 entry.input.flow.sctp4_flow.verify_tag =
7897 rte_cpu_to_be_32(res->verify_tag_value);
7899 case RTE_ETH_FLOW_FRAG_IPV6:
7900 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
7901 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
7902 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
7903 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7904 entry.input.flow.ipv6_flow.dst_ip);
7905 IPV6_ADDR_TO_ARRAY(res->ip_src,
7906 entry.input.flow.ipv6_flow.src_ip);
7907 /* need convert to big endian. */
7908 entry.input.flow.udp6_flow.dst_port =
7909 rte_cpu_to_be_16(res->port_dst);
7910 entry.input.flow.udp6_flow.src_port =
7911 rte_cpu_to_be_16(res->port_src);
7913 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
7914 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7915 entry.input.flow.sctp6_flow.ip.dst_ip);
7916 IPV6_ADDR_TO_ARRAY(res->ip_src,
7917 entry.input.flow.sctp6_flow.ip.src_ip);
7918 /* need convert to big endian. */
7920 entry.input.flow.sctp6_flow.dst_port =
7921 rte_cpu_to_be_16(res->port_dst);
7922 entry.input.flow.sctp6_flow.src_port =
7923 rte_cpu_to_be_16(res->port_src);
7925 entry.input.flow.sctp6_flow.verify_tag =
7926 rte_cpu_to_be_32(res->verify_tag_value);
7928 case RTE_ETH_FLOW_L2_PAYLOAD:
7929 entry.input.flow.l2_flow.ether_type =
7930 rte_cpu_to_be_16(res->ether_type);
7933 printf("invalid parameter.\n");
7936 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
7938 RTE_ETH_FDIR_MAX_FLEXLEN);
7940 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
7942 entry.action.flex_off = 0; /*use 0 by default */
7943 if (!strcmp(res->drop, "drop"))
7944 entry.action.behavior = RTE_ETH_FDIR_REJECT;
7946 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
7947 /* set to report FD ID by default */
7948 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
7949 entry.action.rx_queue = res->queue_id;
7950 entry.soft_id = res->fd_id_value;
7951 if (!strcmp(res->ops, "add"))
7952 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7953 RTE_ETH_FILTER_ADD, &entry);
7954 else if (!strcmp(res->ops, "del"))
7955 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7956 RTE_ETH_FILTER_DELETE, &entry);
7958 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7959 RTE_ETH_FILTER_UPDATE, &entry);
7961 printf("flow director programming error: (%s)\n",
7965 cmdline_parse_token_string_t cmd_flow_director_filter =
7966 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7967 flow_director_filter, "flow_director_filter");
7968 cmdline_parse_token_num_t cmd_flow_director_port_id =
7969 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7971 cmdline_parse_token_string_t cmd_flow_director_ops =
7972 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7973 ops, "add#del#update");
7974 cmdline_parse_token_string_t cmd_flow_director_flow =
7975 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7977 cmdline_parse_token_string_t cmd_flow_director_flow_type =
7978 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7979 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
7980 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
7981 cmdline_parse_token_string_t cmd_flow_director_ether =
7982 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7984 cmdline_parse_token_num_t cmd_flow_director_ether_type =
7985 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7986 ether_type, UINT16);
7987 cmdline_parse_token_string_t cmd_flow_director_src =
7988 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7990 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
7991 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7993 cmdline_parse_token_num_t cmd_flow_director_port_src =
7994 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7996 cmdline_parse_token_string_t cmd_flow_director_dst =
7997 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7999 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8000 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8002 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8003 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8005 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8006 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8007 verify_tag, "verify_tag");
8008 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8009 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8010 verify_tag_value, UINT32);
8011 cmdline_parse_token_string_t cmd_flow_director_vlan =
8012 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8014 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8015 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8016 vlan_value, UINT16);
8017 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8018 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8019 flexbytes, "flexbytes");
8020 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8021 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8022 flexbytes_value, NULL);
8023 cmdline_parse_token_string_t cmd_flow_director_drop =
8024 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8026 cmdline_parse_token_string_t cmd_flow_director_queue =
8027 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8029 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8030 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8032 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8033 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8035 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8036 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8037 fd_id_value, UINT32);
8039 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8040 .f = cmd_flow_director_filter_parsed,
8042 .help_str = "add or delete an ip flow director entry on NIC",
8044 (void *)&cmd_flow_director_filter,
8045 (void *)&cmd_flow_director_port_id,
8046 (void *)&cmd_flow_director_ops,
8047 (void *)&cmd_flow_director_flow,
8048 (void *)&cmd_flow_director_flow_type,
8049 (void *)&cmd_flow_director_src,
8050 (void *)&cmd_flow_director_ip_src,
8051 (void *)&cmd_flow_director_dst,
8052 (void *)&cmd_flow_director_ip_dst,
8053 (void *)&cmd_flow_director_vlan,
8054 (void *)&cmd_flow_director_vlan_value,
8055 (void *)&cmd_flow_director_flexbytes,
8056 (void *)&cmd_flow_director_flexbytes_value,
8057 (void *)&cmd_flow_director_drop,
8058 (void *)&cmd_flow_director_queue,
8059 (void *)&cmd_flow_director_queue_id,
8060 (void *)&cmd_flow_director_fd_id,
8061 (void *)&cmd_flow_director_fd_id_value,
8066 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8067 .f = cmd_flow_director_filter_parsed,
8069 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8071 (void *)&cmd_flow_director_filter,
8072 (void *)&cmd_flow_director_port_id,
8073 (void *)&cmd_flow_director_ops,
8074 (void *)&cmd_flow_director_flow,
8075 (void *)&cmd_flow_director_flow_type,
8076 (void *)&cmd_flow_director_src,
8077 (void *)&cmd_flow_director_ip_src,
8078 (void *)&cmd_flow_director_port_src,
8079 (void *)&cmd_flow_director_dst,
8080 (void *)&cmd_flow_director_ip_dst,
8081 (void *)&cmd_flow_director_port_dst,
8082 (void *)&cmd_flow_director_vlan,
8083 (void *)&cmd_flow_director_vlan_value,
8084 (void *)&cmd_flow_director_flexbytes,
8085 (void *)&cmd_flow_director_flexbytes_value,
8086 (void *)&cmd_flow_director_drop,
8087 (void *)&cmd_flow_director_queue,
8088 (void *)&cmd_flow_director_queue_id,
8089 (void *)&cmd_flow_director_fd_id,
8090 (void *)&cmd_flow_director_fd_id_value,
8095 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8096 .f = cmd_flow_director_filter_parsed,
8098 .help_str = "add or delete a sctp flow director entry on NIC",
8100 (void *)&cmd_flow_director_filter,
8101 (void *)&cmd_flow_director_port_id,
8102 (void *)&cmd_flow_director_ops,
8103 (void *)&cmd_flow_director_flow,
8104 (void *)&cmd_flow_director_flow_type,
8105 (void *)&cmd_flow_director_src,
8106 (void *)&cmd_flow_director_ip_src,
8107 (void *)&cmd_flow_director_port_dst,
8108 (void *)&cmd_flow_director_dst,
8109 (void *)&cmd_flow_director_ip_dst,
8110 (void *)&cmd_flow_director_port_dst,
8111 (void *)&cmd_flow_director_verify_tag,
8112 (void *)&cmd_flow_director_verify_tag_value,
8113 (void *)&cmd_flow_director_vlan,
8114 (void *)&cmd_flow_director_vlan_value,
8115 (void *)&cmd_flow_director_flexbytes,
8116 (void *)&cmd_flow_director_flexbytes_value,
8117 (void *)&cmd_flow_director_drop,
8118 (void *)&cmd_flow_director_queue,
8119 (void *)&cmd_flow_director_queue_id,
8120 (void *)&cmd_flow_director_fd_id,
8121 (void *)&cmd_flow_director_fd_id_value,
8126 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8127 .f = cmd_flow_director_filter_parsed,
8129 .help_str = "add or delete a L2 flow director entry on NIC",
8131 (void *)&cmd_flow_director_filter,
8132 (void *)&cmd_flow_director_port_id,
8133 (void *)&cmd_flow_director_ops,
8134 (void *)&cmd_flow_director_flow,
8135 (void *)&cmd_flow_director_flow_type,
8136 (void *)&cmd_flow_director_ether,
8137 (void *)&cmd_flow_director_ether_type,
8138 (void *)&cmd_flow_director_flexbytes,
8139 (void *)&cmd_flow_director_flexbytes_value,
8140 (void *)&cmd_flow_director_drop,
8141 (void *)&cmd_flow_director_queue,
8142 (void *)&cmd_flow_director_queue_id,
8143 (void *)&cmd_flow_director_fd_id,
8144 (void *)&cmd_flow_director_fd_id_value,
8149 struct cmd_flush_flow_director_result {
8150 cmdline_fixed_string_t flush_flow_director;
8154 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8155 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8156 flush_flow_director, "flush_flow_director");
8157 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8158 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8162 cmd_flush_flow_director_parsed(void *parsed_result,
8163 __attribute__((unused)) struct cmdline *cl,
8164 __attribute__((unused)) void *data)
8166 struct cmd_flow_director_result *res = parsed_result;
8169 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8171 printf("flow director is not supported on port %u.\n",
8176 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8177 RTE_ETH_FILTER_FLUSH, NULL);
8179 printf("flow director table flushing error: (%s)\n",
8183 cmdline_parse_inst_t cmd_flush_flow_director = {
8184 .f = cmd_flush_flow_director_parsed,
8186 .help_str = "flush all flow director entries of a device on NIC",
8188 (void *)&cmd_flush_flow_director_flush,
8189 (void *)&cmd_flush_flow_director_port_id,
8194 /* *** deal with flow director mask *** */
8195 struct cmd_flow_director_mask_result {
8196 cmdline_fixed_string_t flow_director_mask;
8198 cmdline_fixed_string_t vlan;
8199 uint16_t vlan_value;
8200 cmdline_fixed_string_t src_mask;
8201 cmdline_ipaddr_t ipv4_src;
8202 cmdline_ipaddr_t ipv6_src;
8204 cmdline_fixed_string_t dst_mask;
8205 cmdline_ipaddr_t ipv4_dst;
8206 cmdline_ipaddr_t ipv6_dst;
8211 cmd_flow_director_mask_parsed(void *parsed_result,
8212 __attribute__((unused)) struct cmdline *cl,
8213 __attribute__((unused)) void *data)
8215 struct cmd_flow_director_mask_result *res = parsed_result;
8216 struct rte_eth_fdir_masks *mask;
8217 struct rte_port *port;
8219 if (res->port_id > nb_ports) {
8220 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8224 port = &ports[res->port_id];
8225 /** Check if the port is not started **/
8226 if (port->port_status != RTE_PORT_STOPPED) {
8227 printf("Please stop port %d first\n", res->port_id);
8230 mask = &port->dev_conf.fdir_conf.mask;
8232 mask->vlan_tci_mask = res->vlan_value;
8233 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8234 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8235 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8236 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8237 mask->src_port_mask = res->port_src;
8238 mask->dst_port_mask = res->port_dst;
8240 cmd_reconfig_device_queue(res->port_id, 1, 1);
8243 cmdline_parse_token_string_t cmd_flow_director_mask =
8244 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8245 flow_director_mask, "flow_director_mask");
8246 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8247 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8249 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8250 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8252 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8253 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8254 vlan_value, UINT16);
8255 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8257 src_mask, "src_mask");
8258 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8259 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8261 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8262 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8264 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8265 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8267 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8269 dst_mask, "dst_mask");
8270 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8271 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8273 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8274 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8276 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8277 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8279 cmdline_parse_inst_t cmd_set_flow_director_mask = {
8280 .f = cmd_flow_director_mask_parsed,
8282 .help_str = "set flow director's mask on NIC",
8284 (void *)&cmd_flow_director_mask,
8285 (void *)&cmd_flow_director_mask_port_id,
8286 (void *)&cmd_flow_director_mask_vlan,
8287 (void *)&cmd_flow_director_mask_vlan_value,
8288 (void *)&cmd_flow_director_mask_src,
8289 (void *)&cmd_flow_director_mask_ipv4_src,
8290 (void *)&cmd_flow_director_mask_ipv6_src,
8291 (void *)&cmd_flow_director_mask_port_src,
8292 (void *)&cmd_flow_director_mask_dst,
8293 (void *)&cmd_flow_director_mask_ipv4_dst,
8294 (void *)&cmd_flow_director_mask_ipv6_dst,
8295 (void *)&cmd_flow_director_mask_port_dst,
8300 /* *** deal with flow director mask on flexible payload *** */
8301 struct cmd_flow_director_flex_mask_result {
8302 cmdline_fixed_string_t flow_director_flexmask;
8304 cmdline_fixed_string_t flow;
8305 cmdline_fixed_string_t flow_type;
8306 cmdline_fixed_string_t mask;
8310 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8311 __attribute__((unused)) struct cmdline *cl,
8312 __attribute__((unused)) void *data)
8314 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8315 struct rte_eth_fdir_info fdir_info;
8316 struct rte_eth_fdir_flex_mask flex_mask;
8317 struct rte_port *port;
8318 uint32_t flow_type_mask;
8322 if (res->port_id > nb_ports) {
8323 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8327 port = &ports[res->port_id];
8328 /** Check if the port is not started **/
8329 if (port->port_status != RTE_PORT_STOPPED) {
8330 printf("Please stop port %d first\n", res->port_id);
8334 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8335 ret = parse_flexbytes(res->mask,
8337 RTE_ETH_FDIR_MAX_FLEXLEN);
8339 printf("error: Cannot parse mask input.\n");
8343 memset(&fdir_info, 0, sizeof(fdir_info));
8344 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8345 RTE_ETH_FILTER_INFO, &fdir_info);
8347 printf("Cannot get FDir filter info\n");
8351 if (!strcmp(res->flow_type, "none")) {
8352 /* means don't specify the flow type */
8353 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8354 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8355 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8356 0, sizeof(struct rte_eth_fdir_flex_mask));
8357 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8358 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8360 sizeof(struct rte_eth_fdir_flex_mask));
8361 cmd_reconfig_device_queue(res->port_id, 1, 1);
8364 flow_type_mask = fdir_info.flow_types_mask[0];
8365 if (!strcmp(res->flow_type, "all")) {
8366 if (!flow_type_mask) {
8367 printf("No flow type supported\n");
8370 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8371 if (flow_type_mask & (1 << i)) {
8372 flex_mask.flow_type = i;
8373 fdir_set_flex_mask(res->port_id, &flex_mask);
8376 cmd_reconfig_device_queue(res->port_id, 1, 1);
8379 flex_mask.flow_type = str2flowtype(res->flow_type);
8380 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8381 printf("Flow type %s not supported on port %d\n",
8382 res->flow_type, res->port_id);
8385 fdir_set_flex_mask(res->port_id, &flex_mask);
8386 cmd_reconfig_device_queue(res->port_id, 1, 1);
8389 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8390 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8391 flow_director_flexmask,
8392 "flow_director_flex_mask");
8393 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8394 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8396 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8397 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8399 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8400 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8401 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8402 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8403 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8404 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8407 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8408 .f = cmd_flow_director_flex_mask_parsed,
8410 .help_str = "set flow director's flex mask on NIC",
8412 (void *)&cmd_flow_director_flexmask,
8413 (void *)&cmd_flow_director_flexmask_port_id,
8414 (void *)&cmd_flow_director_flexmask_flow,
8415 (void *)&cmd_flow_director_flexmask_flow_type,
8416 (void *)&cmd_flow_director_flexmask_mask,
8421 /* *** deal with flow director flexible payload configuration *** */
8422 struct cmd_flow_director_flexpayload_result {
8423 cmdline_fixed_string_t flow_director_flexpayload;
8425 cmdline_fixed_string_t payload_layer;
8426 cmdline_fixed_string_t payload_cfg;
8430 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8433 const char *p, *p0 = q_arg;
8435 unsigned long int_fld;
8436 char *str_fld[max_num];
8441 p = strchr(p0, '(');
8445 p0 = strchr(p, ')');
8450 if (size >= sizeof(s))
8453 snprintf(s, sizeof(s), "%.*s", size, p);
8454 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8455 if (ret < 0 || ret > max_num)
8457 for (i = 0; i < ret; i++) {
8459 int_fld = strtoul(str_fld[i], &end, 0);
8460 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8462 offsets[i] = (uint16_t)int_fld;
8468 cmd_flow_director_flxpld_parsed(void *parsed_result,
8469 __attribute__((unused)) struct cmdline *cl,
8470 __attribute__((unused)) void *data)
8472 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8473 struct rte_eth_flex_payload_cfg flex_cfg;
8474 struct rte_port *port;
8477 if (res->port_id > nb_ports) {
8478 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8482 port = &ports[res->port_id];
8483 /** Check if the port is not started **/
8484 if (port->port_status != RTE_PORT_STOPPED) {
8485 printf("Please stop port %d first\n", res->port_id);
8489 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8491 if (!strcmp(res->payload_layer, "raw"))
8492 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8493 else if (!strcmp(res->payload_layer, "l2"))
8494 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8495 else if (!strcmp(res->payload_layer, "l3"))
8496 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8497 else if (!strcmp(res->payload_layer, "l4"))
8498 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8500 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8501 RTE_ETH_FDIR_MAX_FLEXLEN);
8503 printf("error: Cannot parse flex payload input.\n");
8507 fdir_set_flex_payload(res->port_id, &flex_cfg);
8508 cmd_reconfig_device_queue(res->port_id, 1, 1);
8511 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8512 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8513 flow_director_flexpayload,
8514 "flow_director_flex_payload");
8515 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8516 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8518 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8519 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8520 payload_layer, "raw#l2#l3#l4");
8521 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8522 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8525 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8526 .f = cmd_flow_director_flxpld_parsed,
8528 .help_str = "set flow director's flex payload on NIC",
8530 (void *)&cmd_flow_director_flexpayload,
8531 (void *)&cmd_flow_director_flexpayload_port_id,
8532 (void *)&cmd_flow_director_flexpayload_payload_layer,
8533 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8538 /* *** Classification Filters Control *** */
8539 /* *** Get symmetric hash enable per port *** */
8540 struct cmd_get_sym_hash_ena_per_port_result {
8541 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8546 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8547 __rte_unused struct cmdline *cl,
8548 __rte_unused void *data)
8550 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8551 struct rte_eth_hash_filter_info info;
8554 if (rte_eth_dev_filter_supported(res->port_id,
8555 RTE_ETH_FILTER_HASH) < 0) {
8556 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8561 memset(&info, 0, sizeof(info));
8562 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8563 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8564 RTE_ETH_FILTER_GET, &info);
8567 printf("Cannot get symmetric hash enable per port "
8568 "on port %u\n", res->port_id);
8572 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8573 "enabled" : "disabled", res->port_id);
8576 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8577 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8578 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8579 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8580 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8583 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8584 .f = cmd_get_sym_hash_per_port_parsed,
8586 .help_str = "get_sym_hash_ena_per_port port_id",
8588 (void *)&cmd_get_sym_hash_ena_per_port_all,
8589 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8594 /* *** Set symmetric hash enable per port *** */
8595 struct cmd_set_sym_hash_ena_per_port_result {
8596 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8597 cmdline_fixed_string_t enable;
8602 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8603 __rte_unused struct cmdline *cl,
8604 __rte_unused void *data)
8606 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8607 struct rte_eth_hash_filter_info info;
8610 if (rte_eth_dev_filter_supported(res->port_id,
8611 RTE_ETH_FILTER_HASH) < 0) {
8612 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8617 memset(&info, 0, sizeof(info));
8618 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8619 if (!strcmp(res->enable, "enable"))
8620 info.info.enable = 1;
8621 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8622 RTE_ETH_FILTER_SET, &info);
8624 printf("Cannot set symmetric hash enable per port on "
8625 "port %u\n", res->port_id);
8628 printf("Symmetric hash has been set to %s on port %u\n",
8629 res->enable, res->port_id);
8632 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8633 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8634 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8635 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8636 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8638 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8639 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8640 enable, "enable#disable");
8642 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8643 .f = cmd_set_sym_hash_per_port_parsed,
8645 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8647 (void *)&cmd_set_sym_hash_ena_per_port_all,
8648 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8649 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8654 /* Get global config of hash function */
8655 struct cmd_get_hash_global_config_result {
8656 cmdline_fixed_string_t get_hash_global_config;
8661 flowtype_to_str(uint16_t ftype)
8668 {"ipv4", RTE_ETH_FLOW_IPV4},
8669 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8670 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8671 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8672 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8673 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8674 {"ipv6", RTE_ETH_FLOW_IPV6},
8675 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8676 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8677 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8678 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8679 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8680 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8683 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8684 if (ftype_table[i].ftype == ftype)
8685 return ftype_table[i].str;
8692 cmd_get_hash_global_config_parsed(void *parsed_result,
8693 __rte_unused struct cmdline *cl,
8694 __rte_unused void *data)
8696 struct cmd_get_hash_global_config_result *res = parsed_result;
8697 struct rte_eth_hash_filter_info info;
8698 uint32_t idx, offset;
8703 if (rte_eth_dev_filter_supported(res->port_id,
8704 RTE_ETH_FILTER_HASH) < 0) {
8705 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8710 memset(&info, 0, sizeof(info));
8711 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8712 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8713 RTE_ETH_FILTER_GET, &info);
8715 printf("Cannot get hash global configurations by port %d\n",
8720 switch (info.info.global_conf.hash_func) {
8721 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8722 printf("Hash function is Toeplitz\n");
8724 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8725 printf("Hash function is Simple XOR\n");
8728 printf("Unknown hash function\n");
8732 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
8733 idx = i / UINT32_BIT;
8734 offset = i % UINT32_BIT;
8735 if (!(info.info.global_conf.valid_bit_mask[idx] &
8738 str = flowtype_to_str(i);
8741 printf("Symmetric hash is %s globally for flow type %s "
8743 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8744 (1UL << offset)) ? "enabled" : "disabled"), str,
8749 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8750 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8751 get_hash_global_config, "get_hash_global_config");
8752 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8753 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8756 cmdline_parse_inst_t cmd_get_hash_global_config = {
8757 .f = cmd_get_hash_global_config_parsed,
8759 .help_str = "get_hash_global_config port_id",
8761 (void *)&cmd_get_hash_global_config_all,
8762 (void *)&cmd_get_hash_global_config_port_id,
8767 /* Set global config of hash function */
8768 struct cmd_set_hash_global_config_result {
8769 cmdline_fixed_string_t set_hash_global_config;
8771 cmdline_fixed_string_t hash_func;
8772 cmdline_fixed_string_t flow_type;
8773 cmdline_fixed_string_t enable;
8777 cmd_set_hash_global_config_parsed(void *parsed_result,
8778 __rte_unused struct cmdline *cl,
8779 __rte_unused void *data)
8781 struct cmd_set_hash_global_config_result *res = parsed_result;
8782 struct rte_eth_hash_filter_info info;
8783 uint32_t ftype, idx, offset;
8786 if (rte_eth_dev_filter_supported(res->port_id,
8787 RTE_ETH_FILTER_HASH) < 0) {
8788 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8792 memset(&info, 0, sizeof(info));
8793 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8794 if (!strcmp(res->hash_func, "toeplitz"))
8795 info.info.global_conf.hash_func =
8796 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8797 else if (!strcmp(res->hash_func, "simple_xor"))
8798 info.info.global_conf.hash_func =
8799 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8800 else if (!strcmp(res->hash_func, "default"))
8801 info.info.global_conf.hash_func =
8802 RTE_ETH_HASH_FUNCTION_DEFAULT;
8804 ftype = str2flowtype(res->flow_type);
8805 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8806 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8807 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8808 if (!strcmp(res->enable, "enable"))
8809 info.info.global_conf.sym_hash_enable_mask[idx] |=
8811 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8812 RTE_ETH_FILTER_SET, &info);
8814 printf("Cannot set global hash configurations by port %d\n",
8817 printf("Global hash configurations have been set "
8818 "succcessfully by port %d\n", res->port_id);
8821 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8822 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8823 set_hash_global_config, "set_hash_global_config");
8824 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8825 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8827 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8828 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8829 hash_func, "toeplitz#simple_xor#default");
8830 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8831 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8833 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
8834 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
8835 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8836 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8837 enable, "enable#disable");
8839 cmdline_parse_inst_t cmd_set_hash_global_config = {
8840 .f = cmd_set_hash_global_config_parsed,
8842 .help_str = "set_hash_global_config port_id "
8843 "toeplitz|simple_xor|default "
8844 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
8845 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
8848 (void *)&cmd_set_hash_global_config_all,
8849 (void *)&cmd_set_hash_global_config_port_id,
8850 (void *)&cmd_set_hash_global_config_hash_func,
8851 (void *)&cmd_set_hash_global_config_flow_type,
8852 (void *)&cmd_set_hash_global_config_enable,
8857 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
8858 struct cmd_mcast_addr_result {
8859 cmdline_fixed_string_t mcast_addr_cmd;
8860 cmdline_fixed_string_t what;
8862 struct ether_addr mc_addr;
8865 static void cmd_mcast_addr_parsed(void *parsed_result,
8866 __attribute__((unused)) struct cmdline *cl,
8867 __attribute__((unused)) void *data)
8869 struct cmd_mcast_addr_result *res = parsed_result;
8871 if (!is_multicast_ether_addr(&res->mc_addr)) {
8872 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
8873 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
8874 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
8875 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
8878 if (strcmp(res->what, "add") == 0)
8879 mcast_addr_add(res->port_num, &res->mc_addr);
8881 mcast_addr_remove(res->port_num, &res->mc_addr);
8884 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
8885 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
8886 mcast_addr_cmd, "mcast_addr");
8887 cmdline_parse_token_string_t cmd_mcast_addr_what =
8888 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
8890 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
8891 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
8892 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
8893 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8895 cmdline_parse_inst_t cmd_mcast_addr = {
8896 .f = cmd_mcast_addr_parsed,
8898 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
8900 (void *)&cmd_mcast_addr_cmd,
8901 (void *)&cmd_mcast_addr_what,
8902 (void *)&cmd_mcast_addr_portnum,
8903 (void *)&cmd_mcast_addr_addr,
8908 /* ******************************************************************************** */
8910 /* list of instructions */
8911 cmdline_parse_ctx_t main_ctx[] = {
8912 (cmdline_parse_inst_t *)&cmd_help_brief,
8913 (cmdline_parse_inst_t *)&cmd_help_long,
8914 (cmdline_parse_inst_t *)&cmd_quit,
8915 (cmdline_parse_inst_t *)&cmd_showport,
8916 (cmdline_parse_inst_t *)&cmd_showportall,
8917 (cmdline_parse_inst_t *)&cmd_showcfg,
8918 (cmdline_parse_inst_t *)&cmd_start,
8919 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8920 (cmdline_parse_inst_t *)&cmd_set_link_up,
8921 (cmdline_parse_inst_t *)&cmd_set_link_down,
8922 (cmdline_parse_inst_t *)&cmd_reset,
8923 (cmdline_parse_inst_t *)&cmd_set_numbers,
8924 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8925 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8926 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8927 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8928 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8929 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8930 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8931 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8932 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8933 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8934 (cmdline_parse_inst_t *)&cmd_set_link_check,
8935 #ifdef RTE_NIC_BYPASS
8936 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8937 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8938 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8939 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8941 #ifdef RTE_LIBRTE_PMD_BOND
8942 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8943 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8944 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8945 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8946 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8947 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8948 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8949 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8950 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8952 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8953 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8954 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8955 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8956 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8957 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
8958 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8959 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8960 (cmdline_parse_inst_t *)&cmd_csum_set,
8961 (cmdline_parse_inst_t *)&cmd_csum_show,
8962 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
8963 (cmdline_parse_inst_t *)&cmd_tso_set,
8964 (cmdline_parse_inst_t *)&cmd_tso_show,
8965 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8966 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8967 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8968 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8969 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8970 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8971 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8972 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8973 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8974 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8975 (cmdline_parse_inst_t *)&cmd_config_dcb,
8976 (cmdline_parse_inst_t *)&cmd_read_reg,
8977 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8978 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8979 (cmdline_parse_inst_t *)&cmd_write_reg,
8980 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8981 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8982 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8983 (cmdline_parse_inst_t *)&cmd_stop,
8984 (cmdline_parse_inst_t *)&cmd_mac_addr,
8985 (cmdline_parse_inst_t *)&cmd_set_qmap,
8986 (cmdline_parse_inst_t *)&cmd_operate_port,
8987 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8988 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
8989 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
8990 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8991 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8992 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8993 (cmdline_parse_inst_t *)&cmd_config_mtu,
8994 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8995 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8996 (cmdline_parse_inst_t *)&cmd_config_rss,
8997 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8998 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8999 (cmdline_parse_inst_t *)&cmd_showport_reta,
9000 (cmdline_parse_inst_t *)&cmd_config_burst,
9001 (cmdline_parse_inst_t *)&cmd_config_thresh,
9002 (cmdline_parse_inst_t *)&cmd_config_threshold,
9003 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9004 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9005 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9006 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9007 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9008 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9009 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9010 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9011 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9012 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9013 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9014 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9015 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9016 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9017 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9018 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9019 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9020 (cmdline_parse_inst_t *)&cmd_dump,
9021 (cmdline_parse_inst_t *)&cmd_dump_one,
9022 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9023 (cmdline_parse_inst_t *)&cmd_syn_filter,
9024 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
9025 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
9026 (cmdline_parse_inst_t *)&cmd_flex_filter,
9027 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9028 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9029 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9030 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
9031 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9032 (cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
9033 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9034 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9035 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9036 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9037 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9038 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9039 (cmdline_parse_inst_t *)&cmd_mcast_addr,
9043 /* prompt function, called from main on MASTER lcore */
9049 /* initialize non-constant commands */
9050 cmd_set_fwd_mode_init();
9052 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9056 cmdline_interact(cl);
9057 cmdline_stdin_exit(cl);
9061 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9063 if (id == (portid_t)RTE_PORT_ALL) {
9066 FOREACH_PORT(pid, ports) {
9067 /* check if need_reconfig has been set to 1 */
9068 if (ports[pid].need_reconfig == 0)
9069 ports[pid].need_reconfig = dev;
9070 /* check if need_reconfig_queues has been set to 1 */
9071 if (ports[pid].need_reconfig_queues == 0)
9072 ports[pid].need_reconfig_queues = queue;
9074 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
9075 /* check if need_reconfig has been set to 1 */
9076 if (ports[id].need_reconfig == 0)
9077 ports[id].need_reconfig = dev;
9078 /* check if need_reconfig_queues has been set to 1 */
9079 if (ports[id].need_reconfig_queues == 0)
9080 ports[id].need_reconfig_queues = queue;
9084 #ifdef RTE_NIC_BYPASS
9086 bypass_is_supported(portid_t port_id)
9088 struct rte_port *port;
9089 struct rte_pci_id *pci_id;
9091 if (port_id_is_invalid(port_id, ENABLED_WARN))
9094 /* Get the device id. */
9095 port = &ports[port_id];
9096 pci_id = &port->dev_info.pci_dev->id;
9098 /* Check if NIC supports bypass. */
9099 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9103 printf("\tBypass not supported for port_id = %d.\n", port_id);