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_launch.h>
63 #include <rte_tailq.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
78 #include <cmdline_rdline.h>
79 #include <cmdline_parse.h>
80 #include <cmdline_parse_num.h>
81 #include <cmdline_parse_string.h>
82 #include <cmdline_parse_ipaddr.h>
83 #include <cmdline_parse_etheraddr.h>
84 #include <cmdline_socket.h>
86 #include <rte_pci_dev_ids.h>
90 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
93 uint8_t bypass_is_supported(portid_t port_id);
96 /* *** Help command with introduction. *** */
97 struct cmd_help_brief_result {
98 cmdline_fixed_string_t help;
101 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
103 __attribute__((unused)) void *data)
108 "Help is available for the following sections:\n\n"
109 " help control : Start and stop forwarding.\n"
110 " help display : Displaying port, stats and config "
112 " help config : Configuration information.\n"
113 " help ports : Configuring ports.\n"
114 " help flowdir : Flow Director filter help.\n"
115 " help registers : Reading and setting port registers.\n"
116 " help filters : Filters configuration help.\n"
117 " help all : All of the above sections.\n\n"
122 cmdline_parse_token_string_t cmd_help_brief_help =
123 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
125 cmdline_parse_inst_t cmd_help_brief = {
126 .f = cmd_help_brief_parsed,
128 .help_str = "show help",
130 (void *)&cmd_help_brief_help,
135 /* *** Help command with help sections. *** */
136 struct cmd_help_long_result {
137 cmdline_fixed_string_t help;
138 cmdline_fixed_string_t section;
141 static void cmd_help_long_parsed(void *parsed_result,
143 __attribute__((unused)) void *data)
146 struct cmd_help_long_result *res = parsed_result;
148 if (!strcmp(res->section, "all"))
151 if (show_all || !strcmp(res->section, "control")) {
156 "Control forwarding:\n"
157 "-------------------\n\n"
160 " Start packet forwarding with current configuration.\n\n"
163 " Start packet forwarding with current config"
164 " after sending one burst of packets.\n\n"
167 " Stop packet forwarding, and display accumulated"
171 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
175 if (show_all || !strcmp(res->section, "display")) {
183 "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
184 " Display information for port_id, or all.\n\n"
186 "show port rss-hash [key]\n"
187 " Display the RSS hash functions and RSS hash key"
190 "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
191 " Clear information for port_id, or all.\n\n"
193 "show config (rxtx|cores|fwd)\n"
194 " Display the given configuration.\n\n"
196 "read rxd (port_id) (queue_id) (rxd_id)\n"
197 " Display an RX descriptor of a port RX queue.\n\n"
199 "read txd (port_id) (queue_id) (txd_id)\n"
200 " Display a TX descriptor of a port TX queue.\n\n"
204 if (show_all || !strcmp(res->section, "config")) {
210 "Configuration changes only become active when"
211 " forwarding is started/restarted.\n\n"
214 " Reset forwarding to the default configuration.\n\n"
216 "set verbose (level)\n"
217 " Set the debug verbosity level X.\n\n"
220 " Set number of ports.\n\n"
223 " Set number of cores.\n\n"
225 "set coremask (mask)\n"
226 " Set the forwarding cores hexadecimal mask.\n\n"
228 "set portmask (mask)\n"
229 " Set the forwarding ports hexadecimal mask.\n\n"
232 " Set number of packets per burst.\n\n"
234 "set burst tx delay (microseconds) retry (num)\n"
235 " Set the transmit delay time and number of retries"
236 " in mac_retry forwarding mode.\n\n"
238 "set txpkts (x[,y]*)\n"
239 " Set the length of each segment of TXONLY"
242 "set corelist (x[,y]*)\n"
243 " Set the list of forwarding cores.\n\n"
245 "set portlist (x[,y]*)\n"
246 " Set the list of forwarding ports.\n\n"
248 "vlan set strip (on|off) (port_id)\n"
249 " Set the VLAN strip on a port.\n\n"
251 "vlan set stripq (on|off) (port_id,queue_id)\n"
252 " Set the VLAN strip for a queue on a port.\n\n"
254 "vlan set filter (on|off) (port_id)\n"
255 " Set the VLAN filter on a port.\n\n"
257 "vlan set qinq (on|off) (port_id)\n"
258 " Set the VLAN QinQ (extended queue in queue)"
261 "vlan set tpid (value) (port_id)\n"
262 " Set the outer VLAN TPID for Packet Filtering on"
265 "rx_vlan add (vlan_id|all) (port_id)\n"
266 " Add a vlan_id, or all identifiers, to the set"
267 " of VLAN identifiers filtered by port_id.\n\n"
269 "rx_vlan rm (vlan_id|all) (port_id)\n"
270 " Remove a vlan_id, or all identifiers, from the set"
271 " of VLAN identifiers filtered by port_id.\n\n"
273 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
274 " Add a vlan_id, to the set of VLAN identifiers"
275 "filtered for VF(s) from port_id.\n\n"
277 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
278 " Remove a vlan_id, to the set of VLAN identifiers"
279 "filtered for VF(s) from port_id.\n\n"
281 "rx_vlan set tpid (value) (port_id)\n"
282 " Set the outer VLAN TPID for Packet Filtering on"
285 "tx_vlan set vlan_id (port_id)\n"
286 " Set hardware insertion of VLAN ID in packets sent"
289 "tx_vlan set pvid port_id vlan_id (on|off)\n"
290 " Set port based TX VLAN insertion.\n\n"
292 "tx_vlan reset (port_id)\n"
293 " Disable hardware insertion of a VLAN header in"
294 " packets sent on a port.\n\n"
296 "tx_checksum set mask (port_id)\n"
297 " Enable hardware insertion of checksum offload with"
298 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
299 " bit 0 - insert ip checksum offload if set\n"
300 " bit 1 - insert udp checksum offload if set\n"
301 " bit 2 - insert tcp checksum offload if set\n"
302 " bit 3 - insert sctp checksum offload if set\n"
303 " Please check the NIC datasheet for HW limits.\n\n"
306 " Set packet forwarding mode.\n\n"
308 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
309 " Add a MAC address on port_id.\n\n"
311 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
312 " Remove a MAC address from port_id.\n\n"
314 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
315 " Add a MAC address for a VF on the port.\n\n"
317 "set port (port_id) uta (mac_address|all) (on|off)\n"
318 " Add/Remove a or all unicast hash filter(s)"
321 "set promisc (port_id|all) (on|off)\n"
322 " Set the promiscuous mode on port_id, or all.\n\n"
324 "set allmulti (port_id|all) (on|off)\n"
325 " Set the allmulti mode on port_id, or all.\n\n"
327 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
328 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
329 " (on|off) (port_id)\n"
330 " Set the link flow control parameter on a port.\n\n"
332 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
333 " (low_water) (pause_time) (priority) (port_id)\n"
334 " Set the priority flow control parameter on a"
337 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
338 " Set statistics mapping (qmapping 0..15) for RX/TX"
340 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
341 " on port 0 to mapping 5.\n\n"
343 "set port (port_id) vf (vf_id) rx|tx on|off \n"
344 " Enable/Disable a VF receive/tranmit from a port\n\n"
346 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
348 " AUPE:accepts untagged VLAN;"
349 "ROPE:accept unicast hash\n\n"
350 " BAM:accepts broadcast packets;"
351 "MPE:accepts all multicast packets\n\n"
352 " Enable/Disable a VF receive mode of a port\n\n"
354 "set port (port_id) queue (queue_id) rate (rate_num)\n"
355 " Set rate limit for a queue of a port\n\n"
357 "set port (port_id) vf (vf_id) rate (rate_num) "
358 "queue_mask (queue_mask_value)\n"
359 " Set rate limit for queues in VF of a port\n\n"
361 "set port (port_id) mirror-rule (rule_id)"
362 "(pool-mirror|vlan-mirror)\n"
363 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
364 " Set pool or vlan type mirror rule on a port.\n"
365 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
366 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
369 "set port (port_id) mirror-rule (rule_id)"
370 " (uplink-mirror|downlink-mirror) dst-pool"
371 " (pool_id) (on|off)\n"
372 " Set uplink or downlink type mirror rule on a port.\n"
373 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
374 " 0 on' enable mirror income traffic to pool 0.\n\n"
376 "reset port (port_id) mirror-rule (rule_id)\n"
377 " Reset a mirror rule.\n\n"
379 "set flush_rx (on|off)\n"
380 " Flush (default) or don't flush RX streams before"
381 " forwarding. Mainly used with PCAP drivers.\n\n"
383 #ifdef RTE_NIC_BYPASS
384 "set bypass mode (normal|bypass|isolate) (port_id)\n"
385 " Set the bypass mode for the lowest port on bypass enabled"
388 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
389 "mode (normal|bypass|isolate) (port_id)\n"
390 " Set the event required to initiate specified bypass mode for"
391 " the lowest port on a bypass enabled NIC where:\n"
392 " timeout = enable bypass after watchdog timeout.\n"
393 " os_on = enable bypass when OS/board is powered on.\n"
394 " os_off = enable bypass when OS/board is powered off.\n"
395 " power_on = enable bypass when power supply is turned on.\n"
396 " power_off = enable bypass when power supply is turned off."
399 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
400 " Set the bypass watchdog timeout to 'n' seconds"
401 " where 0 = instant.\n\n"
403 "show bypass config (port_id)\n"
404 " Show the bypass configuration for a bypass enabled NIC"
405 " using the lowest port on the NIC.\n\n"
408 , list_pkt_forwarding_modes()
413 if (show_all || !strcmp(res->section, "flowdir")) {
418 "Flow director mode:\n"
419 "-------------------\n\n"
421 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
422 " src (src_ip_address) (src_port)"
423 " dst (dst_ip_address) (dst_port)"
424 " flexbytes (flexbytes_values) vlan (vlan_id)"
425 " queue (queue_id)\n"
426 " Add a signature filter.\n\n"
428 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
429 " src (src_ip_address) (src_port)"
430 " dst (dst_ip_address) (dst_port)"
431 " flexbytes (flexbytes_values) vlan (vlan_id)"
432 " queue (queue_id)\n"
433 " Update a signature filter.\n\n"
435 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
436 " src (src_ip_address) (src_port)"
437 " dst (dst_ip_address) (dst_port)"
438 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
439 " Remove a signature filter.\n\n"
441 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
442 " src (src_ip_address) (src_port)"
443 " dst (dst_ip_address) (dst_port)"
444 " flexbytes (flexbytes_values) vlan (vlan_id)"
445 " queue (queue_id) soft (soft_id)\n"
446 " Add a perfect filter.\n\n"
448 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
449 " src (src_ip_address) (src_port)"
450 " dst (dst_ip_address) (dst_port)"
451 " flexbytes (flexbytes_values) vlan (vlan_id)"
452 " queue (queue_id)\n"
453 " Update a perfect filter.\n\n"
455 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
456 " src (src_ip_address) (src_port)"
457 " dst (dst_ip_address) (dst_port)"
458 " flexbytes (flexbytes_values) vlan (vlan_id)"
460 " Remove a perfect filter.\n\n"
462 "set_masks_filter (port_id) only_ip_flow (0|1)"
463 " src_mask (ip_src_mask) (src_port_mask)"
464 " dst_mask (ip_dst_mask) (dst_port_mask)"
465 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
466 " Set IPv4 filter masks.\n\n"
468 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
469 " src_mask (ip_src_mask) (src_port_mask)"
470 " dst_mask (ip_dst_mask) (dst_port_mask)"
471 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
472 " compare_dst (0|1)\n"
473 " Set IPv6 filter masks.\n\n"
477 if (show_all || !strcmp(res->section, "ports")) {
483 "----------------\n\n"
485 "port start (port_id|all)\n"
486 " Start all ports or port_id.\n\n"
488 "port stop (port_id|all)\n"
489 " Stop all ports or port_id.\n\n"
491 "port close (port_id|all)\n"
492 " Close all ports or port_id.\n\n"
494 "port config (port_id|all) speed (10|100|1000|10000|auto)"
495 " duplex (half|full|auto)\n"
496 " Set speed and duplex for all ports or port_id\n\n"
498 "port config all (rxq|txq|rxd|txd) (value)\n"
499 " Set number for rxq/txq/rxd/txd.\n\n"
501 "port config all max-pkt-len (value)\n"
502 " Set the max packet length.\n\n"
504 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
506 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
509 "port config all rss (ip|udp|none)\n"
510 " Set the RSS mode.\n\n"
512 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
513 " Set the RSS redirection table.\n\n"
515 "port config (port_id) dcb vt (on|off) (traffic_class)"
517 " Set the DCB mode.\n\n"
519 "port config all burst (value)\n"
520 " Set the number of packets per burst.\n\n"
522 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
524 " Set the ring prefetch/host/writeback threshold"
525 " for tx/rx queue.\n\n"
527 "port config all (txfreet|txrst|rxfreet) (value)\n"
528 " Set free threshold for rx/tx, or set"
529 " tx rs bit threshold.\n\n"
533 if (show_all || !strcmp(res->section, "registers")) {
541 "read reg (port_id) (address)\n"
542 " Display value of a port register.\n\n"
544 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
545 " Display a port register bit field.\n\n"
547 "read regbit (port_id) (address) (bit_x)\n"
548 " Display a single port register bit.\n\n"
550 "write reg (port_id) (address) (value)\n"
551 " Set value of a port register.\n\n"
553 "write regfield (port_id) (address) (bit_x) (bit_y)"
555 " Set bit field of a port register.\n\n"
557 "write regbit (port_id) (address) (bit_x) (value)\n"
558 " Set single bit value of a port register.\n\n"
561 if (show_all || !strcmp(res->section, "filters")) {
569 "add_ethertype_filter (port_id) ethertype (eth_value)"
570 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
571 " add an ethertype filter.\n\n"
573 "remove_ethertype_filter (port_id) index (idx)\n"
574 " remove an ethertype filter.\n\n"
576 "get_ethertype_filter (port_id) index (idx)\n"
577 " get info of a ethertype filter.\n\n"
579 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
580 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
581 " queue (queue_id) index (idx)\n"
582 " add a 2tuple filter.\n\n"
584 "remove_2tuple_filter (port_id) index (idx)\n"
585 " remove a 2tuple filter.\n\n"
587 "get_2tuple_filter (port_id) index (idx)\n"
588 " get info of a 2tuple filter.\n\n"
590 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
591 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
592 " mask (mask_value) flags (flags_value) priority (prio_value)"
593 " queue (queue_id) index (idx)\n"
594 " add a 5tuple filter.\n\n"
596 "remove_5tuple_filter (port_id) index (idx)\n"
597 " remove a 5tuple filter.\n\n"
599 "get_5tuple_filter (port_id) index (idx)\n"
600 " get info of a 5tuple filter.\n\n"
602 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
603 " add syn filter.\n\n"
605 "remove_syn_filter (port_id)"
606 " remove syn filter.\n\n"
608 "get_syn_filter (port_id) "
609 " get syn filter info.\n\n"
611 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
612 " priority (prio_value) queue (queue_id) index (idx)\n"
613 " add a flex filter.\n\n"
615 "remove_flex_filter (port_id) index (idx)\n"
616 " remove a flex filter.\n\n"
618 "get_flex_filter (port_id) index (idx)\n"
619 " get info of a flex filter.\n\n"
624 cmdline_parse_token_string_t cmd_help_long_help =
625 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
627 cmdline_parse_token_string_t cmd_help_long_section =
628 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
629 "all#control#display#config#flowdir#"
630 "ports#registers#filters");
632 cmdline_parse_inst_t cmd_help_long = {
633 .f = cmd_help_long_parsed,
635 .help_str = "show help",
637 (void *)&cmd_help_long_help,
638 (void *)&cmd_help_long_section,
644 /* *** start/stop/close all ports *** */
645 struct cmd_operate_port_result {
646 cmdline_fixed_string_t keyword;
647 cmdline_fixed_string_t name;
648 cmdline_fixed_string_t value;
651 static void cmd_operate_port_parsed(void *parsed_result,
652 __attribute__((unused)) struct cmdline *cl,
653 __attribute__((unused)) void *data)
655 struct cmd_operate_port_result *res = parsed_result;
657 if (!strcmp(res->name, "start"))
658 start_port(RTE_PORT_ALL);
659 else if (!strcmp(res->name, "stop"))
660 stop_port(RTE_PORT_ALL);
661 else if (!strcmp(res->name, "close"))
662 close_port(RTE_PORT_ALL);
664 printf("Unknown parameter\n");
667 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
668 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
670 cmdline_parse_token_string_t cmd_operate_port_all_port =
671 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
673 cmdline_parse_token_string_t cmd_operate_port_all_all =
674 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
676 cmdline_parse_inst_t cmd_operate_port = {
677 .f = cmd_operate_port_parsed,
679 .help_str = "port start|stop|close all: start/stop/close all ports",
681 (void *)&cmd_operate_port_all_cmd,
682 (void *)&cmd_operate_port_all_port,
683 (void *)&cmd_operate_port_all_all,
688 /* *** start/stop/close specific port *** */
689 struct cmd_operate_specific_port_result {
690 cmdline_fixed_string_t keyword;
691 cmdline_fixed_string_t name;
695 static void cmd_operate_specific_port_parsed(void *parsed_result,
696 __attribute__((unused)) struct cmdline *cl,
697 __attribute__((unused)) void *data)
699 struct cmd_operate_specific_port_result *res = parsed_result;
701 if (!strcmp(res->name, "start"))
702 start_port(res->value);
703 else if (!strcmp(res->name, "stop"))
704 stop_port(res->value);
705 else if (!strcmp(res->name, "close"))
706 close_port(res->value);
708 printf("Unknown parameter\n");
711 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
712 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
714 cmdline_parse_token_string_t cmd_operate_specific_port_port =
715 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
716 name, "start#stop#close");
717 cmdline_parse_token_num_t cmd_operate_specific_port_id =
718 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
721 cmdline_parse_inst_t cmd_operate_specific_port = {
722 .f = cmd_operate_specific_port_parsed,
724 .help_str = "port start|stop|close X: start/stop/close port X",
726 (void *)&cmd_operate_specific_port_cmd,
727 (void *)&cmd_operate_specific_port_port,
728 (void *)&cmd_operate_specific_port_id,
733 /* *** configure speed for all ports *** */
734 struct cmd_config_speed_all {
735 cmdline_fixed_string_t port;
736 cmdline_fixed_string_t keyword;
737 cmdline_fixed_string_t all;
738 cmdline_fixed_string_t item1;
739 cmdline_fixed_string_t item2;
740 cmdline_fixed_string_t value1;
741 cmdline_fixed_string_t value2;
745 cmd_config_speed_all_parsed(void *parsed_result,
746 __attribute__((unused)) struct cmdline *cl,
747 __attribute__((unused)) void *data)
749 struct cmd_config_speed_all *res = parsed_result;
750 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
751 uint16_t link_duplex = 0;
754 if (!all_ports_stopped()) {
755 printf("Please stop all ports first\n");
759 if (!strcmp(res->value1, "10"))
760 link_speed = ETH_LINK_SPEED_10;
761 else if (!strcmp(res->value1, "100"))
762 link_speed = ETH_LINK_SPEED_100;
763 else if (!strcmp(res->value1, "1000"))
764 link_speed = ETH_LINK_SPEED_1000;
765 else if (!strcmp(res->value1, "10000"))
766 link_speed = ETH_LINK_SPEED_10000;
767 else if (!strcmp(res->value1, "auto"))
768 link_speed = ETH_LINK_SPEED_AUTONEG;
770 printf("Unknown parameter\n");
774 if (!strcmp(res->value2, "half"))
775 link_duplex = ETH_LINK_HALF_DUPLEX;
776 else if (!strcmp(res->value2, "full"))
777 link_duplex = ETH_LINK_FULL_DUPLEX;
778 else if (!strcmp(res->value2, "auto"))
779 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
781 printf("Unknown parameter\n");
785 for (pid = 0; pid < nb_ports; pid++) {
786 ports[pid].dev_conf.link_speed = link_speed;
787 ports[pid].dev_conf.link_duplex = link_duplex;
790 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
793 cmdline_parse_token_string_t cmd_config_speed_all_port =
794 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
795 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
796 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
798 cmdline_parse_token_string_t cmd_config_speed_all_all =
799 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
800 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
801 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
802 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
803 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
804 "10#100#1000#10000#auto");
805 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
806 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
807 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
808 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
811 cmdline_parse_inst_t cmd_config_speed_all = {
812 .f = cmd_config_speed_all_parsed,
814 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
817 (void *)&cmd_config_speed_all_port,
818 (void *)&cmd_config_speed_all_keyword,
819 (void *)&cmd_config_speed_all_all,
820 (void *)&cmd_config_speed_all_item1,
821 (void *)&cmd_config_speed_all_value1,
822 (void *)&cmd_config_speed_all_item2,
823 (void *)&cmd_config_speed_all_value2,
828 /* *** configure speed for specific port *** */
829 struct cmd_config_speed_specific {
830 cmdline_fixed_string_t port;
831 cmdline_fixed_string_t keyword;
833 cmdline_fixed_string_t item1;
834 cmdline_fixed_string_t item2;
835 cmdline_fixed_string_t value1;
836 cmdline_fixed_string_t value2;
840 cmd_config_speed_specific_parsed(void *parsed_result,
841 __attribute__((unused)) struct cmdline *cl,
842 __attribute__((unused)) void *data)
844 struct cmd_config_speed_specific *res = parsed_result;
845 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
846 uint16_t link_duplex = 0;
848 if (!all_ports_stopped()) {
849 printf("Please stop all ports first\n");
853 if (res->id >= nb_ports) {
854 printf("Port id %d must be less than %d\n", res->id, nb_ports);
858 if (!strcmp(res->value1, "10"))
859 link_speed = ETH_LINK_SPEED_10;
860 else if (!strcmp(res->value1, "100"))
861 link_speed = ETH_LINK_SPEED_100;
862 else if (!strcmp(res->value1, "1000"))
863 link_speed = ETH_LINK_SPEED_1000;
864 else if (!strcmp(res->value1, "10000"))
865 link_speed = ETH_LINK_SPEED_10000;
866 else if (!strcmp(res->value1, "auto"))
867 link_speed = ETH_LINK_SPEED_AUTONEG;
869 printf("Unknown parameter\n");
873 if (!strcmp(res->value2, "half"))
874 link_duplex = ETH_LINK_HALF_DUPLEX;
875 else if (!strcmp(res->value2, "full"))
876 link_duplex = ETH_LINK_FULL_DUPLEX;
877 else if (!strcmp(res->value2, "auto"))
878 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
880 printf("Unknown parameter\n");
884 ports[res->id].dev_conf.link_speed = link_speed;
885 ports[res->id].dev_conf.link_duplex = link_duplex;
887 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
891 cmdline_parse_token_string_t cmd_config_speed_specific_port =
892 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
894 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
895 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
897 cmdline_parse_token_num_t cmd_config_speed_specific_id =
898 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
899 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
900 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
902 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
903 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
904 "10#100#1000#10000#auto");
905 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
906 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
908 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
909 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
912 cmdline_parse_inst_t cmd_config_speed_specific = {
913 .f = cmd_config_speed_specific_parsed,
915 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
918 (void *)&cmd_config_speed_specific_port,
919 (void *)&cmd_config_speed_specific_keyword,
920 (void *)&cmd_config_speed_specific_id,
921 (void *)&cmd_config_speed_specific_item1,
922 (void *)&cmd_config_speed_specific_value1,
923 (void *)&cmd_config_speed_specific_item2,
924 (void *)&cmd_config_speed_specific_value2,
929 /* *** configure txq/rxq, txd/rxd *** */
930 struct cmd_config_rx_tx {
931 cmdline_fixed_string_t port;
932 cmdline_fixed_string_t keyword;
933 cmdline_fixed_string_t all;
934 cmdline_fixed_string_t name;
939 cmd_config_rx_tx_parsed(void *parsed_result,
940 __attribute__((unused)) struct cmdline *cl,
941 __attribute__((unused)) void *data)
943 struct cmd_config_rx_tx *res = parsed_result;
945 if (!all_ports_stopped()) {
946 printf("Please stop all ports first\n");
950 if (!strcmp(res->name, "rxq")) {
951 if (res->value <= 0) {
952 printf("rxq %d invalid - must be > 0\n", res->value);
957 else if (!strcmp(res->name, "txq")) {
958 if (res->value <= 0) {
959 printf("txq %d invalid - must be > 0\n", res->value);
964 else if (!strcmp(res->name, "rxd")) {
965 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
966 printf("rxd %d invalid - must be > 0 && <= %d\n",
967 res->value, RTE_TEST_RX_DESC_MAX);
971 } else if (!strcmp(res->name, "txd")) {
972 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
973 printf("txd %d invalid - must be > 0 && <= %d\n",
974 res->value, RTE_TEST_TX_DESC_MAX);
979 printf("Unknown parameter\n");
985 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
988 cmdline_parse_token_string_t cmd_config_rx_tx_port =
989 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
990 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
991 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
992 cmdline_parse_token_string_t cmd_config_rx_tx_all =
993 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
994 cmdline_parse_token_string_t cmd_config_rx_tx_name =
995 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
997 cmdline_parse_token_num_t cmd_config_rx_tx_value =
998 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1000 cmdline_parse_inst_t cmd_config_rx_tx = {
1001 .f = cmd_config_rx_tx_parsed,
1003 .help_str = "port config all rxq|txq|rxd|txd value",
1005 (void *)&cmd_config_rx_tx_port,
1006 (void *)&cmd_config_rx_tx_keyword,
1007 (void *)&cmd_config_rx_tx_all,
1008 (void *)&cmd_config_rx_tx_name,
1009 (void *)&cmd_config_rx_tx_value,
1014 /* *** config max packet length *** */
1015 struct cmd_config_max_pkt_len_result {
1016 cmdline_fixed_string_t port;
1017 cmdline_fixed_string_t keyword;
1018 cmdline_fixed_string_t all;
1019 cmdline_fixed_string_t name;
1024 cmd_config_max_pkt_len_parsed(void *parsed_result,
1025 __attribute__((unused)) struct cmdline *cl,
1026 __attribute__((unused)) void *data)
1028 struct cmd_config_max_pkt_len_result *res = parsed_result;
1030 if (!all_ports_stopped()) {
1031 printf("Please stop all ports first\n");
1035 if (!strcmp(res->name, "max-pkt-len")) {
1036 if (res->value < ETHER_MIN_LEN) {
1037 printf("max-pkt-len can not be less than %d\n",
1041 if (res->value == rx_mode.max_rx_pkt_len)
1044 rx_mode.max_rx_pkt_len = res->value;
1045 if (res->value > ETHER_MAX_LEN)
1046 rx_mode.jumbo_frame = 1;
1048 rx_mode.jumbo_frame = 0;
1050 printf("Unknown parameter\n");
1056 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1059 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1060 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1062 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1063 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1065 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1066 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1068 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1069 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1071 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1072 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1075 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1076 .f = cmd_config_max_pkt_len_parsed,
1078 .help_str = "port config all max-pkt-len value",
1080 (void *)&cmd_config_max_pkt_len_port,
1081 (void *)&cmd_config_max_pkt_len_keyword,
1082 (void *)&cmd_config_max_pkt_len_all,
1083 (void *)&cmd_config_max_pkt_len_name,
1084 (void *)&cmd_config_max_pkt_len_value,
1089 /* *** configure rx mode *** */
1090 struct cmd_config_rx_mode_flag {
1091 cmdline_fixed_string_t port;
1092 cmdline_fixed_string_t keyword;
1093 cmdline_fixed_string_t all;
1094 cmdline_fixed_string_t name;
1095 cmdline_fixed_string_t value;
1099 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1100 __attribute__((unused)) struct cmdline *cl,
1101 __attribute__((unused)) void *data)
1103 struct cmd_config_rx_mode_flag *res = parsed_result;
1105 if (!all_ports_stopped()) {
1106 printf("Please stop all ports first\n");
1110 if (!strcmp(res->name, "crc-strip")) {
1111 if (!strcmp(res->value, "on"))
1112 rx_mode.hw_strip_crc = 1;
1113 else if (!strcmp(res->value, "off"))
1114 rx_mode.hw_strip_crc = 0;
1116 printf("Unknown parameter\n");
1119 } else if (!strcmp(res->name, "rx-cksum")) {
1120 if (!strcmp(res->value, "on"))
1121 rx_mode.hw_ip_checksum = 1;
1122 else if (!strcmp(res->value, "off"))
1123 rx_mode.hw_ip_checksum = 0;
1125 printf("Unknown parameter\n");
1128 } else if (!strcmp(res->name, "hw-vlan")) {
1129 if (!strcmp(res->value, "on")) {
1130 rx_mode.hw_vlan_filter = 1;
1131 rx_mode.hw_vlan_strip = 1;
1133 else if (!strcmp(res->value, "off")) {
1134 rx_mode.hw_vlan_filter = 0;
1135 rx_mode.hw_vlan_strip = 0;
1138 printf("Unknown parameter\n");
1141 } else if (!strcmp(res->name, "drop-en")) {
1142 if (!strcmp(res->value, "on"))
1144 else if (!strcmp(res->value, "off"))
1147 printf("Unknown parameter\n");
1151 printf("Unknown parameter\n");
1157 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1160 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1161 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1162 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1163 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1165 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1166 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1167 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1168 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1169 "crc-strip#rx-cksum#hw-vlan");
1170 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1171 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1174 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1175 .f = cmd_config_rx_mode_flag_parsed,
1177 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1179 (void *)&cmd_config_rx_mode_flag_port,
1180 (void *)&cmd_config_rx_mode_flag_keyword,
1181 (void *)&cmd_config_rx_mode_flag_all,
1182 (void *)&cmd_config_rx_mode_flag_name,
1183 (void *)&cmd_config_rx_mode_flag_value,
1188 /* *** configure rss *** */
1189 struct cmd_config_rss {
1190 cmdline_fixed_string_t port;
1191 cmdline_fixed_string_t keyword;
1192 cmdline_fixed_string_t all;
1193 cmdline_fixed_string_t name;
1194 cmdline_fixed_string_t value;
1198 cmd_config_rss_parsed(void *parsed_result,
1199 __attribute__((unused)) struct cmdline *cl,
1200 __attribute__((unused)) void *data)
1202 struct cmd_config_rss *res = parsed_result;
1203 struct rte_eth_rss_conf rss_conf;
1206 if (!strcmp(res->value, "ip"))
1207 rss_conf.rss_hf = ETH_RSS_IP;
1208 else if (!strcmp(res->value, "udp"))
1209 rss_conf.rss_hf = ETH_RSS_UDP;
1210 else if (!strcmp(res->value, "none"))
1211 rss_conf.rss_hf = 0;
1213 printf("Unknown parameter\n");
1216 rss_conf.rss_key = NULL;
1217 for (i = 0; i < rte_eth_dev_count(); i++)
1218 rte_eth_dev_rss_hash_update(i, &rss_conf);
1221 cmdline_parse_token_string_t cmd_config_rss_port =
1222 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1223 cmdline_parse_token_string_t cmd_config_rss_keyword =
1224 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1225 cmdline_parse_token_string_t cmd_config_rss_all =
1226 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1227 cmdline_parse_token_string_t cmd_config_rss_name =
1228 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1229 cmdline_parse_token_string_t cmd_config_rss_value =
1230 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1232 cmdline_parse_inst_t cmd_config_rss = {
1233 .f = cmd_config_rss_parsed,
1235 .help_str = "port config all rss ip|udp|none",
1237 (void *)&cmd_config_rss_port,
1238 (void *)&cmd_config_rss_keyword,
1239 (void *)&cmd_config_rss_all,
1240 (void *)&cmd_config_rss_name,
1241 (void *)&cmd_config_rss_value,
1246 /* *** configure rss hash key *** */
1247 struct cmd_config_rss_hash_key {
1248 cmdline_fixed_string_t port;
1249 cmdline_fixed_string_t config;
1251 cmdline_fixed_string_t rss_hash_key;
1252 cmdline_fixed_string_t key;
1255 #define RSS_HASH_KEY_LENGTH 40
1257 hexa_digit_to_value(char hexa_digit)
1259 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1260 return (uint8_t) (hexa_digit - '0');
1261 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1262 return (uint8_t) ((hexa_digit - 'a') + 10);
1263 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1264 return (uint8_t) ((hexa_digit - 'A') + 10);
1265 /* Invalid hexa digit */
1270 parse_and_check_key_hexa_digit(char *key, int idx)
1274 hexa_v = hexa_digit_to_value(key[idx]);
1276 printf("invalid key: character %c at position %d is not a "
1277 "valid hexa digit\n", key[idx], idx);
1282 cmd_config_rss_hash_key_parsed(void *parsed_result,
1283 __attribute__((unused)) struct cmdline *cl,
1284 __attribute__((unused)) void *data)
1286 struct cmd_config_rss_hash_key *res = parsed_result;
1287 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1292 /* Check the length of the RSS hash key */
1293 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1294 printf("key length: %d invalid - key must be a string of %d"
1295 "hexa-decimal numbers\n", (int) strlen(res->key),
1296 RSS_HASH_KEY_LENGTH * 2);
1299 /* Translate RSS hash key into binary representation */
1300 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1301 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1304 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1307 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1309 port_rss_hash_key_update(res->port_id, hash_key);
1312 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1313 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1314 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1315 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1317 cmdline_parse_token_string_t cmd_config_rss_hash_key_port_id =
1318 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1319 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1320 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1321 rss_hash_key, "rss-hash-key");
1322 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1323 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1325 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1326 .f = cmd_config_rss_hash_key_parsed,
1328 .help_str = "port config X rss-hash-key 80 hexa digits",
1330 (void *)&cmd_config_rss_hash_key_port,
1331 (void *)&cmd_config_rss_hash_key_config,
1332 (void *)&cmd_config_rss_hash_key_port_id,
1333 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1334 (void *)&cmd_config_rss_hash_key_value,
1339 /* *** Configure RSS RETA *** */
1340 struct cmd_config_rss_reta {
1341 cmdline_fixed_string_t port;
1342 cmdline_fixed_string_t keyword;
1344 cmdline_fixed_string_t name;
1345 cmdline_fixed_string_t list_name;
1346 cmdline_fixed_string_t list_of_items;
1350 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1357 const char *p, *p0 = str;
1364 unsigned long int_fld[_NUM_FLD];
1365 char *str_fld[_NUM_FLD];
1367 while ((p = strchr(p0,'(')) != NULL) {
1369 if((p0 = strchr(p,')')) == NULL)
1373 if(size >= sizeof(s))
1376 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1377 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1379 for (i = 0; i < _NUM_FLD; i++) {
1381 int_fld[i] = strtoul(str_fld[i], &end, 0);
1382 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1386 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1387 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1389 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1390 printf("Invalid RETA hash index=%d",hash_index);
1394 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1395 reta_conf->mask_lo |= (1ULL << hash_index);
1397 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1399 reta_conf->reta[hash_index] = nb_queue;
1406 cmd_set_rss_reta_parsed(void *parsed_result,
1407 __attribute__((unused)) struct cmdline *cl,
1408 __attribute__((unused)) void *data)
1411 struct rte_eth_rss_reta reta_conf;
1412 struct cmd_config_rss_reta *res = parsed_result;
1414 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1415 if (!strcmp(res->list_name, "reta")) {
1416 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1417 printf("Invalid RSS Redirection Table config entered\n");
1420 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1422 printf("Bad redirection table parameter, return code = %d \n",ret);
1426 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1427 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1428 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1429 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1430 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1431 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1432 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1433 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1434 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1435 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1436 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1437 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1439 cmdline_parse_inst_t cmd_config_rss_reta = {
1440 .f = cmd_set_rss_reta_parsed,
1442 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1444 (void *)&cmd_config_rss_reta_port,
1445 (void *)&cmd_config_rss_reta_keyword,
1446 (void *)&cmd_config_rss_reta_port_id,
1447 (void *)&cmd_config_rss_reta_name,
1448 (void *)&cmd_config_rss_reta_list_name,
1449 (void *)&cmd_config_rss_reta_list_of_items,
1454 /* *** SHOW PORT RETA INFO *** */
1455 struct cmd_showport_reta {
1456 cmdline_fixed_string_t show;
1457 cmdline_fixed_string_t port;
1459 cmdline_fixed_string_t rss;
1460 cmdline_fixed_string_t reta;
1465 static void cmd_showport_reta_parsed(void *parsed_result,
1466 __attribute__((unused)) struct cmdline *cl,
1467 __attribute__((unused)) void *data)
1469 struct cmd_showport_reta *res = parsed_result;
1470 struct rte_eth_rss_reta reta_conf;
1472 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1473 printf("Invalid RSS Redirection Table config entered\n");
1477 reta_conf.mask_lo = res->mask_lo;
1478 reta_conf.mask_hi = res->mask_hi;
1480 port_rss_reta_info(res->port_id,&reta_conf);
1483 cmdline_parse_token_string_t cmd_showport_reta_show =
1484 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1485 cmdline_parse_token_string_t cmd_showport_reta_port =
1486 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1487 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1488 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1489 cmdline_parse_token_string_t cmd_showport_reta_rss =
1490 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1491 cmdline_parse_token_string_t cmd_showport_reta_reta =
1492 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1493 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1494 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1495 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1496 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1498 cmdline_parse_inst_t cmd_showport_reta = {
1499 .f = cmd_showport_reta_parsed,
1501 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1502 (mask_lo and mask_hi is UINT64)",
1504 (void *)&cmd_showport_reta_show,
1505 (void *)&cmd_showport_reta_port,
1506 (void *)&cmd_showport_reta_port_id,
1507 (void *)&cmd_showport_reta_rss,
1508 (void *)&cmd_showport_reta_reta,
1509 (void *)&cmd_showport_reta_mask_lo,
1510 (void *)&cmd_showport_reta_mask_hi,
1515 /* *** Show RSS hash configuration *** */
1516 struct cmd_showport_rss_hash {
1517 cmdline_fixed_string_t show;
1518 cmdline_fixed_string_t port;
1520 cmdline_fixed_string_t rss_hash;
1521 cmdline_fixed_string_t key; /* optional argument */
1524 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1525 __attribute__((unused)) struct cmdline *cl,
1528 struct cmd_showport_rss_hash *res = parsed_result;
1530 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1533 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1534 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1535 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1536 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1537 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1538 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1539 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1540 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1542 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1543 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1545 cmdline_parse_inst_t cmd_showport_rss_hash = {
1546 .f = cmd_showport_rss_hash_parsed,
1548 .help_str = "show port X rss-hash (X = port number)\n",
1550 (void *)&cmd_showport_rss_hash_show,
1551 (void *)&cmd_showport_rss_hash_port,
1552 (void *)&cmd_showport_rss_hash_port_id,
1553 (void *)&cmd_showport_rss_hash_rss_hash,
1558 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1559 .f = cmd_showport_rss_hash_parsed,
1561 .help_str = "show port X rss-hash key (X = port number)\n",
1563 (void *)&cmd_showport_rss_hash_show,
1564 (void *)&cmd_showport_rss_hash_port,
1565 (void *)&cmd_showport_rss_hash_port_id,
1566 (void *)&cmd_showport_rss_hash_rss_hash,
1567 (void *)&cmd_showport_rss_hash_rss_key,
1572 /* *** Configure DCB *** */
1573 struct cmd_config_dcb {
1574 cmdline_fixed_string_t port;
1575 cmdline_fixed_string_t config;
1577 cmdline_fixed_string_t dcb;
1578 cmdline_fixed_string_t vt;
1579 cmdline_fixed_string_t vt_en;
1581 cmdline_fixed_string_t pfc;
1582 cmdline_fixed_string_t pfc_en;
1586 cmd_config_dcb_parsed(void *parsed_result,
1587 __attribute__((unused)) struct cmdline *cl,
1588 __attribute__((unused)) void *data)
1590 struct cmd_config_dcb *res = parsed_result;
1591 struct dcb_config dcb_conf;
1592 portid_t port_id = res->port_id;
1593 struct rte_port *port;
1595 port = &ports[port_id];
1596 /** Check if the port is not started **/
1597 if (port->port_status != RTE_PORT_STOPPED) {
1598 printf("Please stop port %d first\n",port_id);
1602 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1603 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1604 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1608 /* DCB in VT mode */
1609 if (!strncmp(res->vt_en, "on",2))
1610 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1612 dcb_conf.dcb_mode = DCB_ENABLED;
1614 if (!strncmp(res->pfc_en, "on",2)) {
1615 dcb_conf.pfc_en = 1;
1618 dcb_conf.pfc_en = 0;
1620 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1621 printf("Cannot initialize network ports\n");
1625 cmd_reconfig_device_queue(port_id, 1, 1);
1628 cmdline_parse_token_string_t cmd_config_dcb_port =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1630 cmdline_parse_token_string_t cmd_config_dcb_config =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1632 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1633 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1634 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1635 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1636 cmdline_parse_token_string_t cmd_config_dcb_vt =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1638 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1639 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1640 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1641 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1642 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1644 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1645 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1647 cmdline_parse_inst_t cmd_config_dcb = {
1648 .f = cmd_config_dcb_parsed,
1650 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1652 (void *)&cmd_config_dcb_port,
1653 (void *)&cmd_config_dcb_config,
1654 (void *)&cmd_config_dcb_port_id,
1655 (void *)&cmd_config_dcb_dcb,
1656 (void *)&cmd_config_dcb_vt,
1657 (void *)&cmd_config_dcb_vt_en,
1658 (void *)&cmd_config_dcb_num_tcs,
1659 (void *)&cmd_config_dcb_pfc,
1660 (void *)&cmd_config_dcb_pfc_en,
1665 /* *** configure number of packets per burst *** */
1666 struct cmd_config_burst {
1667 cmdline_fixed_string_t port;
1668 cmdline_fixed_string_t keyword;
1669 cmdline_fixed_string_t all;
1670 cmdline_fixed_string_t name;
1675 cmd_config_burst_parsed(void *parsed_result,
1676 __attribute__((unused)) struct cmdline *cl,
1677 __attribute__((unused)) void *data)
1679 struct cmd_config_burst *res = parsed_result;
1681 if (!all_ports_stopped()) {
1682 printf("Please stop all ports first\n");
1686 if (!strcmp(res->name, "burst")) {
1687 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1688 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1691 nb_pkt_per_burst = res->value;
1693 printf("Unknown parameter\n");
1699 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1702 cmdline_parse_token_string_t cmd_config_burst_port =
1703 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1704 cmdline_parse_token_string_t cmd_config_burst_keyword =
1705 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1706 cmdline_parse_token_string_t cmd_config_burst_all =
1707 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1708 cmdline_parse_token_string_t cmd_config_burst_name =
1709 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1710 cmdline_parse_token_num_t cmd_config_burst_value =
1711 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1713 cmdline_parse_inst_t cmd_config_burst = {
1714 .f = cmd_config_burst_parsed,
1716 .help_str = "port config all burst value",
1718 (void *)&cmd_config_burst_port,
1719 (void *)&cmd_config_burst_keyword,
1720 (void *)&cmd_config_burst_all,
1721 (void *)&cmd_config_burst_name,
1722 (void *)&cmd_config_burst_value,
1727 /* *** configure rx/tx queues *** */
1728 struct cmd_config_thresh {
1729 cmdline_fixed_string_t port;
1730 cmdline_fixed_string_t keyword;
1731 cmdline_fixed_string_t all;
1732 cmdline_fixed_string_t name;
1737 cmd_config_thresh_parsed(void *parsed_result,
1738 __attribute__((unused)) struct cmdline *cl,
1739 __attribute__((unused)) void *data)
1741 struct cmd_config_thresh *res = parsed_result;
1743 if (!all_ports_stopped()) {
1744 printf("Please stop all ports first\n");
1748 if (!strcmp(res->name, "txpt"))
1749 tx_thresh.pthresh = res->value;
1750 else if(!strcmp(res->name, "txht"))
1751 tx_thresh.hthresh = res->value;
1752 else if(!strcmp(res->name, "txwt"))
1753 tx_thresh.wthresh = res->value;
1754 else if(!strcmp(res->name, "rxpt"))
1755 rx_thresh.pthresh = res->value;
1756 else if(!strcmp(res->name, "rxht"))
1757 rx_thresh.hthresh = res->value;
1758 else if(!strcmp(res->name, "rxwt"))
1759 rx_thresh.wthresh = res->value;
1761 printf("Unknown parameter\n");
1767 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1770 cmdline_parse_token_string_t cmd_config_thresh_port =
1771 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1772 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1773 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1774 cmdline_parse_token_string_t cmd_config_thresh_all =
1775 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1776 cmdline_parse_token_string_t cmd_config_thresh_name =
1777 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1778 "txpt#txht#txwt#rxpt#rxht#rxwt");
1779 cmdline_parse_token_num_t cmd_config_thresh_value =
1780 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1782 cmdline_parse_inst_t cmd_config_thresh = {
1783 .f = cmd_config_thresh_parsed,
1785 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1787 (void *)&cmd_config_thresh_port,
1788 (void *)&cmd_config_thresh_keyword,
1789 (void *)&cmd_config_thresh_all,
1790 (void *)&cmd_config_thresh_name,
1791 (void *)&cmd_config_thresh_value,
1796 /* *** configure free/rs threshold *** */
1797 struct cmd_config_threshold {
1798 cmdline_fixed_string_t port;
1799 cmdline_fixed_string_t keyword;
1800 cmdline_fixed_string_t all;
1801 cmdline_fixed_string_t name;
1806 cmd_config_threshold_parsed(void *parsed_result,
1807 __attribute__((unused)) struct cmdline *cl,
1808 __attribute__((unused)) void *data)
1810 struct cmd_config_threshold *res = parsed_result;
1812 if (!all_ports_stopped()) {
1813 printf("Please stop all ports first\n");
1817 if (!strcmp(res->name, "txfreet"))
1818 tx_free_thresh = res->value;
1819 else if (!strcmp(res->name, "txrst"))
1820 tx_rs_thresh = res->value;
1821 else if (!strcmp(res->name, "rxfreet"))
1822 rx_free_thresh = res->value;
1824 printf("Unknown parameter\n");
1830 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1833 cmdline_parse_token_string_t cmd_config_threshold_port =
1834 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1835 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1836 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1838 cmdline_parse_token_string_t cmd_config_threshold_all =
1839 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1840 cmdline_parse_token_string_t cmd_config_threshold_name =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1842 "txfreet#txrst#rxfreet");
1843 cmdline_parse_token_num_t cmd_config_threshold_value =
1844 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1846 cmdline_parse_inst_t cmd_config_threshold = {
1847 .f = cmd_config_threshold_parsed,
1849 .help_str = "port config all txfreet|txrst|rxfreet value",
1851 (void *)&cmd_config_threshold_port,
1852 (void *)&cmd_config_threshold_keyword,
1853 (void *)&cmd_config_threshold_all,
1854 (void *)&cmd_config_threshold_name,
1855 (void *)&cmd_config_threshold_value,
1861 struct cmd_stop_result {
1862 cmdline_fixed_string_t stop;
1865 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1866 __attribute__((unused)) struct cmdline *cl,
1867 __attribute__((unused)) void *data)
1869 stop_packet_forwarding();
1872 cmdline_parse_token_string_t cmd_stop_stop =
1873 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1875 cmdline_parse_inst_t cmd_stop = {
1876 .f = cmd_stop_parsed,
1878 .help_str = "stop - stop packet forwarding",
1880 (void *)&cmd_stop_stop,
1885 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1888 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1889 unsigned int *parsed_items, int check_unique_values)
1891 unsigned int nb_item;
1899 * First parse all items in the list and store their value.
1904 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1906 if ((c >= '0') && (c <= '9')) {
1907 value = (unsigned int) (value * 10 + (c - '0'));
1912 printf("character %c is not a decimal digit\n", c);
1916 printf("No valid value before comma\n");
1919 if (nb_item < max_items) {
1920 parsed_items[nb_item] = value;
1926 if (nb_item >= max_items) {
1927 printf("Number of %s = %u > %u (maximum items)\n",
1928 item_name, nb_item + 1, max_items);
1931 parsed_items[nb_item++] = value;
1932 if (! check_unique_values)
1936 * Then, check that all values in the list are differents.
1937 * No optimization here...
1939 for (i = 0; i < nb_item; i++) {
1940 for (j = i + 1; j < nb_item; j++) {
1941 if (parsed_items[j] == parsed_items[i]) {
1942 printf("duplicated %s %u at index %u and %u\n",
1943 item_name, parsed_items[i], i, j);
1951 struct cmd_set_list_result {
1952 cmdline_fixed_string_t cmd_keyword;
1953 cmdline_fixed_string_t list_name;
1954 cmdline_fixed_string_t list_of_items;
1957 static void cmd_set_list_parsed(void *parsed_result,
1958 __attribute__((unused)) struct cmdline *cl,
1959 __attribute__((unused)) void *data)
1961 struct cmd_set_list_result *res;
1963 unsigned int lcorelist[RTE_MAX_LCORE];
1964 unsigned int portlist[RTE_MAX_ETHPORTS];
1966 unsigned int nb_item;
1968 res = parsed_result;
1969 if (!strcmp(res->list_name, "corelist")) {
1970 nb_item = parse_item_list(res->list_of_items, "core",
1972 parsed_items.lcorelist, 1);
1974 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1977 if (!strcmp(res->list_name, "portlist")) {
1978 nb_item = parse_item_list(res->list_of_items, "port",
1980 parsed_items.portlist, 1);
1982 set_fwd_ports_list(parsed_items.portlist, nb_item);
1986 cmdline_parse_token_string_t cmd_set_list_keyword =
1987 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1989 cmdline_parse_token_string_t cmd_set_list_name =
1990 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1991 "corelist#portlist");
1992 cmdline_parse_token_string_t cmd_set_list_of_items =
1993 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1996 cmdline_parse_inst_t cmd_set_fwd_list = {
1997 .f = cmd_set_list_parsed,
1999 .help_str = "set corelist|portlist x[,y]*",
2001 (void *)&cmd_set_list_keyword,
2002 (void *)&cmd_set_list_name,
2003 (void *)&cmd_set_list_of_items,
2008 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2010 struct cmd_setmask_result {
2011 cmdline_fixed_string_t set;
2012 cmdline_fixed_string_t mask;
2016 static void cmd_set_mask_parsed(void *parsed_result,
2017 __attribute__((unused)) struct cmdline *cl,
2018 __attribute__((unused)) void *data)
2020 struct cmd_setmask_result *res = parsed_result;
2022 if (!strcmp(res->mask, "coremask"))
2023 set_fwd_lcores_mask(res->hexavalue);
2024 else if (!strcmp(res->mask, "portmask"))
2025 set_fwd_ports_mask(res->hexavalue);
2028 cmdline_parse_token_string_t cmd_setmask_set =
2029 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2030 cmdline_parse_token_string_t cmd_setmask_mask =
2031 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2032 "coremask#portmask");
2033 cmdline_parse_token_num_t cmd_setmask_value =
2034 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2036 cmdline_parse_inst_t cmd_set_fwd_mask = {
2037 .f = cmd_set_mask_parsed,
2039 .help_str = "set coremask|portmask hexadecimal value",
2041 (void *)&cmd_setmask_set,
2042 (void *)&cmd_setmask_mask,
2043 (void *)&cmd_setmask_value,
2049 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2051 struct cmd_set_result {
2052 cmdline_fixed_string_t set;
2053 cmdline_fixed_string_t what;
2057 static void cmd_set_parsed(void *parsed_result,
2058 __attribute__((unused)) struct cmdline *cl,
2059 __attribute__((unused)) void *data)
2061 struct cmd_set_result *res = parsed_result;
2062 if (!strcmp(res->what, "nbport"))
2063 set_fwd_ports_number(res->value);
2064 else if (!strcmp(res->what, "nbcore"))
2065 set_fwd_lcores_number(res->value);
2066 else if (!strcmp(res->what, "burst"))
2067 set_nb_pkt_per_burst(res->value);
2068 else if (!strcmp(res->what, "verbose"))
2069 set_verbose_level(res->value);
2072 cmdline_parse_token_string_t cmd_set_set =
2073 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2074 cmdline_parse_token_string_t cmd_set_what =
2075 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2076 "nbport#nbcore#burst#verbose");
2077 cmdline_parse_token_num_t cmd_set_value =
2078 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2080 cmdline_parse_inst_t cmd_set_numbers = {
2081 .f = cmd_set_parsed,
2083 .help_str = "set nbport|nbcore|burst|verbose value",
2085 (void *)&cmd_set_set,
2086 (void *)&cmd_set_what,
2087 (void *)&cmd_set_value,
2092 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2094 struct cmd_set_txpkts_result {
2095 cmdline_fixed_string_t cmd_keyword;
2096 cmdline_fixed_string_t txpkts;
2097 cmdline_fixed_string_t seg_lengths;
2101 cmd_set_txpkts_parsed(void *parsed_result,
2102 __attribute__((unused)) struct cmdline *cl,
2103 __attribute__((unused)) void *data)
2105 struct cmd_set_txpkts_result *res;
2106 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2107 unsigned int nb_segs;
2109 res = parsed_result;
2110 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2111 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2113 set_tx_pkt_segments(seg_lengths, nb_segs);
2116 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2117 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2118 cmd_keyword, "set");
2119 cmdline_parse_token_string_t cmd_set_txpkts_name =
2120 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2122 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2123 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2126 cmdline_parse_inst_t cmd_set_txpkts = {
2127 .f = cmd_set_txpkts_parsed,
2129 .help_str = "set txpkts x[,y]*",
2131 (void *)&cmd_set_txpkts_keyword,
2132 (void *)&cmd_set_txpkts_name,
2133 (void *)&cmd_set_txpkts_lengths,
2138 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2139 struct cmd_rx_vlan_filter_all_result {
2140 cmdline_fixed_string_t rx_vlan;
2141 cmdline_fixed_string_t what;
2142 cmdline_fixed_string_t all;
2147 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2148 __attribute__((unused)) struct cmdline *cl,
2149 __attribute__((unused)) void *data)
2151 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2153 if (!strcmp(res->what, "add"))
2154 rx_vlan_all_filter_set(res->port_id, 1);
2156 rx_vlan_all_filter_set(res->port_id, 0);
2159 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2160 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2161 rx_vlan, "rx_vlan");
2162 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2163 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2165 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2166 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2168 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2169 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2172 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2173 .f = cmd_rx_vlan_filter_all_parsed,
2175 .help_str = "add/remove all identifiers to/from the set of VLAN "
2176 "Identifiers filtered by a port",
2178 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2179 (void *)&cmd_rx_vlan_filter_all_what,
2180 (void *)&cmd_rx_vlan_filter_all_all,
2181 (void *)&cmd_rx_vlan_filter_all_portid,
2186 /* *** VLAN OFFLOAD SET ON A PORT *** */
2187 struct cmd_vlan_offload_result {
2188 cmdline_fixed_string_t vlan;
2189 cmdline_fixed_string_t set;
2190 cmdline_fixed_string_t what;
2191 cmdline_fixed_string_t on;
2192 cmdline_fixed_string_t port_id;
2196 cmd_vlan_offload_parsed(void *parsed_result,
2197 __attribute__((unused)) struct cmdline *cl,
2198 __attribute__((unused)) void *data)
2201 struct cmd_vlan_offload_result *res = parsed_result;
2204 portid_t port_id = 0;
2208 len = strnlen(str, STR_TOKEN_SIZE);
2210 /* Get port_id first */
2218 tmp = strtoul(str, NULL, 0);
2219 /* If port_id greater that what portid_t can represent, return */
2220 if(tmp >= RTE_MAX_ETHPORTS)
2222 port_id = (portid_t)tmp;
2224 if (!strcmp(res->on, "on"))
2229 if (!strcmp(res->what, "strip"))
2230 rx_vlan_strip_set(port_id, on);
2231 else if(!strcmp(res->what, "stripq")){
2232 uint16_t queue_id = 0;
2234 /* No queue_id, return */
2236 printf("must specify (port,queue_id)\n");
2239 tmp = strtoul(str + i + 1, NULL, 0);
2240 /* If queue_id greater that what 16-bits can represent, return */
2244 queue_id = (uint16_t)tmp;
2245 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2247 else if (!strcmp(res->what, "filter"))
2248 rx_vlan_filter_set(port_id, on);
2250 vlan_extend_set(port_id, on);
2255 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2256 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2258 cmdline_parse_token_string_t cmd_vlan_offload_set =
2259 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2261 cmdline_parse_token_string_t cmd_vlan_offload_what =
2262 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2263 what, "strip#filter#qinq#stripq");
2264 cmdline_parse_token_string_t cmd_vlan_offload_on =
2265 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2267 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2268 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2271 cmdline_parse_inst_t cmd_vlan_offload = {
2272 .f = cmd_vlan_offload_parsed,
2274 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2275 " qinq(extended) for both rx/tx sides ",
2277 (void *)&cmd_vlan_offload_vlan,
2278 (void *)&cmd_vlan_offload_set,
2279 (void *)&cmd_vlan_offload_what,
2280 (void *)&cmd_vlan_offload_on,
2281 (void *)&cmd_vlan_offload_portid,
2286 /* *** VLAN TPID SET ON A PORT *** */
2287 struct cmd_vlan_tpid_result {
2288 cmdline_fixed_string_t vlan;
2289 cmdline_fixed_string_t set;
2290 cmdline_fixed_string_t what;
2296 cmd_vlan_tpid_parsed(void *parsed_result,
2297 __attribute__((unused)) struct cmdline *cl,
2298 __attribute__((unused)) void *data)
2300 struct cmd_vlan_tpid_result *res = parsed_result;
2301 vlan_tpid_set(res->port_id, res->tp_id);
2305 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2306 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2308 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2309 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2311 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2312 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2314 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2315 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2317 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2318 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2321 cmdline_parse_inst_t cmd_vlan_tpid = {
2322 .f = cmd_vlan_tpid_parsed,
2324 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2326 (void *)&cmd_vlan_tpid_vlan,
2327 (void *)&cmd_vlan_tpid_set,
2328 (void *)&cmd_vlan_tpid_what,
2329 (void *)&cmd_vlan_tpid_tpid,
2330 (void *)&cmd_vlan_tpid_portid,
2335 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2336 struct cmd_rx_vlan_filter_result {
2337 cmdline_fixed_string_t rx_vlan;
2338 cmdline_fixed_string_t what;
2344 cmd_rx_vlan_filter_parsed(void *parsed_result,
2345 __attribute__((unused)) struct cmdline *cl,
2346 __attribute__((unused)) void *data)
2348 struct cmd_rx_vlan_filter_result *res = parsed_result;
2350 if (!strcmp(res->what, "add"))
2351 rx_vft_set(res->port_id, res->vlan_id, 1);
2353 rx_vft_set(res->port_id, res->vlan_id, 0);
2356 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2357 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2358 rx_vlan, "rx_vlan");
2359 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2360 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2362 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2363 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2365 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2366 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2369 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2370 .f = cmd_rx_vlan_filter_parsed,
2372 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2373 "Identifiers filtered by a port",
2375 (void *)&cmd_rx_vlan_filter_rx_vlan,
2376 (void *)&cmd_rx_vlan_filter_what,
2377 (void *)&cmd_rx_vlan_filter_vlanid,
2378 (void *)&cmd_rx_vlan_filter_portid,
2383 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2384 struct cmd_tx_vlan_set_result {
2385 cmdline_fixed_string_t tx_vlan;
2386 cmdline_fixed_string_t set;
2392 cmd_tx_vlan_set_parsed(void *parsed_result,
2393 __attribute__((unused)) struct cmdline *cl,
2394 __attribute__((unused)) void *data)
2396 struct cmd_tx_vlan_set_result *res = parsed_result;
2397 tx_vlan_set(res->port_id, res->vlan_id);
2400 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2401 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2402 tx_vlan, "tx_vlan");
2403 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2404 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2406 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2407 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2409 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2410 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2413 cmdline_parse_inst_t cmd_tx_vlan_set = {
2414 .f = cmd_tx_vlan_set_parsed,
2416 .help_str = "enable hardware insertion of a VLAN header with a given "
2417 "TAG Identifier in packets sent on a port",
2419 (void *)&cmd_tx_vlan_set_tx_vlan,
2420 (void *)&cmd_tx_vlan_set_set,
2421 (void *)&cmd_tx_vlan_set_vlanid,
2422 (void *)&cmd_tx_vlan_set_portid,
2427 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2428 struct cmd_tx_vlan_set_pvid_result {
2429 cmdline_fixed_string_t tx_vlan;
2430 cmdline_fixed_string_t set;
2431 cmdline_fixed_string_t pvid;
2434 cmdline_fixed_string_t mode;
2438 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2439 __attribute__((unused)) struct cmdline *cl,
2440 __attribute__((unused)) void *data)
2442 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2444 if (strcmp(res->mode, "on") == 0)
2445 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2447 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2450 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2451 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2452 tx_vlan, "tx_vlan");
2453 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2454 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2456 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2457 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2459 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2460 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2462 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2463 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2465 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2466 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2469 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2470 .f = cmd_tx_vlan_set_pvid_parsed,
2472 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2474 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2475 (void *)&cmd_tx_vlan_set_pvid_set,
2476 (void *)&cmd_tx_vlan_set_pvid_pvid,
2477 (void *)&cmd_tx_vlan_set_pvid_port_id,
2478 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2479 (void *)&cmd_tx_vlan_set_pvid_mode,
2484 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2485 struct cmd_tx_vlan_reset_result {
2486 cmdline_fixed_string_t tx_vlan;
2487 cmdline_fixed_string_t reset;
2492 cmd_tx_vlan_reset_parsed(void *parsed_result,
2493 __attribute__((unused)) struct cmdline *cl,
2494 __attribute__((unused)) void *data)
2496 struct cmd_tx_vlan_reset_result *res = parsed_result;
2498 tx_vlan_reset(res->port_id);
2501 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2502 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2503 tx_vlan, "tx_vlan");
2504 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2505 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2507 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2508 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2511 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2512 .f = cmd_tx_vlan_reset_parsed,
2514 .help_str = "disable hardware insertion of a VLAN header in packets "
2517 (void *)&cmd_tx_vlan_reset_tx_vlan,
2518 (void *)&cmd_tx_vlan_reset_reset,
2519 (void *)&cmd_tx_vlan_reset_portid,
2525 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2526 struct cmd_tx_cksum_set_result {
2527 cmdline_fixed_string_t tx_cksum;
2528 cmdline_fixed_string_t set;
2534 cmd_tx_cksum_set_parsed(void *parsed_result,
2535 __attribute__((unused)) struct cmdline *cl,
2536 __attribute__((unused)) void *data)
2538 struct cmd_tx_cksum_set_result *res = parsed_result;
2540 tx_cksum_set(res->port_id, res->cksum_mask);
2543 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2544 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2545 tx_cksum, "tx_checksum");
2546 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2547 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2549 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2550 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2552 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2553 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2556 cmdline_parse_inst_t cmd_tx_cksum_set = {
2557 .f = cmd_tx_cksum_set_parsed,
2559 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2560 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2561 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2563 (void *)&cmd_tx_cksum_set_tx_cksum,
2564 (void *)&cmd_tx_cksum_set_set,
2565 (void *)&cmd_tx_cksum_set_cksum_mask,
2566 (void *)&cmd_tx_cksum_set_portid,
2571 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2572 struct cmd_set_flush_rx {
2573 cmdline_fixed_string_t set;
2574 cmdline_fixed_string_t flush_rx;
2575 cmdline_fixed_string_t mode;
2579 cmd_set_flush_rx_parsed(void *parsed_result,
2580 __attribute__((unused)) struct cmdline *cl,
2581 __attribute__((unused)) void *data)
2583 struct cmd_set_flush_rx *res = parsed_result;
2584 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2587 cmdline_parse_token_string_t cmd_setflushrx_set =
2588 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2590 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2591 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2592 flush_rx, "flush_rx");
2593 cmdline_parse_token_string_t cmd_setflushrx_mode =
2594 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2598 cmdline_parse_inst_t cmd_set_flush_rx = {
2599 .f = cmd_set_flush_rx_parsed,
2600 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2603 (void *)&cmd_setflushrx_set,
2604 (void *)&cmd_setflushrx_flush_rx,
2605 (void *)&cmd_setflushrx_mode,
2610 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2611 struct cmd_set_link_check {
2612 cmdline_fixed_string_t set;
2613 cmdline_fixed_string_t link_check;
2614 cmdline_fixed_string_t mode;
2618 cmd_set_link_check_parsed(void *parsed_result,
2619 __attribute__((unused)) struct cmdline *cl,
2620 __attribute__((unused)) void *data)
2622 struct cmd_set_link_check *res = parsed_result;
2623 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2626 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2627 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2629 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2630 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2631 link_check, "link_check");
2632 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2633 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2637 cmdline_parse_inst_t cmd_set_link_check = {
2638 .f = cmd_set_link_check_parsed,
2639 .help_str = "set link_check on|off: enable/disable link status check "
2640 "when starting/stopping a port",
2643 (void *)&cmd_setlinkcheck_set,
2644 (void *)&cmd_setlinkcheck_link_check,
2645 (void *)&cmd_setlinkcheck_mode,
2650 #ifdef RTE_NIC_BYPASS
2651 /* *** SET NIC BYPASS MODE *** */
2652 struct cmd_set_bypass_mode_result {
2653 cmdline_fixed_string_t set;
2654 cmdline_fixed_string_t bypass;
2655 cmdline_fixed_string_t mode;
2656 cmdline_fixed_string_t value;
2661 cmd_set_bypass_mode_parsed(void *parsed_result,
2662 __attribute__((unused)) struct cmdline *cl,
2663 __attribute__((unused)) void *data)
2665 struct cmd_set_bypass_mode_result *res = parsed_result;
2666 portid_t port_id = res->port_id;
2667 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2669 if (!bypass_is_supported(port_id))
2672 if (!strcmp(res->value, "bypass"))
2673 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2674 else if (!strcmp(res->value, "isolate"))
2675 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2677 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2679 /* Set the bypass mode for the relevant port. */
2680 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2681 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2685 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2686 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2688 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2689 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2691 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2692 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2694 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2695 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2696 value, "normal#bypass#isolate");
2697 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2698 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2701 cmdline_parse_inst_t cmd_set_bypass_mode = {
2702 .f = cmd_set_bypass_mode_parsed,
2703 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2704 "Set the NIC bypass mode for port_id",
2707 (void *)&cmd_setbypass_mode_set,
2708 (void *)&cmd_setbypass_mode_bypass,
2709 (void *)&cmd_setbypass_mode_mode,
2710 (void *)&cmd_setbypass_mode_value,
2711 (void *)&cmd_setbypass_mode_port,
2716 /* *** SET NIC BYPASS EVENT *** */
2717 struct cmd_set_bypass_event_result {
2718 cmdline_fixed_string_t set;
2719 cmdline_fixed_string_t bypass;
2720 cmdline_fixed_string_t event;
2721 cmdline_fixed_string_t event_value;
2722 cmdline_fixed_string_t mode;
2723 cmdline_fixed_string_t mode_value;
2728 cmd_set_bypass_event_parsed(void *parsed_result,
2729 __attribute__((unused)) struct cmdline *cl,
2730 __attribute__((unused)) void *data)
2733 struct cmd_set_bypass_event_result *res = parsed_result;
2734 portid_t port_id = res->port_id;
2735 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2736 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2738 if (!bypass_is_supported(port_id))
2741 if (!strcmp(res->event_value, "timeout"))
2742 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2743 else if (!strcmp(res->event_value, "os_on"))
2744 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2745 else if (!strcmp(res->event_value, "os_off"))
2746 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2747 else if (!strcmp(res->event_value, "power_on"))
2748 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2749 else if (!strcmp(res->event_value, "power_off"))
2750 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2752 bypass_event = RTE_BYPASS_EVENT_NONE;
2754 if (!strcmp(res->mode_value, "bypass"))
2755 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2756 else if (!strcmp(res->mode_value, "isolate"))
2757 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2759 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2761 /* Set the watchdog timeout. */
2762 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2765 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2766 (rc = rte_eth_dev_wd_timeout_store(port_id,
2767 bypass_timeout)) != 0) {
2768 printf("Failed to set timeout value %u "
2769 "for port %d, errto code: %d.\n",
2770 bypass_timeout, port_id, rc);
2774 /* Set the bypass event to transition to bypass mode. */
2775 if (0 != rte_eth_dev_bypass_event_store(port_id,
2776 bypass_event, bypass_mode)) {
2777 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2782 cmdline_parse_token_string_t cmd_setbypass_event_set =
2783 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2785 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2786 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2788 cmdline_parse_token_string_t cmd_setbypass_event_event =
2789 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2791 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2792 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2793 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2794 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2795 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2797 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2798 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2799 mode_value, "normal#bypass#isolate");
2800 cmdline_parse_token_num_t cmd_setbypass_event_port =
2801 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2804 cmdline_parse_inst_t cmd_set_bypass_event = {
2805 .f = cmd_set_bypass_event_parsed,
2806 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2807 "mode (normal|bypass|isolate) (port_id): "
2808 "Set the NIC bypass event mode for port_id",
2811 (void *)&cmd_setbypass_event_set,
2812 (void *)&cmd_setbypass_event_bypass,
2813 (void *)&cmd_setbypass_event_event,
2814 (void *)&cmd_setbypass_event_event_value,
2815 (void *)&cmd_setbypass_event_mode,
2816 (void *)&cmd_setbypass_event_mode_value,
2817 (void *)&cmd_setbypass_event_port,
2823 /* *** SET NIC BYPASS TIMEOUT *** */
2824 struct cmd_set_bypass_timeout_result {
2825 cmdline_fixed_string_t set;
2826 cmdline_fixed_string_t bypass;
2827 cmdline_fixed_string_t timeout;
2828 cmdline_fixed_string_t value;
2832 cmd_set_bypass_timeout_parsed(void *parsed_result,
2833 __attribute__((unused)) struct cmdline *cl,
2834 __attribute__((unused)) void *data)
2836 struct cmd_set_bypass_timeout_result *res = parsed_result;
2838 if (!strcmp(res->value, "1.5"))
2839 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2840 else if (!strcmp(res->value, "2"))
2841 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2842 else if (!strcmp(res->value, "3"))
2843 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2844 else if (!strcmp(res->value, "4"))
2845 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2846 else if (!strcmp(res->value, "8"))
2847 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2848 else if (!strcmp(res->value, "16"))
2849 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2850 else if (!strcmp(res->value, "32"))
2851 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2853 bypass_timeout = RTE_BYPASS_TMT_OFF;
2856 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2857 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2859 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2860 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2862 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2863 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2864 timeout, "timeout");
2865 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2866 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2867 value, "0#1.5#2#3#4#8#16#32");
2869 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2870 .f = cmd_set_bypass_timeout_parsed,
2871 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2872 "Set the NIC bypass watchdog timeout",
2875 (void *)&cmd_setbypass_timeout_set,
2876 (void *)&cmd_setbypass_timeout_bypass,
2877 (void *)&cmd_setbypass_timeout_timeout,
2878 (void *)&cmd_setbypass_timeout_value,
2883 /* *** SHOW NIC BYPASS MODE *** */
2884 struct cmd_show_bypass_config_result {
2885 cmdline_fixed_string_t show;
2886 cmdline_fixed_string_t bypass;
2887 cmdline_fixed_string_t config;
2892 cmd_show_bypass_config_parsed(void *parsed_result,
2893 __attribute__((unused)) struct cmdline *cl,
2894 __attribute__((unused)) void *data)
2896 struct cmd_show_bypass_config_result *res = parsed_result;
2897 uint32_t event_mode;
2898 uint32_t bypass_mode;
2899 portid_t port_id = res->port_id;
2900 uint32_t timeout = bypass_timeout;
2903 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2904 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2905 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2906 {"UNKNOWN", "normal", "bypass", "isolate"};
2907 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2914 int num_events = (sizeof events) / (sizeof events[0]);
2916 if (!bypass_is_supported(port_id))
2919 /* Display the bypass mode.*/
2920 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2921 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2925 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2926 bypass_mode = RTE_BYPASS_MODE_NONE;
2928 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2931 /* Display the bypass timeout.*/
2932 if (!RTE_BYPASS_TMT_VALID(timeout))
2933 timeout = RTE_BYPASS_TMT_OFF;
2935 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2937 /* Display the bypass events and associated modes. */
2938 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2940 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2941 printf("\tFailed to get bypass mode for event = %s\n",
2944 if (!RTE_BYPASS_MODE_VALID(event_mode))
2945 event_mode = RTE_BYPASS_MODE_NONE;
2947 printf("\tbypass event: %-16s = %s\n", events[i],
2953 cmdline_parse_token_string_t cmd_showbypass_config_show =
2954 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2956 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2957 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2959 cmdline_parse_token_string_t cmd_showbypass_config_config =
2960 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2962 cmdline_parse_token_num_t cmd_showbypass_config_port =
2963 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2966 cmdline_parse_inst_t cmd_show_bypass_config = {
2967 .f = cmd_show_bypass_config_parsed,
2968 .help_str = "show bypass config (port_id): "
2969 "Show the NIC bypass config for port_id",
2972 (void *)&cmd_showbypass_config_show,
2973 (void *)&cmd_showbypass_config_bypass,
2974 (void *)&cmd_showbypass_config_config,
2975 (void *)&cmd_showbypass_config_port,
2981 /* *** SET FORWARDING MODE *** */
2982 struct cmd_set_fwd_mode_result {
2983 cmdline_fixed_string_t set;
2984 cmdline_fixed_string_t fwd;
2985 cmdline_fixed_string_t mode;
2988 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2989 __attribute__((unused)) struct cmdline *cl,
2990 __attribute__((unused)) void *data)
2992 struct cmd_set_fwd_mode_result *res = parsed_result;
2994 set_pkt_forwarding_mode(res->mode);
2997 cmdline_parse_token_string_t cmd_setfwd_set =
2998 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2999 cmdline_parse_token_string_t cmd_setfwd_fwd =
3000 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3001 cmdline_parse_token_string_t cmd_setfwd_mode =
3002 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3003 "" /* defined at init */);
3005 cmdline_parse_inst_t cmd_set_fwd_mode = {
3006 .f = cmd_set_fwd_mode_parsed,
3008 .help_str = NULL, /* defined at init */
3010 (void *)&cmd_setfwd_set,
3011 (void *)&cmd_setfwd_fwd,
3012 (void *)&cmd_setfwd_mode,
3017 static void cmd_set_fwd_mode_init(void)
3020 static char token[128];
3021 static char help[256];
3022 cmdline_parse_token_string_t *token_struct;
3024 modes = list_pkt_forwarding_modes();
3025 rte_snprintf(help, sizeof help, "set fwd %s - "
3026 "set packet forwarding mode", modes);
3027 cmd_set_fwd_mode.help_str = help;
3029 /* string token separator is # */
3030 for (c = token; *modes != '\0'; modes++)
3035 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3036 token_struct->string_data.str = token;
3039 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3040 struct cmd_set_burst_tx_retry_result {
3041 cmdline_fixed_string_t set;
3042 cmdline_fixed_string_t burst;
3043 cmdline_fixed_string_t tx;
3044 cmdline_fixed_string_t delay;
3046 cmdline_fixed_string_t retry;
3050 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3051 __attribute__((unused)) struct cmdline *cl,
3052 __attribute__((unused)) void *data)
3054 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3056 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3057 && !strcmp(res->tx, "tx")) {
3058 if (!strcmp(res->delay, "delay"))
3059 burst_tx_delay_time = res->time;
3060 if (!strcmp(res->retry, "retry"))
3061 burst_tx_retry_num = res->retry_num;
3066 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3067 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3068 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3069 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3071 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3072 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3073 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3074 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3075 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3076 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3077 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3078 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3079 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3080 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3082 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3083 .f = cmd_set_burst_tx_retry_parsed,
3084 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3086 (void *)&cmd_set_burst_tx_retry_set,
3087 (void *)&cmd_set_burst_tx_retry_burst,
3088 (void *)&cmd_set_burst_tx_retry_tx,
3089 (void *)&cmd_set_burst_tx_retry_delay,
3090 (void *)&cmd_set_burst_tx_retry_time,
3091 (void *)&cmd_set_burst_tx_retry_retry,
3092 (void *)&cmd_set_burst_tx_retry_retry_num,
3097 /* *** SET PROMISC MODE *** */
3098 struct cmd_set_promisc_mode_result {
3099 cmdline_fixed_string_t set;
3100 cmdline_fixed_string_t promisc;
3101 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3102 uint8_t port_num; /* valid if "allports" argument == 0 */
3103 cmdline_fixed_string_t mode;
3106 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3107 __attribute__((unused)) struct cmdline *cl,
3110 struct cmd_set_promisc_mode_result *res = parsed_result;
3114 if (!strcmp(res->mode, "on"))
3121 for (i = 0; i < nb_ports; i++) {
3123 rte_eth_promiscuous_enable(i);
3125 rte_eth_promiscuous_disable(i);
3130 rte_eth_promiscuous_enable(res->port_num);
3132 rte_eth_promiscuous_disable(res->port_num);
3136 cmdline_parse_token_string_t cmd_setpromisc_set =
3137 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3138 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3139 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3141 cmdline_parse_token_string_t cmd_setpromisc_portall =
3142 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3144 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3145 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3147 cmdline_parse_token_string_t cmd_setpromisc_mode =
3148 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3151 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3152 .f = cmd_set_promisc_mode_parsed,
3154 .help_str = "set promisc all on|off: set promisc mode for all ports",
3156 (void *)&cmd_setpromisc_set,
3157 (void *)&cmd_setpromisc_promisc,
3158 (void *)&cmd_setpromisc_portall,
3159 (void *)&cmd_setpromisc_mode,
3164 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3165 .f = cmd_set_promisc_mode_parsed,
3167 .help_str = "set promisc X on|off: set promisc mode on port X",
3169 (void *)&cmd_setpromisc_set,
3170 (void *)&cmd_setpromisc_promisc,
3171 (void *)&cmd_setpromisc_portnum,
3172 (void *)&cmd_setpromisc_mode,
3177 /* *** SET ALLMULTI MODE *** */
3178 struct cmd_set_allmulti_mode_result {
3179 cmdline_fixed_string_t set;
3180 cmdline_fixed_string_t allmulti;
3181 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3182 uint8_t port_num; /* valid if "allports" argument == 0 */
3183 cmdline_fixed_string_t mode;
3186 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3187 __attribute__((unused)) struct cmdline *cl,
3190 struct cmd_set_allmulti_mode_result *res = parsed_result;
3194 if (!strcmp(res->mode, "on"))
3201 for (i = 0; i < nb_ports; i++) {
3203 rte_eth_allmulticast_enable(i);
3205 rte_eth_allmulticast_disable(i);
3210 rte_eth_allmulticast_enable(res->port_num);
3212 rte_eth_allmulticast_disable(res->port_num);
3216 cmdline_parse_token_string_t cmd_setallmulti_set =
3217 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3218 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3219 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3221 cmdline_parse_token_string_t cmd_setallmulti_portall =
3222 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3224 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3225 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3227 cmdline_parse_token_string_t cmd_setallmulti_mode =
3228 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3231 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3232 .f = cmd_set_allmulti_mode_parsed,
3234 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3236 (void *)&cmd_setallmulti_set,
3237 (void *)&cmd_setallmulti_allmulti,
3238 (void *)&cmd_setallmulti_portall,
3239 (void *)&cmd_setallmulti_mode,
3244 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3245 .f = cmd_set_allmulti_mode_parsed,
3247 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3249 (void *)&cmd_setallmulti_set,
3250 (void *)&cmd_setallmulti_allmulti,
3251 (void *)&cmd_setallmulti_portnum,
3252 (void *)&cmd_setallmulti_mode,
3257 /* *** ADD/REMOVE A PKT FILTER *** */
3258 struct cmd_pkt_filter_result {
3259 cmdline_fixed_string_t pkt_filter;
3261 cmdline_fixed_string_t protocol;
3262 cmdline_fixed_string_t src;
3263 cmdline_ipaddr_t ip_src;
3265 cmdline_fixed_string_t dst;
3266 cmdline_ipaddr_t ip_dst;
3268 cmdline_fixed_string_t flexbytes;
3269 uint16_t flexbytes_value;
3270 cmdline_fixed_string_t vlan;
3272 cmdline_fixed_string_t queue;
3274 cmdline_fixed_string_t soft;
3279 cmd_pkt_filter_parsed(void *parsed_result,
3280 __attribute__((unused)) struct cmdline *cl,
3281 __attribute__((unused)) void *data)
3283 struct rte_fdir_filter fdir_filter;
3284 struct cmd_pkt_filter_result *res = parsed_result;
3286 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
3288 if (res->ip_src.family == AF_INET)
3289 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
3291 memcpy(&(fdir_filter.ip_src.ipv6_addr),
3292 &(res->ip_src.addr.ipv6),
3293 sizeof(struct in6_addr));
3295 if (res->ip_dst.family == AF_INET)
3296 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
3298 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
3299 &(res->ip_dst.addr.ipv6),
3300 sizeof(struct in6_addr));
3302 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
3303 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
3305 if (!strcmp(res->protocol, "udp"))
3306 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
3307 else if (!strcmp(res->protocol, "tcp"))
3308 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
3309 else if (!strcmp(res->protocol, "sctp"))
3310 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
3311 else /* default only IP */
3312 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
3314 if (res->ip_dst.family == AF_INET6)
3315 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
3317 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
3319 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
3320 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
3322 if (!strcmp(res->pkt_filter, "add_signature_filter"))
3323 fdir_add_signature_filter(res->port_id, res->queue_id,
3325 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3326 fdir_update_signature_filter(res->port_id, res->queue_id,
3328 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3329 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3330 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3331 fdir_add_perfect_filter(res->port_id, res->soft_id,
3333 (uint8_t) (res->queue_id < 0),
3335 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3336 fdir_update_perfect_filter(res->port_id, res->soft_id,
3338 (uint8_t) (res->queue_id < 0),
3340 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3341 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3347 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3348 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3350 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3351 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3352 protocol, "ip#tcp#udp#sctp");
3353 cmdline_parse_token_string_t cmd_pkt_filter_src =
3354 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3356 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3357 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3359 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3360 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3362 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3363 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3365 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3366 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3368 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3369 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3371 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
3372 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3373 flexbytes, "flexbytes");
3374 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
3375 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3376 flexbytes_value, UINT16);
3377 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
3378 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3380 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
3381 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3383 cmdline_parse_token_string_t cmd_pkt_filter_queue =
3384 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3386 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
3387 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3389 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3390 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3392 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3393 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3397 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3398 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3399 pkt_filter, "add_signature_filter");
3400 cmdline_parse_inst_t cmd_add_signature_filter = {
3401 .f = cmd_pkt_filter_parsed,
3403 .help_str = "add a signature filter",
3405 (void *)&cmd_pkt_filter_add_signature_filter,
3406 (void *)&cmd_pkt_filter_port_id,
3407 (void *)&cmd_pkt_filter_protocol,
3408 (void *)&cmd_pkt_filter_src,
3409 (void *)&cmd_pkt_filter_ip_src,
3410 (void *)&cmd_pkt_filter_port_src,
3411 (void *)&cmd_pkt_filter_dst,
3412 (void *)&cmd_pkt_filter_ip_dst,
3413 (void *)&cmd_pkt_filter_port_dst,
3414 (void *)&cmd_pkt_filter_flexbytes,
3415 (void *)&cmd_pkt_filter_flexbytes_value,
3416 (void *)&cmd_pkt_filter_vlan,
3417 (void *)&cmd_pkt_filter_vlan_id,
3418 (void *)&cmd_pkt_filter_queue,
3419 (void *)&cmd_pkt_filter_queue_id,
3425 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3426 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3427 pkt_filter, "upd_signature_filter");
3428 cmdline_parse_inst_t cmd_upd_signature_filter = {
3429 .f = cmd_pkt_filter_parsed,
3431 .help_str = "update a signature filter",
3433 (void *)&cmd_pkt_filter_upd_signature_filter,
3434 (void *)&cmd_pkt_filter_port_id,
3435 (void *)&cmd_pkt_filter_protocol,
3436 (void *)&cmd_pkt_filter_src,
3437 (void *)&cmd_pkt_filter_ip_src,
3438 (void *)&cmd_pkt_filter_port_src,
3439 (void *)&cmd_pkt_filter_dst,
3440 (void *)&cmd_pkt_filter_ip_dst,
3441 (void *)&cmd_pkt_filter_port_dst,
3442 (void *)&cmd_pkt_filter_flexbytes,
3443 (void *)&cmd_pkt_filter_flexbytes_value,
3444 (void *)&cmd_pkt_filter_vlan,
3445 (void *)&cmd_pkt_filter_vlan_id,
3446 (void *)&cmd_pkt_filter_queue,
3447 (void *)&cmd_pkt_filter_queue_id,
3453 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3454 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3455 pkt_filter, "rm_signature_filter");
3456 cmdline_parse_inst_t cmd_rm_signature_filter = {
3457 .f = cmd_pkt_filter_parsed,
3459 .help_str = "remove a signature filter",
3461 (void *)&cmd_pkt_filter_rm_signature_filter,
3462 (void *)&cmd_pkt_filter_port_id,
3463 (void *)&cmd_pkt_filter_protocol,
3464 (void *)&cmd_pkt_filter_src,
3465 (void *)&cmd_pkt_filter_ip_src,
3466 (void *)&cmd_pkt_filter_port_src,
3467 (void *)&cmd_pkt_filter_dst,
3468 (void *)&cmd_pkt_filter_ip_dst,
3469 (void *)&cmd_pkt_filter_port_dst,
3470 (void *)&cmd_pkt_filter_flexbytes,
3471 (void *)&cmd_pkt_filter_flexbytes_value,
3472 (void *)&cmd_pkt_filter_vlan,
3473 (void *)&cmd_pkt_filter_vlan_id,
3479 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3480 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3481 pkt_filter, "add_perfect_filter");
3482 cmdline_parse_inst_t cmd_add_perfect_filter = {
3483 .f = cmd_pkt_filter_parsed,
3485 .help_str = "add a perfect filter",
3487 (void *)&cmd_pkt_filter_add_perfect_filter,
3488 (void *)&cmd_pkt_filter_port_id,
3489 (void *)&cmd_pkt_filter_protocol,
3490 (void *)&cmd_pkt_filter_src,
3491 (void *)&cmd_pkt_filter_ip_src,
3492 (void *)&cmd_pkt_filter_port_src,
3493 (void *)&cmd_pkt_filter_dst,
3494 (void *)&cmd_pkt_filter_ip_dst,
3495 (void *)&cmd_pkt_filter_port_dst,
3496 (void *)&cmd_pkt_filter_flexbytes,
3497 (void *)&cmd_pkt_filter_flexbytes_value,
3498 (void *)&cmd_pkt_filter_vlan,
3499 (void *)&cmd_pkt_filter_vlan_id,
3500 (void *)&cmd_pkt_filter_queue,
3501 (void *)&cmd_pkt_filter_queue_id,
3502 (void *)&cmd_pkt_filter_soft,
3503 (void *)&cmd_pkt_filter_soft_id,
3509 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3510 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3511 pkt_filter, "upd_perfect_filter");
3512 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3513 .f = cmd_pkt_filter_parsed,
3515 .help_str = "update a perfect filter",
3517 (void *)&cmd_pkt_filter_upd_perfect_filter,
3518 (void *)&cmd_pkt_filter_port_id,
3519 (void *)&cmd_pkt_filter_protocol,
3520 (void *)&cmd_pkt_filter_src,
3521 (void *)&cmd_pkt_filter_ip_src,
3522 (void *)&cmd_pkt_filter_port_src,
3523 (void *)&cmd_pkt_filter_dst,
3524 (void *)&cmd_pkt_filter_ip_dst,
3525 (void *)&cmd_pkt_filter_port_dst,
3526 (void *)&cmd_pkt_filter_flexbytes,
3527 (void *)&cmd_pkt_filter_flexbytes_value,
3528 (void *)&cmd_pkt_filter_vlan,
3529 (void *)&cmd_pkt_filter_vlan_id,
3530 (void *)&cmd_pkt_filter_queue,
3531 (void *)&cmd_pkt_filter_queue_id,
3532 (void *)&cmd_pkt_filter_soft,
3533 (void *)&cmd_pkt_filter_soft_id,
3539 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3540 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3541 pkt_filter, "rm_perfect_filter");
3542 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3543 .f = cmd_pkt_filter_parsed,
3545 .help_str = "remove a perfect filter",
3547 (void *)&cmd_pkt_filter_rm_perfect_filter,
3548 (void *)&cmd_pkt_filter_port_id,
3549 (void *)&cmd_pkt_filter_protocol,
3550 (void *)&cmd_pkt_filter_src,
3551 (void *)&cmd_pkt_filter_ip_src,
3552 (void *)&cmd_pkt_filter_port_src,
3553 (void *)&cmd_pkt_filter_dst,
3554 (void *)&cmd_pkt_filter_ip_dst,
3555 (void *)&cmd_pkt_filter_port_dst,
3556 (void *)&cmd_pkt_filter_flexbytes,
3557 (void *)&cmd_pkt_filter_flexbytes_value,
3558 (void *)&cmd_pkt_filter_vlan,
3559 (void *)&cmd_pkt_filter_vlan_id,
3560 (void *)&cmd_pkt_filter_soft,
3561 (void *)&cmd_pkt_filter_soft_id,
3566 /* *** SETUP MASKS FILTER *** */
3567 struct cmd_pkt_filter_masks_result {
3568 cmdline_fixed_string_t filter_mask;
3570 cmdline_fixed_string_t src_mask;
3571 uint32_t ip_src_mask;
3572 uint16_t ipv6_src_mask;
3573 uint16_t port_src_mask;
3574 cmdline_fixed_string_t dst_mask;
3575 uint32_t ip_dst_mask;
3576 uint16_t ipv6_dst_mask;
3577 uint16_t port_dst_mask;
3578 cmdline_fixed_string_t flexbytes;
3579 uint8_t flexbytes_value;
3580 cmdline_fixed_string_t vlan_id;
3581 uint8_t vlan_id_value;
3582 cmdline_fixed_string_t vlan_prio;
3583 uint8_t vlan_prio_value;
3584 cmdline_fixed_string_t only_ip_flow;
3585 uint8_t only_ip_flow_value;
3586 cmdline_fixed_string_t comp_ipv6_dst;
3587 uint8_t comp_ipv6_dst_value;
3591 cmd_pkt_filter_masks_parsed(void *parsed_result,
3592 __attribute__((unused)) struct cmdline *cl,
3593 __attribute__((unused)) void *data)
3595 struct rte_fdir_masks fdir_masks;
3596 struct cmd_pkt_filter_masks_result *res = parsed_result;
3598 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3600 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3601 fdir_masks.vlan_id = res->vlan_id_value;
3602 fdir_masks.vlan_prio = res->vlan_prio_value;
3603 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3604 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3605 fdir_masks.src_port_mask = res->port_src_mask;
3606 fdir_masks.dst_port_mask = res->port_dst_mask;
3607 fdir_masks.flexbytes = res->flexbytes_value;
3609 fdir_set_masks(res->port_id, &fdir_masks);
3612 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3613 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3614 filter_mask, "set_masks_filter");
3615 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3616 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3618 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3619 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3620 only_ip_flow, "only_ip_flow");
3621 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3622 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3623 only_ip_flow_value, UINT8);
3624 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3625 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3626 src_mask, "src_mask");
3627 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3628 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3629 ip_src_mask, UINT32);
3630 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3631 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3632 port_src_mask, UINT16);
3633 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3634 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3635 dst_mask, "dst_mask");
3636 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3637 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3638 ip_dst_mask, UINT32);
3639 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3640 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3641 port_dst_mask, UINT16);
3642 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3643 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3644 flexbytes, "flexbytes");
3645 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3646 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3647 flexbytes_value, UINT8);
3648 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3649 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3650 vlan_id, "vlan_id");
3651 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3652 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3653 vlan_id_value, UINT8);
3654 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3655 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3656 vlan_prio, "vlan_prio");
3657 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3658 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3659 vlan_prio_value, UINT8);
3661 cmdline_parse_inst_t cmd_set_masks_filter = {
3662 .f = cmd_pkt_filter_masks_parsed,
3664 .help_str = "setup masks filter",
3666 (void *)&cmd_pkt_filter_masks_filter_mask,
3667 (void *)&cmd_pkt_filter_masks_port_id,
3668 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3669 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3670 (void *)&cmd_pkt_filter_masks_src_mask,
3671 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3672 (void *)&cmd_pkt_filter_masks_port_src_mask,
3673 (void *)&cmd_pkt_filter_masks_dst_mask,
3674 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3675 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3676 (void *)&cmd_pkt_filter_masks_flexbytes,
3677 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3678 (void *)&cmd_pkt_filter_masks_vlan_id,
3679 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3680 (void *)&cmd_pkt_filter_masks_vlan_prio,
3681 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3687 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3688 __attribute__((unused)) struct cmdline *cl,
3689 __attribute__((unused)) void *data)
3691 struct rte_fdir_masks fdir_masks;
3692 struct cmd_pkt_filter_masks_result *res = parsed_result;
3694 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3696 fdir_masks.set_ipv6_mask = 1;
3697 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3698 fdir_masks.vlan_id = res->vlan_id_value;
3699 fdir_masks.vlan_prio = res->vlan_prio_value;
3700 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3701 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3702 fdir_masks.src_port_mask = res->port_src_mask;
3703 fdir_masks.dst_port_mask = res->port_dst_mask;
3704 fdir_masks.flexbytes = res->flexbytes_value;
3705 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3707 fdir_set_masks(res->port_id, &fdir_masks);
3710 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3711 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3712 filter_mask, "set_ipv6_masks_filter");
3713 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3714 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3715 ipv6_src_mask, UINT16);
3716 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3717 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3718 ipv6_dst_mask, UINT16);
3720 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3721 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3722 comp_ipv6_dst, "compare_dst");
3723 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3724 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3725 comp_ipv6_dst_value, UINT8);
3727 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3728 .f = cmd_pkt_filter_masks_ipv6_parsed,
3730 .help_str = "setup ipv6 masks filter",
3732 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3733 (void *)&cmd_pkt_filter_masks_port_id,
3734 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3735 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3736 (void *)&cmd_pkt_filter_masks_src_mask,
3737 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3738 (void *)&cmd_pkt_filter_masks_port_src_mask,
3739 (void *)&cmd_pkt_filter_masks_dst_mask,
3740 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3741 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3742 (void *)&cmd_pkt_filter_masks_flexbytes,
3743 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3744 (void *)&cmd_pkt_filter_masks_vlan_id,
3745 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3746 (void *)&cmd_pkt_filter_masks_vlan_prio,
3747 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3748 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3749 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3754 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3755 struct cmd_link_flow_ctrl_set_result {
3756 cmdline_fixed_string_t set;
3757 cmdline_fixed_string_t flow_ctrl;
3758 cmdline_fixed_string_t rx;
3759 cmdline_fixed_string_t rx_lfc_mode;
3760 cmdline_fixed_string_t tx;
3761 cmdline_fixed_string_t tx_lfc_mode;
3762 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3763 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3764 uint32_t high_water;
3766 uint16_t pause_time;
3772 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3773 __attribute__((unused)) struct cmdline *cl,
3774 __attribute__((unused)) void *data)
3776 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3777 struct rte_eth_fc_conf fc_conf;
3778 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3782 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3783 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3784 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3785 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3787 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3788 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
3791 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3792 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3793 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3795 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3796 fc_conf.high_water = res->high_water;
3797 fc_conf.low_water = res->low_water;
3798 fc_conf.pause_time = res->pause_time;
3799 fc_conf.send_xon = res->send_xon;
3800 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3802 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3804 printf("bad flow contrl parameter, return code = %d \n", ret);
3807 cmdline_parse_token_string_t cmd_lfc_set_set =
3808 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3810 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3811 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3812 flow_ctrl, "flow_ctrl");
3813 cmdline_parse_token_string_t cmd_lfc_set_rx =
3814 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3816 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3817 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3818 rx_lfc_mode, "on#off");
3819 cmdline_parse_token_string_t cmd_lfc_set_tx =
3820 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3822 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3823 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3824 tx_lfc_mode, "on#off");
3825 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3826 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3827 high_water, UINT32);
3828 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3829 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3831 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3832 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3833 pause_time, UINT16);
3834 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3835 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3837 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3838 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3839 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3840 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3841 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3842 mac_ctrl_frame_fwd_mode, "on#off");
3843 cmdline_parse_token_num_t cmd_lfc_set_portid =
3844 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3847 cmdline_parse_inst_t cmd_link_flow_control_set = {
3848 .f = cmd_link_flow_ctrl_set_parsed,
3850 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3851 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3854 (void *)&cmd_lfc_set_set,
3855 (void *)&cmd_lfc_set_flow_ctrl,
3856 (void *)&cmd_lfc_set_rx,
3857 (void *)&cmd_lfc_set_rx_mode,
3858 (void *)&cmd_lfc_set_tx,
3859 (void *)&cmd_lfc_set_tx_mode,
3860 (void *)&cmd_lfc_set_high_water,
3861 (void *)&cmd_lfc_set_low_water,
3862 (void *)&cmd_lfc_set_pause_time,
3863 (void *)&cmd_lfc_set_send_xon,
3864 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3865 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3866 (void *)&cmd_lfc_set_portid,
3871 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3872 struct cmd_priority_flow_ctrl_set_result {
3873 cmdline_fixed_string_t set;
3874 cmdline_fixed_string_t pfc_ctrl;
3875 cmdline_fixed_string_t rx;
3876 cmdline_fixed_string_t rx_pfc_mode;
3877 cmdline_fixed_string_t tx;
3878 cmdline_fixed_string_t tx_pfc_mode;
3879 uint32_t high_water;
3881 uint16_t pause_time;
3887 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3888 __attribute__((unused)) struct cmdline *cl,
3889 __attribute__((unused)) void *data)
3891 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3892 struct rte_eth_pfc_conf pfc_conf;
3893 int rx_fc_enable, tx_fc_enable;
3897 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3898 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3899 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3900 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3902 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3903 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3906 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3907 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3908 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3909 pfc_conf.fc.high_water = res->high_water;
3910 pfc_conf.fc.low_water = res->low_water;
3911 pfc_conf.fc.pause_time = res->pause_time;
3912 pfc_conf.priority = res->priority;
3914 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3916 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3919 cmdline_parse_token_string_t cmd_pfc_set_set =
3920 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3922 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3923 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3924 pfc_ctrl, "pfc_ctrl");
3925 cmdline_parse_token_string_t cmd_pfc_set_rx =
3926 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3928 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3929 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3930 rx_pfc_mode, "on#off");
3931 cmdline_parse_token_string_t cmd_pfc_set_tx =
3932 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3934 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3935 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3936 tx_pfc_mode, "on#off");
3937 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3938 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3939 high_water, UINT32);
3940 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3941 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3943 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3944 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3945 pause_time, UINT16);
3946 cmdline_parse_token_num_t cmd_pfc_set_priority =
3947 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3949 cmdline_parse_token_num_t cmd_pfc_set_portid =
3950 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3953 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3954 .f = cmd_priority_flow_ctrl_set_parsed,
3956 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3957 tx on|off high_water low_water pause_time priority port_id",
3959 (void *)&cmd_pfc_set_set,
3960 (void *)&cmd_pfc_set_flow_ctrl,
3961 (void *)&cmd_pfc_set_rx,
3962 (void *)&cmd_pfc_set_rx_mode,
3963 (void *)&cmd_pfc_set_tx,
3964 (void *)&cmd_pfc_set_tx_mode,
3965 (void *)&cmd_pfc_set_high_water,
3966 (void *)&cmd_pfc_set_low_water,
3967 (void *)&cmd_pfc_set_pause_time,
3968 (void *)&cmd_pfc_set_priority,
3969 (void *)&cmd_pfc_set_portid,
3974 /* *** RESET CONFIGURATION *** */
3975 struct cmd_reset_result {
3976 cmdline_fixed_string_t reset;
3977 cmdline_fixed_string_t def;
3980 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3982 __attribute__((unused)) void *data)
3984 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3985 set_def_fwd_config();
3988 cmdline_parse_token_string_t cmd_reset_set =
3989 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3990 cmdline_parse_token_string_t cmd_reset_def =
3991 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3994 cmdline_parse_inst_t cmd_reset = {
3995 .f = cmd_reset_parsed,
3997 .help_str = "set default: reset default forwarding configuration",
3999 (void *)&cmd_reset_set,
4000 (void *)&cmd_reset_def,
4005 /* *** START FORWARDING *** */
4006 struct cmd_start_result {
4007 cmdline_fixed_string_t start;
4010 cmdline_parse_token_string_t cmd_start_start =
4011 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4013 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4014 __attribute__((unused)) struct cmdline *cl,
4015 __attribute__((unused)) void *data)
4017 start_packet_forwarding(0);
4020 cmdline_parse_inst_t cmd_start = {
4021 .f = cmd_start_parsed,
4023 .help_str = "start packet forwarding",
4025 (void *)&cmd_start_start,
4030 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4031 struct cmd_start_tx_first_result {
4032 cmdline_fixed_string_t start;
4033 cmdline_fixed_string_t tx_first;
4037 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4038 __attribute__((unused)) struct cmdline *cl,
4039 __attribute__((unused)) void *data)
4041 start_packet_forwarding(1);
4044 cmdline_parse_token_string_t cmd_start_tx_first_start =
4045 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4047 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4048 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4049 tx_first, "tx_first");
4051 cmdline_parse_inst_t cmd_start_tx_first = {
4052 .f = cmd_start_tx_first_parsed,
4054 .help_str = "start packet forwarding, after sending 1 burst of packets",
4056 (void *)&cmd_start_tx_first_start,
4057 (void *)&cmd_start_tx_first_tx_first,
4062 /* *** SET LINK UP *** */
4063 struct cmd_set_link_up_result {
4064 cmdline_fixed_string_t set;
4065 cmdline_fixed_string_t link_up;
4066 cmdline_fixed_string_t port;
4070 cmdline_parse_token_string_t cmd_set_link_up_set =
4071 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4072 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4073 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4075 cmdline_parse_token_string_t cmd_set_link_up_port =
4076 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4077 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4078 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4080 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4081 __attribute__((unused)) struct cmdline *cl,
4082 __attribute__((unused)) void *data)
4084 struct cmd_set_link_up_result *res = parsed_result;
4085 dev_set_link_up(res->port_id);
4088 cmdline_parse_inst_t cmd_set_link_up = {
4089 .f = cmd_set_link_up_parsed,
4091 .help_str = "set link-up port (port id)",
4093 (void *)&cmd_set_link_up_set,
4094 (void *)&cmd_set_link_up_link_up,
4095 (void *)&cmd_set_link_up_port,
4096 (void *)&cmd_set_link_up_port_id,
4101 /* *** SET LINK DOWN *** */
4102 struct cmd_set_link_down_result {
4103 cmdline_fixed_string_t set;
4104 cmdline_fixed_string_t link_down;
4105 cmdline_fixed_string_t port;
4109 cmdline_parse_token_string_t cmd_set_link_down_set =
4110 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4111 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4112 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4114 cmdline_parse_token_string_t cmd_set_link_down_port =
4115 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4116 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4117 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4119 static void cmd_set_link_down_parsed(
4120 __attribute__((unused)) void *parsed_result,
4121 __attribute__((unused)) struct cmdline *cl,
4122 __attribute__((unused)) void *data)
4124 struct cmd_set_link_down_result *res = parsed_result;
4125 dev_set_link_down(res->port_id);
4128 cmdline_parse_inst_t cmd_set_link_down = {
4129 .f = cmd_set_link_down_parsed,
4131 .help_str = "set link-down port (port id)",
4133 (void *)&cmd_set_link_down_set,
4134 (void *)&cmd_set_link_down_link_down,
4135 (void *)&cmd_set_link_down_port,
4136 (void *)&cmd_set_link_down_port_id,
4141 /* *** SHOW CFG *** */
4142 struct cmd_showcfg_result {
4143 cmdline_fixed_string_t show;
4144 cmdline_fixed_string_t cfg;
4145 cmdline_fixed_string_t what;
4148 static void cmd_showcfg_parsed(void *parsed_result,
4149 __attribute__((unused)) struct cmdline *cl,
4150 __attribute__((unused)) void *data)
4152 struct cmd_showcfg_result *res = parsed_result;
4153 if (!strcmp(res->what, "rxtx"))
4154 rxtx_config_display();
4155 else if (!strcmp(res->what, "cores"))
4156 fwd_lcores_config_display();
4157 else if (!strcmp(res->what, "fwd"))
4158 fwd_config_display();
4161 cmdline_parse_token_string_t cmd_showcfg_show =
4162 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4163 cmdline_parse_token_string_t cmd_showcfg_port =
4164 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4165 cmdline_parse_token_string_t cmd_showcfg_what =
4166 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4169 cmdline_parse_inst_t cmd_showcfg = {
4170 .f = cmd_showcfg_parsed,
4172 .help_str = "show config rxtx|cores|fwd",
4174 (void *)&cmd_showcfg_show,
4175 (void *)&cmd_showcfg_port,
4176 (void *)&cmd_showcfg_what,
4181 /* *** SHOW ALL PORT INFO *** */
4182 struct cmd_showportall_result {
4183 cmdline_fixed_string_t show;
4184 cmdline_fixed_string_t port;
4185 cmdline_fixed_string_t what;
4186 cmdline_fixed_string_t all;
4189 static void cmd_showportall_parsed(void *parsed_result,
4190 __attribute__((unused)) struct cmdline *cl,
4191 __attribute__((unused)) void *data)
4195 struct cmd_showportall_result *res = parsed_result;
4196 if (!strcmp(res->show, "clear")) {
4197 if (!strcmp(res->what, "stats"))
4198 for (i = 0; i < nb_ports; i++)
4200 } else if (!strcmp(res->what, "info"))
4201 for (i = 0; i < nb_ports; i++)
4202 port_infos_display(i);
4203 else if (!strcmp(res->what, "stats"))
4204 for (i = 0; i < nb_ports; i++)
4205 nic_stats_display(i);
4206 else if (!strcmp(res->what, "fdir"))
4207 for (i = 0; i < nb_ports; i++)
4209 else if (!strcmp(res->what, "stat_qmap"))
4210 for (i = 0; i < nb_ports; i++)
4211 nic_stats_mapping_display(i);
4214 cmdline_parse_token_string_t cmd_showportall_show =
4215 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
4217 cmdline_parse_token_string_t cmd_showportall_port =
4218 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
4219 cmdline_parse_token_string_t cmd_showportall_what =
4220 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
4221 "info#stats#fdir#stat_qmap");
4222 cmdline_parse_token_string_t cmd_showportall_all =
4223 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
4224 cmdline_parse_inst_t cmd_showportall = {
4225 .f = cmd_showportall_parsed,
4227 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
4229 (void *)&cmd_showportall_show,
4230 (void *)&cmd_showportall_port,
4231 (void *)&cmd_showportall_what,
4232 (void *)&cmd_showportall_all,
4237 /* *** SHOW PORT INFO *** */
4238 struct cmd_showport_result {
4239 cmdline_fixed_string_t show;
4240 cmdline_fixed_string_t port;
4241 cmdline_fixed_string_t what;
4245 static void cmd_showport_parsed(void *parsed_result,
4246 __attribute__((unused)) struct cmdline *cl,
4247 __attribute__((unused)) void *data)
4249 struct cmd_showport_result *res = parsed_result;
4250 if (!strcmp(res->show, "clear")) {
4251 if (!strcmp(res->what, "stats"))
4252 nic_stats_clear(res->portnum);
4253 } else if (!strcmp(res->what, "info"))
4254 port_infos_display(res->portnum);
4255 else if (!strcmp(res->what, "stats"))
4256 nic_stats_display(res->portnum);
4257 else if (!strcmp(res->what, "fdir"))
4258 fdir_get_infos(res->portnum);
4259 else if (!strcmp(res->what, "stat_qmap"))
4260 nic_stats_mapping_display(res->portnum);
4263 cmdline_parse_token_string_t cmd_showport_show =
4264 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
4266 cmdline_parse_token_string_t cmd_showport_port =
4267 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
4268 cmdline_parse_token_string_t cmd_showport_what =
4269 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
4270 "info#stats#fdir#stat_qmap");
4271 cmdline_parse_token_num_t cmd_showport_portnum =
4272 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
4274 cmdline_parse_inst_t cmd_showport = {
4275 .f = cmd_showport_parsed,
4277 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
4279 (void *)&cmd_showport_show,
4280 (void *)&cmd_showport_port,
4281 (void *)&cmd_showport_what,
4282 (void *)&cmd_showport_portnum,
4287 /* *** READ PORT REGISTER *** */
4288 struct cmd_read_reg_result {
4289 cmdline_fixed_string_t read;
4290 cmdline_fixed_string_t reg;
4296 cmd_read_reg_parsed(void *parsed_result,
4297 __attribute__((unused)) struct cmdline *cl,
4298 __attribute__((unused)) void *data)
4300 struct cmd_read_reg_result *res = parsed_result;
4301 port_reg_display(res->port_id, res->reg_off);
4304 cmdline_parse_token_string_t cmd_read_reg_read =
4305 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
4306 cmdline_parse_token_string_t cmd_read_reg_reg =
4307 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
4308 cmdline_parse_token_num_t cmd_read_reg_port_id =
4309 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
4310 cmdline_parse_token_num_t cmd_read_reg_reg_off =
4311 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
4313 cmdline_parse_inst_t cmd_read_reg = {
4314 .f = cmd_read_reg_parsed,
4316 .help_str = "read reg port_id reg_off",
4318 (void *)&cmd_read_reg_read,
4319 (void *)&cmd_read_reg_reg,
4320 (void *)&cmd_read_reg_port_id,
4321 (void *)&cmd_read_reg_reg_off,
4326 /* *** READ PORT REGISTER BIT FIELD *** */
4327 struct cmd_read_reg_bit_field_result {
4328 cmdline_fixed_string_t read;
4329 cmdline_fixed_string_t regfield;
4337 cmd_read_reg_bit_field_parsed(void *parsed_result,
4338 __attribute__((unused)) struct cmdline *cl,
4339 __attribute__((unused)) void *data)
4341 struct cmd_read_reg_bit_field_result *res = parsed_result;
4342 port_reg_bit_field_display(res->port_id, res->reg_off,
4343 res->bit1_pos, res->bit2_pos);
4346 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
4347 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
4349 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
4350 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
4351 regfield, "regfield");
4352 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
4353 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
4355 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
4356 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
4358 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
4359 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
4361 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
4362 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
4365 cmdline_parse_inst_t cmd_read_reg_bit_field = {
4366 .f = cmd_read_reg_bit_field_parsed,
4368 .help_str = "read regfield port_id reg_off bit_x bit_y "
4369 "(read register bit field between bit_x and bit_y included)",
4371 (void *)&cmd_read_reg_bit_field_read,
4372 (void *)&cmd_read_reg_bit_field_regfield,
4373 (void *)&cmd_read_reg_bit_field_port_id,
4374 (void *)&cmd_read_reg_bit_field_reg_off,
4375 (void *)&cmd_read_reg_bit_field_bit1_pos,
4376 (void *)&cmd_read_reg_bit_field_bit2_pos,
4381 /* *** READ PORT REGISTER BIT *** */
4382 struct cmd_read_reg_bit_result {
4383 cmdline_fixed_string_t read;
4384 cmdline_fixed_string_t regbit;
4391 cmd_read_reg_bit_parsed(void *parsed_result,
4392 __attribute__((unused)) struct cmdline *cl,
4393 __attribute__((unused)) void *data)
4395 struct cmd_read_reg_bit_result *res = parsed_result;
4396 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
4399 cmdline_parse_token_string_t cmd_read_reg_bit_read =
4400 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
4401 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
4402 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
4404 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4405 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4406 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4407 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4408 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4409 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4411 cmdline_parse_inst_t cmd_read_reg_bit = {
4412 .f = cmd_read_reg_bit_parsed,
4414 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4416 (void *)&cmd_read_reg_bit_read,
4417 (void *)&cmd_read_reg_bit_regbit,
4418 (void *)&cmd_read_reg_bit_port_id,
4419 (void *)&cmd_read_reg_bit_reg_off,
4420 (void *)&cmd_read_reg_bit_bit_pos,
4425 /* *** WRITE PORT REGISTER *** */
4426 struct cmd_write_reg_result {
4427 cmdline_fixed_string_t write;
4428 cmdline_fixed_string_t reg;
4435 cmd_write_reg_parsed(void *parsed_result,
4436 __attribute__((unused)) struct cmdline *cl,
4437 __attribute__((unused)) void *data)
4439 struct cmd_write_reg_result *res = parsed_result;
4440 port_reg_set(res->port_id, res->reg_off, res->value);
4443 cmdline_parse_token_string_t cmd_write_reg_write =
4444 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4445 cmdline_parse_token_string_t cmd_write_reg_reg =
4446 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4447 cmdline_parse_token_num_t cmd_write_reg_port_id =
4448 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4449 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4450 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4451 cmdline_parse_token_num_t cmd_write_reg_value =
4452 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4454 cmdline_parse_inst_t cmd_write_reg = {
4455 .f = cmd_write_reg_parsed,
4457 .help_str = "write reg port_id reg_off reg_value",
4459 (void *)&cmd_write_reg_write,
4460 (void *)&cmd_write_reg_reg,
4461 (void *)&cmd_write_reg_port_id,
4462 (void *)&cmd_write_reg_reg_off,
4463 (void *)&cmd_write_reg_value,
4468 /* *** WRITE PORT REGISTER BIT FIELD *** */
4469 struct cmd_write_reg_bit_field_result {
4470 cmdline_fixed_string_t write;
4471 cmdline_fixed_string_t regfield;
4480 cmd_write_reg_bit_field_parsed(void *parsed_result,
4481 __attribute__((unused)) struct cmdline *cl,
4482 __attribute__((unused)) void *data)
4484 struct cmd_write_reg_bit_field_result *res = parsed_result;
4485 port_reg_bit_field_set(res->port_id, res->reg_off,
4486 res->bit1_pos, res->bit2_pos, res->value);
4489 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4490 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4492 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4493 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4494 regfield, "regfield");
4495 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4496 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4498 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4499 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4501 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4502 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4504 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4505 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4507 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4508 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4511 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4512 .f = cmd_write_reg_bit_field_parsed,
4514 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4515 "(set register bit field between bit_x and bit_y included)",
4517 (void *)&cmd_write_reg_bit_field_write,
4518 (void *)&cmd_write_reg_bit_field_regfield,
4519 (void *)&cmd_write_reg_bit_field_port_id,
4520 (void *)&cmd_write_reg_bit_field_reg_off,
4521 (void *)&cmd_write_reg_bit_field_bit1_pos,
4522 (void *)&cmd_write_reg_bit_field_bit2_pos,
4523 (void *)&cmd_write_reg_bit_field_value,
4528 /* *** WRITE PORT REGISTER BIT *** */
4529 struct cmd_write_reg_bit_result {
4530 cmdline_fixed_string_t write;
4531 cmdline_fixed_string_t regbit;
4539 cmd_write_reg_bit_parsed(void *parsed_result,
4540 __attribute__((unused)) struct cmdline *cl,
4541 __attribute__((unused)) void *data)
4543 struct cmd_write_reg_bit_result *res = parsed_result;
4544 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4547 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4548 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4550 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4551 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4553 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4554 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4555 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4556 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4557 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4558 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4559 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4560 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4562 cmdline_parse_inst_t cmd_write_reg_bit = {
4563 .f = cmd_write_reg_bit_parsed,
4565 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4567 (void *)&cmd_write_reg_bit_write,
4568 (void *)&cmd_write_reg_bit_regbit,
4569 (void *)&cmd_write_reg_bit_port_id,
4570 (void *)&cmd_write_reg_bit_reg_off,
4571 (void *)&cmd_write_reg_bit_bit_pos,
4572 (void *)&cmd_write_reg_bit_value,
4577 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4578 struct cmd_read_rxd_txd_result {
4579 cmdline_fixed_string_t read;
4580 cmdline_fixed_string_t rxd_txd;
4587 cmd_read_rxd_txd_parsed(void *parsed_result,
4588 __attribute__((unused)) struct cmdline *cl,
4589 __attribute__((unused)) void *data)
4591 struct cmd_read_rxd_txd_result *res = parsed_result;
4593 if (!strcmp(res->rxd_txd, "rxd"))
4594 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4595 else if (!strcmp(res->rxd_txd, "txd"))
4596 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4599 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4600 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4601 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4602 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4604 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4605 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4606 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4607 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4608 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4609 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4611 cmdline_parse_inst_t cmd_read_rxd_txd = {
4612 .f = cmd_read_rxd_txd_parsed,
4614 .help_str = "read rxd|txd port_id queue_id rxd_id",
4616 (void *)&cmd_read_rxd_txd_read,
4617 (void *)&cmd_read_rxd_txd_rxd_txd,
4618 (void *)&cmd_read_rxd_txd_port_id,
4619 (void *)&cmd_read_rxd_txd_queue_id,
4620 (void *)&cmd_read_rxd_txd_desc_id,
4626 struct cmd_quit_result {
4627 cmdline_fixed_string_t quit;
4630 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4632 __attribute__((unused)) void *data)
4638 cmdline_parse_token_string_t cmd_quit_quit =
4639 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4641 cmdline_parse_inst_t cmd_quit = {
4642 .f = cmd_quit_parsed,
4644 .help_str = "exit application",
4646 (void *)&cmd_quit_quit,
4651 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4652 struct cmd_mac_addr_result {
4653 cmdline_fixed_string_t mac_addr_cmd;
4654 cmdline_fixed_string_t what;
4656 struct ether_addr address;
4659 static void cmd_mac_addr_parsed(void *parsed_result,
4660 __attribute__((unused)) struct cmdline *cl,
4661 __attribute__((unused)) void *data)
4663 struct cmd_mac_addr_result *res = parsed_result;
4666 if (strcmp(res->what, "add") == 0)
4667 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4669 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4671 /* check the return value and print it if is < 0 */
4673 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4677 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4678 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4680 cmdline_parse_token_string_t cmd_mac_addr_what =
4681 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4683 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4684 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4685 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4686 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4688 cmdline_parse_inst_t cmd_mac_addr = {
4689 .f = cmd_mac_addr_parsed,
4691 .help_str = "mac_addr add|remove X <address>: "
4692 "add/remove MAC address on port X",
4694 (void *)&cmd_mac_addr_cmd,
4695 (void *)&cmd_mac_addr_what,
4696 (void *)&cmd_mac_addr_portnum,
4697 (void *)&cmd_mac_addr_addr,
4703 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4704 struct cmd_set_qmap_result {
4705 cmdline_fixed_string_t set;
4706 cmdline_fixed_string_t qmap;
4707 cmdline_fixed_string_t what;
4714 cmd_set_qmap_parsed(void *parsed_result,
4715 __attribute__((unused)) struct cmdline *cl,
4716 __attribute__((unused)) void *data)
4718 struct cmd_set_qmap_result *res = parsed_result;
4719 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4721 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4724 cmdline_parse_token_string_t cmd_setqmap_set =
4725 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4727 cmdline_parse_token_string_t cmd_setqmap_qmap =
4728 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4730 cmdline_parse_token_string_t cmd_setqmap_what =
4731 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4733 cmdline_parse_token_num_t cmd_setqmap_portid =
4734 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4736 cmdline_parse_token_num_t cmd_setqmap_queueid =
4737 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4739 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4740 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4743 cmdline_parse_inst_t cmd_set_qmap = {
4744 .f = cmd_set_qmap_parsed,
4746 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4748 (void *)&cmd_setqmap_set,
4749 (void *)&cmd_setqmap_qmap,
4750 (void *)&cmd_setqmap_what,
4751 (void *)&cmd_setqmap_portid,
4752 (void *)&cmd_setqmap_queueid,
4753 (void *)&cmd_setqmap_mapvalue,
4758 /* *** CONFIGURE UNICAST HASH TABLE *** */
4759 struct cmd_set_uc_hash_table {
4760 cmdline_fixed_string_t set;
4761 cmdline_fixed_string_t port;
4763 cmdline_fixed_string_t what;
4764 struct ether_addr address;
4765 cmdline_fixed_string_t mode;
4769 cmd_set_uc_hash_parsed(void *parsed_result,
4770 __attribute__((unused)) struct cmdline *cl,
4771 __attribute__((unused)) void *data)
4774 struct cmd_set_uc_hash_table *res = parsed_result;
4776 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4778 if (strcmp(res->what, "uta") == 0)
4779 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4780 &res->address,(uint8_t)is_on);
4782 printf("bad unicast hash table parameter, return code = %d \n", ret);
4786 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4787 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4789 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4790 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4792 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4793 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4795 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4796 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4798 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4799 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4801 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4802 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4805 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4806 .f = cmd_set_uc_hash_parsed,
4808 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4810 (void *)&cmd_set_uc_hash_set,
4811 (void *)&cmd_set_uc_hash_port,
4812 (void *)&cmd_set_uc_hash_portid,
4813 (void *)&cmd_set_uc_hash_what,
4814 (void *)&cmd_set_uc_hash_mac,
4815 (void *)&cmd_set_uc_hash_mode,
4820 struct cmd_set_uc_all_hash_table {
4821 cmdline_fixed_string_t set;
4822 cmdline_fixed_string_t port;
4824 cmdline_fixed_string_t what;
4825 cmdline_fixed_string_t value;
4826 cmdline_fixed_string_t mode;
4830 cmd_set_uc_all_hash_parsed(void *parsed_result,
4831 __attribute__((unused)) struct cmdline *cl,
4832 __attribute__((unused)) void *data)
4835 struct cmd_set_uc_all_hash_table *res = parsed_result;
4837 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4839 if ((strcmp(res->what, "uta") == 0) &&
4840 (strcmp(res->value, "all") == 0))
4841 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4843 printf("bad unicast hash table parameter,"
4844 "return code = %d \n", ret);
4847 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4848 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4850 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4851 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4853 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4854 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4856 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4857 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4859 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4860 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4862 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4863 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4866 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4867 .f = cmd_set_uc_all_hash_parsed,
4869 .help_str = "set port X uta all on|off (X = port number)",
4871 (void *)&cmd_set_uc_all_hash_set,
4872 (void *)&cmd_set_uc_all_hash_port,
4873 (void *)&cmd_set_uc_all_hash_portid,
4874 (void *)&cmd_set_uc_all_hash_what,
4875 (void *)&cmd_set_uc_all_hash_value,
4876 (void *)&cmd_set_uc_all_hash_mode,
4881 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4882 struct cmd_set_vf_traffic {
4883 cmdline_fixed_string_t set;
4884 cmdline_fixed_string_t port;
4886 cmdline_fixed_string_t vf;
4888 cmdline_fixed_string_t what;
4889 cmdline_fixed_string_t mode;
4893 cmd_set_vf_traffic_parsed(void *parsed_result,
4894 __attribute__((unused)) struct cmdline *cl,
4895 __attribute__((unused)) void *data)
4897 struct cmd_set_vf_traffic *res = parsed_result;
4898 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4899 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4901 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4904 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4905 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4907 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4908 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4910 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4911 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4913 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4914 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4916 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4917 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4919 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4920 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4922 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4923 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4926 cmdline_parse_inst_t cmd_set_vf_traffic = {
4927 .f = cmd_set_vf_traffic_parsed,
4929 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4931 (void *)&cmd_setvf_traffic_set,
4932 (void *)&cmd_setvf_traffic_port,
4933 (void *)&cmd_setvf_traffic_portid,
4934 (void *)&cmd_setvf_traffic_vf,
4935 (void *)&cmd_setvf_traffic_vfid,
4936 (void *)&cmd_setvf_traffic_what,
4937 (void *)&cmd_setvf_traffic_mode,
4942 /* *** CONFIGURE VF RECEIVE MODE *** */
4943 struct cmd_set_vf_rxmode {
4944 cmdline_fixed_string_t set;
4945 cmdline_fixed_string_t port;
4947 cmdline_fixed_string_t vf;
4949 cmdline_fixed_string_t what;
4950 cmdline_fixed_string_t mode;
4951 cmdline_fixed_string_t on;
4955 cmd_set_vf_rxmode_parsed(void *parsed_result,
4956 __attribute__((unused)) struct cmdline *cl,
4957 __attribute__((unused)) void *data)
4960 uint16_t rx_mode = 0;
4961 struct cmd_set_vf_rxmode *res = parsed_result;
4963 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4964 if (!strcmp(res->what,"rxmode")) {
4965 if (!strcmp(res->mode, "AUPE"))
4966 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4967 else if (!strcmp(res->mode, "ROPE"))
4968 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4969 else if (!strcmp(res->mode, "BAM"))
4970 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4971 else if (!strncmp(res->mode, "MPE",3))
4972 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4975 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4977 printf("bad VF receive mode parameter, return code = %d \n",
4981 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4984 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4985 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4987 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4988 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4990 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4991 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4993 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4994 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4996 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4997 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4999 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5000 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5001 mode, "AUPE#ROPE#BAM#MPE");
5002 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5003 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5006 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5007 .f = cmd_set_vf_rxmode_parsed,
5009 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5011 (void *)&cmd_set_vf_rxmode_set,
5012 (void *)&cmd_set_vf_rxmode_port,
5013 (void *)&cmd_set_vf_rxmode_portid,
5014 (void *)&cmd_set_vf_rxmode_vf,
5015 (void *)&cmd_set_vf_rxmode_vfid,
5016 (void *)&cmd_set_vf_rxmode_what,
5017 (void *)&cmd_set_vf_rxmode_mode,
5018 (void *)&cmd_set_vf_rxmode_on,
5023 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5024 struct cmd_vf_mac_addr_result {
5025 cmdline_fixed_string_t mac_addr_cmd;
5026 cmdline_fixed_string_t what;
5027 cmdline_fixed_string_t port;
5029 cmdline_fixed_string_t vf;
5031 struct ether_addr address;
5034 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5035 __attribute__((unused)) struct cmdline *cl,
5036 __attribute__((unused)) void *data)
5038 struct cmd_vf_mac_addr_result *res = parsed_result;
5041 if (strcmp(res->what, "add") == 0)
5042 ret = rte_eth_dev_mac_addr_add(res->port_num,
5043 &res->address, res->vf_num);
5045 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5049 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5050 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5051 mac_addr_cmd,"mac_addr");
5052 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5053 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5055 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5056 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5058 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5059 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5061 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5062 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5064 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
5065 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5067 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
5068 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
5071 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
5072 .f = cmd_vf_mac_addr_parsed,
5074 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
5075 "Y = VF number)add MAC address filtering for a VF on port X",
5077 (void *)&cmd_vf_mac_addr_cmd,
5078 (void *)&cmd_vf_mac_addr_what,
5079 (void *)&cmd_vf_mac_addr_port,
5080 (void *)&cmd_vf_mac_addr_portnum,
5081 (void *)&cmd_vf_mac_addr_vf,
5082 (void *)&cmd_vf_mac_addr_vfnum,
5083 (void *)&cmd_vf_mac_addr_addr,
5088 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
5089 struct cmd_vf_rx_vlan_filter {
5090 cmdline_fixed_string_t rx_vlan;
5091 cmdline_fixed_string_t what;
5093 cmdline_fixed_string_t port;
5095 cmdline_fixed_string_t vf;
5100 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
5101 __attribute__((unused)) struct cmdline *cl,
5102 __attribute__((unused)) void *data)
5104 struct cmd_vf_rx_vlan_filter *res = parsed_result;
5106 if (!strcmp(res->what, "add"))
5107 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
5109 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
5112 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
5113 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5114 rx_vlan, "rx_vlan");
5115 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
5116 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5118 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
5119 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5121 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
5122 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5124 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
5125 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5127 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
5128 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5130 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
5131 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5134 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
5135 .f = cmd_vf_rx_vlan_filter_parsed,
5137 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
5138 "Y = port number,Z = hexadecimal VF mask)",
5140 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
5141 (void *)&cmd_vf_rx_vlan_filter_what,
5142 (void *)&cmd_vf_rx_vlan_filter_vlanid,
5143 (void *)&cmd_vf_rx_vlan_filter_port,
5144 (void *)&cmd_vf_rx_vlan_filter_portid,
5145 (void *)&cmd_vf_rx_vlan_filter_vf,
5146 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
5151 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
5152 struct cmd_queue_rate_limit_result {
5153 cmdline_fixed_string_t set;
5154 cmdline_fixed_string_t port;
5156 cmdline_fixed_string_t queue;
5158 cmdline_fixed_string_t rate;
5162 static void cmd_queue_rate_limit_parsed(void *parsed_result,
5163 __attribute__((unused)) struct cmdline *cl,
5164 __attribute__((unused)) void *data)
5166 struct cmd_queue_rate_limit_result *res = parsed_result;
5169 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5170 && (strcmp(res->queue, "queue") == 0)
5171 && (strcmp(res->rate, "rate") == 0))
5172 ret = set_queue_rate_limit(res->port_num, res->queue_num,
5175 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
5179 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
5180 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5182 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
5183 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5185 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
5186 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5188 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
5189 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5191 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
5192 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5194 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
5195 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5197 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
5198 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5201 cmdline_parse_inst_t cmd_queue_rate_limit = {
5202 .f = cmd_queue_rate_limit_parsed,
5204 .help_str = "set port X queue Y rate Z:(X = port number,"
5205 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
5207 (void *)&cmd_queue_rate_limit_set,
5208 (void *)&cmd_queue_rate_limit_port,
5209 (void *)&cmd_queue_rate_limit_portnum,
5210 (void *)&cmd_queue_rate_limit_queue,
5211 (void *)&cmd_queue_rate_limit_queuenum,
5212 (void *)&cmd_queue_rate_limit_rate,
5213 (void *)&cmd_queue_rate_limit_ratenum,
5218 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
5219 struct cmd_vf_rate_limit_result {
5220 cmdline_fixed_string_t set;
5221 cmdline_fixed_string_t port;
5223 cmdline_fixed_string_t vf;
5225 cmdline_fixed_string_t rate;
5227 cmdline_fixed_string_t q_msk;
5231 static void cmd_vf_rate_limit_parsed(void *parsed_result,
5232 __attribute__((unused)) struct cmdline *cl,
5233 __attribute__((unused)) void *data)
5235 struct cmd_vf_rate_limit_result *res = parsed_result;
5238 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5239 && (strcmp(res->vf, "vf") == 0)
5240 && (strcmp(res->rate, "rate") == 0)
5241 && (strcmp(res->q_msk, "queue_mask") == 0))
5242 ret = set_vf_rate_limit(res->port_num, res->vf_num,
5243 res->rate_num, res->q_msk_val);
5245 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
5249 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
5250 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5252 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
5253 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5255 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
5256 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5258 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
5259 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5261 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
5262 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5264 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
5265 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5267 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
5268 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5270 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
5271 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5272 q_msk, "queue_mask");
5273 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
5274 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5277 cmdline_parse_inst_t cmd_vf_rate_limit = {
5278 .f = cmd_vf_rate_limit_parsed,
5280 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
5281 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
5282 "for queues of VF on port X",
5284 (void *)&cmd_vf_rate_limit_set,
5285 (void *)&cmd_vf_rate_limit_port,
5286 (void *)&cmd_vf_rate_limit_portnum,
5287 (void *)&cmd_vf_rate_limit_vf,
5288 (void *)&cmd_vf_rate_limit_vfnum,
5289 (void *)&cmd_vf_rate_limit_rate,
5290 (void *)&cmd_vf_rate_limit_ratenum,
5291 (void *)&cmd_vf_rate_limit_q_msk,
5292 (void *)&cmd_vf_rate_limit_q_msk_val,
5297 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
5298 struct cmd_set_mirror_mask_result {
5299 cmdline_fixed_string_t set;
5300 cmdline_fixed_string_t port;
5302 cmdline_fixed_string_t mirror;
5304 cmdline_fixed_string_t what;
5305 cmdline_fixed_string_t value;
5306 cmdline_fixed_string_t dstpool;
5308 cmdline_fixed_string_t on;
5311 cmdline_parse_token_string_t cmd_mirror_mask_set =
5312 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5314 cmdline_parse_token_string_t cmd_mirror_mask_port =
5315 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5317 cmdline_parse_token_string_t cmd_mirror_mask_portid =
5318 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5320 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
5321 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5322 mirror, "mirror-rule");
5323 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
5324 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5326 cmdline_parse_token_string_t cmd_mirror_mask_what =
5327 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5328 what, "pool-mirror#vlan-mirror");
5329 cmdline_parse_token_string_t cmd_mirror_mask_value =
5330 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5332 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
5333 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5334 dstpool, "dst-pool");
5335 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
5336 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5338 cmdline_parse_token_string_t cmd_mirror_mask_on =
5339 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5343 cmd_set_mirror_mask_parsed(void *parsed_result,
5344 __attribute__((unused)) struct cmdline *cl,
5345 __attribute__((unused)) void *data)
5348 struct cmd_set_mirror_mask_result *res = parsed_result;
5349 struct rte_eth_vmdq_mirror_conf mr_conf;
5351 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5353 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
5355 mr_conf.dst_pool = res->dstpool_id;
5357 if (!strcmp(res->what, "pool-mirror")) {
5358 mr_conf.pool_mask = strtoull(res->value,NULL,16);
5359 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
5360 } else if(!strcmp(res->what, "vlan-mirror")) {
5361 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
5362 nb_item = parse_item_list(res->value, "core",
5363 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
5367 for(i=0; i < nb_item; i++) {
5368 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
5369 printf("Invalid vlan_id: must be < 4096\n");
5373 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
5374 mr_conf.vlan.vlan_mask |= 1ULL << i;
5378 if(!strcmp(res->on, "on"))
5379 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5382 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5385 printf("mirror rule add error: (%s)\n", strerror(-ret));
5388 cmdline_parse_inst_t cmd_set_mirror_mask = {
5389 .f = cmd_set_mirror_mask_parsed,
5391 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
5392 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
5394 (void *)&cmd_mirror_mask_set,
5395 (void *)&cmd_mirror_mask_port,
5396 (void *)&cmd_mirror_mask_portid,
5397 (void *)&cmd_mirror_mask_mirror,
5398 (void *)&cmd_mirror_mask_ruleid,
5399 (void *)&cmd_mirror_mask_what,
5400 (void *)&cmd_mirror_mask_value,
5401 (void *)&cmd_mirror_mask_dstpool,
5402 (void *)&cmd_mirror_mask_poolid,
5403 (void *)&cmd_mirror_mask_on,
5408 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
5409 struct cmd_set_mirror_link_result {
5410 cmdline_fixed_string_t set;
5411 cmdline_fixed_string_t port;
5413 cmdline_fixed_string_t mirror;
5415 cmdline_fixed_string_t what;
5416 cmdline_fixed_string_t dstpool;
5418 cmdline_fixed_string_t on;
5421 cmdline_parse_token_string_t cmd_mirror_link_set =
5422 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5424 cmdline_parse_token_string_t cmd_mirror_link_port =
5425 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5427 cmdline_parse_token_string_t cmd_mirror_link_portid =
5428 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5430 cmdline_parse_token_string_t cmd_mirror_link_mirror =
5431 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5432 mirror, "mirror-rule");
5433 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
5434 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5436 cmdline_parse_token_string_t cmd_mirror_link_what =
5437 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5438 what, "uplink-mirror#downlink-mirror");
5439 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5441 dstpool, "dst-pool");
5442 cmdline_parse_token_num_t cmd_mirror_link_poolid =
5443 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5445 cmdline_parse_token_string_t cmd_mirror_link_on =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5450 cmd_set_mirror_link_parsed(void *parsed_result,
5451 __attribute__((unused)) struct cmdline *cl,
5452 __attribute__((unused)) void *data)
5455 struct cmd_set_mirror_link_result *res = parsed_result;
5456 struct rte_eth_vmdq_mirror_conf mr_conf;
5458 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5459 if(!strcmp(res->what, "uplink-mirror")) {
5460 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
5461 }else if(!strcmp(res->what, "downlink-mirror"))
5462 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
5464 mr_conf.dst_pool = res->dstpool_id;
5466 if(!strcmp(res->on, "on"))
5467 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5470 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5473 /* check the return value and print it if is < 0 */
5475 printf("mirror rule add error: (%s)\n", strerror(-ret));
5479 cmdline_parse_inst_t cmd_set_mirror_link = {
5480 .f = cmd_set_mirror_link_parsed,
5482 .help_str = "set port X mirror-rule Y uplink-mirror|"
5483 "downlink-mirror dst-pool Z on|off",
5485 (void *)&cmd_mirror_link_set,
5486 (void *)&cmd_mirror_link_port,
5487 (void *)&cmd_mirror_link_portid,
5488 (void *)&cmd_mirror_link_mirror,
5489 (void *)&cmd_mirror_link_ruleid,
5490 (void *)&cmd_mirror_link_what,
5491 (void *)&cmd_mirror_link_dstpool,
5492 (void *)&cmd_mirror_link_poolid,
5493 (void *)&cmd_mirror_link_on,
5498 /* *** RESET VM MIRROR RULE *** */
5499 struct cmd_rm_mirror_rule_result {
5500 cmdline_fixed_string_t reset;
5501 cmdline_fixed_string_t port;
5503 cmdline_fixed_string_t mirror;
5507 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
5508 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5510 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
5511 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5513 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
5514 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5516 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
5517 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5518 mirror, "mirror-rule");
5519 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
5520 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5524 cmd_reset_mirror_rule_parsed(void *parsed_result,
5525 __attribute__((unused)) struct cmdline *cl,
5526 __attribute__((unused)) void *data)
5529 struct cmd_set_mirror_link_result *res = parsed_result;
5531 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
5533 printf("mirror rule remove error: (%s)\n", strerror(-ret));
5536 cmdline_parse_inst_t cmd_reset_mirror_rule = {
5537 .f = cmd_reset_mirror_rule_parsed,
5539 .help_str = "reset port X mirror-rule Y",
5541 (void *)&cmd_rm_mirror_rule_reset,
5542 (void *)&cmd_rm_mirror_rule_port,
5543 (void *)&cmd_rm_mirror_rule_portid,
5544 (void *)&cmd_rm_mirror_rule_mirror,
5545 (void *)&cmd_rm_mirror_rule_ruleid,
5550 /* ******************************************************************************** */
5552 struct cmd_dump_result {
5553 cmdline_fixed_string_t dump;
5557 dump_struct_sizes(void)
5559 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
5560 DUMP_SIZE(struct rte_mbuf);
5561 DUMP_SIZE(struct rte_pktmbuf);
5562 DUMP_SIZE(struct rte_ctrlmbuf);
5563 DUMP_SIZE(struct rte_mempool);
5564 DUMP_SIZE(struct rte_ring);
5568 static void cmd_dump_parsed(void *parsed_result,
5569 __attribute__((unused)) struct cmdline *cl,
5570 __attribute__((unused)) void *data)
5572 struct cmd_dump_result *res = parsed_result;
5574 if (!strcmp(res->dump, "dump_physmem"))
5575 rte_dump_physmem_layout(stdout);
5576 else if (!strcmp(res->dump, "dump_memzone"))
5577 rte_memzone_dump(stdout);
5578 else if (!strcmp(res->dump, "dump_log_history"))
5579 rte_log_dump_history(stdout);
5580 else if (!strcmp(res->dump, "dump_struct_sizes"))
5581 dump_struct_sizes();
5582 else if (!strcmp(res->dump, "dump_ring"))
5583 rte_ring_list_dump(stdout);
5584 else if (!strcmp(res->dump, "dump_mempool"))
5585 rte_mempool_list_dump(stdout);
5586 else if (!strcmp(res->dump, "dump_devargs"))
5587 rte_eal_devargs_dump(stdout);
5590 cmdline_parse_token_string_t cmd_dump_dump =
5591 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
5595 "dump_struct_sizes#"
5600 cmdline_parse_inst_t cmd_dump = {
5601 .f = cmd_dump_parsed, /* function to call */
5602 .data = NULL, /* 2nd arg of func */
5603 .help_str = "dump status",
5604 .tokens = { /* token list, NULL terminated */
5605 (void *)&cmd_dump_dump,
5610 /* ******************************************************************************** */
5612 struct cmd_dump_one_result {
5613 cmdline_fixed_string_t dump;
5614 cmdline_fixed_string_t name;
5617 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
5618 __attribute__((unused)) void *data)
5620 struct cmd_dump_one_result *res = parsed_result;
5622 if (!strcmp(res->dump, "dump_ring")) {
5624 r = rte_ring_lookup(res->name);
5626 cmdline_printf(cl, "Cannot find ring\n");
5629 rte_ring_dump(stdout, r);
5630 } else if (!strcmp(res->dump, "dump_mempool")) {
5631 struct rte_mempool *mp;
5632 mp = rte_mempool_lookup(res->name);
5634 cmdline_printf(cl, "Cannot find mempool\n");
5637 rte_mempool_dump(stdout, mp);
5641 cmdline_parse_token_string_t cmd_dump_one_dump =
5642 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
5643 "dump_ring#dump_mempool");
5645 cmdline_parse_token_string_t cmd_dump_one_name =
5646 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
5648 cmdline_parse_inst_t cmd_dump_one = {
5649 .f = cmd_dump_one_parsed, /* function to call */
5650 .data = NULL, /* 2nd arg of func */
5651 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
5652 .tokens = { /* token list, NULL terminated */
5653 (void *)&cmd_dump_one_dump,
5654 (void *)&cmd_dump_one_name,
5659 /* *** ADD/REMOVE an ethertype FILTER *** */
5660 struct cmd_ethertype_filter_result {
5661 cmdline_fixed_string_t filter;
5663 cmdline_fixed_string_t ethertype;
5664 uint16_t ethertype_value;
5665 cmdline_fixed_string_t priority;
5666 cmdline_fixed_string_t priority_en;
5667 uint8_t priority_value;
5668 cmdline_fixed_string_t queue;
5670 cmdline_fixed_string_t index;
5671 uint16_t index_value;
5675 cmd_ethertype_filter_parsed(void *parsed_result,
5676 __attribute__((unused)) struct cmdline *cl,
5677 __attribute__((unused)) void *data)
5680 struct cmd_ethertype_filter_result *res = parsed_result;
5681 struct rte_ethertype_filter filter;
5683 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
5684 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
5685 filter.priority = res->priority_value;
5687 if (!strcmp(res->priority_en, "enable"))
5688 filter.priority_en = 1;
5689 if (!strcmp(res->filter, "add_ethertype_filter"))
5690 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
5692 &filter, res->queue_id);
5693 else if (!strcmp(res->filter, "remove_ethertype_filter"))
5694 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
5696 else if (!strcmp(res->filter, "get_ethertype_filter"))
5697 get_ethertype_filter(res->port_id, res->index_value);
5700 printf("ethertype filter setting error: (%s)\n",
5704 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
5705 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5707 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
5708 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5709 ethertype, "ethertype");
5710 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
5711 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5712 ethertype_value, UINT16);
5713 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
5714 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5715 priority, "priority");
5716 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
5717 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5718 priority_en, "enable#disable");
5719 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
5720 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5721 priority_value, UINT8);
5722 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
5723 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5725 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
5726 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5728 cmdline_parse_token_string_t cmd_ethertype_filter_index =
5729 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5731 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
5732 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5733 index_value, UINT16);
5734 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
5735 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5736 filter, "add_ethertype_filter");
5737 cmdline_parse_inst_t cmd_add_ethertype_filter = {
5738 .f = cmd_ethertype_filter_parsed,
5740 .help_str = "add an ethertype filter",
5742 (void *)&cmd_ethertype_filter_add_filter,
5743 (void *)&cmd_ethertype_filter_port_id,
5744 (void *)&cmd_ethertype_filter_ethertype,
5745 (void *)&cmd_ethertype_filter_ethertype_value,
5746 (void *)&cmd_ethertype_filter_priority,
5747 (void *)&cmd_ethertype_filter_priority_en,
5748 (void *)&cmd_ethertype_filter_priority_value,
5749 (void *)&cmd_ethertype_filter_queue,
5750 (void *)&cmd_ethertype_filter_queue_id,
5751 (void *)&cmd_ethertype_filter_index,
5752 (void *)&cmd_ethertype_filter_index_value,
5757 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
5758 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5759 filter, "remove_ethertype_filter");
5760 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
5761 .f = cmd_ethertype_filter_parsed,
5763 .help_str = "remove an ethertype filter",
5765 (void *)&cmd_ethertype_filter_remove_filter,
5766 (void *)&cmd_ethertype_filter_port_id,
5767 (void *)&cmd_ethertype_filter_index,
5768 (void *)&cmd_ethertype_filter_index_value,
5772 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
5773 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5774 filter, "get_ethertype_filter");
5775 cmdline_parse_inst_t cmd_get_ethertype_filter = {
5776 .f = cmd_ethertype_filter_parsed,
5778 .help_str = "get an ethertype filter",
5780 (void *)&cmd_ethertype_filter_get_filter,
5781 (void *)&cmd_ethertype_filter_port_id,
5782 (void *)&cmd_ethertype_filter_index,
5783 (void *)&cmd_ethertype_filter_index_value,
5788 /* *** set SYN filter *** */
5789 struct cmd_set_syn_filter_result {
5790 cmdline_fixed_string_t filter;
5792 cmdline_fixed_string_t priority;
5793 cmdline_fixed_string_t high;
5794 cmdline_fixed_string_t queue;
5799 cmd_set_syn_filter_parsed(void *parsed_result,
5800 __attribute__((unused)) struct cmdline *cl,
5801 __attribute__((unused)) void *data)
5804 struct cmd_set_syn_filter_result *res = parsed_result;
5805 struct rte_syn_filter filter;
5807 if (!strcmp(res->filter, "add_syn_filter")) {
5808 if (!strcmp(res->high, "high"))
5812 ret = rte_eth_dev_add_syn_filter(res->port_id,
5813 &filter, res->queue_id);
5814 } else if (!strcmp(res->filter, "remove_syn_filter"))
5815 ret = rte_eth_dev_remove_syn_filter(res->port_id);
5816 else if (!strcmp(res->filter, "get_syn_filter"))
5817 get_syn_filter(res->port_id);
5819 printf("syn filter setting error: (%s)\n", strerror(-ret));
5822 cmdline_parse_token_string_t cmd_syn_filter_portid =
5823 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
5825 cmdline_parse_token_string_t cmd_syn_filter_priority =
5826 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5827 priority, "priority");
5828 cmdline_parse_token_string_t cmd_syn_filter_high =
5829 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5831 cmdline_parse_token_string_t cmd_syn_filter_queue =
5832 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5834 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
5835 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
5837 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
5838 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5839 filter, "add_syn_filter");
5840 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5842 filter, "remove_syn_filter");
5843 cmdline_parse_inst_t cmd_add_syn_filter = {
5844 .f = cmd_set_syn_filter_parsed,
5846 .help_str = "add syn filter",
5848 (void *)&cmd_syn_filter_add_filter,
5849 (void *)&cmd_syn_filter_portid,
5850 (void *)&cmd_syn_filter_priority,
5851 (void *)&cmd_syn_filter_high,
5852 (void *)&cmd_syn_filter_queue,
5853 (void *)&cmd_syn_filter_queue_id,
5857 cmdline_parse_inst_t cmd_remove_syn_filter = {
5858 .f = cmd_set_syn_filter_parsed,
5860 .help_str = "remove syn filter",
5862 (void *)&cmd_syn_filter_remove_filter,
5863 (void *)&cmd_syn_filter_portid,
5868 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
5869 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5870 filter, "get_syn_filter");
5872 cmdline_parse_inst_t cmd_get_syn_filter = {
5873 .f = cmd_set_syn_filter_parsed,
5875 .help_str = "get syn filter",
5877 (void *)&cmd_syn_filter_get_filter,
5878 (void *)&cmd_syn_filter_portid,
5883 /* *** ADD/REMOVE A 2tuple FILTER *** */
5884 struct cmd_2tuple_filter_result {
5885 cmdline_fixed_string_t filter;
5887 cmdline_fixed_string_t protocol;
5888 uint8_t protocol_value;
5889 uint8_t protocol_mask;
5890 cmdline_fixed_string_t dst_port;
5891 uint16_t dst_port_value;
5892 uint16_t dst_port_mask;
5893 cmdline_fixed_string_t flags;
5894 uint8_t flags_value;
5895 cmdline_fixed_string_t priority;
5896 uint8_t priority_value;
5897 cmdline_fixed_string_t queue;
5899 cmdline_fixed_string_t index;
5900 uint16_t index_value;
5904 cmd_2tuple_filter_parsed(void *parsed_result,
5905 __attribute__((unused)) struct cmdline *cl,
5906 __attribute__((unused)) void *data)
5909 struct rte_2tuple_filter filter;
5910 struct cmd_2tuple_filter_result *res = parsed_result;
5912 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
5914 if (!strcmp(res->filter, "add_2tuple_filter")) {
5915 /* need convert to big endian. */
5916 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
5917 filter.protocol = res->protocol_value;
5918 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
5919 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
5920 filter.priority = res->priority_value;
5921 filter.tcp_flags = res->flags_value;
5922 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
5923 res->index_value, &filter, res->queue_id);
5924 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
5925 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
5927 else if (!strcmp(res->filter, "get_2tuple_filter"))
5928 get_2tuple_filter(res->port_id, res->index_value);
5931 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
5934 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
5935 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5937 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
5938 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5939 protocol, "protocol");
5940 cmdline_parse_token_string_t cmd_2tuple_filter_protocol_value =
5941 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5942 protocol_value, UINT8);
5943 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
5944 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5945 protocol_mask, UINT8);
5946 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
5947 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5948 dst_port, "dst_port");
5949 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
5950 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5951 dst_port_value, UINT16);
5952 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
5953 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5954 dst_port_mask, UINT16);
5955 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
5956 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5958 cmdline_parse_token_string_t cmd_2tuple_filter_flags_value =
5959 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5960 flags_value, UINT8);
5961 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
5962 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5963 priority, "priority");
5964 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
5965 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5966 priority_value, UINT8);
5967 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
5968 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5970 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
5971 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5973 cmdline_parse_token_string_t cmd_2tuple_filter_index =
5974 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5976 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
5977 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5978 index_value, UINT16);
5979 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
5980 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5981 filter, "add_2tuple_filter");
5982 cmdline_parse_inst_t cmd_add_2tuple_filter = {
5983 .f = cmd_2tuple_filter_parsed,
5985 .help_str = "add a 2tuple filter",
5987 (void *)&cmd_2tuple_filter_add_filter,
5988 (void *)&cmd_2tuple_filter_port_id,
5989 (void *)&cmd_2tuple_filter_protocol,
5990 (void *)&cmd_2tuple_filter_protocol_value,
5991 (void *)&cmd_2tuple_filter_protocol_mask,
5992 (void *)&cmd_2tuple_filter_dst_port,
5993 (void *)&cmd_2tuple_filter_dst_port_value,
5994 (void *)&cmd_2tuple_filter_dst_port_mask,
5995 (void *)&cmd_2tuple_filter_flags,
5996 (void *)&cmd_2tuple_filter_flags_value,
5997 (void *)&cmd_2tuple_filter_priority,
5998 (void *)&cmd_2tuple_filter_priority_value,
5999 (void *)&cmd_2tuple_filter_queue,
6000 (void *)&cmd_2tuple_filter_queue_id,
6001 (void *)&cmd_2tuple_filter_index,
6002 (void *)&cmd_2tuple_filter_index_value,
6007 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
6008 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6009 filter, "remove_2tuple_filter");
6010 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
6011 .f = cmd_2tuple_filter_parsed,
6013 .help_str = "remove a 2tuple filter",
6015 (void *)&cmd_2tuple_filter_remove_filter,
6016 (void *)&cmd_2tuple_filter_port_id,
6017 (void *)&cmd_2tuple_filter_index,
6018 (void *)&cmd_2tuple_filter_index_value,
6022 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
6023 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6024 filter, "get_2tuple_filter");
6025 cmdline_parse_inst_t cmd_get_2tuple_filter = {
6026 .f = cmd_2tuple_filter_parsed,
6028 .help_str = "get a 2tuple filter",
6030 (void *)&cmd_2tuple_filter_get_filter,
6031 (void *)&cmd_2tuple_filter_port_id,
6032 (void *)&cmd_2tuple_filter_index,
6033 (void *)&cmd_2tuple_filter_index_value,
6038 /* *** ADD/REMOVE A 5tuple FILTER *** */
6039 struct cmd_5tuple_filter_result {
6040 cmdline_fixed_string_t filter;
6042 cmdline_fixed_string_t dst_ip;
6043 cmdline_ipaddr_t dst_ip_value;
6044 cmdline_fixed_string_t src_ip;
6045 cmdline_ipaddr_t src_ip_value;
6046 cmdline_fixed_string_t dst_port;
6047 uint16_t dst_port_value;
6048 cmdline_fixed_string_t src_port;
6049 uint16_t src_port_value;
6050 cmdline_fixed_string_t protocol;
6051 uint8_t protocol_value;
6052 cmdline_fixed_string_t mask;
6054 cmdline_fixed_string_t flags;
6055 uint8_t flags_value;
6056 cmdline_fixed_string_t priority;
6057 uint8_t priority_value;
6058 cmdline_fixed_string_t queue;
6060 cmdline_fixed_string_t index;
6061 uint16_t index_value;
6065 cmd_5tuple_filter_parsed(void *parsed_result,
6066 __attribute__((unused)) struct cmdline *cl,
6067 __attribute__((unused)) void *data)
6070 struct rte_5tuple_filter filter;
6071 struct cmd_5tuple_filter_result *res = parsed_result;
6073 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
6075 if (!strcmp(res->filter, "add_5tuple_filter")) {
6076 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
6077 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
6078 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
6079 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
6080 filter.protocol = res->protocol_value;
6081 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
6082 filter.priority = res->priority_value;
6083 filter.tcp_flags = res->flags_value;
6085 if (res->dst_ip_value.family == AF_INET)
6086 /* no need to convert, already big endian. */
6087 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
6089 if (filter.dst_ip_mask == 0) {
6090 printf("can not support ipv6 involved compare.\n");
6096 if (res->src_ip_value.family == AF_INET)
6097 /* no need to convert, already big endian. */
6098 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
6100 if (filter.src_ip_mask == 0) {
6101 printf("can not support ipv6 involved compare.\n");
6106 /* need convert to big endian. */
6107 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6108 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
6110 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
6111 res->index_value, &filter, res->queue_id);
6112 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
6113 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
6115 else if (!strcmp(res->filter, "get_5tuple_filter"))
6116 get_5tuple_filter(res->port_id, res->index_value);
6118 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
6122 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
6123 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6125 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
6126 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6128 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
6129 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6131 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
6132 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6134 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
6135 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6137 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
6138 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6139 dst_port, "dst_port");
6140 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
6141 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6142 dst_port_value, UINT16);
6143 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
6144 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6145 src_port, "src_port");
6146 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
6147 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6148 src_port_value, UINT16);
6149 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
6150 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6151 protocol, "protocol");
6152 cmdline_parse_token_string_t cmd_5tuple_filter_protocol_value =
6153 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6154 protocol_value, UINT8);
6155 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
6156 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6158 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
6159 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6161 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
6162 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6164 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
6165 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6166 flags_value, UINT8);
6167 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
6168 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6169 priority, "priority");
6170 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
6171 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6172 priority_value, UINT8);
6173 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
6174 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6176 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
6177 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6179 cmdline_parse_token_string_t cmd_5tuple_filter_index =
6180 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6182 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
6183 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6184 index_value, UINT16);
6186 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
6187 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6188 filter, "add_5tuple_filter");
6189 cmdline_parse_inst_t cmd_add_5tuple_filter = {
6190 .f = cmd_5tuple_filter_parsed,
6192 .help_str = "add a 5tuple filter",
6194 (void *)&cmd_5tuple_filter_add_filter,
6195 (void *)&cmd_5tuple_filter_port_id,
6196 (void *)&cmd_5tuple_filter_dst_ip,
6197 (void *)&cmd_5tuple_filter_dst_ip_value,
6198 (void *)&cmd_5tuple_filter_src_ip,
6199 (void *)&cmd_5tuple_filter_src_ip_value,
6200 (void *)&cmd_5tuple_filter_dst_port,
6201 (void *)&cmd_5tuple_filter_dst_port_value,
6202 (void *)&cmd_5tuple_filter_src_port,
6203 (void *)&cmd_5tuple_filter_src_port_value,
6204 (void *)&cmd_5tuple_filter_protocol,
6205 (void *)&cmd_5tuple_filter_protocol_value,
6206 (void *)&cmd_5tuple_filter_mask,
6207 (void *)&cmd_5tuple_filter_mask_value,
6208 (void *)&cmd_5tuple_filter_flags,
6209 (void *)&cmd_5tuple_filter_flags_value,
6210 (void *)&cmd_5tuple_filter_priority,
6211 (void *)&cmd_5tuple_filter_priority_value,
6212 (void *)&cmd_5tuple_filter_queue,
6213 (void *)&cmd_5tuple_filter_queue_id,
6214 (void *)&cmd_5tuple_filter_index,
6215 (void *)&cmd_5tuple_filter_index_value,
6220 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
6221 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6222 filter, "remove_5tuple_filter");
6223 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
6224 .f = cmd_5tuple_filter_parsed,
6226 .help_str = "remove a 5tuple filter",
6228 (void *)&cmd_5tuple_filter_remove_filter,
6229 (void *)&cmd_5tuple_filter_port_id,
6230 (void *)&cmd_5tuple_filter_index,
6231 (void *)&cmd_5tuple_filter_index_value,
6236 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
6237 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6238 filter, "get_5tuple_filter");
6239 cmdline_parse_inst_t cmd_get_5tuple_filter = {
6240 .f = cmd_5tuple_filter_parsed,
6242 .help_str = "get a 5tuple filter",
6244 (void *)&cmd_5tuple_filter_get_filter,
6245 (void *)&cmd_5tuple_filter_port_id,
6246 (void *)&cmd_5tuple_filter_index,
6247 (void *)&cmd_5tuple_filter_index_value,
6252 /* *** ADD/REMOVE A flex FILTER *** */
6253 struct cmd_flex_filter_result {
6254 cmdline_fixed_string_t filter;
6256 cmdline_fixed_string_t len;
6258 cmdline_fixed_string_t bytes;
6259 cmdline_fixed_string_t bytes_value;
6260 cmdline_fixed_string_t mask;
6261 cmdline_fixed_string_t mask_value;
6262 cmdline_fixed_string_t priority;
6263 uint8_t priority_value;
6264 cmdline_fixed_string_t queue;
6266 cmdline_fixed_string_t index;
6267 uint16_t index_value;
6270 static int xdigit2val(unsigned char c)
6275 else if (isupper(c))
6283 cmd_flex_filter_parsed(void *parsed_result,
6284 __attribute__((unused)) struct cmdline *cl,
6285 __attribute__((unused)) void *data)
6288 struct rte_flex_filter filter;
6289 struct cmd_flex_filter_result *res = parsed_result;
6290 char *bytes_ptr, *mask_ptr;
6298 if (!strcmp(res->filter, "add_flex_filter")) {
6299 if (res->len_value > 128) {
6300 printf("the len exceed the max length 128\n");
6303 memset(&filter, 0, sizeof(struct rte_flex_filter));
6304 filter.len = res->len_value;
6305 filter.priority = res->priority_value;
6306 bytes_ptr = res->bytes_value;
6307 mask_ptr = res->mask_value;
6310 /* translate bytes string to uint_32 array. */
6311 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
6312 (bytes_ptr[1] == 'X')))
6314 len = strnlen(bytes_ptr, res->len_value * 2);
6315 if (len == 0 || (len % 8 != 0)) {
6316 printf("please check len and bytes input\n");
6319 for (i = 0; i < len; i++) {
6321 if (isxdigit(c) == 0) {
6322 /* invalid characters. */
6323 printf("invalid input\n");
6326 val = xdigit2val(c);
6330 dword |= byte << (4 * mod - 4);
6335 filter.dwords[j] = dword;
6336 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
6342 /* translate mask string to uint8_t array. */
6344 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
6345 (mask_ptr[1] == 'X')))
6347 len = strnlen(mask_ptr, (res->len_value+3)/4);
6349 printf("invalid input\n");
6352 for (i = 0; i < len; i++) {
6354 if (isxdigit(c) == 0) {
6355 /* invalid characters. */
6356 printf("invalid input\n");
6359 val = xdigit2val(c);
6360 hex |= (uint8_t)(val & 0x8) >> 3;
6361 hex |= (uint8_t)(val & 0x4) >> 1;
6362 hex |= (uint8_t)(val & 0x2) << 1;
6363 hex |= (uint8_t)(val & 0x1) << 3;
6366 filter.mask[j] = byte;
6367 printf("mask[%d]:%02x ", j, filter.mask[j]);
6375 printf("call function rte_eth_dev_add_flex_filter: "
6376 "index = %d, queue-id = %d, len = %d, priority = %d\n",
6377 res->index_value, res->queue_id,
6378 filter.len, filter.priority);
6379 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
6380 &filter, res->queue_id);
6382 } else if (!strcmp(res->filter, "remove_flex_filter"))
6383 ret = rte_eth_dev_remove_flex_filter(res->port_id,
6385 else if (!strcmp(res->filter, "get_flex_filter"))
6386 get_flex_filter(res->port_id, res->index_value);
6389 printf("flex filter setting error: (%s)\n", strerror(-ret));
6392 cmdline_parse_token_num_t cmd_flex_filter_port_id =
6393 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6395 cmdline_parse_token_string_t cmd_flex_filter_len =
6396 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6398 cmdline_parse_token_string_t cmd_flex_filter_len_value =
6399 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6401 cmdline_parse_token_string_t cmd_flex_filter_bytes =
6402 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6404 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
6405 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6407 cmdline_parse_token_string_t cmd_flex_filter_mask =
6408 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6410 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
6411 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6413 cmdline_parse_token_string_t cmd_flex_filter_priority =
6414 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6415 priority, "priority");
6416 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
6417 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6418 priority_value, UINT8);
6419 cmdline_parse_token_string_t cmd_flex_filter_queue =
6420 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6422 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
6423 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6425 cmdline_parse_token_string_t cmd_flex_filter_index =
6426 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6428 cmdline_parse_token_num_t cmd_flex_filter_index_value =
6429 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6430 index_value, UINT16);
6431 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
6432 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6433 filter, "add_flex_filter");
6434 cmdline_parse_inst_t cmd_add_flex_filter = {
6435 .f = cmd_flex_filter_parsed,
6437 .help_str = "add a flex filter",
6439 (void *)&cmd_flex_filter_add_filter,
6440 (void *)&cmd_flex_filter_port_id,
6441 (void *)&cmd_flex_filter_len,
6442 (void *)&cmd_flex_filter_len_value,
6443 (void *)&cmd_flex_filter_bytes,
6444 (void *)&cmd_flex_filter_bytes_value,
6445 (void *)&cmd_flex_filter_mask,
6446 (void *)&cmd_flex_filter_mask_value,
6447 (void *)&cmd_flex_filter_priority,
6448 (void *)&cmd_flex_filter_priority_value,
6449 (void *)&cmd_flex_filter_queue,
6450 (void *)&cmd_flex_filter_queue_id,
6451 (void *)&cmd_flex_filter_index,
6452 (void *)&cmd_flex_filter_index_value,
6457 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
6458 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6459 filter, "remove_flex_filter");
6460 cmdline_parse_inst_t cmd_remove_flex_filter = {
6461 .f = cmd_flex_filter_parsed,
6463 .help_str = "remove a flex filter",
6465 (void *)&cmd_flex_filter_remove_filter,
6466 (void *)&cmd_flex_filter_port_id,
6467 (void *)&cmd_flex_filter_index,
6468 (void *)&cmd_flex_filter_index_value,
6473 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
6474 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6475 filter, "get_flex_filter");
6476 cmdline_parse_inst_t cmd_get_flex_filter = {
6477 .f = cmd_flex_filter_parsed,
6479 .help_str = "get a flex filter",
6481 (void *)&cmd_flex_filter_get_filter,
6482 (void *)&cmd_flex_filter_port_id,
6483 (void *)&cmd_flex_filter_index,
6484 (void *)&cmd_flex_filter_index_value,
6489 /* ******************************************************************************** */
6491 /* list of instructions */
6492 cmdline_parse_ctx_t main_ctx[] = {
6493 (cmdline_parse_inst_t *)&cmd_help_brief,
6494 (cmdline_parse_inst_t *)&cmd_help_long,
6495 (cmdline_parse_inst_t *)&cmd_quit,
6496 (cmdline_parse_inst_t *)&cmd_showport,
6497 (cmdline_parse_inst_t *)&cmd_showportall,
6498 (cmdline_parse_inst_t *)&cmd_showcfg,
6499 (cmdline_parse_inst_t *)&cmd_start,
6500 (cmdline_parse_inst_t *)&cmd_start_tx_first,
6501 (cmdline_parse_inst_t *)&cmd_set_link_up,
6502 (cmdline_parse_inst_t *)&cmd_set_link_down,
6503 (cmdline_parse_inst_t *)&cmd_reset,
6504 (cmdline_parse_inst_t *)&cmd_set_numbers,
6505 (cmdline_parse_inst_t *)&cmd_set_txpkts,
6506 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
6507 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
6508 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
6509 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
6510 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
6511 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
6512 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
6513 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
6514 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
6515 (cmdline_parse_inst_t *)&cmd_set_link_check,
6516 #ifdef RTE_NIC_BYPASS
6517 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
6518 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
6519 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
6520 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
6522 (cmdline_parse_inst_t *)&cmd_vlan_offload,
6523 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
6524 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
6525 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
6526 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
6527 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
6528 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
6529 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
6530 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
6531 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
6532 (cmdline_parse_inst_t *)&cmd_config_dcb,
6533 (cmdline_parse_inst_t *)&cmd_read_reg,
6534 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
6535 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
6536 (cmdline_parse_inst_t *)&cmd_write_reg,
6537 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
6538 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
6539 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
6540 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
6541 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
6542 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
6543 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
6544 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
6545 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
6546 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
6547 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
6548 (cmdline_parse_inst_t *)&cmd_stop,
6549 (cmdline_parse_inst_t *)&cmd_mac_addr,
6550 (cmdline_parse_inst_t *)&cmd_set_qmap,
6551 (cmdline_parse_inst_t *)&cmd_operate_port,
6552 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
6553 (cmdline_parse_inst_t *)&cmd_config_speed_all,
6554 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
6555 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
6556 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
6557 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
6558 (cmdline_parse_inst_t *)&cmd_config_rss,
6559 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
6560 (cmdline_parse_inst_t *)&cmd_showport_reta,
6561 (cmdline_parse_inst_t *)&cmd_config_burst,
6562 (cmdline_parse_inst_t *)&cmd_config_thresh,
6563 (cmdline_parse_inst_t *)&cmd_config_threshold,
6564 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
6565 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
6566 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
6567 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
6568 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
6569 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
6570 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
6571 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
6572 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
6573 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
6574 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
6575 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
6576 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
6577 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
6578 (cmdline_parse_inst_t *)&cmd_dump,
6579 (cmdline_parse_inst_t *)&cmd_dump_one,
6580 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
6581 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
6582 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
6583 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
6584 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
6585 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
6586 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
6587 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
6588 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
6589 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
6590 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
6591 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
6592 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
6593 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
6594 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
6598 /* prompt function, called from main on MASTER lcore */
6604 /* initialize non-constant commands */
6605 cmd_set_fwd_mode_init();
6607 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
6611 cmdline_interact(cl);
6612 cmdline_stdin_exit(cl);
6616 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
6618 if (id < nb_ports) {
6619 /* check if need_reconfig has been set to 1 */
6620 if (ports[id].need_reconfig == 0)
6621 ports[id].need_reconfig = dev;
6622 /* check if need_reconfig_queues has been set to 1 */
6623 if (ports[id].need_reconfig_queues == 0)
6624 ports[id].need_reconfig_queues = queue;
6628 for (pid = 0; pid < nb_ports; pid++) {
6629 /* check if need_reconfig has been set to 1 */
6630 if (ports[pid].need_reconfig == 0)
6631 ports[pid].need_reconfig = dev;
6632 /* check if need_reconfig_queues has been set to 1 */
6633 if (ports[pid].need_reconfig_queues == 0)
6634 ports[pid].need_reconfig_queues = queue;
6639 #ifdef RTE_NIC_BYPASS
6641 bypass_is_supported(portid_t port_id)
6643 struct rte_port *port;
6644 struct rte_pci_id *pci_id;
6646 if (port_id >= nb_ports) {
6647 printf("\tPort id must be less than %d.\n", nb_ports);
6651 /* Get the device id. */
6652 port = &ports[port_id];
6653 pci_id = &port->dev_info.pci_dev->id;
6655 /* Check if NIC supports bypass. */
6656 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
6660 printf("\tBypass not supported for port_id = %d.\n", port_id);