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) autoneg (on|off) (port_id)\n"
330 "set flow_ctrl rx (on|off) (portid)\n"
331 "set flow_ctrl tx (on|off) (portid)\n"
332 "set flow_ctrl high_water (high_water) (portid)\n"
333 "set flow_ctrl low_water (low_water) (portid)\n"
334 "set flow_ctrl pause_time (pause_time) (portid)\n"
335 "set flow_ctrl send_xon (send_xon) (portid)\n"
336 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
337 "set flow_ctrl autoneg (on|off) (port_id)\n"
338 " Set the link flow control parameter on a port.\n\n"
340 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
341 " (low_water) (pause_time) (priority) (port_id)\n"
342 " Set the priority flow control parameter on a"
345 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
346 " Set statistics mapping (qmapping 0..15) for RX/TX"
348 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
349 " on port 0 to mapping 5.\n\n"
351 "set port (port_id) vf (vf_id) rx|tx on|off \n"
352 " Enable/Disable a VF receive/tranmit from a port\n\n"
354 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
356 " AUPE:accepts untagged VLAN;"
357 "ROPE:accept unicast hash\n\n"
358 " BAM:accepts broadcast packets;"
359 "MPE:accepts all multicast packets\n\n"
360 " Enable/Disable a VF receive mode of a port\n\n"
362 "set port (port_id) queue (queue_id) rate (rate_num)\n"
363 " Set rate limit for a queue of a port\n\n"
365 "set port (port_id) vf (vf_id) rate (rate_num) "
366 "queue_mask (queue_mask_value)\n"
367 " Set rate limit for queues in VF of a port\n\n"
369 "set port (port_id) mirror-rule (rule_id)"
370 "(pool-mirror|vlan-mirror)\n"
371 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
372 " Set pool or vlan type mirror rule on a port.\n"
373 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
374 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
377 "set port (port_id) mirror-rule (rule_id)"
378 " (uplink-mirror|downlink-mirror) dst-pool"
379 " (pool_id) (on|off)\n"
380 " Set uplink or downlink type mirror rule on a port.\n"
381 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
382 " 0 on' enable mirror income traffic to pool 0.\n\n"
384 "reset port (port_id) mirror-rule (rule_id)\n"
385 " Reset a mirror rule.\n\n"
387 "set flush_rx (on|off)\n"
388 " Flush (default) or don't flush RX streams before"
389 " forwarding. Mainly used with PCAP drivers.\n\n"
391 #ifdef RTE_NIC_BYPASS
392 "set bypass mode (normal|bypass|isolate) (port_id)\n"
393 " Set the bypass mode for the lowest port on bypass enabled"
396 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
397 "mode (normal|bypass|isolate) (port_id)\n"
398 " Set the event required to initiate specified bypass mode for"
399 " the lowest port on a bypass enabled NIC where:\n"
400 " timeout = enable bypass after watchdog timeout.\n"
401 " os_on = enable bypass when OS/board is powered on.\n"
402 " os_off = enable bypass when OS/board is powered off.\n"
403 " power_on = enable bypass when power supply is turned on.\n"
404 " power_off = enable bypass when power supply is turned off."
407 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
408 " Set the bypass watchdog timeout to 'n' seconds"
409 " where 0 = instant.\n\n"
411 "show bypass config (port_id)\n"
412 " Show the bypass configuration for a bypass enabled NIC"
413 " using the lowest port on the NIC.\n\n"
416 , list_pkt_forwarding_modes()
421 if (show_all || !strcmp(res->section, "flowdir")) {
426 "Flow director mode:\n"
427 "-------------------\n\n"
429 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
430 " src (src_ip_address) (src_port)"
431 " dst (dst_ip_address) (dst_port)"
432 " flexbytes (flexbytes_values) vlan (vlan_id)"
433 " queue (queue_id)\n"
434 " Add a signature filter.\n\n"
436 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
437 " src (src_ip_address) (src_port)"
438 " dst (dst_ip_address) (dst_port)"
439 " flexbytes (flexbytes_values) vlan (vlan_id)"
440 " queue (queue_id)\n"
441 " Update a signature filter.\n\n"
443 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
444 " src (src_ip_address) (src_port)"
445 " dst (dst_ip_address) (dst_port)"
446 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
447 " Remove a signature filter.\n\n"
449 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
450 " src (src_ip_address) (src_port)"
451 " dst (dst_ip_address) (dst_port)"
452 " flexbytes (flexbytes_values) vlan (vlan_id)"
453 " queue (queue_id) soft (soft_id)\n"
454 " Add a perfect filter.\n\n"
456 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
457 " src (src_ip_address) (src_port)"
458 " dst (dst_ip_address) (dst_port)"
459 " flexbytes (flexbytes_values) vlan (vlan_id)"
460 " queue (queue_id)\n"
461 " Update a perfect filter.\n\n"
463 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
464 " src (src_ip_address) (src_port)"
465 " dst (dst_ip_address) (dst_port)"
466 " flexbytes (flexbytes_values) vlan (vlan_id)"
468 " Remove a perfect filter.\n\n"
470 "set_masks_filter (port_id) only_ip_flow (0|1)"
471 " src_mask (ip_src_mask) (src_port_mask)"
472 " dst_mask (ip_dst_mask) (dst_port_mask)"
473 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
474 " Set IPv4 filter masks.\n\n"
476 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
477 " src_mask (ip_src_mask) (src_port_mask)"
478 " dst_mask (ip_dst_mask) (dst_port_mask)"
479 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
480 " compare_dst (0|1)\n"
481 " Set IPv6 filter masks.\n\n"
485 if (show_all || !strcmp(res->section, "ports")) {
491 "----------------\n\n"
493 "port start (port_id|all)\n"
494 " Start all ports or port_id.\n\n"
496 "port stop (port_id|all)\n"
497 " Stop all ports or port_id.\n\n"
499 "port close (port_id|all)\n"
500 " Close all ports or port_id.\n\n"
502 "port config (port_id|all) speed (10|100|1000|10000|auto)"
503 " duplex (half|full|auto)\n"
504 " Set speed and duplex for all ports or port_id\n\n"
506 "port config all (rxq|txq|rxd|txd) (value)\n"
507 " Set number for rxq/txq/rxd/txd.\n\n"
509 "port config all max-pkt-len (value)\n"
510 " Set the max packet length.\n\n"
512 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
514 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
517 "port config all rss (ip|udp|none)\n"
518 " Set the RSS mode.\n\n"
520 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
521 " Set the RSS redirection table.\n\n"
523 "port config (port_id) dcb vt (on|off) (traffic_class)"
525 " Set the DCB mode.\n\n"
527 "port config all burst (value)\n"
528 " Set the number of packets per burst.\n\n"
530 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
532 " Set the ring prefetch/host/writeback threshold"
533 " for tx/rx queue.\n\n"
535 "port config all (txfreet|txrst|rxfreet) (value)\n"
536 " Set free threshold for rx/tx, or set"
537 " tx rs bit threshold.\n\n"
538 "port config mtu X value\n"
539 " Set the MTU of port X to a given value\n\n"
543 if (show_all || !strcmp(res->section, "registers")) {
551 "read reg (port_id) (address)\n"
552 " Display value of a port register.\n\n"
554 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
555 " Display a port register bit field.\n\n"
557 "read regbit (port_id) (address) (bit_x)\n"
558 " Display a single port register bit.\n\n"
560 "write reg (port_id) (address) (value)\n"
561 " Set value of a port register.\n\n"
563 "write regfield (port_id) (address) (bit_x) (bit_y)"
565 " Set bit field of a port register.\n\n"
567 "write regbit (port_id) (address) (bit_x) (value)\n"
568 " Set single bit value of a port register.\n\n"
571 if (show_all || !strcmp(res->section, "filters")) {
579 "add_ethertype_filter (port_id) ethertype (eth_value)"
580 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
581 " add an ethertype filter.\n\n"
583 "remove_ethertype_filter (port_id) index (idx)\n"
584 " remove an ethertype filter.\n\n"
586 "get_ethertype_filter (port_id) index (idx)\n"
587 " get info of a ethertype filter.\n\n"
589 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
590 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
591 " queue (queue_id) index (idx)\n"
592 " add a 2tuple filter.\n\n"
594 "remove_2tuple_filter (port_id) index (idx)\n"
595 " remove a 2tuple filter.\n\n"
597 "get_2tuple_filter (port_id) index (idx)\n"
598 " get info of a 2tuple filter.\n\n"
600 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
601 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
602 " mask (mask_value) flags (flags_value) priority (prio_value)"
603 " queue (queue_id) index (idx)\n"
604 " add a 5tuple filter.\n\n"
606 "remove_5tuple_filter (port_id) index (idx)\n"
607 " remove a 5tuple filter.\n\n"
609 "get_5tuple_filter (port_id) index (idx)\n"
610 " get info of a 5tuple filter.\n\n"
612 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
613 " add syn filter.\n\n"
615 "remove_syn_filter (port_id)"
616 " remove syn filter.\n\n"
618 "get_syn_filter (port_id) "
619 " get syn filter info.\n\n"
621 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
622 " priority (prio_value) queue (queue_id) index (idx)\n"
623 " add a flex filter.\n\n"
625 "remove_flex_filter (port_id) index (idx)\n"
626 " remove a flex filter.\n\n"
628 "get_flex_filter (port_id) index (idx)\n"
629 " get info of a flex filter.\n\n"
634 cmdline_parse_token_string_t cmd_help_long_help =
635 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
637 cmdline_parse_token_string_t cmd_help_long_section =
638 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
639 "all#control#display#config#flowdir#"
640 "ports#registers#filters");
642 cmdline_parse_inst_t cmd_help_long = {
643 .f = cmd_help_long_parsed,
645 .help_str = "show help",
647 (void *)&cmd_help_long_help,
648 (void *)&cmd_help_long_section,
654 /* *** start/stop/close all ports *** */
655 struct cmd_operate_port_result {
656 cmdline_fixed_string_t keyword;
657 cmdline_fixed_string_t name;
658 cmdline_fixed_string_t value;
661 static void cmd_operate_port_parsed(void *parsed_result,
662 __attribute__((unused)) struct cmdline *cl,
663 __attribute__((unused)) void *data)
665 struct cmd_operate_port_result *res = parsed_result;
667 if (!strcmp(res->name, "start"))
668 start_port(RTE_PORT_ALL);
669 else if (!strcmp(res->name, "stop"))
670 stop_port(RTE_PORT_ALL);
671 else if (!strcmp(res->name, "close"))
672 close_port(RTE_PORT_ALL);
674 printf("Unknown parameter\n");
677 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
678 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
680 cmdline_parse_token_string_t cmd_operate_port_all_port =
681 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
683 cmdline_parse_token_string_t cmd_operate_port_all_all =
684 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
686 cmdline_parse_inst_t cmd_operate_port = {
687 .f = cmd_operate_port_parsed,
689 .help_str = "port start|stop|close all: start/stop/close all ports",
691 (void *)&cmd_operate_port_all_cmd,
692 (void *)&cmd_operate_port_all_port,
693 (void *)&cmd_operate_port_all_all,
698 /* *** start/stop/close specific port *** */
699 struct cmd_operate_specific_port_result {
700 cmdline_fixed_string_t keyword;
701 cmdline_fixed_string_t name;
705 static void cmd_operate_specific_port_parsed(void *parsed_result,
706 __attribute__((unused)) struct cmdline *cl,
707 __attribute__((unused)) void *data)
709 struct cmd_operate_specific_port_result *res = parsed_result;
711 if (!strcmp(res->name, "start"))
712 start_port(res->value);
713 else if (!strcmp(res->name, "stop"))
714 stop_port(res->value);
715 else if (!strcmp(res->name, "close"))
716 close_port(res->value);
718 printf("Unknown parameter\n");
721 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
722 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
724 cmdline_parse_token_string_t cmd_operate_specific_port_port =
725 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
726 name, "start#stop#close");
727 cmdline_parse_token_num_t cmd_operate_specific_port_id =
728 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
731 cmdline_parse_inst_t cmd_operate_specific_port = {
732 .f = cmd_operate_specific_port_parsed,
734 .help_str = "port start|stop|close X: start/stop/close port X",
736 (void *)&cmd_operate_specific_port_cmd,
737 (void *)&cmd_operate_specific_port_port,
738 (void *)&cmd_operate_specific_port_id,
743 /* *** configure speed for all ports *** */
744 struct cmd_config_speed_all {
745 cmdline_fixed_string_t port;
746 cmdline_fixed_string_t keyword;
747 cmdline_fixed_string_t all;
748 cmdline_fixed_string_t item1;
749 cmdline_fixed_string_t item2;
750 cmdline_fixed_string_t value1;
751 cmdline_fixed_string_t value2;
755 cmd_config_speed_all_parsed(void *parsed_result,
756 __attribute__((unused)) struct cmdline *cl,
757 __attribute__((unused)) void *data)
759 struct cmd_config_speed_all *res = parsed_result;
760 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
761 uint16_t link_duplex = 0;
764 if (!all_ports_stopped()) {
765 printf("Please stop all ports first\n");
769 if (!strcmp(res->value1, "10"))
770 link_speed = ETH_LINK_SPEED_10;
771 else if (!strcmp(res->value1, "100"))
772 link_speed = ETH_LINK_SPEED_100;
773 else if (!strcmp(res->value1, "1000"))
774 link_speed = ETH_LINK_SPEED_1000;
775 else if (!strcmp(res->value1, "10000"))
776 link_speed = ETH_LINK_SPEED_10000;
777 else if (!strcmp(res->value1, "auto"))
778 link_speed = ETH_LINK_SPEED_AUTONEG;
780 printf("Unknown parameter\n");
784 if (!strcmp(res->value2, "half"))
785 link_duplex = ETH_LINK_HALF_DUPLEX;
786 else if (!strcmp(res->value2, "full"))
787 link_duplex = ETH_LINK_FULL_DUPLEX;
788 else if (!strcmp(res->value2, "auto"))
789 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
791 printf("Unknown parameter\n");
795 for (pid = 0; pid < nb_ports; pid++) {
796 ports[pid].dev_conf.link_speed = link_speed;
797 ports[pid].dev_conf.link_duplex = link_duplex;
800 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
803 cmdline_parse_token_string_t cmd_config_speed_all_port =
804 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
805 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
806 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
808 cmdline_parse_token_string_t cmd_config_speed_all_all =
809 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
810 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
811 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
812 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
813 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
814 "10#100#1000#10000#auto");
815 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
816 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
817 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
818 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
821 cmdline_parse_inst_t cmd_config_speed_all = {
822 .f = cmd_config_speed_all_parsed,
824 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
827 (void *)&cmd_config_speed_all_port,
828 (void *)&cmd_config_speed_all_keyword,
829 (void *)&cmd_config_speed_all_all,
830 (void *)&cmd_config_speed_all_item1,
831 (void *)&cmd_config_speed_all_value1,
832 (void *)&cmd_config_speed_all_item2,
833 (void *)&cmd_config_speed_all_value2,
838 /* *** configure speed for specific port *** */
839 struct cmd_config_speed_specific {
840 cmdline_fixed_string_t port;
841 cmdline_fixed_string_t keyword;
843 cmdline_fixed_string_t item1;
844 cmdline_fixed_string_t item2;
845 cmdline_fixed_string_t value1;
846 cmdline_fixed_string_t value2;
850 cmd_config_speed_specific_parsed(void *parsed_result,
851 __attribute__((unused)) struct cmdline *cl,
852 __attribute__((unused)) void *data)
854 struct cmd_config_speed_specific *res = parsed_result;
855 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
856 uint16_t link_duplex = 0;
858 if (!all_ports_stopped()) {
859 printf("Please stop all ports first\n");
863 if (res->id >= nb_ports) {
864 printf("Port id %d must be less than %d\n", res->id, nb_ports);
868 if (!strcmp(res->value1, "10"))
869 link_speed = ETH_LINK_SPEED_10;
870 else if (!strcmp(res->value1, "100"))
871 link_speed = ETH_LINK_SPEED_100;
872 else if (!strcmp(res->value1, "1000"))
873 link_speed = ETH_LINK_SPEED_1000;
874 else if (!strcmp(res->value1, "10000"))
875 link_speed = ETH_LINK_SPEED_10000;
876 else if (!strcmp(res->value1, "auto"))
877 link_speed = ETH_LINK_SPEED_AUTONEG;
879 printf("Unknown parameter\n");
883 if (!strcmp(res->value2, "half"))
884 link_duplex = ETH_LINK_HALF_DUPLEX;
885 else if (!strcmp(res->value2, "full"))
886 link_duplex = ETH_LINK_FULL_DUPLEX;
887 else if (!strcmp(res->value2, "auto"))
888 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
890 printf("Unknown parameter\n");
894 ports[res->id].dev_conf.link_speed = link_speed;
895 ports[res->id].dev_conf.link_duplex = link_duplex;
897 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
901 cmdline_parse_token_string_t cmd_config_speed_specific_port =
902 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
904 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
905 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
907 cmdline_parse_token_num_t cmd_config_speed_specific_id =
908 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
909 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
910 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
912 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
913 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
914 "10#100#1000#10000#auto");
915 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
916 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
918 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
919 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
922 cmdline_parse_inst_t cmd_config_speed_specific = {
923 .f = cmd_config_speed_specific_parsed,
925 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
928 (void *)&cmd_config_speed_specific_port,
929 (void *)&cmd_config_speed_specific_keyword,
930 (void *)&cmd_config_speed_specific_id,
931 (void *)&cmd_config_speed_specific_item1,
932 (void *)&cmd_config_speed_specific_value1,
933 (void *)&cmd_config_speed_specific_item2,
934 (void *)&cmd_config_speed_specific_value2,
939 /* *** configure txq/rxq, txd/rxd *** */
940 struct cmd_config_rx_tx {
941 cmdline_fixed_string_t port;
942 cmdline_fixed_string_t keyword;
943 cmdline_fixed_string_t all;
944 cmdline_fixed_string_t name;
949 cmd_config_rx_tx_parsed(void *parsed_result,
950 __attribute__((unused)) struct cmdline *cl,
951 __attribute__((unused)) void *data)
953 struct cmd_config_rx_tx *res = parsed_result;
955 if (!all_ports_stopped()) {
956 printf("Please stop all ports first\n");
960 if (!strcmp(res->name, "rxq")) {
961 if (res->value <= 0) {
962 printf("rxq %d invalid - must be > 0\n", res->value);
967 else if (!strcmp(res->name, "txq")) {
968 if (res->value <= 0) {
969 printf("txq %d invalid - must be > 0\n", res->value);
974 else if (!strcmp(res->name, "rxd")) {
975 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
976 printf("rxd %d invalid - must be > 0 && <= %d\n",
977 res->value, RTE_TEST_RX_DESC_MAX);
981 } else if (!strcmp(res->name, "txd")) {
982 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
983 printf("txd %d invalid - must be > 0 && <= %d\n",
984 res->value, RTE_TEST_TX_DESC_MAX);
989 printf("Unknown parameter\n");
995 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
998 cmdline_parse_token_string_t cmd_config_rx_tx_port =
999 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1000 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1001 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1002 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1003 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1004 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1005 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1007 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1008 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1010 cmdline_parse_inst_t cmd_config_rx_tx = {
1011 .f = cmd_config_rx_tx_parsed,
1013 .help_str = "port config all rxq|txq|rxd|txd value",
1015 (void *)&cmd_config_rx_tx_port,
1016 (void *)&cmd_config_rx_tx_keyword,
1017 (void *)&cmd_config_rx_tx_all,
1018 (void *)&cmd_config_rx_tx_name,
1019 (void *)&cmd_config_rx_tx_value,
1024 /* *** config max packet length *** */
1025 struct cmd_config_max_pkt_len_result {
1026 cmdline_fixed_string_t port;
1027 cmdline_fixed_string_t keyword;
1028 cmdline_fixed_string_t all;
1029 cmdline_fixed_string_t name;
1034 cmd_config_max_pkt_len_parsed(void *parsed_result,
1035 __attribute__((unused)) struct cmdline *cl,
1036 __attribute__((unused)) void *data)
1038 struct cmd_config_max_pkt_len_result *res = parsed_result;
1040 if (!all_ports_stopped()) {
1041 printf("Please stop all ports first\n");
1045 if (!strcmp(res->name, "max-pkt-len")) {
1046 if (res->value < ETHER_MIN_LEN) {
1047 printf("max-pkt-len can not be less than %d\n",
1051 if (res->value == rx_mode.max_rx_pkt_len)
1054 rx_mode.max_rx_pkt_len = res->value;
1055 if (res->value > ETHER_MAX_LEN)
1056 rx_mode.jumbo_frame = 1;
1058 rx_mode.jumbo_frame = 0;
1060 printf("Unknown parameter\n");
1066 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1069 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1070 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1072 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1073 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1075 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1076 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1078 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1079 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1081 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1082 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1085 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1086 .f = cmd_config_max_pkt_len_parsed,
1088 .help_str = "port config all max-pkt-len value",
1090 (void *)&cmd_config_max_pkt_len_port,
1091 (void *)&cmd_config_max_pkt_len_keyword,
1092 (void *)&cmd_config_max_pkt_len_all,
1093 (void *)&cmd_config_max_pkt_len_name,
1094 (void *)&cmd_config_max_pkt_len_value,
1099 /* *** configure port MTU *** */
1100 struct cmd_config_mtu_result {
1101 cmdline_fixed_string_t port;
1102 cmdline_fixed_string_t keyword;
1103 cmdline_fixed_string_t mtu;
1109 cmd_config_mtu_parsed(void *parsed_result,
1110 __attribute__((unused)) struct cmdline *cl,
1111 __attribute__((unused)) void *data)
1113 struct cmd_config_mtu_result *res = parsed_result;
1115 if (res->value < ETHER_MIN_LEN) {
1116 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1119 port_mtu_set(res->port_id, res->value);
1122 cmdline_parse_token_string_t cmd_config_mtu_port =
1123 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1125 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1126 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1128 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1129 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1131 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1132 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1133 cmdline_parse_token_num_t cmd_config_mtu_value =
1134 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1136 cmdline_parse_inst_t cmd_config_mtu = {
1137 .f = cmd_config_mtu_parsed,
1139 .help_str = "port config mtu value",
1141 (void *)&cmd_config_mtu_port,
1142 (void *)&cmd_config_mtu_keyword,
1143 (void *)&cmd_config_mtu_mtu,
1144 (void *)&cmd_config_mtu_port_id,
1145 (void *)&cmd_config_mtu_value,
1150 /* *** configure rx mode *** */
1151 struct cmd_config_rx_mode_flag {
1152 cmdline_fixed_string_t port;
1153 cmdline_fixed_string_t keyword;
1154 cmdline_fixed_string_t all;
1155 cmdline_fixed_string_t name;
1156 cmdline_fixed_string_t value;
1160 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1161 __attribute__((unused)) struct cmdline *cl,
1162 __attribute__((unused)) void *data)
1164 struct cmd_config_rx_mode_flag *res = parsed_result;
1166 if (!all_ports_stopped()) {
1167 printf("Please stop all ports first\n");
1171 if (!strcmp(res->name, "crc-strip")) {
1172 if (!strcmp(res->value, "on"))
1173 rx_mode.hw_strip_crc = 1;
1174 else if (!strcmp(res->value, "off"))
1175 rx_mode.hw_strip_crc = 0;
1177 printf("Unknown parameter\n");
1180 } else if (!strcmp(res->name, "rx-cksum")) {
1181 if (!strcmp(res->value, "on"))
1182 rx_mode.hw_ip_checksum = 1;
1183 else if (!strcmp(res->value, "off"))
1184 rx_mode.hw_ip_checksum = 0;
1186 printf("Unknown parameter\n");
1189 } else if (!strcmp(res->name, "hw-vlan")) {
1190 if (!strcmp(res->value, "on")) {
1191 rx_mode.hw_vlan_filter = 1;
1192 rx_mode.hw_vlan_strip = 1;
1194 else if (!strcmp(res->value, "off")) {
1195 rx_mode.hw_vlan_filter = 0;
1196 rx_mode.hw_vlan_strip = 0;
1199 printf("Unknown parameter\n");
1202 } else if (!strcmp(res->name, "drop-en")) {
1203 if (!strcmp(res->value, "on"))
1205 else if (!strcmp(res->value, "off"))
1208 printf("Unknown parameter\n");
1212 printf("Unknown parameter\n");
1218 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1221 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1222 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1223 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1224 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1226 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1227 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1228 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1229 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1230 "crc-strip#rx-cksum#hw-vlan");
1231 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1232 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1235 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1236 .f = cmd_config_rx_mode_flag_parsed,
1238 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1240 (void *)&cmd_config_rx_mode_flag_port,
1241 (void *)&cmd_config_rx_mode_flag_keyword,
1242 (void *)&cmd_config_rx_mode_flag_all,
1243 (void *)&cmd_config_rx_mode_flag_name,
1244 (void *)&cmd_config_rx_mode_flag_value,
1249 /* *** configure rss *** */
1250 struct cmd_config_rss {
1251 cmdline_fixed_string_t port;
1252 cmdline_fixed_string_t keyword;
1253 cmdline_fixed_string_t all;
1254 cmdline_fixed_string_t name;
1255 cmdline_fixed_string_t value;
1259 cmd_config_rss_parsed(void *parsed_result,
1260 __attribute__((unused)) struct cmdline *cl,
1261 __attribute__((unused)) void *data)
1263 struct cmd_config_rss *res = parsed_result;
1264 struct rte_eth_rss_conf rss_conf;
1267 if (!strcmp(res->value, "ip"))
1268 rss_conf.rss_hf = ETH_RSS_IP;
1269 else if (!strcmp(res->value, "udp"))
1270 rss_conf.rss_hf = ETH_RSS_UDP;
1271 else if (!strcmp(res->value, "none"))
1272 rss_conf.rss_hf = 0;
1274 printf("Unknown parameter\n");
1277 rss_conf.rss_key = NULL;
1278 for (i = 0; i < rte_eth_dev_count(); i++)
1279 rte_eth_dev_rss_hash_update(i, &rss_conf);
1282 cmdline_parse_token_string_t cmd_config_rss_port =
1283 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1284 cmdline_parse_token_string_t cmd_config_rss_keyword =
1285 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1286 cmdline_parse_token_string_t cmd_config_rss_all =
1287 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1288 cmdline_parse_token_string_t cmd_config_rss_name =
1289 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1290 cmdline_parse_token_string_t cmd_config_rss_value =
1291 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1293 cmdline_parse_inst_t cmd_config_rss = {
1294 .f = cmd_config_rss_parsed,
1296 .help_str = "port config all rss ip|udp|none",
1298 (void *)&cmd_config_rss_port,
1299 (void *)&cmd_config_rss_keyword,
1300 (void *)&cmd_config_rss_all,
1301 (void *)&cmd_config_rss_name,
1302 (void *)&cmd_config_rss_value,
1307 /* *** configure rss hash key *** */
1308 struct cmd_config_rss_hash_key {
1309 cmdline_fixed_string_t port;
1310 cmdline_fixed_string_t config;
1312 cmdline_fixed_string_t rss_hash_key;
1313 cmdline_fixed_string_t key;
1316 #define RSS_HASH_KEY_LENGTH 40
1318 hexa_digit_to_value(char hexa_digit)
1320 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1321 return (uint8_t) (hexa_digit - '0');
1322 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1323 return (uint8_t) ((hexa_digit - 'a') + 10);
1324 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1325 return (uint8_t) ((hexa_digit - 'A') + 10);
1326 /* Invalid hexa digit */
1331 parse_and_check_key_hexa_digit(char *key, int idx)
1335 hexa_v = hexa_digit_to_value(key[idx]);
1337 printf("invalid key: character %c at position %d is not a "
1338 "valid hexa digit\n", key[idx], idx);
1343 cmd_config_rss_hash_key_parsed(void *parsed_result,
1344 __attribute__((unused)) struct cmdline *cl,
1345 __attribute__((unused)) void *data)
1347 struct cmd_config_rss_hash_key *res = parsed_result;
1348 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1353 /* Check the length of the RSS hash key */
1354 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1355 printf("key length: %d invalid - key must be a string of %d"
1356 "hexa-decimal numbers\n", (int) strlen(res->key),
1357 RSS_HASH_KEY_LENGTH * 2);
1360 /* Translate RSS hash key into binary representation */
1361 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1362 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1365 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1368 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1370 port_rss_hash_key_update(res->port_id, hash_key);
1373 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1374 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1375 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1376 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1378 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1379 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1380 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1381 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1382 rss_hash_key, "rss-hash-key");
1383 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1384 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1386 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1387 .f = cmd_config_rss_hash_key_parsed,
1389 .help_str = "port config X rss-hash-key 80 hexa digits",
1391 (void *)&cmd_config_rss_hash_key_port,
1392 (void *)&cmd_config_rss_hash_key_config,
1393 (void *)&cmd_config_rss_hash_key_port_id,
1394 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1395 (void *)&cmd_config_rss_hash_key_value,
1400 /* *** Configure RSS RETA *** */
1401 struct cmd_config_rss_reta {
1402 cmdline_fixed_string_t port;
1403 cmdline_fixed_string_t keyword;
1405 cmdline_fixed_string_t name;
1406 cmdline_fixed_string_t list_name;
1407 cmdline_fixed_string_t list_of_items;
1411 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1418 const char *p, *p0 = str;
1425 unsigned long int_fld[_NUM_FLD];
1426 char *str_fld[_NUM_FLD];
1428 while ((p = strchr(p0,'(')) != NULL) {
1430 if((p0 = strchr(p,')')) == NULL)
1434 if(size >= sizeof(s))
1437 snprintf(s, sizeof(s), "%.*s", size, p);
1438 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1440 for (i = 0; i < _NUM_FLD; i++) {
1442 int_fld[i] = strtoul(str_fld[i], &end, 0);
1443 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1447 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1448 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1450 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1451 printf("Invalid RETA hash index=%d",hash_index);
1455 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1456 reta_conf->mask_lo |= (1ULL << hash_index);
1458 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1460 reta_conf->reta[hash_index] = nb_queue;
1467 cmd_set_rss_reta_parsed(void *parsed_result,
1468 __attribute__((unused)) struct cmdline *cl,
1469 __attribute__((unused)) void *data)
1472 struct rte_eth_rss_reta reta_conf;
1473 struct cmd_config_rss_reta *res = parsed_result;
1475 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1476 if (!strcmp(res->list_name, "reta")) {
1477 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1478 printf("Invalid RSS Redirection Table config entered\n");
1481 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1483 printf("Bad redirection table parameter, return code = %d \n",ret);
1487 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1488 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1489 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1491 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1492 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1493 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1495 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1496 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1497 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1500 cmdline_parse_inst_t cmd_config_rss_reta = {
1501 .f = cmd_set_rss_reta_parsed,
1503 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1505 (void *)&cmd_config_rss_reta_port,
1506 (void *)&cmd_config_rss_reta_keyword,
1507 (void *)&cmd_config_rss_reta_port_id,
1508 (void *)&cmd_config_rss_reta_name,
1509 (void *)&cmd_config_rss_reta_list_name,
1510 (void *)&cmd_config_rss_reta_list_of_items,
1515 /* *** SHOW PORT RETA INFO *** */
1516 struct cmd_showport_reta {
1517 cmdline_fixed_string_t show;
1518 cmdline_fixed_string_t port;
1520 cmdline_fixed_string_t rss;
1521 cmdline_fixed_string_t reta;
1526 static void cmd_showport_reta_parsed(void *parsed_result,
1527 __attribute__((unused)) struct cmdline *cl,
1528 __attribute__((unused)) void *data)
1530 struct cmd_showport_reta *res = parsed_result;
1531 struct rte_eth_rss_reta reta_conf;
1533 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1534 printf("Invalid RSS Redirection Table config entered\n");
1538 reta_conf.mask_lo = res->mask_lo;
1539 reta_conf.mask_hi = res->mask_hi;
1541 port_rss_reta_info(res->port_id,&reta_conf);
1544 cmdline_parse_token_string_t cmd_showport_reta_show =
1545 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1546 cmdline_parse_token_string_t cmd_showport_reta_port =
1547 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1548 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1549 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1550 cmdline_parse_token_string_t cmd_showport_reta_rss =
1551 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1552 cmdline_parse_token_string_t cmd_showport_reta_reta =
1553 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1554 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1555 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1556 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1557 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1559 cmdline_parse_inst_t cmd_showport_reta = {
1560 .f = cmd_showport_reta_parsed,
1562 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1563 (mask_lo and mask_hi is UINT64)",
1565 (void *)&cmd_showport_reta_show,
1566 (void *)&cmd_showport_reta_port,
1567 (void *)&cmd_showport_reta_port_id,
1568 (void *)&cmd_showport_reta_rss,
1569 (void *)&cmd_showport_reta_reta,
1570 (void *)&cmd_showport_reta_mask_lo,
1571 (void *)&cmd_showport_reta_mask_hi,
1576 /* *** Show RSS hash configuration *** */
1577 struct cmd_showport_rss_hash {
1578 cmdline_fixed_string_t show;
1579 cmdline_fixed_string_t port;
1581 cmdline_fixed_string_t rss_hash;
1582 cmdline_fixed_string_t key; /* optional argument */
1585 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1586 __attribute__((unused)) struct cmdline *cl,
1589 struct cmd_showport_rss_hash *res = parsed_result;
1591 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1594 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1595 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1596 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1597 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1598 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1599 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1600 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1601 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1603 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1604 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1606 cmdline_parse_inst_t cmd_showport_rss_hash = {
1607 .f = cmd_showport_rss_hash_parsed,
1609 .help_str = "show port X rss-hash (X = port number)\n",
1611 (void *)&cmd_showport_rss_hash_show,
1612 (void *)&cmd_showport_rss_hash_port,
1613 (void *)&cmd_showport_rss_hash_port_id,
1614 (void *)&cmd_showport_rss_hash_rss_hash,
1619 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1620 .f = cmd_showport_rss_hash_parsed,
1622 .help_str = "show port X rss-hash key (X = port number)\n",
1624 (void *)&cmd_showport_rss_hash_show,
1625 (void *)&cmd_showport_rss_hash_port,
1626 (void *)&cmd_showport_rss_hash_port_id,
1627 (void *)&cmd_showport_rss_hash_rss_hash,
1628 (void *)&cmd_showport_rss_hash_rss_key,
1633 /* *** Configure DCB *** */
1634 struct cmd_config_dcb {
1635 cmdline_fixed_string_t port;
1636 cmdline_fixed_string_t config;
1638 cmdline_fixed_string_t dcb;
1639 cmdline_fixed_string_t vt;
1640 cmdline_fixed_string_t vt_en;
1642 cmdline_fixed_string_t pfc;
1643 cmdline_fixed_string_t pfc_en;
1647 cmd_config_dcb_parsed(void *parsed_result,
1648 __attribute__((unused)) struct cmdline *cl,
1649 __attribute__((unused)) void *data)
1651 struct cmd_config_dcb *res = parsed_result;
1652 struct dcb_config dcb_conf;
1653 portid_t port_id = res->port_id;
1654 struct rte_port *port;
1656 port = &ports[port_id];
1657 /** Check if the port is not started **/
1658 if (port->port_status != RTE_PORT_STOPPED) {
1659 printf("Please stop port %d first\n",port_id);
1663 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1664 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1665 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1669 /* DCB in VT mode */
1670 if (!strncmp(res->vt_en, "on",2))
1671 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1673 dcb_conf.dcb_mode = DCB_ENABLED;
1675 if (!strncmp(res->pfc_en, "on",2)) {
1676 dcb_conf.pfc_en = 1;
1679 dcb_conf.pfc_en = 0;
1681 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1682 printf("Cannot initialize network ports\n");
1686 cmd_reconfig_device_queue(port_id, 1, 1);
1689 cmdline_parse_token_string_t cmd_config_dcb_port =
1690 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1691 cmdline_parse_token_string_t cmd_config_dcb_config =
1692 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1693 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1694 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1695 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1696 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1697 cmdline_parse_token_string_t cmd_config_dcb_vt =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1699 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1700 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1701 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1702 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1703 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1704 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1705 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1706 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1708 cmdline_parse_inst_t cmd_config_dcb = {
1709 .f = cmd_config_dcb_parsed,
1711 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1713 (void *)&cmd_config_dcb_port,
1714 (void *)&cmd_config_dcb_config,
1715 (void *)&cmd_config_dcb_port_id,
1716 (void *)&cmd_config_dcb_dcb,
1717 (void *)&cmd_config_dcb_vt,
1718 (void *)&cmd_config_dcb_vt_en,
1719 (void *)&cmd_config_dcb_num_tcs,
1720 (void *)&cmd_config_dcb_pfc,
1721 (void *)&cmd_config_dcb_pfc_en,
1726 /* *** configure number of packets per burst *** */
1727 struct cmd_config_burst {
1728 cmdline_fixed_string_t port;
1729 cmdline_fixed_string_t keyword;
1730 cmdline_fixed_string_t all;
1731 cmdline_fixed_string_t name;
1736 cmd_config_burst_parsed(void *parsed_result,
1737 __attribute__((unused)) struct cmdline *cl,
1738 __attribute__((unused)) void *data)
1740 struct cmd_config_burst *res = parsed_result;
1742 if (!all_ports_stopped()) {
1743 printf("Please stop all ports first\n");
1747 if (!strcmp(res->name, "burst")) {
1748 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1749 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1752 nb_pkt_per_burst = res->value;
1754 printf("Unknown parameter\n");
1760 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1763 cmdline_parse_token_string_t cmd_config_burst_port =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1765 cmdline_parse_token_string_t cmd_config_burst_keyword =
1766 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1767 cmdline_parse_token_string_t cmd_config_burst_all =
1768 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1769 cmdline_parse_token_string_t cmd_config_burst_name =
1770 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1771 cmdline_parse_token_num_t cmd_config_burst_value =
1772 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1774 cmdline_parse_inst_t cmd_config_burst = {
1775 .f = cmd_config_burst_parsed,
1777 .help_str = "port config all burst value",
1779 (void *)&cmd_config_burst_port,
1780 (void *)&cmd_config_burst_keyword,
1781 (void *)&cmd_config_burst_all,
1782 (void *)&cmd_config_burst_name,
1783 (void *)&cmd_config_burst_value,
1788 /* *** configure rx/tx queues *** */
1789 struct cmd_config_thresh {
1790 cmdline_fixed_string_t port;
1791 cmdline_fixed_string_t keyword;
1792 cmdline_fixed_string_t all;
1793 cmdline_fixed_string_t name;
1798 cmd_config_thresh_parsed(void *parsed_result,
1799 __attribute__((unused)) struct cmdline *cl,
1800 __attribute__((unused)) void *data)
1802 struct cmd_config_thresh *res = parsed_result;
1804 if (!all_ports_stopped()) {
1805 printf("Please stop all ports first\n");
1809 if (!strcmp(res->name, "txpt"))
1810 tx_thresh.pthresh = res->value;
1811 else if(!strcmp(res->name, "txht"))
1812 tx_thresh.hthresh = res->value;
1813 else if(!strcmp(res->name, "txwt"))
1814 tx_thresh.wthresh = res->value;
1815 else if(!strcmp(res->name, "rxpt"))
1816 rx_thresh.pthresh = res->value;
1817 else if(!strcmp(res->name, "rxht"))
1818 rx_thresh.hthresh = res->value;
1819 else if(!strcmp(res->name, "rxwt"))
1820 rx_thresh.wthresh = res->value;
1822 printf("Unknown parameter\n");
1828 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1831 cmdline_parse_token_string_t cmd_config_thresh_port =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1833 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1834 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1835 cmdline_parse_token_string_t cmd_config_thresh_all =
1836 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1837 cmdline_parse_token_string_t cmd_config_thresh_name =
1838 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1839 "txpt#txht#txwt#rxpt#rxht#rxwt");
1840 cmdline_parse_token_num_t cmd_config_thresh_value =
1841 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1843 cmdline_parse_inst_t cmd_config_thresh = {
1844 .f = cmd_config_thresh_parsed,
1846 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1848 (void *)&cmd_config_thresh_port,
1849 (void *)&cmd_config_thresh_keyword,
1850 (void *)&cmd_config_thresh_all,
1851 (void *)&cmd_config_thresh_name,
1852 (void *)&cmd_config_thresh_value,
1857 /* *** configure free/rs threshold *** */
1858 struct cmd_config_threshold {
1859 cmdline_fixed_string_t port;
1860 cmdline_fixed_string_t keyword;
1861 cmdline_fixed_string_t all;
1862 cmdline_fixed_string_t name;
1867 cmd_config_threshold_parsed(void *parsed_result,
1868 __attribute__((unused)) struct cmdline *cl,
1869 __attribute__((unused)) void *data)
1871 struct cmd_config_threshold *res = parsed_result;
1873 if (!all_ports_stopped()) {
1874 printf("Please stop all ports first\n");
1878 if (!strcmp(res->name, "txfreet"))
1879 tx_free_thresh = res->value;
1880 else if (!strcmp(res->name, "txrst"))
1881 tx_rs_thresh = res->value;
1882 else if (!strcmp(res->name, "rxfreet"))
1883 rx_free_thresh = res->value;
1885 printf("Unknown parameter\n");
1891 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1894 cmdline_parse_token_string_t cmd_config_threshold_port =
1895 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1896 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1897 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1899 cmdline_parse_token_string_t cmd_config_threshold_all =
1900 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1901 cmdline_parse_token_string_t cmd_config_threshold_name =
1902 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1903 "txfreet#txrst#rxfreet");
1904 cmdline_parse_token_num_t cmd_config_threshold_value =
1905 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1907 cmdline_parse_inst_t cmd_config_threshold = {
1908 .f = cmd_config_threshold_parsed,
1910 .help_str = "port config all txfreet|txrst|rxfreet value",
1912 (void *)&cmd_config_threshold_port,
1913 (void *)&cmd_config_threshold_keyword,
1914 (void *)&cmd_config_threshold_all,
1915 (void *)&cmd_config_threshold_name,
1916 (void *)&cmd_config_threshold_value,
1922 struct cmd_stop_result {
1923 cmdline_fixed_string_t stop;
1926 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1927 __attribute__((unused)) struct cmdline *cl,
1928 __attribute__((unused)) void *data)
1930 stop_packet_forwarding();
1933 cmdline_parse_token_string_t cmd_stop_stop =
1934 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1936 cmdline_parse_inst_t cmd_stop = {
1937 .f = cmd_stop_parsed,
1939 .help_str = "stop - stop packet forwarding",
1941 (void *)&cmd_stop_stop,
1946 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1949 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1950 unsigned int *parsed_items, int check_unique_values)
1952 unsigned int nb_item;
1960 * First parse all items in the list and store their value.
1965 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1967 if ((c >= '0') && (c <= '9')) {
1968 value = (unsigned int) (value * 10 + (c - '0'));
1973 printf("character %c is not a decimal digit\n", c);
1977 printf("No valid value before comma\n");
1980 if (nb_item < max_items) {
1981 parsed_items[nb_item] = value;
1987 if (nb_item >= max_items) {
1988 printf("Number of %s = %u > %u (maximum items)\n",
1989 item_name, nb_item + 1, max_items);
1992 parsed_items[nb_item++] = value;
1993 if (! check_unique_values)
1997 * Then, check that all values in the list are differents.
1998 * No optimization here...
2000 for (i = 0; i < nb_item; i++) {
2001 for (j = i + 1; j < nb_item; j++) {
2002 if (parsed_items[j] == parsed_items[i]) {
2003 printf("duplicated %s %u at index %u and %u\n",
2004 item_name, parsed_items[i], i, j);
2012 struct cmd_set_list_result {
2013 cmdline_fixed_string_t cmd_keyword;
2014 cmdline_fixed_string_t list_name;
2015 cmdline_fixed_string_t list_of_items;
2018 static void cmd_set_list_parsed(void *parsed_result,
2019 __attribute__((unused)) struct cmdline *cl,
2020 __attribute__((unused)) void *data)
2022 struct cmd_set_list_result *res;
2024 unsigned int lcorelist[RTE_MAX_LCORE];
2025 unsigned int portlist[RTE_MAX_ETHPORTS];
2027 unsigned int nb_item;
2029 res = parsed_result;
2030 if (!strcmp(res->list_name, "corelist")) {
2031 nb_item = parse_item_list(res->list_of_items, "core",
2033 parsed_items.lcorelist, 1);
2035 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2038 if (!strcmp(res->list_name, "portlist")) {
2039 nb_item = parse_item_list(res->list_of_items, "port",
2041 parsed_items.portlist, 1);
2043 set_fwd_ports_list(parsed_items.portlist, nb_item);
2047 cmdline_parse_token_string_t cmd_set_list_keyword =
2048 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2050 cmdline_parse_token_string_t cmd_set_list_name =
2051 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2052 "corelist#portlist");
2053 cmdline_parse_token_string_t cmd_set_list_of_items =
2054 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2057 cmdline_parse_inst_t cmd_set_fwd_list = {
2058 .f = cmd_set_list_parsed,
2060 .help_str = "set corelist|portlist x[,y]*",
2062 (void *)&cmd_set_list_keyword,
2063 (void *)&cmd_set_list_name,
2064 (void *)&cmd_set_list_of_items,
2069 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2071 struct cmd_setmask_result {
2072 cmdline_fixed_string_t set;
2073 cmdline_fixed_string_t mask;
2077 static void cmd_set_mask_parsed(void *parsed_result,
2078 __attribute__((unused)) struct cmdline *cl,
2079 __attribute__((unused)) void *data)
2081 struct cmd_setmask_result *res = parsed_result;
2083 if (!strcmp(res->mask, "coremask"))
2084 set_fwd_lcores_mask(res->hexavalue);
2085 else if (!strcmp(res->mask, "portmask"))
2086 set_fwd_ports_mask(res->hexavalue);
2089 cmdline_parse_token_string_t cmd_setmask_set =
2090 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2091 cmdline_parse_token_string_t cmd_setmask_mask =
2092 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2093 "coremask#portmask");
2094 cmdline_parse_token_num_t cmd_setmask_value =
2095 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2097 cmdline_parse_inst_t cmd_set_fwd_mask = {
2098 .f = cmd_set_mask_parsed,
2100 .help_str = "set coremask|portmask hexadecimal value",
2102 (void *)&cmd_setmask_set,
2103 (void *)&cmd_setmask_mask,
2104 (void *)&cmd_setmask_value,
2110 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2112 struct cmd_set_result {
2113 cmdline_fixed_string_t set;
2114 cmdline_fixed_string_t what;
2118 static void cmd_set_parsed(void *parsed_result,
2119 __attribute__((unused)) struct cmdline *cl,
2120 __attribute__((unused)) void *data)
2122 struct cmd_set_result *res = parsed_result;
2123 if (!strcmp(res->what, "nbport"))
2124 set_fwd_ports_number(res->value);
2125 else if (!strcmp(res->what, "nbcore"))
2126 set_fwd_lcores_number(res->value);
2127 else if (!strcmp(res->what, "burst"))
2128 set_nb_pkt_per_burst(res->value);
2129 else if (!strcmp(res->what, "verbose"))
2130 set_verbose_level(res->value);
2133 cmdline_parse_token_string_t cmd_set_set =
2134 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2135 cmdline_parse_token_string_t cmd_set_what =
2136 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2137 "nbport#nbcore#burst#verbose");
2138 cmdline_parse_token_num_t cmd_set_value =
2139 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2141 cmdline_parse_inst_t cmd_set_numbers = {
2142 .f = cmd_set_parsed,
2144 .help_str = "set nbport|nbcore|burst|verbose value",
2146 (void *)&cmd_set_set,
2147 (void *)&cmd_set_what,
2148 (void *)&cmd_set_value,
2153 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2155 struct cmd_set_txpkts_result {
2156 cmdline_fixed_string_t cmd_keyword;
2157 cmdline_fixed_string_t txpkts;
2158 cmdline_fixed_string_t seg_lengths;
2162 cmd_set_txpkts_parsed(void *parsed_result,
2163 __attribute__((unused)) struct cmdline *cl,
2164 __attribute__((unused)) void *data)
2166 struct cmd_set_txpkts_result *res;
2167 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2168 unsigned int nb_segs;
2170 res = parsed_result;
2171 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2172 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2174 set_tx_pkt_segments(seg_lengths, nb_segs);
2177 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2178 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2179 cmd_keyword, "set");
2180 cmdline_parse_token_string_t cmd_set_txpkts_name =
2181 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2183 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2184 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2187 cmdline_parse_inst_t cmd_set_txpkts = {
2188 .f = cmd_set_txpkts_parsed,
2190 .help_str = "set txpkts x[,y]*",
2192 (void *)&cmd_set_txpkts_keyword,
2193 (void *)&cmd_set_txpkts_name,
2194 (void *)&cmd_set_txpkts_lengths,
2199 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2200 struct cmd_rx_vlan_filter_all_result {
2201 cmdline_fixed_string_t rx_vlan;
2202 cmdline_fixed_string_t what;
2203 cmdline_fixed_string_t all;
2208 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2209 __attribute__((unused)) struct cmdline *cl,
2210 __attribute__((unused)) void *data)
2212 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2214 if (!strcmp(res->what, "add"))
2215 rx_vlan_all_filter_set(res->port_id, 1);
2217 rx_vlan_all_filter_set(res->port_id, 0);
2220 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2221 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2222 rx_vlan, "rx_vlan");
2223 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2224 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2226 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2227 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2229 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2230 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2233 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2234 .f = cmd_rx_vlan_filter_all_parsed,
2236 .help_str = "add/remove all identifiers to/from the set of VLAN "
2237 "Identifiers filtered by a port",
2239 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2240 (void *)&cmd_rx_vlan_filter_all_what,
2241 (void *)&cmd_rx_vlan_filter_all_all,
2242 (void *)&cmd_rx_vlan_filter_all_portid,
2247 /* *** VLAN OFFLOAD SET ON A PORT *** */
2248 struct cmd_vlan_offload_result {
2249 cmdline_fixed_string_t vlan;
2250 cmdline_fixed_string_t set;
2251 cmdline_fixed_string_t what;
2252 cmdline_fixed_string_t on;
2253 cmdline_fixed_string_t port_id;
2257 cmd_vlan_offload_parsed(void *parsed_result,
2258 __attribute__((unused)) struct cmdline *cl,
2259 __attribute__((unused)) void *data)
2262 struct cmd_vlan_offload_result *res = parsed_result;
2265 portid_t port_id = 0;
2269 len = strnlen(str, STR_TOKEN_SIZE);
2271 /* Get port_id first */
2279 tmp = strtoul(str, NULL, 0);
2280 /* If port_id greater that what portid_t can represent, return */
2281 if(tmp >= RTE_MAX_ETHPORTS)
2283 port_id = (portid_t)tmp;
2285 if (!strcmp(res->on, "on"))
2290 if (!strcmp(res->what, "strip"))
2291 rx_vlan_strip_set(port_id, on);
2292 else if(!strcmp(res->what, "stripq")){
2293 uint16_t queue_id = 0;
2295 /* No queue_id, return */
2297 printf("must specify (port,queue_id)\n");
2300 tmp = strtoul(str + i + 1, NULL, 0);
2301 /* If queue_id greater that what 16-bits can represent, return */
2305 queue_id = (uint16_t)tmp;
2306 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2308 else if (!strcmp(res->what, "filter"))
2309 rx_vlan_filter_set(port_id, on);
2311 vlan_extend_set(port_id, on);
2316 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2317 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2319 cmdline_parse_token_string_t cmd_vlan_offload_set =
2320 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2322 cmdline_parse_token_string_t cmd_vlan_offload_what =
2323 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2324 what, "strip#filter#qinq#stripq");
2325 cmdline_parse_token_string_t cmd_vlan_offload_on =
2326 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2328 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2329 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2332 cmdline_parse_inst_t cmd_vlan_offload = {
2333 .f = cmd_vlan_offload_parsed,
2335 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2336 " qinq(extended) for both rx/tx sides ",
2338 (void *)&cmd_vlan_offload_vlan,
2339 (void *)&cmd_vlan_offload_set,
2340 (void *)&cmd_vlan_offload_what,
2341 (void *)&cmd_vlan_offload_on,
2342 (void *)&cmd_vlan_offload_portid,
2347 /* *** VLAN TPID SET ON A PORT *** */
2348 struct cmd_vlan_tpid_result {
2349 cmdline_fixed_string_t vlan;
2350 cmdline_fixed_string_t set;
2351 cmdline_fixed_string_t what;
2357 cmd_vlan_tpid_parsed(void *parsed_result,
2358 __attribute__((unused)) struct cmdline *cl,
2359 __attribute__((unused)) void *data)
2361 struct cmd_vlan_tpid_result *res = parsed_result;
2362 vlan_tpid_set(res->port_id, res->tp_id);
2366 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2367 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2369 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2370 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2372 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2373 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2375 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2376 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2378 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2379 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2382 cmdline_parse_inst_t cmd_vlan_tpid = {
2383 .f = cmd_vlan_tpid_parsed,
2385 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2387 (void *)&cmd_vlan_tpid_vlan,
2388 (void *)&cmd_vlan_tpid_set,
2389 (void *)&cmd_vlan_tpid_what,
2390 (void *)&cmd_vlan_tpid_tpid,
2391 (void *)&cmd_vlan_tpid_portid,
2396 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2397 struct cmd_rx_vlan_filter_result {
2398 cmdline_fixed_string_t rx_vlan;
2399 cmdline_fixed_string_t what;
2405 cmd_rx_vlan_filter_parsed(void *parsed_result,
2406 __attribute__((unused)) struct cmdline *cl,
2407 __attribute__((unused)) void *data)
2409 struct cmd_rx_vlan_filter_result *res = parsed_result;
2411 if (!strcmp(res->what, "add"))
2412 rx_vft_set(res->port_id, res->vlan_id, 1);
2414 rx_vft_set(res->port_id, res->vlan_id, 0);
2417 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2418 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2419 rx_vlan, "rx_vlan");
2420 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2421 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2423 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2424 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2426 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2427 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2430 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2431 .f = cmd_rx_vlan_filter_parsed,
2433 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2434 "Identifiers filtered by a port",
2436 (void *)&cmd_rx_vlan_filter_rx_vlan,
2437 (void *)&cmd_rx_vlan_filter_what,
2438 (void *)&cmd_rx_vlan_filter_vlanid,
2439 (void *)&cmd_rx_vlan_filter_portid,
2444 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2445 struct cmd_tx_vlan_set_result {
2446 cmdline_fixed_string_t tx_vlan;
2447 cmdline_fixed_string_t set;
2453 cmd_tx_vlan_set_parsed(void *parsed_result,
2454 __attribute__((unused)) struct cmdline *cl,
2455 __attribute__((unused)) void *data)
2457 struct cmd_tx_vlan_set_result *res = parsed_result;
2458 tx_vlan_set(res->port_id, res->vlan_id);
2461 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2462 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2463 tx_vlan, "tx_vlan");
2464 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2465 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2467 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2468 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2470 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2471 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2474 cmdline_parse_inst_t cmd_tx_vlan_set = {
2475 .f = cmd_tx_vlan_set_parsed,
2477 .help_str = "enable hardware insertion of a VLAN header with a given "
2478 "TAG Identifier in packets sent on a port",
2480 (void *)&cmd_tx_vlan_set_tx_vlan,
2481 (void *)&cmd_tx_vlan_set_set,
2482 (void *)&cmd_tx_vlan_set_vlanid,
2483 (void *)&cmd_tx_vlan_set_portid,
2488 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2489 struct cmd_tx_vlan_set_pvid_result {
2490 cmdline_fixed_string_t tx_vlan;
2491 cmdline_fixed_string_t set;
2492 cmdline_fixed_string_t pvid;
2495 cmdline_fixed_string_t mode;
2499 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2500 __attribute__((unused)) struct cmdline *cl,
2501 __attribute__((unused)) void *data)
2503 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2505 if (strcmp(res->mode, "on") == 0)
2506 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2508 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2511 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2512 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2513 tx_vlan, "tx_vlan");
2514 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2515 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2517 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2518 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2520 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2521 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2523 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2524 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2526 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2527 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2530 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2531 .f = cmd_tx_vlan_set_pvid_parsed,
2533 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2535 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2536 (void *)&cmd_tx_vlan_set_pvid_set,
2537 (void *)&cmd_tx_vlan_set_pvid_pvid,
2538 (void *)&cmd_tx_vlan_set_pvid_port_id,
2539 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2540 (void *)&cmd_tx_vlan_set_pvid_mode,
2545 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2546 struct cmd_tx_vlan_reset_result {
2547 cmdline_fixed_string_t tx_vlan;
2548 cmdline_fixed_string_t reset;
2553 cmd_tx_vlan_reset_parsed(void *parsed_result,
2554 __attribute__((unused)) struct cmdline *cl,
2555 __attribute__((unused)) void *data)
2557 struct cmd_tx_vlan_reset_result *res = parsed_result;
2559 tx_vlan_reset(res->port_id);
2562 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2563 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2564 tx_vlan, "tx_vlan");
2565 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2566 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2568 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2569 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2572 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2573 .f = cmd_tx_vlan_reset_parsed,
2575 .help_str = "disable hardware insertion of a VLAN header in packets "
2578 (void *)&cmd_tx_vlan_reset_tx_vlan,
2579 (void *)&cmd_tx_vlan_reset_reset,
2580 (void *)&cmd_tx_vlan_reset_portid,
2586 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2587 struct cmd_tx_cksum_set_result {
2588 cmdline_fixed_string_t tx_cksum;
2589 cmdline_fixed_string_t set;
2595 cmd_tx_cksum_set_parsed(void *parsed_result,
2596 __attribute__((unused)) struct cmdline *cl,
2597 __attribute__((unused)) void *data)
2599 struct cmd_tx_cksum_set_result *res = parsed_result;
2601 tx_cksum_set(res->port_id, res->cksum_mask);
2604 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2605 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2606 tx_cksum, "tx_checksum");
2607 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2608 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2610 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2611 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2613 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2614 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2617 cmdline_parse_inst_t cmd_tx_cksum_set = {
2618 .f = cmd_tx_cksum_set_parsed,
2620 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2621 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2622 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2624 (void *)&cmd_tx_cksum_set_tx_cksum,
2625 (void *)&cmd_tx_cksum_set_set,
2626 (void *)&cmd_tx_cksum_set_cksum_mask,
2627 (void *)&cmd_tx_cksum_set_portid,
2632 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2633 struct cmd_set_flush_rx {
2634 cmdline_fixed_string_t set;
2635 cmdline_fixed_string_t flush_rx;
2636 cmdline_fixed_string_t mode;
2640 cmd_set_flush_rx_parsed(void *parsed_result,
2641 __attribute__((unused)) struct cmdline *cl,
2642 __attribute__((unused)) void *data)
2644 struct cmd_set_flush_rx *res = parsed_result;
2645 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2648 cmdline_parse_token_string_t cmd_setflushrx_set =
2649 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2651 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2652 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2653 flush_rx, "flush_rx");
2654 cmdline_parse_token_string_t cmd_setflushrx_mode =
2655 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2659 cmdline_parse_inst_t cmd_set_flush_rx = {
2660 .f = cmd_set_flush_rx_parsed,
2661 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2664 (void *)&cmd_setflushrx_set,
2665 (void *)&cmd_setflushrx_flush_rx,
2666 (void *)&cmd_setflushrx_mode,
2671 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2672 struct cmd_set_link_check {
2673 cmdline_fixed_string_t set;
2674 cmdline_fixed_string_t link_check;
2675 cmdline_fixed_string_t mode;
2679 cmd_set_link_check_parsed(void *parsed_result,
2680 __attribute__((unused)) struct cmdline *cl,
2681 __attribute__((unused)) void *data)
2683 struct cmd_set_link_check *res = parsed_result;
2684 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2687 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2688 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2690 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2691 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2692 link_check, "link_check");
2693 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2694 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2698 cmdline_parse_inst_t cmd_set_link_check = {
2699 .f = cmd_set_link_check_parsed,
2700 .help_str = "set link_check on|off: enable/disable link status check "
2701 "when starting/stopping a port",
2704 (void *)&cmd_setlinkcheck_set,
2705 (void *)&cmd_setlinkcheck_link_check,
2706 (void *)&cmd_setlinkcheck_mode,
2711 #ifdef RTE_NIC_BYPASS
2712 /* *** SET NIC BYPASS MODE *** */
2713 struct cmd_set_bypass_mode_result {
2714 cmdline_fixed_string_t set;
2715 cmdline_fixed_string_t bypass;
2716 cmdline_fixed_string_t mode;
2717 cmdline_fixed_string_t value;
2722 cmd_set_bypass_mode_parsed(void *parsed_result,
2723 __attribute__((unused)) struct cmdline *cl,
2724 __attribute__((unused)) void *data)
2726 struct cmd_set_bypass_mode_result *res = parsed_result;
2727 portid_t port_id = res->port_id;
2728 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2730 if (!bypass_is_supported(port_id))
2733 if (!strcmp(res->value, "bypass"))
2734 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2735 else if (!strcmp(res->value, "isolate"))
2736 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2738 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2740 /* Set the bypass mode for the relevant port. */
2741 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2742 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2746 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2747 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2749 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2750 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2752 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2753 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2755 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2756 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2757 value, "normal#bypass#isolate");
2758 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2759 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2762 cmdline_parse_inst_t cmd_set_bypass_mode = {
2763 .f = cmd_set_bypass_mode_parsed,
2764 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2765 "Set the NIC bypass mode for port_id",
2768 (void *)&cmd_setbypass_mode_set,
2769 (void *)&cmd_setbypass_mode_bypass,
2770 (void *)&cmd_setbypass_mode_mode,
2771 (void *)&cmd_setbypass_mode_value,
2772 (void *)&cmd_setbypass_mode_port,
2777 /* *** SET NIC BYPASS EVENT *** */
2778 struct cmd_set_bypass_event_result {
2779 cmdline_fixed_string_t set;
2780 cmdline_fixed_string_t bypass;
2781 cmdline_fixed_string_t event;
2782 cmdline_fixed_string_t event_value;
2783 cmdline_fixed_string_t mode;
2784 cmdline_fixed_string_t mode_value;
2789 cmd_set_bypass_event_parsed(void *parsed_result,
2790 __attribute__((unused)) struct cmdline *cl,
2791 __attribute__((unused)) void *data)
2794 struct cmd_set_bypass_event_result *res = parsed_result;
2795 portid_t port_id = res->port_id;
2796 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2797 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2799 if (!bypass_is_supported(port_id))
2802 if (!strcmp(res->event_value, "timeout"))
2803 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2804 else if (!strcmp(res->event_value, "os_on"))
2805 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2806 else if (!strcmp(res->event_value, "os_off"))
2807 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2808 else if (!strcmp(res->event_value, "power_on"))
2809 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2810 else if (!strcmp(res->event_value, "power_off"))
2811 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2813 bypass_event = RTE_BYPASS_EVENT_NONE;
2815 if (!strcmp(res->mode_value, "bypass"))
2816 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2817 else if (!strcmp(res->mode_value, "isolate"))
2818 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2820 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2822 /* Set the watchdog timeout. */
2823 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2826 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2827 (rc = rte_eth_dev_wd_timeout_store(port_id,
2828 bypass_timeout)) != 0) {
2829 printf("Failed to set timeout value %u "
2830 "for port %d, errto code: %d.\n",
2831 bypass_timeout, port_id, rc);
2835 /* Set the bypass event to transition to bypass mode. */
2836 if (0 != rte_eth_dev_bypass_event_store(port_id,
2837 bypass_event, bypass_mode)) {
2838 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2843 cmdline_parse_token_string_t cmd_setbypass_event_set =
2844 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2846 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2847 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2849 cmdline_parse_token_string_t cmd_setbypass_event_event =
2850 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2852 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2853 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2854 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2855 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2856 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2858 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2859 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2860 mode_value, "normal#bypass#isolate");
2861 cmdline_parse_token_num_t cmd_setbypass_event_port =
2862 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2865 cmdline_parse_inst_t cmd_set_bypass_event = {
2866 .f = cmd_set_bypass_event_parsed,
2867 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2868 "mode (normal|bypass|isolate) (port_id): "
2869 "Set the NIC bypass event mode for port_id",
2872 (void *)&cmd_setbypass_event_set,
2873 (void *)&cmd_setbypass_event_bypass,
2874 (void *)&cmd_setbypass_event_event,
2875 (void *)&cmd_setbypass_event_event_value,
2876 (void *)&cmd_setbypass_event_mode,
2877 (void *)&cmd_setbypass_event_mode_value,
2878 (void *)&cmd_setbypass_event_port,
2884 /* *** SET NIC BYPASS TIMEOUT *** */
2885 struct cmd_set_bypass_timeout_result {
2886 cmdline_fixed_string_t set;
2887 cmdline_fixed_string_t bypass;
2888 cmdline_fixed_string_t timeout;
2889 cmdline_fixed_string_t value;
2893 cmd_set_bypass_timeout_parsed(void *parsed_result,
2894 __attribute__((unused)) struct cmdline *cl,
2895 __attribute__((unused)) void *data)
2897 struct cmd_set_bypass_timeout_result *res = parsed_result;
2899 if (!strcmp(res->value, "1.5"))
2900 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2901 else if (!strcmp(res->value, "2"))
2902 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2903 else if (!strcmp(res->value, "3"))
2904 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2905 else if (!strcmp(res->value, "4"))
2906 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2907 else if (!strcmp(res->value, "8"))
2908 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2909 else if (!strcmp(res->value, "16"))
2910 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2911 else if (!strcmp(res->value, "32"))
2912 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2914 bypass_timeout = RTE_BYPASS_TMT_OFF;
2917 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2918 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2920 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2921 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2923 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2924 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2925 timeout, "timeout");
2926 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2927 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2928 value, "0#1.5#2#3#4#8#16#32");
2930 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2931 .f = cmd_set_bypass_timeout_parsed,
2932 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2933 "Set the NIC bypass watchdog timeout",
2936 (void *)&cmd_setbypass_timeout_set,
2937 (void *)&cmd_setbypass_timeout_bypass,
2938 (void *)&cmd_setbypass_timeout_timeout,
2939 (void *)&cmd_setbypass_timeout_value,
2944 /* *** SHOW NIC BYPASS MODE *** */
2945 struct cmd_show_bypass_config_result {
2946 cmdline_fixed_string_t show;
2947 cmdline_fixed_string_t bypass;
2948 cmdline_fixed_string_t config;
2953 cmd_show_bypass_config_parsed(void *parsed_result,
2954 __attribute__((unused)) struct cmdline *cl,
2955 __attribute__((unused)) void *data)
2957 struct cmd_show_bypass_config_result *res = parsed_result;
2958 uint32_t event_mode;
2959 uint32_t bypass_mode;
2960 portid_t port_id = res->port_id;
2961 uint32_t timeout = bypass_timeout;
2964 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2965 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2966 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2967 {"UNKNOWN", "normal", "bypass", "isolate"};
2968 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2975 int num_events = (sizeof events) / (sizeof events[0]);
2977 if (!bypass_is_supported(port_id))
2980 /* Display the bypass mode.*/
2981 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2982 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2986 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2987 bypass_mode = RTE_BYPASS_MODE_NONE;
2989 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2992 /* Display the bypass timeout.*/
2993 if (!RTE_BYPASS_TMT_VALID(timeout))
2994 timeout = RTE_BYPASS_TMT_OFF;
2996 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2998 /* Display the bypass events and associated modes. */
2999 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3001 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3002 printf("\tFailed to get bypass mode for event = %s\n",
3005 if (!RTE_BYPASS_MODE_VALID(event_mode))
3006 event_mode = RTE_BYPASS_MODE_NONE;
3008 printf("\tbypass event: %-16s = %s\n", events[i],
3014 cmdline_parse_token_string_t cmd_showbypass_config_show =
3015 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3017 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3018 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3020 cmdline_parse_token_string_t cmd_showbypass_config_config =
3021 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3023 cmdline_parse_token_num_t cmd_showbypass_config_port =
3024 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3027 cmdline_parse_inst_t cmd_show_bypass_config = {
3028 .f = cmd_show_bypass_config_parsed,
3029 .help_str = "show bypass config (port_id): "
3030 "Show the NIC bypass config for port_id",
3033 (void *)&cmd_showbypass_config_show,
3034 (void *)&cmd_showbypass_config_bypass,
3035 (void *)&cmd_showbypass_config_config,
3036 (void *)&cmd_showbypass_config_port,
3042 /* *** SET FORWARDING MODE *** */
3043 struct cmd_set_fwd_mode_result {
3044 cmdline_fixed_string_t set;
3045 cmdline_fixed_string_t fwd;
3046 cmdline_fixed_string_t mode;
3049 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3050 __attribute__((unused)) struct cmdline *cl,
3051 __attribute__((unused)) void *data)
3053 struct cmd_set_fwd_mode_result *res = parsed_result;
3055 set_pkt_forwarding_mode(res->mode);
3058 cmdline_parse_token_string_t cmd_setfwd_set =
3059 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3060 cmdline_parse_token_string_t cmd_setfwd_fwd =
3061 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3062 cmdline_parse_token_string_t cmd_setfwd_mode =
3063 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3064 "" /* defined at init */);
3066 cmdline_parse_inst_t cmd_set_fwd_mode = {
3067 .f = cmd_set_fwd_mode_parsed,
3069 .help_str = NULL, /* defined at init */
3071 (void *)&cmd_setfwd_set,
3072 (void *)&cmd_setfwd_fwd,
3073 (void *)&cmd_setfwd_mode,
3078 static void cmd_set_fwd_mode_init(void)
3081 static char token[128];
3082 static char help[256];
3083 cmdline_parse_token_string_t *token_struct;
3085 modes = list_pkt_forwarding_modes();
3086 snprintf(help, sizeof help, "set fwd %s - "
3087 "set packet forwarding mode", modes);
3088 cmd_set_fwd_mode.help_str = help;
3090 /* string token separator is # */
3091 for (c = token; *modes != '\0'; modes++)
3096 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3097 token_struct->string_data.str = token;
3100 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3101 struct cmd_set_burst_tx_retry_result {
3102 cmdline_fixed_string_t set;
3103 cmdline_fixed_string_t burst;
3104 cmdline_fixed_string_t tx;
3105 cmdline_fixed_string_t delay;
3107 cmdline_fixed_string_t retry;
3111 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3112 __attribute__((unused)) struct cmdline *cl,
3113 __attribute__((unused)) void *data)
3115 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3117 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3118 && !strcmp(res->tx, "tx")) {
3119 if (!strcmp(res->delay, "delay"))
3120 burst_tx_delay_time = res->time;
3121 if (!strcmp(res->retry, "retry"))
3122 burst_tx_retry_num = res->retry_num;
3127 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3128 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3129 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3130 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3132 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3133 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3134 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3135 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3136 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3137 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3138 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3139 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3140 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3141 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3143 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3144 .f = cmd_set_burst_tx_retry_parsed,
3145 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3147 (void *)&cmd_set_burst_tx_retry_set,
3148 (void *)&cmd_set_burst_tx_retry_burst,
3149 (void *)&cmd_set_burst_tx_retry_tx,
3150 (void *)&cmd_set_burst_tx_retry_delay,
3151 (void *)&cmd_set_burst_tx_retry_time,
3152 (void *)&cmd_set_burst_tx_retry_retry,
3153 (void *)&cmd_set_burst_tx_retry_retry_num,
3158 /* *** SET PROMISC MODE *** */
3159 struct cmd_set_promisc_mode_result {
3160 cmdline_fixed_string_t set;
3161 cmdline_fixed_string_t promisc;
3162 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3163 uint8_t port_num; /* valid if "allports" argument == 0 */
3164 cmdline_fixed_string_t mode;
3167 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3168 __attribute__((unused)) struct cmdline *cl,
3171 struct cmd_set_promisc_mode_result *res = parsed_result;
3175 if (!strcmp(res->mode, "on"))
3182 for (i = 0; i < nb_ports; i++) {
3184 rte_eth_promiscuous_enable(i);
3186 rte_eth_promiscuous_disable(i);
3191 rte_eth_promiscuous_enable(res->port_num);
3193 rte_eth_promiscuous_disable(res->port_num);
3197 cmdline_parse_token_string_t cmd_setpromisc_set =
3198 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3199 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3200 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3202 cmdline_parse_token_string_t cmd_setpromisc_portall =
3203 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3205 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3206 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3208 cmdline_parse_token_string_t cmd_setpromisc_mode =
3209 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3212 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3213 .f = cmd_set_promisc_mode_parsed,
3215 .help_str = "set promisc all on|off: set promisc mode for all ports",
3217 (void *)&cmd_setpromisc_set,
3218 (void *)&cmd_setpromisc_promisc,
3219 (void *)&cmd_setpromisc_portall,
3220 (void *)&cmd_setpromisc_mode,
3225 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3226 .f = cmd_set_promisc_mode_parsed,
3228 .help_str = "set promisc X on|off: set promisc mode on port X",
3230 (void *)&cmd_setpromisc_set,
3231 (void *)&cmd_setpromisc_promisc,
3232 (void *)&cmd_setpromisc_portnum,
3233 (void *)&cmd_setpromisc_mode,
3238 /* *** SET ALLMULTI MODE *** */
3239 struct cmd_set_allmulti_mode_result {
3240 cmdline_fixed_string_t set;
3241 cmdline_fixed_string_t allmulti;
3242 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3243 uint8_t port_num; /* valid if "allports" argument == 0 */
3244 cmdline_fixed_string_t mode;
3247 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3248 __attribute__((unused)) struct cmdline *cl,
3251 struct cmd_set_allmulti_mode_result *res = parsed_result;
3255 if (!strcmp(res->mode, "on"))
3262 for (i = 0; i < nb_ports; i++) {
3264 rte_eth_allmulticast_enable(i);
3266 rte_eth_allmulticast_disable(i);
3271 rte_eth_allmulticast_enable(res->port_num);
3273 rte_eth_allmulticast_disable(res->port_num);
3277 cmdline_parse_token_string_t cmd_setallmulti_set =
3278 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3279 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3280 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3282 cmdline_parse_token_string_t cmd_setallmulti_portall =
3283 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3285 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3286 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3288 cmdline_parse_token_string_t cmd_setallmulti_mode =
3289 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3292 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3293 .f = cmd_set_allmulti_mode_parsed,
3295 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3297 (void *)&cmd_setallmulti_set,
3298 (void *)&cmd_setallmulti_allmulti,
3299 (void *)&cmd_setallmulti_portall,
3300 (void *)&cmd_setallmulti_mode,
3305 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3306 .f = cmd_set_allmulti_mode_parsed,
3308 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3310 (void *)&cmd_setallmulti_set,
3311 (void *)&cmd_setallmulti_allmulti,
3312 (void *)&cmd_setallmulti_portnum,
3313 (void *)&cmd_setallmulti_mode,
3318 /* *** ADD/REMOVE A PKT FILTER *** */
3319 struct cmd_pkt_filter_result {
3320 cmdline_fixed_string_t pkt_filter;
3322 cmdline_fixed_string_t protocol;
3323 cmdline_fixed_string_t src;
3324 cmdline_ipaddr_t ip_src;
3326 cmdline_fixed_string_t dst;
3327 cmdline_ipaddr_t ip_dst;
3329 cmdline_fixed_string_t flexbytes;
3330 uint16_t flexbytes_value;
3331 cmdline_fixed_string_t vlan;
3333 cmdline_fixed_string_t queue;
3335 cmdline_fixed_string_t soft;
3340 cmd_pkt_filter_parsed(void *parsed_result,
3341 __attribute__((unused)) struct cmdline *cl,
3342 __attribute__((unused)) void *data)
3344 struct rte_fdir_filter fdir_filter;
3345 struct cmd_pkt_filter_result *res = parsed_result;
3347 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
3349 if (res->ip_src.family == AF_INET)
3350 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
3352 memcpy(&(fdir_filter.ip_src.ipv6_addr),
3353 &(res->ip_src.addr.ipv6),
3354 sizeof(struct in6_addr));
3356 if (res->ip_dst.family == AF_INET)
3357 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
3359 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
3360 &(res->ip_dst.addr.ipv6),
3361 sizeof(struct in6_addr));
3363 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
3364 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
3366 if (!strcmp(res->protocol, "udp"))
3367 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
3368 else if (!strcmp(res->protocol, "tcp"))
3369 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
3370 else if (!strcmp(res->protocol, "sctp"))
3371 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
3372 else /* default only IP */
3373 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
3375 if (res->ip_dst.family == AF_INET6)
3376 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
3378 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
3380 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
3381 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
3383 if (!strcmp(res->pkt_filter, "add_signature_filter"))
3384 fdir_add_signature_filter(res->port_id, res->queue_id,
3386 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3387 fdir_update_signature_filter(res->port_id, res->queue_id,
3389 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3390 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3391 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3392 fdir_add_perfect_filter(res->port_id, res->soft_id,
3394 (uint8_t) (res->queue_id < 0),
3396 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3397 fdir_update_perfect_filter(res->port_id, res->soft_id,
3399 (uint8_t) (res->queue_id < 0),
3401 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3402 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3408 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3409 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3411 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3412 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3413 protocol, "ip#tcp#udp#sctp");
3414 cmdline_parse_token_string_t cmd_pkt_filter_src =
3415 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3417 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3418 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3420 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3421 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3423 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3424 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3426 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3427 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3429 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3430 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3432 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
3433 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3434 flexbytes, "flexbytes");
3435 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
3436 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3437 flexbytes_value, UINT16);
3438 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
3439 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3441 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
3442 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3444 cmdline_parse_token_string_t cmd_pkt_filter_queue =
3445 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3447 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
3448 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3450 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3451 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3453 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3454 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3458 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3459 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3460 pkt_filter, "add_signature_filter");
3461 cmdline_parse_inst_t cmd_add_signature_filter = {
3462 .f = cmd_pkt_filter_parsed,
3464 .help_str = "add a signature filter",
3466 (void *)&cmd_pkt_filter_add_signature_filter,
3467 (void *)&cmd_pkt_filter_port_id,
3468 (void *)&cmd_pkt_filter_protocol,
3469 (void *)&cmd_pkt_filter_src,
3470 (void *)&cmd_pkt_filter_ip_src,
3471 (void *)&cmd_pkt_filter_port_src,
3472 (void *)&cmd_pkt_filter_dst,
3473 (void *)&cmd_pkt_filter_ip_dst,
3474 (void *)&cmd_pkt_filter_port_dst,
3475 (void *)&cmd_pkt_filter_flexbytes,
3476 (void *)&cmd_pkt_filter_flexbytes_value,
3477 (void *)&cmd_pkt_filter_vlan,
3478 (void *)&cmd_pkt_filter_vlan_id,
3479 (void *)&cmd_pkt_filter_queue,
3480 (void *)&cmd_pkt_filter_queue_id,
3486 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3487 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3488 pkt_filter, "upd_signature_filter");
3489 cmdline_parse_inst_t cmd_upd_signature_filter = {
3490 .f = cmd_pkt_filter_parsed,
3492 .help_str = "update a signature filter",
3494 (void *)&cmd_pkt_filter_upd_signature_filter,
3495 (void *)&cmd_pkt_filter_port_id,
3496 (void *)&cmd_pkt_filter_protocol,
3497 (void *)&cmd_pkt_filter_src,
3498 (void *)&cmd_pkt_filter_ip_src,
3499 (void *)&cmd_pkt_filter_port_src,
3500 (void *)&cmd_pkt_filter_dst,
3501 (void *)&cmd_pkt_filter_ip_dst,
3502 (void *)&cmd_pkt_filter_port_dst,
3503 (void *)&cmd_pkt_filter_flexbytes,
3504 (void *)&cmd_pkt_filter_flexbytes_value,
3505 (void *)&cmd_pkt_filter_vlan,
3506 (void *)&cmd_pkt_filter_vlan_id,
3507 (void *)&cmd_pkt_filter_queue,
3508 (void *)&cmd_pkt_filter_queue_id,
3514 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3515 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3516 pkt_filter, "rm_signature_filter");
3517 cmdline_parse_inst_t cmd_rm_signature_filter = {
3518 .f = cmd_pkt_filter_parsed,
3520 .help_str = "remove a signature filter",
3522 (void *)&cmd_pkt_filter_rm_signature_filter,
3523 (void *)&cmd_pkt_filter_port_id,
3524 (void *)&cmd_pkt_filter_protocol,
3525 (void *)&cmd_pkt_filter_src,
3526 (void *)&cmd_pkt_filter_ip_src,
3527 (void *)&cmd_pkt_filter_port_src,
3528 (void *)&cmd_pkt_filter_dst,
3529 (void *)&cmd_pkt_filter_ip_dst,
3530 (void *)&cmd_pkt_filter_port_dst,
3531 (void *)&cmd_pkt_filter_flexbytes,
3532 (void *)&cmd_pkt_filter_flexbytes_value,
3533 (void *)&cmd_pkt_filter_vlan,
3534 (void *)&cmd_pkt_filter_vlan_id,
3540 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3541 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3542 pkt_filter, "add_perfect_filter");
3543 cmdline_parse_inst_t cmd_add_perfect_filter = {
3544 .f = cmd_pkt_filter_parsed,
3546 .help_str = "add a perfect filter",
3548 (void *)&cmd_pkt_filter_add_perfect_filter,
3549 (void *)&cmd_pkt_filter_port_id,
3550 (void *)&cmd_pkt_filter_protocol,
3551 (void *)&cmd_pkt_filter_src,
3552 (void *)&cmd_pkt_filter_ip_src,
3553 (void *)&cmd_pkt_filter_port_src,
3554 (void *)&cmd_pkt_filter_dst,
3555 (void *)&cmd_pkt_filter_ip_dst,
3556 (void *)&cmd_pkt_filter_port_dst,
3557 (void *)&cmd_pkt_filter_flexbytes,
3558 (void *)&cmd_pkt_filter_flexbytes_value,
3559 (void *)&cmd_pkt_filter_vlan,
3560 (void *)&cmd_pkt_filter_vlan_id,
3561 (void *)&cmd_pkt_filter_queue,
3562 (void *)&cmd_pkt_filter_queue_id,
3563 (void *)&cmd_pkt_filter_soft,
3564 (void *)&cmd_pkt_filter_soft_id,
3570 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3571 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3572 pkt_filter, "upd_perfect_filter");
3573 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3574 .f = cmd_pkt_filter_parsed,
3576 .help_str = "update a perfect filter",
3578 (void *)&cmd_pkt_filter_upd_perfect_filter,
3579 (void *)&cmd_pkt_filter_port_id,
3580 (void *)&cmd_pkt_filter_protocol,
3581 (void *)&cmd_pkt_filter_src,
3582 (void *)&cmd_pkt_filter_ip_src,
3583 (void *)&cmd_pkt_filter_port_src,
3584 (void *)&cmd_pkt_filter_dst,
3585 (void *)&cmd_pkt_filter_ip_dst,
3586 (void *)&cmd_pkt_filter_port_dst,
3587 (void *)&cmd_pkt_filter_flexbytes,
3588 (void *)&cmd_pkt_filter_flexbytes_value,
3589 (void *)&cmd_pkt_filter_vlan,
3590 (void *)&cmd_pkt_filter_vlan_id,
3591 (void *)&cmd_pkt_filter_queue,
3592 (void *)&cmd_pkt_filter_queue_id,
3593 (void *)&cmd_pkt_filter_soft,
3594 (void *)&cmd_pkt_filter_soft_id,
3600 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3601 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3602 pkt_filter, "rm_perfect_filter");
3603 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3604 .f = cmd_pkt_filter_parsed,
3606 .help_str = "remove a perfect filter",
3608 (void *)&cmd_pkt_filter_rm_perfect_filter,
3609 (void *)&cmd_pkt_filter_port_id,
3610 (void *)&cmd_pkt_filter_protocol,
3611 (void *)&cmd_pkt_filter_src,
3612 (void *)&cmd_pkt_filter_ip_src,
3613 (void *)&cmd_pkt_filter_port_src,
3614 (void *)&cmd_pkt_filter_dst,
3615 (void *)&cmd_pkt_filter_ip_dst,
3616 (void *)&cmd_pkt_filter_port_dst,
3617 (void *)&cmd_pkt_filter_flexbytes,
3618 (void *)&cmd_pkt_filter_flexbytes_value,
3619 (void *)&cmd_pkt_filter_vlan,
3620 (void *)&cmd_pkt_filter_vlan_id,
3621 (void *)&cmd_pkt_filter_soft,
3622 (void *)&cmd_pkt_filter_soft_id,
3627 /* *** SETUP MASKS FILTER *** */
3628 struct cmd_pkt_filter_masks_result {
3629 cmdline_fixed_string_t filter_mask;
3631 cmdline_fixed_string_t src_mask;
3632 uint32_t ip_src_mask;
3633 uint16_t ipv6_src_mask;
3634 uint16_t port_src_mask;
3635 cmdline_fixed_string_t dst_mask;
3636 uint32_t ip_dst_mask;
3637 uint16_t ipv6_dst_mask;
3638 uint16_t port_dst_mask;
3639 cmdline_fixed_string_t flexbytes;
3640 uint8_t flexbytes_value;
3641 cmdline_fixed_string_t vlan_id;
3642 uint8_t vlan_id_value;
3643 cmdline_fixed_string_t vlan_prio;
3644 uint8_t vlan_prio_value;
3645 cmdline_fixed_string_t only_ip_flow;
3646 uint8_t only_ip_flow_value;
3647 cmdline_fixed_string_t comp_ipv6_dst;
3648 uint8_t comp_ipv6_dst_value;
3652 cmd_pkt_filter_masks_parsed(void *parsed_result,
3653 __attribute__((unused)) struct cmdline *cl,
3654 __attribute__((unused)) void *data)
3656 struct rte_fdir_masks fdir_masks;
3657 struct cmd_pkt_filter_masks_result *res = parsed_result;
3659 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3661 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3662 fdir_masks.vlan_id = res->vlan_id_value;
3663 fdir_masks.vlan_prio = res->vlan_prio_value;
3664 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3665 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3666 fdir_masks.src_port_mask = res->port_src_mask;
3667 fdir_masks.dst_port_mask = res->port_dst_mask;
3668 fdir_masks.flexbytes = res->flexbytes_value;
3670 fdir_set_masks(res->port_id, &fdir_masks);
3673 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3674 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3675 filter_mask, "set_masks_filter");
3676 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3677 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3679 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3680 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3681 only_ip_flow, "only_ip_flow");
3682 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3683 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3684 only_ip_flow_value, UINT8);
3685 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3686 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3687 src_mask, "src_mask");
3688 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3689 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3690 ip_src_mask, UINT32);
3691 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3692 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3693 port_src_mask, UINT16);
3694 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3695 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3696 dst_mask, "dst_mask");
3697 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3698 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3699 ip_dst_mask, UINT32);
3700 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3701 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3702 port_dst_mask, UINT16);
3703 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3704 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3705 flexbytes, "flexbytes");
3706 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3707 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3708 flexbytes_value, UINT8);
3709 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3710 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3711 vlan_id, "vlan_id");
3712 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3713 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3714 vlan_id_value, UINT8);
3715 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3716 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3717 vlan_prio, "vlan_prio");
3718 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3719 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3720 vlan_prio_value, UINT8);
3722 cmdline_parse_inst_t cmd_set_masks_filter = {
3723 .f = cmd_pkt_filter_masks_parsed,
3725 .help_str = "setup masks filter",
3727 (void *)&cmd_pkt_filter_masks_filter_mask,
3728 (void *)&cmd_pkt_filter_masks_port_id,
3729 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3730 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3731 (void *)&cmd_pkt_filter_masks_src_mask,
3732 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3733 (void *)&cmd_pkt_filter_masks_port_src_mask,
3734 (void *)&cmd_pkt_filter_masks_dst_mask,
3735 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3736 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3737 (void *)&cmd_pkt_filter_masks_flexbytes,
3738 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3739 (void *)&cmd_pkt_filter_masks_vlan_id,
3740 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3741 (void *)&cmd_pkt_filter_masks_vlan_prio,
3742 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3748 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3749 __attribute__((unused)) struct cmdline *cl,
3750 __attribute__((unused)) void *data)
3752 struct rte_fdir_masks fdir_masks;
3753 struct cmd_pkt_filter_masks_result *res = parsed_result;
3755 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3757 fdir_masks.set_ipv6_mask = 1;
3758 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3759 fdir_masks.vlan_id = res->vlan_id_value;
3760 fdir_masks.vlan_prio = res->vlan_prio_value;
3761 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3762 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3763 fdir_masks.src_port_mask = res->port_src_mask;
3764 fdir_masks.dst_port_mask = res->port_dst_mask;
3765 fdir_masks.flexbytes = res->flexbytes_value;
3766 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3768 fdir_set_masks(res->port_id, &fdir_masks);
3771 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3772 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3773 filter_mask, "set_ipv6_masks_filter");
3774 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3775 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3776 ipv6_src_mask, UINT16);
3777 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3778 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3779 ipv6_dst_mask, UINT16);
3781 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3782 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3783 comp_ipv6_dst, "compare_dst");
3784 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3785 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3786 comp_ipv6_dst_value, UINT8);
3788 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3789 .f = cmd_pkt_filter_masks_ipv6_parsed,
3791 .help_str = "setup ipv6 masks filter",
3793 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3794 (void *)&cmd_pkt_filter_masks_port_id,
3795 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3796 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3797 (void *)&cmd_pkt_filter_masks_src_mask,
3798 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3799 (void *)&cmd_pkt_filter_masks_port_src_mask,
3800 (void *)&cmd_pkt_filter_masks_dst_mask,
3801 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3802 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3803 (void *)&cmd_pkt_filter_masks_flexbytes,
3804 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3805 (void *)&cmd_pkt_filter_masks_vlan_id,
3806 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3807 (void *)&cmd_pkt_filter_masks_vlan_prio,
3808 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3809 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3810 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3815 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3816 struct cmd_link_flow_ctrl_set_result {
3817 cmdline_fixed_string_t set;
3818 cmdline_fixed_string_t flow_ctrl;
3819 cmdline_fixed_string_t rx;
3820 cmdline_fixed_string_t rx_lfc_mode;
3821 cmdline_fixed_string_t tx;
3822 cmdline_fixed_string_t tx_lfc_mode;
3823 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3824 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3825 cmdline_fixed_string_t autoneg_str;
3826 cmdline_fixed_string_t autoneg;
3827 cmdline_fixed_string_t hw_str;
3828 uint32_t high_water;
3829 cmdline_fixed_string_t lw_str;
3831 cmdline_fixed_string_t pt_str;
3832 uint16_t pause_time;
3833 cmdline_fixed_string_t xon_str;
3838 cmdline_parse_token_string_t cmd_lfc_set_set =
3839 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3841 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3842 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3843 flow_ctrl, "flow_ctrl");
3844 cmdline_parse_token_string_t cmd_lfc_set_rx =
3845 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3847 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3848 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3849 rx_lfc_mode, "on#off");
3850 cmdline_parse_token_string_t cmd_lfc_set_tx =
3851 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3853 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3854 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3855 tx_lfc_mode, "on#off");
3856 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
3857 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3858 hw_str, "high_water");
3859 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3860 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3861 high_water, UINT32);
3862 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
3863 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3864 lw_str, "low_water");
3865 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3866 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3868 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
3869 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3870 pt_str, "pause_time");
3871 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3872 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3873 pause_time, UINT16);
3874 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
3875 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3876 xon_str, "send_xon");
3877 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3878 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3880 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3881 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3882 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3883 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3884 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3885 mac_ctrl_frame_fwd_mode, "on#off");
3886 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
3887 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3888 autoneg_str, "autoneg");
3889 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
3890 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3892 cmdline_parse_token_num_t cmd_lfc_set_portid =
3893 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3896 /* forward declaration */
3898 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
3901 cmdline_parse_inst_t cmd_link_flow_control_set = {
3902 .f = cmd_link_flow_ctrl_set_parsed,
3904 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3905 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3906 autoneg on|off port_id",
3908 (void *)&cmd_lfc_set_set,
3909 (void *)&cmd_lfc_set_flow_ctrl,
3910 (void *)&cmd_lfc_set_rx,
3911 (void *)&cmd_lfc_set_rx_mode,
3912 (void *)&cmd_lfc_set_tx,
3913 (void *)&cmd_lfc_set_tx_mode,
3914 (void *)&cmd_lfc_set_high_water,
3915 (void *)&cmd_lfc_set_low_water,
3916 (void *)&cmd_lfc_set_pause_time,
3917 (void *)&cmd_lfc_set_send_xon,
3918 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3919 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3920 (void *)&cmd_lfc_set_autoneg_str,
3921 (void *)&cmd_lfc_set_autoneg,
3922 (void *)&cmd_lfc_set_portid,
3927 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
3928 .f = cmd_link_flow_ctrl_set_parsed,
3929 .data = (void *)&cmd_link_flow_control_set_rx,
3930 .help_str = "Change rx flow control parameter: set flow_ctrl "
3931 "rx on|off port_id",
3933 (void *)&cmd_lfc_set_set,
3934 (void *)&cmd_lfc_set_flow_ctrl,
3935 (void *)&cmd_lfc_set_rx,
3936 (void *)&cmd_lfc_set_rx_mode,
3937 (void *)&cmd_lfc_set_portid,
3942 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
3943 .f = cmd_link_flow_ctrl_set_parsed,
3944 .data = (void *)&cmd_link_flow_control_set_tx,
3945 .help_str = "Change tx flow control parameter: set flow_ctrl "
3946 "tx on|off port_id",
3948 (void *)&cmd_lfc_set_set,
3949 (void *)&cmd_lfc_set_flow_ctrl,
3950 (void *)&cmd_lfc_set_tx,
3951 (void *)&cmd_lfc_set_tx_mode,
3952 (void *)&cmd_lfc_set_portid,
3957 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
3958 .f = cmd_link_flow_ctrl_set_parsed,
3959 .data = (void *)&cmd_link_flow_control_set_hw,
3960 .help_str = "Change high water flow control parameter: set flow_ctrl "
3961 "high_water value port_id",
3963 (void *)&cmd_lfc_set_set,
3964 (void *)&cmd_lfc_set_flow_ctrl,
3965 (void *)&cmd_lfc_set_high_water_str,
3966 (void *)&cmd_lfc_set_high_water,
3967 (void *)&cmd_lfc_set_portid,
3972 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
3973 .f = cmd_link_flow_ctrl_set_parsed,
3974 .data = (void *)&cmd_link_flow_control_set_lw,
3975 .help_str = "Change low water flow control parameter: set flow_ctrl "
3976 "low_water value port_id",
3978 (void *)&cmd_lfc_set_set,
3979 (void *)&cmd_lfc_set_flow_ctrl,
3980 (void *)&cmd_lfc_set_low_water_str,
3981 (void *)&cmd_lfc_set_low_water,
3982 (void *)&cmd_lfc_set_portid,
3987 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
3988 .f = cmd_link_flow_ctrl_set_parsed,
3989 .data = (void *)&cmd_link_flow_control_set_pt,
3990 .help_str = "Change pause time flow control parameter: set flow_ctrl "
3991 "pause_time value port_id",
3993 (void *)&cmd_lfc_set_set,
3994 (void *)&cmd_lfc_set_flow_ctrl,
3995 (void *)&cmd_lfc_set_pause_time_str,
3996 (void *)&cmd_lfc_set_pause_time,
3997 (void *)&cmd_lfc_set_portid,
4002 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4003 .f = cmd_link_flow_ctrl_set_parsed,
4004 .data = (void *)&cmd_link_flow_control_set_xon,
4005 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4006 "send_xon value port_id",
4008 (void *)&cmd_lfc_set_set,
4009 (void *)&cmd_lfc_set_flow_ctrl,
4010 (void *)&cmd_lfc_set_send_xon_str,
4011 (void *)&cmd_lfc_set_send_xon,
4012 (void *)&cmd_lfc_set_portid,
4017 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4018 .f = cmd_link_flow_ctrl_set_parsed,
4019 .data = (void *)&cmd_link_flow_control_set_macfwd,
4020 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4021 "mac_ctrl_frame_fwd on|off port_id",
4023 (void *)&cmd_lfc_set_set,
4024 (void *)&cmd_lfc_set_flow_ctrl,
4025 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4026 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4027 (void *)&cmd_lfc_set_portid,
4032 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4033 .f = cmd_link_flow_ctrl_set_parsed,
4034 .data = (void *)&cmd_link_flow_control_set_autoneg,
4035 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4036 "autoneg on|off port_id",
4038 (void *)&cmd_lfc_set_set,
4039 (void *)&cmd_lfc_set_flow_ctrl,
4040 (void *)&cmd_lfc_set_autoneg_str,
4041 (void *)&cmd_lfc_set_autoneg,
4042 (void *)&cmd_lfc_set_portid,
4048 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4049 __attribute__((unused)) struct cmdline *cl,
4052 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4053 cmdline_parse_inst_t *cmd = data;
4054 struct rte_eth_fc_conf fc_conf;
4055 int rx_fc_en, tx_fc_en;
4059 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4060 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4061 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4062 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4064 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4065 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4068 /* Partial command line, retrieve current configuration */
4070 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4072 printf("cannot get current flow ctrl parameters, return"
4073 "code = %d\n", ret);
4077 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4078 (fc_conf.mode == RTE_FC_FULL))
4080 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4081 (fc_conf.mode == RTE_FC_FULL))
4085 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4086 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4088 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4089 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4091 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4093 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4094 fc_conf.high_water = res->high_water;
4096 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4097 fc_conf.low_water = res->low_water;
4099 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4100 fc_conf.pause_time = res->pause_time;
4102 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4103 fc_conf.send_xon = res->send_xon;
4105 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4106 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4107 fc_conf.mac_ctrl_frame_fwd = 1;
4109 fc_conf.mac_ctrl_frame_fwd = 0;
4112 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4113 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4115 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4117 printf("bad flow contrl parameter, return code = %d \n", ret);
4120 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4121 struct cmd_priority_flow_ctrl_set_result {
4122 cmdline_fixed_string_t set;
4123 cmdline_fixed_string_t pfc_ctrl;
4124 cmdline_fixed_string_t rx;
4125 cmdline_fixed_string_t rx_pfc_mode;
4126 cmdline_fixed_string_t tx;
4127 cmdline_fixed_string_t tx_pfc_mode;
4128 uint32_t high_water;
4130 uint16_t pause_time;
4136 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4137 __attribute__((unused)) struct cmdline *cl,
4138 __attribute__((unused)) void *data)
4140 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4141 struct rte_eth_pfc_conf pfc_conf;
4142 int rx_fc_enable, tx_fc_enable;
4146 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4147 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4148 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4149 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4151 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4152 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4155 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4156 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4157 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4158 pfc_conf.fc.high_water = res->high_water;
4159 pfc_conf.fc.low_water = res->low_water;
4160 pfc_conf.fc.pause_time = res->pause_time;
4161 pfc_conf.priority = res->priority;
4163 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4165 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4168 cmdline_parse_token_string_t cmd_pfc_set_set =
4169 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4171 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4172 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4173 pfc_ctrl, "pfc_ctrl");
4174 cmdline_parse_token_string_t cmd_pfc_set_rx =
4175 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4177 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4178 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4179 rx_pfc_mode, "on#off");
4180 cmdline_parse_token_string_t cmd_pfc_set_tx =
4181 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4183 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4184 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4185 tx_pfc_mode, "on#off");
4186 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4187 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4188 high_water, UINT32);
4189 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4190 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4192 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4193 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4194 pause_time, UINT16);
4195 cmdline_parse_token_num_t cmd_pfc_set_priority =
4196 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4198 cmdline_parse_token_num_t cmd_pfc_set_portid =
4199 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4202 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4203 .f = cmd_priority_flow_ctrl_set_parsed,
4205 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4206 tx on|off high_water low_water pause_time priority port_id",
4208 (void *)&cmd_pfc_set_set,
4209 (void *)&cmd_pfc_set_flow_ctrl,
4210 (void *)&cmd_pfc_set_rx,
4211 (void *)&cmd_pfc_set_rx_mode,
4212 (void *)&cmd_pfc_set_tx,
4213 (void *)&cmd_pfc_set_tx_mode,
4214 (void *)&cmd_pfc_set_high_water,
4215 (void *)&cmd_pfc_set_low_water,
4216 (void *)&cmd_pfc_set_pause_time,
4217 (void *)&cmd_pfc_set_priority,
4218 (void *)&cmd_pfc_set_portid,
4223 /* *** RESET CONFIGURATION *** */
4224 struct cmd_reset_result {
4225 cmdline_fixed_string_t reset;
4226 cmdline_fixed_string_t def;
4229 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4231 __attribute__((unused)) void *data)
4233 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4234 set_def_fwd_config();
4237 cmdline_parse_token_string_t cmd_reset_set =
4238 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4239 cmdline_parse_token_string_t cmd_reset_def =
4240 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4243 cmdline_parse_inst_t cmd_reset = {
4244 .f = cmd_reset_parsed,
4246 .help_str = "set default: reset default forwarding configuration",
4248 (void *)&cmd_reset_set,
4249 (void *)&cmd_reset_def,
4254 /* *** START FORWARDING *** */
4255 struct cmd_start_result {
4256 cmdline_fixed_string_t start;
4259 cmdline_parse_token_string_t cmd_start_start =
4260 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4262 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4263 __attribute__((unused)) struct cmdline *cl,
4264 __attribute__((unused)) void *data)
4266 start_packet_forwarding(0);
4269 cmdline_parse_inst_t cmd_start = {
4270 .f = cmd_start_parsed,
4272 .help_str = "start packet forwarding",
4274 (void *)&cmd_start_start,
4279 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4280 struct cmd_start_tx_first_result {
4281 cmdline_fixed_string_t start;
4282 cmdline_fixed_string_t tx_first;
4286 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4287 __attribute__((unused)) struct cmdline *cl,
4288 __attribute__((unused)) void *data)
4290 start_packet_forwarding(1);
4293 cmdline_parse_token_string_t cmd_start_tx_first_start =
4294 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4296 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4297 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4298 tx_first, "tx_first");
4300 cmdline_parse_inst_t cmd_start_tx_first = {
4301 .f = cmd_start_tx_first_parsed,
4303 .help_str = "start packet forwarding, after sending 1 burst of packets",
4305 (void *)&cmd_start_tx_first_start,
4306 (void *)&cmd_start_tx_first_tx_first,
4311 /* *** SET LINK UP *** */
4312 struct cmd_set_link_up_result {
4313 cmdline_fixed_string_t set;
4314 cmdline_fixed_string_t link_up;
4315 cmdline_fixed_string_t port;
4319 cmdline_parse_token_string_t cmd_set_link_up_set =
4320 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4321 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4322 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4324 cmdline_parse_token_string_t cmd_set_link_up_port =
4325 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4326 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4327 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4329 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4330 __attribute__((unused)) struct cmdline *cl,
4331 __attribute__((unused)) void *data)
4333 struct cmd_set_link_up_result *res = parsed_result;
4334 dev_set_link_up(res->port_id);
4337 cmdline_parse_inst_t cmd_set_link_up = {
4338 .f = cmd_set_link_up_parsed,
4340 .help_str = "set link-up port (port id)",
4342 (void *)&cmd_set_link_up_set,
4343 (void *)&cmd_set_link_up_link_up,
4344 (void *)&cmd_set_link_up_port,
4345 (void *)&cmd_set_link_up_port_id,
4350 /* *** SET LINK DOWN *** */
4351 struct cmd_set_link_down_result {
4352 cmdline_fixed_string_t set;
4353 cmdline_fixed_string_t link_down;
4354 cmdline_fixed_string_t port;
4358 cmdline_parse_token_string_t cmd_set_link_down_set =
4359 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4360 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4361 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4363 cmdline_parse_token_string_t cmd_set_link_down_port =
4364 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4365 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4366 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4368 static void cmd_set_link_down_parsed(
4369 __attribute__((unused)) void *parsed_result,
4370 __attribute__((unused)) struct cmdline *cl,
4371 __attribute__((unused)) void *data)
4373 struct cmd_set_link_down_result *res = parsed_result;
4374 dev_set_link_down(res->port_id);
4377 cmdline_parse_inst_t cmd_set_link_down = {
4378 .f = cmd_set_link_down_parsed,
4380 .help_str = "set link-down port (port id)",
4382 (void *)&cmd_set_link_down_set,
4383 (void *)&cmd_set_link_down_link_down,
4384 (void *)&cmd_set_link_down_port,
4385 (void *)&cmd_set_link_down_port_id,
4390 /* *** SHOW CFG *** */
4391 struct cmd_showcfg_result {
4392 cmdline_fixed_string_t show;
4393 cmdline_fixed_string_t cfg;
4394 cmdline_fixed_string_t what;
4397 static void cmd_showcfg_parsed(void *parsed_result,
4398 __attribute__((unused)) struct cmdline *cl,
4399 __attribute__((unused)) void *data)
4401 struct cmd_showcfg_result *res = parsed_result;
4402 if (!strcmp(res->what, "rxtx"))
4403 rxtx_config_display();
4404 else if (!strcmp(res->what, "cores"))
4405 fwd_lcores_config_display();
4406 else if (!strcmp(res->what, "fwd"))
4407 fwd_config_display();
4410 cmdline_parse_token_string_t cmd_showcfg_show =
4411 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4412 cmdline_parse_token_string_t cmd_showcfg_port =
4413 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4414 cmdline_parse_token_string_t cmd_showcfg_what =
4415 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4418 cmdline_parse_inst_t cmd_showcfg = {
4419 .f = cmd_showcfg_parsed,
4421 .help_str = "show config rxtx|cores|fwd",
4423 (void *)&cmd_showcfg_show,
4424 (void *)&cmd_showcfg_port,
4425 (void *)&cmd_showcfg_what,
4430 /* *** SHOW ALL PORT INFO *** */
4431 struct cmd_showportall_result {
4432 cmdline_fixed_string_t show;
4433 cmdline_fixed_string_t port;
4434 cmdline_fixed_string_t what;
4435 cmdline_fixed_string_t all;
4438 static void cmd_showportall_parsed(void *parsed_result,
4439 __attribute__((unused)) struct cmdline *cl,
4440 __attribute__((unused)) void *data)
4444 struct cmd_showportall_result *res = parsed_result;
4445 if (!strcmp(res->show, "clear")) {
4446 if (!strcmp(res->what, "stats"))
4447 for (i = 0; i < nb_ports; i++)
4449 } else if (!strcmp(res->what, "info"))
4450 for (i = 0; i < nb_ports; i++)
4451 port_infos_display(i);
4452 else if (!strcmp(res->what, "stats"))
4453 for (i = 0; i < nb_ports; i++)
4454 nic_stats_display(i);
4455 else if (!strcmp(res->what, "fdir"))
4456 for (i = 0; i < nb_ports; i++)
4458 else if (!strcmp(res->what, "stat_qmap"))
4459 for (i = 0; i < nb_ports; i++)
4460 nic_stats_mapping_display(i);
4463 cmdline_parse_token_string_t cmd_showportall_show =
4464 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
4466 cmdline_parse_token_string_t cmd_showportall_port =
4467 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
4468 cmdline_parse_token_string_t cmd_showportall_what =
4469 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
4470 "info#stats#fdir#stat_qmap");
4471 cmdline_parse_token_string_t cmd_showportall_all =
4472 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
4473 cmdline_parse_inst_t cmd_showportall = {
4474 .f = cmd_showportall_parsed,
4476 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
4478 (void *)&cmd_showportall_show,
4479 (void *)&cmd_showportall_port,
4480 (void *)&cmd_showportall_what,
4481 (void *)&cmd_showportall_all,
4486 /* *** SHOW PORT INFO *** */
4487 struct cmd_showport_result {
4488 cmdline_fixed_string_t show;
4489 cmdline_fixed_string_t port;
4490 cmdline_fixed_string_t what;
4494 static void cmd_showport_parsed(void *parsed_result,
4495 __attribute__((unused)) struct cmdline *cl,
4496 __attribute__((unused)) void *data)
4498 struct cmd_showport_result *res = parsed_result;
4499 if (!strcmp(res->show, "clear")) {
4500 if (!strcmp(res->what, "stats"))
4501 nic_stats_clear(res->portnum);
4502 } else if (!strcmp(res->what, "info"))
4503 port_infos_display(res->portnum);
4504 else if (!strcmp(res->what, "stats"))
4505 nic_stats_display(res->portnum);
4506 else if (!strcmp(res->what, "fdir"))
4507 fdir_get_infos(res->portnum);
4508 else if (!strcmp(res->what, "stat_qmap"))
4509 nic_stats_mapping_display(res->portnum);
4512 cmdline_parse_token_string_t cmd_showport_show =
4513 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
4515 cmdline_parse_token_string_t cmd_showport_port =
4516 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
4517 cmdline_parse_token_string_t cmd_showport_what =
4518 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
4519 "info#stats#fdir#stat_qmap");
4520 cmdline_parse_token_num_t cmd_showport_portnum =
4521 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
4523 cmdline_parse_inst_t cmd_showport = {
4524 .f = cmd_showport_parsed,
4526 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
4528 (void *)&cmd_showport_show,
4529 (void *)&cmd_showport_port,
4530 (void *)&cmd_showport_what,
4531 (void *)&cmd_showport_portnum,
4536 /* *** READ PORT REGISTER *** */
4537 struct cmd_read_reg_result {
4538 cmdline_fixed_string_t read;
4539 cmdline_fixed_string_t reg;
4545 cmd_read_reg_parsed(void *parsed_result,
4546 __attribute__((unused)) struct cmdline *cl,
4547 __attribute__((unused)) void *data)
4549 struct cmd_read_reg_result *res = parsed_result;
4550 port_reg_display(res->port_id, res->reg_off);
4553 cmdline_parse_token_string_t cmd_read_reg_read =
4554 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
4555 cmdline_parse_token_string_t cmd_read_reg_reg =
4556 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
4557 cmdline_parse_token_num_t cmd_read_reg_port_id =
4558 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
4559 cmdline_parse_token_num_t cmd_read_reg_reg_off =
4560 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
4562 cmdline_parse_inst_t cmd_read_reg = {
4563 .f = cmd_read_reg_parsed,
4565 .help_str = "read reg port_id reg_off",
4567 (void *)&cmd_read_reg_read,
4568 (void *)&cmd_read_reg_reg,
4569 (void *)&cmd_read_reg_port_id,
4570 (void *)&cmd_read_reg_reg_off,
4575 /* *** READ PORT REGISTER BIT FIELD *** */
4576 struct cmd_read_reg_bit_field_result {
4577 cmdline_fixed_string_t read;
4578 cmdline_fixed_string_t regfield;
4586 cmd_read_reg_bit_field_parsed(void *parsed_result,
4587 __attribute__((unused)) struct cmdline *cl,
4588 __attribute__((unused)) void *data)
4590 struct cmd_read_reg_bit_field_result *res = parsed_result;
4591 port_reg_bit_field_display(res->port_id, res->reg_off,
4592 res->bit1_pos, res->bit2_pos);
4595 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
4596 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
4598 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
4599 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
4600 regfield, "regfield");
4601 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
4602 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
4604 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
4605 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
4607 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
4608 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
4610 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
4611 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
4614 cmdline_parse_inst_t cmd_read_reg_bit_field = {
4615 .f = cmd_read_reg_bit_field_parsed,
4617 .help_str = "read regfield port_id reg_off bit_x bit_y "
4618 "(read register bit field between bit_x and bit_y included)",
4620 (void *)&cmd_read_reg_bit_field_read,
4621 (void *)&cmd_read_reg_bit_field_regfield,
4622 (void *)&cmd_read_reg_bit_field_port_id,
4623 (void *)&cmd_read_reg_bit_field_reg_off,
4624 (void *)&cmd_read_reg_bit_field_bit1_pos,
4625 (void *)&cmd_read_reg_bit_field_bit2_pos,
4630 /* *** READ PORT REGISTER BIT *** */
4631 struct cmd_read_reg_bit_result {
4632 cmdline_fixed_string_t read;
4633 cmdline_fixed_string_t regbit;
4640 cmd_read_reg_bit_parsed(void *parsed_result,
4641 __attribute__((unused)) struct cmdline *cl,
4642 __attribute__((unused)) void *data)
4644 struct cmd_read_reg_bit_result *res = parsed_result;
4645 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
4648 cmdline_parse_token_string_t cmd_read_reg_bit_read =
4649 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
4650 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
4651 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
4653 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4654 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4655 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4656 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4657 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4658 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4660 cmdline_parse_inst_t cmd_read_reg_bit = {
4661 .f = cmd_read_reg_bit_parsed,
4663 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4665 (void *)&cmd_read_reg_bit_read,
4666 (void *)&cmd_read_reg_bit_regbit,
4667 (void *)&cmd_read_reg_bit_port_id,
4668 (void *)&cmd_read_reg_bit_reg_off,
4669 (void *)&cmd_read_reg_bit_bit_pos,
4674 /* *** WRITE PORT REGISTER *** */
4675 struct cmd_write_reg_result {
4676 cmdline_fixed_string_t write;
4677 cmdline_fixed_string_t reg;
4684 cmd_write_reg_parsed(void *parsed_result,
4685 __attribute__((unused)) struct cmdline *cl,
4686 __attribute__((unused)) void *data)
4688 struct cmd_write_reg_result *res = parsed_result;
4689 port_reg_set(res->port_id, res->reg_off, res->value);
4692 cmdline_parse_token_string_t cmd_write_reg_write =
4693 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4694 cmdline_parse_token_string_t cmd_write_reg_reg =
4695 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4696 cmdline_parse_token_num_t cmd_write_reg_port_id =
4697 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4698 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4699 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4700 cmdline_parse_token_num_t cmd_write_reg_value =
4701 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4703 cmdline_parse_inst_t cmd_write_reg = {
4704 .f = cmd_write_reg_parsed,
4706 .help_str = "write reg port_id reg_off reg_value",
4708 (void *)&cmd_write_reg_write,
4709 (void *)&cmd_write_reg_reg,
4710 (void *)&cmd_write_reg_port_id,
4711 (void *)&cmd_write_reg_reg_off,
4712 (void *)&cmd_write_reg_value,
4717 /* *** WRITE PORT REGISTER BIT FIELD *** */
4718 struct cmd_write_reg_bit_field_result {
4719 cmdline_fixed_string_t write;
4720 cmdline_fixed_string_t regfield;
4729 cmd_write_reg_bit_field_parsed(void *parsed_result,
4730 __attribute__((unused)) struct cmdline *cl,
4731 __attribute__((unused)) void *data)
4733 struct cmd_write_reg_bit_field_result *res = parsed_result;
4734 port_reg_bit_field_set(res->port_id, res->reg_off,
4735 res->bit1_pos, res->bit2_pos, res->value);
4738 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4739 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4741 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4742 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4743 regfield, "regfield");
4744 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4745 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4747 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4748 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4750 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4751 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4753 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4754 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4756 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4757 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4760 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4761 .f = cmd_write_reg_bit_field_parsed,
4763 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4764 "(set register bit field between bit_x and bit_y included)",
4766 (void *)&cmd_write_reg_bit_field_write,
4767 (void *)&cmd_write_reg_bit_field_regfield,
4768 (void *)&cmd_write_reg_bit_field_port_id,
4769 (void *)&cmd_write_reg_bit_field_reg_off,
4770 (void *)&cmd_write_reg_bit_field_bit1_pos,
4771 (void *)&cmd_write_reg_bit_field_bit2_pos,
4772 (void *)&cmd_write_reg_bit_field_value,
4777 /* *** WRITE PORT REGISTER BIT *** */
4778 struct cmd_write_reg_bit_result {
4779 cmdline_fixed_string_t write;
4780 cmdline_fixed_string_t regbit;
4788 cmd_write_reg_bit_parsed(void *parsed_result,
4789 __attribute__((unused)) struct cmdline *cl,
4790 __attribute__((unused)) void *data)
4792 struct cmd_write_reg_bit_result *res = parsed_result;
4793 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4796 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4797 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4799 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4800 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4802 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4803 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4804 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4805 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4806 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4807 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4808 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4809 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4811 cmdline_parse_inst_t cmd_write_reg_bit = {
4812 .f = cmd_write_reg_bit_parsed,
4814 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4816 (void *)&cmd_write_reg_bit_write,
4817 (void *)&cmd_write_reg_bit_regbit,
4818 (void *)&cmd_write_reg_bit_port_id,
4819 (void *)&cmd_write_reg_bit_reg_off,
4820 (void *)&cmd_write_reg_bit_bit_pos,
4821 (void *)&cmd_write_reg_bit_value,
4826 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4827 struct cmd_read_rxd_txd_result {
4828 cmdline_fixed_string_t read;
4829 cmdline_fixed_string_t rxd_txd;
4836 cmd_read_rxd_txd_parsed(void *parsed_result,
4837 __attribute__((unused)) struct cmdline *cl,
4838 __attribute__((unused)) void *data)
4840 struct cmd_read_rxd_txd_result *res = parsed_result;
4842 if (!strcmp(res->rxd_txd, "rxd"))
4843 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4844 else if (!strcmp(res->rxd_txd, "txd"))
4845 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4848 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4849 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4850 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4851 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4853 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4854 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4855 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4856 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4857 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4858 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4860 cmdline_parse_inst_t cmd_read_rxd_txd = {
4861 .f = cmd_read_rxd_txd_parsed,
4863 .help_str = "read rxd|txd port_id queue_id rxd_id",
4865 (void *)&cmd_read_rxd_txd_read,
4866 (void *)&cmd_read_rxd_txd_rxd_txd,
4867 (void *)&cmd_read_rxd_txd_port_id,
4868 (void *)&cmd_read_rxd_txd_queue_id,
4869 (void *)&cmd_read_rxd_txd_desc_id,
4875 struct cmd_quit_result {
4876 cmdline_fixed_string_t quit;
4879 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4881 __attribute__((unused)) void *data)
4887 cmdline_parse_token_string_t cmd_quit_quit =
4888 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4890 cmdline_parse_inst_t cmd_quit = {
4891 .f = cmd_quit_parsed,
4893 .help_str = "exit application",
4895 (void *)&cmd_quit_quit,
4900 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4901 struct cmd_mac_addr_result {
4902 cmdline_fixed_string_t mac_addr_cmd;
4903 cmdline_fixed_string_t what;
4905 struct ether_addr address;
4908 static void cmd_mac_addr_parsed(void *parsed_result,
4909 __attribute__((unused)) struct cmdline *cl,
4910 __attribute__((unused)) void *data)
4912 struct cmd_mac_addr_result *res = parsed_result;
4915 if (strcmp(res->what, "add") == 0)
4916 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4918 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4920 /* check the return value and print it if is < 0 */
4922 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4926 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4927 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4929 cmdline_parse_token_string_t cmd_mac_addr_what =
4930 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4932 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4933 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4934 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4935 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4937 cmdline_parse_inst_t cmd_mac_addr = {
4938 .f = cmd_mac_addr_parsed,
4940 .help_str = "mac_addr add|remove X <address>: "
4941 "add/remove MAC address on port X",
4943 (void *)&cmd_mac_addr_cmd,
4944 (void *)&cmd_mac_addr_what,
4945 (void *)&cmd_mac_addr_portnum,
4946 (void *)&cmd_mac_addr_addr,
4952 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4953 struct cmd_set_qmap_result {
4954 cmdline_fixed_string_t set;
4955 cmdline_fixed_string_t qmap;
4956 cmdline_fixed_string_t what;
4963 cmd_set_qmap_parsed(void *parsed_result,
4964 __attribute__((unused)) struct cmdline *cl,
4965 __attribute__((unused)) void *data)
4967 struct cmd_set_qmap_result *res = parsed_result;
4968 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4970 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4973 cmdline_parse_token_string_t cmd_setqmap_set =
4974 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4976 cmdline_parse_token_string_t cmd_setqmap_qmap =
4977 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4979 cmdline_parse_token_string_t cmd_setqmap_what =
4980 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4982 cmdline_parse_token_num_t cmd_setqmap_portid =
4983 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4985 cmdline_parse_token_num_t cmd_setqmap_queueid =
4986 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4988 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4989 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4992 cmdline_parse_inst_t cmd_set_qmap = {
4993 .f = cmd_set_qmap_parsed,
4995 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4997 (void *)&cmd_setqmap_set,
4998 (void *)&cmd_setqmap_qmap,
4999 (void *)&cmd_setqmap_what,
5000 (void *)&cmd_setqmap_portid,
5001 (void *)&cmd_setqmap_queueid,
5002 (void *)&cmd_setqmap_mapvalue,
5007 /* *** CONFIGURE UNICAST HASH TABLE *** */
5008 struct cmd_set_uc_hash_table {
5009 cmdline_fixed_string_t set;
5010 cmdline_fixed_string_t port;
5012 cmdline_fixed_string_t what;
5013 struct ether_addr address;
5014 cmdline_fixed_string_t mode;
5018 cmd_set_uc_hash_parsed(void *parsed_result,
5019 __attribute__((unused)) struct cmdline *cl,
5020 __attribute__((unused)) void *data)
5023 struct cmd_set_uc_hash_table *res = parsed_result;
5025 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5027 if (strcmp(res->what, "uta") == 0)
5028 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5029 &res->address,(uint8_t)is_on);
5031 printf("bad unicast hash table parameter, return code = %d \n", ret);
5035 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5036 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5038 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5039 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5041 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5042 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5044 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5045 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5047 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5048 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5050 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5051 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5054 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5055 .f = cmd_set_uc_hash_parsed,
5057 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5059 (void *)&cmd_set_uc_hash_set,
5060 (void *)&cmd_set_uc_hash_port,
5061 (void *)&cmd_set_uc_hash_portid,
5062 (void *)&cmd_set_uc_hash_what,
5063 (void *)&cmd_set_uc_hash_mac,
5064 (void *)&cmd_set_uc_hash_mode,
5069 struct cmd_set_uc_all_hash_table {
5070 cmdline_fixed_string_t set;
5071 cmdline_fixed_string_t port;
5073 cmdline_fixed_string_t what;
5074 cmdline_fixed_string_t value;
5075 cmdline_fixed_string_t mode;
5079 cmd_set_uc_all_hash_parsed(void *parsed_result,
5080 __attribute__((unused)) struct cmdline *cl,
5081 __attribute__((unused)) void *data)
5084 struct cmd_set_uc_all_hash_table *res = parsed_result;
5086 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5088 if ((strcmp(res->what, "uta") == 0) &&
5089 (strcmp(res->value, "all") == 0))
5090 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5092 printf("bad unicast hash table parameter,"
5093 "return code = %d \n", ret);
5096 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5097 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5099 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5100 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5102 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5103 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5105 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5106 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5108 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5109 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5111 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5112 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5115 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5116 .f = cmd_set_uc_all_hash_parsed,
5118 .help_str = "set port X uta all on|off (X = port number)",
5120 (void *)&cmd_set_uc_all_hash_set,
5121 (void *)&cmd_set_uc_all_hash_port,
5122 (void *)&cmd_set_uc_all_hash_portid,
5123 (void *)&cmd_set_uc_all_hash_what,
5124 (void *)&cmd_set_uc_all_hash_value,
5125 (void *)&cmd_set_uc_all_hash_mode,
5130 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5131 struct cmd_set_vf_traffic {
5132 cmdline_fixed_string_t set;
5133 cmdline_fixed_string_t port;
5135 cmdline_fixed_string_t vf;
5137 cmdline_fixed_string_t what;
5138 cmdline_fixed_string_t mode;
5142 cmd_set_vf_traffic_parsed(void *parsed_result,
5143 __attribute__((unused)) struct cmdline *cl,
5144 __attribute__((unused)) void *data)
5146 struct cmd_set_vf_traffic *res = parsed_result;
5147 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5148 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5150 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5153 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5154 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5156 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5157 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5159 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5160 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5162 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5163 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5165 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5166 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5168 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5169 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5171 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5172 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5175 cmdline_parse_inst_t cmd_set_vf_traffic = {
5176 .f = cmd_set_vf_traffic_parsed,
5178 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
5180 (void *)&cmd_setvf_traffic_set,
5181 (void *)&cmd_setvf_traffic_port,
5182 (void *)&cmd_setvf_traffic_portid,
5183 (void *)&cmd_setvf_traffic_vf,
5184 (void *)&cmd_setvf_traffic_vfid,
5185 (void *)&cmd_setvf_traffic_what,
5186 (void *)&cmd_setvf_traffic_mode,
5191 /* *** CONFIGURE VF RECEIVE MODE *** */
5192 struct cmd_set_vf_rxmode {
5193 cmdline_fixed_string_t set;
5194 cmdline_fixed_string_t port;
5196 cmdline_fixed_string_t vf;
5198 cmdline_fixed_string_t what;
5199 cmdline_fixed_string_t mode;
5200 cmdline_fixed_string_t on;
5204 cmd_set_vf_rxmode_parsed(void *parsed_result,
5205 __attribute__((unused)) struct cmdline *cl,
5206 __attribute__((unused)) void *data)
5209 uint16_t rx_mode = 0;
5210 struct cmd_set_vf_rxmode *res = parsed_result;
5212 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5213 if (!strcmp(res->what,"rxmode")) {
5214 if (!strcmp(res->mode, "AUPE"))
5215 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5216 else if (!strcmp(res->mode, "ROPE"))
5217 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5218 else if (!strcmp(res->mode, "BAM"))
5219 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5220 else if (!strncmp(res->mode, "MPE",3))
5221 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5224 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5226 printf("bad VF receive mode parameter, return code = %d \n",
5230 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5231 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5233 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5234 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5236 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5237 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5239 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5240 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5242 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5243 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5245 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5246 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5248 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5249 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5250 mode, "AUPE#ROPE#BAM#MPE");
5251 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5252 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5255 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5256 .f = cmd_set_vf_rxmode_parsed,
5258 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5260 (void *)&cmd_set_vf_rxmode_set,
5261 (void *)&cmd_set_vf_rxmode_port,
5262 (void *)&cmd_set_vf_rxmode_portid,
5263 (void *)&cmd_set_vf_rxmode_vf,
5264 (void *)&cmd_set_vf_rxmode_vfid,
5265 (void *)&cmd_set_vf_rxmode_what,
5266 (void *)&cmd_set_vf_rxmode_mode,
5267 (void *)&cmd_set_vf_rxmode_on,
5272 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5273 struct cmd_vf_mac_addr_result {
5274 cmdline_fixed_string_t mac_addr_cmd;
5275 cmdline_fixed_string_t what;
5276 cmdline_fixed_string_t port;
5278 cmdline_fixed_string_t vf;
5280 struct ether_addr address;
5283 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5284 __attribute__((unused)) struct cmdline *cl,
5285 __attribute__((unused)) void *data)
5287 struct cmd_vf_mac_addr_result *res = parsed_result;
5290 if (strcmp(res->what, "add") == 0)
5291 ret = rte_eth_dev_mac_addr_add(res->port_num,
5292 &res->address, res->vf_num);
5294 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5298 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5299 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5300 mac_addr_cmd,"mac_addr");
5301 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5302 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5304 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5305 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5307 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5308 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5310 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5311 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5313 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
5314 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5316 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
5317 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
5320 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
5321 .f = cmd_vf_mac_addr_parsed,
5323 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
5324 "Y = VF number)add MAC address filtering for a VF on port X",
5326 (void *)&cmd_vf_mac_addr_cmd,
5327 (void *)&cmd_vf_mac_addr_what,
5328 (void *)&cmd_vf_mac_addr_port,
5329 (void *)&cmd_vf_mac_addr_portnum,
5330 (void *)&cmd_vf_mac_addr_vf,
5331 (void *)&cmd_vf_mac_addr_vfnum,
5332 (void *)&cmd_vf_mac_addr_addr,
5337 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
5338 struct cmd_vf_rx_vlan_filter {
5339 cmdline_fixed_string_t rx_vlan;
5340 cmdline_fixed_string_t what;
5342 cmdline_fixed_string_t port;
5344 cmdline_fixed_string_t vf;
5349 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
5350 __attribute__((unused)) struct cmdline *cl,
5351 __attribute__((unused)) void *data)
5353 struct cmd_vf_rx_vlan_filter *res = parsed_result;
5355 if (!strcmp(res->what, "add"))
5356 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
5358 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
5361 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
5362 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5363 rx_vlan, "rx_vlan");
5364 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
5365 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5367 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
5368 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5370 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
5371 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5373 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
5374 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5376 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
5377 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5379 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
5380 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5383 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
5384 .f = cmd_vf_rx_vlan_filter_parsed,
5386 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
5387 "Y = port number,Z = hexadecimal VF mask)",
5389 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
5390 (void *)&cmd_vf_rx_vlan_filter_what,
5391 (void *)&cmd_vf_rx_vlan_filter_vlanid,
5392 (void *)&cmd_vf_rx_vlan_filter_port,
5393 (void *)&cmd_vf_rx_vlan_filter_portid,
5394 (void *)&cmd_vf_rx_vlan_filter_vf,
5395 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
5400 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
5401 struct cmd_queue_rate_limit_result {
5402 cmdline_fixed_string_t set;
5403 cmdline_fixed_string_t port;
5405 cmdline_fixed_string_t queue;
5407 cmdline_fixed_string_t rate;
5411 static void cmd_queue_rate_limit_parsed(void *parsed_result,
5412 __attribute__((unused)) struct cmdline *cl,
5413 __attribute__((unused)) void *data)
5415 struct cmd_queue_rate_limit_result *res = parsed_result;
5418 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5419 && (strcmp(res->queue, "queue") == 0)
5420 && (strcmp(res->rate, "rate") == 0))
5421 ret = set_queue_rate_limit(res->port_num, res->queue_num,
5424 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
5428 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
5429 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5431 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
5432 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5434 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
5435 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5437 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
5438 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5440 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
5441 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5443 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
5444 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5446 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
5447 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5450 cmdline_parse_inst_t cmd_queue_rate_limit = {
5451 .f = cmd_queue_rate_limit_parsed,
5453 .help_str = "set port X queue Y rate Z:(X = port number,"
5454 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
5456 (void *)&cmd_queue_rate_limit_set,
5457 (void *)&cmd_queue_rate_limit_port,
5458 (void *)&cmd_queue_rate_limit_portnum,
5459 (void *)&cmd_queue_rate_limit_queue,
5460 (void *)&cmd_queue_rate_limit_queuenum,
5461 (void *)&cmd_queue_rate_limit_rate,
5462 (void *)&cmd_queue_rate_limit_ratenum,
5467 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
5468 struct cmd_vf_rate_limit_result {
5469 cmdline_fixed_string_t set;
5470 cmdline_fixed_string_t port;
5472 cmdline_fixed_string_t vf;
5474 cmdline_fixed_string_t rate;
5476 cmdline_fixed_string_t q_msk;
5480 static void cmd_vf_rate_limit_parsed(void *parsed_result,
5481 __attribute__((unused)) struct cmdline *cl,
5482 __attribute__((unused)) void *data)
5484 struct cmd_vf_rate_limit_result *res = parsed_result;
5487 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5488 && (strcmp(res->vf, "vf") == 0)
5489 && (strcmp(res->rate, "rate") == 0)
5490 && (strcmp(res->q_msk, "queue_mask") == 0))
5491 ret = set_vf_rate_limit(res->port_num, res->vf_num,
5492 res->rate_num, res->q_msk_val);
5494 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
5498 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
5499 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5501 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
5502 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5504 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
5505 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5507 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
5508 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5510 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
5511 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5513 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
5514 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5516 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
5517 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5519 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
5520 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5521 q_msk, "queue_mask");
5522 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
5523 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5526 cmdline_parse_inst_t cmd_vf_rate_limit = {
5527 .f = cmd_vf_rate_limit_parsed,
5529 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
5530 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
5531 "for queues of VF on port X",
5533 (void *)&cmd_vf_rate_limit_set,
5534 (void *)&cmd_vf_rate_limit_port,
5535 (void *)&cmd_vf_rate_limit_portnum,
5536 (void *)&cmd_vf_rate_limit_vf,
5537 (void *)&cmd_vf_rate_limit_vfnum,
5538 (void *)&cmd_vf_rate_limit_rate,
5539 (void *)&cmd_vf_rate_limit_ratenum,
5540 (void *)&cmd_vf_rate_limit_q_msk,
5541 (void *)&cmd_vf_rate_limit_q_msk_val,
5546 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
5547 struct cmd_set_mirror_mask_result {
5548 cmdline_fixed_string_t set;
5549 cmdline_fixed_string_t port;
5551 cmdline_fixed_string_t mirror;
5553 cmdline_fixed_string_t what;
5554 cmdline_fixed_string_t value;
5555 cmdline_fixed_string_t dstpool;
5557 cmdline_fixed_string_t on;
5560 cmdline_parse_token_string_t cmd_mirror_mask_set =
5561 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5563 cmdline_parse_token_string_t cmd_mirror_mask_port =
5564 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5566 cmdline_parse_token_num_t cmd_mirror_mask_portid =
5567 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5569 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
5570 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5571 mirror, "mirror-rule");
5572 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
5573 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5575 cmdline_parse_token_string_t cmd_mirror_mask_what =
5576 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5577 what, "pool-mirror#vlan-mirror");
5578 cmdline_parse_token_string_t cmd_mirror_mask_value =
5579 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5581 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
5582 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5583 dstpool, "dst-pool");
5584 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
5585 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5587 cmdline_parse_token_string_t cmd_mirror_mask_on =
5588 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5592 cmd_set_mirror_mask_parsed(void *parsed_result,
5593 __attribute__((unused)) struct cmdline *cl,
5594 __attribute__((unused)) void *data)
5597 struct cmd_set_mirror_mask_result *res = parsed_result;
5598 struct rte_eth_vmdq_mirror_conf mr_conf;
5600 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5602 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
5604 mr_conf.dst_pool = res->dstpool_id;
5606 if (!strcmp(res->what, "pool-mirror")) {
5607 mr_conf.pool_mask = strtoull(res->value,NULL,16);
5608 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
5609 } else if(!strcmp(res->what, "vlan-mirror")) {
5610 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
5611 nb_item = parse_item_list(res->value, "core",
5612 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
5616 for(i=0; i < nb_item; i++) {
5617 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
5618 printf("Invalid vlan_id: must be < 4096\n");
5622 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
5623 mr_conf.vlan.vlan_mask |= 1ULL << i;
5627 if(!strcmp(res->on, "on"))
5628 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5631 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5634 printf("mirror rule add error: (%s)\n", strerror(-ret));
5637 cmdline_parse_inst_t cmd_set_mirror_mask = {
5638 .f = cmd_set_mirror_mask_parsed,
5640 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
5641 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
5643 (void *)&cmd_mirror_mask_set,
5644 (void *)&cmd_mirror_mask_port,
5645 (void *)&cmd_mirror_mask_portid,
5646 (void *)&cmd_mirror_mask_mirror,
5647 (void *)&cmd_mirror_mask_ruleid,
5648 (void *)&cmd_mirror_mask_what,
5649 (void *)&cmd_mirror_mask_value,
5650 (void *)&cmd_mirror_mask_dstpool,
5651 (void *)&cmd_mirror_mask_poolid,
5652 (void *)&cmd_mirror_mask_on,
5657 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
5658 struct cmd_set_mirror_link_result {
5659 cmdline_fixed_string_t set;
5660 cmdline_fixed_string_t port;
5662 cmdline_fixed_string_t mirror;
5664 cmdline_fixed_string_t what;
5665 cmdline_fixed_string_t dstpool;
5667 cmdline_fixed_string_t on;
5670 cmdline_parse_token_string_t cmd_mirror_link_set =
5671 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5673 cmdline_parse_token_string_t cmd_mirror_link_port =
5674 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5676 cmdline_parse_token_num_t cmd_mirror_link_portid =
5677 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5679 cmdline_parse_token_string_t cmd_mirror_link_mirror =
5680 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5681 mirror, "mirror-rule");
5682 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
5683 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5685 cmdline_parse_token_string_t cmd_mirror_link_what =
5686 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5687 what, "uplink-mirror#downlink-mirror");
5688 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
5689 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5690 dstpool, "dst-pool");
5691 cmdline_parse_token_num_t cmd_mirror_link_poolid =
5692 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5694 cmdline_parse_token_string_t cmd_mirror_link_on =
5695 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5699 cmd_set_mirror_link_parsed(void *parsed_result,
5700 __attribute__((unused)) struct cmdline *cl,
5701 __attribute__((unused)) void *data)
5704 struct cmd_set_mirror_link_result *res = parsed_result;
5705 struct rte_eth_vmdq_mirror_conf mr_conf;
5707 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5708 if(!strcmp(res->what, "uplink-mirror")) {
5709 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
5710 }else if(!strcmp(res->what, "downlink-mirror"))
5711 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
5713 mr_conf.dst_pool = res->dstpool_id;
5715 if(!strcmp(res->on, "on"))
5716 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5719 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5722 /* check the return value and print it if is < 0 */
5724 printf("mirror rule add error: (%s)\n", strerror(-ret));
5728 cmdline_parse_inst_t cmd_set_mirror_link = {
5729 .f = cmd_set_mirror_link_parsed,
5731 .help_str = "set port X mirror-rule Y uplink-mirror|"
5732 "downlink-mirror dst-pool Z on|off",
5734 (void *)&cmd_mirror_link_set,
5735 (void *)&cmd_mirror_link_port,
5736 (void *)&cmd_mirror_link_portid,
5737 (void *)&cmd_mirror_link_mirror,
5738 (void *)&cmd_mirror_link_ruleid,
5739 (void *)&cmd_mirror_link_what,
5740 (void *)&cmd_mirror_link_dstpool,
5741 (void *)&cmd_mirror_link_poolid,
5742 (void *)&cmd_mirror_link_on,
5747 /* *** RESET VM MIRROR RULE *** */
5748 struct cmd_rm_mirror_rule_result {
5749 cmdline_fixed_string_t reset;
5750 cmdline_fixed_string_t port;
5752 cmdline_fixed_string_t mirror;
5756 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
5757 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5759 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
5760 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5762 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
5763 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5765 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
5766 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5767 mirror, "mirror-rule");
5768 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
5769 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5773 cmd_reset_mirror_rule_parsed(void *parsed_result,
5774 __attribute__((unused)) struct cmdline *cl,
5775 __attribute__((unused)) void *data)
5778 struct cmd_set_mirror_link_result *res = parsed_result;
5780 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
5782 printf("mirror rule remove error: (%s)\n", strerror(-ret));
5785 cmdline_parse_inst_t cmd_reset_mirror_rule = {
5786 .f = cmd_reset_mirror_rule_parsed,
5788 .help_str = "reset port X mirror-rule Y",
5790 (void *)&cmd_rm_mirror_rule_reset,
5791 (void *)&cmd_rm_mirror_rule_port,
5792 (void *)&cmd_rm_mirror_rule_portid,
5793 (void *)&cmd_rm_mirror_rule_mirror,
5794 (void *)&cmd_rm_mirror_rule_ruleid,
5799 /* ******************************************************************************** */
5801 struct cmd_dump_result {
5802 cmdline_fixed_string_t dump;
5806 dump_struct_sizes(void)
5808 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
5809 DUMP_SIZE(struct rte_mbuf);
5810 DUMP_SIZE(struct rte_pktmbuf);
5811 DUMP_SIZE(struct rte_ctrlmbuf);
5812 DUMP_SIZE(struct rte_mempool);
5813 DUMP_SIZE(struct rte_ring);
5817 static void cmd_dump_parsed(void *parsed_result,
5818 __attribute__((unused)) struct cmdline *cl,
5819 __attribute__((unused)) void *data)
5821 struct cmd_dump_result *res = parsed_result;
5823 if (!strcmp(res->dump, "dump_physmem"))
5824 rte_dump_physmem_layout(stdout);
5825 else if (!strcmp(res->dump, "dump_memzone"))
5826 rte_memzone_dump(stdout);
5827 else if (!strcmp(res->dump, "dump_log_history"))
5828 rte_log_dump_history(stdout);
5829 else if (!strcmp(res->dump, "dump_struct_sizes"))
5830 dump_struct_sizes();
5831 else if (!strcmp(res->dump, "dump_ring"))
5832 rte_ring_list_dump(stdout);
5833 else if (!strcmp(res->dump, "dump_mempool"))
5834 rte_mempool_list_dump(stdout);
5835 else if (!strcmp(res->dump, "dump_devargs"))
5836 rte_eal_devargs_dump(stdout);
5839 cmdline_parse_token_string_t cmd_dump_dump =
5840 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
5844 "dump_struct_sizes#"
5849 cmdline_parse_inst_t cmd_dump = {
5850 .f = cmd_dump_parsed, /* function to call */
5851 .data = NULL, /* 2nd arg of func */
5852 .help_str = "dump status",
5853 .tokens = { /* token list, NULL terminated */
5854 (void *)&cmd_dump_dump,
5859 /* ******************************************************************************** */
5861 struct cmd_dump_one_result {
5862 cmdline_fixed_string_t dump;
5863 cmdline_fixed_string_t name;
5866 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
5867 __attribute__((unused)) void *data)
5869 struct cmd_dump_one_result *res = parsed_result;
5871 if (!strcmp(res->dump, "dump_ring")) {
5873 r = rte_ring_lookup(res->name);
5875 cmdline_printf(cl, "Cannot find ring\n");
5878 rte_ring_dump(stdout, r);
5879 } else if (!strcmp(res->dump, "dump_mempool")) {
5880 struct rte_mempool *mp;
5881 mp = rte_mempool_lookup(res->name);
5883 cmdline_printf(cl, "Cannot find mempool\n");
5886 rte_mempool_dump(stdout, mp);
5890 cmdline_parse_token_string_t cmd_dump_one_dump =
5891 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
5892 "dump_ring#dump_mempool");
5894 cmdline_parse_token_string_t cmd_dump_one_name =
5895 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
5897 cmdline_parse_inst_t cmd_dump_one = {
5898 .f = cmd_dump_one_parsed, /* function to call */
5899 .data = NULL, /* 2nd arg of func */
5900 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
5901 .tokens = { /* token list, NULL terminated */
5902 (void *)&cmd_dump_one_dump,
5903 (void *)&cmd_dump_one_name,
5908 /* *** ADD/REMOVE an ethertype FILTER *** */
5909 struct cmd_ethertype_filter_result {
5910 cmdline_fixed_string_t filter;
5912 cmdline_fixed_string_t ethertype;
5913 uint16_t ethertype_value;
5914 cmdline_fixed_string_t priority;
5915 cmdline_fixed_string_t priority_en;
5916 uint8_t priority_value;
5917 cmdline_fixed_string_t queue;
5919 cmdline_fixed_string_t index;
5920 uint16_t index_value;
5924 cmd_ethertype_filter_parsed(void *parsed_result,
5925 __attribute__((unused)) struct cmdline *cl,
5926 __attribute__((unused)) void *data)
5929 struct cmd_ethertype_filter_result *res = parsed_result;
5930 struct rte_ethertype_filter filter;
5932 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
5933 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
5934 filter.priority = res->priority_value;
5936 if (!strcmp(res->priority_en, "enable"))
5937 filter.priority_en = 1;
5938 if (!strcmp(res->filter, "add_ethertype_filter"))
5939 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
5941 &filter, res->queue_id);
5942 else if (!strcmp(res->filter, "remove_ethertype_filter"))
5943 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
5945 else if (!strcmp(res->filter, "get_ethertype_filter"))
5946 get_ethertype_filter(res->port_id, res->index_value);
5949 printf("ethertype filter setting error: (%s)\n",
5953 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
5954 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5956 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
5957 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5958 ethertype, "ethertype");
5959 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
5960 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5961 ethertype_value, UINT16);
5962 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
5963 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5964 priority, "priority");
5965 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
5966 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5967 priority_en, "enable#disable");
5968 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
5969 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5970 priority_value, UINT8);
5971 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
5972 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5974 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
5975 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5977 cmdline_parse_token_string_t cmd_ethertype_filter_index =
5978 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5980 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
5981 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5982 index_value, UINT16);
5983 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
5984 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5985 filter, "add_ethertype_filter");
5986 cmdline_parse_inst_t cmd_add_ethertype_filter = {
5987 .f = cmd_ethertype_filter_parsed,
5989 .help_str = "add an ethertype filter",
5991 (void *)&cmd_ethertype_filter_add_filter,
5992 (void *)&cmd_ethertype_filter_port_id,
5993 (void *)&cmd_ethertype_filter_ethertype,
5994 (void *)&cmd_ethertype_filter_ethertype_value,
5995 (void *)&cmd_ethertype_filter_priority,
5996 (void *)&cmd_ethertype_filter_priority_en,
5997 (void *)&cmd_ethertype_filter_priority_value,
5998 (void *)&cmd_ethertype_filter_queue,
5999 (void *)&cmd_ethertype_filter_queue_id,
6000 (void *)&cmd_ethertype_filter_index,
6001 (void *)&cmd_ethertype_filter_index_value,
6006 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
6007 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6008 filter, "remove_ethertype_filter");
6009 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
6010 .f = cmd_ethertype_filter_parsed,
6012 .help_str = "remove an ethertype filter",
6014 (void *)&cmd_ethertype_filter_remove_filter,
6015 (void *)&cmd_ethertype_filter_port_id,
6016 (void *)&cmd_ethertype_filter_index,
6017 (void *)&cmd_ethertype_filter_index_value,
6021 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
6022 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6023 filter, "get_ethertype_filter");
6024 cmdline_parse_inst_t cmd_get_ethertype_filter = {
6025 .f = cmd_ethertype_filter_parsed,
6027 .help_str = "get an ethertype filter",
6029 (void *)&cmd_ethertype_filter_get_filter,
6030 (void *)&cmd_ethertype_filter_port_id,
6031 (void *)&cmd_ethertype_filter_index,
6032 (void *)&cmd_ethertype_filter_index_value,
6037 /* *** set SYN filter *** */
6038 struct cmd_set_syn_filter_result {
6039 cmdline_fixed_string_t filter;
6041 cmdline_fixed_string_t priority;
6042 cmdline_fixed_string_t high;
6043 cmdline_fixed_string_t queue;
6048 cmd_set_syn_filter_parsed(void *parsed_result,
6049 __attribute__((unused)) struct cmdline *cl,
6050 __attribute__((unused)) void *data)
6053 struct cmd_set_syn_filter_result *res = parsed_result;
6054 struct rte_syn_filter filter;
6056 if (!strcmp(res->filter, "add_syn_filter")) {
6057 if (!strcmp(res->high, "high"))
6061 ret = rte_eth_dev_add_syn_filter(res->port_id,
6062 &filter, res->queue_id);
6063 } else if (!strcmp(res->filter, "remove_syn_filter"))
6064 ret = rte_eth_dev_remove_syn_filter(res->port_id);
6065 else if (!strcmp(res->filter, "get_syn_filter"))
6066 get_syn_filter(res->port_id);
6068 printf("syn filter setting error: (%s)\n", strerror(-ret));
6071 cmdline_parse_token_num_t cmd_syn_filter_portid =
6072 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6074 cmdline_parse_token_string_t cmd_syn_filter_priority =
6075 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6076 priority, "priority");
6077 cmdline_parse_token_string_t cmd_syn_filter_high =
6078 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6080 cmdline_parse_token_string_t cmd_syn_filter_queue =
6081 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6083 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6084 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6086 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
6087 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6088 filter, "add_syn_filter");
6089 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
6090 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6091 filter, "remove_syn_filter");
6092 cmdline_parse_inst_t cmd_add_syn_filter = {
6093 .f = cmd_set_syn_filter_parsed,
6095 .help_str = "add syn filter",
6097 (void *)&cmd_syn_filter_add_filter,
6098 (void *)&cmd_syn_filter_portid,
6099 (void *)&cmd_syn_filter_priority,
6100 (void *)&cmd_syn_filter_high,
6101 (void *)&cmd_syn_filter_queue,
6102 (void *)&cmd_syn_filter_queue_id,
6106 cmdline_parse_inst_t cmd_remove_syn_filter = {
6107 .f = cmd_set_syn_filter_parsed,
6109 .help_str = "remove syn filter",
6111 (void *)&cmd_syn_filter_remove_filter,
6112 (void *)&cmd_syn_filter_portid,
6117 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
6118 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6119 filter, "get_syn_filter");
6121 cmdline_parse_inst_t cmd_get_syn_filter = {
6122 .f = cmd_set_syn_filter_parsed,
6124 .help_str = "get syn filter",
6126 (void *)&cmd_syn_filter_get_filter,
6127 (void *)&cmd_syn_filter_portid,
6132 /* *** ADD/REMOVE A 2tuple FILTER *** */
6133 struct cmd_2tuple_filter_result {
6134 cmdline_fixed_string_t filter;
6136 cmdline_fixed_string_t protocol;
6137 uint8_t protocol_value;
6138 uint8_t protocol_mask;
6139 cmdline_fixed_string_t dst_port;
6140 uint16_t dst_port_value;
6141 uint16_t dst_port_mask;
6142 cmdline_fixed_string_t flags;
6143 uint8_t flags_value;
6144 cmdline_fixed_string_t priority;
6145 uint8_t priority_value;
6146 cmdline_fixed_string_t queue;
6148 cmdline_fixed_string_t index;
6149 uint16_t index_value;
6153 cmd_2tuple_filter_parsed(void *parsed_result,
6154 __attribute__((unused)) struct cmdline *cl,
6155 __attribute__((unused)) void *data)
6158 struct rte_2tuple_filter filter;
6159 struct cmd_2tuple_filter_result *res = parsed_result;
6161 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
6163 if (!strcmp(res->filter, "add_2tuple_filter")) {
6164 /* need convert to big endian. */
6165 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6166 filter.protocol = res->protocol_value;
6167 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
6168 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
6169 filter.priority = res->priority_value;
6170 filter.tcp_flags = res->flags_value;
6171 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
6172 res->index_value, &filter, res->queue_id);
6173 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
6174 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
6176 else if (!strcmp(res->filter, "get_2tuple_filter"))
6177 get_2tuple_filter(res->port_id, res->index_value);
6180 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
6183 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6184 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6186 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6187 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6188 protocol, "protocol");
6189 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6190 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6191 protocol_value, UINT8);
6192 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
6193 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6194 protocol_mask, UINT8);
6195 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6196 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6197 dst_port, "dst_port");
6198 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6199 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6200 dst_port_value, UINT16);
6201 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
6202 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6203 dst_port_mask, UINT16);
6204 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
6205 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6207 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
6208 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6209 flags_value, UINT8);
6210 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6211 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6212 priority, "priority");
6213 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6214 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6215 priority_value, UINT8);
6216 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6217 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6219 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6220 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6222 cmdline_parse_token_string_t cmd_2tuple_filter_index =
6223 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6225 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
6226 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6227 index_value, UINT16);
6228 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
6229 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6230 filter, "add_2tuple_filter");
6231 cmdline_parse_inst_t cmd_add_2tuple_filter = {
6232 .f = cmd_2tuple_filter_parsed,
6234 .help_str = "add a 2tuple filter",
6236 (void *)&cmd_2tuple_filter_add_filter,
6237 (void *)&cmd_2tuple_filter_port_id,
6238 (void *)&cmd_2tuple_filter_protocol,
6239 (void *)&cmd_2tuple_filter_protocol_value,
6240 (void *)&cmd_2tuple_filter_protocol_mask,
6241 (void *)&cmd_2tuple_filter_dst_port,
6242 (void *)&cmd_2tuple_filter_dst_port_value,
6243 (void *)&cmd_2tuple_filter_dst_port_mask,
6244 (void *)&cmd_2tuple_filter_flags,
6245 (void *)&cmd_2tuple_filter_flags_value,
6246 (void *)&cmd_2tuple_filter_priority,
6247 (void *)&cmd_2tuple_filter_priority_value,
6248 (void *)&cmd_2tuple_filter_queue,
6249 (void *)&cmd_2tuple_filter_queue_id,
6250 (void *)&cmd_2tuple_filter_index,
6251 (void *)&cmd_2tuple_filter_index_value,
6256 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
6257 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6258 filter, "remove_2tuple_filter");
6259 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
6260 .f = cmd_2tuple_filter_parsed,
6262 .help_str = "remove a 2tuple filter",
6264 (void *)&cmd_2tuple_filter_remove_filter,
6265 (void *)&cmd_2tuple_filter_port_id,
6266 (void *)&cmd_2tuple_filter_index,
6267 (void *)&cmd_2tuple_filter_index_value,
6271 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
6272 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6273 filter, "get_2tuple_filter");
6274 cmdline_parse_inst_t cmd_get_2tuple_filter = {
6275 .f = cmd_2tuple_filter_parsed,
6277 .help_str = "get a 2tuple filter",
6279 (void *)&cmd_2tuple_filter_get_filter,
6280 (void *)&cmd_2tuple_filter_port_id,
6281 (void *)&cmd_2tuple_filter_index,
6282 (void *)&cmd_2tuple_filter_index_value,
6287 /* *** ADD/REMOVE A 5tuple FILTER *** */
6288 struct cmd_5tuple_filter_result {
6289 cmdline_fixed_string_t filter;
6291 cmdline_fixed_string_t dst_ip;
6292 cmdline_ipaddr_t dst_ip_value;
6293 cmdline_fixed_string_t src_ip;
6294 cmdline_ipaddr_t src_ip_value;
6295 cmdline_fixed_string_t dst_port;
6296 uint16_t dst_port_value;
6297 cmdline_fixed_string_t src_port;
6298 uint16_t src_port_value;
6299 cmdline_fixed_string_t protocol;
6300 uint8_t protocol_value;
6301 cmdline_fixed_string_t mask;
6303 cmdline_fixed_string_t flags;
6304 uint8_t flags_value;
6305 cmdline_fixed_string_t priority;
6306 uint8_t priority_value;
6307 cmdline_fixed_string_t queue;
6309 cmdline_fixed_string_t index;
6310 uint16_t index_value;
6314 cmd_5tuple_filter_parsed(void *parsed_result,
6315 __attribute__((unused)) struct cmdline *cl,
6316 __attribute__((unused)) void *data)
6319 struct rte_5tuple_filter filter;
6320 struct cmd_5tuple_filter_result *res = parsed_result;
6322 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
6324 if (!strcmp(res->filter, "add_5tuple_filter")) {
6325 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
6326 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
6327 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
6328 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
6329 filter.protocol = res->protocol_value;
6330 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
6331 filter.priority = res->priority_value;
6332 filter.tcp_flags = res->flags_value;
6334 if (res->dst_ip_value.family == AF_INET)
6335 /* no need to convert, already big endian. */
6336 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
6338 if (filter.dst_ip_mask == 0) {
6339 printf("can not support ipv6 involved compare.\n");
6345 if (res->src_ip_value.family == AF_INET)
6346 /* no need to convert, already big endian. */
6347 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
6349 if (filter.src_ip_mask == 0) {
6350 printf("can not support ipv6 involved compare.\n");
6355 /* need convert to big endian. */
6356 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6357 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
6359 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
6360 res->index_value, &filter, res->queue_id);
6361 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
6362 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
6364 else if (!strcmp(res->filter, "get_5tuple_filter"))
6365 get_5tuple_filter(res->port_id, res->index_value);
6367 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
6371 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
6372 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6374 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
6375 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6377 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
6378 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6380 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
6381 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6383 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
6384 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6386 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
6387 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6388 dst_port, "dst_port");
6389 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
6390 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6391 dst_port_value, UINT16);
6392 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
6393 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6394 src_port, "src_port");
6395 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
6396 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6397 src_port_value, UINT16);
6398 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
6399 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6400 protocol, "protocol");
6401 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
6402 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6403 protocol_value, UINT8);
6404 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
6405 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6407 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
6408 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6410 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
6411 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6413 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
6414 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6415 flags_value, UINT8);
6416 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
6417 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6418 priority, "priority");
6419 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
6420 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6421 priority_value, UINT8);
6422 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
6423 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6425 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
6426 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6428 cmdline_parse_token_string_t cmd_5tuple_filter_index =
6429 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6431 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
6432 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6433 index_value, UINT16);
6435 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
6436 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6437 filter, "add_5tuple_filter");
6438 cmdline_parse_inst_t cmd_add_5tuple_filter = {
6439 .f = cmd_5tuple_filter_parsed,
6441 .help_str = "add a 5tuple filter",
6443 (void *)&cmd_5tuple_filter_add_filter,
6444 (void *)&cmd_5tuple_filter_port_id,
6445 (void *)&cmd_5tuple_filter_dst_ip,
6446 (void *)&cmd_5tuple_filter_dst_ip_value,
6447 (void *)&cmd_5tuple_filter_src_ip,
6448 (void *)&cmd_5tuple_filter_src_ip_value,
6449 (void *)&cmd_5tuple_filter_dst_port,
6450 (void *)&cmd_5tuple_filter_dst_port_value,
6451 (void *)&cmd_5tuple_filter_src_port,
6452 (void *)&cmd_5tuple_filter_src_port_value,
6453 (void *)&cmd_5tuple_filter_protocol,
6454 (void *)&cmd_5tuple_filter_protocol_value,
6455 (void *)&cmd_5tuple_filter_mask,
6456 (void *)&cmd_5tuple_filter_mask_value,
6457 (void *)&cmd_5tuple_filter_flags,
6458 (void *)&cmd_5tuple_filter_flags_value,
6459 (void *)&cmd_5tuple_filter_priority,
6460 (void *)&cmd_5tuple_filter_priority_value,
6461 (void *)&cmd_5tuple_filter_queue,
6462 (void *)&cmd_5tuple_filter_queue_id,
6463 (void *)&cmd_5tuple_filter_index,
6464 (void *)&cmd_5tuple_filter_index_value,
6469 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
6470 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6471 filter, "remove_5tuple_filter");
6472 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
6473 .f = cmd_5tuple_filter_parsed,
6475 .help_str = "remove a 5tuple filter",
6477 (void *)&cmd_5tuple_filter_remove_filter,
6478 (void *)&cmd_5tuple_filter_port_id,
6479 (void *)&cmd_5tuple_filter_index,
6480 (void *)&cmd_5tuple_filter_index_value,
6485 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
6486 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6487 filter, "get_5tuple_filter");
6488 cmdline_parse_inst_t cmd_get_5tuple_filter = {
6489 .f = cmd_5tuple_filter_parsed,
6491 .help_str = "get a 5tuple filter",
6493 (void *)&cmd_5tuple_filter_get_filter,
6494 (void *)&cmd_5tuple_filter_port_id,
6495 (void *)&cmd_5tuple_filter_index,
6496 (void *)&cmd_5tuple_filter_index_value,
6501 /* *** ADD/REMOVE A flex FILTER *** */
6502 struct cmd_flex_filter_result {
6503 cmdline_fixed_string_t filter;
6505 cmdline_fixed_string_t len;
6507 cmdline_fixed_string_t bytes;
6508 cmdline_fixed_string_t bytes_value;
6509 cmdline_fixed_string_t mask;
6510 cmdline_fixed_string_t mask_value;
6511 cmdline_fixed_string_t priority;
6512 uint8_t priority_value;
6513 cmdline_fixed_string_t queue;
6515 cmdline_fixed_string_t index;
6516 uint16_t index_value;
6519 static int xdigit2val(unsigned char c)
6524 else if (isupper(c))
6532 cmd_flex_filter_parsed(void *parsed_result,
6533 __attribute__((unused)) struct cmdline *cl,
6534 __attribute__((unused)) void *data)
6537 struct rte_flex_filter filter;
6538 struct cmd_flex_filter_result *res = parsed_result;
6539 char *bytes_ptr, *mask_ptr;
6547 if (!strcmp(res->filter, "add_flex_filter")) {
6548 if (res->len_value > 128) {
6549 printf("the len exceed the max length 128\n");
6552 memset(&filter, 0, sizeof(struct rte_flex_filter));
6553 filter.len = res->len_value;
6554 filter.priority = res->priority_value;
6555 bytes_ptr = res->bytes_value;
6556 mask_ptr = res->mask_value;
6559 /* translate bytes string to uint_32 array. */
6560 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
6561 (bytes_ptr[1] == 'X')))
6563 len = strnlen(bytes_ptr, res->len_value * 2);
6564 if (len == 0 || (len % 8 != 0)) {
6565 printf("please check len and bytes input\n");
6568 for (i = 0; i < len; i++) {
6570 if (isxdigit(c) == 0) {
6571 /* invalid characters. */
6572 printf("invalid input\n");
6575 val = xdigit2val(c);
6579 dword |= byte << (4 * mod - 4);
6584 filter.dwords[j] = dword;
6585 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
6591 /* translate mask string to uint8_t array. */
6593 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
6594 (mask_ptr[1] == 'X')))
6596 len = strnlen(mask_ptr, (res->len_value+3)/4);
6598 printf("invalid input\n");
6601 for (i = 0; i < len; i++) {
6603 if (isxdigit(c) == 0) {
6604 /* invalid characters. */
6605 printf("invalid input\n");
6608 val = xdigit2val(c);
6609 hex |= (uint8_t)(val & 0x8) >> 3;
6610 hex |= (uint8_t)(val & 0x4) >> 1;
6611 hex |= (uint8_t)(val & 0x2) << 1;
6612 hex |= (uint8_t)(val & 0x1) << 3;
6615 filter.mask[j] = byte;
6616 printf("mask[%d]:%02x ", j, filter.mask[j]);
6624 printf("call function rte_eth_dev_add_flex_filter: "
6625 "index = %d, queue-id = %d, len = %d, priority = %d\n",
6626 res->index_value, res->queue_id,
6627 filter.len, filter.priority);
6628 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
6629 &filter, res->queue_id);
6631 } else if (!strcmp(res->filter, "remove_flex_filter"))
6632 ret = rte_eth_dev_remove_flex_filter(res->port_id,
6634 else if (!strcmp(res->filter, "get_flex_filter"))
6635 get_flex_filter(res->port_id, res->index_value);
6638 printf("flex filter setting error: (%s)\n", strerror(-ret));
6641 cmdline_parse_token_num_t cmd_flex_filter_port_id =
6642 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6644 cmdline_parse_token_string_t cmd_flex_filter_len =
6645 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6647 cmdline_parse_token_num_t cmd_flex_filter_len_value =
6648 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6650 cmdline_parse_token_string_t cmd_flex_filter_bytes =
6651 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6653 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
6654 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6656 cmdline_parse_token_string_t cmd_flex_filter_mask =
6657 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6659 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
6660 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6662 cmdline_parse_token_string_t cmd_flex_filter_priority =
6663 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6664 priority, "priority");
6665 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
6666 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6667 priority_value, UINT8);
6668 cmdline_parse_token_string_t cmd_flex_filter_queue =
6669 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6671 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
6672 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6674 cmdline_parse_token_string_t cmd_flex_filter_index =
6675 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6677 cmdline_parse_token_num_t cmd_flex_filter_index_value =
6678 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6679 index_value, UINT16);
6680 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
6681 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6682 filter, "add_flex_filter");
6683 cmdline_parse_inst_t cmd_add_flex_filter = {
6684 .f = cmd_flex_filter_parsed,
6686 .help_str = "add a flex filter",
6688 (void *)&cmd_flex_filter_add_filter,
6689 (void *)&cmd_flex_filter_port_id,
6690 (void *)&cmd_flex_filter_len,
6691 (void *)&cmd_flex_filter_len_value,
6692 (void *)&cmd_flex_filter_bytes,
6693 (void *)&cmd_flex_filter_bytes_value,
6694 (void *)&cmd_flex_filter_mask,
6695 (void *)&cmd_flex_filter_mask_value,
6696 (void *)&cmd_flex_filter_priority,
6697 (void *)&cmd_flex_filter_priority_value,
6698 (void *)&cmd_flex_filter_queue,
6699 (void *)&cmd_flex_filter_queue_id,
6700 (void *)&cmd_flex_filter_index,
6701 (void *)&cmd_flex_filter_index_value,
6706 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
6707 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6708 filter, "remove_flex_filter");
6709 cmdline_parse_inst_t cmd_remove_flex_filter = {
6710 .f = cmd_flex_filter_parsed,
6712 .help_str = "remove a flex filter",
6714 (void *)&cmd_flex_filter_remove_filter,
6715 (void *)&cmd_flex_filter_port_id,
6716 (void *)&cmd_flex_filter_index,
6717 (void *)&cmd_flex_filter_index_value,
6722 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
6723 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6724 filter, "get_flex_filter");
6725 cmdline_parse_inst_t cmd_get_flex_filter = {
6726 .f = cmd_flex_filter_parsed,
6728 .help_str = "get a flex filter",
6730 (void *)&cmd_flex_filter_get_filter,
6731 (void *)&cmd_flex_filter_port_id,
6732 (void *)&cmd_flex_filter_index,
6733 (void *)&cmd_flex_filter_index_value,
6738 /* ******************************************************************************** */
6740 /* list of instructions */
6741 cmdline_parse_ctx_t main_ctx[] = {
6742 (cmdline_parse_inst_t *)&cmd_help_brief,
6743 (cmdline_parse_inst_t *)&cmd_help_long,
6744 (cmdline_parse_inst_t *)&cmd_quit,
6745 (cmdline_parse_inst_t *)&cmd_showport,
6746 (cmdline_parse_inst_t *)&cmd_showportall,
6747 (cmdline_parse_inst_t *)&cmd_showcfg,
6748 (cmdline_parse_inst_t *)&cmd_start,
6749 (cmdline_parse_inst_t *)&cmd_start_tx_first,
6750 (cmdline_parse_inst_t *)&cmd_set_link_up,
6751 (cmdline_parse_inst_t *)&cmd_set_link_down,
6752 (cmdline_parse_inst_t *)&cmd_reset,
6753 (cmdline_parse_inst_t *)&cmd_set_numbers,
6754 (cmdline_parse_inst_t *)&cmd_set_txpkts,
6755 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
6756 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
6757 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
6758 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
6759 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
6760 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
6761 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
6762 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
6763 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
6764 (cmdline_parse_inst_t *)&cmd_set_link_check,
6765 #ifdef RTE_NIC_BYPASS
6766 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
6767 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
6768 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
6769 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
6771 (cmdline_parse_inst_t *)&cmd_vlan_offload,
6772 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
6773 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
6774 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
6775 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
6776 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
6777 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
6778 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
6779 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
6780 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
6781 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
6782 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
6783 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
6784 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
6785 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
6786 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
6787 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
6788 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
6789 (cmdline_parse_inst_t *)&cmd_config_dcb,
6790 (cmdline_parse_inst_t *)&cmd_read_reg,
6791 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
6792 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
6793 (cmdline_parse_inst_t *)&cmd_write_reg,
6794 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
6795 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
6796 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
6797 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
6798 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
6799 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
6800 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
6801 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
6802 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
6803 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
6804 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
6805 (cmdline_parse_inst_t *)&cmd_stop,
6806 (cmdline_parse_inst_t *)&cmd_mac_addr,
6807 (cmdline_parse_inst_t *)&cmd_set_qmap,
6808 (cmdline_parse_inst_t *)&cmd_operate_port,
6809 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
6810 (cmdline_parse_inst_t *)&cmd_config_speed_all,
6811 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
6812 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
6813 (cmdline_parse_inst_t *)&cmd_config_mtu,
6814 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
6815 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
6816 (cmdline_parse_inst_t *)&cmd_config_rss,
6817 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
6818 (cmdline_parse_inst_t *)&cmd_showport_reta,
6819 (cmdline_parse_inst_t *)&cmd_config_burst,
6820 (cmdline_parse_inst_t *)&cmd_config_thresh,
6821 (cmdline_parse_inst_t *)&cmd_config_threshold,
6822 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
6823 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
6824 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
6825 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
6826 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
6827 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
6828 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
6829 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
6830 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
6831 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
6832 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
6833 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
6834 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
6835 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
6836 (cmdline_parse_inst_t *)&cmd_dump,
6837 (cmdline_parse_inst_t *)&cmd_dump_one,
6838 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
6839 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
6840 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
6841 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
6842 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
6843 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
6844 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
6845 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
6846 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
6847 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
6848 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
6849 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
6850 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
6851 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
6852 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
6856 /* prompt function, called from main on MASTER lcore */
6862 /* initialize non-constant commands */
6863 cmd_set_fwd_mode_init();
6865 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
6869 cmdline_interact(cl);
6870 cmdline_stdin_exit(cl);
6874 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
6876 if (id < nb_ports) {
6877 /* check if need_reconfig has been set to 1 */
6878 if (ports[id].need_reconfig == 0)
6879 ports[id].need_reconfig = dev;
6880 /* check if need_reconfig_queues has been set to 1 */
6881 if (ports[id].need_reconfig_queues == 0)
6882 ports[id].need_reconfig_queues = queue;
6886 for (pid = 0; pid < nb_ports; pid++) {
6887 /* check if need_reconfig has been set to 1 */
6888 if (ports[pid].need_reconfig == 0)
6889 ports[pid].need_reconfig = dev;
6890 /* check if need_reconfig_queues has been set to 1 */
6891 if (ports[pid].need_reconfig_queues == 0)
6892 ports[pid].need_reconfig_queues = queue;
6897 #ifdef RTE_NIC_BYPASS
6899 bypass_is_supported(portid_t port_id)
6901 struct rte_port *port;
6902 struct rte_pci_id *pci_id;
6904 if (port_id >= nb_ports) {
6905 printf("\tPort id must be less than %d.\n", nb_ports);
6909 /* Get the device id. */
6910 port = &ports[port_id];
6911 pci_id = &port->dev_info.pci_dev->id;
6913 /* Check if NIC supports bypass. */
6914 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
6918 printf("\tBypass not supported for port_id = %d.\n", port_id);