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>
87 #ifdef RTE_LIBRTE_PMD_BOND
88 #include <rte_eth_bond.h>
93 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
96 uint8_t bypass_is_supported(portid_t port_id);
99 /* *** Help command with introduction. *** */
100 struct cmd_help_brief_result {
101 cmdline_fixed_string_t help;
104 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
106 __attribute__((unused)) void *data)
111 "Help is available for the following sections:\n\n"
112 " help control : Start and stop forwarding.\n"
113 " help display : Displaying port, stats and config "
115 " help config : Configuration information.\n"
116 " help ports : Configuring ports.\n"
117 " help flowdir : Flow Director filter help.\n"
118 " help registers : Reading and setting port registers.\n"
119 " help filters : Filters configuration help.\n"
120 " help all : All of the above sections.\n\n"
125 cmdline_parse_token_string_t cmd_help_brief_help =
126 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
128 cmdline_parse_inst_t cmd_help_brief = {
129 .f = cmd_help_brief_parsed,
131 .help_str = "show help",
133 (void *)&cmd_help_brief_help,
138 /* *** Help command with help sections. *** */
139 struct cmd_help_long_result {
140 cmdline_fixed_string_t help;
141 cmdline_fixed_string_t section;
144 static void cmd_help_long_parsed(void *parsed_result,
146 __attribute__((unused)) void *data)
149 struct cmd_help_long_result *res = parsed_result;
151 if (!strcmp(res->section, "all"))
154 if (show_all || !strcmp(res->section, "control")) {
159 "Control forwarding:\n"
160 "-------------------\n\n"
163 " Start packet forwarding with current configuration.\n\n"
166 " Start packet forwarding with current config"
167 " after sending one burst of packets.\n\n"
170 " Stop packet forwarding, and display accumulated"
174 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
178 if (show_all || !strcmp(res->section, "display")) {
186 "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
187 " Display information for port_id, or all.\n\n"
189 "show port rss-hash [key]\n"
190 " Display the RSS hash functions and RSS hash key"
193 "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
194 " Clear information for port_id, or all.\n\n"
196 "show config (rxtx|cores|fwd)\n"
197 " Display the given configuration.\n\n"
199 "read rxd (port_id) (queue_id) (rxd_id)\n"
200 " Display an RX descriptor of a port RX queue.\n\n"
202 "read txd (port_id) (queue_id) (txd_id)\n"
203 " Display a TX descriptor of a port TX queue.\n\n"
207 if (show_all || !strcmp(res->section, "config")) {
213 "Configuration changes only become active when"
214 " forwarding is started/restarted.\n\n"
217 " Reset forwarding to the default configuration.\n\n"
219 "set verbose (level)\n"
220 " Set the debug verbosity level X.\n\n"
223 " Set number of ports.\n\n"
226 " Set number of cores.\n\n"
228 "set coremask (mask)\n"
229 " Set the forwarding cores hexadecimal mask.\n\n"
231 "set portmask (mask)\n"
232 " Set the forwarding ports hexadecimal mask.\n\n"
235 " Set number of packets per burst.\n\n"
237 "set burst tx delay (microseconds) retry (num)\n"
238 " Set the transmit delay time and number of retries"
239 " in mac_retry forwarding mode.\n\n"
241 "set txpkts (x[,y]*)\n"
242 " Set the length of each segment of TXONLY"
245 "set corelist (x[,y]*)\n"
246 " Set the list of forwarding cores.\n\n"
248 "set portlist (x[,y]*)\n"
249 " Set the list of forwarding ports.\n\n"
251 "vlan set strip (on|off) (port_id)\n"
252 " Set the VLAN strip on a port.\n\n"
254 "vlan set stripq (on|off) (port_id,queue_id)\n"
255 " Set the VLAN strip for a queue on a port.\n\n"
257 "vlan set filter (on|off) (port_id)\n"
258 " Set the VLAN filter on a port.\n\n"
260 "vlan set qinq (on|off) (port_id)\n"
261 " Set the VLAN QinQ (extended queue in queue)"
264 "vlan set tpid (value) (port_id)\n"
265 " Set the outer VLAN TPID for Packet Filtering on"
268 "rx_vlan add (vlan_id|all) (port_id)\n"
269 " Add a vlan_id, or all identifiers, to the set"
270 " of VLAN identifiers filtered by port_id.\n\n"
272 "rx_vlan rm (vlan_id|all) (port_id)\n"
273 " Remove a vlan_id, or all identifiers, from the set"
274 " of VLAN identifiers filtered by port_id.\n\n"
276 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
277 " Add a vlan_id, to the set of VLAN identifiers"
278 "filtered for VF(s) from port_id.\n\n"
280 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
281 " Remove a vlan_id, to the set of VLAN identifiers"
282 "filtered for VF(s) from port_id.\n\n"
284 "rx_vlan set tpid (value) (port_id)\n"
285 " Set the outer VLAN TPID for Packet Filtering on"
288 "tx_vlan set vlan_id (port_id)\n"
289 " Set hardware insertion of VLAN ID in packets sent"
292 "tx_vlan set pvid port_id vlan_id (on|off)\n"
293 " Set port based TX VLAN insertion.\n\n"
295 "tx_vlan reset (port_id)\n"
296 " Disable hardware insertion of a VLAN header in"
297 " packets sent on a port.\n\n"
299 "tx_checksum set mask (port_id)\n"
300 " Enable hardware insertion of checksum offload with"
301 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
302 " bit 0 - insert ip checksum offload if set\n"
303 " bit 1 - insert udp checksum offload if set\n"
304 " bit 2 - insert tcp checksum offload if set\n"
305 " bit 3 - insert sctp checksum offload if set\n"
306 " Please check the NIC datasheet for HW limits.\n\n"
309 " Set packet forwarding mode.\n\n"
311 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
312 " Add a MAC address on port_id.\n\n"
314 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
315 " Remove a MAC address from port_id.\n\n"
317 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
318 " Add a MAC address for a VF on the port.\n\n"
320 "set port (port_id) uta (mac_address|all) (on|off)\n"
321 " Add/Remove a or all unicast hash filter(s)"
324 "set promisc (port_id|all) (on|off)\n"
325 " Set the promiscuous mode on port_id, or all.\n\n"
327 "set allmulti (port_id|all) (on|off)\n"
328 " Set the allmulti mode on port_id, or all.\n\n"
330 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
331 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
332 " (on|off) autoneg (on|off) (port_id)\n"
333 "set flow_ctrl rx (on|off) (portid)\n"
334 "set flow_ctrl tx (on|off) (portid)\n"
335 "set flow_ctrl high_water (high_water) (portid)\n"
336 "set flow_ctrl low_water (low_water) (portid)\n"
337 "set flow_ctrl pause_time (pause_time) (portid)\n"
338 "set flow_ctrl send_xon (send_xon) (portid)\n"
339 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
340 "set flow_ctrl autoneg (on|off) (port_id)\n"
341 " Set the link flow control parameter on a port.\n\n"
343 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
344 " (low_water) (pause_time) (priority) (port_id)\n"
345 " Set the priority flow control parameter on a"
348 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
349 " Set statistics mapping (qmapping 0..15) for RX/TX"
351 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
352 " on port 0 to mapping 5.\n\n"
354 "set port (port_id) vf (vf_id) rx|tx on|off \n"
355 " Enable/Disable a VF receive/tranmit from a port\n\n"
357 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
359 " AUPE:accepts untagged VLAN;"
360 "ROPE:accept unicast hash\n\n"
361 " BAM:accepts broadcast packets;"
362 "MPE:accepts all multicast packets\n\n"
363 " Enable/Disable a VF receive mode of a port\n\n"
365 "set port (port_id) queue (queue_id) rate (rate_num)\n"
366 " Set rate limit for a queue of a port\n\n"
368 "set port (port_id) vf (vf_id) rate (rate_num) "
369 "queue_mask (queue_mask_value)\n"
370 " Set rate limit for queues in VF of a port\n\n"
372 "set port (port_id) mirror-rule (rule_id)"
373 "(pool-mirror|vlan-mirror)\n"
374 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
375 " Set pool or vlan type mirror rule on a port.\n"
376 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
377 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
380 "set port (port_id) mirror-rule (rule_id)"
381 " (uplink-mirror|downlink-mirror) dst-pool"
382 " (pool_id) (on|off)\n"
383 " Set uplink or downlink type mirror rule on a port.\n"
384 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
385 " 0 on' enable mirror income traffic to pool 0.\n\n"
387 "reset port (port_id) mirror-rule (rule_id)\n"
388 " Reset a mirror rule.\n\n"
390 "set flush_rx (on|off)\n"
391 " Flush (default) or don't flush RX streams before"
392 " forwarding. Mainly used with PCAP drivers.\n\n"
394 #ifdef RTE_NIC_BYPASS
395 "set bypass mode (normal|bypass|isolate) (port_id)\n"
396 " Set the bypass mode for the lowest port on bypass enabled"
399 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
400 "mode (normal|bypass|isolate) (port_id)\n"
401 " Set the event required to initiate specified bypass mode for"
402 " the lowest port on a bypass enabled NIC where:\n"
403 " timeout = enable bypass after watchdog timeout.\n"
404 " os_on = enable bypass when OS/board is powered on.\n"
405 " os_off = enable bypass when OS/board is powered off.\n"
406 " power_on = enable bypass when power supply is turned on.\n"
407 " power_off = enable bypass when power supply is turned off."
410 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
411 " Set the bypass watchdog timeout to 'n' seconds"
412 " where 0 = instant.\n\n"
414 "show bypass config (port_id)\n"
415 " Show the bypass configuration for a bypass enabled NIC"
416 " using the lowest port on the NIC.\n\n"
418 #ifdef RTE_LIBRTE_PMD_BOND
419 "create bonded device (mode) (socket)\n"
420 " Create a new bonded device with specific bonding mode and socket.\n\n"
422 "add bonding slave (slave_id) (port_id)\n"
423 " Add a slave device to a bonded device.\n\n"
425 "remove bonding slave (slave_id) (port_id)\n"
426 " Remove a slave device from a bonded device.\n\n"
428 "set bonding mode (value) (port_id)\n"
429 " Set the bonding mode on a bonded device.\n\n"
431 "set bonding primary (slave_id) (port_id)\n"
432 " Set the primary slave for a bonded device.\n\n"
434 "show bonding config (port_id)\n"
435 " Show the bonding config for port_id.\n\n"
437 "set bonding mac_addr (port_id) (address)\n"
438 " Set the MAC address of a bonded device.\n\n"
440 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
441 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
444 , list_pkt_forwarding_modes()
449 if (show_all || !strcmp(res->section, "flowdir")) {
454 "Flow director mode:\n"
455 "-------------------\n\n"
457 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
458 " src (src_ip_address) (src_port)"
459 " dst (dst_ip_address) (dst_port)"
460 " flexbytes (flexbytes_values) vlan (vlan_id)"
461 " queue (queue_id)\n"
462 " Add a signature filter.\n\n"
464 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
465 " src (src_ip_address) (src_port)"
466 " dst (dst_ip_address) (dst_port)"
467 " flexbytes (flexbytes_values) vlan (vlan_id)"
468 " queue (queue_id)\n"
469 " Update a signature filter.\n\n"
471 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
472 " src (src_ip_address) (src_port)"
473 " dst (dst_ip_address) (dst_port)"
474 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
475 " Remove a signature filter.\n\n"
477 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
478 " src (src_ip_address) (src_port)"
479 " dst (dst_ip_address) (dst_port)"
480 " flexbytes (flexbytes_values) vlan (vlan_id)"
481 " queue (queue_id) soft (soft_id)\n"
482 " Add a perfect filter.\n\n"
484 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
485 " src (src_ip_address) (src_port)"
486 " dst (dst_ip_address) (dst_port)"
487 " flexbytes (flexbytes_values) vlan (vlan_id)"
488 " queue (queue_id)\n"
489 " Update a perfect filter.\n\n"
491 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
492 " src (src_ip_address) (src_port)"
493 " dst (dst_ip_address) (dst_port)"
494 " flexbytes (flexbytes_values) vlan (vlan_id)"
496 " Remove a perfect filter.\n\n"
498 "set_masks_filter (port_id) only_ip_flow (0|1)"
499 " src_mask (ip_src_mask) (src_port_mask)"
500 " dst_mask (ip_dst_mask) (dst_port_mask)"
501 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
502 " Set IPv4 filter masks.\n\n"
504 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
505 " src_mask (ip_src_mask) (src_port_mask)"
506 " dst_mask (ip_dst_mask) (dst_port_mask)"
507 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
508 " compare_dst (0|1)\n"
509 " Set IPv6 filter masks.\n\n"
513 if (show_all || !strcmp(res->section, "ports")) {
519 "----------------\n\n"
521 "port start (port_id|all)\n"
522 " Start all ports or port_id.\n\n"
524 "port stop (port_id|all)\n"
525 " Stop all ports or port_id.\n\n"
527 "port close (port_id|all)\n"
528 " Close all ports or port_id.\n\n"
530 "port config (port_id|all)"
531 " speed (10|100|1000|10000|40000|auto)"
532 " duplex (half|full|auto)\n"
533 " Set speed and duplex for all ports or port_id\n\n"
535 "port config all (rxq|txq|rxd|txd) (value)\n"
536 " Set number for rxq/txq/rxd/txd.\n\n"
538 "port config all max-pkt-len (value)\n"
539 " Set the max packet length.\n\n"
541 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
543 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
546 "port config all rss (ip|udp|none)\n"
547 " Set the RSS mode.\n\n"
549 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
550 " Set the RSS redirection table.\n\n"
552 "port config (port_id) dcb vt (on|off) (traffic_class)"
554 " Set the DCB mode.\n\n"
556 "port config all burst (value)\n"
557 " Set the number of packets per burst.\n\n"
559 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
561 " Set the ring prefetch/host/writeback threshold"
562 " for tx/rx queue.\n\n"
564 "port config all (txfreet|txrst|rxfreet) (value)\n"
565 " Set free threshold for rx/tx, or set"
566 " tx rs bit threshold.\n\n"
567 "port config mtu X value\n"
568 " Set the MTU of port X to a given value\n\n"
572 if (show_all || !strcmp(res->section, "registers")) {
580 "read reg (port_id) (address)\n"
581 " Display value of a port register.\n\n"
583 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
584 " Display a port register bit field.\n\n"
586 "read regbit (port_id) (address) (bit_x)\n"
587 " Display a single port register bit.\n\n"
589 "write reg (port_id) (address) (value)\n"
590 " Set value of a port register.\n\n"
592 "write regfield (port_id) (address) (bit_x) (bit_y)"
594 " Set bit field of a port register.\n\n"
596 "write regbit (port_id) (address) (bit_x) (value)\n"
597 " Set single bit value of a port register.\n\n"
600 if (show_all || !strcmp(res->section, "filters")) {
608 "add_ethertype_filter (port_id) ethertype (eth_value)"
609 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
610 " add an ethertype filter.\n\n"
612 "remove_ethertype_filter (port_id) index (idx)\n"
613 " remove an ethertype filter.\n\n"
615 "get_ethertype_filter (port_id) index (idx)\n"
616 " get info of a ethertype filter.\n\n"
618 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
619 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
620 " queue (queue_id) index (idx)\n"
621 " add a 2tuple filter.\n\n"
623 "remove_2tuple_filter (port_id) index (idx)\n"
624 " remove a 2tuple filter.\n\n"
626 "get_2tuple_filter (port_id) index (idx)\n"
627 " get info of a 2tuple filter.\n\n"
629 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
630 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
631 " mask (mask_value) flags (flags_value) priority (prio_value)"
632 " queue (queue_id) index (idx)\n"
633 " add a 5tuple filter.\n\n"
635 "remove_5tuple_filter (port_id) index (idx)\n"
636 " remove a 5tuple filter.\n\n"
638 "get_5tuple_filter (port_id) index (idx)\n"
639 " get info of a 5tuple filter.\n\n"
641 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
642 " add syn filter.\n\n"
644 "remove_syn_filter (port_id)"
645 " remove syn filter.\n\n"
647 "get_syn_filter (port_id) "
648 " get syn filter info.\n\n"
650 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
651 " priority (prio_value) queue (queue_id) index (idx)\n"
652 " add a flex filter.\n\n"
654 "remove_flex_filter (port_id) index (idx)\n"
655 " remove a flex filter.\n\n"
657 "get_flex_filter (port_id) index (idx)\n"
658 " get info of a flex filter.\n\n"
663 cmdline_parse_token_string_t cmd_help_long_help =
664 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
666 cmdline_parse_token_string_t cmd_help_long_section =
667 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
668 "all#control#display#config#flowdir#"
669 "ports#registers#filters");
671 cmdline_parse_inst_t cmd_help_long = {
672 .f = cmd_help_long_parsed,
674 .help_str = "show help",
676 (void *)&cmd_help_long_help,
677 (void *)&cmd_help_long_section,
683 /* *** start/stop/close all ports *** */
684 struct cmd_operate_port_result {
685 cmdline_fixed_string_t keyword;
686 cmdline_fixed_string_t name;
687 cmdline_fixed_string_t value;
690 static void cmd_operate_port_parsed(void *parsed_result,
691 __attribute__((unused)) struct cmdline *cl,
692 __attribute__((unused)) void *data)
694 struct cmd_operate_port_result *res = parsed_result;
696 if (!strcmp(res->name, "start"))
697 start_port(RTE_PORT_ALL);
698 else if (!strcmp(res->name, "stop"))
699 stop_port(RTE_PORT_ALL);
700 else if (!strcmp(res->name, "close"))
701 close_port(RTE_PORT_ALL);
703 printf("Unknown parameter\n");
706 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
707 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
709 cmdline_parse_token_string_t cmd_operate_port_all_port =
710 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
712 cmdline_parse_token_string_t cmd_operate_port_all_all =
713 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
715 cmdline_parse_inst_t cmd_operate_port = {
716 .f = cmd_operate_port_parsed,
718 .help_str = "port start|stop|close all: start/stop/close all ports",
720 (void *)&cmd_operate_port_all_cmd,
721 (void *)&cmd_operate_port_all_port,
722 (void *)&cmd_operate_port_all_all,
727 /* *** start/stop/close specific port *** */
728 struct cmd_operate_specific_port_result {
729 cmdline_fixed_string_t keyword;
730 cmdline_fixed_string_t name;
734 static void cmd_operate_specific_port_parsed(void *parsed_result,
735 __attribute__((unused)) struct cmdline *cl,
736 __attribute__((unused)) void *data)
738 struct cmd_operate_specific_port_result *res = parsed_result;
740 if (!strcmp(res->name, "start"))
741 start_port(res->value);
742 else if (!strcmp(res->name, "stop"))
743 stop_port(res->value);
744 else if (!strcmp(res->name, "close"))
745 close_port(res->value);
747 printf("Unknown parameter\n");
750 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
751 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
753 cmdline_parse_token_string_t cmd_operate_specific_port_port =
754 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
755 name, "start#stop#close");
756 cmdline_parse_token_num_t cmd_operate_specific_port_id =
757 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
760 cmdline_parse_inst_t cmd_operate_specific_port = {
761 .f = cmd_operate_specific_port_parsed,
763 .help_str = "port start|stop|close X: start/stop/close port X",
765 (void *)&cmd_operate_specific_port_cmd,
766 (void *)&cmd_operate_specific_port_port,
767 (void *)&cmd_operate_specific_port_id,
772 /* *** configure speed for all ports *** */
773 struct cmd_config_speed_all {
774 cmdline_fixed_string_t port;
775 cmdline_fixed_string_t keyword;
776 cmdline_fixed_string_t all;
777 cmdline_fixed_string_t item1;
778 cmdline_fixed_string_t item2;
779 cmdline_fixed_string_t value1;
780 cmdline_fixed_string_t value2;
784 cmd_config_speed_all_parsed(void *parsed_result,
785 __attribute__((unused)) struct cmdline *cl,
786 __attribute__((unused)) void *data)
788 struct cmd_config_speed_all *res = parsed_result;
789 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
790 uint16_t link_duplex = 0;
793 if (!all_ports_stopped()) {
794 printf("Please stop all ports first\n");
798 if (!strcmp(res->value1, "10"))
799 link_speed = ETH_LINK_SPEED_10;
800 else if (!strcmp(res->value1, "100"))
801 link_speed = ETH_LINK_SPEED_100;
802 else if (!strcmp(res->value1, "1000"))
803 link_speed = ETH_LINK_SPEED_1000;
804 else if (!strcmp(res->value1, "10000"))
805 link_speed = ETH_LINK_SPEED_10G;
806 else if (!strcmp(res->value1, "40000"))
807 link_speed = ETH_LINK_SPEED_40G;
808 else if (!strcmp(res->value1, "auto"))
809 link_speed = ETH_LINK_SPEED_AUTONEG;
811 printf("Unknown parameter\n");
815 if (!strcmp(res->value2, "half"))
816 link_duplex = ETH_LINK_HALF_DUPLEX;
817 else if (!strcmp(res->value2, "full"))
818 link_duplex = ETH_LINK_FULL_DUPLEX;
819 else if (!strcmp(res->value2, "auto"))
820 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
822 printf("Unknown parameter\n");
826 for (pid = 0; pid < nb_ports; pid++) {
827 ports[pid].dev_conf.link_speed = link_speed;
828 ports[pid].dev_conf.link_duplex = link_duplex;
831 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
834 cmdline_parse_token_string_t cmd_config_speed_all_port =
835 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
836 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
837 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
839 cmdline_parse_token_string_t cmd_config_speed_all_all =
840 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
841 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
842 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
843 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
844 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
845 "10#100#1000#10000#40000#auto");
846 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
847 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
848 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
849 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
852 cmdline_parse_inst_t cmd_config_speed_all = {
853 .f = cmd_config_speed_all_parsed,
855 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
858 (void *)&cmd_config_speed_all_port,
859 (void *)&cmd_config_speed_all_keyword,
860 (void *)&cmd_config_speed_all_all,
861 (void *)&cmd_config_speed_all_item1,
862 (void *)&cmd_config_speed_all_value1,
863 (void *)&cmd_config_speed_all_item2,
864 (void *)&cmd_config_speed_all_value2,
869 /* *** configure speed for specific port *** */
870 struct cmd_config_speed_specific {
871 cmdline_fixed_string_t port;
872 cmdline_fixed_string_t keyword;
874 cmdline_fixed_string_t item1;
875 cmdline_fixed_string_t item2;
876 cmdline_fixed_string_t value1;
877 cmdline_fixed_string_t value2;
881 cmd_config_speed_specific_parsed(void *parsed_result,
882 __attribute__((unused)) struct cmdline *cl,
883 __attribute__((unused)) void *data)
885 struct cmd_config_speed_specific *res = parsed_result;
886 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
887 uint16_t link_duplex = 0;
889 if (!all_ports_stopped()) {
890 printf("Please stop all ports first\n");
894 if (res->id >= nb_ports) {
895 printf("Port id %d must be less than %d\n", res->id, nb_ports);
899 if (!strcmp(res->value1, "10"))
900 link_speed = ETH_LINK_SPEED_10;
901 else if (!strcmp(res->value1, "100"))
902 link_speed = ETH_LINK_SPEED_100;
903 else if (!strcmp(res->value1, "1000"))
904 link_speed = ETH_LINK_SPEED_1000;
905 else if (!strcmp(res->value1, "10000"))
906 link_speed = ETH_LINK_SPEED_10000;
907 else if (!strcmp(res->value1, "40000"))
908 link_speed = ETH_LINK_SPEED_40G;
909 else if (!strcmp(res->value1, "auto"))
910 link_speed = ETH_LINK_SPEED_AUTONEG;
912 printf("Unknown parameter\n");
916 if (!strcmp(res->value2, "half"))
917 link_duplex = ETH_LINK_HALF_DUPLEX;
918 else if (!strcmp(res->value2, "full"))
919 link_duplex = ETH_LINK_FULL_DUPLEX;
920 else if (!strcmp(res->value2, "auto"))
921 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
923 printf("Unknown parameter\n");
927 ports[res->id].dev_conf.link_speed = link_speed;
928 ports[res->id].dev_conf.link_duplex = link_duplex;
930 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
934 cmdline_parse_token_string_t cmd_config_speed_specific_port =
935 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
937 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
938 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
940 cmdline_parse_token_num_t cmd_config_speed_specific_id =
941 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
942 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
943 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
945 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
946 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
947 "10#100#1000#10000#40000#auto");
948 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
949 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
951 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
952 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
955 cmdline_parse_inst_t cmd_config_speed_specific = {
956 .f = cmd_config_speed_specific_parsed,
958 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
961 (void *)&cmd_config_speed_specific_port,
962 (void *)&cmd_config_speed_specific_keyword,
963 (void *)&cmd_config_speed_specific_id,
964 (void *)&cmd_config_speed_specific_item1,
965 (void *)&cmd_config_speed_specific_value1,
966 (void *)&cmd_config_speed_specific_item2,
967 (void *)&cmd_config_speed_specific_value2,
972 /* *** configure txq/rxq, txd/rxd *** */
973 struct cmd_config_rx_tx {
974 cmdline_fixed_string_t port;
975 cmdline_fixed_string_t keyword;
976 cmdline_fixed_string_t all;
977 cmdline_fixed_string_t name;
982 cmd_config_rx_tx_parsed(void *parsed_result,
983 __attribute__((unused)) struct cmdline *cl,
984 __attribute__((unused)) void *data)
986 struct cmd_config_rx_tx *res = parsed_result;
988 if (!all_ports_stopped()) {
989 printf("Please stop all ports first\n");
993 if (!strcmp(res->name, "rxq")) {
994 if (res->value <= 0) {
995 printf("rxq %d invalid - must be > 0\n", res->value);
1000 else if (!strcmp(res->name, "txq")) {
1001 if (res->value <= 0) {
1002 printf("txq %d invalid - must be > 0\n", res->value);
1005 nb_txq = res->value;
1007 else if (!strcmp(res->name, "rxd")) {
1008 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1009 printf("rxd %d invalid - must be > 0 && <= %d\n",
1010 res->value, RTE_TEST_RX_DESC_MAX);
1013 nb_rxd = res->value;
1014 } else if (!strcmp(res->name, "txd")) {
1015 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1016 printf("txd %d invalid - must be > 0 && <= %d\n",
1017 res->value, RTE_TEST_TX_DESC_MAX);
1020 nb_txd = res->value;
1022 printf("Unknown parameter\n");
1028 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1031 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1032 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1033 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1034 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1035 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1036 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1037 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1038 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1040 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1041 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1043 cmdline_parse_inst_t cmd_config_rx_tx = {
1044 .f = cmd_config_rx_tx_parsed,
1046 .help_str = "port config all rxq|txq|rxd|txd value",
1048 (void *)&cmd_config_rx_tx_port,
1049 (void *)&cmd_config_rx_tx_keyword,
1050 (void *)&cmd_config_rx_tx_all,
1051 (void *)&cmd_config_rx_tx_name,
1052 (void *)&cmd_config_rx_tx_value,
1057 /* *** config max packet length *** */
1058 struct cmd_config_max_pkt_len_result {
1059 cmdline_fixed_string_t port;
1060 cmdline_fixed_string_t keyword;
1061 cmdline_fixed_string_t all;
1062 cmdline_fixed_string_t name;
1067 cmd_config_max_pkt_len_parsed(void *parsed_result,
1068 __attribute__((unused)) struct cmdline *cl,
1069 __attribute__((unused)) void *data)
1071 struct cmd_config_max_pkt_len_result *res = parsed_result;
1073 if (!all_ports_stopped()) {
1074 printf("Please stop all ports first\n");
1078 if (!strcmp(res->name, "max-pkt-len")) {
1079 if (res->value < ETHER_MIN_LEN) {
1080 printf("max-pkt-len can not be less than %d\n",
1084 if (res->value == rx_mode.max_rx_pkt_len)
1087 rx_mode.max_rx_pkt_len = res->value;
1088 if (res->value > ETHER_MAX_LEN)
1089 rx_mode.jumbo_frame = 1;
1091 rx_mode.jumbo_frame = 0;
1093 printf("Unknown parameter\n");
1099 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1102 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1103 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1105 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1106 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1108 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1109 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1111 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1112 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1114 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1115 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1118 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1119 .f = cmd_config_max_pkt_len_parsed,
1121 .help_str = "port config all max-pkt-len value",
1123 (void *)&cmd_config_max_pkt_len_port,
1124 (void *)&cmd_config_max_pkt_len_keyword,
1125 (void *)&cmd_config_max_pkt_len_all,
1126 (void *)&cmd_config_max_pkt_len_name,
1127 (void *)&cmd_config_max_pkt_len_value,
1132 /* *** configure port MTU *** */
1133 struct cmd_config_mtu_result {
1134 cmdline_fixed_string_t port;
1135 cmdline_fixed_string_t keyword;
1136 cmdline_fixed_string_t mtu;
1142 cmd_config_mtu_parsed(void *parsed_result,
1143 __attribute__((unused)) struct cmdline *cl,
1144 __attribute__((unused)) void *data)
1146 struct cmd_config_mtu_result *res = parsed_result;
1148 if (res->value < ETHER_MIN_LEN) {
1149 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1152 port_mtu_set(res->port_id, res->value);
1155 cmdline_parse_token_string_t cmd_config_mtu_port =
1156 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1158 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1159 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1161 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1162 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1164 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1165 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1166 cmdline_parse_token_num_t cmd_config_mtu_value =
1167 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1169 cmdline_parse_inst_t cmd_config_mtu = {
1170 .f = cmd_config_mtu_parsed,
1172 .help_str = "port config mtu value",
1174 (void *)&cmd_config_mtu_port,
1175 (void *)&cmd_config_mtu_keyword,
1176 (void *)&cmd_config_mtu_mtu,
1177 (void *)&cmd_config_mtu_port_id,
1178 (void *)&cmd_config_mtu_value,
1183 /* *** configure rx mode *** */
1184 struct cmd_config_rx_mode_flag {
1185 cmdline_fixed_string_t port;
1186 cmdline_fixed_string_t keyword;
1187 cmdline_fixed_string_t all;
1188 cmdline_fixed_string_t name;
1189 cmdline_fixed_string_t value;
1193 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1194 __attribute__((unused)) struct cmdline *cl,
1195 __attribute__((unused)) void *data)
1197 struct cmd_config_rx_mode_flag *res = parsed_result;
1199 if (!all_ports_stopped()) {
1200 printf("Please stop all ports first\n");
1204 if (!strcmp(res->name, "crc-strip")) {
1205 if (!strcmp(res->value, "on"))
1206 rx_mode.hw_strip_crc = 1;
1207 else if (!strcmp(res->value, "off"))
1208 rx_mode.hw_strip_crc = 0;
1210 printf("Unknown parameter\n");
1213 } else if (!strcmp(res->name, "rx-cksum")) {
1214 if (!strcmp(res->value, "on"))
1215 rx_mode.hw_ip_checksum = 1;
1216 else if (!strcmp(res->value, "off"))
1217 rx_mode.hw_ip_checksum = 0;
1219 printf("Unknown parameter\n");
1222 } else if (!strcmp(res->name, "hw-vlan")) {
1223 if (!strcmp(res->value, "on")) {
1224 rx_mode.hw_vlan_filter = 1;
1225 rx_mode.hw_vlan_strip = 1;
1227 else if (!strcmp(res->value, "off")) {
1228 rx_mode.hw_vlan_filter = 0;
1229 rx_mode.hw_vlan_strip = 0;
1232 printf("Unknown parameter\n");
1235 } else if (!strcmp(res->name, "drop-en")) {
1236 if (!strcmp(res->value, "on"))
1238 else if (!strcmp(res->value, "off"))
1241 printf("Unknown parameter\n");
1245 printf("Unknown parameter\n");
1251 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1254 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1255 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1256 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1257 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1259 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1260 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1261 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1262 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1263 "crc-strip#rx-cksum#hw-vlan");
1264 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1265 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1268 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1269 .f = cmd_config_rx_mode_flag_parsed,
1271 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1273 (void *)&cmd_config_rx_mode_flag_port,
1274 (void *)&cmd_config_rx_mode_flag_keyword,
1275 (void *)&cmd_config_rx_mode_flag_all,
1276 (void *)&cmd_config_rx_mode_flag_name,
1277 (void *)&cmd_config_rx_mode_flag_value,
1282 /* *** configure rss *** */
1283 struct cmd_config_rss {
1284 cmdline_fixed_string_t port;
1285 cmdline_fixed_string_t keyword;
1286 cmdline_fixed_string_t all;
1287 cmdline_fixed_string_t name;
1288 cmdline_fixed_string_t value;
1292 cmd_config_rss_parsed(void *parsed_result,
1293 __attribute__((unused)) struct cmdline *cl,
1294 __attribute__((unused)) void *data)
1296 struct cmd_config_rss *res = parsed_result;
1297 struct rte_eth_rss_conf rss_conf;
1300 if (!strcmp(res->value, "ip"))
1301 rss_conf.rss_hf = ETH_RSS_IP;
1302 else if (!strcmp(res->value, "udp"))
1303 rss_conf.rss_hf = ETH_RSS_UDP;
1304 else if (!strcmp(res->value, "none"))
1305 rss_conf.rss_hf = 0;
1307 printf("Unknown parameter\n");
1310 rss_conf.rss_key = NULL;
1311 for (i = 0; i < rte_eth_dev_count(); i++)
1312 rte_eth_dev_rss_hash_update(i, &rss_conf);
1315 cmdline_parse_token_string_t cmd_config_rss_port =
1316 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1317 cmdline_parse_token_string_t cmd_config_rss_keyword =
1318 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1319 cmdline_parse_token_string_t cmd_config_rss_all =
1320 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1321 cmdline_parse_token_string_t cmd_config_rss_name =
1322 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1323 cmdline_parse_token_string_t cmd_config_rss_value =
1324 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1326 cmdline_parse_inst_t cmd_config_rss = {
1327 .f = cmd_config_rss_parsed,
1329 .help_str = "port config all rss ip|udp|none",
1331 (void *)&cmd_config_rss_port,
1332 (void *)&cmd_config_rss_keyword,
1333 (void *)&cmd_config_rss_all,
1334 (void *)&cmd_config_rss_name,
1335 (void *)&cmd_config_rss_value,
1340 /* *** configure rss hash key *** */
1341 struct cmd_config_rss_hash_key {
1342 cmdline_fixed_string_t port;
1343 cmdline_fixed_string_t config;
1345 cmdline_fixed_string_t rss_hash_key;
1346 cmdline_fixed_string_t key;
1349 #define RSS_HASH_KEY_LENGTH 40
1351 hexa_digit_to_value(char hexa_digit)
1353 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1354 return (uint8_t) (hexa_digit - '0');
1355 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1356 return (uint8_t) ((hexa_digit - 'a') + 10);
1357 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1358 return (uint8_t) ((hexa_digit - 'A') + 10);
1359 /* Invalid hexa digit */
1364 parse_and_check_key_hexa_digit(char *key, int idx)
1368 hexa_v = hexa_digit_to_value(key[idx]);
1370 printf("invalid key: character %c at position %d is not a "
1371 "valid hexa digit\n", key[idx], idx);
1376 cmd_config_rss_hash_key_parsed(void *parsed_result,
1377 __attribute__((unused)) struct cmdline *cl,
1378 __attribute__((unused)) void *data)
1380 struct cmd_config_rss_hash_key *res = parsed_result;
1381 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1386 /* Check the length of the RSS hash key */
1387 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1388 printf("key length: %d invalid - key must be a string of %d"
1389 "hexa-decimal numbers\n", (int) strlen(res->key),
1390 RSS_HASH_KEY_LENGTH * 2);
1393 /* Translate RSS hash key into binary representation */
1394 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1395 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1398 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1401 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1403 port_rss_hash_key_update(res->port_id, hash_key);
1406 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1407 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1408 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1409 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1411 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1412 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1413 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1414 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1415 rss_hash_key, "rss-hash-key");
1416 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1419 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1420 .f = cmd_config_rss_hash_key_parsed,
1422 .help_str = "port config X rss-hash-key 80 hexa digits",
1424 (void *)&cmd_config_rss_hash_key_port,
1425 (void *)&cmd_config_rss_hash_key_config,
1426 (void *)&cmd_config_rss_hash_key_port_id,
1427 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1428 (void *)&cmd_config_rss_hash_key_value,
1433 /* *** Configure RSS RETA *** */
1434 struct cmd_config_rss_reta {
1435 cmdline_fixed_string_t port;
1436 cmdline_fixed_string_t keyword;
1438 cmdline_fixed_string_t name;
1439 cmdline_fixed_string_t list_name;
1440 cmdline_fixed_string_t list_of_items;
1444 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1451 const char *p, *p0 = str;
1458 unsigned long int_fld[_NUM_FLD];
1459 char *str_fld[_NUM_FLD];
1461 while ((p = strchr(p0,'(')) != NULL) {
1463 if((p0 = strchr(p,')')) == NULL)
1467 if(size >= sizeof(s))
1470 snprintf(s, sizeof(s), "%.*s", size, p);
1471 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1473 for (i = 0; i < _NUM_FLD; i++) {
1475 int_fld[i] = strtoul(str_fld[i], &end, 0);
1476 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1480 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1481 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1483 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1484 printf("Invalid RETA hash index=%d",hash_index);
1488 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1489 reta_conf->mask_lo |= (1ULL << hash_index);
1491 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1493 reta_conf->reta[hash_index] = nb_queue;
1500 cmd_set_rss_reta_parsed(void *parsed_result,
1501 __attribute__((unused)) struct cmdline *cl,
1502 __attribute__((unused)) void *data)
1505 struct rte_eth_rss_reta reta_conf;
1506 struct cmd_config_rss_reta *res = parsed_result;
1508 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1509 if (!strcmp(res->list_name, "reta")) {
1510 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1511 printf("Invalid RSS Redirection Table config entered\n");
1514 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1516 printf("Bad redirection table parameter, return code = %d \n",ret);
1520 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1521 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1522 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1523 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1524 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1525 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1526 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1527 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1528 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1529 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1530 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1531 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1533 cmdline_parse_inst_t cmd_config_rss_reta = {
1534 .f = cmd_set_rss_reta_parsed,
1536 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1538 (void *)&cmd_config_rss_reta_port,
1539 (void *)&cmd_config_rss_reta_keyword,
1540 (void *)&cmd_config_rss_reta_port_id,
1541 (void *)&cmd_config_rss_reta_name,
1542 (void *)&cmd_config_rss_reta_list_name,
1543 (void *)&cmd_config_rss_reta_list_of_items,
1548 /* *** SHOW PORT RETA INFO *** */
1549 struct cmd_showport_reta {
1550 cmdline_fixed_string_t show;
1551 cmdline_fixed_string_t port;
1553 cmdline_fixed_string_t rss;
1554 cmdline_fixed_string_t reta;
1559 static void cmd_showport_reta_parsed(void *parsed_result,
1560 __attribute__((unused)) struct cmdline *cl,
1561 __attribute__((unused)) void *data)
1563 struct cmd_showport_reta *res = parsed_result;
1564 struct rte_eth_rss_reta reta_conf;
1566 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1567 printf("Invalid RSS Redirection Table config entered\n");
1571 reta_conf.mask_lo = res->mask_lo;
1572 reta_conf.mask_hi = res->mask_hi;
1574 port_rss_reta_info(res->port_id,&reta_conf);
1577 cmdline_parse_token_string_t cmd_showport_reta_show =
1578 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1579 cmdline_parse_token_string_t cmd_showport_reta_port =
1580 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1581 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1582 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1583 cmdline_parse_token_string_t cmd_showport_reta_rss =
1584 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1585 cmdline_parse_token_string_t cmd_showport_reta_reta =
1586 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1587 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1588 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1589 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1590 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1592 cmdline_parse_inst_t cmd_showport_reta = {
1593 .f = cmd_showport_reta_parsed,
1595 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1596 (mask_lo and mask_hi is UINT64)",
1598 (void *)&cmd_showport_reta_show,
1599 (void *)&cmd_showport_reta_port,
1600 (void *)&cmd_showport_reta_port_id,
1601 (void *)&cmd_showport_reta_rss,
1602 (void *)&cmd_showport_reta_reta,
1603 (void *)&cmd_showport_reta_mask_lo,
1604 (void *)&cmd_showport_reta_mask_hi,
1609 /* *** Show RSS hash configuration *** */
1610 struct cmd_showport_rss_hash {
1611 cmdline_fixed_string_t show;
1612 cmdline_fixed_string_t port;
1614 cmdline_fixed_string_t rss_hash;
1615 cmdline_fixed_string_t key; /* optional argument */
1618 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1619 __attribute__((unused)) struct cmdline *cl,
1622 struct cmd_showport_rss_hash *res = parsed_result;
1624 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1627 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1628 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1629 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1630 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1631 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1632 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1633 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1634 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1636 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1637 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1639 cmdline_parse_inst_t cmd_showport_rss_hash = {
1640 .f = cmd_showport_rss_hash_parsed,
1642 .help_str = "show port X rss-hash (X = port number)\n",
1644 (void *)&cmd_showport_rss_hash_show,
1645 (void *)&cmd_showport_rss_hash_port,
1646 (void *)&cmd_showport_rss_hash_port_id,
1647 (void *)&cmd_showport_rss_hash_rss_hash,
1652 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1653 .f = cmd_showport_rss_hash_parsed,
1655 .help_str = "show port X rss-hash key (X = port number)\n",
1657 (void *)&cmd_showport_rss_hash_show,
1658 (void *)&cmd_showport_rss_hash_port,
1659 (void *)&cmd_showport_rss_hash_port_id,
1660 (void *)&cmd_showport_rss_hash_rss_hash,
1661 (void *)&cmd_showport_rss_hash_rss_key,
1666 /* *** Configure DCB *** */
1667 struct cmd_config_dcb {
1668 cmdline_fixed_string_t port;
1669 cmdline_fixed_string_t config;
1671 cmdline_fixed_string_t dcb;
1672 cmdline_fixed_string_t vt;
1673 cmdline_fixed_string_t vt_en;
1675 cmdline_fixed_string_t pfc;
1676 cmdline_fixed_string_t pfc_en;
1680 cmd_config_dcb_parsed(void *parsed_result,
1681 __attribute__((unused)) struct cmdline *cl,
1682 __attribute__((unused)) void *data)
1684 struct cmd_config_dcb *res = parsed_result;
1685 struct dcb_config dcb_conf;
1686 portid_t port_id = res->port_id;
1687 struct rte_port *port;
1689 port = &ports[port_id];
1690 /** Check if the port is not started **/
1691 if (port->port_status != RTE_PORT_STOPPED) {
1692 printf("Please stop port %d first\n",port_id);
1696 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1697 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1698 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1702 /* DCB in VT mode */
1703 if (!strncmp(res->vt_en, "on",2))
1704 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1706 dcb_conf.dcb_mode = DCB_ENABLED;
1708 if (!strncmp(res->pfc_en, "on",2)) {
1709 dcb_conf.pfc_en = 1;
1712 dcb_conf.pfc_en = 0;
1714 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1715 printf("Cannot initialize network ports\n");
1719 cmd_reconfig_device_queue(port_id, 1, 1);
1722 cmdline_parse_token_string_t cmd_config_dcb_port =
1723 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1724 cmdline_parse_token_string_t cmd_config_dcb_config =
1725 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1726 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1727 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1728 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1729 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1730 cmdline_parse_token_string_t cmd_config_dcb_vt =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1732 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1733 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1734 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1735 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1736 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1738 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1739 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1741 cmdline_parse_inst_t cmd_config_dcb = {
1742 .f = cmd_config_dcb_parsed,
1744 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1746 (void *)&cmd_config_dcb_port,
1747 (void *)&cmd_config_dcb_config,
1748 (void *)&cmd_config_dcb_port_id,
1749 (void *)&cmd_config_dcb_dcb,
1750 (void *)&cmd_config_dcb_vt,
1751 (void *)&cmd_config_dcb_vt_en,
1752 (void *)&cmd_config_dcb_num_tcs,
1753 (void *)&cmd_config_dcb_pfc,
1754 (void *)&cmd_config_dcb_pfc_en,
1759 /* *** configure number of packets per burst *** */
1760 struct cmd_config_burst {
1761 cmdline_fixed_string_t port;
1762 cmdline_fixed_string_t keyword;
1763 cmdline_fixed_string_t all;
1764 cmdline_fixed_string_t name;
1769 cmd_config_burst_parsed(void *parsed_result,
1770 __attribute__((unused)) struct cmdline *cl,
1771 __attribute__((unused)) void *data)
1773 struct cmd_config_burst *res = parsed_result;
1775 if (!all_ports_stopped()) {
1776 printf("Please stop all ports first\n");
1780 if (!strcmp(res->name, "burst")) {
1781 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1782 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1785 nb_pkt_per_burst = res->value;
1787 printf("Unknown parameter\n");
1793 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1796 cmdline_parse_token_string_t cmd_config_burst_port =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1798 cmdline_parse_token_string_t cmd_config_burst_keyword =
1799 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1800 cmdline_parse_token_string_t cmd_config_burst_all =
1801 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1802 cmdline_parse_token_string_t cmd_config_burst_name =
1803 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1804 cmdline_parse_token_num_t cmd_config_burst_value =
1805 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1807 cmdline_parse_inst_t cmd_config_burst = {
1808 .f = cmd_config_burst_parsed,
1810 .help_str = "port config all burst value",
1812 (void *)&cmd_config_burst_port,
1813 (void *)&cmd_config_burst_keyword,
1814 (void *)&cmd_config_burst_all,
1815 (void *)&cmd_config_burst_name,
1816 (void *)&cmd_config_burst_value,
1821 /* *** configure rx/tx queues *** */
1822 struct cmd_config_thresh {
1823 cmdline_fixed_string_t port;
1824 cmdline_fixed_string_t keyword;
1825 cmdline_fixed_string_t all;
1826 cmdline_fixed_string_t name;
1831 cmd_config_thresh_parsed(void *parsed_result,
1832 __attribute__((unused)) struct cmdline *cl,
1833 __attribute__((unused)) void *data)
1835 struct cmd_config_thresh *res = parsed_result;
1837 if (!all_ports_stopped()) {
1838 printf("Please stop all ports first\n");
1842 if (!strcmp(res->name, "txpt"))
1843 tx_thresh.pthresh = res->value;
1844 else if(!strcmp(res->name, "txht"))
1845 tx_thresh.hthresh = res->value;
1846 else if(!strcmp(res->name, "txwt"))
1847 tx_thresh.wthresh = res->value;
1848 else if(!strcmp(res->name, "rxpt"))
1849 rx_thresh.pthresh = res->value;
1850 else if(!strcmp(res->name, "rxht"))
1851 rx_thresh.hthresh = res->value;
1852 else if(!strcmp(res->name, "rxwt"))
1853 rx_thresh.wthresh = res->value;
1855 printf("Unknown parameter\n");
1861 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1864 cmdline_parse_token_string_t cmd_config_thresh_port =
1865 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1866 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1867 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1868 cmdline_parse_token_string_t cmd_config_thresh_all =
1869 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1870 cmdline_parse_token_string_t cmd_config_thresh_name =
1871 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1872 "txpt#txht#txwt#rxpt#rxht#rxwt");
1873 cmdline_parse_token_num_t cmd_config_thresh_value =
1874 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1876 cmdline_parse_inst_t cmd_config_thresh = {
1877 .f = cmd_config_thresh_parsed,
1879 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1881 (void *)&cmd_config_thresh_port,
1882 (void *)&cmd_config_thresh_keyword,
1883 (void *)&cmd_config_thresh_all,
1884 (void *)&cmd_config_thresh_name,
1885 (void *)&cmd_config_thresh_value,
1890 /* *** configure free/rs threshold *** */
1891 struct cmd_config_threshold {
1892 cmdline_fixed_string_t port;
1893 cmdline_fixed_string_t keyword;
1894 cmdline_fixed_string_t all;
1895 cmdline_fixed_string_t name;
1900 cmd_config_threshold_parsed(void *parsed_result,
1901 __attribute__((unused)) struct cmdline *cl,
1902 __attribute__((unused)) void *data)
1904 struct cmd_config_threshold *res = parsed_result;
1906 if (!all_ports_stopped()) {
1907 printf("Please stop all ports first\n");
1911 if (!strcmp(res->name, "txfreet"))
1912 tx_free_thresh = res->value;
1913 else if (!strcmp(res->name, "txrst"))
1914 tx_rs_thresh = res->value;
1915 else if (!strcmp(res->name, "rxfreet"))
1916 rx_free_thresh = res->value;
1918 printf("Unknown parameter\n");
1924 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1927 cmdline_parse_token_string_t cmd_config_threshold_port =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1929 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1930 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1932 cmdline_parse_token_string_t cmd_config_threshold_all =
1933 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1934 cmdline_parse_token_string_t cmd_config_threshold_name =
1935 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1936 "txfreet#txrst#rxfreet");
1937 cmdline_parse_token_num_t cmd_config_threshold_value =
1938 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1940 cmdline_parse_inst_t cmd_config_threshold = {
1941 .f = cmd_config_threshold_parsed,
1943 .help_str = "port config all txfreet|txrst|rxfreet value",
1945 (void *)&cmd_config_threshold_port,
1946 (void *)&cmd_config_threshold_keyword,
1947 (void *)&cmd_config_threshold_all,
1948 (void *)&cmd_config_threshold_name,
1949 (void *)&cmd_config_threshold_value,
1955 struct cmd_stop_result {
1956 cmdline_fixed_string_t stop;
1959 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1960 __attribute__((unused)) struct cmdline *cl,
1961 __attribute__((unused)) void *data)
1963 stop_packet_forwarding();
1966 cmdline_parse_token_string_t cmd_stop_stop =
1967 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1969 cmdline_parse_inst_t cmd_stop = {
1970 .f = cmd_stop_parsed,
1972 .help_str = "stop - stop packet forwarding",
1974 (void *)&cmd_stop_stop,
1979 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1982 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1983 unsigned int *parsed_items, int check_unique_values)
1985 unsigned int nb_item;
1993 * First parse all items in the list and store their value.
1998 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2000 if ((c >= '0') && (c <= '9')) {
2001 value = (unsigned int) (value * 10 + (c - '0'));
2006 printf("character %c is not a decimal digit\n", c);
2010 printf("No valid value before comma\n");
2013 if (nb_item < max_items) {
2014 parsed_items[nb_item] = value;
2020 if (nb_item >= max_items) {
2021 printf("Number of %s = %u > %u (maximum items)\n",
2022 item_name, nb_item + 1, max_items);
2025 parsed_items[nb_item++] = value;
2026 if (! check_unique_values)
2030 * Then, check that all values in the list are differents.
2031 * No optimization here...
2033 for (i = 0; i < nb_item; i++) {
2034 for (j = i + 1; j < nb_item; j++) {
2035 if (parsed_items[j] == parsed_items[i]) {
2036 printf("duplicated %s %u at index %u and %u\n",
2037 item_name, parsed_items[i], i, j);
2045 struct cmd_set_list_result {
2046 cmdline_fixed_string_t cmd_keyword;
2047 cmdline_fixed_string_t list_name;
2048 cmdline_fixed_string_t list_of_items;
2051 static void cmd_set_list_parsed(void *parsed_result,
2052 __attribute__((unused)) struct cmdline *cl,
2053 __attribute__((unused)) void *data)
2055 struct cmd_set_list_result *res;
2057 unsigned int lcorelist[RTE_MAX_LCORE];
2058 unsigned int portlist[RTE_MAX_ETHPORTS];
2060 unsigned int nb_item;
2062 res = parsed_result;
2063 if (!strcmp(res->list_name, "corelist")) {
2064 nb_item = parse_item_list(res->list_of_items, "core",
2066 parsed_items.lcorelist, 1);
2068 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2071 if (!strcmp(res->list_name, "portlist")) {
2072 nb_item = parse_item_list(res->list_of_items, "port",
2074 parsed_items.portlist, 1);
2076 set_fwd_ports_list(parsed_items.portlist, nb_item);
2080 cmdline_parse_token_string_t cmd_set_list_keyword =
2081 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2083 cmdline_parse_token_string_t cmd_set_list_name =
2084 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2085 "corelist#portlist");
2086 cmdline_parse_token_string_t cmd_set_list_of_items =
2087 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2090 cmdline_parse_inst_t cmd_set_fwd_list = {
2091 .f = cmd_set_list_parsed,
2093 .help_str = "set corelist|portlist x[,y]*",
2095 (void *)&cmd_set_list_keyword,
2096 (void *)&cmd_set_list_name,
2097 (void *)&cmd_set_list_of_items,
2102 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2104 struct cmd_setmask_result {
2105 cmdline_fixed_string_t set;
2106 cmdline_fixed_string_t mask;
2110 static void cmd_set_mask_parsed(void *parsed_result,
2111 __attribute__((unused)) struct cmdline *cl,
2112 __attribute__((unused)) void *data)
2114 struct cmd_setmask_result *res = parsed_result;
2116 if (!strcmp(res->mask, "coremask"))
2117 set_fwd_lcores_mask(res->hexavalue);
2118 else if (!strcmp(res->mask, "portmask"))
2119 set_fwd_ports_mask(res->hexavalue);
2122 cmdline_parse_token_string_t cmd_setmask_set =
2123 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2124 cmdline_parse_token_string_t cmd_setmask_mask =
2125 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2126 "coremask#portmask");
2127 cmdline_parse_token_num_t cmd_setmask_value =
2128 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2130 cmdline_parse_inst_t cmd_set_fwd_mask = {
2131 .f = cmd_set_mask_parsed,
2133 .help_str = "set coremask|portmask hexadecimal value",
2135 (void *)&cmd_setmask_set,
2136 (void *)&cmd_setmask_mask,
2137 (void *)&cmd_setmask_value,
2143 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2145 struct cmd_set_result {
2146 cmdline_fixed_string_t set;
2147 cmdline_fixed_string_t what;
2151 static void cmd_set_parsed(void *parsed_result,
2152 __attribute__((unused)) struct cmdline *cl,
2153 __attribute__((unused)) void *data)
2155 struct cmd_set_result *res = parsed_result;
2156 if (!strcmp(res->what, "nbport"))
2157 set_fwd_ports_number(res->value);
2158 else if (!strcmp(res->what, "nbcore"))
2159 set_fwd_lcores_number(res->value);
2160 else if (!strcmp(res->what, "burst"))
2161 set_nb_pkt_per_burst(res->value);
2162 else if (!strcmp(res->what, "verbose"))
2163 set_verbose_level(res->value);
2166 cmdline_parse_token_string_t cmd_set_set =
2167 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2168 cmdline_parse_token_string_t cmd_set_what =
2169 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2170 "nbport#nbcore#burst#verbose");
2171 cmdline_parse_token_num_t cmd_set_value =
2172 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2174 cmdline_parse_inst_t cmd_set_numbers = {
2175 .f = cmd_set_parsed,
2177 .help_str = "set nbport|nbcore|burst|verbose value",
2179 (void *)&cmd_set_set,
2180 (void *)&cmd_set_what,
2181 (void *)&cmd_set_value,
2186 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2188 struct cmd_set_txpkts_result {
2189 cmdline_fixed_string_t cmd_keyword;
2190 cmdline_fixed_string_t txpkts;
2191 cmdline_fixed_string_t seg_lengths;
2195 cmd_set_txpkts_parsed(void *parsed_result,
2196 __attribute__((unused)) struct cmdline *cl,
2197 __attribute__((unused)) void *data)
2199 struct cmd_set_txpkts_result *res;
2200 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2201 unsigned int nb_segs;
2203 res = parsed_result;
2204 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2205 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2207 set_tx_pkt_segments(seg_lengths, nb_segs);
2210 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2211 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2212 cmd_keyword, "set");
2213 cmdline_parse_token_string_t cmd_set_txpkts_name =
2214 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2216 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2217 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2220 cmdline_parse_inst_t cmd_set_txpkts = {
2221 .f = cmd_set_txpkts_parsed,
2223 .help_str = "set txpkts x[,y]*",
2225 (void *)&cmd_set_txpkts_keyword,
2226 (void *)&cmd_set_txpkts_name,
2227 (void *)&cmd_set_txpkts_lengths,
2232 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2233 struct cmd_rx_vlan_filter_all_result {
2234 cmdline_fixed_string_t rx_vlan;
2235 cmdline_fixed_string_t what;
2236 cmdline_fixed_string_t all;
2241 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2242 __attribute__((unused)) struct cmdline *cl,
2243 __attribute__((unused)) void *data)
2245 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2247 if (!strcmp(res->what, "add"))
2248 rx_vlan_all_filter_set(res->port_id, 1);
2250 rx_vlan_all_filter_set(res->port_id, 0);
2253 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2254 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2255 rx_vlan, "rx_vlan");
2256 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2257 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2259 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2260 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2262 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2263 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2266 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2267 .f = cmd_rx_vlan_filter_all_parsed,
2269 .help_str = "add/remove all identifiers to/from the set of VLAN "
2270 "Identifiers filtered by a port",
2272 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2273 (void *)&cmd_rx_vlan_filter_all_what,
2274 (void *)&cmd_rx_vlan_filter_all_all,
2275 (void *)&cmd_rx_vlan_filter_all_portid,
2280 /* *** VLAN OFFLOAD SET ON A PORT *** */
2281 struct cmd_vlan_offload_result {
2282 cmdline_fixed_string_t vlan;
2283 cmdline_fixed_string_t set;
2284 cmdline_fixed_string_t what;
2285 cmdline_fixed_string_t on;
2286 cmdline_fixed_string_t port_id;
2290 cmd_vlan_offload_parsed(void *parsed_result,
2291 __attribute__((unused)) struct cmdline *cl,
2292 __attribute__((unused)) void *data)
2295 struct cmd_vlan_offload_result *res = parsed_result;
2298 portid_t port_id = 0;
2302 len = strnlen(str, STR_TOKEN_SIZE);
2304 /* Get port_id first */
2312 tmp = strtoul(str, NULL, 0);
2313 /* If port_id greater that what portid_t can represent, return */
2314 if(tmp >= RTE_MAX_ETHPORTS)
2316 port_id = (portid_t)tmp;
2318 if (!strcmp(res->on, "on"))
2323 if (!strcmp(res->what, "strip"))
2324 rx_vlan_strip_set(port_id, on);
2325 else if(!strcmp(res->what, "stripq")){
2326 uint16_t queue_id = 0;
2328 /* No queue_id, return */
2330 printf("must specify (port,queue_id)\n");
2333 tmp = strtoul(str + i + 1, NULL, 0);
2334 /* If queue_id greater that what 16-bits can represent, return */
2338 queue_id = (uint16_t)tmp;
2339 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2341 else if (!strcmp(res->what, "filter"))
2342 rx_vlan_filter_set(port_id, on);
2344 vlan_extend_set(port_id, on);
2349 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2350 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2352 cmdline_parse_token_string_t cmd_vlan_offload_set =
2353 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2355 cmdline_parse_token_string_t cmd_vlan_offload_what =
2356 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2357 what, "strip#filter#qinq#stripq");
2358 cmdline_parse_token_string_t cmd_vlan_offload_on =
2359 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2361 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2362 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2365 cmdline_parse_inst_t cmd_vlan_offload = {
2366 .f = cmd_vlan_offload_parsed,
2368 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2369 " qinq(extended) for both rx/tx sides ",
2371 (void *)&cmd_vlan_offload_vlan,
2372 (void *)&cmd_vlan_offload_set,
2373 (void *)&cmd_vlan_offload_what,
2374 (void *)&cmd_vlan_offload_on,
2375 (void *)&cmd_vlan_offload_portid,
2380 /* *** VLAN TPID SET ON A PORT *** */
2381 struct cmd_vlan_tpid_result {
2382 cmdline_fixed_string_t vlan;
2383 cmdline_fixed_string_t set;
2384 cmdline_fixed_string_t what;
2390 cmd_vlan_tpid_parsed(void *parsed_result,
2391 __attribute__((unused)) struct cmdline *cl,
2392 __attribute__((unused)) void *data)
2394 struct cmd_vlan_tpid_result *res = parsed_result;
2395 vlan_tpid_set(res->port_id, res->tp_id);
2399 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2400 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2402 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2403 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2405 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2406 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2408 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2409 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2411 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2412 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2415 cmdline_parse_inst_t cmd_vlan_tpid = {
2416 .f = cmd_vlan_tpid_parsed,
2418 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2420 (void *)&cmd_vlan_tpid_vlan,
2421 (void *)&cmd_vlan_tpid_set,
2422 (void *)&cmd_vlan_tpid_what,
2423 (void *)&cmd_vlan_tpid_tpid,
2424 (void *)&cmd_vlan_tpid_portid,
2429 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2430 struct cmd_rx_vlan_filter_result {
2431 cmdline_fixed_string_t rx_vlan;
2432 cmdline_fixed_string_t what;
2438 cmd_rx_vlan_filter_parsed(void *parsed_result,
2439 __attribute__((unused)) struct cmdline *cl,
2440 __attribute__((unused)) void *data)
2442 struct cmd_rx_vlan_filter_result *res = parsed_result;
2444 if (!strcmp(res->what, "add"))
2445 rx_vft_set(res->port_id, res->vlan_id, 1);
2447 rx_vft_set(res->port_id, res->vlan_id, 0);
2450 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2451 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2452 rx_vlan, "rx_vlan");
2453 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2454 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2456 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2457 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2459 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2460 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2463 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2464 .f = cmd_rx_vlan_filter_parsed,
2466 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2467 "Identifiers filtered by a port",
2469 (void *)&cmd_rx_vlan_filter_rx_vlan,
2470 (void *)&cmd_rx_vlan_filter_what,
2471 (void *)&cmd_rx_vlan_filter_vlanid,
2472 (void *)&cmd_rx_vlan_filter_portid,
2477 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2478 struct cmd_tx_vlan_set_result {
2479 cmdline_fixed_string_t tx_vlan;
2480 cmdline_fixed_string_t set;
2486 cmd_tx_vlan_set_parsed(void *parsed_result,
2487 __attribute__((unused)) struct cmdline *cl,
2488 __attribute__((unused)) void *data)
2490 struct cmd_tx_vlan_set_result *res = parsed_result;
2491 tx_vlan_set(res->port_id, res->vlan_id);
2494 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2495 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2496 tx_vlan, "tx_vlan");
2497 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2498 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2500 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2501 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2503 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2504 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2507 cmdline_parse_inst_t cmd_tx_vlan_set = {
2508 .f = cmd_tx_vlan_set_parsed,
2510 .help_str = "enable hardware insertion of a VLAN header with a given "
2511 "TAG Identifier in packets sent on a port",
2513 (void *)&cmd_tx_vlan_set_tx_vlan,
2514 (void *)&cmd_tx_vlan_set_set,
2515 (void *)&cmd_tx_vlan_set_vlanid,
2516 (void *)&cmd_tx_vlan_set_portid,
2521 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2522 struct cmd_tx_vlan_set_pvid_result {
2523 cmdline_fixed_string_t tx_vlan;
2524 cmdline_fixed_string_t set;
2525 cmdline_fixed_string_t pvid;
2528 cmdline_fixed_string_t mode;
2532 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2533 __attribute__((unused)) struct cmdline *cl,
2534 __attribute__((unused)) void *data)
2536 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2538 if (strcmp(res->mode, "on") == 0)
2539 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2541 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2544 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2545 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2546 tx_vlan, "tx_vlan");
2547 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2548 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2550 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2551 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2553 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2554 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2556 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2557 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2559 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2560 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2563 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2564 .f = cmd_tx_vlan_set_pvid_parsed,
2566 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2568 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2569 (void *)&cmd_tx_vlan_set_pvid_set,
2570 (void *)&cmd_tx_vlan_set_pvid_pvid,
2571 (void *)&cmd_tx_vlan_set_pvid_port_id,
2572 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2573 (void *)&cmd_tx_vlan_set_pvid_mode,
2578 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2579 struct cmd_tx_vlan_reset_result {
2580 cmdline_fixed_string_t tx_vlan;
2581 cmdline_fixed_string_t reset;
2586 cmd_tx_vlan_reset_parsed(void *parsed_result,
2587 __attribute__((unused)) struct cmdline *cl,
2588 __attribute__((unused)) void *data)
2590 struct cmd_tx_vlan_reset_result *res = parsed_result;
2592 tx_vlan_reset(res->port_id);
2595 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2596 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2597 tx_vlan, "tx_vlan");
2598 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2599 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2601 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2602 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2605 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2606 .f = cmd_tx_vlan_reset_parsed,
2608 .help_str = "disable hardware insertion of a VLAN header in packets "
2611 (void *)&cmd_tx_vlan_reset_tx_vlan,
2612 (void *)&cmd_tx_vlan_reset_reset,
2613 (void *)&cmd_tx_vlan_reset_portid,
2619 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2620 struct cmd_tx_cksum_set_result {
2621 cmdline_fixed_string_t tx_cksum;
2622 cmdline_fixed_string_t set;
2628 cmd_tx_cksum_set_parsed(void *parsed_result,
2629 __attribute__((unused)) struct cmdline *cl,
2630 __attribute__((unused)) void *data)
2632 struct cmd_tx_cksum_set_result *res = parsed_result;
2634 tx_cksum_set(res->port_id, res->cksum_mask);
2637 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2638 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2639 tx_cksum, "tx_checksum");
2640 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2641 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2643 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2644 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2646 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2647 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2650 cmdline_parse_inst_t cmd_tx_cksum_set = {
2651 .f = cmd_tx_cksum_set_parsed,
2653 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2654 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2655 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2657 (void *)&cmd_tx_cksum_set_tx_cksum,
2658 (void *)&cmd_tx_cksum_set_set,
2659 (void *)&cmd_tx_cksum_set_cksum_mask,
2660 (void *)&cmd_tx_cksum_set_portid,
2665 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2666 struct cmd_set_flush_rx {
2667 cmdline_fixed_string_t set;
2668 cmdline_fixed_string_t flush_rx;
2669 cmdline_fixed_string_t mode;
2673 cmd_set_flush_rx_parsed(void *parsed_result,
2674 __attribute__((unused)) struct cmdline *cl,
2675 __attribute__((unused)) void *data)
2677 struct cmd_set_flush_rx *res = parsed_result;
2678 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2681 cmdline_parse_token_string_t cmd_setflushrx_set =
2682 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2684 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2685 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2686 flush_rx, "flush_rx");
2687 cmdline_parse_token_string_t cmd_setflushrx_mode =
2688 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2692 cmdline_parse_inst_t cmd_set_flush_rx = {
2693 .f = cmd_set_flush_rx_parsed,
2694 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2697 (void *)&cmd_setflushrx_set,
2698 (void *)&cmd_setflushrx_flush_rx,
2699 (void *)&cmd_setflushrx_mode,
2704 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2705 struct cmd_set_link_check {
2706 cmdline_fixed_string_t set;
2707 cmdline_fixed_string_t link_check;
2708 cmdline_fixed_string_t mode;
2712 cmd_set_link_check_parsed(void *parsed_result,
2713 __attribute__((unused)) struct cmdline *cl,
2714 __attribute__((unused)) void *data)
2716 struct cmd_set_link_check *res = parsed_result;
2717 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2720 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2721 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2723 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2724 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2725 link_check, "link_check");
2726 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2727 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2731 cmdline_parse_inst_t cmd_set_link_check = {
2732 .f = cmd_set_link_check_parsed,
2733 .help_str = "set link_check on|off: enable/disable link status check "
2734 "when starting/stopping a port",
2737 (void *)&cmd_setlinkcheck_set,
2738 (void *)&cmd_setlinkcheck_link_check,
2739 (void *)&cmd_setlinkcheck_mode,
2744 #ifdef RTE_NIC_BYPASS
2745 /* *** SET NIC BYPASS MODE *** */
2746 struct cmd_set_bypass_mode_result {
2747 cmdline_fixed_string_t set;
2748 cmdline_fixed_string_t bypass;
2749 cmdline_fixed_string_t mode;
2750 cmdline_fixed_string_t value;
2755 cmd_set_bypass_mode_parsed(void *parsed_result,
2756 __attribute__((unused)) struct cmdline *cl,
2757 __attribute__((unused)) void *data)
2759 struct cmd_set_bypass_mode_result *res = parsed_result;
2760 portid_t port_id = res->port_id;
2761 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2763 if (!bypass_is_supported(port_id))
2766 if (!strcmp(res->value, "bypass"))
2767 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2768 else if (!strcmp(res->value, "isolate"))
2769 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2771 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2773 /* Set the bypass mode for the relevant port. */
2774 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2775 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2779 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2780 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2782 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2783 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2785 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2786 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2788 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2789 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2790 value, "normal#bypass#isolate");
2791 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2792 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2795 cmdline_parse_inst_t cmd_set_bypass_mode = {
2796 .f = cmd_set_bypass_mode_parsed,
2797 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2798 "Set the NIC bypass mode for port_id",
2801 (void *)&cmd_setbypass_mode_set,
2802 (void *)&cmd_setbypass_mode_bypass,
2803 (void *)&cmd_setbypass_mode_mode,
2804 (void *)&cmd_setbypass_mode_value,
2805 (void *)&cmd_setbypass_mode_port,
2810 /* *** SET NIC BYPASS EVENT *** */
2811 struct cmd_set_bypass_event_result {
2812 cmdline_fixed_string_t set;
2813 cmdline_fixed_string_t bypass;
2814 cmdline_fixed_string_t event;
2815 cmdline_fixed_string_t event_value;
2816 cmdline_fixed_string_t mode;
2817 cmdline_fixed_string_t mode_value;
2822 cmd_set_bypass_event_parsed(void *parsed_result,
2823 __attribute__((unused)) struct cmdline *cl,
2824 __attribute__((unused)) void *data)
2827 struct cmd_set_bypass_event_result *res = parsed_result;
2828 portid_t port_id = res->port_id;
2829 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2830 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2832 if (!bypass_is_supported(port_id))
2835 if (!strcmp(res->event_value, "timeout"))
2836 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2837 else if (!strcmp(res->event_value, "os_on"))
2838 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2839 else if (!strcmp(res->event_value, "os_off"))
2840 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2841 else if (!strcmp(res->event_value, "power_on"))
2842 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2843 else if (!strcmp(res->event_value, "power_off"))
2844 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2846 bypass_event = RTE_BYPASS_EVENT_NONE;
2848 if (!strcmp(res->mode_value, "bypass"))
2849 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2850 else if (!strcmp(res->mode_value, "isolate"))
2851 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2853 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2855 /* Set the watchdog timeout. */
2856 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2859 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2860 (rc = rte_eth_dev_wd_timeout_store(port_id,
2861 bypass_timeout)) != 0) {
2862 printf("Failed to set timeout value %u "
2863 "for port %d, errto code: %d.\n",
2864 bypass_timeout, port_id, rc);
2868 /* Set the bypass event to transition to bypass mode. */
2869 if (0 != rte_eth_dev_bypass_event_store(port_id,
2870 bypass_event, bypass_mode)) {
2871 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2876 cmdline_parse_token_string_t cmd_setbypass_event_set =
2877 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2879 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2880 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2882 cmdline_parse_token_string_t cmd_setbypass_event_event =
2883 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2885 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2886 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2887 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2888 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2889 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2891 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2892 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2893 mode_value, "normal#bypass#isolate");
2894 cmdline_parse_token_num_t cmd_setbypass_event_port =
2895 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2898 cmdline_parse_inst_t cmd_set_bypass_event = {
2899 .f = cmd_set_bypass_event_parsed,
2900 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2901 "mode (normal|bypass|isolate) (port_id): "
2902 "Set the NIC bypass event mode for port_id",
2905 (void *)&cmd_setbypass_event_set,
2906 (void *)&cmd_setbypass_event_bypass,
2907 (void *)&cmd_setbypass_event_event,
2908 (void *)&cmd_setbypass_event_event_value,
2909 (void *)&cmd_setbypass_event_mode,
2910 (void *)&cmd_setbypass_event_mode_value,
2911 (void *)&cmd_setbypass_event_port,
2917 /* *** SET NIC BYPASS TIMEOUT *** */
2918 struct cmd_set_bypass_timeout_result {
2919 cmdline_fixed_string_t set;
2920 cmdline_fixed_string_t bypass;
2921 cmdline_fixed_string_t timeout;
2922 cmdline_fixed_string_t value;
2926 cmd_set_bypass_timeout_parsed(void *parsed_result,
2927 __attribute__((unused)) struct cmdline *cl,
2928 __attribute__((unused)) void *data)
2930 struct cmd_set_bypass_timeout_result *res = parsed_result;
2932 if (!strcmp(res->value, "1.5"))
2933 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2934 else if (!strcmp(res->value, "2"))
2935 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2936 else if (!strcmp(res->value, "3"))
2937 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2938 else if (!strcmp(res->value, "4"))
2939 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2940 else if (!strcmp(res->value, "8"))
2941 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2942 else if (!strcmp(res->value, "16"))
2943 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2944 else if (!strcmp(res->value, "32"))
2945 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2947 bypass_timeout = RTE_BYPASS_TMT_OFF;
2950 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2951 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2953 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2954 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2956 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2957 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2958 timeout, "timeout");
2959 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2960 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2961 value, "0#1.5#2#3#4#8#16#32");
2963 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2964 .f = cmd_set_bypass_timeout_parsed,
2965 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2966 "Set the NIC bypass watchdog timeout",
2969 (void *)&cmd_setbypass_timeout_set,
2970 (void *)&cmd_setbypass_timeout_bypass,
2971 (void *)&cmd_setbypass_timeout_timeout,
2972 (void *)&cmd_setbypass_timeout_value,
2977 /* *** SHOW NIC BYPASS MODE *** */
2978 struct cmd_show_bypass_config_result {
2979 cmdline_fixed_string_t show;
2980 cmdline_fixed_string_t bypass;
2981 cmdline_fixed_string_t config;
2986 cmd_show_bypass_config_parsed(void *parsed_result,
2987 __attribute__((unused)) struct cmdline *cl,
2988 __attribute__((unused)) void *data)
2990 struct cmd_show_bypass_config_result *res = parsed_result;
2991 uint32_t event_mode;
2992 uint32_t bypass_mode;
2993 portid_t port_id = res->port_id;
2994 uint32_t timeout = bypass_timeout;
2997 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2998 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2999 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3000 {"UNKNOWN", "normal", "bypass", "isolate"};
3001 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3008 int num_events = (sizeof events) / (sizeof events[0]);
3010 if (!bypass_is_supported(port_id))
3013 /* Display the bypass mode.*/
3014 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3015 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3019 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3020 bypass_mode = RTE_BYPASS_MODE_NONE;
3022 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3025 /* Display the bypass timeout.*/
3026 if (!RTE_BYPASS_TMT_VALID(timeout))
3027 timeout = RTE_BYPASS_TMT_OFF;
3029 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3031 /* Display the bypass events and associated modes. */
3032 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3034 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3035 printf("\tFailed to get bypass mode for event = %s\n",
3038 if (!RTE_BYPASS_MODE_VALID(event_mode))
3039 event_mode = RTE_BYPASS_MODE_NONE;
3041 printf("\tbypass event: %-16s = %s\n", events[i],
3047 cmdline_parse_token_string_t cmd_showbypass_config_show =
3048 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3050 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3051 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3053 cmdline_parse_token_string_t cmd_showbypass_config_config =
3054 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3056 cmdline_parse_token_num_t cmd_showbypass_config_port =
3057 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3060 cmdline_parse_inst_t cmd_show_bypass_config = {
3061 .f = cmd_show_bypass_config_parsed,
3062 .help_str = "show bypass config (port_id): "
3063 "Show the NIC bypass config for port_id",
3066 (void *)&cmd_showbypass_config_show,
3067 (void *)&cmd_showbypass_config_bypass,
3068 (void *)&cmd_showbypass_config_config,
3069 (void *)&cmd_showbypass_config_port,
3075 #ifdef RTE_LIBRTE_PMD_BOND
3076 /* *** SET BONDING MODE *** */
3077 struct cmd_set_bonding_mode_result {
3078 cmdline_fixed_string_t set;
3079 cmdline_fixed_string_t bonding;
3080 cmdline_fixed_string_t mode;
3085 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3086 __attribute__((unused)) struct cmdline *cl,
3087 __attribute__((unused)) void *data)
3089 struct cmd_set_bonding_mode_result *res = parsed_result;
3090 portid_t port_id = res->port_id;
3092 /* Set the bonding mode for the relevant port. */
3093 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3094 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3097 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3098 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3100 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3101 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3102 bonding, "bonding");
3103 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3104 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3106 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3107 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3109 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3110 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3113 cmdline_parse_inst_t cmd_set_bonding_mode = {
3114 .f = cmd_set_bonding_mode_parsed,
3115 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3118 (void *) &cmd_setbonding_mode_set,
3119 (void *) &cmd_setbonding_mode_bonding,
3120 (void *) &cmd_setbonding_mode_mode,
3121 (void *) &cmd_setbonding_mode_value,
3122 (void *) &cmd_setbonding_mode_port,
3127 /* *** SET BALANCE XMIT POLICY *** */
3128 struct cmd_set_bonding_balance_xmit_policy_result {
3129 cmdline_fixed_string_t set;
3130 cmdline_fixed_string_t bonding;
3131 cmdline_fixed_string_t balance_xmit_policy;
3133 cmdline_fixed_string_t policy;
3136 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3137 __attribute__((unused)) struct cmdline *cl,
3138 __attribute__((unused)) void *data)
3140 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3141 portid_t port_id = res->port_id;
3144 if (!strcmp(res->policy, "l2")) {
3145 policy = BALANCE_XMIT_POLICY_LAYER2;
3146 } else if (!strcmp(res->policy, "l23")) {
3147 policy = BALANCE_XMIT_POLICY_LAYER23;
3148 } else if (!strcmp(res->policy, "l34")) {
3149 policy = BALANCE_XMIT_POLICY_LAYER34;
3151 printf("\t Invalid xmit policy selection");
3155 /* Set the bonding mode for the relevant port. */
3156 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3157 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3162 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3163 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3165 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3166 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3167 bonding, "bonding");
3168 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3169 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3170 balance_xmit_policy, "balance_xmit_policy");
3171 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3172 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3174 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3175 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3176 policy, "l2#l23#l34");
3178 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3179 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3180 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3183 (void *)&cmd_setbonding_balance_xmit_policy_set,
3184 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3185 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3186 (void *)&cmd_setbonding_balance_xmit_policy_port,
3187 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3192 /* *** SHOW NIC BONDING CONFIGURATION *** */
3193 struct cmd_show_bonding_config_result {
3194 cmdline_fixed_string_t show;
3195 cmdline_fixed_string_t bonding;
3196 cmdline_fixed_string_t config;
3200 static void cmd_show_bonding_config_parsed(void *parsed_result,
3201 __attribute__((unused)) struct cmdline *cl,
3202 __attribute__((unused)) void *data)
3204 struct cmd_show_bonding_config_result *res = parsed_result;
3206 uint8_t slaves[RTE_MAX_ETHPORTS];
3207 int num_slaves, num_active_slaves;
3210 portid_t port_id = res->port_id;
3212 /* Display the bonding mode.*/
3213 bonding_mode = rte_eth_bond_mode_get(port_id);
3214 if (bonding_mode < 0) {
3215 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3218 printf("\tBonding mode: %d\n", bonding_mode);
3220 if (bonding_mode == BONDING_MODE_BALANCE) {
3221 int balance_xmit_policy;
3223 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3224 if (balance_xmit_policy < 0) {
3225 printf("\tFailed to get balance xmit policy for port = %d\n",
3229 printf("\tBalance Xmit Policy: ");
3231 switch (balance_xmit_policy) {
3232 case BALANCE_XMIT_POLICY_LAYER2:
3233 printf("BALANCE_XMIT_POLICY_LAYER2");
3235 case BALANCE_XMIT_POLICY_LAYER23:
3236 printf("BALANCE_XMIT_POLICY_LAYER23");
3238 case BALANCE_XMIT_POLICY_LAYER34:
3239 printf("BALANCE_XMIT_POLICY_LAYER34");
3246 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3248 if (num_slaves < 0) {
3249 printf("\tFailed to get slave list for port = %d\n", port_id);
3252 if (num_slaves > 0) {
3253 printf("\tSlaves (%d): [", num_slaves);
3254 for (i = 0; i < num_slaves - 1; i++)
3255 printf("%d ", slaves[i]);
3257 printf("%d]\n", slaves[num_slaves - 1]);
3259 printf("\tSlaves: []\n");
3263 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3266 if (num_active_slaves < 0) {
3267 printf("\tFailed to get active slave list for port = %d\n", port_id);
3270 if (num_active_slaves > 0) {
3271 printf("\tActive Slaves (%d): [", num_active_slaves);
3272 for (i = 0; i < num_active_slaves - 1; i++)
3273 printf("%d ", slaves[i]);
3275 printf("%d]\n", slaves[num_active_slaves - 1]);
3278 printf("\tActive Slaves: []\n");
3282 primary_id = rte_eth_bond_primary_get(port_id);
3283 if (primary_id < 0) {
3284 printf("\tFailed to get primary slave for port = %d\n", port_id);
3287 printf("\tPrimary: [%d]\n", primary_id);
3291 cmdline_parse_token_string_t cmd_showbonding_config_show =
3292 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3294 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3295 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3296 bonding, "bonding");
3297 cmdline_parse_token_string_t cmd_showbonding_config_config =
3298 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3300 cmdline_parse_token_num_t cmd_showbonding_config_port =
3301 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3304 cmdline_parse_inst_t cmd_show_bonding_config = {
3305 .f = cmd_show_bonding_config_parsed,
3306 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3309 (void *)&cmd_showbonding_config_show,
3310 (void *)&cmd_showbonding_config_bonding,
3311 (void *)&cmd_showbonding_config_config,
3312 (void *)&cmd_showbonding_config_port,
3317 /* *** SET BONDING PRIMARY *** */
3318 struct cmd_set_bonding_primary_result {
3319 cmdline_fixed_string_t set;
3320 cmdline_fixed_string_t bonding;
3321 cmdline_fixed_string_t primary;
3326 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3327 __attribute__((unused)) struct cmdline *cl,
3328 __attribute__((unused)) void *data)
3330 struct cmd_set_bonding_primary_result *res = parsed_result;
3331 portid_t master_port_id = res->port_id;
3332 portid_t slave_port_id = res->slave_id;
3334 /* Set the primary slave for a bonded device. */
3335 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3336 printf("\t Failed to set primary slave for port = %d.\n",
3343 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3344 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3346 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3347 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3348 bonding, "bonding");
3349 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3350 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3351 primary, "primary");
3352 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3353 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3355 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3356 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3359 cmdline_parse_inst_t cmd_set_bonding_primary = {
3360 .f = cmd_set_bonding_primary_parsed,
3361 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3364 (void *)&cmd_setbonding_primary_set,
3365 (void *)&cmd_setbonding_primary_bonding,
3366 (void *)&cmd_setbonding_primary_primary,
3367 (void *)&cmd_setbonding_primary_slave,
3368 (void *)&cmd_setbonding_primary_port,
3373 /* *** ADD SLAVE *** */
3374 struct cmd_add_bonding_slave_result {
3375 cmdline_fixed_string_t add;
3376 cmdline_fixed_string_t bonding;
3377 cmdline_fixed_string_t slave;
3382 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3383 __attribute__((unused)) struct cmdline *cl,
3384 __attribute__((unused)) void *data)
3386 struct cmd_add_bonding_slave_result *res = parsed_result;
3387 portid_t master_port_id = res->port_id;
3388 portid_t slave_port_id = res->slave_id;
3390 /* Set the primary slave for a bonded device. */
3391 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3392 printf("\t Failed to add slave %d to master port = %d.\n",
3393 slave_port_id, master_port_id);
3399 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3400 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3402 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3403 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3404 bonding, "bonding");
3405 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3406 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3408 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3409 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3411 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3412 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3415 cmdline_parse_inst_t cmd_add_bonding_slave = {
3416 .f = cmd_add_bonding_slave_parsed,
3417 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3420 (void *)&cmd_addbonding_slave_add,
3421 (void *)&cmd_addbonding_slave_bonding,
3422 (void *)&cmd_addbonding_slave_slave,
3423 (void *)&cmd_addbonding_slave_slaveid,
3424 (void *)&cmd_addbonding_slave_port,
3429 /* *** REMOVE SLAVE *** */
3430 struct cmd_remove_bonding_slave_result {
3431 cmdline_fixed_string_t remove;
3432 cmdline_fixed_string_t bonding;
3433 cmdline_fixed_string_t slave;
3438 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3439 __attribute__((unused)) struct cmdline *cl,
3440 __attribute__((unused)) void *data)
3442 struct cmd_remove_bonding_slave_result *res = parsed_result;
3443 portid_t master_port_id = res->port_id;
3444 portid_t slave_port_id = res->slave_id;
3446 /* Set the primary slave for a bonded device. */
3447 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3448 printf("\t Failed to remove slave %d from master port = %d.\n",
3449 slave_port_id, master_port_id);
3455 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3456 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3458 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3459 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3460 bonding, "bonding");
3461 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3462 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3464 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3465 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3467 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3468 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3471 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3472 .f = cmd_remove_bonding_slave_parsed,
3473 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3476 (void *)&cmd_removebonding_slave_remove,
3477 (void *)&cmd_removebonding_slave_bonding,
3478 (void *)&cmd_removebonding_slave_slave,
3479 (void *)&cmd_removebonding_slave_slaveid,
3480 (void *)&cmd_removebonding_slave_port,
3485 /* *** CREATE BONDED DEVICE *** */
3486 struct cmd_create_bonded_device_result {
3487 cmdline_fixed_string_t create;
3488 cmdline_fixed_string_t bonded;
3489 cmdline_fixed_string_t device;
3494 static int bond_dev_num = 0;
3496 static void cmd_create_bonded_device_parsed(void *parsed_result,
3497 __attribute__((unused)) struct cmdline *cl,
3498 __attribute__((unused)) void *data)
3500 struct cmd_create_bonded_device_result *res = parsed_result;
3501 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3504 if (test_done == 0) {
3505 printf("Please stop forwarding first\n");
3509 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3512 /* Create a new bonded device. */
3513 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3515 printf("\t Failed to create bonded device.\n");
3518 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3521 /* Update number of ports */
3522 nb_ports = rte_eth_dev_count();
3524 rte_eth_promiscuous_enable(port_id);
3529 cmdline_parse_token_string_t cmd_createbonded_device_create =
3530 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3532 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3533 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3535 cmdline_parse_token_string_t cmd_createbonded_device_device =
3536 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3538 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3539 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3541 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3542 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3545 cmdline_parse_inst_t cmd_create_bonded_device = {
3546 .f = cmd_create_bonded_device_parsed,
3547 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3550 (void *)&cmd_createbonded_device_create,
3551 (void *)&cmd_createbonded_device_bonded,
3552 (void *)&cmd_createbonded_device_device,
3553 (void *)&cmd_createbonded_device_mode,
3554 (void *)&cmd_createbonded_device_socket,
3559 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3560 struct cmd_set_bond_mac_addr_result {
3561 cmdline_fixed_string_t set;
3562 cmdline_fixed_string_t bonding;
3563 cmdline_fixed_string_t mac_addr;
3565 struct ether_addr address;
3568 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3569 __attribute__((unused)) struct cmdline *cl,
3570 __attribute__((unused)) void *data)
3572 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3575 if (res->port_num >= nb_ports) {
3576 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3580 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3582 /* check the return value and print it if is < 0 */
3584 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3587 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3588 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3589 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3590 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3592 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3593 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3595 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3596 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3597 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3598 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3600 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3601 .f = cmd_set_bond_mac_addr_parsed,
3603 .help_str = "set bonding mac_addr (port_id) (address): ",
3605 (void *)&cmd_set_bond_mac_addr_set,
3606 (void *)&cmd_set_bond_mac_addr_bonding,
3607 (void *)&cmd_set_bond_mac_addr_mac,
3608 (void *)&cmd_set_bond_mac_addr_portnum,
3609 (void *)&cmd_set_bond_mac_addr_addr,
3614 #endif /* RTE_LIBRTE_PMD_BOND */
3616 /* *** SET FORWARDING MODE *** */
3617 struct cmd_set_fwd_mode_result {
3618 cmdline_fixed_string_t set;
3619 cmdline_fixed_string_t fwd;
3620 cmdline_fixed_string_t mode;
3623 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3624 __attribute__((unused)) struct cmdline *cl,
3625 __attribute__((unused)) void *data)
3627 struct cmd_set_fwd_mode_result *res = parsed_result;
3629 set_pkt_forwarding_mode(res->mode);
3632 cmdline_parse_token_string_t cmd_setfwd_set =
3633 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3634 cmdline_parse_token_string_t cmd_setfwd_fwd =
3635 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3636 cmdline_parse_token_string_t cmd_setfwd_mode =
3637 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3638 "" /* defined at init */);
3640 cmdline_parse_inst_t cmd_set_fwd_mode = {
3641 .f = cmd_set_fwd_mode_parsed,
3643 .help_str = NULL, /* defined at init */
3645 (void *)&cmd_setfwd_set,
3646 (void *)&cmd_setfwd_fwd,
3647 (void *)&cmd_setfwd_mode,
3652 static void cmd_set_fwd_mode_init(void)
3655 static char token[128];
3656 static char help[256];
3657 cmdline_parse_token_string_t *token_struct;
3659 modes = list_pkt_forwarding_modes();
3660 snprintf(help, sizeof help, "set fwd %s - "
3661 "set packet forwarding mode", modes);
3662 cmd_set_fwd_mode.help_str = help;
3664 /* string token separator is # */
3665 for (c = token; *modes != '\0'; modes++)
3670 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3671 token_struct->string_data.str = token;
3674 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3675 struct cmd_set_burst_tx_retry_result {
3676 cmdline_fixed_string_t set;
3677 cmdline_fixed_string_t burst;
3678 cmdline_fixed_string_t tx;
3679 cmdline_fixed_string_t delay;
3681 cmdline_fixed_string_t retry;
3685 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3686 __attribute__((unused)) struct cmdline *cl,
3687 __attribute__((unused)) void *data)
3689 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3691 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3692 && !strcmp(res->tx, "tx")) {
3693 if (!strcmp(res->delay, "delay"))
3694 burst_tx_delay_time = res->time;
3695 if (!strcmp(res->retry, "retry"))
3696 burst_tx_retry_num = res->retry_num;
3701 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3702 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3703 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3704 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3706 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3707 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3708 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3709 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3710 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3711 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3712 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3713 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3714 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3715 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3717 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3718 .f = cmd_set_burst_tx_retry_parsed,
3719 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3721 (void *)&cmd_set_burst_tx_retry_set,
3722 (void *)&cmd_set_burst_tx_retry_burst,
3723 (void *)&cmd_set_burst_tx_retry_tx,
3724 (void *)&cmd_set_burst_tx_retry_delay,
3725 (void *)&cmd_set_burst_tx_retry_time,
3726 (void *)&cmd_set_burst_tx_retry_retry,
3727 (void *)&cmd_set_burst_tx_retry_retry_num,
3732 /* *** SET PROMISC MODE *** */
3733 struct cmd_set_promisc_mode_result {
3734 cmdline_fixed_string_t set;
3735 cmdline_fixed_string_t promisc;
3736 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3737 uint8_t port_num; /* valid if "allports" argument == 0 */
3738 cmdline_fixed_string_t mode;
3741 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3742 __attribute__((unused)) struct cmdline *cl,
3745 struct cmd_set_promisc_mode_result *res = parsed_result;
3749 if (!strcmp(res->mode, "on"))
3756 for (i = 0; i < nb_ports; i++) {
3758 rte_eth_promiscuous_enable(i);
3760 rte_eth_promiscuous_disable(i);
3765 rte_eth_promiscuous_enable(res->port_num);
3767 rte_eth_promiscuous_disable(res->port_num);
3771 cmdline_parse_token_string_t cmd_setpromisc_set =
3772 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3773 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3774 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3776 cmdline_parse_token_string_t cmd_setpromisc_portall =
3777 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3779 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3780 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3782 cmdline_parse_token_string_t cmd_setpromisc_mode =
3783 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3786 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3787 .f = cmd_set_promisc_mode_parsed,
3789 .help_str = "set promisc all on|off: set promisc mode for all ports",
3791 (void *)&cmd_setpromisc_set,
3792 (void *)&cmd_setpromisc_promisc,
3793 (void *)&cmd_setpromisc_portall,
3794 (void *)&cmd_setpromisc_mode,
3799 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3800 .f = cmd_set_promisc_mode_parsed,
3802 .help_str = "set promisc X on|off: set promisc mode on port X",
3804 (void *)&cmd_setpromisc_set,
3805 (void *)&cmd_setpromisc_promisc,
3806 (void *)&cmd_setpromisc_portnum,
3807 (void *)&cmd_setpromisc_mode,
3812 /* *** SET ALLMULTI MODE *** */
3813 struct cmd_set_allmulti_mode_result {
3814 cmdline_fixed_string_t set;
3815 cmdline_fixed_string_t allmulti;
3816 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3817 uint8_t port_num; /* valid if "allports" argument == 0 */
3818 cmdline_fixed_string_t mode;
3821 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3822 __attribute__((unused)) struct cmdline *cl,
3825 struct cmd_set_allmulti_mode_result *res = parsed_result;
3829 if (!strcmp(res->mode, "on"))
3836 for (i = 0; i < nb_ports; i++) {
3838 rte_eth_allmulticast_enable(i);
3840 rte_eth_allmulticast_disable(i);
3845 rte_eth_allmulticast_enable(res->port_num);
3847 rte_eth_allmulticast_disable(res->port_num);
3851 cmdline_parse_token_string_t cmd_setallmulti_set =
3852 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3853 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3854 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3856 cmdline_parse_token_string_t cmd_setallmulti_portall =
3857 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3859 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3860 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3862 cmdline_parse_token_string_t cmd_setallmulti_mode =
3863 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3866 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3867 .f = cmd_set_allmulti_mode_parsed,
3869 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3871 (void *)&cmd_setallmulti_set,
3872 (void *)&cmd_setallmulti_allmulti,
3873 (void *)&cmd_setallmulti_portall,
3874 (void *)&cmd_setallmulti_mode,
3879 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3880 .f = cmd_set_allmulti_mode_parsed,
3882 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3884 (void *)&cmd_setallmulti_set,
3885 (void *)&cmd_setallmulti_allmulti,
3886 (void *)&cmd_setallmulti_portnum,
3887 (void *)&cmd_setallmulti_mode,
3892 /* *** ADD/REMOVE A PKT FILTER *** */
3893 struct cmd_pkt_filter_result {
3894 cmdline_fixed_string_t pkt_filter;
3896 cmdline_fixed_string_t protocol;
3897 cmdline_fixed_string_t src;
3898 cmdline_ipaddr_t ip_src;
3900 cmdline_fixed_string_t dst;
3901 cmdline_ipaddr_t ip_dst;
3903 cmdline_fixed_string_t flexbytes;
3904 uint16_t flexbytes_value;
3905 cmdline_fixed_string_t vlan;
3907 cmdline_fixed_string_t queue;
3909 cmdline_fixed_string_t soft;
3914 cmd_pkt_filter_parsed(void *parsed_result,
3915 __attribute__((unused)) struct cmdline *cl,
3916 __attribute__((unused)) void *data)
3918 struct rte_fdir_filter fdir_filter;
3919 struct cmd_pkt_filter_result *res = parsed_result;
3921 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
3923 if (res->ip_src.family == AF_INET)
3924 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
3926 memcpy(&(fdir_filter.ip_src.ipv6_addr),
3927 &(res->ip_src.addr.ipv6),
3928 sizeof(struct in6_addr));
3930 if (res->ip_dst.family == AF_INET)
3931 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
3933 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
3934 &(res->ip_dst.addr.ipv6),
3935 sizeof(struct in6_addr));
3937 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
3938 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
3940 if (!strcmp(res->protocol, "udp"))
3941 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
3942 else if (!strcmp(res->protocol, "tcp"))
3943 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
3944 else if (!strcmp(res->protocol, "sctp"))
3945 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
3946 else /* default only IP */
3947 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
3949 if (res->ip_dst.family == AF_INET6)
3950 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
3952 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
3954 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
3955 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
3957 if (!strcmp(res->pkt_filter, "add_signature_filter"))
3958 fdir_add_signature_filter(res->port_id, res->queue_id,
3960 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3961 fdir_update_signature_filter(res->port_id, res->queue_id,
3963 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3964 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3965 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3966 fdir_add_perfect_filter(res->port_id, res->soft_id,
3968 (uint8_t) (res->queue_id < 0),
3970 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3971 fdir_update_perfect_filter(res->port_id, res->soft_id,
3973 (uint8_t) (res->queue_id < 0),
3975 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3976 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3982 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3983 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3985 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3986 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3987 protocol, "ip#tcp#udp#sctp");
3988 cmdline_parse_token_string_t cmd_pkt_filter_src =
3989 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3991 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3992 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3994 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3995 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3997 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3998 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4000 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4001 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4003 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4004 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4006 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4007 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4008 flexbytes, "flexbytes");
4009 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4010 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4011 flexbytes_value, UINT16);
4012 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4013 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4015 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4016 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4018 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4019 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4021 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4022 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4024 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4025 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4027 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4028 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4032 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4033 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4034 pkt_filter, "add_signature_filter");
4035 cmdline_parse_inst_t cmd_add_signature_filter = {
4036 .f = cmd_pkt_filter_parsed,
4038 .help_str = "add a signature filter",
4040 (void *)&cmd_pkt_filter_add_signature_filter,
4041 (void *)&cmd_pkt_filter_port_id,
4042 (void *)&cmd_pkt_filter_protocol,
4043 (void *)&cmd_pkt_filter_src,
4044 (void *)&cmd_pkt_filter_ip_src,
4045 (void *)&cmd_pkt_filter_port_src,
4046 (void *)&cmd_pkt_filter_dst,
4047 (void *)&cmd_pkt_filter_ip_dst,
4048 (void *)&cmd_pkt_filter_port_dst,
4049 (void *)&cmd_pkt_filter_flexbytes,
4050 (void *)&cmd_pkt_filter_flexbytes_value,
4051 (void *)&cmd_pkt_filter_vlan,
4052 (void *)&cmd_pkt_filter_vlan_id,
4053 (void *)&cmd_pkt_filter_queue,
4054 (void *)&cmd_pkt_filter_queue_id,
4060 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4061 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4062 pkt_filter, "upd_signature_filter");
4063 cmdline_parse_inst_t cmd_upd_signature_filter = {
4064 .f = cmd_pkt_filter_parsed,
4066 .help_str = "update a signature filter",
4068 (void *)&cmd_pkt_filter_upd_signature_filter,
4069 (void *)&cmd_pkt_filter_port_id,
4070 (void *)&cmd_pkt_filter_protocol,
4071 (void *)&cmd_pkt_filter_src,
4072 (void *)&cmd_pkt_filter_ip_src,
4073 (void *)&cmd_pkt_filter_port_src,
4074 (void *)&cmd_pkt_filter_dst,
4075 (void *)&cmd_pkt_filter_ip_dst,
4076 (void *)&cmd_pkt_filter_port_dst,
4077 (void *)&cmd_pkt_filter_flexbytes,
4078 (void *)&cmd_pkt_filter_flexbytes_value,
4079 (void *)&cmd_pkt_filter_vlan,
4080 (void *)&cmd_pkt_filter_vlan_id,
4081 (void *)&cmd_pkt_filter_queue,
4082 (void *)&cmd_pkt_filter_queue_id,
4088 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4089 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4090 pkt_filter, "rm_signature_filter");
4091 cmdline_parse_inst_t cmd_rm_signature_filter = {
4092 .f = cmd_pkt_filter_parsed,
4094 .help_str = "remove a signature filter",
4096 (void *)&cmd_pkt_filter_rm_signature_filter,
4097 (void *)&cmd_pkt_filter_port_id,
4098 (void *)&cmd_pkt_filter_protocol,
4099 (void *)&cmd_pkt_filter_src,
4100 (void *)&cmd_pkt_filter_ip_src,
4101 (void *)&cmd_pkt_filter_port_src,
4102 (void *)&cmd_pkt_filter_dst,
4103 (void *)&cmd_pkt_filter_ip_dst,
4104 (void *)&cmd_pkt_filter_port_dst,
4105 (void *)&cmd_pkt_filter_flexbytes,
4106 (void *)&cmd_pkt_filter_flexbytes_value,
4107 (void *)&cmd_pkt_filter_vlan,
4108 (void *)&cmd_pkt_filter_vlan_id,
4114 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4115 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4116 pkt_filter, "add_perfect_filter");
4117 cmdline_parse_inst_t cmd_add_perfect_filter = {
4118 .f = cmd_pkt_filter_parsed,
4120 .help_str = "add a perfect filter",
4122 (void *)&cmd_pkt_filter_add_perfect_filter,
4123 (void *)&cmd_pkt_filter_port_id,
4124 (void *)&cmd_pkt_filter_protocol,
4125 (void *)&cmd_pkt_filter_src,
4126 (void *)&cmd_pkt_filter_ip_src,
4127 (void *)&cmd_pkt_filter_port_src,
4128 (void *)&cmd_pkt_filter_dst,
4129 (void *)&cmd_pkt_filter_ip_dst,
4130 (void *)&cmd_pkt_filter_port_dst,
4131 (void *)&cmd_pkt_filter_flexbytes,
4132 (void *)&cmd_pkt_filter_flexbytes_value,
4133 (void *)&cmd_pkt_filter_vlan,
4134 (void *)&cmd_pkt_filter_vlan_id,
4135 (void *)&cmd_pkt_filter_queue,
4136 (void *)&cmd_pkt_filter_queue_id,
4137 (void *)&cmd_pkt_filter_soft,
4138 (void *)&cmd_pkt_filter_soft_id,
4144 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4145 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4146 pkt_filter, "upd_perfect_filter");
4147 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4148 .f = cmd_pkt_filter_parsed,
4150 .help_str = "update a perfect filter",
4152 (void *)&cmd_pkt_filter_upd_perfect_filter,
4153 (void *)&cmd_pkt_filter_port_id,
4154 (void *)&cmd_pkt_filter_protocol,
4155 (void *)&cmd_pkt_filter_src,
4156 (void *)&cmd_pkt_filter_ip_src,
4157 (void *)&cmd_pkt_filter_port_src,
4158 (void *)&cmd_pkt_filter_dst,
4159 (void *)&cmd_pkt_filter_ip_dst,
4160 (void *)&cmd_pkt_filter_port_dst,
4161 (void *)&cmd_pkt_filter_flexbytes,
4162 (void *)&cmd_pkt_filter_flexbytes_value,
4163 (void *)&cmd_pkt_filter_vlan,
4164 (void *)&cmd_pkt_filter_vlan_id,
4165 (void *)&cmd_pkt_filter_queue,
4166 (void *)&cmd_pkt_filter_queue_id,
4167 (void *)&cmd_pkt_filter_soft,
4168 (void *)&cmd_pkt_filter_soft_id,
4174 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4175 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4176 pkt_filter, "rm_perfect_filter");
4177 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4178 .f = cmd_pkt_filter_parsed,
4180 .help_str = "remove a perfect filter",
4182 (void *)&cmd_pkt_filter_rm_perfect_filter,
4183 (void *)&cmd_pkt_filter_port_id,
4184 (void *)&cmd_pkt_filter_protocol,
4185 (void *)&cmd_pkt_filter_src,
4186 (void *)&cmd_pkt_filter_ip_src,
4187 (void *)&cmd_pkt_filter_port_src,
4188 (void *)&cmd_pkt_filter_dst,
4189 (void *)&cmd_pkt_filter_ip_dst,
4190 (void *)&cmd_pkt_filter_port_dst,
4191 (void *)&cmd_pkt_filter_flexbytes,
4192 (void *)&cmd_pkt_filter_flexbytes_value,
4193 (void *)&cmd_pkt_filter_vlan,
4194 (void *)&cmd_pkt_filter_vlan_id,
4195 (void *)&cmd_pkt_filter_soft,
4196 (void *)&cmd_pkt_filter_soft_id,
4201 /* *** SETUP MASKS FILTER *** */
4202 struct cmd_pkt_filter_masks_result {
4203 cmdline_fixed_string_t filter_mask;
4205 cmdline_fixed_string_t src_mask;
4206 uint32_t ip_src_mask;
4207 uint16_t ipv6_src_mask;
4208 uint16_t port_src_mask;
4209 cmdline_fixed_string_t dst_mask;
4210 uint32_t ip_dst_mask;
4211 uint16_t ipv6_dst_mask;
4212 uint16_t port_dst_mask;
4213 cmdline_fixed_string_t flexbytes;
4214 uint8_t flexbytes_value;
4215 cmdline_fixed_string_t vlan_id;
4216 uint8_t vlan_id_value;
4217 cmdline_fixed_string_t vlan_prio;
4218 uint8_t vlan_prio_value;
4219 cmdline_fixed_string_t only_ip_flow;
4220 uint8_t only_ip_flow_value;
4221 cmdline_fixed_string_t comp_ipv6_dst;
4222 uint8_t comp_ipv6_dst_value;
4226 cmd_pkt_filter_masks_parsed(void *parsed_result,
4227 __attribute__((unused)) struct cmdline *cl,
4228 __attribute__((unused)) void *data)
4230 struct rte_fdir_masks fdir_masks;
4231 struct cmd_pkt_filter_masks_result *res = parsed_result;
4233 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4235 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4236 fdir_masks.vlan_id = res->vlan_id_value;
4237 fdir_masks.vlan_prio = res->vlan_prio_value;
4238 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4239 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4240 fdir_masks.src_port_mask = res->port_src_mask;
4241 fdir_masks.dst_port_mask = res->port_dst_mask;
4242 fdir_masks.flexbytes = res->flexbytes_value;
4244 fdir_set_masks(res->port_id, &fdir_masks);
4247 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4248 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4249 filter_mask, "set_masks_filter");
4250 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4251 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4253 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4254 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4255 only_ip_flow, "only_ip_flow");
4256 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4257 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4258 only_ip_flow_value, UINT8);
4259 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4260 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4261 src_mask, "src_mask");
4262 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4263 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4264 ip_src_mask, UINT32);
4265 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4266 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4267 port_src_mask, UINT16);
4268 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4269 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4270 dst_mask, "dst_mask");
4271 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4272 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4273 ip_dst_mask, UINT32);
4274 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4275 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4276 port_dst_mask, UINT16);
4277 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4278 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4279 flexbytes, "flexbytes");
4280 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4281 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4282 flexbytes_value, UINT8);
4283 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4284 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4285 vlan_id, "vlan_id");
4286 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4287 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4288 vlan_id_value, UINT8);
4289 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4290 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4291 vlan_prio, "vlan_prio");
4292 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4293 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4294 vlan_prio_value, UINT8);
4296 cmdline_parse_inst_t cmd_set_masks_filter = {
4297 .f = cmd_pkt_filter_masks_parsed,
4299 .help_str = "setup masks filter",
4301 (void *)&cmd_pkt_filter_masks_filter_mask,
4302 (void *)&cmd_pkt_filter_masks_port_id,
4303 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4304 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4305 (void *)&cmd_pkt_filter_masks_src_mask,
4306 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4307 (void *)&cmd_pkt_filter_masks_port_src_mask,
4308 (void *)&cmd_pkt_filter_masks_dst_mask,
4309 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4310 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4311 (void *)&cmd_pkt_filter_masks_flexbytes,
4312 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4313 (void *)&cmd_pkt_filter_masks_vlan_id,
4314 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4315 (void *)&cmd_pkt_filter_masks_vlan_prio,
4316 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4322 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4323 __attribute__((unused)) struct cmdline *cl,
4324 __attribute__((unused)) void *data)
4326 struct rte_fdir_masks fdir_masks;
4327 struct cmd_pkt_filter_masks_result *res = parsed_result;
4329 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4331 fdir_masks.set_ipv6_mask = 1;
4332 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4333 fdir_masks.vlan_id = res->vlan_id_value;
4334 fdir_masks.vlan_prio = res->vlan_prio_value;
4335 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4336 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4337 fdir_masks.src_port_mask = res->port_src_mask;
4338 fdir_masks.dst_port_mask = res->port_dst_mask;
4339 fdir_masks.flexbytes = res->flexbytes_value;
4340 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4342 fdir_set_masks(res->port_id, &fdir_masks);
4345 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4346 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4347 filter_mask, "set_ipv6_masks_filter");
4348 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4349 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4350 ipv6_src_mask, UINT16);
4351 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4352 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4353 ipv6_dst_mask, UINT16);
4355 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4356 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4357 comp_ipv6_dst, "compare_dst");
4358 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4359 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4360 comp_ipv6_dst_value, UINT8);
4362 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4363 .f = cmd_pkt_filter_masks_ipv6_parsed,
4365 .help_str = "setup ipv6 masks filter",
4367 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4368 (void *)&cmd_pkt_filter_masks_port_id,
4369 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4370 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4371 (void *)&cmd_pkt_filter_masks_src_mask,
4372 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4373 (void *)&cmd_pkt_filter_masks_port_src_mask,
4374 (void *)&cmd_pkt_filter_masks_dst_mask,
4375 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4376 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4377 (void *)&cmd_pkt_filter_masks_flexbytes,
4378 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4379 (void *)&cmd_pkt_filter_masks_vlan_id,
4380 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4381 (void *)&cmd_pkt_filter_masks_vlan_prio,
4382 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4383 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4384 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4389 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4390 struct cmd_link_flow_ctrl_set_result {
4391 cmdline_fixed_string_t set;
4392 cmdline_fixed_string_t flow_ctrl;
4393 cmdline_fixed_string_t rx;
4394 cmdline_fixed_string_t rx_lfc_mode;
4395 cmdline_fixed_string_t tx;
4396 cmdline_fixed_string_t tx_lfc_mode;
4397 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4398 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4399 cmdline_fixed_string_t autoneg_str;
4400 cmdline_fixed_string_t autoneg;
4401 cmdline_fixed_string_t hw_str;
4402 uint32_t high_water;
4403 cmdline_fixed_string_t lw_str;
4405 cmdline_fixed_string_t pt_str;
4406 uint16_t pause_time;
4407 cmdline_fixed_string_t xon_str;
4412 cmdline_parse_token_string_t cmd_lfc_set_set =
4413 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4415 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4416 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4417 flow_ctrl, "flow_ctrl");
4418 cmdline_parse_token_string_t cmd_lfc_set_rx =
4419 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4421 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4423 rx_lfc_mode, "on#off");
4424 cmdline_parse_token_string_t cmd_lfc_set_tx =
4425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4427 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4429 tx_lfc_mode, "on#off");
4430 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4431 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4432 hw_str, "high_water");
4433 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4434 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4435 high_water, UINT32);
4436 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4437 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4438 lw_str, "low_water");
4439 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4440 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4442 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4443 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4444 pt_str, "pause_time");
4445 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4446 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4447 pause_time, UINT16);
4448 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4449 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4450 xon_str, "send_xon");
4451 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4452 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4454 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4455 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4456 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4457 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4458 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4459 mac_ctrl_frame_fwd_mode, "on#off");
4460 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4461 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4462 autoneg_str, "autoneg");
4463 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4464 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4466 cmdline_parse_token_num_t cmd_lfc_set_portid =
4467 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4470 /* forward declaration */
4472 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4475 cmdline_parse_inst_t cmd_link_flow_control_set = {
4476 .f = cmd_link_flow_ctrl_set_parsed,
4478 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4479 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4480 autoneg on|off port_id",
4482 (void *)&cmd_lfc_set_set,
4483 (void *)&cmd_lfc_set_flow_ctrl,
4484 (void *)&cmd_lfc_set_rx,
4485 (void *)&cmd_lfc_set_rx_mode,
4486 (void *)&cmd_lfc_set_tx,
4487 (void *)&cmd_lfc_set_tx_mode,
4488 (void *)&cmd_lfc_set_high_water,
4489 (void *)&cmd_lfc_set_low_water,
4490 (void *)&cmd_lfc_set_pause_time,
4491 (void *)&cmd_lfc_set_send_xon,
4492 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4493 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4494 (void *)&cmd_lfc_set_autoneg_str,
4495 (void *)&cmd_lfc_set_autoneg,
4496 (void *)&cmd_lfc_set_portid,
4501 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4502 .f = cmd_link_flow_ctrl_set_parsed,
4503 .data = (void *)&cmd_link_flow_control_set_rx,
4504 .help_str = "Change rx flow control parameter: set flow_ctrl "
4505 "rx on|off port_id",
4507 (void *)&cmd_lfc_set_set,
4508 (void *)&cmd_lfc_set_flow_ctrl,
4509 (void *)&cmd_lfc_set_rx,
4510 (void *)&cmd_lfc_set_rx_mode,
4511 (void *)&cmd_lfc_set_portid,
4516 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4517 .f = cmd_link_flow_ctrl_set_parsed,
4518 .data = (void *)&cmd_link_flow_control_set_tx,
4519 .help_str = "Change tx flow control parameter: set flow_ctrl "
4520 "tx on|off port_id",
4522 (void *)&cmd_lfc_set_set,
4523 (void *)&cmd_lfc_set_flow_ctrl,
4524 (void *)&cmd_lfc_set_tx,
4525 (void *)&cmd_lfc_set_tx_mode,
4526 (void *)&cmd_lfc_set_portid,
4531 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4532 .f = cmd_link_flow_ctrl_set_parsed,
4533 .data = (void *)&cmd_link_flow_control_set_hw,
4534 .help_str = "Change high water flow control parameter: set flow_ctrl "
4535 "high_water value port_id",
4537 (void *)&cmd_lfc_set_set,
4538 (void *)&cmd_lfc_set_flow_ctrl,
4539 (void *)&cmd_lfc_set_high_water_str,
4540 (void *)&cmd_lfc_set_high_water,
4541 (void *)&cmd_lfc_set_portid,
4546 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4547 .f = cmd_link_flow_ctrl_set_parsed,
4548 .data = (void *)&cmd_link_flow_control_set_lw,
4549 .help_str = "Change low water flow control parameter: set flow_ctrl "
4550 "low_water value port_id",
4552 (void *)&cmd_lfc_set_set,
4553 (void *)&cmd_lfc_set_flow_ctrl,
4554 (void *)&cmd_lfc_set_low_water_str,
4555 (void *)&cmd_lfc_set_low_water,
4556 (void *)&cmd_lfc_set_portid,
4561 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4562 .f = cmd_link_flow_ctrl_set_parsed,
4563 .data = (void *)&cmd_link_flow_control_set_pt,
4564 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4565 "pause_time value port_id",
4567 (void *)&cmd_lfc_set_set,
4568 (void *)&cmd_lfc_set_flow_ctrl,
4569 (void *)&cmd_lfc_set_pause_time_str,
4570 (void *)&cmd_lfc_set_pause_time,
4571 (void *)&cmd_lfc_set_portid,
4576 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4577 .f = cmd_link_flow_ctrl_set_parsed,
4578 .data = (void *)&cmd_link_flow_control_set_xon,
4579 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4580 "send_xon value port_id",
4582 (void *)&cmd_lfc_set_set,
4583 (void *)&cmd_lfc_set_flow_ctrl,
4584 (void *)&cmd_lfc_set_send_xon_str,
4585 (void *)&cmd_lfc_set_send_xon,
4586 (void *)&cmd_lfc_set_portid,
4591 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4592 .f = cmd_link_flow_ctrl_set_parsed,
4593 .data = (void *)&cmd_link_flow_control_set_macfwd,
4594 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4595 "mac_ctrl_frame_fwd on|off port_id",
4597 (void *)&cmd_lfc_set_set,
4598 (void *)&cmd_lfc_set_flow_ctrl,
4599 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4600 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4601 (void *)&cmd_lfc_set_portid,
4606 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4607 .f = cmd_link_flow_ctrl_set_parsed,
4608 .data = (void *)&cmd_link_flow_control_set_autoneg,
4609 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4610 "autoneg on|off port_id",
4612 (void *)&cmd_lfc_set_set,
4613 (void *)&cmd_lfc_set_flow_ctrl,
4614 (void *)&cmd_lfc_set_autoneg_str,
4615 (void *)&cmd_lfc_set_autoneg,
4616 (void *)&cmd_lfc_set_portid,
4622 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4623 __attribute__((unused)) struct cmdline *cl,
4626 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4627 cmdline_parse_inst_t *cmd = data;
4628 struct rte_eth_fc_conf fc_conf;
4629 int rx_fc_en, tx_fc_en;
4633 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4634 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4635 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4636 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4638 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4639 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4642 /* Partial command line, retrieve current configuration */
4644 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4646 printf("cannot get current flow ctrl parameters, return"
4647 "code = %d\n", ret);
4651 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4652 (fc_conf.mode == RTE_FC_FULL))
4654 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4655 (fc_conf.mode == RTE_FC_FULL))
4659 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4660 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4662 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4663 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4665 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4667 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4668 fc_conf.high_water = res->high_water;
4670 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4671 fc_conf.low_water = res->low_water;
4673 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4674 fc_conf.pause_time = res->pause_time;
4676 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4677 fc_conf.send_xon = res->send_xon;
4679 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4680 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4681 fc_conf.mac_ctrl_frame_fwd = 1;
4683 fc_conf.mac_ctrl_frame_fwd = 0;
4686 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4687 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4689 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4691 printf("bad flow contrl parameter, return code = %d \n", ret);
4694 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4695 struct cmd_priority_flow_ctrl_set_result {
4696 cmdline_fixed_string_t set;
4697 cmdline_fixed_string_t pfc_ctrl;
4698 cmdline_fixed_string_t rx;
4699 cmdline_fixed_string_t rx_pfc_mode;
4700 cmdline_fixed_string_t tx;
4701 cmdline_fixed_string_t tx_pfc_mode;
4702 uint32_t high_water;
4704 uint16_t pause_time;
4710 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4711 __attribute__((unused)) struct cmdline *cl,
4712 __attribute__((unused)) void *data)
4714 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4715 struct rte_eth_pfc_conf pfc_conf;
4716 int rx_fc_enable, tx_fc_enable;
4720 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4721 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4722 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4723 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4725 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4726 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4729 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4730 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4731 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4732 pfc_conf.fc.high_water = res->high_water;
4733 pfc_conf.fc.low_water = res->low_water;
4734 pfc_conf.fc.pause_time = res->pause_time;
4735 pfc_conf.priority = res->priority;
4737 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4739 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4742 cmdline_parse_token_string_t cmd_pfc_set_set =
4743 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4745 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4746 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4747 pfc_ctrl, "pfc_ctrl");
4748 cmdline_parse_token_string_t cmd_pfc_set_rx =
4749 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4751 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4752 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4753 rx_pfc_mode, "on#off");
4754 cmdline_parse_token_string_t cmd_pfc_set_tx =
4755 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4757 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4758 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4759 tx_pfc_mode, "on#off");
4760 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4761 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4762 high_water, UINT32);
4763 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4764 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4766 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4767 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4768 pause_time, UINT16);
4769 cmdline_parse_token_num_t cmd_pfc_set_priority =
4770 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4772 cmdline_parse_token_num_t cmd_pfc_set_portid =
4773 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4776 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4777 .f = cmd_priority_flow_ctrl_set_parsed,
4779 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4780 tx on|off high_water low_water pause_time priority port_id",
4782 (void *)&cmd_pfc_set_set,
4783 (void *)&cmd_pfc_set_flow_ctrl,
4784 (void *)&cmd_pfc_set_rx,
4785 (void *)&cmd_pfc_set_rx_mode,
4786 (void *)&cmd_pfc_set_tx,
4787 (void *)&cmd_pfc_set_tx_mode,
4788 (void *)&cmd_pfc_set_high_water,
4789 (void *)&cmd_pfc_set_low_water,
4790 (void *)&cmd_pfc_set_pause_time,
4791 (void *)&cmd_pfc_set_priority,
4792 (void *)&cmd_pfc_set_portid,
4797 /* *** RESET CONFIGURATION *** */
4798 struct cmd_reset_result {
4799 cmdline_fixed_string_t reset;
4800 cmdline_fixed_string_t def;
4803 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4805 __attribute__((unused)) void *data)
4807 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4808 set_def_fwd_config();
4811 cmdline_parse_token_string_t cmd_reset_set =
4812 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4813 cmdline_parse_token_string_t cmd_reset_def =
4814 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4817 cmdline_parse_inst_t cmd_reset = {
4818 .f = cmd_reset_parsed,
4820 .help_str = "set default: reset default forwarding configuration",
4822 (void *)&cmd_reset_set,
4823 (void *)&cmd_reset_def,
4828 /* *** START FORWARDING *** */
4829 struct cmd_start_result {
4830 cmdline_fixed_string_t start;
4833 cmdline_parse_token_string_t cmd_start_start =
4834 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4836 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4837 __attribute__((unused)) struct cmdline *cl,
4838 __attribute__((unused)) void *data)
4840 start_packet_forwarding(0);
4843 cmdline_parse_inst_t cmd_start = {
4844 .f = cmd_start_parsed,
4846 .help_str = "start packet forwarding",
4848 (void *)&cmd_start_start,
4853 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4854 struct cmd_start_tx_first_result {
4855 cmdline_fixed_string_t start;
4856 cmdline_fixed_string_t tx_first;
4860 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4861 __attribute__((unused)) struct cmdline *cl,
4862 __attribute__((unused)) void *data)
4864 start_packet_forwarding(1);
4867 cmdline_parse_token_string_t cmd_start_tx_first_start =
4868 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4870 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4871 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4872 tx_first, "tx_first");
4874 cmdline_parse_inst_t cmd_start_tx_first = {
4875 .f = cmd_start_tx_first_parsed,
4877 .help_str = "start packet forwarding, after sending 1 burst of packets",
4879 (void *)&cmd_start_tx_first_start,
4880 (void *)&cmd_start_tx_first_tx_first,
4885 /* *** SET LINK UP *** */
4886 struct cmd_set_link_up_result {
4887 cmdline_fixed_string_t set;
4888 cmdline_fixed_string_t link_up;
4889 cmdline_fixed_string_t port;
4893 cmdline_parse_token_string_t cmd_set_link_up_set =
4894 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4895 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4896 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4898 cmdline_parse_token_string_t cmd_set_link_up_port =
4899 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4900 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4901 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4903 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4904 __attribute__((unused)) struct cmdline *cl,
4905 __attribute__((unused)) void *data)
4907 struct cmd_set_link_up_result *res = parsed_result;
4908 dev_set_link_up(res->port_id);
4911 cmdline_parse_inst_t cmd_set_link_up = {
4912 .f = cmd_set_link_up_parsed,
4914 .help_str = "set link-up port (port id)",
4916 (void *)&cmd_set_link_up_set,
4917 (void *)&cmd_set_link_up_link_up,
4918 (void *)&cmd_set_link_up_port,
4919 (void *)&cmd_set_link_up_port_id,
4924 /* *** SET LINK DOWN *** */
4925 struct cmd_set_link_down_result {
4926 cmdline_fixed_string_t set;
4927 cmdline_fixed_string_t link_down;
4928 cmdline_fixed_string_t port;
4932 cmdline_parse_token_string_t cmd_set_link_down_set =
4933 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4934 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4935 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4937 cmdline_parse_token_string_t cmd_set_link_down_port =
4938 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4939 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4940 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4942 static void cmd_set_link_down_parsed(
4943 __attribute__((unused)) void *parsed_result,
4944 __attribute__((unused)) struct cmdline *cl,
4945 __attribute__((unused)) void *data)
4947 struct cmd_set_link_down_result *res = parsed_result;
4948 dev_set_link_down(res->port_id);
4951 cmdline_parse_inst_t cmd_set_link_down = {
4952 .f = cmd_set_link_down_parsed,
4954 .help_str = "set link-down port (port id)",
4956 (void *)&cmd_set_link_down_set,
4957 (void *)&cmd_set_link_down_link_down,
4958 (void *)&cmd_set_link_down_port,
4959 (void *)&cmd_set_link_down_port_id,
4964 /* *** SHOW CFG *** */
4965 struct cmd_showcfg_result {
4966 cmdline_fixed_string_t show;
4967 cmdline_fixed_string_t cfg;
4968 cmdline_fixed_string_t what;
4971 static void cmd_showcfg_parsed(void *parsed_result,
4972 __attribute__((unused)) struct cmdline *cl,
4973 __attribute__((unused)) void *data)
4975 struct cmd_showcfg_result *res = parsed_result;
4976 if (!strcmp(res->what, "rxtx"))
4977 rxtx_config_display();
4978 else if (!strcmp(res->what, "cores"))
4979 fwd_lcores_config_display();
4980 else if (!strcmp(res->what, "fwd"))
4981 fwd_config_display();
4984 cmdline_parse_token_string_t cmd_showcfg_show =
4985 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4986 cmdline_parse_token_string_t cmd_showcfg_port =
4987 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4988 cmdline_parse_token_string_t cmd_showcfg_what =
4989 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4992 cmdline_parse_inst_t cmd_showcfg = {
4993 .f = cmd_showcfg_parsed,
4995 .help_str = "show config rxtx|cores|fwd",
4997 (void *)&cmd_showcfg_show,
4998 (void *)&cmd_showcfg_port,
4999 (void *)&cmd_showcfg_what,
5004 /* *** SHOW ALL PORT INFO *** */
5005 struct cmd_showportall_result {
5006 cmdline_fixed_string_t show;
5007 cmdline_fixed_string_t port;
5008 cmdline_fixed_string_t what;
5009 cmdline_fixed_string_t all;
5012 static void cmd_showportall_parsed(void *parsed_result,
5013 __attribute__((unused)) struct cmdline *cl,
5014 __attribute__((unused)) void *data)
5018 struct cmd_showportall_result *res = parsed_result;
5019 if (!strcmp(res->show, "clear")) {
5020 if (!strcmp(res->what, "stats"))
5021 for (i = 0; i < nb_ports; i++)
5023 } else if (!strcmp(res->what, "info"))
5024 for (i = 0; i < nb_ports; i++)
5025 port_infos_display(i);
5026 else if (!strcmp(res->what, "stats"))
5027 for (i = 0; i < nb_ports; i++)
5028 nic_stats_display(i);
5029 else if (!strcmp(res->what, "fdir"))
5030 for (i = 0; i < nb_ports; i++)
5032 else if (!strcmp(res->what, "stat_qmap"))
5033 for (i = 0; i < nb_ports; i++)
5034 nic_stats_mapping_display(i);
5037 cmdline_parse_token_string_t cmd_showportall_show =
5038 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5040 cmdline_parse_token_string_t cmd_showportall_port =
5041 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5042 cmdline_parse_token_string_t cmd_showportall_what =
5043 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5044 "info#stats#fdir#stat_qmap");
5045 cmdline_parse_token_string_t cmd_showportall_all =
5046 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5047 cmdline_parse_inst_t cmd_showportall = {
5048 .f = cmd_showportall_parsed,
5050 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
5052 (void *)&cmd_showportall_show,
5053 (void *)&cmd_showportall_port,
5054 (void *)&cmd_showportall_what,
5055 (void *)&cmd_showportall_all,
5060 /* *** SHOW PORT INFO *** */
5061 struct cmd_showport_result {
5062 cmdline_fixed_string_t show;
5063 cmdline_fixed_string_t port;
5064 cmdline_fixed_string_t what;
5068 static void cmd_showport_parsed(void *parsed_result,
5069 __attribute__((unused)) struct cmdline *cl,
5070 __attribute__((unused)) void *data)
5072 struct cmd_showport_result *res = parsed_result;
5073 if (!strcmp(res->show, "clear")) {
5074 if (!strcmp(res->what, "stats"))
5075 nic_stats_clear(res->portnum);
5076 } else if (!strcmp(res->what, "info"))
5077 port_infos_display(res->portnum);
5078 else if (!strcmp(res->what, "stats"))
5079 nic_stats_display(res->portnum);
5080 else if (!strcmp(res->what, "fdir"))
5081 fdir_get_infos(res->portnum);
5082 else if (!strcmp(res->what, "stat_qmap"))
5083 nic_stats_mapping_display(res->portnum);
5086 cmdline_parse_token_string_t cmd_showport_show =
5087 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5089 cmdline_parse_token_string_t cmd_showport_port =
5090 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5091 cmdline_parse_token_string_t cmd_showport_what =
5092 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5093 "info#stats#fdir#stat_qmap");
5094 cmdline_parse_token_num_t cmd_showport_portnum =
5095 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5097 cmdline_parse_inst_t cmd_showport = {
5098 .f = cmd_showport_parsed,
5100 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
5102 (void *)&cmd_showport_show,
5103 (void *)&cmd_showport_port,
5104 (void *)&cmd_showport_what,
5105 (void *)&cmd_showport_portnum,
5110 /* *** READ PORT REGISTER *** */
5111 struct cmd_read_reg_result {
5112 cmdline_fixed_string_t read;
5113 cmdline_fixed_string_t reg;
5119 cmd_read_reg_parsed(void *parsed_result,
5120 __attribute__((unused)) struct cmdline *cl,
5121 __attribute__((unused)) void *data)
5123 struct cmd_read_reg_result *res = parsed_result;
5124 port_reg_display(res->port_id, res->reg_off);
5127 cmdline_parse_token_string_t cmd_read_reg_read =
5128 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5129 cmdline_parse_token_string_t cmd_read_reg_reg =
5130 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5131 cmdline_parse_token_num_t cmd_read_reg_port_id =
5132 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5133 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5134 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5136 cmdline_parse_inst_t cmd_read_reg = {
5137 .f = cmd_read_reg_parsed,
5139 .help_str = "read reg port_id reg_off",
5141 (void *)&cmd_read_reg_read,
5142 (void *)&cmd_read_reg_reg,
5143 (void *)&cmd_read_reg_port_id,
5144 (void *)&cmd_read_reg_reg_off,
5149 /* *** READ PORT REGISTER BIT FIELD *** */
5150 struct cmd_read_reg_bit_field_result {
5151 cmdline_fixed_string_t read;
5152 cmdline_fixed_string_t regfield;
5160 cmd_read_reg_bit_field_parsed(void *parsed_result,
5161 __attribute__((unused)) struct cmdline *cl,
5162 __attribute__((unused)) void *data)
5164 struct cmd_read_reg_bit_field_result *res = parsed_result;
5165 port_reg_bit_field_display(res->port_id, res->reg_off,
5166 res->bit1_pos, res->bit2_pos);
5169 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5170 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5172 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5173 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5174 regfield, "regfield");
5175 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5176 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5178 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5179 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5181 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5182 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5184 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5185 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5188 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5189 .f = cmd_read_reg_bit_field_parsed,
5191 .help_str = "read regfield port_id reg_off bit_x bit_y "
5192 "(read register bit field between bit_x and bit_y included)",
5194 (void *)&cmd_read_reg_bit_field_read,
5195 (void *)&cmd_read_reg_bit_field_regfield,
5196 (void *)&cmd_read_reg_bit_field_port_id,
5197 (void *)&cmd_read_reg_bit_field_reg_off,
5198 (void *)&cmd_read_reg_bit_field_bit1_pos,
5199 (void *)&cmd_read_reg_bit_field_bit2_pos,
5204 /* *** READ PORT REGISTER BIT *** */
5205 struct cmd_read_reg_bit_result {
5206 cmdline_fixed_string_t read;
5207 cmdline_fixed_string_t regbit;
5214 cmd_read_reg_bit_parsed(void *parsed_result,
5215 __attribute__((unused)) struct cmdline *cl,
5216 __attribute__((unused)) void *data)
5218 struct cmd_read_reg_bit_result *res = parsed_result;
5219 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5222 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5223 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5224 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5225 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5227 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5228 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5229 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5230 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5231 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5232 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5234 cmdline_parse_inst_t cmd_read_reg_bit = {
5235 .f = cmd_read_reg_bit_parsed,
5237 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5239 (void *)&cmd_read_reg_bit_read,
5240 (void *)&cmd_read_reg_bit_regbit,
5241 (void *)&cmd_read_reg_bit_port_id,
5242 (void *)&cmd_read_reg_bit_reg_off,
5243 (void *)&cmd_read_reg_bit_bit_pos,
5248 /* *** WRITE PORT REGISTER *** */
5249 struct cmd_write_reg_result {
5250 cmdline_fixed_string_t write;
5251 cmdline_fixed_string_t reg;
5258 cmd_write_reg_parsed(void *parsed_result,
5259 __attribute__((unused)) struct cmdline *cl,
5260 __attribute__((unused)) void *data)
5262 struct cmd_write_reg_result *res = parsed_result;
5263 port_reg_set(res->port_id, res->reg_off, res->value);
5266 cmdline_parse_token_string_t cmd_write_reg_write =
5267 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5268 cmdline_parse_token_string_t cmd_write_reg_reg =
5269 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5270 cmdline_parse_token_num_t cmd_write_reg_port_id =
5271 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5272 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5273 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5274 cmdline_parse_token_num_t cmd_write_reg_value =
5275 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5277 cmdline_parse_inst_t cmd_write_reg = {
5278 .f = cmd_write_reg_parsed,
5280 .help_str = "write reg port_id reg_off reg_value",
5282 (void *)&cmd_write_reg_write,
5283 (void *)&cmd_write_reg_reg,
5284 (void *)&cmd_write_reg_port_id,
5285 (void *)&cmd_write_reg_reg_off,
5286 (void *)&cmd_write_reg_value,
5291 /* *** WRITE PORT REGISTER BIT FIELD *** */
5292 struct cmd_write_reg_bit_field_result {
5293 cmdline_fixed_string_t write;
5294 cmdline_fixed_string_t regfield;
5303 cmd_write_reg_bit_field_parsed(void *parsed_result,
5304 __attribute__((unused)) struct cmdline *cl,
5305 __attribute__((unused)) void *data)
5307 struct cmd_write_reg_bit_field_result *res = parsed_result;
5308 port_reg_bit_field_set(res->port_id, res->reg_off,
5309 res->bit1_pos, res->bit2_pos, res->value);
5312 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5313 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5315 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5316 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5317 regfield, "regfield");
5318 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5319 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5321 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5322 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5324 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5325 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5327 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5328 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5330 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5331 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5334 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5335 .f = cmd_write_reg_bit_field_parsed,
5337 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5338 "(set register bit field between bit_x and bit_y included)",
5340 (void *)&cmd_write_reg_bit_field_write,
5341 (void *)&cmd_write_reg_bit_field_regfield,
5342 (void *)&cmd_write_reg_bit_field_port_id,
5343 (void *)&cmd_write_reg_bit_field_reg_off,
5344 (void *)&cmd_write_reg_bit_field_bit1_pos,
5345 (void *)&cmd_write_reg_bit_field_bit2_pos,
5346 (void *)&cmd_write_reg_bit_field_value,
5351 /* *** WRITE PORT REGISTER BIT *** */
5352 struct cmd_write_reg_bit_result {
5353 cmdline_fixed_string_t write;
5354 cmdline_fixed_string_t regbit;
5362 cmd_write_reg_bit_parsed(void *parsed_result,
5363 __attribute__((unused)) struct cmdline *cl,
5364 __attribute__((unused)) void *data)
5366 struct cmd_write_reg_bit_result *res = parsed_result;
5367 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5370 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5371 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5373 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5374 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5376 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5377 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5378 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5379 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5380 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5381 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5382 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5383 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5385 cmdline_parse_inst_t cmd_write_reg_bit = {
5386 .f = cmd_write_reg_bit_parsed,
5388 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5390 (void *)&cmd_write_reg_bit_write,
5391 (void *)&cmd_write_reg_bit_regbit,
5392 (void *)&cmd_write_reg_bit_port_id,
5393 (void *)&cmd_write_reg_bit_reg_off,
5394 (void *)&cmd_write_reg_bit_bit_pos,
5395 (void *)&cmd_write_reg_bit_value,
5400 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5401 struct cmd_read_rxd_txd_result {
5402 cmdline_fixed_string_t read;
5403 cmdline_fixed_string_t rxd_txd;
5410 cmd_read_rxd_txd_parsed(void *parsed_result,
5411 __attribute__((unused)) struct cmdline *cl,
5412 __attribute__((unused)) void *data)
5414 struct cmd_read_rxd_txd_result *res = parsed_result;
5416 if (!strcmp(res->rxd_txd, "rxd"))
5417 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5418 else if (!strcmp(res->rxd_txd, "txd"))
5419 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5422 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5423 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5424 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5425 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5427 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5428 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5429 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5430 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5431 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5432 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5434 cmdline_parse_inst_t cmd_read_rxd_txd = {
5435 .f = cmd_read_rxd_txd_parsed,
5437 .help_str = "read rxd|txd port_id queue_id rxd_id",
5439 (void *)&cmd_read_rxd_txd_read,
5440 (void *)&cmd_read_rxd_txd_rxd_txd,
5441 (void *)&cmd_read_rxd_txd_port_id,
5442 (void *)&cmd_read_rxd_txd_queue_id,
5443 (void *)&cmd_read_rxd_txd_desc_id,
5449 struct cmd_quit_result {
5450 cmdline_fixed_string_t quit;
5453 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5455 __attribute__((unused)) void *data)
5461 cmdline_parse_token_string_t cmd_quit_quit =
5462 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5464 cmdline_parse_inst_t cmd_quit = {
5465 .f = cmd_quit_parsed,
5467 .help_str = "exit application",
5469 (void *)&cmd_quit_quit,
5474 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5475 struct cmd_mac_addr_result {
5476 cmdline_fixed_string_t mac_addr_cmd;
5477 cmdline_fixed_string_t what;
5479 struct ether_addr address;
5482 static void cmd_mac_addr_parsed(void *parsed_result,
5483 __attribute__((unused)) struct cmdline *cl,
5484 __attribute__((unused)) void *data)
5486 struct cmd_mac_addr_result *res = parsed_result;
5489 if (strcmp(res->what, "add") == 0)
5490 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5492 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5494 /* check the return value and print it if is < 0 */
5496 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5500 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5501 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5503 cmdline_parse_token_string_t cmd_mac_addr_what =
5504 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5506 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5507 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5508 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5509 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5511 cmdline_parse_inst_t cmd_mac_addr = {
5512 .f = cmd_mac_addr_parsed,
5514 .help_str = "mac_addr add|remove X <address>: "
5515 "add/remove MAC address on port X",
5517 (void *)&cmd_mac_addr_cmd,
5518 (void *)&cmd_mac_addr_what,
5519 (void *)&cmd_mac_addr_portnum,
5520 (void *)&cmd_mac_addr_addr,
5526 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5527 struct cmd_set_qmap_result {
5528 cmdline_fixed_string_t set;
5529 cmdline_fixed_string_t qmap;
5530 cmdline_fixed_string_t what;
5537 cmd_set_qmap_parsed(void *parsed_result,
5538 __attribute__((unused)) struct cmdline *cl,
5539 __attribute__((unused)) void *data)
5541 struct cmd_set_qmap_result *res = parsed_result;
5542 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5544 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5547 cmdline_parse_token_string_t cmd_setqmap_set =
5548 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5550 cmdline_parse_token_string_t cmd_setqmap_qmap =
5551 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5553 cmdline_parse_token_string_t cmd_setqmap_what =
5554 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5556 cmdline_parse_token_num_t cmd_setqmap_portid =
5557 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5559 cmdline_parse_token_num_t cmd_setqmap_queueid =
5560 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5562 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5563 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5566 cmdline_parse_inst_t cmd_set_qmap = {
5567 .f = cmd_set_qmap_parsed,
5569 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5571 (void *)&cmd_setqmap_set,
5572 (void *)&cmd_setqmap_qmap,
5573 (void *)&cmd_setqmap_what,
5574 (void *)&cmd_setqmap_portid,
5575 (void *)&cmd_setqmap_queueid,
5576 (void *)&cmd_setqmap_mapvalue,
5581 /* *** CONFIGURE UNICAST HASH TABLE *** */
5582 struct cmd_set_uc_hash_table {
5583 cmdline_fixed_string_t set;
5584 cmdline_fixed_string_t port;
5586 cmdline_fixed_string_t what;
5587 struct ether_addr address;
5588 cmdline_fixed_string_t mode;
5592 cmd_set_uc_hash_parsed(void *parsed_result,
5593 __attribute__((unused)) struct cmdline *cl,
5594 __attribute__((unused)) void *data)
5597 struct cmd_set_uc_hash_table *res = parsed_result;
5599 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5601 if (strcmp(res->what, "uta") == 0)
5602 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5603 &res->address,(uint8_t)is_on);
5605 printf("bad unicast hash table parameter, return code = %d \n", ret);
5609 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5610 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5612 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5613 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5615 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5616 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5618 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5619 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5621 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5622 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5624 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5625 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5628 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5629 .f = cmd_set_uc_hash_parsed,
5631 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5633 (void *)&cmd_set_uc_hash_set,
5634 (void *)&cmd_set_uc_hash_port,
5635 (void *)&cmd_set_uc_hash_portid,
5636 (void *)&cmd_set_uc_hash_what,
5637 (void *)&cmd_set_uc_hash_mac,
5638 (void *)&cmd_set_uc_hash_mode,
5643 struct cmd_set_uc_all_hash_table {
5644 cmdline_fixed_string_t set;
5645 cmdline_fixed_string_t port;
5647 cmdline_fixed_string_t what;
5648 cmdline_fixed_string_t value;
5649 cmdline_fixed_string_t mode;
5653 cmd_set_uc_all_hash_parsed(void *parsed_result,
5654 __attribute__((unused)) struct cmdline *cl,
5655 __attribute__((unused)) void *data)
5658 struct cmd_set_uc_all_hash_table *res = parsed_result;
5660 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5662 if ((strcmp(res->what, "uta") == 0) &&
5663 (strcmp(res->value, "all") == 0))
5664 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5666 printf("bad unicast hash table parameter,"
5667 "return code = %d \n", ret);
5670 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5671 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5673 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5674 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5676 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5677 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5679 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5680 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5682 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5683 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5685 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5686 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5689 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5690 .f = cmd_set_uc_all_hash_parsed,
5692 .help_str = "set port X uta all on|off (X = port number)",
5694 (void *)&cmd_set_uc_all_hash_set,
5695 (void *)&cmd_set_uc_all_hash_port,
5696 (void *)&cmd_set_uc_all_hash_portid,
5697 (void *)&cmd_set_uc_all_hash_what,
5698 (void *)&cmd_set_uc_all_hash_value,
5699 (void *)&cmd_set_uc_all_hash_mode,
5704 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5705 struct cmd_set_vf_traffic {
5706 cmdline_fixed_string_t set;
5707 cmdline_fixed_string_t port;
5709 cmdline_fixed_string_t vf;
5711 cmdline_fixed_string_t what;
5712 cmdline_fixed_string_t mode;
5716 cmd_set_vf_traffic_parsed(void *parsed_result,
5717 __attribute__((unused)) struct cmdline *cl,
5718 __attribute__((unused)) void *data)
5720 struct cmd_set_vf_traffic *res = parsed_result;
5721 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5722 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5724 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5727 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5728 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5730 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5731 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5733 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5734 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5736 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5737 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5739 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5740 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5742 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5743 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5745 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5746 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5749 cmdline_parse_inst_t cmd_set_vf_traffic = {
5750 .f = cmd_set_vf_traffic_parsed,
5752 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
5754 (void *)&cmd_setvf_traffic_set,
5755 (void *)&cmd_setvf_traffic_port,
5756 (void *)&cmd_setvf_traffic_portid,
5757 (void *)&cmd_setvf_traffic_vf,
5758 (void *)&cmd_setvf_traffic_vfid,
5759 (void *)&cmd_setvf_traffic_what,
5760 (void *)&cmd_setvf_traffic_mode,
5765 /* *** CONFIGURE VF RECEIVE MODE *** */
5766 struct cmd_set_vf_rxmode {
5767 cmdline_fixed_string_t set;
5768 cmdline_fixed_string_t port;
5770 cmdline_fixed_string_t vf;
5772 cmdline_fixed_string_t what;
5773 cmdline_fixed_string_t mode;
5774 cmdline_fixed_string_t on;
5778 cmd_set_vf_rxmode_parsed(void *parsed_result,
5779 __attribute__((unused)) struct cmdline *cl,
5780 __attribute__((unused)) void *data)
5783 uint16_t rx_mode = 0;
5784 struct cmd_set_vf_rxmode *res = parsed_result;
5786 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5787 if (!strcmp(res->what,"rxmode")) {
5788 if (!strcmp(res->mode, "AUPE"))
5789 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5790 else if (!strcmp(res->mode, "ROPE"))
5791 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5792 else if (!strcmp(res->mode, "BAM"))
5793 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5794 else if (!strncmp(res->mode, "MPE",3))
5795 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5798 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5800 printf("bad VF receive mode parameter, return code = %d \n",
5804 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5805 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5807 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5808 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5810 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5811 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5813 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5814 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5816 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5817 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5819 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5820 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5822 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5823 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5824 mode, "AUPE#ROPE#BAM#MPE");
5825 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5826 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5829 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5830 .f = cmd_set_vf_rxmode_parsed,
5832 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5834 (void *)&cmd_set_vf_rxmode_set,
5835 (void *)&cmd_set_vf_rxmode_port,
5836 (void *)&cmd_set_vf_rxmode_portid,
5837 (void *)&cmd_set_vf_rxmode_vf,
5838 (void *)&cmd_set_vf_rxmode_vfid,
5839 (void *)&cmd_set_vf_rxmode_what,
5840 (void *)&cmd_set_vf_rxmode_mode,
5841 (void *)&cmd_set_vf_rxmode_on,
5846 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5847 struct cmd_vf_mac_addr_result {
5848 cmdline_fixed_string_t mac_addr_cmd;
5849 cmdline_fixed_string_t what;
5850 cmdline_fixed_string_t port;
5852 cmdline_fixed_string_t vf;
5854 struct ether_addr address;
5857 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5858 __attribute__((unused)) struct cmdline *cl,
5859 __attribute__((unused)) void *data)
5861 struct cmd_vf_mac_addr_result *res = parsed_result;
5864 if (strcmp(res->what, "add") == 0)
5865 ret = rte_eth_dev_mac_addr_add(res->port_num,
5866 &res->address, res->vf_num);
5868 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5872 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5873 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5874 mac_addr_cmd,"mac_addr");
5875 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5876 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5878 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5879 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5881 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5882 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5884 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5885 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5887 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
5888 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5890 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
5891 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
5894 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
5895 .f = cmd_vf_mac_addr_parsed,
5897 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
5898 "Y = VF number)add MAC address filtering for a VF on port X",
5900 (void *)&cmd_vf_mac_addr_cmd,
5901 (void *)&cmd_vf_mac_addr_what,
5902 (void *)&cmd_vf_mac_addr_port,
5903 (void *)&cmd_vf_mac_addr_portnum,
5904 (void *)&cmd_vf_mac_addr_vf,
5905 (void *)&cmd_vf_mac_addr_vfnum,
5906 (void *)&cmd_vf_mac_addr_addr,
5911 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
5912 struct cmd_vf_rx_vlan_filter {
5913 cmdline_fixed_string_t rx_vlan;
5914 cmdline_fixed_string_t what;
5916 cmdline_fixed_string_t port;
5918 cmdline_fixed_string_t vf;
5923 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
5924 __attribute__((unused)) struct cmdline *cl,
5925 __attribute__((unused)) void *data)
5927 struct cmd_vf_rx_vlan_filter *res = parsed_result;
5929 if (!strcmp(res->what, "add"))
5930 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
5932 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
5935 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
5936 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5937 rx_vlan, "rx_vlan");
5938 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
5939 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5941 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
5942 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5944 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
5945 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5947 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
5948 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5950 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
5951 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5953 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
5954 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5957 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
5958 .f = cmd_vf_rx_vlan_filter_parsed,
5960 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
5961 "Y = port number,Z = hexadecimal VF mask)",
5963 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
5964 (void *)&cmd_vf_rx_vlan_filter_what,
5965 (void *)&cmd_vf_rx_vlan_filter_vlanid,
5966 (void *)&cmd_vf_rx_vlan_filter_port,
5967 (void *)&cmd_vf_rx_vlan_filter_portid,
5968 (void *)&cmd_vf_rx_vlan_filter_vf,
5969 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
5974 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
5975 struct cmd_queue_rate_limit_result {
5976 cmdline_fixed_string_t set;
5977 cmdline_fixed_string_t port;
5979 cmdline_fixed_string_t queue;
5981 cmdline_fixed_string_t rate;
5985 static void cmd_queue_rate_limit_parsed(void *parsed_result,
5986 __attribute__((unused)) struct cmdline *cl,
5987 __attribute__((unused)) void *data)
5989 struct cmd_queue_rate_limit_result *res = parsed_result;
5992 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5993 && (strcmp(res->queue, "queue") == 0)
5994 && (strcmp(res->rate, "rate") == 0))
5995 ret = set_queue_rate_limit(res->port_num, res->queue_num,
5998 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6002 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6003 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6005 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6006 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6008 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6009 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6011 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6012 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6014 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6015 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6017 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6018 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6020 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6021 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6024 cmdline_parse_inst_t cmd_queue_rate_limit = {
6025 .f = cmd_queue_rate_limit_parsed,
6027 .help_str = "set port X queue Y rate Z:(X = port number,"
6028 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6030 (void *)&cmd_queue_rate_limit_set,
6031 (void *)&cmd_queue_rate_limit_port,
6032 (void *)&cmd_queue_rate_limit_portnum,
6033 (void *)&cmd_queue_rate_limit_queue,
6034 (void *)&cmd_queue_rate_limit_queuenum,
6035 (void *)&cmd_queue_rate_limit_rate,
6036 (void *)&cmd_queue_rate_limit_ratenum,
6041 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6042 struct cmd_vf_rate_limit_result {
6043 cmdline_fixed_string_t set;
6044 cmdline_fixed_string_t port;
6046 cmdline_fixed_string_t vf;
6048 cmdline_fixed_string_t rate;
6050 cmdline_fixed_string_t q_msk;
6054 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6055 __attribute__((unused)) struct cmdline *cl,
6056 __attribute__((unused)) void *data)
6058 struct cmd_vf_rate_limit_result *res = parsed_result;
6061 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6062 && (strcmp(res->vf, "vf") == 0)
6063 && (strcmp(res->rate, "rate") == 0)
6064 && (strcmp(res->q_msk, "queue_mask") == 0))
6065 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6066 res->rate_num, res->q_msk_val);
6068 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6072 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6073 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6075 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6076 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6078 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6079 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6081 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6082 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6084 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6085 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6087 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6088 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6090 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6091 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6093 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6094 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6095 q_msk, "queue_mask");
6096 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6097 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6100 cmdline_parse_inst_t cmd_vf_rate_limit = {
6101 .f = cmd_vf_rate_limit_parsed,
6103 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6104 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6105 "for queues of VF on port X",
6107 (void *)&cmd_vf_rate_limit_set,
6108 (void *)&cmd_vf_rate_limit_port,
6109 (void *)&cmd_vf_rate_limit_portnum,
6110 (void *)&cmd_vf_rate_limit_vf,
6111 (void *)&cmd_vf_rate_limit_vfnum,
6112 (void *)&cmd_vf_rate_limit_rate,
6113 (void *)&cmd_vf_rate_limit_ratenum,
6114 (void *)&cmd_vf_rate_limit_q_msk,
6115 (void *)&cmd_vf_rate_limit_q_msk_val,
6120 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6121 struct cmd_set_mirror_mask_result {
6122 cmdline_fixed_string_t set;
6123 cmdline_fixed_string_t port;
6125 cmdline_fixed_string_t mirror;
6127 cmdline_fixed_string_t what;
6128 cmdline_fixed_string_t value;
6129 cmdline_fixed_string_t dstpool;
6131 cmdline_fixed_string_t on;
6134 cmdline_parse_token_string_t cmd_mirror_mask_set =
6135 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6137 cmdline_parse_token_string_t cmd_mirror_mask_port =
6138 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6140 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6141 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6143 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6144 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6145 mirror, "mirror-rule");
6146 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6147 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6149 cmdline_parse_token_string_t cmd_mirror_mask_what =
6150 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6151 what, "pool-mirror#vlan-mirror");
6152 cmdline_parse_token_string_t cmd_mirror_mask_value =
6153 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6155 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6156 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6157 dstpool, "dst-pool");
6158 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6159 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6161 cmdline_parse_token_string_t cmd_mirror_mask_on =
6162 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6166 cmd_set_mirror_mask_parsed(void *parsed_result,
6167 __attribute__((unused)) struct cmdline *cl,
6168 __attribute__((unused)) void *data)
6171 struct cmd_set_mirror_mask_result *res = parsed_result;
6172 struct rte_eth_vmdq_mirror_conf mr_conf;
6174 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6176 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6178 mr_conf.dst_pool = res->dstpool_id;
6180 if (!strcmp(res->what, "pool-mirror")) {
6181 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6182 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6183 } else if(!strcmp(res->what, "vlan-mirror")) {
6184 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6185 nb_item = parse_item_list(res->value, "core",
6186 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6190 for(i=0; i < nb_item; i++) {
6191 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6192 printf("Invalid vlan_id: must be < 4096\n");
6196 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6197 mr_conf.vlan.vlan_mask |= 1ULL << i;
6201 if(!strcmp(res->on, "on"))
6202 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6205 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6208 printf("mirror rule add error: (%s)\n", strerror(-ret));
6211 cmdline_parse_inst_t cmd_set_mirror_mask = {
6212 .f = cmd_set_mirror_mask_parsed,
6214 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6215 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6217 (void *)&cmd_mirror_mask_set,
6218 (void *)&cmd_mirror_mask_port,
6219 (void *)&cmd_mirror_mask_portid,
6220 (void *)&cmd_mirror_mask_mirror,
6221 (void *)&cmd_mirror_mask_ruleid,
6222 (void *)&cmd_mirror_mask_what,
6223 (void *)&cmd_mirror_mask_value,
6224 (void *)&cmd_mirror_mask_dstpool,
6225 (void *)&cmd_mirror_mask_poolid,
6226 (void *)&cmd_mirror_mask_on,
6231 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6232 struct cmd_set_mirror_link_result {
6233 cmdline_fixed_string_t set;
6234 cmdline_fixed_string_t port;
6236 cmdline_fixed_string_t mirror;
6238 cmdline_fixed_string_t what;
6239 cmdline_fixed_string_t dstpool;
6241 cmdline_fixed_string_t on;
6244 cmdline_parse_token_string_t cmd_mirror_link_set =
6245 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6247 cmdline_parse_token_string_t cmd_mirror_link_port =
6248 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6250 cmdline_parse_token_num_t cmd_mirror_link_portid =
6251 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6253 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6254 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6255 mirror, "mirror-rule");
6256 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6257 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6259 cmdline_parse_token_string_t cmd_mirror_link_what =
6260 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6261 what, "uplink-mirror#downlink-mirror");
6262 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6263 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6264 dstpool, "dst-pool");
6265 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6266 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6268 cmdline_parse_token_string_t cmd_mirror_link_on =
6269 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6273 cmd_set_mirror_link_parsed(void *parsed_result,
6274 __attribute__((unused)) struct cmdline *cl,
6275 __attribute__((unused)) void *data)
6278 struct cmd_set_mirror_link_result *res = parsed_result;
6279 struct rte_eth_vmdq_mirror_conf mr_conf;
6281 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6282 if(!strcmp(res->what, "uplink-mirror")) {
6283 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6284 }else if(!strcmp(res->what, "downlink-mirror"))
6285 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6287 mr_conf.dst_pool = res->dstpool_id;
6289 if(!strcmp(res->on, "on"))
6290 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6293 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6296 /* check the return value and print it if is < 0 */
6298 printf("mirror rule add error: (%s)\n", strerror(-ret));
6302 cmdline_parse_inst_t cmd_set_mirror_link = {
6303 .f = cmd_set_mirror_link_parsed,
6305 .help_str = "set port X mirror-rule Y uplink-mirror|"
6306 "downlink-mirror dst-pool Z on|off",
6308 (void *)&cmd_mirror_link_set,
6309 (void *)&cmd_mirror_link_port,
6310 (void *)&cmd_mirror_link_portid,
6311 (void *)&cmd_mirror_link_mirror,
6312 (void *)&cmd_mirror_link_ruleid,
6313 (void *)&cmd_mirror_link_what,
6314 (void *)&cmd_mirror_link_dstpool,
6315 (void *)&cmd_mirror_link_poolid,
6316 (void *)&cmd_mirror_link_on,
6321 /* *** RESET VM MIRROR RULE *** */
6322 struct cmd_rm_mirror_rule_result {
6323 cmdline_fixed_string_t reset;
6324 cmdline_fixed_string_t port;
6326 cmdline_fixed_string_t mirror;
6330 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6331 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6333 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6334 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6336 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6337 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6339 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6340 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6341 mirror, "mirror-rule");
6342 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6343 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6347 cmd_reset_mirror_rule_parsed(void *parsed_result,
6348 __attribute__((unused)) struct cmdline *cl,
6349 __attribute__((unused)) void *data)
6352 struct cmd_set_mirror_link_result *res = parsed_result;
6354 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6356 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6359 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6360 .f = cmd_reset_mirror_rule_parsed,
6362 .help_str = "reset port X mirror-rule Y",
6364 (void *)&cmd_rm_mirror_rule_reset,
6365 (void *)&cmd_rm_mirror_rule_port,
6366 (void *)&cmd_rm_mirror_rule_portid,
6367 (void *)&cmd_rm_mirror_rule_mirror,
6368 (void *)&cmd_rm_mirror_rule_ruleid,
6373 /* ******************************************************************************** */
6375 struct cmd_dump_result {
6376 cmdline_fixed_string_t dump;
6380 dump_struct_sizes(void)
6382 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6383 DUMP_SIZE(struct rte_mbuf);
6384 DUMP_SIZE(struct rte_pktmbuf);
6385 DUMP_SIZE(struct rte_ctrlmbuf);
6386 DUMP_SIZE(struct rte_mempool);
6387 DUMP_SIZE(struct rte_ring);
6391 static void cmd_dump_parsed(void *parsed_result,
6392 __attribute__((unused)) struct cmdline *cl,
6393 __attribute__((unused)) void *data)
6395 struct cmd_dump_result *res = parsed_result;
6397 if (!strcmp(res->dump, "dump_physmem"))
6398 rte_dump_physmem_layout(stdout);
6399 else if (!strcmp(res->dump, "dump_memzone"))
6400 rte_memzone_dump(stdout);
6401 else if (!strcmp(res->dump, "dump_log_history"))
6402 rte_log_dump_history(stdout);
6403 else if (!strcmp(res->dump, "dump_struct_sizes"))
6404 dump_struct_sizes();
6405 else if (!strcmp(res->dump, "dump_ring"))
6406 rte_ring_list_dump(stdout);
6407 else if (!strcmp(res->dump, "dump_mempool"))
6408 rte_mempool_list_dump(stdout);
6409 else if (!strcmp(res->dump, "dump_devargs"))
6410 rte_eal_devargs_dump(stdout);
6413 cmdline_parse_token_string_t cmd_dump_dump =
6414 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6418 "dump_struct_sizes#"
6423 cmdline_parse_inst_t cmd_dump = {
6424 .f = cmd_dump_parsed, /* function to call */
6425 .data = NULL, /* 2nd arg of func */
6426 .help_str = "dump status",
6427 .tokens = { /* token list, NULL terminated */
6428 (void *)&cmd_dump_dump,
6433 /* ******************************************************************************** */
6435 struct cmd_dump_one_result {
6436 cmdline_fixed_string_t dump;
6437 cmdline_fixed_string_t name;
6440 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6441 __attribute__((unused)) void *data)
6443 struct cmd_dump_one_result *res = parsed_result;
6445 if (!strcmp(res->dump, "dump_ring")) {
6447 r = rte_ring_lookup(res->name);
6449 cmdline_printf(cl, "Cannot find ring\n");
6452 rte_ring_dump(stdout, r);
6453 } else if (!strcmp(res->dump, "dump_mempool")) {
6454 struct rte_mempool *mp;
6455 mp = rte_mempool_lookup(res->name);
6457 cmdline_printf(cl, "Cannot find mempool\n");
6460 rte_mempool_dump(stdout, mp);
6464 cmdline_parse_token_string_t cmd_dump_one_dump =
6465 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6466 "dump_ring#dump_mempool");
6468 cmdline_parse_token_string_t cmd_dump_one_name =
6469 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6471 cmdline_parse_inst_t cmd_dump_one = {
6472 .f = cmd_dump_one_parsed, /* function to call */
6473 .data = NULL, /* 2nd arg of func */
6474 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6475 .tokens = { /* token list, NULL terminated */
6476 (void *)&cmd_dump_one_dump,
6477 (void *)&cmd_dump_one_name,
6482 /* *** ADD/REMOVE an ethertype FILTER *** */
6483 struct cmd_ethertype_filter_result {
6484 cmdline_fixed_string_t filter;
6486 cmdline_fixed_string_t ethertype;
6487 uint16_t ethertype_value;
6488 cmdline_fixed_string_t priority;
6489 cmdline_fixed_string_t priority_en;
6490 uint8_t priority_value;
6491 cmdline_fixed_string_t queue;
6493 cmdline_fixed_string_t index;
6494 uint16_t index_value;
6498 cmd_ethertype_filter_parsed(void *parsed_result,
6499 __attribute__((unused)) struct cmdline *cl,
6500 __attribute__((unused)) void *data)
6503 struct cmd_ethertype_filter_result *res = parsed_result;
6504 struct rte_ethertype_filter filter;
6506 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
6507 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
6508 filter.priority = res->priority_value;
6510 if (!strcmp(res->priority_en, "enable"))
6511 filter.priority_en = 1;
6512 if (!strcmp(res->filter, "add_ethertype_filter"))
6513 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
6515 &filter, res->queue_id);
6516 else if (!strcmp(res->filter, "remove_ethertype_filter"))
6517 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
6519 else if (!strcmp(res->filter, "get_ethertype_filter"))
6520 get_ethertype_filter(res->port_id, res->index_value);
6523 printf("ethertype filter setting error: (%s)\n",
6527 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
6528 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6530 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
6531 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6532 ethertype, "ethertype");
6533 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
6534 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6535 ethertype_value, UINT16);
6536 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
6537 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6538 priority, "priority");
6539 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
6540 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6541 priority_en, "enable#disable");
6542 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
6543 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6544 priority_value, UINT8);
6545 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
6546 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6548 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
6549 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6551 cmdline_parse_token_string_t cmd_ethertype_filter_index =
6552 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6554 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
6555 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6556 index_value, UINT16);
6557 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
6558 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6559 filter, "add_ethertype_filter");
6560 cmdline_parse_inst_t cmd_add_ethertype_filter = {
6561 .f = cmd_ethertype_filter_parsed,
6563 .help_str = "add an ethertype filter",
6565 (void *)&cmd_ethertype_filter_add_filter,
6566 (void *)&cmd_ethertype_filter_port_id,
6567 (void *)&cmd_ethertype_filter_ethertype,
6568 (void *)&cmd_ethertype_filter_ethertype_value,
6569 (void *)&cmd_ethertype_filter_priority,
6570 (void *)&cmd_ethertype_filter_priority_en,
6571 (void *)&cmd_ethertype_filter_priority_value,
6572 (void *)&cmd_ethertype_filter_queue,
6573 (void *)&cmd_ethertype_filter_queue_id,
6574 (void *)&cmd_ethertype_filter_index,
6575 (void *)&cmd_ethertype_filter_index_value,
6580 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
6581 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6582 filter, "remove_ethertype_filter");
6583 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
6584 .f = cmd_ethertype_filter_parsed,
6586 .help_str = "remove an ethertype filter",
6588 (void *)&cmd_ethertype_filter_remove_filter,
6589 (void *)&cmd_ethertype_filter_port_id,
6590 (void *)&cmd_ethertype_filter_index,
6591 (void *)&cmd_ethertype_filter_index_value,
6595 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
6596 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6597 filter, "get_ethertype_filter");
6598 cmdline_parse_inst_t cmd_get_ethertype_filter = {
6599 .f = cmd_ethertype_filter_parsed,
6601 .help_str = "get an ethertype filter",
6603 (void *)&cmd_ethertype_filter_get_filter,
6604 (void *)&cmd_ethertype_filter_port_id,
6605 (void *)&cmd_ethertype_filter_index,
6606 (void *)&cmd_ethertype_filter_index_value,
6611 /* *** set SYN filter *** */
6612 struct cmd_set_syn_filter_result {
6613 cmdline_fixed_string_t filter;
6615 cmdline_fixed_string_t priority;
6616 cmdline_fixed_string_t high;
6617 cmdline_fixed_string_t queue;
6622 cmd_set_syn_filter_parsed(void *parsed_result,
6623 __attribute__((unused)) struct cmdline *cl,
6624 __attribute__((unused)) void *data)
6627 struct cmd_set_syn_filter_result *res = parsed_result;
6628 struct rte_syn_filter filter;
6630 if (!strcmp(res->filter, "add_syn_filter")) {
6631 if (!strcmp(res->high, "high"))
6635 ret = rte_eth_dev_add_syn_filter(res->port_id,
6636 &filter, res->queue_id);
6637 } else if (!strcmp(res->filter, "remove_syn_filter"))
6638 ret = rte_eth_dev_remove_syn_filter(res->port_id);
6639 else if (!strcmp(res->filter, "get_syn_filter"))
6640 get_syn_filter(res->port_id);
6642 printf("syn filter setting error: (%s)\n", strerror(-ret));
6645 cmdline_parse_token_num_t cmd_syn_filter_portid =
6646 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6648 cmdline_parse_token_string_t cmd_syn_filter_priority =
6649 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6650 priority, "priority");
6651 cmdline_parse_token_string_t cmd_syn_filter_high =
6652 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6654 cmdline_parse_token_string_t cmd_syn_filter_queue =
6655 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6657 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6658 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6660 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
6661 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6662 filter, "add_syn_filter");
6663 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
6664 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6665 filter, "remove_syn_filter");
6666 cmdline_parse_inst_t cmd_add_syn_filter = {
6667 .f = cmd_set_syn_filter_parsed,
6669 .help_str = "add syn filter",
6671 (void *)&cmd_syn_filter_add_filter,
6672 (void *)&cmd_syn_filter_portid,
6673 (void *)&cmd_syn_filter_priority,
6674 (void *)&cmd_syn_filter_high,
6675 (void *)&cmd_syn_filter_queue,
6676 (void *)&cmd_syn_filter_queue_id,
6680 cmdline_parse_inst_t cmd_remove_syn_filter = {
6681 .f = cmd_set_syn_filter_parsed,
6683 .help_str = "remove syn filter",
6685 (void *)&cmd_syn_filter_remove_filter,
6686 (void *)&cmd_syn_filter_portid,
6691 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
6692 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6693 filter, "get_syn_filter");
6695 cmdline_parse_inst_t cmd_get_syn_filter = {
6696 .f = cmd_set_syn_filter_parsed,
6698 .help_str = "get syn filter",
6700 (void *)&cmd_syn_filter_get_filter,
6701 (void *)&cmd_syn_filter_portid,
6706 /* *** ADD/REMOVE A 2tuple FILTER *** */
6707 struct cmd_2tuple_filter_result {
6708 cmdline_fixed_string_t filter;
6710 cmdline_fixed_string_t protocol;
6711 uint8_t protocol_value;
6712 uint8_t protocol_mask;
6713 cmdline_fixed_string_t dst_port;
6714 uint16_t dst_port_value;
6715 uint16_t dst_port_mask;
6716 cmdline_fixed_string_t flags;
6717 uint8_t flags_value;
6718 cmdline_fixed_string_t priority;
6719 uint8_t priority_value;
6720 cmdline_fixed_string_t queue;
6722 cmdline_fixed_string_t index;
6723 uint16_t index_value;
6727 cmd_2tuple_filter_parsed(void *parsed_result,
6728 __attribute__((unused)) struct cmdline *cl,
6729 __attribute__((unused)) void *data)
6732 struct rte_2tuple_filter filter;
6733 struct cmd_2tuple_filter_result *res = parsed_result;
6735 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
6737 if (!strcmp(res->filter, "add_2tuple_filter")) {
6738 /* need convert to big endian. */
6739 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6740 filter.protocol = res->protocol_value;
6741 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
6742 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
6743 filter.priority = res->priority_value;
6744 filter.tcp_flags = res->flags_value;
6745 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
6746 res->index_value, &filter, res->queue_id);
6747 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
6748 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
6750 else if (!strcmp(res->filter, "get_2tuple_filter"))
6751 get_2tuple_filter(res->port_id, res->index_value);
6754 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
6757 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6758 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6760 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6761 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6762 protocol, "protocol");
6763 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6764 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6765 protocol_value, UINT8);
6766 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
6767 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6768 protocol_mask, UINT8);
6769 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6770 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6771 dst_port, "dst_port");
6772 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6773 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6774 dst_port_value, UINT16);
6775 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
6776 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6777 dst_port_mask, UINT16);
6778 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
6779 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6781 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
6782 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6783 flags_value, UINT8);
6784 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6785 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6786 priority, "priority");
6787 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6788 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6789 priority_value, UINT8);
6790 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6791 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6793 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6794 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6796 cmdline_parse_token_string_t cmd_2tuple_filter_index =
6797 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6799 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
6800 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6801 index_value, UINT16);
6802 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
6803 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6804 filter, "add_2tuple_filter");
6805 cmdline_parse_inst_t cmd_add_2tuple_filter = {
6806 .f = cmd_2tuple_filter_parsed,
6808 .help_str = "add a 2tuple filter",
6810 (void *)&cmd_2tuple_filter_add_filter,
6811 (void *)&cmd_2tuple_filter_port_id,
6812 (void *)&cmd_2tuple_filter_protocol,
6813 (void *)&cmd_2tuple_filter_protocol_value,
6814 (void *)&cmd_2tuple_filter_protocol_mask,
6815 (void *)&cmd_2tuple_filter_dst_port,
6816 (void *)&cmd_2tuple_filter_dst_port_value,
6817 (void *)&cmd_2tuple_filter_dst_port_mask,
6818 (void *)&cmd_2tuple_filter_flags,
6819 (void *)&cmd_2tuple_filter_flags_value,
6820 (void *)&cmd_2tuple_filter_priority,
6821 (void *)&cmd_2tuple_filter_priority_value,
6822 (void *)&cmd_2tuple_filter_queue,
6823 (void *)&cmd_2tuple_filter_queue_id,
6824 (void *)&cmd_2tuple_filter_index,
6825 (void *)&cmd_2tuple_filter_index_value,
6830 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
6831 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6832 filter, "remove_2tuple_filter");
6833 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
6834 .f = cmd_2tuple_filter_parsed,
6836 .help_str = "remove a 2tuple filter",
6838 (void *)&cmd_2tuple_filter_remove_filter,
6839 (void *)&cmd_2tuple_filter_port_id,
6840 (void *)&cmd_2tuple_filter_index,
6841 (void *)&cmd_2tuple_filter_index_value,
6845 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
6846 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6847 filter, "get_2tuple_filter");
6848 cmdline_parse_inst_t cmd_get_2tuple_filter = {
6849 .f = cmd_2tuple_filter_parsed,
6851 .help_str = "get a 2tuple filter",
6853 (void *)&cmd_2tuple_filter_get_filter,
6854 (void *)&cmd_2tuple_filter_port_id,
6855 (void *)&cmd_2tuple_filter_index,
6856 (void *)&cmd_2tuple_filter_index_value,
6861 /* *** ADD/REMOVE A 5tuple FILTER *** */
6862 struct cmd_5tuple_filter_result {
6863 cmdline_fixed_string_t filter;
6865 cmdline_fixed_string_t dst_ip;
6866 cmdline_ipaddr_t dst_ip_value;
6867 cmdline_fixed_string_t src_ip;
6868 cmdline_ipaddr_t src_ip_value;
6869 cmdline_fixed_string_t dst_port;
6870 uint16_t dst_port_value;
6871 cmdline_fixed_string_t src_port;
6872 uint16_t src_port_value;
6873 cmdline_fixed_string_t protocol;
6874 uint8_t protocol_value;
6875 cmdline_fixed_string_t mask;
6877 cmdline_fixed_string_t flags;
6878 uint8_t flags_value;
6879 cmdline_fixed_string_t priority;
6880 uint8_t priority_value;
6881 cmdline_fixed_string_t queue;
6883 cmdline_fixed_string_t index;
6884 uint16_t index_value;
6888 cmd_5tuple_filter_parsed(void *parsed_result,
6889 __attribute__((unused)) struct cmdline *cl,
6890 __attribute__((unused)) void *data)
6893 struct rte_5tuple_filter filter;
6894 struct cmd_5tuple_filter_result *res = parsed_result;
6896 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
6898 if (!strcmp(res->filter, "add_5tuple_filter")) {
6899 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
6900 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
6901 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
6902 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
6903 filter.protocol = res->protocol_value;
6904 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
6905 filter.priority = res->priority_value;
6906 filter.tcp_flags = res->flags_value;
6908 if (res->dst_ip_value.family == AF_INET)
6909 /* no need to convert, already big endian. */
6910 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
6912 if (filter.dst_ip_mask == 0) {
6913 printf("can not support ipv6 involved compare.\n");
6919 if (res->src_ip_value.family == AF_INET)
6920 /* no need to convert, already big endian. */
6921 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
6923 if (filter.src_ip_mask == 0) {
6924 printf("can not support ipv6 involved compare.\n");
6929 /* need convert to big endian. */
6930 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6931 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
6933 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
6934 res->index_value, &filter, res->queue_id);
6935 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
6936 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
6938 else if (!strcmp(res->filter, "get_5tuple_filter"))
6939 get_5tuple_filter(res->port_id, res->index_value);
6941 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
6945 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
6946 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6948 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
6949 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6951 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
6952 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6954 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
6955 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6957 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
6958 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6960 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
6961 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6962 dst_port, "dst_port");
6963 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
6964 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6965 dst_port_value, UINT16);
6966 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
6967 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6968 src_port, "src_port");
6969 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
6970 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6971 src_port_value, UINT16);
6972 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
6973 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6974 protocol, "protocol");
6975 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
6976 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6977 protocol_value, UINT8);
6978 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
6979 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6981 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
6982 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6984 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
6985 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6987 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
6988 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6989 flags_value, UINT8);
6990 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
6991 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6992 priority, "priority");
6993 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
6994 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6995 priority_value, UINT8);
6996 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
6997 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6999 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7000 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7002 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7003 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7005 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7006 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7007 index_value, UINT16);
7009 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7010 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7011 filter, "add_5tuple_filter");
7012 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7013 .f = cmd_5tuple_filter_parsed,
7015 .help_str = "add a 5tuple filter",
7017 (void *)&cmd_5tuple_filter_add_filter,
7018 (void *)&cmd_5tuple_filter_port_id,
7019 (void *)&cmd_5tuple_filter_dst_ip,
7020 (void *)&cmd_5tuple_filter_dst_ip_value,
7021 (void *)&cmd_5tuple_filter_src_ip,
7022 (void *)&cmd_5tuple_filter_src_ip_value,
7023 (void *)&cmd_5tuple_filter_dst_port,
7024 (void *)&cmd_5tuple_filter_dst_port_value,
7025 (void *)&cmd_5tuple_filter_src_port,
7026 (void *)&cmd_5tuple_filter_src_port_value,
7027 (void *)&cmd_5tuple_filter_protocol,
7028 (void *)&cmd_5tuple_filter_protocol_value,
7029 (void *)&cmd_5tuple_filter_mask,
7030 (void *)&cmd_5tuple_filter_mask_value,
7031 (void *)&cmd_5tuple_filter_flags,
7032 (void *)&cmd_5tuple_filter_flags_value,
7033 (void *)&cmd_5tuple_filter_priority,
7034 (void *)&cmd_5tuple_filter_priority_value,
7035 (void *)&cmd_5tuple_filter_queue,
7036 (void *)&cmd_5tuple_filter_queue_id,
7037 (void *)&cmd_5tuple_filter_index,
7038 (void *)&cmd_5tuple_filter_index_value,
7043 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7044 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7045 filter, "remove_5tuple_filter");
7046 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7047 .f = cmd_5tuple_filter_parsed,
7049 .help_str = "remove a 5tuple filter",
7051 (void *)&cmd_5tuple_filter_remove_filter,
7052 (void *)&cmd_5tuple_filter_port_id,
7053 (void *)&cmd_5tuple_filter_index,
7054 (void *)&cmd_5tuple_filter_index_value,
7059 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7060 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7061 filter, "get_5tuple_filter");
7062 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7063 .f = cmd_5tuple_filter_parsed,
7065 .help_str = "get a 5tuple filter",
7067 (void *)&cmd_5tuple_filter_get_filter,
7068 (void *)&cmd_5tuple_filter_port_id,
7069 (void *)&cmd_5tuple_filter_index,
7070 (void *)&cmd_5tuple_filter_index_value,
7075 /* *** ADD/REMOVE A flex FILTER *** */
7076 struct cmd_flex_filter_result {
7077 cmdline_fixed_string_t filter;
7079 cmdline_fixed_string_t len;
7081 cmdline_fixed_string_t bytes;
7082 cmdline_fixed_string_t bytes_value;
7083 cmdline_fixed_string_t mask;
7084 cmdline_fixed_string_t mask_value;
7085 cmdline_fixed_string_t priority;
7086 uint8_t priority_value;
7087 cmdline_fixed_string_t queue;
7089 cmdline_fixed_string_t index;
7090 uint16_t index_value;
7093 static int xdigit2val(unsigned char c)
7098 else if (isupper(c))
7106 cmd_flex_filter_parsed(void *parsed_result,
7107 __attribute__((unused)) struct cmdline *cl,
7108 __attribute__((unused)) void *data)
7111 struct rte_flex_filter filter;
7112 struct cmd_flex_filter_result *res = parsed_result;
7113 char *bytes_ptr, *mask_ptr;
7121 if (!strcmp(res->filter, "add_flex_filter")) {
7122 if (res->len_value > 128) {
7123 printf("the len exceed the max length 128\n");
7126 memset(&filter, 0, sizeof(struct rte_flex_filter));
7127 filter.len = res->len_value;
7128 filter.priority = res->priority_value;
7129 bytes_ptr = res->bytes_value;
7130 mask_ptr = res->mask_value;
7133 /* translate bytes string to uint_32 array. */
7134 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7135 (bytes_ptr[1] == 'X')))
7137 len = strnlen(bytes_ptr, res->len_value * 2);
7138 if (len == 0 || (len % 8 != 0)) {
7139 printf("please check len and bytes input\n");
7142 for (i = 0; i < len; i++) {
7144 if (isxdigit(c) == 0) {
7145 /* invalid characters. */
7146 printf("invalid input\n");
7149 val = xdigit2val(c);
7153 dword |= byte << (4 * mod - 4);
7158 filter.dwords[j] = dword;
7159 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7165 /* translate mask string to uint8_t array. */
7167 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7168 (mask_ptr[1] == 'X')))
7170 len = strnlen(mask_ptr, (res->len_value+3)/4);
7172 printf("invalid input\n");
7175 for (i = 0; i < len; i++) {
7177 if (isxdigit(c) == 0) {
7178 /* invalid characters. */
7179 printf("invalid input\n");
7182 val = xdigit2val(c);
7183 hex |= (uint8_t)(val & 0x8) >> 3;
7184 hex |= (uint8_t)(val & 0x4) >> 1;
7185 hex |= (uint8_t)(val & 0x2) << 1;
7186 hex |= (uint8_t)(val & 0x1) << 3;
7189 filter.mask[j] = byte;
7190 printf("mask[%d]:%02x ", j, filter.mask[j]);
7198 printf("call function rte_eth_dev_add_flex_filter: "
7199 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7200 res->index_value, res->queue_id,
7201 filter.len, filter.priority);
7202 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7203 &filter, res->queue_id);
7205 } else if (!strcmp(res->filter, "remove_flex_filter"))
7206 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7208 else if (!strcmp(res->filter, "get_flex_filter"))
7209 get_flex_filter(res->port_id, res->index_value);
7212 printf("flex filter setting error: (%s)\n", strerror(-ret));
7215 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7216 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7218 cmdline_parse_token_string_t cmd_flex_filter_len =
7219 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7221 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7222 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7224 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7225 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7227 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7228 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7230 cmdline_parse_token_string_t cmd_flex_filter_mask =
7231 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7233 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7234 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7236 cmdline_parse_token_string_t cmd_flex_filter_priority =
7237 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7238 priority, "priority");
7239 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7240 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7241 priority_value, UINT8);
7242 cmdline_parse_token_string_t cmd_flex_filter_queue =
7243 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7245 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7246 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7248 cmdline_parse_token_string_t cmd_flex_filter_index =
7249 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7251 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7252 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7253 index_value, UINT16);
7254 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7255 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7256 filter, "add_flex_filter");
7257 cmdline_parse_inst_t cmd_add_flex_filter = {
7258 .f = cmd_flex_filter_parsed,
7260 .help_str = "add a flex filter",
7262 (void *)&cmd_flex_filter_add_filter,
7263 (void *)&cmd_flex_filter_port_id,
7264 (void *)&cmd_flex_filter_len,
7265 (void *)&cmd_flex_filter_len_value,
7266 (void *)&cmd_flex_filter_bytes,
7267 (void *)&cmd_flex_filter_bytes_value,
7268 (void *)&cmd_flex_filter_mask,
7269 (void *)&cmd_flex_filter_mask_value,
7270 (void *)&cmd_flex_filter_priority,
7271 (void *)&cmd_flex_filter_priority_value,
7272 (void *)&cmd_flex_filter_queue,
7273 (void *)&cmd_flex_filter_queue_id,
7274 (void *)&cmd_flex_filter_index,
7275 (void *)&cmd_flex_filter_index_value,
7280 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7281 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7282 filter, "remove_flex_filter");
7283 cmdline_parse_inst_t cmd_remove_flex_filter = {
7284 .f = cmd_flex_filter_parsed,
7286 .help_str = "remove a flex filter",
7288 (void *)&cmd_flex_filter_remove_filter,
7289 (void *)&cmd_flex_filter_port_id,
7290 (void *)&cmd_flex_filter_index,
7291 (void *)&cmd_flex_filter_index_value,
7296 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7297 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7298 filter, "get_flex_filter");
7299 cmdline_parse_inst_t cmd_get_flex_filter = {
7300 .f = cmd_flex_filter_parsed,
7302 .help_str = "get a flex filter",
7304 (void *)&cmd_flex_filter_get_filter,
7305 (void *)&cmd_flex_filter_port_id,
7306 (void *)&cmd_flex_filter_index,
7307 (void *)&cmd_flex_filter_index_value,
7312 /* ******************************************************************************** */
7314 /* list of instructions */
7315 cmdline_parse_ctx_t main_ctx[] = {
7316 (cmdline_parse_inst_t *)&cmd_help_brief,
7317 (cmdline_parse_inst_t *)&cmd_help_long,
7318 (cmdline_parse_inst_t *)&cmd_quit,
7319 (cmdline_parse_inst_t *)&cmd_showport,
7320 (cmdline_parse_inst_t *)&cmd_showportall,
7321 (cmdline_parse_inst_t *)&cmd_showcfg,
7322 (cmdline_parse_inst_t *)&cmd_start,
7323 (cmdline_parse_inst_t *)&cmd_start_tx_first,
7324 (cmdline_parse_inst_t *)&cmd_set_link_up,
7325 (cmdline_parse_inst_t *)&cmd_set_link_down,
7326 (cmdline_parse_inst_t *)&cmd_reset,
7327 (cmdline_parse_inst_t *)&cmd_set_numbers,
7328 (cmdline_parse_inst_t *)&cmd_set_txpkts,
7329 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
7330 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
7331 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
7332 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
7333 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
7334 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
7335 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
7336 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
7337 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
7338 (cmdline_parse_inst_t *)&cmd_set_link_check,
7339 #ifdef RTE_NIC_BYPASS
7340 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
7341 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
7342 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
7343 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
7345 #ifdef RTE_LIBRTE_PMD_BOND
7346 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
7347 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
7348 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
7349 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
7350 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
7351 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
7352 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
7353 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
7355 (cmdline_parse_inst_t *)&cmd_vlan_offload,
7356 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
7357 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
7358 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
7359 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
7360 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
7361 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
7362 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
7363 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
7364 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
7365 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
7366 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
7367 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
7368 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
7369 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
7370 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
7371 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
7372 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
7373 (cmdline_parse_inst_t *)&cmd_config_dcb,
7374 (cmdline_parse_inst_t *)&cmd_read_reg,
7375 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
7376 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
7377 (cmdline_parse_inst_t *)&cmd_write_reg,
7378 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
7379 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
7380 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
7381 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
7382 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
7383 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
7384 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
7385 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
7386 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
7387 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
7388 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
7389 (cmdline_parse_inst_t *)&cmd_stop,
7390 (cmdline_parse_inst_t *)&cmd_mac_addr,
7391 (cmdline_parse_inst_t *)&cmd_set_qmap,
7392 (cmdline_parse_inst_t *)&cmd_operate_port,
7393 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
7394 (cmdline_parse_inst_t *)&cmd_config_speed_all,
7395 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
7396 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
7397 (cmdline_parse_inst_t *)&cmd_config_mtu,
7398 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
7399 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
7400 (cmdline_parse_inst_t *)&cmd_config_rss,
7401 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
7402 (cmdline_parse_inst_t *)&cmd_showport_reta,
7403 (cmdline_parse_inst_t *)&cmd_config_burst,
7404 (cmdline_parse_inst_t *)&cmd_config_thresh,
7405 (cmdline_parse_inst_t *)&cmd_config_threshold,
7406 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
7407 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
7408 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
7409 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
7410 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
7411 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
7412 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
7413 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
7414 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
7415 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
7416 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
7417 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
7418 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
7419 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
7420 (cmdline_parse_inst_t *)&cmd_dump,
7421 (cmdline_parse_inst_t *)&cmd_dump_one,
7422 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
7423 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
7424 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
7425 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
7426 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
7427 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
7428 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
7429 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
7430 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
7431 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
7432 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
7433 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
7434 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
7435 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
7436 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
7440 /* prompt function, called from main on MASTER lcore */
7446 /* initialize non-constant commands */
7447 cmd_set_fwd_mode_init();
7449 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
7453 cmdline_interact(cl);
7454 cmdline_stdin_exit(cl);
7458 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
7460 if (id < nb_ports) {
7461 /* check if need_reconfig has been set to 1 */
7462 if (ports[id].need_reconfig == 0)
7463 ports[id].need_reconfig = dev;
7464 /* check if need_reconfig_queues has been set to 1 */
7465 if (ports[id].need_reconfig_queues == 0)
7466 ports[id].need_reconfig_queues = queue;
7470 for (pid = 0; pid < nb_ports; pid++) {
7471 /* check if need_reconfig has been set to 1 */
7472 if (ports[pid].need_reconfig == 0)
7473 ports[pid].need_reconfig = dev;
7474 /* check if need_reconfig_queues has been set to 1 */
7475 if (ports[pid].need_reconfig_queues == 0)
7476 ports[pid].need_reconfig_queues = queue;
7481 #ifdef RTE_NIC_BYPASS
7483 bypass_is_supported(portid_t port_id)
7485 struct rte_port *port;
7486 struct rte_pci_id *pci_id;
7488 if (port_id >= nb_ports) {
7489 printf("\tPort id must be less than %d.\n", nb_ports);
7493 /* Get the device id. */
7494 port = &ports[port_id];
7495 pci_id = &port->dev_info.pci_dev->id;
7497 /* Check if NIC supports bypass. */
7498 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
7502 printf("\tBypass not supported for port_id = %d.\n", port_id);