4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_malloc.h>
63 #include <rte_launch.h>
64 #include <rte_tailq.h>
66 #include <rte_per_lcore.h>
67 #include <rte_lcore.h>
68 #include <rte_atomic.h>
69 #include <rte_branch_prediction.h>
71 #include <rte_mempool.h>
72 #include <rte_interrupts.h>
74 #include <rte_ether.h>
75 #include <rte_ethdev.h>
76 #include <rte_string_fns.h>
77 #include <rte_devargs.h>
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 flowdir : Flow Director filter help.\n"
119 " help registers : Reading and setting port registers.\n"
120 " help filters : Filters configuration help.\n"
121 " help all : All of the above sections.\n\n"
126 cmdline_parse_token_string_t cmd_help_brief_help =
127 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
129 cmdline_parse_inst_t cmd_help_brief = {
130 .f = cmd_help_brief_parsed,
132 .help_str = "show help",
134 (void *)&cmd_help_brief_help,
139 /* *** Help command with help sections. *** */
140 struct cmd_help_long_result {
141 cmdline_fixed_string_t help;
142 cmdline_fixed_string_t section;
145 static void cmd_help_long_parsed(void *parsed_result,
147 __attribute__((unused)) void *data)
150 struct cmd_help_long_result *res = parsed_result;
152 if (!strcmp(res->section, "all"))
155 if (show_all || !strcmp(res->section, "control")) {
160 "Control forwarding:\n"
161 "-------------------\n\n"
164 " Start packet forwarding with current configuration.\n\n"
167 " Start packet forwarding with current config"
168 " after sending one burst of packets.\n\n"
171 " Stop packet forwarding, and display accumulated"
175 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
179 if (show_all || !strcmp(res->section, "display")) {
187 "show port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
188 " Display information for port_id, or all.\n\n"
190 "show port X rss reta (size) (mask0,mask1,...)\n"
191 " Display the rss redirection table entry indicated"
192 " by masks on port X. size is used to indicate the"
193 " hardware supported reta size\n\n"
195 "show port rss-hash [key]\n"
196 " Display the RSS hash functions and RSS hash key"
199 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
200 " Clear information for port_id, or all.\n\n"
202 "show config (rxtx|cores|fwd)\n"
203 " Display the given configuration.\n\n"
205 "read rxd (port_id) (queue_id) (rxd_id)\n"
206 " Display an RX descriptor of a port RX queue.\n\n"
208 "read txd (port_id) (queue_id) (txd_id)\n"
209 " Display a TX descriptor of a port TX queue.\n\n"
213 if (show_all || !strcmp(res->section, "config")) {
219 "Configuration changes only become active when"
220 " forwarding is started/restarted.\n\n"
223 " Reset forwarding to the default configuration.\n\n"
225 "set verbose (level)\n"
226 " Set the debug verbosity level X.\n\n"
229 " Set number of ports.\n\n"
232 " Set number of cores.\n\n"
234 "set coremask (mask)\n"
235 " Set the forwarding cores hexadecimal mask.\n\n"
237 "set portmask (mask)\n"
238 " Set the forwarding ports hexadecimal mask.\n\n"
241 " Set number of packets per burst.\n\n"
243 "set burst tx delay (microseconds) retry (num)\n"
244 " Set the transmit delay time and number of retries"
245 " in mac_retry forwarding mode.\n\n"
247 "set txpkts (x[,y]*)\n"
248 " Set the length of each segment of TXONLY"
251 "set corelist (x[,y]*)\n"
252 " Set the list of forwarding cores.\n\n"
254 "set portlist (x[,y]*)\n"
255 " Set the list of forwarding ports.\n\n"
257 "vlan set strip (on|off) (port_id)\n"
258 " Set the VLAN strip on a port.\n\n"
260 "vlan set stripq (on|off) (port_id,queue_id)\n"
261 " Set the VLAN strip for a queue on a port.\n\n"
263 "vlan set filter (on|off) (port_id)\n"
264 " Set the VLAN filter on a port.\n\n"
266 "vlan set qinq (on|off) (port_id)\n"
267 " Set the VLAN QinQ (extended queue in queue)"
270 "vlan set tpid (value) (port_id)\n"
271 " Set the outer VLAN TPID for Packet Filtering on"
274 "rx_vlan add (vlan_id|all) (port_id)\n"
275 " Add a vlan_id, or all identifiers, to the set"
276 " of VLAN identifiers filtered by port_id.\n\n"
278 "rx_vlan rm (vlan_id|all) (port_id)\n"
279 " Remove a vlan_id, or all identifiers, from the set"
280 " of VLAN identifiers filtered by port_id.\n\n"
282 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
283 " Add a vlan_id, to the set of VLAN identifiers"
284 "filtered for VF(s) from port_id.\n\n"
286 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
287 " Remove a vlan_id, to the set of VLAN identifiers"
288 "filtered for VF(s) from port_id.\n\n"
290 "rx_vlan set tpid (value) (port_id)\n"
291 " Set the outer VLAN TPID for Packet Filtering on"
294 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
295 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
296 " add a tunnel filter of a port.\n\n"
298 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
299 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
300 " remove a tunnel filter of a port.\n\n"
302 "rx_vxlan_port add (udp_port) (port_id)\n"
303 " Add an UDP port for VXLAN packet filter on a port\n\n"
305 "rx_vxlan_port rm (udp_port) (port_id)\n"
306 " Remove an UDP port for VXLAN packet filter on a port\n\n"
308 "tx_vlan set vlan_id (port_id)\n"
309 " Set hardware insertion of VLAN ID in packets sent"
312 "tx_vlan set pvid port_id vlan_id (on|off)\n"
313 " Set port based TX VLAN insertion.\n\n"
315 "tx_vlan reset (port_id)\n"
316 " Disable hardware insertion of a VLAN header in"
317 " packets sent on a port.\n\n"
319 "tx_cksum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n"
320 " Select hardware or software calculation of the"
321 " checksum with when transmitting a packet using the"
322 " csum forward engine.\n"
323 " ip|udp|tcp|sctp always concern the inner layer.\n"
324 " vxlan concerns the outer IP and UDP layer (in"
325 " case the packet is recognized as a vxlan packet by"
326 " the forward engine)\n"
327 " Please check the NIC datasheet for HW limits.\n\n"
329 "tx_checksum show (port_id)\n"
330 " Display tx checksum offload configuration\n\n"
333 " Set packet forwarding mode.\n\n"
335 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
336 " Add a MAC address on port_id.\n\n"
338 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
339 " Remove a MAC address from port_id.\n\n"
341 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
342 " Add a MAC address for a VF on the port.\n\n"
344 "set port (port_id) uta (mac_address|all) (on|off)\n"
345 " Add/Remove a or all unicast hash filter(s)"
348 "set promisc (port_id|all) (on|off)\n"
349 " Set the promiscuous mode on port_id, or all.\n\n"
351 "set allmulti (port_id|all) (on|off)\n"
352 " Set the allmulti mode on port_id, or all.\n\n"
354 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
355 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
356 " (on|off) autoneg (on|off) (port_id)\n"
357 "set flow_ctrl rx (on|off) (portid)\n"
358 "set flow_ctrl tx (on|off) (portid)\n"
359 "set flow_ctrl high_water (high_water) (portid)\n"
360 "set flow_ctrl low_water (low_water) (portid)\n"
361 "set flow_ctrl pause_time (pause_time) (portid)\n"
362 "set flow_ctrl send_xon (send_xon) (portid)\n"
363 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
364 "set flow_ctrl autoneg (on|off) (port_id)\n"
365 " Set the link flow control parameter on a port.\n\n"
367 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
368 " (low_water) (pause_time) (priority) (port_id)\n"
369 " Set the priority flow control parameter on a"
372 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
373 " Set statistics mapping (qmapping 0..15) for RX/TX"
375 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
376 " on port 0 to mapping 5.\n\n"
378 "set port (port_id) vf (vf_id) rx|tx on|off\n"
379 " Enable/Disable a VF receive/tranmit from a port\n\n"
381 "set port (port_id) vf (vf_id) (mac_addr)"
382 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
383 " Add/Remove unicast or multicast MAC addr filter"
386 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
388 " AUPE:accepts untagged VLAN;"
389 "ROPE:accept unicast hash\n\n"
390 " BAM:accepts broadcast packets;"
391 "MPE:accepts all multicast packets\n\n"
392 " Enable/Disable a VF receive mode of a port\n\n"
394 "set port (port_id) queue (queue_id) rate (rate_num)\n"
395 " Set rate limit for a queue of a port\n\n"
397 "set port (port_id) vf (vf_id) rate (rate_num) "
398 "queue_mask (queue_mask_value)\n"
399 " Set rate limit for queues in VF of a port\n\n"
401 "set port (port_id) mirror-rule (rule_id)"
402 "(pool-mirror|vlan-mirror)\n"
403 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
404 " Set pool or vlan type mirror rule on a port.\n"
405 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
406 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
409 "set port (port_id) mirror-rule (rule_id)"
410 " (uplink-mirror|downlink-mirror) dst-pool"
411 " (pool_id) (on|off)\n"
412 " Set uplink or downlink type mirror rule on a port.\n"
413 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
414 " 0 on' enable mirror income traffic to pool 0.\n\n"
416 "reset port (port_id) mirror-rule (rule_id)\n"
417 " Reset a mirror rule.\n\n"
419 "set flush_rx (on|off)\n"
420 " Flush (default) or don't flush RX streams before"
421 " forwarding. Mainly used with PCAP drivers.\n\n"
423 #ifdef RTE_NIC_BYPASS
424 "set bypass mode (normal|bypass|isolate) (port_id)\n"
425 " Set the bypass mode for the lowest port on bypass enabled"
428 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
429 "mode (normal|bypass|isolate) (port_id)\n"
430 " Set the event required to initiate specified bypass mode for"
431 " the lowest port on a bypass enabled NIC where:\n"
432 " timeout = enable bypass after watchdog timeout.\n"
433 " os_on = enable bypass when OS/board is powered on.\n"
434 " os_off = enable bypass when OS/board is powered off.\n"
435 " power_on = enable bypass when power supply is turned on.\n"
436 " power_off = enable bypass when power supply is turned off."
439 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
440 " Set the bypass watchdog timeout to 'n' seconds"
441 " where 0 = instant.\n\n"
443 "show bypass config (port_id)\n"
444 " Show the bypass configuration for a bypass enabled NIC"
445 " using the lowest port on the NIC.\n\n"
447 #ifdef RTE_LIBRTE_PMD_BOND
448 "create bonded device (mode) (socket)\n"
449 " Create a new bonded device with specific bonding mode and socket.\n\n"
451 "add bonding slave (slave_id) (port_id)\n"
452 " Add a slave device to a bonded device.\n\n"
454 "remove bonding slave (slave_id) (port_id)\n"
455 " Remove a slave device from a bonded device.\n\n"
457 "set bonding mode (value) (port_id)\n"
458 " Set the bonding mode on a bonded device.\n\n"
460 "set bonding primary (slave_id) (port_id)\n"
461 " Set the primary slave for a bonded device.\n\n"
463 "show bonding config (port_id)\n"
464 " Show the bonding config for port_id.\n\n"
466 "set bonding mac_addr (port_id) (address)\n"
467 " Set the MAC address of a bonded device.\n\n"
469 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
470 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
472 "set bonding mon_period (port_id) (value)\n"
473 " Set the bonding link status monitoring polling period in ms.\n\n"
475 "set link-up port (port_id)\n"
476 " Set link up for a port.\n\n"
478 "set link-down port (port_id)\n"
479 " Set link down for a port.\n\n"
481 , list_pkt_forwarding_modes()
486 if (show_all || !strcmp(res->section, "flowdir")) {
491 "Flow director mode:\n"
492 "-------------------\n\n"
494 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
495 " src (src_ip_address) (src_port)"
496 " dst (dst_ip_address) (dst_port)"
497 " flexbytes (flexbytes_values) vlan (vlan_id)"
498 " queue (queue_id)\n"
499 " Add a signature filter.\n\n"
501 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
502 " src (src_ip_address) (src_port)"
503 " dst (dst_ip_address) (dst_port)"
504 " flexbytes (flexbytes_values) vlan (vlan_id)"
505 " queue (queue_id)\n"
506 " Update a signature filter.\n\n"
508 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
509 " src (src_ip_address) (src_port)"
510 " dst (dst_ip_address) (dst_port)"
511 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
512 " Remove a signature filter.\n\n"
514 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
515 " src (src_ip_address) (src_port)"
516 " dst (dst_ip_address) (dst_port)"
517 " flexbytes (flexbytes_values) vlan (vlan_id)"
518 " queue (queue_id) soft (soft_id)\n"
519 " Add a perfect filter.\n\n"
521 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
522 " src (src_ip_address) (src_port)"
523 " dst (dst_ip_address) (dst_port)"
524 " flexbytes (flexbytes_values) vlan (vlan_id)"
525 " queue (queue_id)\n"
526 " Update a perfect filter.\n\n"
528 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
529 " src (src_ip_address) (src_port)"
530 " dst (dst_ip_address) (dst_port)"
531 " flexbytes (flexbytes_values) vlan (vlan_id)"
533 " Remove a perfect filter.\n\n"
535 "set_masks_filter (port_id) only_ip_flow (0|1)"
536 " src_mask (ip_src_mask) (src_port_mask)"
537 " dst_mask (ip_dst_mask) (dst_port_mask)"
538 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
539 " Set IPv4 filter masks.\n\n"
541 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
542 " src_mask (ip_src_mask) (src_port_mask)"
543 " dst_mask (ip_dst_mask) (dst_port_mask)"
544 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
545 " compare_dst (0|1)\n"
546 " Set IPv6 filter masks.\n\n"
550 if (show_all || !strcmp(res->section, "ports")) {
556 "----------------\n\n"
558 "port start (port_id|all)\n"
559 " Start all ports or port_id.\n\n"
561 "port stop (port_id|all)\n"
562 " Stop all ports or port_id.\n\n"
564 "port close (port_id|all)\n"
565 " Close all ports or port_id.\n\n"
567 "port config (port_id|all)"
568 " speed (10|100|1000|10000|40000|auto)"
569 " duplex (half|full|auto)\n"
570 " Set speed and duplex for all ports or port_id\n\n"
572 "port config all (rxq|txq|rxd|txd) (value)\n"
573 " Set number for rxq/txq/rxd/txd.\n\n"
575 "port config all max-pkt-len (value)\n"
576 " Set the max packet length.\n\n"
578 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
580 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
583 "port config all rss (ip|udp|none)\n"
584 " Set the RSS mode.\n\n"
586 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
587 " Set the RSS redirection table.\n\n"
589 "port config (port_id) dcb vt (on|off) (traffic_class)"
591 " Set the DCB mode.\n\n"
593 "port config all burst (value)\n"
594 " Set the number of packets per burst.\n\n"
596 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
598 " Set the ring prefetch/host/writeback threshold"
599 " for tx/rx queue.\n\n"
601 "port config all (txfreet|txrst|rxfreet) (value)\n"
602 " Set free threshold for rx/tx, or set"
603 " tx rs bit threshold.\n\n"
604 "port config mtu X value\n"
605 " Set the MTU of port X to a given value\n\n"
607 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
608 " Start/stop a rx/tx queue of port X. Only take effect"
609 " when port X is started\n"
613 if (show_all || !strcmp(res->section, "registers")) {
621 "read reg (port_id) (address)\n"
622 " Display value of a port register.\n\n"
624 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
625 " Display a port register bit field.\n\n"
627 "read regbit (port_id) (address) (bit_x)\n"
628 " Display a single port register bit.\n\n"
630 "write reg (port_id) (address) (value)\n"
631 " Set value of a port register.\n\n"
633 "write regfield (port_id) (address) (bit_x) (bit_y)"
635 " Set bit field of a port register.\n\n"
637 "write regbit (port_id) (address) (bit_x) (value)\n"
638 " Set single bit value of a port register.\n\n"
641 if (show_all || !strcmp(res->section, "filters")) {
649 "add_ethertype_filter (port_id) ethertype (eth_value)"
650 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
651 " add an ethertype filter.\n\n"
653 "remove_ethertype_filter (port_id) index (idx)\n"
654 " remove an ethertype filter.\n\n"
656 "get_ethertype_filter (port_id) index (idx)\n"
657 " get info of a ethertype filter.\n\n"
659 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
660 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
661 " queue (queue_id) index (idx)\n"
662 " add a 2tuple filter.\n\n"
664 "remove_2tuple_filter (port_id) index (idx)\n"
665 " remove a 2tuple filter.\n\n"
667 "get_2tuple_filter (port_id) index (idx)\n"
668 " get info of a 2tuple filter.\n\n"
670 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
671 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
672 " mask (mask_value) flags (flags_value) priority (prio_value)"
673 " queue (queue_id) index (idx)\n"
674 " add a 5tuple filter.\n\n"
676 "remove_5tuple_filter (port_id) index (idx)\n"
677 " remove a 5tuple filter.\n\n"
679 "get_5tuple_filter (port_id) index (idx)\n"
680 " get info of a 5tuple filter.\n\n"
682 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
683 " add syn filter.\n\n"
685 "remove_syn_filter (port_id)"
686 " remove syn filter.\n\n"
688 "get_syn_filter (port_id) "
689 " get syn filter info.\n\n"
691 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
692 " priority (prio_value) queue (queue_id) index (idx)\n"
693 " add a flex filter.\n\n"
695 "remove_flex_filter (port_id) index (idx)\n"
696 " remove a flex filter.\n\n"
698 "get_flex_filter (port_id) index (idx)\n"
699 " get info of a flex filter.\n\n"
701 "flow_director_filter (port_id) (add|del)"
702 " flow (ip4|ip4-frag|ip6|ip6-frag)"
703 " src (src_ip_address) dst (dst_ip_address)"
704 " flexbytes (flexbytes_value)"
705 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
706 " Add/Del an IP type flow director filter.\n\n"
708 "flow_director_filter (port_id) (add|del)"
709 " flow (udp4|tcp4|udp6|tcp6)"
710 " src (src_ip_address) (src_port)"
711 " dst (dst_ip_address) (dst_port)"
712 " flexbytes (flexbytes_value)"
713 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
714 " Add/Del an UDP/TCP type flow director filter.\n\n"
716 "flow_director_filter (port_id) (add|del)"
717 " flow (sctp4|sctp6)"
718 " src (src_ip_address) dst (dst_ip_address)"
719 " tag (verification_tag)"
720 " flexbytes (flexbytes_value) (drop|fwd)"
721 " queue (queue_id) fd_id (fd_id_value)\n"
722 " Add/Del a SCTP type flow director filter.\n\n"
724 "flush_flow_director (port_id)\n"
725 " Flush all flow director entries of a device.\n\n"
727 "flow_director_flex_mask (port_id)"
728 " flow (ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
730 " Configure mask of flex payload.\n\n"
732 "flow_director_flex_payload (port_id)"
733 " (l2|l3|l4) (config)\n"
734 " Configure flex payload selection.\n\n"
739 cmdline_parse_token_string_t cmd_help_long_help =
740 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
742 cmdline_parse_token_string_t cmd_help_long_section =
743 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
744 "all#control#display#config#flowdir#"
745 "ports#registers#filters");
747 cmdline_parse_inst_t cmd_help_long = {
748 .f = cmd_help_long_parsed,
750 .help_str = "show help",
752 (void *)&cmd_help_long_help,
753 (void *)&cmd_help_long_section,
759 /* *** start/stop/close all ports *** */
760 struct cmd_operate_port_result {
761 cmdline_fixed_string_t keyword;
762 cmdline_fixed_string_t name;
763 cmdline_fixed_string_t value;
766 static void cmd_operate_port_parsed(void *parsed_result,
767 __attribute__((unused)) struct cmdline *cl,
768 __attribute__((unused)) void *data)
770 struct cmd_operate_port_result *res = parsed_result;
772 if (!strcmp(res->name, "start"))
773 start_port(RTE_PORT_ALL);
774 else if (!strcmp(res->name, "stop"))
775 stop_port(RTE_PORT_ALL);
776 else if (!strcmp(res->name, "close"))
777 close_port(RTE_PORT_ALL);
779 printf("Unknown parameter\n");
782 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
783 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
785 cmdline_parse_token_string_t cmd_operate_port_all_port =
786 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
788 cmdline_parse_token_string_t cmd_operate_port_all_all =
789 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
791 cmdline_parse_inst_t cmd_operate_port = {
792 .f = cmd_operate_port_parsed,
794 .help_str = "port start|stop|close all: start/stop/close all ports",
796 (void *)&cmd_operate_port_all_cmd,
797 (void *)&cmd_operate_port_all_port,
798 (void *)&cmd_operate_port_all_all,
803 /* *** start/stop/close specific port *** */
804 struct cmd_operate_specific_port_result {
805 cmdline_fixed_string_t keyword;
806 cmdline_fixed_string_t name;
810 static void cmd_operate_specific_port_parsed(void *parsed_result,
811 __attribute__((unused)) struct cmdline *cl,
812 __attribute__((unused)) void *data)
814 struct cmd_operate_specific_port_result *res = parsed_result;
816 if (!strcmp(res->name, "start"))
817 start_port(res->value);
818 else if (!strcmp(res->name, "stop"))
819 stop_port(res->value);
820 else if (!strcmp(res->name, "close"))
821 close_port(res->value);
823 printf("Unknown parameter\n");
826 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
827 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
829 cmdline_parse_token_string_t cmd_operate_specific_port_port =
830 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
831 name, "start#stop#close");
832 cmdline_parse_token_num_t cmd_operate_specific_port_id =
833 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
836 cmdline_parse_inst_t cmd_operate_specific_port = {
837 .f = cmd_operate_specific_port_parsed,
839 .help_str = "port start|stop|close X: start/stop/close port X",
841 (void *)&cmd_operate_specific_port_cmd,
842 (void *)&cmd_operate_specific_port_port,
843 (void *)&cmd_operate_specific_port_id,
848 /* *** configure speed for all ports *** */
849 struct cmd_config_speed_all {
850 cmdline_fixed_string_t port;
851 cmdline_fixed_string_t keyword;
852 cmdline_fixed_string_t all;
853 cmdline_fixed_string_t item1;
854 cmdline_fixed_string_t item2;
855 cmdline_fixed_string_t value1;
856 cmdline_fixed_string_t value2;
860 cmd_config_speed_all_parsed(void *parsed_result,
861 __attribute__((unused)) struct cmdline *cl,
862 __attribute__((unused)) void *data)
864 struct cmd_config_speed_all *res = parsed_result;
865 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
866 uint16_t link_duplex = 0;
869 if (!all_ports_stopped()) {
870 printf("Please stop all ports first\n");
874 if (!strcmp(res->value1, "10"))
875 link_speed = ETH_LINK_SPEED_10;
876 else if (!strcmp(res->value1, "100"))
877 link_speed = ETH_LINK_SPEED_100;
878 else if (!strcmp(res->value1, "1000"))
879 link_speed = ETH_LINK_SPEED_1000;
880 else if (!strcmp(res->value1, "10000"))
881 link_speed = ETH_LINK_SPEED_10G;
882 else if (!strcmp(res->value1, "40000"))
883 link_speed = ETH_LINK_SPEED_40G;
884 else if (!strcmp(res->value1, "auto"))
885 link_speed = ETH_LINK_SPEED_AUTONEG;
887 printf("Unknown parameter\n");
891 if (!strcmp(res->value2, "half"))
892 link_duplex = ETH_LINK_HALF_DUPLEX;
893 else if (!strcmp(res->value2, "full"))
894 link_duplex = ETH_LINK_FULL_DUPLEX;
895 else if (!strcmp(res->value2, "auto"))
896 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
898 printf("Unknown parameter\n");
902 for (pid = 0; pid < nb_ports; pid++) {
903 ports[pid].dev_conf.link_speed = link_speed;
904 ports[pid].dev_conf.link_duplex = link_duplex;
907 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
910 cmdline_parse_token_string_t cmd_config_speed_all_port =
911 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
912 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
913 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
915 cmdline_parse_token_string_t cmd_config_speed_all_all =
916 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
917 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
918 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
919 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
920 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
921 "10#100#1000#10000#40000#auto");
922 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
923 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
924 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
925 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
928 cmdline_parse_inst_t cmd_config_speed_all = {
929 .f = cmd_config_speed_all_parsed,
931 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
934 (void *)&cmd_config_speed_all_port,
935 (void *)&cmd_config_speed_all_keyword,
936 (void *)&cmd_config_speed_all_all,
937 (void *)&cmd_config_speed_all_item1,
938 (void *)&cmd_config_speed_all_value1,
939 (void *)&cmd_config_speed_all_item2,
940 (void *)&cmd_config_speed_all_value2,
945 /* *** configure speed for specific port *** */
946 struct cmd_config_speed_specific {
947 cmdline_fixed_string_t port;
948 cmdline_fixed_string_t keyword;
950 cmdline_fixed_string_t item1;
951 cmdline_fixed_string_t item2;
952 cmdline_fixed_string_t value1;
953 cmdline_fixed_string_t value2;
957 cmd_config_speed_specific_parsed(void *parsed_result,
958 __attribute__((unused)) struct cmdline *cl,
959 __attribute__((unused)) void *data)
961 struct cmd_config_speed_specific *res = parsed_result;
962 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
963 uint16_t link_duplex = 0;
965 if (!all_ports_stopped()) {
966 printf("Please stop all ports first\n");
970 if (res->id >= nb_ports) {
971 printf("Port id %d must be less than %d\n", res->id, nb_ports);
975 if (!strcmp(res->value1, "10"))
976 link_speed = ETH_LINK_SPEED_10;
977 else if (!strcmp(res->value1, "100"))
978 link_speed = ETH_LINK_SPEED_100;
979 else if (!strcmp(res->value1, "1000"))
980 link_speed = ETH_LINK_SPEED_1000;
981 else if (!strcmp(res->value1, "10000"))
982 link_speed = ETH_LINK_SPEED_10000;
983 else if (!strcmp(res->value1, "40000"))
984 link_speed = ETH_LINK_SPEED_40G;
985 else if (!strcmp(res->value1, "auto"))
986 link_speed = ETH_LINK_SPEED_AUTONEG;
988 printf("Unknown parameter\n");
992 if (!strcmp(res->value2, "half"))
993 link_duplex = ETH_LINK_HALF_DUPLEX;
994 else if (!strcmp(res->value2, "full"))
995 link_duplex = ETH_LINK_FULL_DUPLEX;
996 else if (!strcmp(res->value2, "auto"))
997 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
999 printf("Unknown parameter\n");
1003 ports[res->id].dev_conf.link_speed = link_speed;
1004 ports[res->id].dev_conf.link_duplex = link_duplex;
1006 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1010 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1011 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1013 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1014 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1016 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1017 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1018 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1019 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1021 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1022 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1023 "10#100#1000#10000#40000#auto");
1024 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1025 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1027 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1028 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1031 cmdline_parse_inst_t cmd_config_speed_specific = {
1032 .f = cmd_config_speed_specific_parsed,
1034 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1037 (void *)&cmd_config_speed_specific_port,
1038 (void *)&cmd_config_speed_specific_keyword,
1039 (void *)&cmd_config_speed_specific_id,
1040 (void *)&cmd_config_speed_specific_item1,
1041 (void *)&cmd_config_speed_specific_value1,
1042 (void *)&cmd_config_speed_specific_item2,
1043 (void *)&cmd_config_speed_specific_value2,
1048 /* *** configure txq/rxq, txd/rxd *** */
1049 struct cmd_config_rx_tx {
1050 cmdline_fixed_string_t port;
1051 cmdline_fixed_string_t keyword;
1052 cmdline_fixed_string_t all;
1053 cmdline_fixed_string_t name;
1058 cmd_config_rx_tx_parsed(void *parsed_result,
1059 __attribute__((unused)) struct cmdline *cl,
1060 __attribute__((unused)) void *data)
1062 struct cmd_config_rx_tx *res = parsed_result;
1064 if (!all_ports_stopped()) {
1065 printf("Please stop all ports first\n");
1069 if (!strcmp(res->name, "rxq")) {
1070 if (res->value <= 0) {
1071 printf("rxq %d invalid - must be > 0\n", res->value);
1074 nb_rxq = res->value;
1076 else if (!strcmp(res->name, "txq")) {
1077 if (res->value <= 0) {
1078 printf("txq %d invalid - must be > 0\n", res->value);
1081 nb_txq = res->value;
1083 else if (!strcmp(res->name, "rxd")) {
1084 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1085 printf("rxd %d invalid - must be > 0 && <= %d\n",
1086 res->value, RTE_TEST_RX_DESC_MAX);
1089 nb_rxd = res->value;
1090 } else if (!strcmp(res->name, "txd")) {
1091 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1092 printf("txd %d invalid - must be > 0 && <= %d\n",
1093 res->value, RTE_TEST_TX_DESC_MAX);
1096 nb_txd = res->value;
1098 printf("Unknown parameter\n");
1104 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1107 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1108 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1109 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1110 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1111 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1112 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1113 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1114 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1116 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1117 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1119 cmdline_parse_inst_t cmd_config_rx_tx = {
1120 .f = cmd_config_rx_tx_parsed,
1122 .help_str = "port config all rxq|txq|rxd|txd value",
1124 (void *)&cmd_config_rx_tx_port,
1125 (void *)&cmd_config_rx_tx_keyword,
1126 (void *)&cmd_config_rx_tx_all,
1127 (void *)&cmd_config_rx_tx_name,
1128 (void *)&cmd_config_rx_tx_value,
1133 /* *** config max packet length *** */
1134 struct cmd_config_max_pkt_len_result {
1135 cmdline_fixed_string_t port;
1136 cmdline_fixed_string_t keyword;
1137 cmdline_fixed_string_t all;
1138 cmdline_fixed_string_t name;
1143 cmd_config_max_pkt_len_parsed(void *parsed_result,
1144 __attribute__((unused)) struct cmdline *cl,
1145 __attribute__((unused)) void *data)
1147 struct cmd_config_max_pkt_len_result *res = parsed_result;
1149 if (!all_ports_stopped()) {
1150 printf("Please stop all ports first\n");
1154 if (!strcmp(res->name, "max-pkt-len")) {
1155 if (res->value < ETHER_MIN_LEN) {
1156 printf("max-pkt-len can not be less than %d\n",
1160 if (res->value == rx_mode.max_rx_pkt_len)
1163 rx_mode.max_rx_pkt_len = res->value;
1164 if (res->value > ETHER_MAX_LEN)
1165 rx_mode.jumbo_frame = 1;
1167 rx_mode.jumbo_frame = 0;
1169 printf("Unknown parameter\n");
1175 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1178 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1179 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1181 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1182 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1184 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1185 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1187 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1188 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1190 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1191 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1194 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1195 .f = cmd_config_max_pkt_len_parsed,
1197 .help_str = "port config all max-pkt-len value",
1199 (void *)&cmd_config_max_pkt_len_port,
1200 (void *)&cmd_config_max_pkt_len_keyword,
1201 (void *)&cmd_config_max_pkt_len_all,
1202 (void *)&cmd_config_max_pkt_len_name,
1203 (void *)&cmd_config_max_pkt_len_value,
1208 /* *** configure port MTU *** */
1209 struct cmd_config_mtu_result {
1210 cmdline_fixed_string_t port;
1211 cmdline_fixed_string_t keyword;
1212 cmdline_fixed_string_t mtu;
1218 cmd_config_mtu_parsed(void *parsed_result,
1219 __attribute__((unused)) struct cmdline *cl,
1220 __attribute__((unused)) void *data)
1222 struct cmd_config_mtu_result *res = parsed_result;
1224 if (res->value < ETHER_MIN_LEN) {
1225 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1228 port_mtu_set(res->port_id, res->value);
1231 cmdline_parse_token_string_t cmd_config_mtu_port =
1232 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1234 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1235 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1237 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1238 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1240 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1241 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1242 cmdline_parse_token_num_t cmd_config_mtu_value =
1243 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1245 cmdline_parse_inst_t cmd_config_mtu = {
1246 .f = cmd_config_mtu_parsed,
1248 .help_str = "port config mtu value",
1250 (void *)&cmd_config_mtu_port,
1251 (void *)&cmd_config_mtu_keyword,
1252 (void *)&cmd_config_mtu_mtu,
1253 (void *)&cmd_config_mtu_port_id,
1254 (void *)&cmd_config_mtu_value,
1259 /* *** configure rx mode *** */
1260 struct cmd_config_rx_mode_flag {
1261 cmdline_fixed_string_t port;
1262 cmdline_fixed_string_t keyword;
1263 cmdline_fixed_string_t all;
1264 cmdline_fixed_string_t name;
1265 cmdline_fixed_string_t value;
1269 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1270 __attribute__((unused)) struct cmdline *cl,
1271 __attribute__((unused)) void *data)
1273 struct cmd_config_rx_mode_flag *res = parsed_result;
1275 if (!all_ports_stopped()) {
1276 printf("Please stop all ports first\n");
1280 if (!strcmp(res->name, "crc-strip")) {
1281 if (!strcmp(res->value, "on"))
1282 rx_mode.hw_strip_crc = 1;
1283 else if (!strcmp(res->value, "off"))
1284 rx_mode.hw_strip_crc = 0;
1286 printf("Unknown parameter\n");
1289 } else if (!strcmp(res->name, "rx-cksum")) {
1290 if (!strcmp(res->value, "on"))
1291 rx_mode.hw_ip_checksum = 1;
1292 else if (!strcmp(res->value, "off"))
1293 rx_mode.hw_ip_checksum = 0;
1295 printf("Unknown parameter\n");
1298 } else if (!strcmp(res->name, "hw-vlan")) {
1299 if (!strcmp(res->value, "on")) {
1300 rx_mode.hw_vlan_filter = 1;
1301 rx_mode.hw_vlan_strip = 1;
1303 else if (!strcmp(res->value, "off")) {
1304 rx_mode.hw_vlan_filter = 0;
1305 rx_mode.hw_vlan_strip = 0;
1308 printf("Unknown parameter\n");
1311 } else if (!strcmp(res->name, "drop-en")) {
1312 if (!strcmp(res->value, "on"))
1314 else if (!strcmp(res->value, "off"))
1317 printf("Unknown parameter\n");
1321 printf("Unknown parameter\n");
1327 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1330 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1331 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1332 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1333 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1335 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1336 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1337 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1338 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1339 "crc-strip#rx-cksum#hw-vlan");
1340 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1341 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1344 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1345 .f = cmd_config_rx_mode_flag_parsed,
1347 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1349 (void *)&cmd_config_rx_mode_flag_port,
1350 (void *)&cmd_config_rx_mode_flag_keyword,
1351 (void *)&cmd_config_rx_mode_flag_all,
1352 (void *)&cmd_config_rx_mode_flag_name,
1353 (void *)&cmd_config_rx_mode_flag_value,
1358 /* *** configure rss *** */
1359 struct cmd_config_rss {
1360 cmdline_fixed_string_t port;
1361 cmdline_fixed_string_t keyword;
1362 cmdline_fixed_string_t all;
1363 cmdline_fixed_string_t name;
1364 cmdline_fixed_string_t value;
1368 cmd_config_rss_parsed(void *parsed_result,
1369 __attribute__((unused)) struct cmdline *cl,
1370 __attribute__((unused)) void *data)
1372 struct cmd_config_rss *res = parsed_result;
1373 struct rte_eth_rss_conf rss_conf;
1376 if (!strcmp(res->value, "ip"))
1377 rss_conf.rss_hf = ETH_RSS_IP;
1378 else if (!strcmp(res->value, "udp"))
1379 rss_conf.rss_hf = ETH_RSS_UDP;
1380 else if (!strcmp(res->value, "none"))
1381 rss_conf.rss_hf = 0;
1383 printf("Unknown parameter\n");
1386 rss_conf.rss_key = NULL;
1387 for (i = 0; i < rte_eth_dev_count(); i++)
1388 rte_eth_dev_rss_hash_update(i, &rss_conf);
1391 cmdline_parse_token_string_t cmd_config_rss_port =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1393 cmdline_parse_token_string_t cmd_config_rss_keyword =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1395 cmdline_parse_token_string_t cmd_config_rss_all =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1397 cmdline_parse_token_string_t cmd_config_rss_name =
1398 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1399 cmdline_parse_token_string_t cmd_config_rss_value =
1400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1402 cmdline_parse_inst_t cmd_config_rss = {
1403 .f = cmd_config_rss_parsed,
1405 .help_str = "port config all rss ip|udp|none",
1407 (void *)&cmd_config_rss_port,
1408 (void *)&cmd_config_rss_keyword,
1409 (void *)&cmd_config_rss_all,
1410 (void *)&cmd_config_rss_name,
1411 (void *)&cmd_config_rss_value,
1416 /* *** configure rss hash key *** */
1417 struct cmd_config_rss_hash_key {
1418 cmdline_fixed_string_t port;
1419 cmdline_fixed_string_t config;
1421 cmdline_fixed_string_t rss_hash_key;
1422 cmdline_fixed_string_t key;
1425 #define RSS_HASH_KEY_LENGTH 40
1427 hexa_digit_to_value(char hexa_digit)
1429 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1430 return (uint8_t) (hexa_digit - '0');
1431 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1432 return (uint8_t) ((hexa_digit - 'a') + 10);
1433 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1434 return (uint8_t) ((hexa_digit - 'A') + 10);
1435 /* Invalid hexa digit */
1440 parse_and_check_key_hexa_digit(char *key, int idx)
1444 hexa_v = hexa_digit_to_value(key[idx]);
1446 printf("invalid key: character %c at position %d is not a "
1447 "valid hexa digit\n", key[idx], idx);
1452 cmd_config_rss_hash_key_parsed(void *parsed_result,
1453 __attribute__((unused)) struct cmdline *cl,
1454 __attribute__((unused)) void *data)
1456 struct cmd_config_rss_hash_key *res = parsed_result;
1457 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1462 /* Check the length of the RSS hash key */
1463 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1464 printf("key length: %d invalid - key must be a string of %d"
1465 "hexa-decimal numbers\n", (int) strlen(res->key),
1466 RSS_HASH_KEY_LENGTH * 2);
1469 /* Translate RSS hash key into binary representation */
1470 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1471 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1474 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1477 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1479 port_rss_hash_key_update(res->port_id, hash_key);
1482 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1483 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1484 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1485 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1487 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1488 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1489 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1491 rss_hash_key, "rss-hash-key");
1492 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1495 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1496 .f = cmd_config_rss_hash_key_parsed,
1498 .help_str = "port config X rss-hash-key 80 hexa digits",
1500 (void *)&cmd_config_rss_hash_key_port,
1501 (void *)&cmd_config_rss_hash_key_config,
1502 (void *)&cmd_config_rss_hash_key_port_id,
1503 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1504 (void *)&cmd_config_rss_hash_key_value,
1509 /* *** configure port rxq/txq start/stop *** */
1510 struct cmd_config_rxtx_queue {
1511 cmdline_fixed_string_t port;
1513 cmdline_fixed_string_t rxtxq;
1515 cmdline_fixed_string_t opname;
1519 cmd_config_rxtx_queue_parsed(void *parsed_result,
1520 __attribute__((unused)) struct cmdline *cl,
1521 __attribute__((unused)) void *data)
1523 struct cmd_config_rxtx_queue *res = parsed_result;
1528 if (test_done == 0) {
1529 printf("Please stop forwarding first\n");
1533 if (port_id_is_invalid(res->portid))
1536 if (port_is_started(res->portid) != 1) {
1537 printf("Please start port %u first\n", res->portid);
1541 if (!strcmp(res->rxtxq, "rxq"))
1543 else if (!strcmp(res->rxtxq, "txq"))
1546 printf("Unknown parameter\n");
1550 if (isrx && rx_queue_id_is_invalid(res->qid))
1552 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1555 if (!strcmp(res->opname, "start"))
1557 else if (!strcmp(res->opname, "stop"))
1560 printf("Unknown parameter\n");
1564 if (isstart && isrx)
1565 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1566 else if (!isstart && isrx)
1567 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1568 else if (isstart && !isrx)
1569 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1571 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1573 if (ret == -ENOTSUP)
1574 printf("Function not supported in PMD driver\n");
1577 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1579 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1580 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1581 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1582 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1583 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1584 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1585 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1589 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1590 .f = cmd_config_rxtx_queue_parsed,
1592 .help_str = "port X rxq|txq ID start|stop",
1594 (void *)&cmd_config_speed_all_port,
1595 (void *)&cmd_config_rxtx_queue_portid,
1596 (void *)&cmd_config_rxtx_queue_rxtxq,
1597 (void *)&cmd_config_rxtx_queue_qid,
1598 (void *)&cmd_config_rxtx_queue_opname,
1603 /* *** Configure RSS RETA *** */
1604 struct cmd_config_rss_reta {
1605 cmdline_fixed_string_t port;
1606 cmdline_fixed_string_t keyword;
1608 cmdline_fixed_string_t name;
1609 cmdline_fixed_string_t list_name;
1610 cmdline_fixed_string_t list_of_items;
1614 parse_reta_config(const char *str,
1615 struct rte_eth_rss_reta_entry64 *reta_conf,
1616 uint16_t nb_entries)
1620 uint16_t hash_index, idx, shift;
1623 const char *p, *p0 = str;
1630 unsigned long int_fld[_NUM_FLD];
1631 char *str_fld[_NUM_FLD];
1633 while ((p = strchr(p0,'(')) != NULL) {
1635 if((p0 = strchr(p,')')) == NULL)
1639 if(size >= sizeof(s))
1642 snprintf(s, sizeof(s), "%.*s", size, p);
1643 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1645 for (i = 0; i < _NUM_FLD; i++) {
1647 int_fld[i] = strtoul(str_fld[i], &end, 0);
1648 if (errno != 0 || end == str_fld[i] ||
1653 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1654 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1656 if (hash_index >= nb_entries) {
1657 printf("Invalid RETA hash index=%d\n", hash_index);
1661 idx = hash_index / RTE_RETA_GROUP_SIZE;
1662 shift = hash_index % RTE_RETA_GROUP_SIZE;
1663 reta_conf[idx].mask |= (1ULL << shift);
1664 reta_conf[idx].reta[shift] = nb_queue;
1671 cmd_set_rss_reta_parsed(void *parsed_result,
1672 __attribute__((unused)) struct cmdline *cl,
1673 __attribute__((unused)) void *data)
1676 struct rte_eth_dev_info dev_info;
1677 struct rte_eth_rss_reta_entry64 reta_conf[8];
1678 struct cmd_config_rss_reta *res = parsed_result;
1680 memset(&dev_info, 0, sizeof(dev_info));
1681 rte_eth_dev_info_get(res->port_id, &dev_info);
1682 if (dev_info.reta_size == 0) {
1683 printf("Redirection table size is 0 which is "
1684 "invalid for RSS\n");
1687 printf("The reta size of port %d is %u\n",
1688 res->port_id, dev_info.reta_size);
1689 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1690 printf("Currently do not support more than %u entries of "
1691 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1695 memset(reta_conf, 0, sizeof(reta_conf));
1696 if (!strcmp(res->list_name, "reta")) {
1697 if (parse_reta_config(res->list_of_items, reta_conf,
1698 dev_info.reta_size)) {
1699 printf("Invalid RSS Redirection Table "
1700 "config entered\n");
1703 ret = rte_eth_dev_rss_reta_update(res->port_id,
1704 reta_conf, dev_info.reta_size);
1706 printf("Bad redirection table parameter, "
1707 "return code = %d \n", ret);
1711 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1713 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1715 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1716 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1717 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1719 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1721 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1724 cmdline_parse_inst_t cmd_config_rss_reta = {
1725 .f = cmd_set_rss_reta_parsed,
1727 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1729 (void *)&cmd_config_rss_reta_port,
1730 (void *)&cmd_config_rss_reta_keyword,
1731 (void *)&cmd_config_rss_reta_port_id,
1732 (void *)&cmd_config_rss_reta_name,
1733 (void *)&cmd_config_rss_reta_list_name,
1734 (void *)&cmd_config_rss_reta_list_of_items,
1739 /* *** SHOW PORT RETA INFO *** */
1740 struct cmd_showport_reta {
1741 cmdline_fixed_string_t show;
1742 cmdline_fixed_string_t port;
1744 cmdline_fixed_string_t rss;
1745 cmdline_fixed_string_t reta;
1747 cmdline_fixed_string_t list_of_items;
1751 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1752 uint16_t nb_entries,
1756 const char *p, *p0 = str;
1760 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1763 p = strchr(p0, '(');
1767 p0 = strchr(p, ')');
1771 if (size >= sizeof(s)) {
1772 printf("The string size exceeds the internal buffer size\n");
1775 snprintf(s, sizeof(s), "%.*s", size, p);
1776 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1777 if (ret <= 0 || ret != num) {
1778 printf("The bits of masks do not match the number of "
1779 "reta entries: %u\n", num);
1782 for (i = 0; i < ret; i++)
1783 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1789 cmd_showport_reta_parsed(void *parsed_result,
1790 __attribute__((unused)) struct cmdline *cl,
1791 __attribute__((unused)) void *data)
1793 struct cmd_showport_reta *res = parsed_result;
1794 struct rte_eth_rss_reta_entry64 reta_conf[8];
1795 struct rte_eth_dev_info dev_info;
1797 memset(&dev_info, 0, sizeof(dev_info));
1798 rte_eth_dev_info_get(res->port_id, &dev_info);
1799 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1800 res->size > ETH_RSS_RETA_SIZE_512) {
1801 printf("Invalid redirection table size: %u\n", res->size);
1805 memset(reta_conf, 0, sizeof(reta_conf));
1806 if (showport_parse_reta_config(reta_conf, res->size,
1807 res->list_of_items) < 0) {
1808 printf("Invalid string: %s for reta masks\n",
1809 res->list_of_items);
1812 port_rss_reta_info(res->port_id, reta_conf, res->size);
1815 cmdline_parse_token_string_t cmd_showport_reta_show =
1816 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1817 cmdline_parse_token_string_t cmd_showport_reta_port =
1818 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1819 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1820 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1821 cmdline_parse_token_string_t cmd_showport_reta_rss =
1822 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1823 cmdline_parse_token_string_t cmd_showport_reta_reta =
1824 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1825 cmdline_parse_token_num_t cmd_showport_reta_size =
1826 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1827 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1828 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1829 list_of_items, NULL);
1831 cmdline_parse_inst_t cmd_showport_reta = {
1832 .f = cmd_showport_reta_parsed,
1834 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1836 (void *)&cmd_showport_reta_show,
1837 (void *)&cmd_showport_reta_port,
1838 (void *)&cmd_showport_reta_port_id,
1839 (void *)&cmd_showport_reta_rss,
1840 (void *)&cmd_showport_reta_reta,
1841 (void *)&cmd_showport_reta_size,
1842 (void *)&cmd_showport_reta_list_of_items,
1847 /* *** Show RSS hash configuration *** */
1848 struct cmd_showport_rss_hash {
1849 cmdline_fixed_string_t show;
1850 cmdline_fixed_string_t port;
1852 cmdline_fixed_string_t rss_hash;
1853 cmdline_fixed_string_t key; /* optional argument */
1856 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1857 __attribute__((unused)) struct cmdline *cl,
1860 struct cmd_showport_rss_hash *res = parsed_result;
1862 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1865 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1866 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1867 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1868 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1869 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1870 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1871 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1872 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1874 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1875 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1877 cmdline_parse_inst_t cmd_showport_rss_hash = {
1878 .f = cmd_showport_rss_hash_parsed,
1880 .help_str = "show port X rss-hash (X = port number)\n",
1882 (void *)&cmd_showport_rss_hash_show,
1883 (void *)&cmd_showport_rss_hash_port,
1884 (void *)&cmd_showport_rss_hash_port_id,
1885 (void *)&cmd_showport_rss_hash_rss_hash,
1890 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1891 .f = cmd_showport_rss_hash_parsed,
1893 .help_str = "show port X rss-hash key (X = port number)\n",
1895 (void *)&cmd_showport_rss_hash_show,
1896 (void *)&cmd_showport_rss_hash_port,
1897 (void *)&cmd_showport_rss_hash_port_id,
1898 (void *)&cmd_showport_rss_hash_rss_hash,
1899 (void *)&cmd_showport_rss_hash_rss_key,
1904 /* *** Configure DCB *** */
1905 struct cmd_config_dcb {
1906 cmdline_fixed_string_t port;
1907 cmdline_fixed_string_t config;
1909 cmdline_fixed_string_t dcb;
1910 cmdline_fixed_string_t vt;
1911 cmdline_fixed_string_t vt_en;
1913 cmdline_fixed_string_t pfc;
1914 cmdline_fixed_string_t pfc_en;
1918 cmd_config_dcb_parsed(void *parsed_result,
1919 __attribute__((unused)) struct cmdline *cl,
1920 __attribute__((unused)) void *data)
1922 struct cmd_config_dcb *res = parsed_result;
1923 struct dcb_config dcb_conf;
1924 portid_t port_id = res->port_id;
1925 struct rte_port *port;
1927 port = &ports[port_id];
1928 /** Check if the port is not started **/
1929 if (port->port_status != RTE_PORT_STOPPED) {
1930 printf("Please stop port %d first\n",port_id);
1934 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1935 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1936 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1940 /* DCB in VT mode */
1941 if (!strncmp(res->vt_en, "on",2))
1942 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1944 dcb_conf.dcb_mode = DCB_ENABLED;
1946 if (!strncmp(res->pfc_en, "on",2)) {
1947 dcb_conf.pfc_en = 1;
1950 dcb_conf.pfc_en = 0;
1952 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1953 printf("Cannot initialize network ports\n");
1957 cmd_reconfig_device_queue(port_id, 1, 1);
1960 cmdline_parse_token_string_t cmd_config_dcb_port =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1962 cmdline_parse_token_string_t cmd_config_dcb_config =
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1964 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1965 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1966 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1968 cmdline_parse_token_string_t cmd_config_dcb_vt =
1969 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1970 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1971 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1972 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1973 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1974 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1975 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1976 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1977 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1979 cmdline_parse_inst_t cmd_config_dcb = {
1980 .f = cmd_config_dcb_parsed,
1982 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1984 (void *)&cmd_config_dcb_port,
1985 (void *)&cmd_config_dcb_config,
1986 (void *)&cmd_config_dcb_port_id,
1987 (void *)&cmd_config_dcb_dcb,
1988 (void *)&cmd_config_dcb_vt,
1989 (void *)&cmd_config_dcb_vt_en,
1990 (void *)&cmd_config_dcb_num_tcs,
1991 (void *)&cmd_config_dcb_pfc,
1992 (void *)&cmd_config_dcb_pfc_en,
1997 /* *** configure number of packets per burst *** */
1998 struct cmd_config_burst {
1999 cmdline_fixed_string_t port;
2000 cmdline_fixed_string_t keyword;
2001 cmdline_fixed_string_t all;
2002 cmdline_fixed_string_t name;
2007 cmd_config_burst_parsed(void *parsed_result,
2008 __attribute__((unused)) struct cmdline *cl,
2009 __attribute__((unused)) void *data)
2011 struct cmd_config_burst *res = parsed_result;
2013 if (!all_ports_stopped()) {
2014 printf("Please stop all ports first\n");
2018 if (!strcmp(res->name, "burst")) {
2019 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2020 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2023 nb_pkt_per_burst = res->value;
2025 printf("Unknown parameter\n");
2031 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2034 cmdline_parse_token_string_t cmd_config_burst_port =
2035 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2036 cmdline_parse_token_string_t cmd_config_burst_keyword =
2037 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2038 cmdline_parse_token_string_t cmd_config_burst_all =
2039 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2040 cmdline_parse_token_string_t cmd_config_burst_name =
2041 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2042 cmdline_parse_token_num_t cmd_config_burst_value =
2043 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2045 cmdline_parse_inst_t cmd_config_burst = {
2046 .f = cmd_config_burst_parsed,
2048 .help_str = "port config all burst value",
2050 (void *)&cmd_config_burst_port,
2051 (void *)&cmd_config_burst_keyword,
2052 (void *)&cmd_config_burst_all,
2053 (void *)&cmd_config_burst_name,
2054 (void *)&cmd_config_burst_value,
2059 /* *** configure rx/tx queues *** */
2060 struct cmd_config_thresh {
2061 cmdline_fixed_string_t port;
2062 cmdline_fixed_string_t keyword;
2063 cmdline_fixed_string_t all;
2064 cmdline_fixed_string_t name;
2069 cmd_config_thresh_parsed(void *parsed_result,
2070 __attribute__((unused)) struct cmdline *cl,
2071 __attribute__((unused)) void *data)
2073 struct cmd_config_thresh *res = parsed_result;
2075 if (!all_ports_stopped()) {
2076 printf("Please stop all ports first\n");
2080 if (!strcmp(res->name, "txpt"))
2081 tx_thresh.pthresh = res->value;
2082 else if(!strcmp(res->name, "txht"))
2083 tx_thresh.hthresh = res->value;
2084 else if(!strcmp(res->name, "txwt"))
2085 tx_thresh.wthresh = res->value;
2086 else if(!strcmp(res->name, "rxpt"))
2087 rx_thresh.pthresh = res->value;
2088 else if(!strcmp(res->name, "rxht"))
2089 rx_thresh.hthresh = res->value;
2090 else if(!strcmp(res->name, "rxwt"))
2091 rx_thresh.wthresh = res->value;
2093 printf("Unknown parameter\n");
2099 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2102 cmdline_parse_token_string_t cmd_config_thresh_port =
2103 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2104 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2105 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2106 cmdline_parse_token_string_t cmd_config_thresh_all =
2107 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2108 cmdline_parse_token_string_t cmd_config_thresh_name =
2109 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2110 "txpt#txht#txwt#rxpt#rxht#rxwt");
2111 cmdline_parse_token_num_t cmd_config_thresh_value =
2112 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2114 cmdline_parse_inst_t cmd_config_thresh = {
2115 .f = cmd_config_thresh_parsed,
2117 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2119 (void *)&cmd_config_thresh_port,
2120 (void *)&cmd_config_thresh_keyword,
2121 (void *)&cmd_config_thresh_all,
2122 (void *)&cmd_config_thresh_name,
2123 (void *)&cmd_config_thresh_value,
2128 /* *** configure free/rs threshold *** */
2129 struct cmd_config_threshold {
2130 cmdline_fixed_string_t port;
2131 cmdline_fixed_string_t keyword;
2132 cmdline_fixed_string_t all;
2133 cmdline_fixed_string_t name;
2138 cmd_config_threshold_parsed(void *parsed_result,
2139 __attribute__((unused)) struct cmdline *cl,
2140 __attribute__((unused)) void *data)
2142 struct cmd_config_threshold *res = parsed_result;
2144 if (!all_ports_stopped()) {
2145 printf("Please stop all ports first\n");
2149 if (!strcmp(res->name, "txfreet"))
2150 tx_free_thresh = res->value;
2151 else if (!strcmp(res->name, "txrst"))
2152 tx_rs_thresh = res->value;
2153 else if (!strcmp(res->name, "rxfreet"))
2154 rx_free_thresh = res->value;
2156 printf("Unknown parameter\n");
2162 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2165 cmdline_parse_token_string_t cmd_config_threshold_port =
2166 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2167 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2168 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2170 cmdline_parse_token_string_t cmd_config_threshold_all =
2171 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2172 cmdline_parse_token_string_t cmd_config_threshold_name =
2173 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2174 "txfreet#txrst#rxfreet");
2175 cmdline_parse_token_num_t cmd_config_threshold_value =
2176 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2178 cmdline_parse_inst_t cmd_config_threshold = {
2179 .f = cmd_config_threshold_parsed,
2181 .help_str = "port config all txfreet|txrst|rxfreet value",
2183 (void *)&cmd_config_threshold_port,
2184 (void *)&cmd_config_threshold_keyword,
2185 (void *)&cmd_config_threshold_all,
2186 (void *)&cmd_config_threshold_name,
2187 (void *)&cmd_config_threshold_value,
2193 struct cmd_stop_result {
2194 cmdline_fixed_string_t stop;
2197 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2198 __attribute__((unused)) struct cmdline *cl,
2199 __attribute__((unused)) void *data)
2201 stop_packet_forwarding();
2204 cmdline_parse_token_string_t cmd_stop_stop =
2205 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2207 cmdline_parse_inst_t cmd_stop = {
2208 .f = cmd_stop_parsed,
2210 .help_str = "stop - stop packet forwarding",
2212 (void *)&cmd_stop_stop,
2217 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2220 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2221 unsigned int *parsed_items, int check_unique_values)
2223 unsigned int nb_item;
2231 * First parse all items in the list and store their value.
2236 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2238 if ((c >= '0') && (c <= '9')) {
2239 value = (unsigned int) (value * 10 + (c - '0'));
2244 printf("character %c is not a decimal digit\n", c);
2248 printf("No valid value before comma\n");
2251 if (nb_item < max_items) {
2252 parsed_items[nb_item] = value;
2258 if (nb_item >= max_items) {
2259 printf("Number of %s = %u > %u (maximum items)\n",
2260 item_name, nb_item + 1, max_items);
2263 parsed_items[nb_item++] = value;
2264 if (! check_unique_values)
2268 * Then, check that all values in the list are differents.
2269 * No optimization here...
2271 for (i = 0; i < nb_item; i++) {
2272 for (j = i + 1; j < nb_item; j++) {
2273 if (parsed_items[j] == parsed_items[i]) {
2274 printf("duplicated %s %u at index %u and %u\n",
2275 item_name, parsed_items[i], i, j);
2283 struct cmd_set_list_result {
2284 cmdline_fixed_string_t cmd_keyword;
2285 cmdline_fixed_string_t list_name;
2286 cmdline_fixed_string_t list_of_items;
2289 static void cmd_set_list_parsed(void *parsed_result,
2290 __attribute__((unused)) struct cmdline *cl,
2291 __attribute__((unused)) void *data)
2293 struct cmd_set_list_result *res;
2295 unsigned int lcorelist[RTE_MAX_LCORE];
2296 unsigned int portlist[RTE_MAX_ETHPORTS];
2298 unsigned int nb_item;
2300 res = parsed_result;
2301 if (!strcmp(res->list_name, "corelist")) {
2302 nb_item = parse_item_list(res->list_of_items, "core",
2304 parsed_items.lcorelist, 1);
2306 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2309 if (!strcmp(res->list_name, "portlist")) {
2310 nb_item = parse_item_list(res->list_of_items, "port",
2312 parsed_items.portlist, 1);
2314 set_fwd_ports_list(parsed_items.portlist, nb_item);
2318 cmdline_parse_token_string_t cmd_set_list_keyword =
2319 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2321 cmdline_parse_token_string_t cmd_set_list_name =
2322 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2323 "corelist#portlist");
2324 cmdline_parse_token_string_t cmd_set_list_of_items =
2325 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2328 cmdline_parse_inst_t cmd_set_fwd_list = {
2329 .f = cmd_set_list_parsed,
2331 .help_str = "set corelist|portlist x[,y]*",
2333 (void *)&cmd_set_list_keyword,
2334 (void *)&cmd_set_list_name,
2335 (void *)&cmd_set_list_of_items,
2340 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2342 struct cmd_setmask_result {
2343 cmdline_fixed_string_t set;
2344 cmdline_fixed_string_t mask;
2348 static void cmd_set_mask_parsed(void *parsed_result,
2349 __attribute__((unused)) struct cmdline *cl,
2350 __attribute__((unused)) void *data)
2352 struct cmd_setmask_result *res = parsed_result;
2354 if (!strcmp(res->mask, "coremask"))
2355 set_fwd_lcores_mask(res->hexavalue);
2356 else if (!strcmp(res->mask, "portmask"))
2357 set_fwd_ports_mask(res->hexavalue);
2360 cmdline_parse_token_string_t cmd_setmask_set =
2361 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2362 cmdline_parse_token_string_t cmd_setmask_mask =
2363 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2364 "coremask#portmask");
2365 cmdline_parse_token_num_t cmd_setmask_value =
2366 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2368 cmdline_parse_inst_t cmd_set_fwd_mask = {
2369 .f = cmd_set_mask_parsed,
2371 .help_str = "set coremask|portmask hexadecimal value",
2373 (void *)&cmd_setmask_set,
2374 (void *)&cmd_setmask_mask,
2375 (void *)&cmd_setmask_value,
2381 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2383 struct cmd_set_result {
2384 cmdline_fixed_string_t set;
2385 cmdline_fixed_string_t what;
2389 static void cmd_set_parsed(void *parsed_result,
2390 __attribute__((unused)) struct cmdline *cl,
2391 __attribute__((unused)) void *data)
2393 struct cmd_set_result *res = parsed_result;
2394 if (!strcmp(res->what, "nbport"))
2395 set_fwd_ports_number(res->value);
2396 else if (!strcmp(res->what, "nbcore"))
2397 set_fwd_lcores_number(res->value);
2398 else if (!strcmp(res->what, "burst"))
2399 set_nb_pkt_per_burst(res->value);
2400 else if (!strcmp(res->what, "verbose"))
2401 set_verbose_level(res->value);
2404 cmdline_parse_token_string_t cmd_set_set =
2405 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2406 cmdline_parse_token_string_t cmd_set_what =
2407 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2408 "nbport#nbcore#burst#verbose");
2409 cmdline_parse_token_num_t cmd_set_value =
2410 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2412 cmdline_parse_inst_t cmd_set_numbers = {
2413 .f = cmd_set_parsed,
2415 .help_str = "set nbport|nbcore|burst|verbose value",
2417 (void *)&cmd_set_set,
2418 (void *)&cmd_set_what,
2419 (void *)&cmd_set_value,
2424 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2426 struct cmd_set_txpkts_result {
2427 cmdline_fixed_string_t cmd_keyword;
2428 cmdline_fixed_string_t txpkts;
2429 cmdline_fixed_string_t seg_lengths;
2433 cmd_set_txpkts_parsed(void *parsed_result,
2434 __attribute__((unused)) struct cmdline *cl,
2435 __attribute__((unused)) void *data)
2437 struct cmd_set_txpkts_result *res;
2438 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2439 unsigned int nb_segs;
2441 res = parsed_result;
2442 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2443 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2445 set_tx_pkt_segments(seg_lengths, nb_segs);
2448 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2449 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2450 cmd_keyword, "set");
2451 cmdline_parse_token_string_t cmd_set_txpkts_name =
2452 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2454 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2455 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2458 cmdline_parse_inst_t cmd_set_txpkts = {
2459 .f = cmd_set_txpkts_parsed,
2461 .help_str = "set txpkts x[,y]*",
2463 (void *)&cmd_set_txpkts_keyword,
2464 (void *)&cmd_set_txpkts_name,
2465 (void *)&cmd_set_txpkts_lengths,
2470 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2471 struct cmd_rx_vlan_filter_all_result {
2472 cmdline_fixed_string_t rx_vlan;
2473 cmdline_fixed_string_t what;
2474 cmdline_fixed_string_t all;
2479 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2480 __attribute__((unused)) struct cmdline *cl,
2481 __attribute__((unused)) void *data)
2483 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2485 if (!strcmp(res->what, "add"))
2486 rx_vlan_all_filter_set(res->port_id, 1);
2488 rx_vlan_all_filter_set(res->port_id, 0);
2491 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2492 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2493 rx_vlan, "rx_vlan");
2494 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2495 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2497 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2498 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2500 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2501 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2504 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2505 .f = cmd_rx_vlan_filter_all_parsed,
2507 .help_str = "add/remove all identifiers to/from the set of VLAN "
2508 "Identifiers filtered by a port",
2510 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2511 (void *)&cmd_rx_vlan_filter_all_what,
2512 (void *)&cmd_rx_vlan_filter_all_all,
2513 (void *)&cmd_rx_vlan_filter_all_portid,
2518 /* *** VLAN OFFLOAD SET ON A PORT *** */
2519 struct cmd_vlan_offload_result {
2520 cmdline_fixed_string_t vlan;
2521 cmdline_fixed_string_t set;
2522 cmdline_fixed_string_t what;
2523 cmdline_fixed_string_t on;
2524 cmdline_fixed_string_t port_id;
2528 cmd_vlan_offload_parsed(void *parsed_result,
2529 __attribute__((unused)) struct cmdline *cl,
2530 __attribute__((unused)) void *data)
2533 struct cmd_vlan_offload_result *res = parsed_result;
2536 portid_t port_id = 0;
2540 len = strnlen(str, STR_TOKEN_SIZE);
2542 /* Get port_id first */
2550 tmp = strtoul(str, NULL, 0);
2551 /* If port_id greater that what portid_t can represent, return */
2552 if(tmp >= RTE_MAX_ETHPORTS)
2554 port_id = (portid_t)tmp;
2556 if (!strcmp(res->on, "on"))
2561 if (!strcmp(res->what, "strip"))
2562 rx_vlan_strip_set(port_id, on);
2563 else if(!strcmp(res->what, "stripq")){
2564 uint16_t queue_id = 0;
2566 /* No queue_id, return */
2568 printf("must specify (port,queue_id)\n");
2571 tmp = strtoul(str + i + 1, NULL, 0);
2572 /* If queue_id greater that what 16-bits can represent, return */
2576 queue_id = (uint16_t)tmp;
2577 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2579 else if (!strcmp(res->what, "filter"))
2580 rx_vlan_filter_set(port_id, on);
2582 vlan_extend_set(port_id, on);
2587 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2588 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2590 cmdline_parse_token_string_t cmd_vlan_offload_set =
2591 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2593 cmdline_parse_token_string_t cmd_vlan_offload_what =
2594 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2595 what, "strip#filter#qinq#stripq");
2596 cmdline_parse_token_string_t cmd_vlan_offload_on =
2597 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2599 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2600 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2603 cmdline_parse_inst_t cmd_vlan_offload = {
2604 .f = cmd_vlan_offload_parsed,
2606 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2607 " qinq(extended) for both rx/tx sides ",
2609 (void *)&cmd_vlan_offload_vlan,
2610 (void *)&cmd_vlan_offload_set,
2611 (void *)&cmd_vlan_offload_what,
2612 (void *)&cmd_vlan_offload_on,
2613 (void *)&cmd_vlan_offload_portid,
2618 /* *** VLAN TPID SET ON A PORT *** */
2619 struct cmd_vlan_tpid_result {
2620 cmdline_fixed_string_t vlan;
2621 cmdline_fixed_string_t set;
2622 cmdline_fixed_string_t what;
2628 cmd_vlan_tpid_parsed(void *parsed_result,
2629 __attribute__((unused)) struct cmdline *cl,
2630 __attribute__((unused)) void *data)
2632 struct cmd_vlan_tpid_result *res = parsed_result;
2633 vlan_tpid_set(res->port_id, res->tp_id);
2637 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2638 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2640 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2641 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2643 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2644 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2646 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2647 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2649 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2650 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2653 cmdline_parse_inst_t cmd_vlan_tpid = {
2654 .f = cmd_vlan_tpid_parsed,
2656 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2658 (void *)&cmd_vlan_tpid_vlan,
2659 (void *)&cmd_vlan_tpid_set,
2660 (void *)&cmd_vlan_tpid_what,
2661 (void *)&cmd_vlan_tpid_tpid,
2662 (void *)&cmd_vlan_tpid_portid,
2667 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2668 struct cmd_rx_vlan_filter_result {
2669 cmdline_fixed_string_t rx_vlan;
2670 cmdline_fixed_string_t what;
2676 cmd_rx_vlan_filter_parsed(void *parsed_result,
2677 __attribute__((unused)) struct cmdline *cl,
2678 __attribute__((unused)) void *data)
2680 struct cmd_rx_vlan_filter_result *res = parsed_result;
2682 if (!strcmp(res->what, "add"))
2683 rx_vft_set(res->port_id, res->vlan_id, 1);
2685 rx_vft_set(res->port_id, res->vlan_id, 0);
2688 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2689 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2690 rx_vlan, "rx_vlan");
2691 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2692 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2694 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2695 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2697 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2698 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2701 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2702 .f = cmd_rx_vlan_filter_parsed,
2704 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2705 "Identifiers filtered by a port",
2707 (void *)&cmd_rx_vlan_filter_rx_vlan,
2708 (void *)&cmd_rx_vlan_filter_what,
2709 (void *)&cmd_rx_vlan_filter_vlanid,
2710 (void *)&cmd_rx_vlan_filter_portid,
2715 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2716 struct cmd_tx_vlan_set_result {
2717 cmdline_fixed_string_t tx_vlan;
2718 cmdline_fixed_string_t set;
2724 cmd_tx_vlan_set_parsed(void *parsed_result,
2725 __attribute__((unused)) struct cmdline *cl,
2726 __attribute__((unused)) void *data)
2728 struct cmd_tx_vlan_set_result *res = parsed_result;
2729 tx_vlan_set(res->port_id, res->vlan_id);
2732 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2733 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2734 tx_vlan, "tx_vlan");
2735 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2736 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2738 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2739 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2741 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2742 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2745 cmdline_parse_inst_t cmd_tx_vlan_set = {
2746 .f = cmd_tx_vlan_set_parsed,
2748 .help_str = "enable hardware insertion of a VLAN header with a given "
2749 "TAG Identifier in packets sent on a port",
2751 (void *)&cmd_tx_vlan_set_tx_vlan,
2752 (void *)&cmd_tx_vlan_set_set,
2753 (void *)&cmd_tx_vlan_set_vlanid,
2754 (void *)&cmd_tx_vlan_set_portid,
2759 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2760 struct cmd_tx_vlan_set_pvid_result {
2761 cmdline_fixed_string_t tx_vlan;
2762 cmdline_fixed_string_t set;
2763 cmdline_fixed_string_t pvid;
2766 cmdline_fixed_string_t mode;
2770 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2771 __attribute__((unused)) struct cmdline *cl,
2772 __attribute__((unused)) void *data)
2774 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2776 if (strcmp(res->mode, "on") == 0)
2777 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2779 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2782 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2783 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2784 tx_vlan, "tx_vlan");
2785 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2786 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2788 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2789 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2791 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2792 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2794 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2795 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2797 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2798 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2801 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2802 .f = cmd_tx_vlan_set_pvid_parsed,
2804 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2806 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2807 (void *)&cmd_tx_vlan_set_pvid_set,
2808 (void *)&cmd_tx_vlan_set_pvid_pvid,
2809 (void *)&cmd_tx_vlan_set_pvid_port_id,
2810 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2811 (void *)&cmd_tx_vlan_set_pvid_mode,
2816 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2817 struct cmd_tx_vlan_reset_result {
2818 cmdline_fixed_string_t tx_vlan;
2819 cmdline_fixed_string_t reset;
2824 cmd_tx_vlan_reset_parsed(void *parsed_result,
2825 __attribute__((unused)) struct cmdline *cl,
2826 __attribute__((unused)) void *data)
2828 struct cmd_tx_vlan_reset_result *res = parsed_result;
2830 tx_vlan_reset(res->port_id);
2833 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2834 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2835 tx_vlan, "tx_vlan");
2836 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2837 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2839 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2840 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2843 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2844 .f = cmd_tx_vlan_reset_parsed,
2846 .help_str = "disable hardware insertion of a VLAN header in packets "
2849 (void *)&cmd_tx_vlan_reset_tx_vlan,
2850 (void *)&cmd_tx_vlan_reset_reset,
2851 (void *)&cmd_tx_vlan_reset_portid,
2857 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2858 struct cmd_tx_cksum_result {
2859 cmdline_fixed_string_t tx_cksum;
2860 cmdline_fixed_string_t mode;
2861 cmdline_fixed_string_t proto;
2862 cmdline_fixed_string_t hwsw;
2867 cmd_tx_cksum_parsed(void *parsed_result,
2868 __attribute__((unused)) struct cmdline *cl,
2869 __attribute__((unused)) void *data)
2871 struct cmd_tx_cksum_result *res = parsed_result;
2873 uint16_t ol_flags, mask = 0;
2874 struct rte_eth_dev_info dev_info;
2876 if (port_id_is_invalid(res->port_id)) {
2877 printf("invalid port %d\n", res->port_id);
2881 if (!strcmp(res->mode, "set")) {
2883 if (!strcmp(res->hwsw, "hw"))
2886 if (!strcmp(res->proto, "ip")) {
2887 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2888 } else if (!strcmp(res->proto, "udp")) {
2889 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2890 } else if (!strcmp(res->proto, "tcp")) {
2891 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2892 } else if (!strcmp(res->proto, "sctp")) {
2893 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2894 } else if (!strcmp(res->proto, "vxlan")) {
2895 mask = TESTPMD_TX_OFFLOAD_VXLAN_CKSUM;
2899 ports[res->port_id].tx_ol_flags |= mask;
2901 ports[res->port_id].tx_ol_flags &= (~mask);
2904 ol_flags = ports[res->port_id].tx_ol_flags;
2905 printf("IP checksum offload is %s\n",
2906 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2907 printf("UDP checksum offload is %s\n",
2908 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2909 printf("TCP checksum offload is %s\n",
2910 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2911 printf("SCTP checksum offload is %s\n",
2912 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2913 printf("VxLAN checksum offload is %s\n",
2914 (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw");
2916 /* display warnings if configuration is not supported by the NIC */
2917 rte_eth_dev_info_get(res->port_id, &dev_info);
2918 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2919 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2920 printf("Warning: hardware IP checksum enabled but not "
2921 "supported by port %d\n", res->port_id);
2923 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2924 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2925 printf("Warning: hardware UDP checksum enabled but not "
2926 "supported by port %d\n", res->port_id);
2928 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2929 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2930 printf("Warning: hardware TCP checksum enabled but not "
2931 "supported by port %d\n", res->port_id);
2933 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2934 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2935 printf("Warning: hardware SCTP checksum enabled but not "
2936 "supported by port %d\n", res->port_id);
2940 cmdline_parse_token_string_t cmd_tx_cksum_tx_cksum =
2941 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2942 tx_cksum, "tx_checksum");
2943 cmdline_parse_token_string_t cmd_tx_cksum_mode =
2944 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2946 cmdline_parse_token_string_t cmd_tx_cksum_proto =
2947 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2948 proto, "ip#tcp#udp#sctp#vxlan");
2949 cmdline_parse_token_string_t cmd_tx_cksum_hwsw =
2950 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2952 cmdline_parse_token_num_t cmd_tx_cksum_portid =
2953 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_result,
2956 cmdline_parse_inst_t cmd_tx_cksum_set = {
2957 .f = cmd_tx_cksum_parsed,
2959 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
2960 "using csum forward engine: tx_cksum set ip|tcp|udp|sctp|vxlan hw|sw <port>",
2962 (void *)&cmd_tx_cksum_tx_cksum,
2963 (void *)&cmd_tx_cksum_mode,
2964 (void *)&cmd_tx_cksum_proto,
2965 (void *)&cmd_tx_cksum_hwsw,
2966 (void *)&cmd_tx_cksum_portid,
2971 cmdline_parse_token_string_t cmd_tx_cksum_mode_show =
2972 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result,
2975 cmdline_parse_inst_t cmd_tx_cksum_show = {
2976 .f = cmd_tx_cksum_parsed,
2978 .help_str = "show checksum offload configuration: tx_cksum show <port>",
2980 (void *)&cmd_tx_cksum_tx_cksum,
2981 (void *)&cmd_tx_cksum_mode_show,
2982 (void *)&cmd_tx_cksum_portid,
2987 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2988 struct cmd_set_flush_rx {
2989 cmdline_fixed_string_t set;
2990 cmdline_fixed_string_t flush_rx;
2991 cmdline_fixed_string_t mode;
2995 cmd_set_flush_rx_parsed(void *parsed_result,
2996 __attribute__((unused)) struct cmdline *cl,
2997 __attribute__((unused)) void *data)
2999 struct cmd_set_flush_rx *res = parsed_result;
3000 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3003 cmdline_parse_token_string_t cmd_setflushrx_set =
3004 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3006 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3007 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3008 flush_rx, "flush_rx");
3009 cmdline_parse_token_string_t cmd_setflushrx_mode =
3010 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3014 cmdline_parse_inst_t cmd_set_flush_rx = {
3015 .f = cmd_set_flush_rx_parsed,
3016 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3019 (void *)&cmd_setflushrx_set,
3020 (void *)&cmd_setflushrx_flush_rx,
3021 (void *)&cmd_setflushrx_mode,
3026 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3027 struct cmd_set_link_check {
3028 cmdline_fixed_string_t set;
3029 cmdline_fixed_string_t link_check;
3030 cmdline_fixed_string_t mode;
3034 cmd_set_link_check_parsed(void *parsed_result,
3035 __attribute__((unused)) struct cmdline *cl,
3036 __attribute__((unused)) void *data)
3038 struct cmd_set_link_check *res = parsed_result;
3039 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3042 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3043 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3045 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3046 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3047 link_check, "link_check");
3048 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3049 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3053 cmdline_parse_inst_t cmd_set_link_check = {
3054 .f = cmd_set_link_check_parsed,
3055 .help_str = "set link_check on|off: enable/disable link status check "
3056 "when starting/stopping a port",
3059 (void *)&cmd_setlinkcheck_set,
3060 (void *)&cmd_setlinkcheck_link_check,
3061 (void *)&cmd_setlinkcheck_mode,
3066 #ifdef RTE_NIC_BYPASS
3067 /* *** SET NIC BYPASS MODE *** */
3068 struct cmd_set_bypass_mode_result {
3069 cmdline_fixed_string_t set;
3070 cmdline_fixed_string_t bypass;
3071 cmdline_fixed_string_t mode;
3072 cmdline_fixed_string_t value;
3077 cmd_set_bypass_mode_parsed(void *parsed_result,
3078 __attribute__((unused)) struct cmdline *cl,
3079 __attribute__((unused)) void *data)
3081 struct cmd_set_bypass_mode_result *res = parsed_result;
3082 portid_t port_id = res->port_id;
3083 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3085 if (!bypass_is_supported(port_id))
3088 if (!strcmp(res->value, "bypass"))
3089 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3090 else if (!strcmp(res->value, "isolate"))
3091 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3093 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3095 /* Set the bypass mode for the relevant port. */
3096 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3097 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3101 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3102 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3104 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3105 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3107 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3108 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3110 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3111 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3112 value, "normal#bypass#isolate");
3113 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3114 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3117 cmdline_parse_inst_t cmd_set_bypass_mode = {
3118 .f = cmd_set_bypass_mode_parsed,
3119 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3120 "Set the NIC bypass mode for port_id",
3123 (void *)&cmd_setbypass_mode_set,
3124 (void *)&cmd_setbypass_mode_bypass,
3125 (void *)&cmd_setbypass_mode_mode,
3126 (void *)&cmd_setbypass_mode_value,
3127 (void *)&cmd_setbypass_mode_port,
3132 /* *** SET NIC BYPASS EVENT *** */
3133 struct cmd_set_bypass_event_result {
3134 cmdline_fixed_string_t set;
3135 cmdline_fixed_string_t bypass;
3136 cmdline_fixed_string_t event;
3137 cmdline_fixed_string_t event_value;
3138 cmdline_fixed_string_t mode;
3139 cmdline_fixed_string_t mode_value;
3144 cmd_set_bypass_event_parsed(void *parsed_result,
3145 __attribute__((unused)) struct cmdline *cl,
3146 __attribute__((unused)) void *data)
3149 struct cmd_set_bypass_event_result *res = parsed_result;
3150 portid_t port_id = res->port_id;
3151 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3152 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3154 if (!bypass_is_supported(port_id))
3157 if (!strcmp(res->event_value, "timeout"))
3158 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3159 else if (!strcmp(res->event_value, "os_on"))
3160 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3161 else if (!strcmp(res->event_value, "os_off"))
3162 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3163 else if (!strcmp(res->event_value, "power_on"))
3164 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3165 else if (!strcmp(res->event_value, "power_off"))
3166 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3168 bypass_event = RTE_BYPASS_EVENT_NONE;
3170 if (!strcmp(res->mode_value, "bypass"))
3171 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3172 else if (!strcmp(res->mode_value, "isolate"))
3173 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3175 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3177 /* Set the watchdog timeout. */
3178 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3181 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3182 (rc = rte_eth_dev_wd_timeout_store(port_id,
3183 bypass_timeout)) != 0) {
3184 printf("Failed to set timeout value %u "
3185 "for port %d, errto code: %d.\n",
3186 bypass_timeout, port_id, rc);
3190 /* Set the bypass event to transition to bypass mode. */
3191 if (0 != rte_eth_dev_bypass_event_store(port_id,
3192 bypass_event, bypass_mode)) {
3193 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3198 cmdline_parse_token_string_t cmd_setbypass_event_set =
3199 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3201 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3202 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3204 cmdline_parse_token_string_t cmd_setbypass_event_event =
3205 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3207 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3208 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3209 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3210 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3211 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3213 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3214 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3215 mode_value, "normal#bypass#isolate");
3216 cmdline_parse_token_num_t cmd_setbypass_event_port =
3217 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3220 cmdline_parse_inst_t cmd_set_bypass_event = {
3221 .f = cmd_set_bypass_event_parsed,
3222 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3223 "mode (normal|bypass|isolate) (port_id): "
3224 "Set the NIC bypass event mode for port_id",
3227 (void *)&cmd_setbypass_event_set,
3228 (void *)&cmd_setbypass_event_bypass,
3229 (void *)&cmd_setbypass_event_event,
3230 (void *)&cmd_setbypass_event_event_value,
3231 (void *)&cmd_setbypass_event_mode,
3232 (void *)&cmd_setbypass_event_mode_value,
3233 (void *)&cmd_setbypass_event_port,
3239 /* *** SET NIC BYPASS TIMEOUT *** */
3240 struct cmd_set_bypass_timeout_result {
3241 cmdline_fixed_string_t set;
3242 cmdline_fixed_string_t bypass;
3243 cmdline_fixed_string_t timeout;
3244 cmdline_fixed_string_t value;
3248 cmd_set_bypass_timeout_parsed(void *parsed_result,
3249 __attribute__((unused)) struct cmdline *cl,
3250 __attribute__((unused)) void *data)
3252 struct cmd_set_bypass_timeout_result *res = parsed_result;
3254 if (!strcmp(res->value, "1.5"))
3255 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3256 else if (!strcmp(res->value, "2"))
3257 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3258 else if (!strcmp(res->value, "3"))
3259 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3260 else if (!strcmp(res->value, "4"))
3261 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3262 else if (!strcmp(res->value, "8"))
3263 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3264 else if (!strcmp(res->value, "16"))
3265 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3266 else if (!strcmp(res->value, "32"))
3267 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3269 bypass_timeout = RTE_BYPASS_TMT_OFF;
3272 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3273 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3275 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3276 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3278 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3279 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3280 timeout, "timeout");
3281 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3282 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3283 value, "0#1.5#2#3#4#8#16#32");
3285 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3286 .f = cmd_set_bypass_timeout_parsed,
3287 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3288 "Set the NIC bypass watchdog timeout",
3291 (void *)&cmd_setbypass_timeout_set,
3292 (void *)&cmd_setbypass_timeout_bypass,
3293 (void *)&cmd_setbypass_timeout_timeout,
3294 (void *)&cmd_setbypass_timeout_value,
3299 /* *** SHOW NIC BYPASS MODE *** */
3300 struct cmd_show_bypass_config_result {
3301 cmdline_fixed_string_t show;
3302 cmdline_fixed_string_t bypass;
3303 cmdline_fixed_string_t config;
3308 cmd_show_bypass_config_parsed(void *parsed_result,
3309 __attribute__((unused)) struct cmdline *cl,
3310 __attribute__((unused)) void *data)
3312 struct cmd_show_bypass_config_result *res = parsed_result;
3313 uint32_t event_mode;
3314 uint32_t bypass_mode;
3315 portid_t port_id = res->port_id;
3316 uint32_t timeout = bypass_timeout;
3319 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3320 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3321 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3322 {"UNKNOWN", "normal", "bypass", "isolate"};
3323 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3330 int num_events = (sizeof events) / (sizeof events[0]);
3332 if (!bypass_is_supported(port_id))
3335 /* Display the bypass mode.*/
3336 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3337 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3341 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3342 bypass_mode = RTE_BYPASS_MODE_NONE;
3344 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3347 /* Display the bypass timeout.*/
3348 if (!RTE_BYPASS_TMT_VALID(timeout))
3349 timeout = RTE_BYPASS_TMT_OFF;
3351 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3353 /* Display the bypass events and associated modes. */
3354 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3356 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3357 printf("\tFailed to get bypass mode for event = %s\n",
3360 if (!RTE_BYPASS_MODE_VALID(event_mode))
3361 event_mode = RTE_BYPASS_MODE_NONE;
3363 printf("\tbypass event: %-16s = %s\n", events[i],
3369 cmdline_parse_token_string_t cmd_showbypass_config_show =
3370 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3372 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3373 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3375 cmdline_parse_token_string_t cmd_showbypass_config_config =
3376 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3378 cmdline_parse_token_num_t cmd_showbypass_config_port =
3379 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3382 cmdline_parse_inst_t cmd_show_bypass_config = {
3383 .f = cmd_show_bypass_config_parsed,
3384 .help_str = "show bypass config (port_id): "
3385 "Show the NIC bypass config for port_id",
3388 (void *)&cmd_showbypass_config_show,
3389 (void *)&cmd_showbypass_config_bypass,
3390 (void *)&cmd_showbypass_config_config,
3391 (void *)&cmd_showbypass_config_port,
3397 #ifdef RTE_LIBRTE_PMD_BOND
3398 /* *** SET BONDING MODE *** */
3399 struct cmd_set_bonding_mode_result {
3400 cmdline_fixed_string_t set;
3401 cmdline_fixed_string_t bonding;
3402 cmdline_fixed_string_t mode;
3407 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3408 __attribute__((unused)) struct cmdline *cl,
3409 __attribute__((unused)) void *data)
3411 struct cmd_set_bonding_mode_result *res = parsed_result;
3412 portid_t port_id = res->port_id;
3414 /* Set the bonding mode for the relevant port. */
3415 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3416 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3419 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3420 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3422 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3423 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3424 bonding, "bonding");
3425 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3426 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3428 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3429 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3431 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3432 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3435 cmdline_parse_inst_t cmd_set_bonding_mode = {
3436 .f = cmd_set_bonding_mode_parsed,
3437 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3440 (void *) &cmd_setbonding_mode_set,
3441 (void *) &cmd_setbonding_mode_bonding,
3442 (void *) &cmd_setbonding_mode_mode,
3443 (void *) &cmd_setbonding_mode_value,
3444 (void *) &cmd_setbonding_mode_port,
3449 /* *** SET BALANCE XMIT POLICY *** */
3450 struct cmd_set_bonding_balance_xmit_policy_result {
3451 cmdline_fixed_string_t set;
3452 cmdline_fixed_string_t bonding;
3453 cmdline_fixed_string_t balance_xmit_policy;
3455 cmdline_fixed_string_t policy;
3458 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3459 __attribute__((unused)) struct cmdline *cl,
3460 __attribute__((unused)) void *data)
3462 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3463 portid_t port_id = res->port_id;
3466 if (!strcmp(res->policy, "l2")) {
3467 policy = BALANCE_XMIT_POLICY_LAYER2;
3468 } else if (!strcmp(res->policy, "l23")) {
3469 policy = BALANCE_XMIT_POLICY_LAYER23;
3470 } else if (!strcmp(res->policy, "l34")) {
3471 policy = BALANCE_XMIT_POLICY_LAYER34;
3473 printf("\t Invalid xmit policy selection");
3477 /* Set the bonding mode for the relevant port. */
3478 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3479 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3484 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3485 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3487 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3488 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3489 bonding, "bonding");
3490 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3491 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3492 balance_xmit_policy, "balance_xmit_policy");
3493 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3494 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3496 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3497 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3498 policy, "l2#l23#l34");
3500 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3501 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3502 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3505 (void *)&cmd_setbonding_balance_xmit_policy_set,
3506 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3507 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3508 (void *)&cmd_setbonding_balance_xmit_policy_port,
3509 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3514 /* *** SHOW NIC BONDING CONFIGURATION *** */
3515 struct cmd_show_bonding_config_result {
3516 cmdline_fixed_string_t show;
3517 cmdline_fixed_string_t bonding;
3518 cmdline_fixed_string_t config;
3522 static void cmd_show_bonding_config_parsed(void *parsed_result,
3523 __attribute__((unused)) struct cmdline *cl,
3524 __attribute__((unused)) void *data)
3526 struct cmd_show_bonding_config_result *res = parsed_result;
3528 uint8_t slaves[RTE_MAX_ETHPORTS];
3529 int num_slaves, num_active_slaves;
3532 portid_t port_id = res->port_id;
3534 /* Display the bonding mode.*/
3535 bonding_mode = rte_eth_bond_mode_get(port_id);
3536 if (bonding_mode < 0) {
3537 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3540 printf("\tBonding mode: %d\n", bonding_mode);
3542 if (bonding_mode == BONDING_MODE_BALANCE) {
3543 int balance_xmit_policy;
3545 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3546 if (balance_xmit_policy < 0) {
3547 printf("\tFailed to get balance xmit policy for port = %d\n",
3551 printf("\tBalance Xmit Policy: ");
3553 switch (balance_xmit_policy) {
3554 case BALANCE_XMIT_POLICY_LAYER2:
3555 printf("BALANCE_XMIT_POLICY_LAYER2");
3557 case BALANCE_XMIT_POLICY_LAYER23:
3558 printf("BALANCE_XMIT_POLICY_LAYER23");
3560 case BALANCE_XMIT_POLICY_LAYER34:
3561 printf("BALANCE_XMIT_POLICY_LAYER34");
3568 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3570 if (num_slaves < 0) {
3571 printf("\tFailed to get slave list for port = %d\n", port_id);
3574 if (num_slaves > 0) {
3575 printf("\tSlaves (%d): [", num_slaves);
3576 for (i = 0; i < num_slaves - 1; i++)
3577 printf("%d ", slaves[i]);
3579 printf("%d]\n", slaves[num_slaves - 1]);
3581 printf("\tSlaves: []\n");
3585 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3588 if (num_active_slaves < 0) {
3589 printf("\tFailed to get active slave list for port = %d\n", port_id);
3592 if (num_active_slaves > 0) {
3593 printf("\tActive Slaves (%d): [", num_active_slaves);
3594 for (i = 0; i < num_active_slaves - 1; i++)
3595 printf("%d ", slaves[i]);
3597 printf("%d]\n", slaves[num_active_slaves - 1]);
3600 printf("\tActive Slaves: []\n");
3604 primary_id = rte_eth_bond_primary_get(port_id);
3605 if (primary_id < 0) {
3606 printf("\tFailed to get primary slave for port = %d\n", port_id);
3609 printf("\tPrimary: [%d]\n", primary_id);
3613 cmdline_parse_token_string_t cmd_showbonding_config_show =
3614 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3616 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3617 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3618 bonding, "bonding");
3619 cmdline_parse_token_string_t cmd_showbonding_config_config =
3620 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3622 cmdline_parse_token_num_t cmd_showbonding_config_port =
3623 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3626 cmdline_parse_inst_t cmd_show_bonding_config = {
3627 .f = cmd_show_bonding_config_parsed,
3628 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3631 (void *)&cmd_showbonding_config_show,
3632 (void *)&cmd_showbonding_config_bonding,
3633 (void *)&cmd_showbonding_config_config,
3634 (void *)&cmd_showbonding_config_port,
3639 /* *** SET BONDING PRIMARY *** */
3640 struct cmd_set_bonding_primary_result {
3641 cmdline_fixed_string_t set;
3642 cmdline_fixed_string_t bonding;
3643 cmdline_fixed_string_t primary;
3648 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3649 __attribute__((unused)) struct cmdline *cl,
3650 __attribute__((unused)) void *data)
3652 struct cmd_set_bonding_primary_result *res = parsed_result;
3653 portid_t master_port_id = res->port_id;
3654 portid_t slave_port_id = res->slave_id;
3656 /* Set the primary slave for a bonded device. */
3657 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3658 printf("\t Failed to set primary slave for port = %d.\n",
3665 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3666 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3668 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3669 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3670 bonding, "bonding");
3671 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3672 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3673 primary, "primary");
3674 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3675 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3677 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3678 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3681 cmdline_parse_inst_t cmd_set_bonding_primary = {
3682 .f = cmd_set_bonding_primary_parsed,
3683 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3686 (void *)&cmd_setbonding_primary_set,
3687 (void *)&cmd_setbonding_primary_bonding,
3688 (void *)&cmd_setbonding_primary_primary,
3689 (void *)&cmd_setbonding_primary_slave,
3690 (void *)&cmd_setbonding_primary_port,
3695 /* *** ADD SLAVE *** */
3696 struct cmd_add_bonding_slave_result {
3697 cmdline_fixed_string_t add;
3698 cmdline_fixed_string_t bonding;
3699 cmdline_fixed_string_t slave;
3704 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3705 __attribute__((unused)) struct cmdline *cl,
3706 __attribute__((unused)) void *data)
3708 struct cmd_add_bonding_slave_result *res = parsed_result;
3709 portid_t master_port_id = res->port_id;
3710 portid_t slave_port_id = res->slave_id;
3712 /* Set the primary slave for a bonded device. */
3713 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3714 printf("\t Failed to add slave %d to master port = %d.\n",
3715 slave_port_id, master_port_id);
3721 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3722 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3724 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3725 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3726 bonding, "bonding");
3727 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3728 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3730 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3731 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3733 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3734 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3737 cmdline_parse_inst_t cmd_add_bonding_slave = {
3738 .f = cmd_add_bonding_slave_parsed,
3739 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3742 (void *)&cmd_addbonding_slave_add,
3743 (void *)&cmd_addbonding_slave_bonding,
3744 (void *)&cmd_addbonding_slave_slave,
3745 (void *)&cmd_addbonding_slave_slaveid,
3746 (void *)&cmd_addbonding_slave_port,
3751 /* *** REMOVE SLAVE *** */
3752 struct cmd_remove_bonding_slave_result {
3753 cmdline_fixed_string_t remove;
3754 cmdline_fixed_string_t bonding;
3755 cmdline_fixed_string_t slave;
3760 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3761 __attribute__((unused)) struct cmdline *cl,
3762 __attribute__((unused)) void *data)
3764 struct cmd_remove_bonding_slave_result *res = parsed_result;
3765 portid_t master_port_id = res->port_id;
3766 portid_t slave_port_id = res->slave_id;
3768 /* Set the primary slave for a bonded device. */
3769 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3770 printf("\t Failed to remove slave %d from master port = %d.\n",
3771 slave_port_id, master_port_id);
3777 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3778 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3780 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3781 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3782 bonding, "bonding");
3783 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3784 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3786 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3787 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3789 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3790 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3793 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3794 .f = cmd_remove_bonding_slave_parsed,
3795 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3798 (void *)&cmd_removebonding_slave_remove,
3799 (void *)&cmd_removebonding_slave_bonding,
3800 (void *)&cmd_removebonding_slave_slave,
3801 (void *)&cmd_removebonding_slave_slaveid,
3802 (void *)&cmd_removebonding_slave_port,
3807 /* *** CREATE BONDED DEVICE *** */
3808 struct cmd_create_bonded_device_result {
3809 cmdline_fixed_string_t create;
3810 cmdline_fixed_string_t bonded;
3811 cmdline_fixed_string_t device;
3816 static int bond_dev_num = 0;
3818 static void cmd_create_bonded_device_parsed(void *parsed_result,
3819 __attribute__((unused)) struct cmdline *cl,
3820 __attribute__((unused)) void *data)
3822 struct cmd_create_bonded_device_result *res = parsed_result;
3823 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3826 if (test_done == 0) {
3827 printf("Please stop forwarding first\n");
3831 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3834 /* Create a new bonded device. */
3835 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3837 printf("\t Failed to create bonded device.\n");
3840 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3843 /* Update number of ports */
3844 nb_ports = rte_eth_dev_count();
3845 reconfig(port_id, res->socket);
3846 rte_eth_promiscuous_enable(port_id);
3851 cmdline_parse_token_string_t cmd_createbonded_device_create =
3852 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3854 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3855 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3857 cmdline_parse_token_string_t cmd_createbonded_device_device =
3858 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3860 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3861 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3863 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3864 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3867 cmdline_parse_inst_t cmd_create_bonded_device = {
3868 .f = cmd_create_bonded_device_parsed,
3869 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3872 (void *)&cmd_createbonded_device_create,
3873 (void *)&cmd_createbonded_device_bonded,
3874 (void *)&cmd_createbonded_device_device,
3875 (void *)&cmd_createbonded_device_mode,
3876 (void *)&cmd_createbonded_device_socket,
3881 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3882 struct cmd_set_bond_mac_addr_result {
3883 cmdline_fixed_string_t set;
3884 cmdline_fixed_string_t bonding;
3885 cmdline_fixed_string_t mac_addr;
3887 struct ether_addr address;
3890 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3891 __attribute__((unused)) struct cmdline *cl,
3892 __attribute__((unused)) void *data)
3894 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3897 if (res->port_num >= nb_ports) {
3898 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3902 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3904 /* check the return value and print it if is < 0 */
3906 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3909 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3910 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3911 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3912 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3914 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3915 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3917 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3918 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3919 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3920 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3922 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3923 .f = cmd_set_bond_mac_addr_parsed,
3925 .help_str = "set bonding mac_addr (port_id) (address): ",
3927 (void *)&cmd_set_bond_mac_addr_set,
3928 (void *)&cmd_set_bond_mac_addr_bonding,
3929 (void *)&cmd_set_bond_mac_addr_mac,
3930 (void *)&cmd_set_bond_mac_addr_portnum,
3931 (void *)&cmd_set_bond_mac_addr_addr,
3937 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
3938 struct cmd_set_bond_mon_period_result {
3939 cmdline_fixed_string_t set;
3940 cmdline_fixed_string_t bonding;
3941 cmdline_fixed_string_t mon_period;
3946 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
3947 __attribute__((unused)) struct cmdline *cl,
3948 __attribute__((unused)) void *data)
3950 struct cmd_set_bond_mon_period_result *res = parsed_result;
3953 if (res->port_num >= nb_ports) {
3954 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3958 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
3960 /* check the return value and print it if is < 0 */
3962 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3965 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
3966 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3968 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
3969 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3970 bonding, "bonding");
3971 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
3972 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3973 mon_period, "mon_period");
3974 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
3975 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3977 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
3978 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3981 cmdline_parse_inst_t cmd_set_bond_mon_period = {
3982 .f = cmd_set_bond_mon_period_parsed,
3984 .help_str = "set bonding mon_period (port_id) (period_ms): ",
3986 (void *)&cmd_set_bond_mon_period_set,
3987 (void *)&cmd_set_bond_mon_period_bonding,
3988 (void *)&cmd_set_bond_mon_period_mon_period,
3989 (void *)&cmd_set_bond_mon_period_portnum,
3990 (void *)&cmd_set_bond_mon_period_period_ms,
3995 #endif /* RTE_LIBRTE_PMD_BOND */
3997 /* *** SET FORWARDING MODE *** */
3998 struct cmd_set_fwd_mode_result {
3999 cmdline_fixed_string_t set;
4000 cmdline_fixed_string_t fwd;
4001 cmdline_fixed_string_t mode;
4004 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4005 __attribute__((unused)) struct cmdline *cl,
4006 __attribute__((unused)) void *data)
4008 struct cmd_set_fwd_mode_result *res = parsed_result;
4010 set_pkt_forwarding_mode(res->mode);
4013 cmdline_parse_token_string_t cmd_setfwd_set =
4014 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4015 cmdline_parse_token_string_t cmd_setfwd_fwd =
4016 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4017 cmdline_parse_token_string_t cmd_setfwd_mode =
4018 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4019 "" /* defined at init */);
4021 cmdline_parse_inst_t cmd_set_fwd_mode = {
4022 .f = cmd_set_fwd_mode_parsed,
4024 .help_str = NULL, /* defined at init */
4026 (void *)&cmd_setfwd_set,
4027 (void *)&cmd_setfwd_fwd,
4028 (void *)&cmd_setfwd_mode,
4033 static void cmd_set_fwd_mode_init(void)
4036 static char token[128];
4037 static char help[256];
4038 cmdline_parse_token_string_t *token_struct;
4040 modes = list_pkt_forwarding_modes();
4041 snprintf(help, sizeof help, "set fwd %s - "
4042 "set packet forwarding mode", modes);
4043 cmd_set_fwd_mode.help_str = help;
4045 /* string token separator is # */
4046 for (c = token; *modes != '\0'; modes++)
4051 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4052 token_struct->string_data.str = token;
4055 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4056 struct cmd_set_burst_tx_retry_result {
4057 cmdline_fixed_string_t set;
4058 cmdline_fixed_string_t burst;
4059 cmdline_fixed_string_t tx;
4060 cmdline_fixed_string_t delay;
4062 cmdline_fixed_string_t retry;
4066 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4067 __attribute__((unused)) struct cmdline *cl,
4068 __attribute__((unused)) void *data)
4070 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4072 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4073 && !strcmp(res->tx, "tx")) {
4074 if (!strcmp(res->delay, "delay"))
4075 burst_tx_delay_time = res->time;
4076 if (!strcmp(res->retry, "retry"))
4077 burst_tx_retry_num = res->retry_num;
4082 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4083 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4084 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4085 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4087 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4088 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4089 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4090 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4091 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4092 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4093 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4094 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4095 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4096 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4098 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4099 .f = cmd_set_burst_tx_retry_parsed,
4100 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4102 (void *)&cmd_set_burst_tx_retry_set,
4103 (void *)&cmd_set_burst_tx_retry_burst,
4104 (void *)&cmd_set_burst_tx_retry_tx,
4105 (void *)&cmd_set_burst_tx_retry_delay,
4106 (void *)&cmd_set_burst_tx_retry_time,
4107 (void *)&cmd_set_burst_tx_retry_retry,
4108 (void *)&cmd_set_burst_tx_retry_retry_num,
4113 /* *** SET PROMISC MODE *** */
4114 struct cmd_set_promisc_mode_result {
4115 cmdline_fixed_string_t set;
4116 cmdline_fixed_string_t promisc;
4117 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4118 uint8_t port_num; /* valid if "allports" argument == 0 */
4119 cmdline_fixed_string_t mode;
4122 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4123 __attribute__((unused)) struct cmdline *cl,
4126 struct cmd_set_promisc_mode_result *res = parsed_result;
4130 if (!strcmp(res->mode, "on"))
4137 for (i = 0; i < nb_ports; i++) {
4139 rte_eth_promiscuous_enable(i);
4141 rte_eth_promiscuous_disable(i);
4146 rte_eth_promiscuous_enable(res->port_num);
4148 rte_eth_promiscuous_disable(res->port_num);
4152 cmdline_parse_token_string_t cmd_setpromisc_set =
4153 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4154 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4155 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4157 cmdline_parse_token_string_t cmd_setpromisc_portall =
4158 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4160 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4161 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4163 cmdline_parse_token_string_t cmd_setpromisc_mode =
4164 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4167 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4168 .f = cmd_set_promisc_mode_parsed,
4170 .help_str = "set promisc all on|off: set promisc mode for all ports",
4172 (void *)&cmd_setpromisc_set,
4173 (void *)&cmd_setpromisc_promisc,
4174 (void *)&cmd_setpromisc_portall,
4175 (void *)&cmd_setpromisc_mode,
4180 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4181 .f = cmd_set_promisc_mode_parsed,
4183 .help_str = "set promisc X on|off: set promisc mode on port X",
4185 (void *)&cmd_setpromisc_set,
4186 (void *)&cmd_setpromisc_promisc,
4187 (void *)&cmd_setpromisc_portnum,
4188 (void *)&cmd_setpromisc_mode,
4193 /* *** SET ALLMULTI MODE *** */
4194 struct cmd_set_allmulti_mode_result {
4195 cmdline_fixed_string_t set;
4196 cmdline_fixed_string_t allmulti;
4197 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4198 uint8_t port_num; /* valid if "allports" argument == 0 */
4199 cmdline_fixed_string_t mode;
4202 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4203 __attribute__((unused)) struct cmdline *cl,
4206 struct cmd_set_allmulti_mode_result *res = parsed_result;
4210 if (!strcmp(res->mode, "on"))
4217 for (i = 0; i < nb_ports; i++) {
4219 rte_eth_allmulticast_enable(i);
4221 rte_eth_allmulticast_disable(i);
4226 rte_eth_allmulticast_enable(res->port_num);
4228 rte_eth_allmulticast_disable(res->port_num);
4232 cmdline_parse_token_string_t cmd_setallmulti_set =
4233 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4234 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4235 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4237 cmdline_parse_token_string_t cmd_setallmulti_portall =
4238 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4240 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4241 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4243 cmdline_parse_token_string_t cmd_setallmulti_mode =
4244 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4247 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4248 .f = cmd_set_allmulti_mode_parsed,
4250 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4252 (void *)&cmd_setallmulti_set,
4253 (void *)&cmd_setallmulti_allmulti,
4254 (void *)&cmd_setallmulti_portall,
4255 (void *)&cmd_setallmulti_mode,
4260 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4261 .f = cmd_set_allmulti_mode_parsed,
4263 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4265 (void *)&cmd_setallmulti_set,
4266 (void *)&cmd_setallmulti_allmulti,
4267 (void *)&cmd_setallmulti_portnum,
4268 (void *)&cmd_setallmulti_mode,
4273 /* *** ADD/REMOVE A PKT FILTER *** */
4274 struct cmd_pkt_filter_result {
4275 cmdline_fixed_string_t pkt_filter;
4277 cmdline_fixed_string_t protocol;
4278 cmdline_fixed_string_t src;
4279 cmdline_ipaddr_t ip_src;
4281 cmdline_fixed_string_t dst;
4282 cmdline_ipaddr_t ip_dst;
4284 cmdline_fixed_string_t flexbytes;
4285 uint16_t flexbytes_value;
4286 cmdline_fixed_string_t vlan;
4288 cmdline_fixed_string_t queue;
4290 cmdline_fixed_string_t soft;
4295 cmd_pkt_filter_parsed(void *parsed_result,
4296 __attribute__((unused)) struct cmdline *cl,
4297 __attribute__((unused)) void *data)
4299 struct rte_fdir_filter fdir_filter;
4300 struct cmd_pkt_filter_result *res = parsed_result;
4302 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4304 if (res->ip_src.family == AF_INET)
4305 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4307 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4308 &(res->ip_src.addr.ipv6),
4309 sizeof(struct in6_addr));
4311 if (res->ip_dst.family == AF_INET)
4312 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4314 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4315 &(res->ip_dst.addr.ipv6),
4316 sizeof(struct in6_addr));
4318 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4319 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4321 if (!strcmp(res->protocol, "udp"))
4322 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4323 else if (!strcmp(res->protocol, "tcp"))
4324 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4325 else if (!strcmp(res->protocol, "sctp"))
4326 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4327 else /* default only IP */
4328 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4330 if (res->ip_dst.family == AF_INET6)
4331 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4333 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4335 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4336 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4338 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4339 fdir_add_signature_filter(res->port_id, res->queue_id,
4341 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4342 fdir_update_signature_filter(res->port_id, res->queue_id,
4344 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4345 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4346 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4347 fdir_add_perfect_filter(res->port_id, res->soft_id,
4349 (uint8_t) (res->queue_id < 0),
4351 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4352 fdir_update_perfect_filter(res->port_id, res->soft_id,
4354 (uint8_t) (res->queue_id < 0),
4356 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4357 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4363 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4364 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4366 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4367 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4368 protocol, "ip#tcp#udp#sctp");
4369 cmdline_parse_token_string_t cmd_pkt_filter_src =
4370 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4372 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4373 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4375 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4376 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4378 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4379 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4381 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4382 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4384 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4385 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4387 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4388 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4389 flexbytes, "flexbytes");
4390 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4391 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4392 flexbytes_value, UINT16);
4393 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4394 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4396 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4397 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4399 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4400 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4402 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4403 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4405 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4406 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4408 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4409 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4413 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4414 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4415 pkt_filter, "add_signature_filter");
4416 cmdline_parse_inst_t cmd_add_signature_filter = {
4417 .f = cmd_pkt_filter_parsed,
4419 .help_str = "add a signature filter",
4421 (void *)&cmd_pkt_filter_add_signature_filter,
4422 (void *)&cmd_pkt_filter_port_id,
4423 (void *)&cmd_pkt_filter_protocol,
4424 (void *)&cmd_pkt_filter_src,
4425 (void *)&cmd_pkt_filter_ip_src,
4426 (void *)&cmd_pkt_filter_port_src,
4427 (void *)&cmd_pkt_filter_dst,
4428 (void *)&cmd_pkt_filter_ip_dst,
4429 (void *)&cmd_pkt_filter_port_dst,
4430 (void *)&cmd_pkt_filter_flexbytes,
4431 (void *)&cmd_pkt_filter_flexbytes_value,
4432 (void *)&cmd_pkt_filter_vlan,
4433 (void *)&cmd_pkt_filter_vlan_id,
4434 (void *)&cmd_pkt_filter_queue,
4435 (void *)&cmd_pkt_filter_queue_id,
4441 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4442 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4443 pkt_filter, "upd_signature_filter");
4444 cmdline_parse_inst_t cmd_upd_signature_filter = {
4445 .f = cmd_pkt_filter_parsed,
4447 .help_str = "update a signature filter",
4449 (void *)&cmd_pkt_filter_upd_signature_filter,
4450 (void *)&cmd_pkt_filter_port_id,
4451 (void *)&cmd_pkt_filter_protocol,
4452 (void *)&cmd_pkt_filter_src,
4453 (void *)&cmd_pkt_filter_ip_src,
4454 (void *)&cmd_pkt_filter_port_src,
4455 (void *)&cmd_pkt_filter_dst,
4456 (void *)&cmd_pkt_filter_ip_dst,
4457 (void *)&cmd_pkt_filter_port_dst,
4458 (void *)&cmd_pkt_filter_flexbytes,
4459 (void *)&cmd_pkt_filter_flexbytes_value,
4460 (void *)&cmd_pkt_filter_vlan,
4461 (void *)&cmd_pkt_filter_vlan_id,
4462 (void *)&cmd_pkt_filter_queue,
4463 (void *)&cmd_pkt_filter_queue_id,
4469 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4470 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4471 pkt_filter, "rm_signature_filter");
4472 cmdline_parse_inst_t cmd_rm_signature_filter = {
4473 .f = cmd_pkt_filter_parsed,
4475 .help_str = "remove a signature filter",
4477 (void *)&cmd_pkt_filter_rm_signature_filter,
4478 (void *)&cmd_pkt_filter_port_id,
4479 (void *)&cmd_pkt_filter_protocol,
4480 (void *)&cmd_pkt_filter_src,
4481 (void *)&cmd_pkt_filter_ip_src,
4482 (void *)&cmd_pkt_filter_port_src,
4483 (void *)&cmd_pkt_filter_dst,
4484 (void *)&cmd_pkt_filter_ip_dst,
4485 (void *)&cmd_pkt_filter_port_dst,
4486 (void *)&cmd_pkt_filter_flexbytes,
4487 (void *)&cmd_pkt_filter_flexbytes_value,
4488 (void *)&cmd_pkt_filter_vlan,
4489 (void *)&cmd_pkt_filter_vlan_id,
4495 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4496 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4497 pkt_filter, "add_perfect_filter");
4498 cmdline_parse_inst_t cmd_add_perfect_filter = {
4499 .f = cmd_pkt_filter_parsed,
4501 .help_str = "add a perfect filter",
4503 (void *)&cmd_pkt_filter_add_perfect_filter,
4504 (void *)&cmd_pkt_filter_port_id,
4505 (void *)&cmd_pkt_filter_protocol,
4506 (void *)&cmd_pkt_filter_src,
4507 (void *)&cmd_pkt_filter_ip_src,
4508 (void *)&cmd_pkt_filter_port_src,
4509 (void *)&cmd_pkt_filter_dst,
4510 (void *)&cmd_pkt_filter_ip_dst,
4511 (void *)&cmd_pkt_filter_port_dst,
4512 (void *)&cmd_pkt_filter_flexbytes,
4513 (void *)&cmd_pkt_filter_flexbytes_value,
4514 (void *)&cmd_pkt_filter_vlan,
4515 (void *)&cmd_pkt_filter_vlan_id,
4516 (void *)&cmd_pkt_filter_queue,
4517 (void *)&cmd_pkt_filter_queue_id,
4518 (void *)&cmd_pkt_filter_soft,
4519 (void *)&cmd_pkt_filter_soft_id,
4525 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4526 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4527 pkt_filter, "upd_perfect_filter");
4528 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4529 .f = cmd_pkt_filter_parsed,
4531 .help_str = "update a perfect filter",
4533 (void *)&cmd_pkt_filter_upd_perfect_filter,
4534 (void *)&cmd_pkt_filter_port_id,
4535 (void *)&cmd_pkt_filter_protocol,
4536 (void *)&cmd_pkt_filter_src,
4537 (void *)&cmd_pkt_filter_ip_src,
4538 (void *)&cmd_pkt_filter_port_src,
4539 (void *)&cmd_pkt_filter_dst,
4540 (void *)&cmd_pkt_filter_ip_dst,
4541 (void *)&cmd_pkt_filter_port_dst,
4542 (void *)&cmd_pkt_filter_flexbytes,
4543 (void *)&cmd_pkt_filter_flexbytes_value,
4544 (void *)&cmd_pkt_filter_vlan,
4545 (void *)&cmd_pkt_filter_vlan_id,
4546 (void *)&cmd_pkt_filter_queue,
4547 (void *)&cmd_pkt_filter_queue_id,
4548 (void *)&cmd_pkt_filter_soft,
4549 (void *)&cmd_pkt_filter_soft_id,
4555 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4556 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4557 pkt_filter, "rm_perfect_filter");
4558 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4559 .f = cmd_pkt_filter_parsed,
4561 .help_str = "remove a perfect filter",
4563 (void *)&cmd_pkt_filter_rm_perfect_filter,
4564 (void *)&cmd_pkt_filter_port_id,
4565 (void *)&cmd_pkt_filter_protocol,
4566 (void *)&cmd_pkt_filter_src,
4567 (void *)&cmd_pkt_filter_ip_src,
4568 (void *)&cmd_pkt_filter_port_src,
4569 (void *)&cmd_pkt_filter_dst,
4570 (void *)&cmd_pkt_filter_ip_dst,
4571 (void *)&cmd_pkt_filter_port_dst,
4572 (void *)&cmd_pkt_filter_flexbytes,
4573 (void *)&cmd_pkt_filter_flexbytes_value,
4574 (void *)&cmd_pkt_filter_vlan,
4575 (void *)&cmd_pkt_filter_vlan_id,
4576 (void *)&cmd_pkt_filter_soft,
4577 (void *)&cmd_pkt_filter_soft_id,
4582 /* *** SETUP MASKS FILTER *** */
4583 struct cmd_pkt_filter_masks_result {
4584 cmdline_fixed_string_t filter_mask;
4586 cmdline_fixed_string_t src_mask;
4587 uint32_t ip_src_mask;
4588 uint16_t ipv6_src_mask;
4589 uint16_t port_src_mask;
4590 cmdline_fixed_string_t dst_mask;
4591 uint32_t ip_dst_mask;
4592 uint16_t ipv6_dst_mask;
4593 uint16_t port_dst_mask;
4594 cmdline_fixed_string_t flexbytes;
4595 uint8_t flexbytes_value;
4596 cmdline_fixed_string_t vlan_id;
4597 uint8_t vlan_id_value;
4598 cmdline_fixed_string_t vlan_prio;
4599 uint8_t vlan_prio_value;
4600 cmdline_fixed_string_t only_ip_flow;
4601 uint8_t only_ip_flow_value;
4602 cmdline_fixed_string_t comp_ipv6_dst;
4603 uint8_t comp_ipv6_dst_value;
4607 cmd_pkt_filter_masks_parsed(void *parsed_result,
4608 __attribute__((unused)) struct cmdline *cl,
4609 __attribute__((unused)) void *data)
4611 struct rte_fdir_masks fdir_masks;
4612 struct cmd_pkt_filter_masks_result *res = parsed_result;
4614 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4616 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4617 fdir_masks.vlan_id = res->vlan_id_value;
4618 fdir_masks.vlan_prio = res->vlan_prio_value;
4619 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4620 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4621 fdir_masks.src_port_mask = res->port_src_mask;
4622 fdir_masks.dst_port_mask = res->port_dst_mask;
4623 fdir_masks.flexbytes = res->flexbytes_value;
4625 fdir_set_masks(res->port_id, &fdir_masks);
4628 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4629 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4630 filter_mask, "set_masks_filter");
4631 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4632 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4634 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4635 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4636 only_ip_flow, "only_ip_flow");
4637 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4638 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4639 only_ip_flow_value, UINT8);
4640 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4641 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4642 src_mask, "src_mask");
4643 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4644 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4645 ip_src_mask, UINT32);
4646 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4647 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4648 port_src_mask, UINT16);
4649 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4650 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4651 dst_mask, "dst_mask");
4652 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4653 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4654 ip_dst_mask, UINT32);
4655 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4656 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4657 port_dst_mask, UINT16);
4658 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4659 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4660 flexbytes, "flexbytes");
4661 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4662 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4663 flexbytes_value, UINT8);
4664 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4665 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4666 vlan_id, "vlan_id");
4667 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4668 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4669 vlan_id_value, UINT8);
4670 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4671 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4672 vlan_prio, "vlan_prio");
4673 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4674 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4675 vlan_prio_value, UINT8);
4677 cmdline_parse_inst_t cmd_set_masks_filter = {
4678 .f = cmd_pkt_filter_masks_parsed,
4680 .help_str = "setup masks filter",
4682 (void *)&cmd_pkt_filter_masks_filter_mask,
4683 (void *)&cmd_pkt_filter_masks_port_id,
4684 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4685 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4686 (void *)&cmd_pkt_filter_masks_src_mask,
4687 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4688 (void *)&cmd_pkt_filter_masks_port_src_mask,
4689 (void *)&cmd_pkt_filter_masks_dst_mask,
4690 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4691 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4692 (void *)&cmd_pkt_filter_masks_flexbytes,
4693 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4694 (void *)&cmd_pkt_filter_masks_vlan_id,
4695 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4696 (void *)&cmd_pkt_filter_masks_vlan_prio,
4697 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4703 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4704 __attribute__((unused)) struct cmdline *cl,
4705 __attribute__((unused)) void *data)
4707 struct rte_fdir_masks fdir_masks;
4708 struct cmd_pkt_filter_masks_result *res = parsed_result;
4710 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4712 fdir_masks.set_ipv6_mask = 1;
4713 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4714 fdir_masks.vlan_id = res->vlan_id_value;
4715 fdir_masks.vlan_prio = res->vlan_prio_value;
4716 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4717 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4718 fdir_masks.src_port_mask = res->port_src_mask;
4719 fdir_masks.dst_port_mask = res->port_dst_mask;
4720 fdir_masks.flexbytes = res->flexbytes_value;
4721 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4723 fdir_set_masks(res->port_id, &fdir_masks);
4726 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4727 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4728 filter_mask, "set_ipv6_masks_filter");
4729 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4730 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4731 ipv6_src_mask, UINT16);
4732 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4733 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4734 ipv6_dst_mask, UINT16);
4736 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4737 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4738 comp_ipv6_dst, "compare_dst");
4739 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4740 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4741 comp_ipv6_dst_value, UINT8);
4743 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4744 .f = cmd_pkt_filter_masks_ipv6_parsed,
4746 .help_str = "setup ipv6 masks filter",
4748 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4749 (void *)&cmd_pkt_filter_masks_port_id,
4750 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4751 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4752 (void *)&cmd_pkt_filter_masks_src_mask,
4753 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4754 (void *)&cmd_pkt_filter_masks_port_src_mask,
4755 (void *)&cmd_pkt_filter_masks_dst_mask,
4756 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4757 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4758 (void *)&cmd_pkt_filter_masks_flexbytes,
4759 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4760 (void *)&cmd_pkt_filter_masks_vlan_id,
4761 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4762 (void *)&cmd_pkt_filter_masks_vlan_prio,
4763 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4764 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4765 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4770 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4771 struct cmd_link_flow_ctrl_set_result {
4772 cmdline_fixed_string_t set;
4773 cmdline_fixed_string_t flow_ctrl;
4774 cmdline_fixed_string_t rx;
4775 cmdline_fixed_string_t rx_lfc_mode;
4776 cmdline_fixed_string_t tx;
4777 cmdline_fixed_string_t tx_lfc_mode;
4778 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4779 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4780 cmdline_fixed_string_t autoneg_str;
4781 cmdline_fixed_string_t autoneg;
4782 cmdline_fixed_string_t hw_str;
4783 uint32_t high_water;
4784 cmdline_fixed_string_t lw_str;
4786 cmdline_fixed_string_t pt_str;
4787 uint16_t pause_time;
4788 cmdline_fixed_string_t xon_str;
4793 cmdline_parse_token_string_t cmd_lfc_set_set =
4794 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4796 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4797 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4798 flow_ctrl, "flow_ctrl");
4799 cmdline_parse_token_string_t cmd_lfc_set_rx =
4800 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4802 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4803 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4804 rx_lfc_mode, "on#off");
4805 cmdline_parse_token_string_t cmd_lfc_set_tx =
4806 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4808 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4809 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4810 tx_lfc_mode, "on#off");
4811 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4812 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4813 hw_str, "high_water");
4814 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4815 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4816 high_water, UINT32);
4817 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4818 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4819 lw_str, "low_water");
4820 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4821 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4823 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4824 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4825 pt_str, "pause_time");
4826 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4827 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4828 pause_time, UINT16);
4829 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4830 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4831 xon_str, "send_xon");
4832 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4833 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4835 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4836 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4837 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4838 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4839 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4840 mac_ctrl_frame_fwd_mode, "on#off");
4841 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4842 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4843 autoneg_str, "autoneg");
4844 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4845 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4847 cmdline_parse_token_num_t cmd_lfc_set_portid =
4848 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4851 /* forward declaration */
4853 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4856 cmdline_parse_inst_t cmd_link_flow_control_set = {
4857 .f = cmd_link_flow_ctrl_set_parsed,
4859 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4860 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4861 autoneg on|off port_id",
4863 (void *)&cmd_lfc_set_set,
4864 (void *)&cmd_lfc_set_flow_ctrl,
4865 (void *)&cmd_lfc_set_rx,
4866 (void *)&cmd_lfc_set_rx_mode,
4867 (void *)&cmd_lfc_set_tx,
4868 (void *)&cmd_lfc_set_tx_mode,
4869 (void *)&cmd_lfc_set_high_water,
4870 (void *)&cmd_lfc_set_low_water,
4871 (void *)&cmd_lfc_set_pause_time,
4872 (void *)&cmd_lfc_set_send_xon,
4873 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4874 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4875 (void *)&cmd_lfc_set_autoneg_str,
4876 (void *)&cmd_lfc_set_autoneg,
4877 (void *)&cmd_lfc_set_portid,
4882 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4883 .f = cmd_link_flow_ctrl_set_parsed,
4884 .data = (void *)&cmd_link_flow_control_set_rx,
4885 .help_str = "Change rx flow control parameter: set flow_ctrl "
4886 "rx on|off port_id",
4888 (void *)&cmd_lfc_set_set,
4889 (void *)&cmd_lfc_set_flow_ctrl,
4890 (void *)&cmd_lfc_set_rx,
4891 (void *)&cmd_lfc_set_rx_mode,
4892 (void *)&cmd_lfc_set_portid,
4897 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4898 .f = cmd_link_flow_ctrl_set_parsed,
4899 .data = (void *)&cmd_link_flow_control_set_tx,
4900 .help_str = "Change tx flow control parameter: set flow_ctrl "
4901 "tx on|off port_id",
4903 (void *)&cmd_lfc_set_set,
4904 (void *)&cmd_lfc_set_flow_ctrl,
4905 (void *)&cmd_lfc_set_tx,
4906 (void *)&cmd_lfc_set_tx_mode,
4907 (void *)&cmd_lfc_set_portid,
4912 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4913 .f = cmd_link_flow_ctrl_set_parsed,
4914 .data = (void *)&cmd_link_flow_control_set_hw,
4915 .help_str = "Change high water flow control parameter: set flow_ctrl "
4916 "high_water value port_id",
4918 (void *)&cmd_lfc_set_set,
4919 (void *)&cmd_lfc_set_flow_ctrl,
4920 (void *)&cmd_lfc_set_high_water_str,
4921 (void *)&cmd_lfc_set_high_water,
4922 (void *)&cmd_lfc_set_portid,
4927 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4928 .f = cmd_link_flow_ctrl_set_parsed,
4929 .data = (void *)&cmd_link_flow_control_set_lw,
4930 .help_str = "Change low water flow control parameter: set flow_ctrl "
4931 "low_water value port_id",
4933 (void *)&cmd_lfc_set_set,
4934 (void *)&cmd_lfc_set_flow_ctrl,
4935 (void *)&cmd_lfc_set_low_water_str,
4936 (void *)&cmd_lfc_set_low_water,
4937 (void *)&cmd_lfc_set_portid,
4942 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4943 .f = cmd_link_flow_ctrl_set_parsed,
4944 .data = (void *)&cmd_link_flow_control_set_pt,
4945 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4946 "pause_time value port_id",
4948 (void *)&cmd_lfc_set_set,
4949 (void *)&cmd_lfc_set_flow_ctrl,
4950 (void *)&cmd_lfc_set_pause_time_str,
4951 (void *)&cmd_lfc_set_pause_time,
4952 (void *)&cmd_lfc_set_portid,
4957 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4958 .f = cmd_link_flow_ctrl_set_parsed,
4959 .data = (void *)&cmd_link_flow_control_set_xon,
4960 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4961 "send_xon value port_id",
4963 (void *)&cmd_lfc_set_set,
4964 (void *)&cmd_lfc_set_flow_ctrl,
4965 (void *)&cmd_lfc_set_send_xon_str,
4966 (void *)&cmd_lfc_set_send_xon,
4967 (void *)&cmd_lfc_set_portid,
4972 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4973 .f = cmd_link_flow_ctrl_set_parsed,
4974 .data = (void *)&cmd_link_flow_control_set_macfwd,
4975 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4976 "mac_ctrl_frame_fwd on|off port_id",
4978 (void *)&cmd_lfc_set_set,
4979 (void *)&cmd_lfc_set_flow_ctrl,
4980 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4981 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4982 (void *)&cmd_lfc_set_portid,
4987 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4988 .f = cmd_link_flow_ctrl_set_parsed,
4989 .data = (void *)&cmd_link_flow_control_set_autoneg,
4990 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4991 "autoneg on|off port_id",
4993 (void *)&cmd_lfc_set_set,
4994 (void *)&cmd_lfc_set_flow_ctrl,
4995 (void *)&cmd_lfc_set_autoneg_str,
4996 (void *)&cmd_lfc_set_autoneg,
4997 (void *)&cmd_lfc_set_portid,
5003 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5004 __attribute__((unused)) struct cmdline *cl,
5007 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5008 cmdline_parse_inst_t *cmd = data;
5009 struct rte_eth_fc_conf fc_conf;
5010 int rx_fc_en, tx_fc_en;
5014 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5015 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5016 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5017 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5019 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5020 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5023 /* Partial command line, retrieve current configuration */
5025 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5027 printf("cannot get current flow ctrl parameters, return"
5028 "code = %d\n", ret);
5032 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5033 (fc_conf.mode == RTE_FC_FULL))
5035 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5036 (fc_conf.mode == RTE_FC_FULL))
5040 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5041 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5043 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5044 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5046 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5048 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5049 fc_conf.high_water = res->high_water;
5051 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5052 fc_conf.low_water = res->low_water;
5054 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5055 fc_conf.pause_time = res->pause_time;
5057 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5058 fc_conf.send_xon = res->send_xon;
5060 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5061 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5062 fc_conf.mac_ctrl_frame_fwd = 1;
5064 fc_conf.mac_ctrl_frame_fwd = 0;
5067 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5068 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5070 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5072 printf("bad flow contrl parameter, return code = %d \n", ret);
5075 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5076 struct cmd_priority_flow_ctrl_set_result {
5077 cmdline_fixed_string_t set;
5078 cmdline_fixed_string_t pfc_ctrl;
5079 cmdline_fixed_string_t rx;
5080 cmdline_fixed_string_t rx_pfc_mode;
5081 cmdline_fixed_string_t tx;
5082 cmdline_fixed_string_t tx_pfc_mode;
5083 uint32_t high_water;
5085 uint16_t pause_time;
5091 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5092 __attribute__((unused)) struct cmdline *cl,
5093 __attribute__((unused)) void *data)
5095 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5096 struct rte_eth_pfc_conf pfc_conf;
5097 int rx_fc_enable, tx_fc_enable;
5101 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5102 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5103 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5104 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5106 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5107 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5110 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5111 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5112 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5113 pfc_conf.fc.high_water = res->high_water;
5114 pfc_conf.fc.low_water = res->low_water;
5115 pfc_conf.fc.pause_time = res->pause_time;
5116 pfc_conf.priority = res->priority;
5118 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5120 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5123 cmdline_parse_token_string_t cmd_pfc_set_set =
5124 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5126 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5127 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5128 pfc_ctrl, "pfc_ctrl");
5129 cmdline_parse_token_string_t cmd_pfc_set_rx =
5130 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5132 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5133 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5134 rx_pfc_mode, "on#off");
5135 cmdline_parse_token_string_t cmd_pfc_set_tx =
5136 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5138 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5139 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5140 tx_pfc_mode, "on#off");
5141 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5142 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5143 high_water, UINT32);
5144 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5145 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5147 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5148 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5149 pause_time, UINT16);
5150 cmdline_parse_token_num_t cmd_pfc_set_priority =
5151 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5153 cmdline_parse_token_num_t cmd_pfc_set_portid =
5154 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5157 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5158 .f = cmd_priority_flow_ctrl_set_parsed,
5160 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5161 tx on|off high_water low_water pause_time priority port_id",
5163 (void *)&cmd_pfc_set_set,
5164 (void *)&cmd_pfc_set_flow_ctrl,
5165 (void *)&cmd_pfc_set_rx,
5166 (void *)&cmd_pfc_set_rx_mode,
5167 (void *)&cmd_pfc_set_tx,
5168 (void *)&cmd_pfc_set_tx_mode,
5169 (void *)&cmd_pfc_set_high_water,
5170 (void *)&cmd_pfc_set_low_water,
5171 (void *)&cmd_pfc_set_pause_time,
5172 (void *)&cmd_pfc_set_priority,
5173 (void *)&cmd_pfc_set_portid,
5178 /* *** RESET CONFIGURATION *** */
5179 struct cmd_reset_result {
5180 cmdline_fixed_string_t reset;
5181 cmdline_fixed_string_t def;
5184 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5186 __attribute__((unused)) void *data)
5188 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5189 set_def_fwd_config();
5192 cmdline_parse_token_string_t cmd_reset_set =
5193 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5194 cmdline_parse_token_string_t cmd_reset_def =
5195 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5198 cmdline_parse_inst_t cmd_reset = {
5199 .f = cmd_reset_parsed,
5201 .help_str = "set default: reset default forwarding configuration",
5203 (void *)&cmd_reset_set,
5204 (void *)&cmd_reset_def,
5209 /* *** START FORWARDING *** */
5210 struct cmd_start_result {
5211 cmdline_fixed_string_t start;
5214 cmdline_parse_token_string_t cmd_start_start =
5215 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5217 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5218 __attribute__((unused)) struct cmdline *cl,
5219 __attribute__((unused)) void *data)
5221 start_packet_forwarding(0);
5224 cmdline_parse_inst_t cmd_start = {
5225 .f = cmd_start_parsed,
5227 .help_str = "start packet forwarding",
5229 (void *)&cmd_start_start,
5234 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5235 struct cmd_start_tx_first_result {
5236 cmdline_fixed_string_t start;
5237 cmdline_fixed_string_t tx_first;
5241 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5242 __attribute__((unused)) struct cmdline *cl,
5243 __attribute__((unused)) void *data)
5245 start_packet_forwarding(1);
5248 cmdline_parse_token_string_t cmd_start_tx_first_start =
5249 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5251 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5252 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5253 tx_first, "tx_first");
5255 cmdline_parse_inst_t cmd_start_tx_first = {
5256 .f = cmd_start_tx_first_parsed,
5258 .help_str = "start packet forwarding, after sending 1 burst of packets",
5260 (void *)&cmd_start_tx_first_start,
5261 (void *)&cmd_start_tx_first_tx_first,
5266 /* *** SET LINK UP *** */
5267 struct cmd_set_link_up_result {
5268 cmdline_fixed_string_t set;
5269 cmdline_fixed_string_t link_up;
5270 cmdline_fixed_string_t port;
5274 cmdline_parse_token_string_t cmd_set_link_up_set =
5275 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5276 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5277 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5279 cmdline_parse_token_string_t cmd_set_link_up_port =
5280 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5281 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5282 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5284 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5285 __attribute__((unused)) struct cmdline *cl,
5286 __attribute__((unused)) void *data)
5288 struct cmd_set_link_up_result *res = parsed_result;
5289 dev_set_link_up(res->port_id);
5292 cmdline_parse_inst_t cmd_set_link_up = {
5293 .f = cmd_set_link_up_parsed,
5295 .help_str = "set link-up port (port id)",
5297 (void *)&cmd_set_link_up_set,
5298 (void *)&cmd_set_link_up_link_up,
5299 (void *)&cmd_set_link_up_port,
5300 (void *)&cmd_set_link_up_port_id,
5305 /* *** SET LINK DOWN *** */
5306 struct cmd_set_link_down_result {
5307 cmdline_fixed_string_t set;
5308 cmdline_fixed_string_t link_down;
5309 cmdline_fixed_string_t port;
5313 cmdline_parse_token_string_t cmd_set_link_down_set =
5314 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5315 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5316 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5318 cmdline_parse_token_string_t cmd_set_link_down_port =
5319 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5320 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5321 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5323 static void cmd_set_link_down_parsed(
5324 __attribute__((unused)) void *parsed_result,
5325 __attribute__((unused)) struct cmdline *cl,
5326 __attribute__((unused)) void *data)
5328 struct cmd_set_link_down_result *res = parsed_result;
5329 dev_set_link_down(res->port_id);
5332 cmdline_parse_inst_t cmd_set_link_down = {
5333 .f = cmd_set_link_down_parsed,
5335 .help_str = "set link-down port (port id)",
5337 (void *)&cmd_set_link_down_set,
5338 (void *)&cmd_set_link_down_link_down,
5339 (void *)&cmd_set_link_down_port,
5340 (void *)&cmd_set_link_down_port_id,
5345 /* *** SHOW CFG *** */
5346 struct cmd_showcfg_result {
5347 cmdline_fixed_string_t show;
5348 cmdline_fixed_string_t cfg;
5349 cmdline_fixed_string_t what;
5352 static void cmd_showcfg_parsed(void *parsed_result,
5353 __attribute__((unused)) struct cmdline *cl,
5354 __attribute__((unused)) void *data)
5356 struct cmd_showcfg_result *res = parsed_result;
5357 if (!strcmp(res->what, "rxtx"))
5358 rxtx_config_display();
5359 else if (!strcmp(res->what, "cores"))
5360 fwd_lcores_config_display();
5361 else if (!strcmp(res->what, "fwd"))
5362 fwd_config_display();
5365 cmdline_parse_token_string_t cmd_showcfg_show =
5366 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5367 cmdline_parse_token_string_t cmd_showcfg_port =
5368 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5369 cmdline_parse_token_string_t cmd_showcfg_what =
5370 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5373 cmdline_parse_inst_t cmd_showcfg = {
5374 .f = cmd_showcfg_parsed,
5376 .help_str = "show config rxtx|cores|fwd",
5378 (void *)&cmd_showcfg_show,
5379 (void *)&cmd_showcfg_port,
5380 (void *)&cmd_showcfg_what,
5385 /* *** SHOW ALL PORT INFO *** */
5386 struct cmd_showportall_result {
5387 cmdline_fixed_string_t show;
5388 cmdline_fixed_string_t port;
5389 cmdline_fixed_string_t what;
5390 cmdline_fixed_string_t all;
5393 static void cmd_showportall_parsed(void *parsed_result,
5394 __attribute__((unused)) struct cmdline *cl,
5395 __attribute__((unused)) void *data)
5399 struct cmd_showportall_result *res = parsed_result;
5400 if (!strcmp(res->show, "clear")) {
5401 if (!strcmp(res->what, "stats"))
5402 for (i = 0; i < nb_ports; i++)
5404 else if (!strcmp(res->what, "xstats"))
5405 for (i = 0; i < nb_ports; i++)
5406 nic_xstats_clear(i);
5407 } else if (!strcmp(res->what, "info"))
5408 for (i = 0; i < nb_ports; i++)
5409 port_infos_display(i);
5410 else if (!strcmp(res->what, "stats"))
5411 for (i = 0; i < nb_ports; i++)
5412 nic_stats_display(i);
5413 else if (!strcmp(res->what, "xstats"))
5414 for (i = 0; i < nb_ports; i++)
5415 nic_xstats_display(i);
5416 else if (!strcmp(res->what, "fdir"))
5417 for (i = 0; i < nb_ports; i++)
5419 else if (!strcmp(res->what, "stat_qmap"))
5420 for (i = 0; i < nb_ports; i++)
5421 nic_stats_mapping_display(i);
5424 cmdline_parse_token_string_t cmd_showportall_show =
5425 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5427 cmdline_parse_token_string_t cmd_showportall_port =
5428 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5429 cmdline_parse_token_string_t cmd_showportall_what =
5430 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5431 "info#stats#xstats#fdir#stat_qmap");
5432 cmdline_parse_token_string_t cmd_showportall_all =
5433 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5434 cmdline_parse_inst_t cmd_showportall = {
5435 .f = cmd_showportall_parsed,
5437 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5439 (void *)&cmd_showportall_show,
5440 (void *)&cmd_showportall_port,
5441 (void *)&cmd_showportall_what,
5442 (void *)&cmd_showportall_all,
5447 /* *** SHOW PORT INFO *** */
5448 struct cmd_showport_result {
5449 cmdline_fixed_string_t show;
5450 cmdline_fixed_string_t port;
5451 cmdline_fixed_string_t what;
5455 static void cmd_showport_parsed(void *parsed_result,
5456 __attribute__((unused)) struct cmdline *cl,
5457 __attribute__((unused)) void *data)
5459 struct cmd_showport_result *res = parsed_result;
5460 if (!strcmp(res->show, "clear")) {
5461 if (!strcmp(res->what, "stats"))
5462 nic_stats_clear(res->portnum);
5463 else if (!strcmp(res->what, "xstats"))
5464 nic_xstats_clear(res->portnum);
5465 } else if (!strcmp(res->what, "info"))
5466 port_infos_display(res->portnum);
5467 else if (!strcmp(res->what, "stats"))
5468 nic_stats_display(res->portnum);
5469 else if (!strcmp(res->what, "xstats"))
5470 nic_xstats_display(res->portnum);
5471 else if (!strcmp(res->what, "fdir"))
5472 fdir_get_infos(res->portnum);
5473 else if (!strcmp(res->what, "stat_qmap"))
5474 nic_stats_mapping_display(res->portnum);
5477 cmdline_parse_token_string_t cmd_showport_show =
5478 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5480 cmdline_parse_token_string_t cmd_showport_port =
5481 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5482 cmdline_parse_token_string_t cmd_showport_what =
5483 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5484 "info#stats#xstats#fdir#stat_qmap");
5485 cmdline_parse_token_num_t cmd_showport_portnum =
5486 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5488 cmdline_parse_inst_t cmd_showport = {
5489 .f = cmd_showport_parsed,
5491 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5493 (void *)&cmd_showport_show,
5494 (void *)&cmd_showport_port,
5495 (void *)&cmd_showport_what,
5496 (void *)&cmd_showport_portnum,
5501 /* *** READ PORT REGISTER *** */
5502 struct cmd_read_reg_result {
5503 cmdline_fixed_string_t read;
5504 cmdline_fixed_string_t reg;
5510 cmd_read_reg_parsed(void *parsed_result,
5511 __attribute__((unused)) struct cmdline *cl,
5512 __attribute__((unused)) void *data)
5514 struct cmd_read_reg_result *res = parsed_result;
5515 port_reg_display(res->port_id, res->reg_off);
5518 cmdline_parse_token_string_t cmd_read_reg_read =
5519 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5520 cmdline_parse_token_string_t cmd_read_reg_reg =
5521 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5522 cmdline_parse_token_num_t cmd_read_reg_port_id =
5523 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5524 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5525 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5527 cmdline_parse_inst_t cmd_read_reg = {
5528 .f = cmd_read_reg_parsed,
5530 .help_str = "read reg port_id reg_off",
5532 (void *)&cmd_read_reg_read,
5533 (void *)&cmd_read_reg_reg,
5534 (void *)&cmd_read_reg_port_id,
5535 (void *)&cmd_read_reg_reg_off,
5540 /* *** READ PORT REGISTER BIT FIELD *** */
5541 struct cmd_read_reg_bit_field_result {
5542 cmdline_fixed_string_t read;
5543 cmdline_fixed_string_t regfield;
5551 cmd_read_reg_bit_field_parsed(void *parsed_result,
5552 __attribute__((unused)) struct cmdline *cl,
5553 __attribute__((unused)) void *data)
5555 struct cmd_read_reg_bit_field_result *res = parsed_result;
5556 port_reg_bit_field_display(res->port_id, res->reg_off,
5557 res->bit1_pos, res->bit2_pos);
5560 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5561 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5563 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5564 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5565 regfield, "regfield");
5566 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5567 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5569 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5570 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5572 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5573 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5575 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5576 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5579 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5580 .f = cmd_read_reg_bit_field_parsed,
5582 .help_str = "read regfield port_id reg_off bit_x bit_y "
5583 "(read register bit field between bit_x and bit_y included)",
5585 (void *)&cmd_read_reg_bit_field_read,
5586 (void *)&cmd_read_reg_bit_field_regfield,
5587 (void *)&cmd_read_reg_bit_field_port_id,
5588 (void *)&cmd_read_reg_bit_field_reg_off,
5589 (void *)&cmd_read_reg_bit_field_bit1_pos,
5590 (void *)&cmd_read_reg_bit_field_bit2_pos,
5595 /* *** READ PORT REGISTER BIT *** */
5596 struct cmd_read_reg_bit_result {
5597 cmdline_fixed_string_t read;
5598 cmdline_fixed_string_t regbit;
5605 cmd_read_reg_bit_parsed(void *parsed_result,
5606 __attribute__((unused)) struct cmdline *cl,
5607 __attribute__((unused)) void *data)
5609 struct cmd_read_reg_bit_result *res = parsed_result;
5610 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5613 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5614 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5615 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5616 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5618 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5619 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5620 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5621 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5622 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5623 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5625 cmdline_parse_inst_t cmd_read_reg_bit = {
5626 .f = cmd_read_reg_bit_parsed,
5628 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5630 (void *)&cmd_read_reg_bit_read,
5631 (void *)&cmd_read_reg_bit_regbit,
5632 (void *)&cmd_read_reg_bit_port_id,
5633 (void *)&cmd_read_reg_bit_reg_off,
5634 (void *)&cmd_read_reg_bit_bit_pos,
5639 /* *** WRITE PORT REGISTER *** */
5640 struct cmd_write_reg_result {
5641 cmdline_fixed_string_t write;
5642 cmdline_fixed_string_t reg;
5649 cmd_write_reg_parsed(void *parsed_result,
5650 __attribute__((unused)) struct cmdline *cl,
5651 __attribute__((unused)) void *data)
5653 struct cmd_write_reg_result *res = parsed_result;
5654 port_reg_set(res->port_id, res->reg_off, res->value);
5657 cmdline_parse_token_string_t cmd_write_reg_write =
5658 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5659 cmdline_parse_token_string_t cmd_write_reg_reg =
5660 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5661 cmdline_parse_token_num_t cmd_write_reg_port_id =
5662 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5663 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5664 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5665 cmdline_parse_token_num_t cmd_write_reg_value =
5666 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5668 cmdline_parse_inst_t cmd_write_reg = {
5669 .f = cmd_write_reg_parsed,
5671 .help_str = "write reg port_id reg_off reg_value",
5673 (void *)&cmd_write_reg_write,
5674 (void *)&cmd_write_reg_reg,
5675 (void *)&cmd_write_reg_port_id,
5676 (void *)&cmd_write_reg_reg_off,
5677 (void *)&cmd_write_reg_value,
5682 /* *** WRITE PORT REGISTER BIT FIELD *** */
5683 struct cmd_write_reg_bit_field_result {
5684 cmdline_fixed_string_t write;
5685 cmdline_fixed_string_t regfield;
5694 cmd_write_reg_bit_field_parsed(void *parsed_result,
5695 __attribute__((unused)) struct cmdline *cl,
5696 __attribute__((unused)) void *data)
5698 struct cmd_write_reg_bit_field_result *res = parsed_result;
5699 port_reg_bit_field_set(res->port_id, res->reg_off,
5700 res->bit1_pos, res->bit2_pos, res->value);
5703 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5704 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5706 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5707 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5708 regfield, "regfield");
5709 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5710 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5712 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5713 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5715 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5716 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5718 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5719 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5721 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5722 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5725 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5726 .f = cmd_write_reg_bit_field_parsed,
5728 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5729 "(set register bit field between bit_x and bit_y included)",
5731 (void *)&cmd_write_reg_bit_field_write,
5732 (void *)&cmd_write_reg_bit_field_regfield,
5733 (void *)&cmd_write_reg_bit_field_port_id,
5734 (void *)&cmd_write_reg_bit_field_reg_off,
5735 (void *)&cmd_write_reg_bit_field_bit1_pos,
5736 (void *)&cmd_write_reg_bit_field_bit2_pos,
5737 (void *)&cmd_write_reg_bit_field_value,
5742 /* *** WRITE PORT REGISTER BIT *** */
5743 struct cmd_write_reg_bit_result {
5744 cmdline_fixed_string_t write;
5745 cmdline_fixed_string_t regbit;
5753 cmd_write_reg_bit_parsed(void *parsed_result,
5754 __attribute__((unused)) struct cmdline *cl,
5755 __attribute__((unused)) void *data)
5757 struct cmd_write_reg_bit_result *res = parsed_result;
5758 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5761 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5762 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5764 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5765 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5767 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5768 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5769 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5770 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5771 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5772 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5773 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5774 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5776 cmdline_parse_inst_t cmd_write_reg_bit = {
5777 .f = cmd_write_reg_bit_parsed,
5779 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5781 (void *)&cmd_write_reg_bit_write,
5782 (void *)&cmd_write_reg_bit_regbit,
5783 (void *)&cmd_write_reg_bit_port_id,
5784 (void *)&cmd_write_reg_bit_reg_off,
5785 (void *)&cmd_write_reg_bit_bit_pos,
5786 (void *)&cmd_write_reg_bit_value,
5791 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5792 struct cmd_read_rxd_txd_result {
5793 cmdline_fixed_string_t read;
5794 cmdline_fixed_string_t rxd_txd;
5801 cmd_read_rxd_txd_parsed(void *parsed_result,
5802 __attribute__((unused)) struct cmdline *cl,
5803 __attribute__((unused)) void *data)
5805 struct cmd_read_rxd_txd_result *res = parsed_result;
5807 if (!strcmp(res->rxd_txd, "rxd"))
5808 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5809 else if (!strcmp(res->rxd_txd, "txd"))
5810 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5813 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5814 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5815 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5816 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5818 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5819 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5820 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5821 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5822 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5823 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5825 cmdline_parse_inst_t cmd_read_rxd_txd = {
5826 .f = cmd_read_rxd_txd_parsed,
5828 .help_str = "read rxd|txd port_id queue_id rxd_id",
5830 (void *)&cmd_read_rxd_txd_read,
5831 (void *)&cmd_read_rxd_txd_rxd_txd,
5832 (void *)&cmd_read_rxd_txd_port_id,
5833 (void *)&cmd_read_rxd_txd_queue_id,
5834 (void *)&cmd_read_rxd_txd_desc_id,
5840 struct cmd_quit_result {
5841 cmdline_fixed_string_t quit;
5844 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5846 __attribute__((unused)) void *data)
5852 cmdline_parse_token_string_t cmd_quit_quit =
5853 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5855 cmdline_parse_inst_t cmd_quit = {
5856 .f = cmd_quit_parsed,
5858 .help_str = "exit application",
5860 (void *)&cmd_quit_quit,
5865 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5866 struct cmd_mac_addr_result {
5867 cmdline_fixed_string_t mac_addr_cmd;
5868 cmdline_fixed_string_t what;
5870 struct ether_addr address;
5873 static void cmd_mac_addr_parsed(void *parsed_result,
5874 __attribute__((unused)) struct cmdline *cl,
5875 __attribute__((unused)) void *data)
5877 struct cmd_mac_addr_result *res = parsed_result;
5880 if (strcmp(res->what, "add") == 0)
5881 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5883 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5885 /* check the return value and print it if is < 0 */
5887 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5891 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5892 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5894 cmdline_parse_token_string_t cmd_mac_addr_what =
5895 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5897 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5898 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5899 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5900 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5902 cmdline_parse_inst_t cmd_mac_addr = {
5903 .f = cmd_mac_addr_parsed,
5905 .help_str = "mac_addr add|remove X <address>: "
5906 "add/remove MAC address on port X",
5908 (void *)&cmd_mac_addr_cmd,
5909 (void *)&cmd_mac_addr_what,
5910 (void *)&cmd_mac_addr_portnum,
5911 (void *)&cmd_mac_addr_addr,
5917 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5918 struct cmd_set_qmap_result {
5919 cmdline_fixed_string_t set;
5920 cmdline_fixed_string_t qmap;
5921 cmdline_fixed_string_t what;
5928 cmd_set_qmap_parsed(void *parsed_result,
5929 __attribute__((unused)) struct cmdline *cl,
5930 __attribute__((unused)) void *data)
5932 struct cmd_set_qmap_result *res = parsed_result;
5933 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5935 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5938 cmdline_parse_token_string_t cmd_setqmap_set =
5939 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5941 cmdline_parse_token_string_t cmd_setqmap_qmap =
5942 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5944 cmdline_parse_token_string_t cmd_setqmap_what =
5945 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5947 cmdline_parse_token_num_t cmd_setqmap_portid =
5948 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5950 cmdline_parse_token_num_t cmd_setqmap_queueid =
5951 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5953 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5954 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5957 cmdline_parse_inst_t cmd_set_qmap = {
5958 .f = cmd_set_qmap_parsed,
5960 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5962 (void *)&cmd_setqmap_set,
5963 (void *)&cmd_setqmap_qmap,
5964 (void *)&cmd_setqmap_what,
5965 (void *)&cmd_setqmap_portid,
5966 (void *)&cmd_setqmap_queueid,
5967 (void *)&cmd_setqmap_mapvalue,
5972 /* *** CONFIGURE UNICAST HASH TABLE *** */
5973 struct cmd_set_uc_hash_table {
5974 cmdline_fixed_string_t set;
5975 cmdline_fixed_string_t port;
5977 cmdline_fixed_string_t what;
5978 struct ether_addr address;
5979 cmdline_fixed_string_t mode;
5983 cmd_set_uc_hash_parsed(void *parsed_result,
5984 __attribute__((unused)) struct cmdline *cl,
5985 __attribute__((unused)) void *data)
5988 struct cmd_set_uc_hash_table *res = parsed_result;
5990 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5992 if (strcmp(res->what, "uta") == 0)
5993 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5994 &res->address,(uint8_t)is_on);
5996 printf("bad unicast hash table parameter, return code = %d \n", ret);
6000 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6001 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6003 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6004 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6006 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6007 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6009 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6010 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6012 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6013 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6015 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6019 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6020 .f = cmd_set_uc_hash_parsed,
6022 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6024 (void *)&cmd_set_uc_hash_set,
6025 (void *)&cmd_set_uc_hash_port,
6026 (void *)&cmd_set_uc_hash_portid,
6027 (void *)&cmd_set_uc_hash_what,
6028 (void *)&cmd_set_uc_hash_mac,
6029 (void *)&cmd_set_uc_hash_mode,
6034 struct cmd_set_uc_all_hash_table {
6035 cmdline_fixed_string_t set;
6036 cmdline_fixed_string_t port;
6038 cmdline_fixed_string_t what;
6039 cmdline_fixed_string_t value;
6040 cmdline_fixed_string_t mode;
6044 cmd_set_uc_all_hash_parsed(void *parsed_result,
6045 __attribute__((unused)) struct cmdline *cl,
6046 __attribute__((unused)) void *data)
6049 struct cmd_set_uc_all_hash_table *res = parsed_result;
6051 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6053 if ((strcmp(res->what, "uta") == 0) &&
6054 (strcmp(res->value, "all") == 0))
6055 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6057 printf("bad unicast hash table parameter,"
6058 "return code = %d \n", ret);
6061 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6062 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6064 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6065 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6067 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6068 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6070 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6071 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6073 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6074 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6076 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6077 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6080 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6081 .f = cmd_set_uc_all_hash_parsed,
6083 .help_str = "set port X uta all on|off (X = port number)",
6085 (void *)&cmd_set_uc_all_hash_set,
6086 (void *)&cmd_set_uc_all_hash_port,
6087 (void *)&cmd_set_uc_all_hash_portid,
6088 (void *)&cmd_set_uc_all_hash_what,
6089 (void *)&cmd_set_uc_all_hash_value,
6090 (void *)&cmd_set_uc_all_hash_mode,
6095 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6096 struct cmd_set_vf_macvlan_filter {
6097 cmdline_fixed_string_t set;
6098 cmdline_fixed_string_t port;
6100 cmdline_fixed_string_t vf;
6102 struct ether_addr address;
6103 cmdline_fixed_string_t filter_type;
6104 cmdline_fixed_string_t mode;
6108 cmd_set_vf_macvlan_parsed(void *parsed_result,
6109 __attribute__((unused)) struct cmdline *cl,
6110 __attribute__((unused)) void *data)
6113 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6114 struct rte_eth_mac_filter filter;
6116 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6118 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6120 /* set VF MAC filter */
6124 filter.dst_id = res->vf_id;
6126 if (!strcmp(res->filter_type, "exact-mac"))
6127 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6128 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6129 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6130 else if (!strcmp(res->filter_type, "hashmac"))
6131 filter.filter_type = RTE_MAC_HASH_MATCH;
6132 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6133 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6135 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6138 ret = rte_eth_dev_filter_ctrl(res->port_id,
6139 RTE_ETH_FILTER_MACVLAN,
6143 ret = rte_eth_dev_filter_ctrl(res->port_id,
6144 RTE_ETH_FILTER_MACVLAN,
6145 RTE_ETH_FILTER_DELETE,
6149 printf("bad set MAC hash parameter, return code = %d\n", ret);
6153 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6154 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6156 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6157 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6159 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6160 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6162 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6163 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6165 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6166 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6168 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6169 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6171 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6172 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6173 filter_type, "exact-mac#exact-mac-vlan"
6174 "#hashmac#hashmac-vlan");
6175 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6176 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6179 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6180 .f = cmd_set_vf_macvlan_parsed,
6182 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6183 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6185 "exact match rule:exact match of MAC or MAC and VLAN; "
6186 "hash match rule: hash match of MAC and exact match "
6189 (void *)&cmd_set_vf_macvlan_set,
6190 (void *)&cmd_set_vf_macvlan_port,
6191 (void *)&cmd_set_vf_macvlan_portid,
6192 (void *)&cmd_set_vf_macvlan_vf,
6193 (void *)&cmd_set_vf_macvlan_vf_id,
6194 (void *)&cmd_set_vf_macvlan_mac,
6195 (void *)&cmd_set_vf_macvlan_filter_type,
6196 (void *)&cmd_set_vf_macvlan_mode,
6201 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6202 struct cmd_set_vf_traffic {
6203 cmdline_fixed_string_t set;
6204 cmdline_fixed_string_t port;
6206 cmdline_fixed_string_t vf;
6208 cmdline_fixed_string_t what;
6209 cmdline_fixed_string_t mode;
6213 cmd_set_vf_traffic_parsed(void *parsed_result,
6214 __attribute__((unused)) struct cmdline *cl,
6215 __attribute__((unused)) void *data)
6217 struct cmd_set_vf_traffic *res = parsed_result;
6218 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6219 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6221 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6224 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6225 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6227 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6228 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6230 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6231 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6233 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6234 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6236 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6237 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6239 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6240 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6242 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6243 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6246 cmdline_parse_inst_t cmd_set_vf_traffic = {
6247 .f = cmd_set_vf_traffic_parsed,
6249 .help_str = "set port X vf Y rx|tx on|off"
6250 "(X = port number,Y = vf id)",
6252 (void *)&cmd_setvf_traffic_set,
6253 (void *)&cmd_setvf_traffic_port,
6254 (void *)&cmd_setvf_traffic_portid,
6255 (void *)&cmd_setvf_traffic_vf,
6256 (void *)&cmd_setvf_traffic_vfid,
6257 (void *)&cmd_setvf_traffic_what,
6258 (void *)&cmd_setvf_traffic_mode,
6263 /* *** CONFIGURE VF RECEIVE MODE *** */
6264 struct cmd_set_vf_rxmode {
6265 cmdline_fixed_string_t set;
6266 cmdline_fixed_string_t port;
6268 cmdline_fixed_string_t vf;
6270 cmdline_fixed_string_t what;
6271 cmdline_fixed_string_t mode;
6272 cmdline_fixed_string_t on;
6276 cmd_set_vf_rxmode_parsed(void *parsed_result,
6277 __attribute__((unused)) struct cmdline *cl,
6278 __attribute__((unused)) void *data)
6281 uint16_t rx_mode = 0;
6282 struct cmd_set_vf_rxmode *res = parsed_result;
6284 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6285 if (!strcmp(res->what,"rxmode")) {
6286 if (!strcmp(res->mode, "AUPE"))
6287 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6288 else if (!strcmp(res->mode, "ROPE"))
6289 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6290 else if (!strcmp(res->mode, "BAM"))
6291 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6292 else if (!strncmp(res->mode, "MPE",3))
6293 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6296 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6298 printf("bad VF receive mode parameter, return code = %d \n",
6302 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6303 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6305 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6306 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6308 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6309 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6311 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6312 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6314 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6315 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6317 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6318 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6320 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6321 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6322 mode, "AUPE#ROPE#BAM#MPE");
6323 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6324 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6327 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6328 .f = cmd_set_vf_rxmode_parsed,
6330 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6332 (void *)&cmd_set_vf_rxmode_set,
6333 (void *)&cmd_set_vf_rxmode_port,
6334 (void *)&cmd_set_vf_rxmode_portid,
6335 (void *)&cmd_set_vf_rxmode_vf,
6336 (void *)&cmd_set_vf_rxmode_vfid,
6337 (void *)&cmd_set_vf_rxmode_what,
6338 (void *)&cmd_set_vf_rxmode_mode,
6339 (void *)&cmd_set_vf_rxmode_on,
6344 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6345 struct cmd_vf_mac_addr_result {
6346 cmdline_fixed_string_t mac_addr_cmd;
6347 cmdline_fixed_string_t what;
6348 cmdline_fixed_string_t port;
6350 cmdline_fixed_string_t vf;
6352 struct ether_addr address;
6355 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6356 __attribute__((unused)) struct cmdline *cl,
6357 __attribute__((unused)) void *data)
6359 struct cmd_vf_mac_addr_result *res = parsed_result;
6362 if (strcmp(res->what, "add") == 0)
6363 ret = rte_eth_dev_mac_addr_add(res->port_num,
6364 &res->address, res->vf_num);
6366 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6370 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6371 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6372 mac_addr_cmd,"mac_addr");
6373 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6374 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6376 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6377 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6379 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6380 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6382 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6383 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6385 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6386 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6388 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6389 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6392 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6393 .f = cmd_vf_mac_addr_parsed,
6395 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6396 "Y = VF number)add MAC address filtering for a VF on port X",
6398 (void *)&cmd_vf_mac_addr_cmd,
6399 (void *)&cmd_vf_mac_addr_what,
6400 (void *)&cmd_vf_mac_addr_port,
6401 (void *)&cmd_vf_mac_addr_portnum,
6402 (void *)&cmd_vf_mac_addr_vf,
6403 (void *)&cmd_vf_mac_addr_vfnum,
6404 (void *)&cmd_vf_mac_addr_addr,
6409 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6410 struct cmd_vf_rx_vlan_filter {
6411 cmdline_fixed_string_t rx_vlan;
6412 cmdline_fixed_string_t what;
6414 cmdline_fixed_string_t port;
6416 cmdline_fixed_string_t vf;
6421 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6422 __attribute__((unused)) struct cmdline *cl,
6423 __attribute__((unused)) void *data)
6425 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6427 if (!strcmp(res->what, "add"))
6428 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6430 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6433 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6434 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6435 rx_vlan, "rx_vlan");
6436 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6437 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6439 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6440 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6442 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6443 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6445 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6446 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6448 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6449 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6451 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6452 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6455 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6456 .f = cmd_vf_rx_vlan_filter_parsed,
6458 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6459 "Y = port number,Z = hexadecimal VF mask)",
6461 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6462 (void *)&cmd_vf_rx_vlan_filter_what,
6463 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6464 (void *)&cmd_vf_rx_vlan_filter_port,
6465 (void *)&cmd_vf_rx_vlan_filter_portid,
6466 (void *)&cmd_vf_rx_vlan_filter_vf,
6467 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6472 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6473 struct cmd_queue_rate_limit_result {
6474 cmdline_fixed_string_t set;
6475 cmdline_fixed_string_t port;
6477 cmdline_fixed_string_t queue;
6479 cmdline_fixed_string_t rate;
6483 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6484 __attribute__((unused)) struct cmdline *cl,
6485 __attribute__((unused)) void *data)
6487 struct cmd_queue_rate_limit_result *res = parsed_result;
6490 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6491 && (strcmp(res->queue, "queue") == 0)
6492 && (strcmp(res->rate, "rate") == 0))
6493 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6496 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6500 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6501 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6503 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6504 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6506 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6507 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6509 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6510 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6512 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6513 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6515 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6516 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6518 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6519 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6522 cmdline_parse_inst_t cmd_queue_rate_limit = {
6523 .f = cmd_queue_rate_limit_parsed,
6525 .help_str = "set port X queue Y rate Z:(X = port number,"
6526 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6528 (void *)&cmd_queue_rate_limit_set,
6529 (void *)&cmd_queue_rate_limit_port,
6530 (void *)&cmd_queue_rate_limit_portnum,
6531 (void *)&cmd_queue_rate_limit_queue,
6532 (void *)&cmd_queue_rate_limit_queuenum,
6533 (void *)&cmd_queue_rate_limit_rate,
6534 (void *)&cmd_queue_rate_limit_ratenum,
6539 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6540 struct cmd_vf_rate_limit_result {
6541 cmdline_fixed_string_t set;
6542 cmdline_fixed_string_t port;
6544 cmdline_fixed_string_t vf;
6546 cmdline_fixed_string_t rate;
6548 cmdline_fixed_string_t q_msk;
6552 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6553 __attribute__((unused)) struct cmdline *cl,
6554 __attribute__((unused)) void *data)
6556 struct cmd_vf_rate_limit_result *res = parsed_result;
6559 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6560 && (strcmp(res->vf, "vf") == 0)
6561 && (strcmp(res->rate, "rate") == 0)
6562 && (strcmp(res->q_msk, "queue_mask") == 0))
6563 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6564 res->rate_num, res->q_msk_val);
6566 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6570 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6571 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6573 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6574 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6576 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6577 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6579 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6580 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6582 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6583 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6585 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6586 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6588 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6589 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6591 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6592 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6593 q_msk, "queue_mask");
6594 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6595 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6598 cmdline_parse_inst_t cmd_vf_rate_limit = {
6599 .f = cmd_vf_rate_limit_parsed,
6601 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6602 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6603 "for queues of VF on port X",
6605 (void *)&cmd_vf_rate_limit_set,
6606 (void *)&cmd_vf_rate_limit_port,
6607 (void *)&cmd_vf_rate_limit_portnum,
6608 (void *)&cmd_vf_rate_limit_vf,
6609 (void *)&cmd_vf_rate_limit_vfnum,
6610 (void *)&cmd_vf_rate_limit_rate,
6611 (void *)&cmd_vf_rate_limit_ratenum,
6612 (void *)&cmd_vf_rate_limit_q_msk,
6613 (void *)&cmd_vf_rate_limit_q_msk_val,
6618 /* *** ADD TUNNEL FILTER OF A PORT *** */
6619 struct cmd_tunnel_filter_result {
6620 cmdline_fixed_string_t cmd;
6621 cmdline_fixed_string_t what;
6623 struct ether_addr outer_mac;
6624 struct ether_addr inner_mac;
6625 cmdline_ipaddr_t ip_value;
6626 uint16_t inner_vlan;
6627 cmdline_fixed_string_t tunnel_type;
6628 cmdline_fixed_string_t filter_type;
6634 cmd_tunnel_filter_parsed(void *parsed_result,
6635 __attribute__((unused)) struct cmdline *cl,
6636 __attribute__((unused)) void *data)
6638 struct cmd_tunnel_filter_result *res = parsed_result;
6639 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6642 tunnel_filter_conf.outer_mac = &res->outer_mac;
6643 tunnel_filter_conf.inner_mac = &res->inner_mac;
6644 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6646 if (res->ip_value.family == AF_INET) {
6647 tunnel_filter_conf.ip_addr.ipv4_addr =
6648 res->ip_value.addr.ipv4.s_addr;
6649 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6651 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6652 &(res->ip_value.addr.ipv6),
6653 sizeof(struct in6_addr));
6654 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6657 if (!strcmp(res->filter_type, "imac-ivlan"))
6658 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6659 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6660 tunnel_filter_conf.filter_type =
6661 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6662 else if (!strcmp(res->filter_type, "imac-tenid"))
6663 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6664 else if (!strcmp(res->filter_type, "imac"))
6665 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6666 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6667 tunnel_filter_conf.filter_type =
6668 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6670 printf("The filter type is not supported");
6674 if (!strcmp(res->tunnel_type, "vxlan"))
6675 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6677 printf("Only VXLAN is supported now.\n");
6681 tunnel_filter_conf.tenant_id = res->tenant_id;
6682 tunnel_filter_conf.queue_id = res->queue_num;
6683 if (!strcmp(res->what, "add"))
6684 ret = rte_eth_dev_filter_ctrl(res->port_id,
6685 RTE_ETH_FILTER_TUNNEL,
6687 &tunnel_filter_conf);
6689 ret = rte_eth_dev_filter_ctrl(res->port_id,
6690 RTE_ETH_FILTER_TUNNEL,
6691 RTE_ETH_FILTER_DELETE,
6692 &tunnel_filter_conf);
6694 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6698 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6699 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6700 cmd, "tunnel_filter");
6701 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6702 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6704 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6705 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6707 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6708 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6710 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6711 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6713 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6714 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6715 inner_vlan, UINT16);
6716 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6717 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6719 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6720 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6721 tunnel_type, "vxlan");
6723 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6724 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6725 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6726 "imac#omac-imac-tenid");
6727 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6728 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6730 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6731 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6734 cmdline_parse_inst_t cmd_tunnel_filter = {
6735 .f = cmd_tunnel_filter_parsed,
6737 .help_str = "add/rm tunnel filter of a port: "
6738 "tunnel_filter add port_id outer_mac inner_mac ip "
6739 "inner_vlan tunnel_type(vxlan) filter_type "
6740 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6741 "imac|omac-imac-tenid) "
6742 "tenant_id queue_num",
6744 (void *)&cmd_tunnel_filter_cmd,
6745 (void *)&cmd_tunnel_filter_what,
6746 (void *)&cmd_tunnel_filter_port_id,
6747 (void *)&cmd_tunnel_filter_outer_mac,
6748 (void *)&cmd_tunnel_filter_inner_mac,
6749 (void *)&cmd_tunnel_filter_ip_value,
6750 (void *)&cmd_tunnel_filter_innner_vlan,
6751 (void *)&cmd_tunnel_filter_tunnel_type,
6752 (void *)&cmd_tunnel_filter_filter_type,
6753 (void *)&cmd_tunnel_filter_tenant_id,
6754 (void *)&cmd_tunnel_filter_queue_num,
6759 /* *** CONFIGURE TUNNEL UDP PORT *** */
6760 struct cmd_tunnel_udp_config {
6761 cmdline_fixed_string_t cmd;
6762 cmdline_fixed_string_t what;
6768 cmd_tunnel_udp_config_parsed(void *parsed_result,
6769 __attribute__((unused)) struct cmdline *cl,
6770 __attribute__((unused)) void *data)
6772 struct cmd_tunnel_udp_config *res = parsed_result;
6773 struct rte_eth_udp_tunnel tunnel_udp;
6776 tunnel_udp.udp_port = res->udp_port;
6778 if (!strcmp(res->cmd, "rx_vxlan_port"))
6779 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6781 if (!strcmp(res->what, "add"))
6782 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6784 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6787 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6790 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6791 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6792 cmd, "rx_vxlan_port");
6793 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6794 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6796 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6797 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6799 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6800 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6803 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6804 .f = cmd_tunnel_udp_config_parsed,
6806 .help_str = "add/rm an tunneling UDP port filter: "
6807 "rx_vxlan_port add udp_port port_id",
6809 (void *)&cmd_tunnel_udp_config_cmd,
6810 (void *)&cmd_tunnel_udp_config_what,
6811 (void *)&cmd_tunnel_udp_config_udp_port,
6812 (void *)&cmd_tunnel_udp_config_port_id,
6817 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6818 struct cmd_set_mirror_mask_result {
6819 cmdline_fixed_string_t set;
6820 cmdline_fixed_string_t port;
6822 cmdline_fixed_string_t mirror;
6824 cmdline_fixed_string_t what;
6825 cmdline_fixed_string_t value;
6826 cmdline_fixed_string_t dstpool;
6828 cmdline_fixed_string_t on;
6831 cmdline_parse_token_string_t cmd_mirror_mask_set =
6832 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6834 cmdline_parse_token_string_t cmd_mirror_mask_port =
6835 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6837 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6838 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6840 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6841 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6842 mirror, "mirror-rule");
6843 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6844 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6846 cmdline_parse_token_string_t cmd_mirror_mask_what =
6847 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6848 what, "pool-mirror#vlan-mirror");
6849 cmdline_parse_token_string_t cmd_mirror_mask_value =
6850 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6852 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6853 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6854 dstpool, "dst-pool");
6855 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6856 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6858 cmdline_parse_token_string_t cmd_mirror_mask_on =
6859 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6863 cmd_set_mirror_mask_parsed(void *parsed_result,
6864 __attribute__((unused)) struct cmdline *cl,
6865 __attribute__((unused)) void *data)
6868 struct cmd_set_mirror_mask_result *res = parsed_result;
6869 struct rte_eth_vmdq_mirror_conf mr_conf;
6871 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6873 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6875 mr_conf.dst_pool = res->dstpool_id;
6877 if (!strcmp(res->what, "pool-mirror")) {
6878 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6879 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6880 } else if(!strcmp(res->what, "vlan-mirror")) {
6881 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6882 nb_item = parse_item_list(res->value, "core",
6883 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6887 for(i=0; i < nb_item; i++) {
6888 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6889 printf("Invalid vlan_id: must be < 4096\n");
6893 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6894 mr_conf.vlan.vlan_mask |= 1ULL << i;
6898 if(!strcmp(res->on, "on"))
6899 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6902 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6905 printf("mirror rule add error: (%s)\n", strerror(-ret));
6908 cmdline_parse_inst_t cmd_set_mirror_mask = {
6909 .f = cmd_set_mirror_mask_parsed,
6911 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6912 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6914 (void *)&cmd_mirror_mask_set,
6915 (void *)&cmd_mirror_mask_port,
6916 (void *)&cmd_mirror_mask_portid,
6917 (void *)&cmd_mirror_mask_mirror,
6918 (void *)&cmd_mirror_mask_ruleid,
6919 (void *)&cmd_mirror_mask_what,
6920 (void *)&cmd_mirror_mask_value,
6921 (void *)&cmd_mirror_mask_dstpool,
6922 (void *)&cmd_mirror_mask_poolid,
6923 (void *)&cmd_mirror_mask_on,
6928 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6929 struct cmd_set_mirror_link_result {
6930 cmdline_fixed_string_t set;
6931 cmdline_fixed_string_t port;
6933 cmdline_fixed_string_t mirror;
6935 cmdline_fixed_string_t what;
6936 cmdline_fixed_string_t dstpool;
6938 cmdline_fixed_string_t on;
6941 cmdline_parse_token_string_t cmd_mirror_link_set =
6942 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6944 cmdline_parse_token_string_t cmd_mirror_link_port =
6945 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6947 cmdline_parse_token_num_t cmd_mirror_link_portid =
6948 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6950 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6951 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6952 mirror, "mirror-rule");
6953 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6954 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6956 cmdline_parse_token_string_t cmd_mirror_link_what =
6957 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6958 what, "uplink-mirror#downlink-mirror");
6959 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6960 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6961 dstpool, "dst-pool");
6962 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6963 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6965 cmdline_parse_token_string_t cmd_mirror_link_on =
6966 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6970 cmd_set_mirror_link_parsed(void *parsed_result,
6971 __attribute__((unused)) struct cmdline *cl,
6972 __attribute__((unused)) void *data)
6975 struct cmd_set_mirror_link_result *res = parsed_result;
6976 struct rte_eth_vmdq_mirror_conf mr_conf;
6978 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6979 if(!strcmp(res->what, "uplink-mirror")) {
6980 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6981 }else if(!strcmp(res->what, "downlink-mirror"))
6982 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6984 mr_conf.dst_pool = res->dstpool_id;
6986 if(!strcmp(res->on, "on"))
6987 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6990 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6993 /* check the return value and print it if is < 0 */
6995 printf("mirror rule add error: (%s)\n", strerror(-ret));
6999 cmdline_parse_inst_t cmd_set_mirror_link = {
7000 .f = cmd_set_mirror_link_parsed,
7002 .help_str = "set port X mirror-rule Y uplink-mirror|"
7003 "downlink-mirror dst-pool Z on|off",
7005 (void *)&cmd_mirror_link_set,
7006 (void *)&cmd_mirror_link_port,
7007 (void *)&cmd_mirror_link_portid,
7008 (void *)&cmd_mirror_link_mirror,
7009 (void *)&cmd_mirror_link_ruleid,
7010 (void *)&cmd_mirror_link_what,
7011 (void *)&cmd_mirror_link_dstpool,
7012 (void *)&cmd_mirror_link_poolid,
7013 (void *)&cmd_mirror_link_on,
7018 /* *** RESET VM MIRROR RULE *** */
7019 struct cmd_rm_mirror_rule_result {
7020 cmdline_fixed_string_t reset;
7021 cmdline_fixed_string_t port;
7023 cmdline_fixed_string_t mirror;
7027 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7028 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7030 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7031 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7033 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7034 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7036 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7037 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7038 mirror, "mirror-rule");
7039 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7040 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7044 cmd_reset_mirror_rule_parsed(void *parsed_result,
7045 __attribute__((unused)) struct cmdline *cl,
7046 __attribute__((unused)) void *data)
7049 struct cmd_set_mirror_link_result *res = parsed_result;
7051 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7053 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7056 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7057 .f = cmd_reset_mirror_rule_parsed,
7059 .help_str = "reset port X mirror-rule Y",
7061 (void *)&cmd_rm_mirror_rule_reset,
7062 (void *)&cmd_rm_mirror_rule_port,
7063 (void *)&cmd_rm_mirror_rule_portid,
7064 (void *)&cmd_rm_mirror_rule_mirror,
7065 (void *)&cmd_rm_mirror_rule_ruleid,
7070 /* ******************************************************************************** */
7072 struct cmd_dump_result {
7073 cmdline_fixed_string_t dump;
7077 dump_struct_sizes(void)
7079 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7080 DUMP_SIZE(struct rte_mbuf);
7081 DUMP_SIZE(struct rte_mempool);
7082 DUMP_SIZE(struct rte_ring);
7086 static void cmd_dump_parsed(void *parsed_result,
7087 __attribute__((unused)) struct cmdline *cl,
7088 __attribute__((unused)) void *data)
7090 struct cmd_dump_result *res = parsed_result;
7092 if (!strcmp(res->dump, "dump_physmem"))
7093 rte_dump_physmem_layout(stdout);
7094 else if (!strcmp(res->dump, "dump_memzone"))
7095 rte_memzone_dump(stdout);
7096 else if (!strcmp(res->dump, "dump_log_history"))
7097 rte_log_dump_history(stdout);
7098 else if (!strcmp(res->dump, "dump_struct_sizes"))
7099 dump_struct_sizes();
7100 else if (!strcmp(res->dump, "dump_ring"))
7101 rte_ring_list_dump(stdout);
7102 else if (!strcmp(res->dump, "dump_mempool"))
7103 rte_mempool_list_dump(stdout);
7104 else if (!strcmp(res->dump, "dump_devargs"))
7105 rte_eal_devargs_dump(stdout);
7108 cmdline_parse_token_string_t cmd_dump_dump =
7109 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7113 "dump_struct_sizes#"
7118 cmdline_parse_inst_t cmd_dump = {
7119 .f = cmd_dump_parsed, /* function to call */
7120 .data = NULL, /* 2nd arg of func */
7121 .help_str = "dump status",
7122 .tokens = { /* token list, NULL terminated */
7123 (void *)&cmd_dump_dump,
7128 /* ******************************************************************************** */
7130 struct cmd_dump_one_result {
7131 cmdline_fixed_string_t dump;
7132 cmdline_fixed_string_t name;
7135 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7136 __attribute__((unused)) void *data)
7138 struct cmd_dump_one_result *res = parsed_result;
7140 if (!strcmp(res->dump, "dump_ring")) {
7142 r = rte_ring_lookup(res->name);
7144 cmdline_printf(cl, "Cannot find ring\n");
7147 rte_ring_dump(stdout, r);
7148 } else if (!strcmp(res->dump, "dump_mempool")) {
7149 struct rte_mempool *mp;
7150 mp = rte_mempool_lookup(res->name);
7152 cmdline_printf(cl, "Cannot find mempool\n");
7155 rte_mempool_dump(stdout, mp);
7159 cmdline_parse_token_string_t cmd_dump_one_dump =
7160 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7161 "dump_ring#dump_mempool");
7163 cmdline_parse_token_string_t cmd_dump_one_name =
7164 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7166 cmdline_parse_inst_t cmd_dump_one = {
7167 .f = cmd_dump_one_parsed, /* function to call */
7168 .data = NULL, /* 2nd arg of func */
7169 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7170 .tokens = { /* token list, NULL terminated */
7171 (void *)&cmd_dump_one_dump,
7172 (void *)&cmd_dump_one_name,
7177 /* *** ADD/REMOVE an ethertype FILTER *** */
7178 struct cmd_ethertype_filter_result {
7179 cmdline_fixed_string_t filter;
7181 cmdline_fixed_string_t ethertype;
7182 uint16_t ethertype_value;
7183 cmdline_fixed_string_t priority;
7184 cmdline_fixed_string_t priority_en;
7185 uint8_t priority_value;
7186 cmdline_fixed_string_t queue;
7188 cmdline_fixed_string_t index;
7189 uint16_t index_value;
7193 cmd_ethertype_filter_parsed(void *parsed_result,
7194 __attribute__((unused)) struct cmdline *cl,
7195 __attribute__((unused)) void *data)
7198 struct cmd_ethertype_filter_result *res = parsed_result;
7199 struct rte_ethertype_filter filter;
7201 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
7202 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
7203 filter.priority = res->priority_value;
7205 if (!strcmp(res->priority_en, "enable"))
7206 filter.priority_en = 1;
7207 if (!strcmp(res->filter, "add_ethertype_filter"))
7208 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
7210 &filter, res->queue_id);
7211 else if (!strcmp(res->filter, "remove_ethertype_filter"))
7212 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
7214 else if (!strcmp(res->filter, "get_ethertype_filter"))
7215 get_ethertype_filter(res->port_id, res->index_value);
7218 printf("ethertype filter setting error: (%s)\n",
7222 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7223 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7225 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7226 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7227 ethertype, "ethertype");
7228 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
7229 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7230 ethertype_value, UINT16);
7231 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
7232 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7233 priority, "priority");
7234 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
7235 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7236 priority_en, "enable#disable");
7237 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
7238 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7239 priority_value, UINT8);
7240 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7241 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7243 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7244 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7246 cmdline_parse_token_string_t cmd_ethertype_filter_index =
7247 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7249 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
7250 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7251 index_value, UINT16);
7252 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
7253 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7254 filter, "add_ethertype_filter");
7255 cmdline_parse_inst_t cmd_add_ethertype_filter = {
7256 .f = cmd_ethertype_filter_parsed,
7258 .help_str = "add an ethertype filter",
7260 (void *)&cmd_ethertype_filter_add_filter,
7261 (void *)&cmd_ethertype_filter_port_id,
7262 (void *)&cmd_ethertype_filter_ethertype,
7263 (void *)&cmd_ethertype_filter_ethertype_value,
7264 (void *)&cmd_ethertype_filter_priority,
7265 (void *)&cmd_ethertype_filter_priority_en,
7266 (void *)&cmd_ethertype_filter_priority_value,
7267 (void *)&cmd_ethertype_filter_queue,
7268 (void *)&cmd_ethertype_filter_queue_id,
7269 (void *)&cmd_ethertype_filter_index,
7270 (void *)&cmd_ethertype_filter_index_value,
7275 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
7276 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7277 filter, "remove_ethertype_filter");
7278 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
7279 .f = cmd_ethertype_filter_parsed,
7281 .help_str = "remove an ethertype filter",
7283 (void *)&cmd_ethertype_filter_remove_filter,
7284 (void *)&cmd_ethertype_filter_port_id,
7285 (void *)&cmd_ethertype_filter_index,
7286 (void *)&cmd_ethertype_filter_index_value,
7290 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
7291 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7292 filter, "get_ethertype_filter");
7293 cmdline_parse_inst_t cmd_get_ethertype_filter = {
7294 .f = cmd_ethertype_filter_parsed,
7296 .help_str = "get an ethertype filter",
7298 (void *)&cmd_ethertype_filter_get_filter,
7299 (void *)&cmd_ethertype_filter_port_id,
7300 (void *)&cmd_ethertype_filter_index,
7301 (void *)&cmd_ethertype_filter_index_value,
7306 /* *** set SYN filter *** */
7307 struct cmd_set_syn_filter_result {
7308 cmdline_fixed_string_t filter;
7310 cmdline_fixed_string_t priority;
7311 cmdline_fixed_string_t high;
7312 cmdline_fixed_string_t queue;
7317 cmd_set_syn_filter_parsed(void *parsed_result,
7318 __attribute__((unused)) struct cmdline *cl,
7319 __attribute__((unused)) void *data)
7322 struct cmd_set_syn_filter_result *res = parsed_result;
7323 struct rte_syn_filter filter;
7325 if (!strcmp(res->filter, "add_syn_filter")) {
7326 if (!strcmp(res->high, "high"))
7330 ret = rte_eth_dev_add_syn_filter(res->port_id,
7331 &filter, res->queue_id);
7332 } else if (!strcmp(res->filter, "remove_syn_filter"))
7333 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7334 else if (!strcmp(res->filter, "get_syn_filter"))
7335 get_syn_filter(res->port_id);
7337 printf("syn filter setting error: (%s)\n", strerror(-ret));
7340 cmdline_parse_token_num_t cmd_syn_filter_portid =
7341 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7343 cmdline_parse_token_string_t cmd_syn_filter_priority =
7344 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7345 priority, "priority");
7346 cmdline_parse_token_string_t cmd_syn_filter_high =
7347 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7349 cmdline_parse_token_string_t cmd_syn_filter_queue =
7350 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7352 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7353 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7355 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7356 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7357 filter, "add_syn_filter");
7358 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7359 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7360 filter, "remove_syn_filter");
7361 cmdline_parse_inst_t cmd_add_syn_filter = {
7362 .f = cmd_set_syn_filter_parsed,
7364 .help_str = "add syn filter",
7366 (void *)&cmd_syn_filter_add_filter,
7367 (void *)&cmd_syn_filter_portid,
7368 (void *)&cmd_syn_filter_priority,
7369 (void *)&cmd_syn_filter_high,
7370 (void *)&cmd_syn_filter_queue,
7371 (void *)&cmd_syn_filter_queue_id,
7375 cmdline_parse_inst_t cmd_remove_syn_filter = {
7376 .f = cmd_set_syn_filter_parsed,
7378 .help_str = "remove syn filter",
7380 (void *)&cmd_syn_filter_remove_filter,
7381 (void *)&cmd_syn_filter_portid,
7386 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7387 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7388 filter, "get_syn_filter");
7390 cmdline_parse_inst_t cmd_get_syn_filter = {
7391 .f = cmd_set_syn_filter_parsed,
7393 .help_str = "get syn filter",
7395 (void *)&cmd_syn_filter_get_filter,
7396 (void *)&cmd_syn_filter_portid,
7401 /* *** ADD/REMOVE A 2tuple FILTER *** */
7402 struct cmd_2tuple_filter_result {
7403 cmdline_fixed_string_t filter;
7405 cmdline_fixed_string_t protocol;
7406 uint8_t protocol_value;
7407 uint8_t protocol_mask;
7408 cmdline_fixed_string_t dst_port;
7409 uint16_t dst_port_value;
7410 uint16_t dst_port_mask;
7411 cmdline_fixed_string_t flags;
7412 uint8_t flags_value;
7413 cmdline_fixed_string_t priority;
7414 uint8_t priority_value;
7415 cmdline_fixed_string_t queue;
7417 cmdline_fixed_string_t index;
7418 uint16_t index_value;
7422 cmd_2tuple_filter_parsed(void *parsed_result,
7423 __attribute__((unused)) struct cmdline *cl,
7424 __attribute__((unused)) void *data)
7427 struct rte_2tuple_filter filter;
7428 struct cmd_2tuple_filter_result *res = parsed_result;
7430 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7432 if (!strcmp(res->filter, "add_2tuple_filter")) {
7433 /* need convert to big endian. */
7434 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7435 filter.protocol = res->protocol_value;
7436 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7437 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7438 filter.priority = res->priority_value;
7439 filter.tcp_flags = res->flags_value;
7440 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7441 res->index_value, &filter, res->queue_id);
7442 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7443 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7445 else if (!strcmp(res->filter, "get_2tuple_filter"))
7446 get_2tuple_filter(res->port_id, res->index_value);
7449 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7452 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7453 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7455 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7456 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7457 protocol, "protocol");
7458 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7459 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7460 protocol_value, UINT8);
7461 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7462 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7463 protocol_mask, UINT8);
7464 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7465 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7466 dst_port, "dst_port");
7467 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7468 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7469 dst_port_value, UINT16);
7470 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7471 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7472 dst_port_mask, UINT16);
7473 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7474 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7476 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7477 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7478 flags_value, UINT8);
7479 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7480 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7481 priority, "priority");
7482 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7483 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7484 priority_value, UINT8);
7485 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7486 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7488 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7489 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7491 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7492 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7494 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7495 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7496 index_value, UINT16);
7497 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7498 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7499 filter, "add_2tuple_filter");
7500 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7501 .f = cmd_2tuple_filter_parsed,
7503 .help_str = "add a 2tuple filter",
7505 (void *)&cmd_2tuple_filter_add_filter,
7506 (void *)&cmd_2tuple_filter_port_id,
7507 (void *)&cmd_2tuple_filter_protocol,
7508 (void *)&cmd_2tuple_filter_protocol_value,
7509 (void *)&cmd_2tuple_filter_protocol_mask,
7510 (void *)&cmd_2tuple_filter_dst_port,
7511 (void *)&cmd_2tuple_filter_dst_port_value,
7512 (void *)&cmd_2tuple_filter_dst_port_mask,
7513 (void *)&cmd_2tuple_filter_flags,
7514 (void *)&cmd_2tuple_filter_flags_value,
7515 (void *)&cmd_2tuple_filter_priority,
7516 (void *)&cmd_2tuple_filter_priority_value,
7517 (void *)&cmd_2tuple_filter_queue,
7518 (void *)&cmd_2tuple_filter_queue_id,
7519 (void *)&cmd_2tuple_filter_index,
7520 (void *)&cmd_2tuple_filter_index_value,
7525 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7526 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7527 filter, "remove_2tuple_filter");
7528 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7529 .f = cmd_2tuple_filter_parsed,
7531 .help_str = "remove a 2tuple filter",
7533 (void *)&cmd_2tuple_filter_remove_filter,
7534 (void *)&cmd_2tuple_filter_port_id,
7535 (void *)&cmd_2tuple_filter_index,
7536 (void *)&cmd_2tuple_filter_index_value,
7540 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7541 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7542 filter, "get_2tuple_filter");
7543 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7544 .f = cmd_2tuple_filter_parsed,
7546 .help_str = "get a 2tuple filter",
7548 (void *)&cmd_2tuple_filter_get_filter,
7549 (void *)&cmd_2tuple_filter_port_id,
7550 (void *)&cmd_2tuple_filter_index,
7551 (void *)&cmd_2tuple_filter_index_value,
7556 /* *** ADD/REMOVE A 5tuple FILTER *** */
7557 struct cmd_5tuple_filter_result {
7558 cmdline_fixed_string_t filter;
7560 cmdline_fixed_string_t dst_ip;
7561 cmdline_ipaddr_t dst_ip_value;
7562 cmdline_fixed_string_t src_ip;
7563 cmdline_ipaddr_t src_ip_value;
7564 cmdline_fixed_string_t dst_port;
7565 uint16_t dst_port_value;
7566 cmdline_fixed_string_t src_port;
7567 uint16_t src_port_value;
7568 cmdline_fixed_string_t protocol;
7569 uint8_t protocol_value;
7570 cmdline_fixed_string_t mask;
7572 cmdline_fixed_string_t flags;
7573 uint8_t flags_value;
7574 cmdline_fixed_string_t priority;
7575 uint8_t priority_value;
7576 cmdline_fixed_string_t queue;
7578 cmdline_fixed_string_t index;
7579 uint16_t index_value;
7583 cmd_5tuple_filter_parsed(void *parsed_result,
7584 __attribute__((unused)) struct cmdline *cl,
7585 __attribute__((unused)) void *data)
7588 struct rte_5tuple_filter filter;
7589 struct cmd_5tuple_filter_result *res = parsed_result;
7591 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7593 if (!strcmp(res->filter, "add_5tuple_filter")) {
7594 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7595 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7596 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7597 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7598 filter.protocol = res->protocol_value;
7599 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7600 filter.priority = res->priority_value;
7601 filter.tcp_flags = res->flags_value;
7603 if (res->dst_ip_value.family == AF_INET)
7604 /* no need to convert, already big endian. */
7605 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7607 if (filter.dst_ip_mask == 0) {
7608 printf("can not support ipv6 involved compare.\n");
7614 if (res->src_ip_value.family == AF_INET)
7615 /* no need to convert, already big endian. */
7616 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7618 if (filter.src_ip_mask == 0) {
7619 printf("can not support ipv6 involved compare.\n");
7624 /* need convert to big endian. */
7625 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7626 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7628 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7629 res->index_value, &filter, res->queue_id);
7630 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7631 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7633 else if (!strcmp(res->filter, "get_5tuple_filter"))
7634 get_5tuple_filter(res->port_id, res->index_value);
7636 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7640 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7641 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7643 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7644 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7646 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7647 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7649 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7650 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7652 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7653 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7655 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7656 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7657 dst_port, "dst_port");
7658 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7659 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7660 dst_port_value, UINT16);
7661 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7662 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7663 src_port, "src_port");
7664 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7665 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7666 src_port_value, UINT16);
7667 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7668 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7669 protocol, "protocol");
7670 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7671 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7672 protocol_value, UINT8);
7673 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7674 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7676 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7677 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7679 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7680 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7682 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7683 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7684 flags_value, UINT8);
7685 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7686 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7687 priority, "priority");
7688 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7689 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7690 priority_value, UINT8);
7691 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7692 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7694 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7695 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7697 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7698 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7700 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7701 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7702 index_value, UINT16);
7704 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7705 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7706 filter, "add_5tuple_filter");
7707 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7708 .f = cmd_5tuple_filter_parsed,
7710 .help_str = "add a 5tuple filter",
7712 (void *)&cmd_5tuple_filter_add_filter,
7713 (void *)&cmd_5tuple_filter_port_id,
7714 (void *)&cmd_5tuple_filter_dst_ip,
7715 (void *)&cmd_5tuple_filter_dst_ip_value,
7716 (void *)&cmd_5tuple_filter_src_ip,
7717 (void *)&cmd_5tuple_filter_src_ip_value,
7718 (void *)&cmd_5tuple_filter_dst_port,
7719 (void *)&cmd_5tuple_filter_dst_port_value,
7720 (void *)&cmd_5tuple_filter_src_port,
7721 (void *)&cmd_5tuple_filter_src_port_value,
7722 (void *)&cmd_5tuple_filter_protocol,
7723 (void *)&cmd_5tuple_filter_protocol_value,
7724 (void *)&cmd_5tuple_filter_mask,
7725 (void *)&cmd_5tuple_filter_mask_value,
7726 (void *)&cmd_5tuple_filter_flags,
7727 (void *)&cmd_5tuple_filter_flags_value,
7728 (void *)&cmd_5tuple_filter_priority,
7729 (void *)&cmd_5tuple_filter_priority_value,
7730 (void *)&cmd_5tuple_filter_queue,
7731 (void *)&cmd_5tuple_filter_queue_id,
7732 (void *)&cmd_5tuple_filter_index,
7733 (void *)&cmd_5tuple_filter_index_value,
7738 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7739 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7740 filter, "remove_5tuple_filter");
7741 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7742 .f = cmd_5tuple_filter_parsed,
7744 .help_str = "remove a 5tuple filter",
7746 (void *)&cmd_5tuple_filter_remove_filter,
7747 (void *)&cmd_5tuple_filter_port_id,
7748 (void *)&cmd_5tuple_filter_index,
7749 (void *)&cmd_5tuple_filter_index_value,
7754 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7755 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7756 filter, "get_5tuple_filter");
7757 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7758 .f = cmd_5tuple_filter_parsed,
7760 .help_str = "get a 5tuple filter",
7762 (void *)&cmd_5tuple_filter_get_filter,
7763 (void *)&cmd_5tuple_filter_port_id,
7764 (void *)&cmd_5tuple_filter_index,
7765 (void *)&cmd_5tuple_filter_index_value,
7770 /* *** ADD/REMOVE A flex FILTER *** */
7771 struct cmd_flex_filter_result {
7772 cmdline_fixed_string_t filter;
7774 cmdline_fixed_string_t len;
7776 cmdline_fixed_string_t bytes;
7777 cmdline_fixed_string_t bytes_value;
7778 cmdline_fixed_string_t mask;
7779 cmdline_fixed_string_t mask_value;
7780 cmdline_fixed_string_t priority;
7781 uint8_t priority_value;
7782 cmdline_fixed_string_t queue;
7784 cmdline_fixed_string_t index;
7785 uint16_t index_value;
7788 static int xdigit2val(unsigned char c)
7793 else if (isupper(c))
7801 cmd_flex_filter_parsed(void *parsed_result,
7802 __attribute__((unused)) struct cmdline *cl,
7803 __attribute__((unused)) void *data)
7806 struct rte_flex_filter filter;
7807 struct cmd_flex_filter_result *res = parsed_result;
7808 char *bytes_ptr, *mask_ptr;
7816 if (!strcmp(res->filter, "add_flex_filter")) {
7817 if (res->len_value > 128) {
7818 printf("the len exceed the max length 128\n");
7821 memset(&filter, 0, sizeof(struct rte_flex_filter));
7822 filter.len = res->len_value;
7823 filter.priority = res->priority_value;
7824 bytes_ptr = res->bytes_value;
7825 mask_ptr = res->mask_value;
7828 /* translate bytes string to uint_32 array. */
7829 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7830 (bytes_ptr[1] == 'X')))
7832 len = strnlen(bytes_ptr, res->len_value * 2);
7833 if (len == 0 || (len % 8 != 0)) {
7834 printf("please check len and bytes input\n");
7837 for (i = 0; i < len; i++) {
7839 if (isxdigit(c) == 0) {
7840 /* invalid characters. */
7841 printf("invalid input\n");
7844 val = xdigit2val(c);
7848 dword |= byte << (4 * mod - 4);
7853 filter.dwords[j] = dword;
7854 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7860 /* translate mask string to uint8_t array. */
7862 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7863 (mask_ptr[1] == 'X')))
7865 len = strnlen(mask_ptr, (res->len_value+3)/4);
7867 printf("invalid input\n");
7870 for (i = 0; i < len; i++) {
7872 if (isxdigit(c) == 0) {
7873 /* invalid characters. */
7874 printf("invalid input\n");
7877 val = xdigit2val(c);
7878 hex |= (uint8_t)(val & 0x8) >> 3;
7879 hex |= (uint8_t)(val & 0x4) >> 1;
7880 hex |= (uint8_t)(val & 0x2) << 1;
7881 hex |= (uint8_t)(val & 0x1) << 3;
7884 filter.mask[j] = byte;
7885 printf("mask[%d]:%02x ", j, filter.mask[j]);
7893 printf("call function rte_eth_dev_add_flex_filter: "
7894 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7895 res->index_value, res->queue_id,
7896 filter.len, filter.priority);
7897 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7898 &filter, res->queue_id);
7900 } else if (!strcmp(res->filter, "remove_flex_filter"))
7901 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7903 else if (!strcmp(res->filter, "get_flex_filter"))
7904 get_flex_filter(res->port_id, res->index_value);
7907 printf("flex filter setting error: (%s)\n", strerror(-ret));
7910 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7911 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7913 cmdline_parse_token_string_t cmd_flex_filter_len =
7914 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7916 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7917 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7919 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7920 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7922 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7923 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7925 cmdline_parse_token_string_t cmd_flex_filter_mask =
7926 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7928 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7929 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7931 cmdline_parse_token_string_t cmd_flex_filter_priority =
7932 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7933 priority, "priority");
7934 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7935 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7936 priority_value, UINT8);
7937 cmdline_parse_token_string_t cmd_flex_filter_queue =
7938 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7940 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7941 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7943 cmdline_parse_token_string_t cmd_flex_filter_index =
7944 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7946 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7947 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7948 index_value, UINT16);
7949 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7950 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7951 filter, "add_flex_filter");
7952 cmdline_parse_inst_t cmd_add_flex_filter = {
7953 .f = cmd_flex_filter_parsed,
7955 .help_str = "add a flex filter",
7957 (void *)&cmd_flex_filter_add_filter,
7958 (void *)&cmd_flex_filter_port_id,
7959 (void *)&cmd_flex_filter_len,
7960 (void *)&cmd_flex_filter_len_value,
7961 (void *)&cmd_flex_filter_bytes,
7962 (void *)&cmd_flex_filter_bytes_value,
7963 (void *)&cmd_flex_filter_mask,
7964 (void *)&cmd_flex_filter_mask_value,
7965 (void *)&cmd_flex_filter_priority,
7966 (void *)&cmd_flex_filter_priority_value,
7967 (void *)&cmd_flex_filter_queue,
7968 (void *)&cmd_flex_filter_queue_id,
7969 (void *)&cmd_flex_filter_index,
7970 (void *)&cmd_flex_filter_index_value,
7975 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7976 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7977 filter, "remove_flex_filter");
7978 cmdline_parse_inst_t cmd_remove_flex_filter = {
7979 .f = cmd_flex_filter_parsed,
7981 .help_str = "remove a flex filter",
7983 (void *)&cmd_flex_filter_remove_filter,
7984 (void *)&cmd_flex_filter_port_id,
7985 (void *)&cmd_flex_filter_index,
7986 (void *)&cmd_flex_filter_index_value,
7991 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7992 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7993 filter, "get_flex_filter");
7994 cmdline_parse_inst_t cmd_get_flex_filter = {
7995 .f = cmd_flex_filter_parsed,
7997 .help_str = "get a flex filter",
7999 (void *)&cmd_flex_filter_get_filter,
8000 (void *)&cmd_flex_filter_port_id,
8001 (void *)&cmd_flex_filter_index,
8002 (void *)&cmd_flex_filter_index_value,
8007 /* *** Filters Control *** */
8009 /* *** deal with flow director filter *** */
8010 struct cmd_flow_director_result {
8011 cmdline_fixed_string_t flow_director_filter;
8013 cmdline_fixed_string_t ops;
8014 cmdline_fixed_string_t flow;
8015 cmdline_fixed_string_t flow_type;
8016 cmdline_fixed_string_t src;
8017 cmdline_ipaddr_t ip_src;
8019 cmdline_fixed_string_t dst;
8020 cmdline_ipaddr_t ip_dst;
8022 cmdline_fixed_string_t verify_tag;
8023 uint32_t verify_tag_value;
8024 cmdline_fixed_string_t flexbytes;
8025 cmdline_fixed_string_t flexbytes_value;
8026 cmdline_fixed_string_t drop;
8027 cmdline_fixed_string_t queue;
8029 cmdline_fixed_string_t fd_id;
8030 uint32_t fd_id_value;
8034 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8037 const char *p, *p0 = q_arg;
8039 unsigned long int_fld;
8040 char *str_fld[max_num];
8045 p = strchr(p0, '(');
8049 p0 = strchr(p, ')');
8054 if (size >= sizeof(s))
8057 snprintf(s, sizeof(s), "%.*s", size, p);
8058 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8059 if (ret < 0 || ret > max_num)
8061 for (i = 0; i < ret; i++) {
8063 int_fld = strtoul(str_fld[i], &end, 0);
8064 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8066 flexbytes[i] = (uint8_t)int_fld;
8071 static enum rte_eth_flow_type
8072 str2flowtype(char *string)
8075 static const struct {
8077 enum rte_eth_flow_type type;
8078 } flowtype_str[] = {
8079 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8080 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8081 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8082 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8083 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8084 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8085 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8086 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8087 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8088 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8091 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8092 if (!strcmp(flowtype_str[i].str, string))
8093 return flowtype_str[i].type;
8095 return RTE_ETH_FLOW_TYPE_NONE;
8098 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8100 if ((ip_addr).family == AF_INET) \
8101 (ip) = (ip_addr).addr.ipv4.s_addr; \
8103 printf("invalid parameter.\n"); \
8108 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8110 if ((ip_addr).family == AF_INET6) \
8111 (void)rte_memcpy(&(ip), \
8112 &((ip_addr).addr.ipv6), \
8113 sizeof(struct in6_addr)); \
8115 printf("invalid parameter.\n"); \
8121 cmd_flow_director_filter_parsed(void *parsed_result,
8122 __attribute__((unused)) struct cmdline *cl,
8123 __attribute__((unused)) void *data)
8125 struct cmd_flow_director_result *res = parsed_result;
8126 struct rte_eth_fdir_filter entry;
8127 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8130 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8132 printf("flow director is not supported on port %u.\n",
8136 memset(flexbytes, 0, sizeof(flexbytes));
8137 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8138 ret = parse_flexbytes(res->flexbytes_value,
8140 RTE_ETH_FDIR_MAX_FLEXLEN);
8142 printf("error: Cannot parse flexbytes input.\n");
8146 entry.input.flow_type = str2flowtype(res->flow_type);
8147 switch (entry.input.flow_type) {
8148 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
8149 case RTE_ETH_FLOW_TYPE_UDPV4:
8150 case RTE_ETH_FLOW_TYPE_TCPV4:
8151 IPV4_ADDR_TO_UINT(res->ip_dst,
8152 entry.input.flow.ip4_flow.dst_ip);
8153 IPV4_ADDR_TO_UINT(res->ip_src,
8154 entry.input.flow.ip4_flow.src_ip);
8155 /* need convert to big endian. */
8156 entry.input.flow.udp4_flow.dst_port =
8157 rte_cpu_to_be_16(res->port_dst);
8158 entry.input.flow.udp4_flow.src_port =
8159 rte_cpu_to_be_16(res->port_src);
8161 case RTE_ETH_FLOW_TYPE_SCTPV4:
8162 IPV4_ADDR_TO_UINT(res->ip_dst,
8163 entry.input.flow.sctp4_flow.ip.dst_ip);
8164 IPV4_ADDR_TO_UINT(res->ip_src,
8165 entry.input.flow.sctp4_flow.ip.src_ip);
8166 /* need convert to big endian. */
8167 entry.input.flow.sctp4_flow.verify_tag =
8168 rte_cpu_to_be_32(res->verify_tag_value);
8170 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
8171 case RTE_ETH_FLOW_TYPE_UDPV6:
8172 case RTE_ETH_FLOW_TYPE_TCPV6:
8173 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8174 entry.input.flow.ip6_flow.dst_ip);
8175 IPV6_ADDR_TO_ARRAY(res->ip_src,
8176 entry.input.flow.ip6_flow.src_ip);
8177 /* need convert to big endian. */
8178 entry.input.flow.udp6_flow.dst_port =
8179 rte_cpu_to_be_16(res->port_dst);
8180 entry.input.flow.udp6_flow.src_port =
8181 rte_cpu_to_be_16(res->port_src);
8183 case RTE_ETH_FLOW_TYPE_SCTPV6:
8184 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8185 entry.input.flow.sctp6_flow.ip.dst_ip);
8186 IPV6_ADDR_TO_ARRAY(res->ip_src,
8187 entry.input.flow.sctp6_flow.ip.src_ip);
8188 /* need convert to big endian. */
8189 entry.input.flow.sctp6_flow.verify_tag =
8190 rte_cpu_to_be_32(res->verify_tag_value);
8193 printf("invalid parameter.\n");
8196 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8198 RTE_ETH_FDIR_MAX_FLEXLEN);
8200 entry.action.flex_off = 0; /*use 0 by default */
8201 if (!strcmp(res->drop, "drop"))
8202 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8204 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8205 /* set to report FD ID by default */
8206 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8207 entry.action.rx_queue = res->queue_id;
8208 entry.soft_id = res->fd_id_value;
8209 if (!strcmp(res->ops, "add"))
8210 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8211 RTE_ETH_FILTER_ADD, &entry);
8213 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8214 RTE_ETH_FILTER_DELETE, &entry);
8216 printf("flow director programming error: (%s)\n",
8220 cmdline_parse_token_string_t cmd_flow_director_filter =
8221 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8222 flow_director_filter, "flow_director_filter");
8223 cmdline_parse_token_num_t cmd_flow_director_port_id =
8224 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8226 cmdline_parse_token_string_t cmd_flow_director_ops =
8227 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8229 cmdline_parse_token_string_t cmd_flow_director_flow =
8230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8232 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8233 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8235 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8236 "ip6#ip6-frag#tcp6#udp6#sctp6");
8237 cmdline_parse_token_string_t cmd_flow_director_src =
8238 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8240 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8241 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8243 cmdline_parse_token_num_t cmd_flow_director_port_src =
8244 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8246 cmdline_parse_token_string_t cmd_flow_director_dst =
8247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8249 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8250 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8252 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8253 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8255 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8257 verify_tag, "verify_tag");
8258 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8259 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8260 verify_tag_value, UINT32);
8261 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8263 flexbytes, "flexbytes");
8264 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8266 flexbytes_value, NULL);
8267 cmdline_parse_token_string_t cmd_flow_director_drop =
8268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8270 cmdline_parse_token_string_t cmd_flow_director_queue =
8271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8273 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8274 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8276 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8279 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8280 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8281 fd_id_value, UINT32);
8283 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8284 .f = cmd_flow_director_filter_parsed,
8286 .help_str = "add or delete an ip flow director entry on NIC",
8288 (void *)&cmd_flow_director_filter,
8289 (void *)&cmd_flow_director_port_id,
8290 (void *)&cmd_flow_director_ops,
8291 (void *)&cmd_flow_director_flow,
8292 (void *)&cmd_flow_director_flow_type,
8293 (void *)&cmd_flow_director_src,
8294 (void *)&cmd_flow_director_ip_src,
8295 (void *)&cmd_flow_director_dst,
8296 (void *)&cmd_flow_director_ip_dst,
8297 (void *)&cmd_flow_director_flexbytes,
8298 (void *)&cmd_flow_director_flexbytes_value,
8299 (void *)&cmd_flow_director_drop,
8300 (void *)&cmd_flow_director_queue,
8301 (void *)&cmd_flow_director_queue_id,
8302 (void *)&cmd_flow_director_fd_id,
8303 (void *)&cmd_flow_director_fd_id_value,
8308 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8309 .f = cmd_flow_director_filter_parsed,
8311 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8313 (void *)&cmd_flow_director_filter,
8314 (void *)&cmd_flow_director_port_id,
8315 (void *)&cmd_flow_director_ops,
8316 (void *)&cmd_flow_director_flow,
8317 (void *)&cmd_flow_director_flow_type,
8318 (void *)&cmd_flow_director_src,
8319 (void *)&cmd_flow_director_ip_src,
8320 (void *)&cmd_flow_director_port_src,
8321 (void *)&cmd_flow_director_dst,
8322 (void *)&cmd_flow_director_ip_dst,
8323 (void *)&cmd_flow_director_port_dst,
8324 (void *)&cmd_flow_director_flexbytes,
8325 (void *)&cmd_flow_director_flexbytes_value,
8326 (void *)&cmd_flow_director_drop,
8327 (void *)&cmd_flow_director_queue,
8328 (void *)&cmd_flow_director_queue_id,
8329 (void *)&cmd_flow_director_fd_id,
8330 (void *)&cmd_flow_director_fd_id_value,
8335 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8336 .f = cmd_flow_director_filter_parsed,
8338 .help_str = "add or delete a sctp flow director entry on NIC",
8340 (void *)&cmd_flow_director_filter,
8341 (void *)&cmd_flow_director_port_id,
8342 (void *)&cmd_flow_director_ops,
8343 (void *)&cmd_flow_director_flow,
8344 (void *)&cmd_flow_director_flow_type,
8345 (void *)&cmd_flow_director_src,
8346 (void *)&cmd_flow_director_ip_src,
8347 (void *)&cmd_flow_director_dst,
8348 (void *)&cmd_flow_director_ip_dst,
8349 (void *)&cmd_flow_director_verify_tag,
8350 (void *)&cmd_flow_director_verify_tag_value,
8351 (void *)&cmd_flow_director_flexbytes,
8352 (void *)&cmd_flow_director_flexbytes_value,
8353 (void *)&cmd_flow_director_drop,
8354 (void *)&cmd_flow_director_queue,
8355 (void *)&cmd_flow_director_queue_id,
8356 (void *)&cmd_flow_director_fd_id,
8357 (void *)&cmd_flow_director_fd_id_value,
8362 struct cmd_flush_flow_director_result {
8363 cmdline_fixed_string_t flush_flow_director;
8367 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8368 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8369 flush_flow_director, "flush_flow_director");
8370 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8371 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8375 cmd_flush_flow_director_parsed(void *parsed_result,
8376 __attribute__((unused)) struct cmdline *cl,
8377 __attribute__((unused)) void *data)
8379 struct cmd_flow_director_result *res = parsed_result;
8382 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8384 printf("flow director is not supported on port %u.\n",
8389 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8390 RTE_ETH_FILTER_FLUSH, NULL);
8392 printf("flow director table flushing error: (%s)\n",
8396 cmdline_parse_inst_t cmd_flush_flow_director = {
8397 .f = cmd_flush_flow_director_parsed,
8399 .help_str = "flush all flow director entries of a device on NIC",
8401 (void *)&cmd_flush_flow_director_flush,
8402 (void *)&cmd_flush_flow_director_port_id,
8407 /* *** deal with flow director mask on flexible payload *** */
8408 struct cmd_flow_director_flex_mask_result {
8409 cmdline_fixed_string_t flow_director_flexmask;
8411 cmdline_fixed_string_t flow;
8412 cmdline_fixed_string_t flow_type;
8413 cmdline_fixed_string_t mask;
8417 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8418 __attribute__((unused)) struct cmdline *cl,
8419 __attribute__((unused)) void *data)
8421 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8422 struct rte_eth_fdir_flex_mask flex_mask;
8423 struct rte_port *port;
8424 enum rte_eth_flow_type i;
8427 if (res->port_id > nb_ports) {
8428 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8432 port = &ports[res->port_id];
8433 /** Check if the port is not started **/
8434 if (port->port_status != RTE_PORT_STOPPED) {
8435 printf("Please stop port %d first\n", res->port_id);
8439 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8440 ret = parse_flexbytes(res->mask,
8442 RTE_ETH_FDIR_MAX_FLEXLEN);
8444 printf("error: Cannot parse mask input.\n");
8447 if (!strcmp(res->flow_type, "all")) {
8448 for (i = RTE_ETH_FLOW_TYPE_UDPV4;
8449 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8451 flex_mask.flow_type = i;
8452 fdir_set_flex_mask(res->port_id, &flex_mask);
8454 cmd_reconfig_device_queue(res->port_id, 1, 0);
8457 flex_mask.flow_type = str2flowtype(res->flow_type);
8458 fdir_set_flex_mask(res->port_id, &flex_mask);
8459 cmd_reconfig_device_queue(res->port_id, 1, 0);
8462 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8463 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8464 flow_director_flexmask,
8465 "flow_director_flex_mask");
8466 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8467 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8469 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8472 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8475 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8476 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8477 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8478 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8481 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8482 .f = cmd_flow_director_flex_mask_parsed,
8484 .help_str = "set flow director's flex mask on NIC",
8486 (void *)&cmd_flow_director_flexmask,
8487 (void *)&cmd_flow_director_flexmask_port_id,
8488 (void *)&cmd_flow_director_flexmask_flow,
8489 (void *)&cmd_flow_director_flexmask_flow_type,
8490 (void *)&cmd_flow_director_flexmask_mask,
8495 /* *** deal with flow director flexible payload configuration *** */
8496 struct cmd_flow_director_flexpayload_result {
8497 cmdline_fixed_string_t flow_director_flexpayload;
8499 cmdline_fixed_string_t payload_layer;
8500 cmdline_fixed_string_t payload_cfg;
8504 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8507 const char *p, *p0 = q_arg;
8509 unsigned long int_fld;
8510 char *str_fld[max_num];
8515 p = strchr(p0, '(');
8519 p0 = strchr(p, ')');
8524 if (size >= sizeof(s))
8527 snprintf(s, sizeof(s), "%.*s", size, p);
8528 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8529 if (ret < 0 || ret > max_num)
8531 for (i = 0; i < ret; i++) {
8533 int_fld = strtoul(str_fld[i], &end, 0);
8534 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8536 offsets[i] = (uint16_t)int_fld;
8542 cmd_flow_director_flxpld_parsed(void *parsed_result,
8543 __attribute__((unused)) struct cmdline *cl,
8544 __attribute__((unused)) void *data)
8546 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8547 struct rte_eth_flex_payload_cfg flex_cfg;
8548 struct rte_port *port;
8551 if (res->port_id > nb_ports) {
8552 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8556 port = &ports[res->port_id];
8557 /** Check if the port is not started **/
8558 if (port->port_status != RTE_PORT_STOPPED) {
8559 printf("Please stop port %d first\n", res->port_id);
8563 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8565 if (!strcmp(res->payload_layer, "l2"))
8566 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8567 else if (!strcmp(res->payload_layer, "l3"))
8568 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8569 else if (!strcmp(res->payload_layer, "l4"))
8570 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8572 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8573 RTE_ETH_FDIR_MAX_FLEXLEN);
8575 printf("error: Cannot parse flex payload input.\n");
8579 fdir_set_flex_payload(res->port_id, &flex_cfg);
8580 cmd_reconfig_device_queue(res->port_id, 1, 0);
8583 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8584 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8585 flow_director_flexpayload,
8586 "flow_director_flex_payload");
8587 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8588 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8590 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8592 payload_layer, "l2#l3#l4");
8593 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8597 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8598 .f = cmd_flow_director_flxpld_parsed,
8600 .help_str = "set flow director's flex payload on NIC",
8602 (void *)&cmd_flow_director_flexpayload,
8603 (void *)&cmd_flow_director_flexpayload_port_id,
8604 (void *)&cmd_flow_director_flexpayload_payload_layer,
8605 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8610 /* ******************************************************************************** */
8612 /* list of instructions */
8613 cmdline_parse_ctx_t main_ctx[] = {
8614 (cmdline_parse_inst_t *)&cmd_help_brief,
8615 (cmdline_parse_inst_t *)&cmd_help_long,
8616 (cmdline_parse_inst_t *)&cmd_quit,
8617 (cmdline_parse_inst_t *)&cmd_showport,
8618 (cmdline_parse_inst_t *)&cmd_showportall,
8619 (cmdline_parse_inst_t *)&cmd_showcfg,
8620 (cmdline_parse_inst_t *)&cmd_start,
8621 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8622 (cmdline_parse_inst_t *)&cmd_set_link_up,
8623 (cmdline_parse_inst_t *)&cmd_set_link_down,
8624 (cmdline_parse_inst_t *)&cmd_reset,
8625 (cmdline_parse_inst_t *)&cmd_set_numbers,
8626 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8627 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8628 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8629 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8630 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8631 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8632 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8633 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8634 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8635 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8636 (cmdline_parse_inst_t *)&cmd_set_link_check,
8637 #ifdef RTE_NIC_BYPASS
8638 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8639 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8640 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8641 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8643 #ifdef RTE_LIBRTE_PMD_BOND
8644 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8645 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8646 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8647 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8648 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8649 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8650 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8651 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8652 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8654 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8655 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8656 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8657 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8658 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8659 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8660 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8661 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
8662 (cmdline_parse_inst_t *)&cmd_tx_cksum_show,
8663 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8664 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8665 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8666 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8667 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8668 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8669 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8670 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8671 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8672 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8673 (cmdline_parse_inst_t *)&cmd_config_dcb,
8674 (cmdline_parse_inst_t *)&cmd_read_reg,
8675 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8676 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8677 (cmdline_parse_inst_t *)&cmd_write_reg,
8678 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8679 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8680 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8681 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
8682 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
8683 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
8684 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
8685 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
8686 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
8687 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
8688 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
8689 (cmdline_parse_inst_t *)&cmd_stop,
8690 (cmdline_parse_inst_t *)&cmd_mac_addr,
8691 (cmdline_parse_inst_t *)&cmd_set_qmap,
8692 (cmdline_parse_inst_t *)&cmd_operate_port,
8693 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8694 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8695 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8696 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8697 (cmdline_parse_inst_t *)&cmd_config_mtu,
8698 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8699 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8700 (cmdline_parse_inst_t *)&cmd_config_rss,
8701 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8702 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8703 (cmdline_parse_inst_t *)&cmd_showport_reta,
8704 (cmdline_parse_inst_t *)&cmd_config_burst,
8705 (cmdline_parse_inst_t *)&cmd_config_thresh,
8706 (cmdline_parse_inst_t *)&cmd_config_threshold,
8707 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8708 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8709 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8710 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8711 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8712 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8713 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8714 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8715 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8716 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8717 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8718 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8719 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8720 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8721 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8722 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8723 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8724 (cmdline_parse_inst_t *)&cmd_dump,
8725 (cmdline_parse_inst_t *)&cmd_dump_one,
8726 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
8727 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
8728 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
8729 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
8730 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
8731 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
8732 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
8733 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
8734 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
8735 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
8736 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
8737 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
8738 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
8739 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
8740 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
8741 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8742 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8743 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8744 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8745 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8746 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
8750 /* prompt function, called from main on MASTER lcore */
8756 /* initialize non-constant commands */
8757 cmd_set_fwd_mode_init();
8759 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8763 cmdline_interact(cl);
8764 cmdline_stdin_exit(cl);
8768 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8770 if (id < nb_ports) {
8771 /* check if need_reconfig has been set to 1 */
8772 if (ports[id].need_reconfig == 0)
8773 ports[id].need_reconfig = dev;
8774 /* check if need_reconfig_queues has been set to 1 */
8775 if (ports[id].need_reconfig_queues == 0)
8776 ports[id].need_reconfig_queues = queue;
8780 for (pid = 0; pid < nb_ports; pid++) {
8781 /* check if need_reconfig has been set to 1 */
8782 if (ports[pid].need_reconfig == 0)
8783 ports[pid].need_reconfig = dev;
8784 /* check if need_reconfig_queues has been set to 1 */
8785 if (ports[pid].need_reconfig_queues == 0)
8786 ports[pid].need_reconfig_queues = queue;
8791 #ifdef RTE_NIC_BYPASS
8793 bypass_is_supported(portid_t port_id)
8795 struct rte_port *port;
8796 struct rte_pci_id *pci_id;
8798 if (port_id >= nb_ports) {
8799 printf("\tPort id must be less than %d.\n", nb_ports);
8803 /* Get the device id. */
8804 port = &ports[port_id];
8805 pci_id = &port->dev_info.pci_dev->id;
8807 /* Check if NIC supports bypass. */
8808 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8812 printf("\tBypass not supported for port_id = %d.\n", port_id);