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) speed (10|100|1000|10000|auto)"
531 " duplex (half|full|auto)\n"
532 " Set speed and duplex for all ports or port_id\n\n"
534 "port config all (rxq|txq|rxd|txd) (value)\n"
535 " Set number for rxq/txq/rxd/txd.\n\n"
537 "port config all max-pkt-len (value)\n"
538 " Set the max packet length.\n\n"
540 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
542 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
545 "port config all rss (ip|udp|none)\n"
546 " Set the RSS mode.\n\n"
548 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
549 " Set the RSS redirection table.\n\n"
551 "port config (port_id) dcb vt (on|off) (traffic_class)"
553 " Set the DCB mode.\n\n"
555 "port config all burst (value)\n"
556 " Set the number of packets per burst.\n\n"
558 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
560 " Set the ring prefetch/host/writeback threshold"
561 " for tx/rx queue.\n\n"
563 "port config all (txfreet|txrst|rxfreet) (value)\n"
564 " Set free threshold for rx/tx, or set"
565 " tx rs bit threshold.\n\n"
566 "port config mtu X value\n"
567 " Set the MTU of port X to a given value\n\n"
571 if (show_all || !strcmp(res->section, "registers")) {
579 "read reg (port_id) (address)\n"
580 " Display value of a port register.\n\n"
582 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
583 " Display a port register bit field.\n\n"
585 "read regbit (port_id) (address) (bit_x)\n"
586 " Display a single port register bit.\n\n"
588 "write reg (port_id) (address) (value)\n"
589 " Set value of a port register.\n\n"
591 "write regfield (port_id) (address) (bit_x) (bit_y)"
593 " Set bit field of a port register.\n\n"
595 "write regbit (port_id) (address) (bit_x) (value)\n"
596 " Set single bit value of a port register.\n\n"
599 if (show_all || !strcmp(res->section, "filters")) {
607 "add_ethertype_filter (port_id) ethertype (eth_value)"
608 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
609 " add an ethertype filter.\n\n"
611 "remove_ethertype_filter (port_id) index (idx)\n"
612 " remove an ethertype filter.\n\n"
614 "get_ethertype_filter (port_id) index (idx)\n"
615 " get info of a ethertype filter.\n\n"
617 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
618 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
619 " queue (queue_id) index (idx)\n"
620 " add a 2tuple filter.\n\n"
622 "remove_2tuple_filter (port_id) index (idx)\n"
623 " remove a 2tuple filter.\n\n"
625 "get_2tuple_filter (port_id) index (idx)\n"
626 " get info of a 2tuple filter.\n\n"
628 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
629 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
630 " mask (mask_value) flags (flags_value) priority (prio_value)"
631 " queue (queue_id) index (idx)\n"
632 " add a 5tuple filter.\n\n"
634 "remove_5tuple_filter (port_id) index (idx)\n"
635 " remove a 5tuple filter.\n\n"
637 "get_5tuple_filter (port_id) index (idx)\n"
638 " get info of a 5tuple filter.\n\n"
640 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
641 " add syn filter.\n\n"
643 "remove_syn_filter (port_id)"
644 " remove syn filter.\n\n"
646 "get_syn_filter (port_id) "
647 " get syn filter info.\n\n"
649 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
650 " priority (prio_value) queue (queue_id) index (idx)\n"
651 " add a flex filter.\n\n"
653 "remove_flex_filter (port_id) index (idx)\n"
654 " remove a flex filter.\n\n"
656 "get_flex_filter (port_id) index (idx)\n"
657 " get info of a flex filter.\n\n"
662 cmdline_parse_token_string_t cmd_help_long_help =
663 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
665 cmdline_parse_token_string_t cmd_help_long_section =
666 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
667 "all#control#display#config#flowdir#"
668 "ports#registers#filters");
670 cmdline_parse_inst_t cmd_help_long = {
671 .f = cmd_help_long_parsed,
673 .help_str = "show help",
675 (void *)&cmd_help_long_help,
676 (void *)&cmd_help_long_section,
682 /* *** start/stop/close all ports *** */
683 struct cmd_operate_port_result {
684 cmdline_fixed_string_t keyword;
685 cmdline_fixed_string_t name;
686 cmdline_fixed_string_t value;
689 static void cmd_operate_port_parsed(void *parsed_result,
690 __attribute__((unused)) struct cmdline *cl,
691 __attribute__((unused)) void *data)
693 struct cmd_operate_port_result *res = parsed_result;
695 if (!strcmp(res->name, "start"))
696 start_port(RTE_PORT_ALL);
697 else if (!strcmp(res->name, "stop"))
698 stop_port(RTE_PORT_ALL);
699 else if (!strcmp(res->name, "close"))
700 close_port(RTE_PORT_ALL);
702 printf("Unknown parameter\n");
705 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
706 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
708 cmdline_parse_token_string_t cmd_operate_port_all_port =
709 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
711 cmdline_parse_token_string_t cmd_operate_port_all_all =
712 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
714 cmdline_parse_inst_t cmd_operate_port = {
715 .f = cmd_operate_port_parsed,
717 .help_str = "port start|stop|close all: start/stop/close all ports",
719 (void *)&cmd_operate_port_all_cmd,
720 (void *)&cmd_operate_port_all_port,
721 (void *)&cmd_operate_port_all_all,
726 /* *** start/stop/close specific port *** */
727 struct cmd_operate_specific_port_result {
728 cmdline_fixed_string_t keyword;
729 cmdline_fixed_string_t name;
733 static void cmd_operate_specific_port_parsed(void *parsed_result,
734 __attribute__((unused)) struct cmdline *cl,
735 __attribute__((unused)) void *data)
737 struct cmd_operate_specific_port_result *res = parsed_result;
739 if (!strcmp(res->name, "start"))
740 start_port(res->value);
741 else if (!strcmp(res->name, "stop"))
742 stop_port(res->value);
743 else if (!strcmp(res->name, "close"))
744 close_port(res->value);
746 printf("Unknown parameter\n");
749 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
750 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
752 cmdline_parse_token_string_t cmd_operate_specific_port_port =
753 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
754 name, "start#stop#close");
755 cmdline_parse_token_num_t cmd_operate_specific_port_id =
756 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
759 cmdline_parse_inst_t cmd_operate_specific_port = {
760 .f = cmd_operate_specific_port_parsed,
762 .help_str = "port start|stop|close X: start/stop/close port X",
764 (void *)&cmd_operate_specific_port_cmd,
765 (void *)&cmd_operate_specific_port_port,
766 (void *)&cmd_operate_specific_port_id,
771 /* *** configure speed for all ports *** */
772 struct cmd_config_speed_all {
773 cmdline_fixed_string_t port;
774 cmdline_fixed_string_t keyword;
775 cmdline_fixed_string_t all;
776 cmdline_fixed_string_t item1;
777 cmdline_fixed_string_t item2;
778 cmdline_fixed_string_t value1;
779 cmdline_fixed_string_t value2;
783 cmd_config_speed_all_parsed(void *parsed_result,
784 __attribute__((unused)) struct cmdline *cl,
785 __attribute__((unused)) void *data)
787 struct cmd_config_speed_all *res = parsed_result;
788 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
789 uint16_t link_duplex = 0;
792 if (!all_ports_stopped()) {
793 printf("Please stop all ports first\n");
797 if (!strcmp(res->value1, "10"))
798 link_speed = ETH_LINK_SPEED_10;
799 else if (!strcmp(res->value1, "100"))
800 link_speed = ETH_LINK_SPEED_100;
801 else if (!strcmp(res->value1, "1000"))
802 link_speed = ETH_LINK_SPEED_1000;
803 else if (!strcmp(res->value1, "10000"))
804 link_speed = ETH_LINK_SPEED_10000;
805 else if (!strcmp(res->value1, "auto"))
806 link_speed = ETH_LINK_SPEED_AUTONEG;
808 printf("Unknown parameter\n");
812 if (!strcmp(res->value2, "half"))
813 link_duplex = ETH_LINK_HALF_DUPLEX;
814 else if (!strcmp(res->value2, "full"))
815 link_duplex = ETH_LINK_FULL_DUPLEX;
816 else if (!strcmp(res->value2, "auto"))
817 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
819 printf("Unknown parameter\n");
823 for (pid = 0; pid < nb_ports; pid++) {
824 ports[pid].dev_conf.link_speed = link_speed;
825 ports[pid].dev_conf.link_duplex = link_duplex;
828 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
831 cmdline_parse_token_string_t cmd_config_speed_all_port =
832 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
833 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
834 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
836 cmdline_parse_token_string_t cmd_config_speed_all_all =
837 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
838 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
839 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
840 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
841 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
842 "10#100#1000#10000#auto");
843 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
844 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
845 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
846 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
849 cmdline_parse_inst_t cmd_config_speed_all = {
850 .f = cmd_config_speed_all_parsed,
852 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
855 (void *)&cmd_config_speed_all_port,
856 (void *)&cmd_config_speed_all_keyword,
857 (void *)&cmd_config_speed_all_all,
858 (void *)&cmd_config_speed_all_item1,
859 (void *)&cmd_config_speed_all_value1,
860 (void *)&cmd_config_speed_all_item2,
861 (void *)&cmd_config_speed_all_value2,
866 /* *** configure speed for specific port *** */
867 struct cmd_config_speed_specific {
868 cmdline_fixed_string_t port;
869 cmdline_fixed_string_t keyword;
871 cmdline_fixed_string_t item1;
872 cmdline_fixed_string_t item2;
873 cmdline_fixed_string_t value1;
874 cmdline_fixed_string_t value2;
878 cmd_config_speed_specific_parsed(void *parsed_result,
879 __attribute__((unused)) struct cmdline *cl,
880 __attribute__((unused)) void *data)
882 struct cmd_config_speed_specific *res = parsed_result;
883 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
884 uint16_t link_duplex = 0;
886 if (!all_ports_stopped()) {
887 printf("Please stop all ports first\n");
891 if (res->id >= nb_ports) {
892 printf("Port id %d must be less than %d\n", res->id, nb_ports);
896 if (!strcmp(res->value1, "10"))
897 link_speed = ETH_LINK_SPEED_10;
898 else if (!strcmp(res->value1, "100"))
899 link_speed = ETH_LINK_SPEED_100;
900 else if (!strcmp(res->value1, "1000"))
901 link_speed = ETH_LINK_SPEED_1000;
902 else if (!strcmp(res->value1, "10000"))
903 link_speed = ETH_LINK_SPEED_10000;
904 else if (!strcmp(res->value1, "auto"))
905 link_speed = ETH_LINK_SPEED_AUTONEG;
907 printf("Unknown parameter\n");
911 if (!strcmp(res->value2, "half"))
912 link_duplex = ETH_LINK_HALF_DUPLEX;
913 else if (!strcmp(res->value2, "full"))
914 link_duplex = ETH_LINK_FULL_DUPLEX;
915 else if (!strcmp(res->value2, "auto"))
916 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
918 printf("Unknown parameter\n");
922 ports[res->id].dev_conf.link_speed = link_speed;
923 ports[res->id].dev_conf.link_duplex = link_duplex;
925 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
929 cmdline_parse_token_string_t cmd_config_speed_specific_port =
930 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
932 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
933 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
935 cmdline_parse_token_num_t cmd_config_speed_specific_id =
936 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
937 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
938 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
940 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
941 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
942 "10#100#1000#10000#auto");
943 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
944 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
946 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
947 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
950 cmdline_parse_inst_t cmd_config_speed_specific = {
951 .f = cmd_config_speed_specific_parsed,
953 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
956 (void *)&cmd_config_speed_specific_port,
957 (void *)&cmd_config_speed_specific_keyword,
958 (void *)&cmd_config_speed_specific_id,
959 (void *)&cmd_config_speed_specific_item1,
960 (void *)&cmd_config_speed_specific_value1,
961 (void *)&cmd_config_speed_specific_item2,
962 (void *)&cmd_config_speed_specific_value2,
967 /* *** configure txq/rxq, txd/rxd *** */
968 struct cmd_config_rx_tx {
969 cmdline_fixed_string_t port;
970 cmdline_fixed_string_t keyword;
971 cmdline_fixed_string_t all;
972 cmdline_fixed_string_t name;
977 cmd_config_rx_tx_parsed(void *parsed_result,
978 __attribute__((unused)) struct cmdline *cl,
979 __attribute__((unused)) void *data)
981 struct cmd_config_rx_tx *res = parsed_result;
983 if (!all_ports_stopped()) {
984 printf("Please stop all ports first\n");
988 if (!strcmp(res->name, "rxq")) {
989 if (res->value <= 0) {
990 printf("rxq %d invalid - must be > 0\n", res->value);
995 else if (!strcmp(res->name, "txq")) {
996 if (res->value <= 0) {
997 printf("txq %d invalid - must be > 0\n", res->value);
1000 nb_txq = res->value;
1002 else if (!strcmp(res->name, "rxd")) {
1003 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1004 printf("rxd %d invalid - must be > 0 && <= %d\n",
1005 res->value, RTE_TEST_RX_DESC_MAX);
1008 nb_rxd = res->value;
1009 } else if (!strcmp(res->name, "txd")) {
1010 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1011 printf("txd %d invalid - must be > 0 && <= %d\n",
1012 res->value, RTE_TEST_TX_DESC_MAX);
1015 nb_txd = res->value;
1017 printf("Unknown parameter\n");
1023 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1026 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1027 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1028 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1029 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1030 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1031 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1032 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1033 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1035 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1036 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1038 cmdline_parse_inst_t cmd_config_rx_tx = {
1039 .f = cmd_config_rx_tx_parsed,
1041 .help_str = "port config all rxq|txq|rxd|txd value",
1043 (void *)&cmd_config_rx_tx_port,
1044 (void *)&cmd_config_rx_tx_keyword,
1045 (void *)&cmd_config_rx_tx_all,
1046 (void *)&cmd_config_rx_tx_name,
1047 (void *)&cmd_config_rx_tx_value,
1052 /* *** config max packet length *** */
1053 struct cmd_config_max_pkt_len_result {
1054 cmdline_fixed_string_t port;
1055 cmdline_fixed_string_t keyword;
1056 cmdline_fixed_string_t all;
1057 cmdline_fixed_string_t name;
1062 cmd_config_max_pkt_len_parsed(void *parsed_result,
1063 __attribute__((unused)) struct cmdline *cl,
1064 __attribute__((unused)) void *data)
1066 struct cmd_config_max_pkt_len_result *res = parsed_result;
1068 if (!all_ports_stopped()) {
1069 printf("Please stop all ports first\n");
1073 if (!strcmp(res->name, "max-pkt-len")) {
1074 if (res->value < ETHER_MIN_LEN) {
1075 printf("max-pkt-len can not be less than %d\n",
1079 if (res->value == rx_mode.max_rx_pkt_len)
1082 rx_mode.max_rx_pkt_len = res->value;
1083 if (res->value > ETHER_MAX_LEN)
1084 rx_mode.jumbo_frame = 1;
1086 rx_mode.jumbo_frame = 0;
1088 printf("Unknown parameter\n");
1094 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1097 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1098 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1100 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1101 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1103 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1104 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1106 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1107 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1109 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1110 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1113 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1114 .f = cmd_config_max_pkt_len_parsed,
1116 .help_str = "port config all max-pkt-len value",
1118 (void *)&cmd_config_max_pkt_len_port,
1119 (void *)&cmd_config_max_pkt_len_keyword,
1120 (void *)&cmd_config_max_pkt_len_all,
1121 (void *)&cmd_config_max_pkt_len_name,
1122 (void *)&cmd_config_max_pkt_len_value,
1127 /* *** configure port MTU *** */
1128 struct cmd_config_mtu_result {
1129 cmdline_fixed_string_t port;
1130 cmdline_fixed_string_t keyword;
1131 cmdline_fixed_string_t mtu;
1137 cmd_config_mtu_parsed(void *parsed_result,
1138 __attribute__((unused)) struct cmdline *cl,
1139 __attribute__((unused)) void *data)
1141 struct cmd_config_mtu_result *res = parsed_result;
1143 if (res->value < ETHER_MIN_LEN) {
1144 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1147 port_mtu_set(res->port_id, res->value);
1150 cmdline_parse_token_string_t cmd_config_mtu_port =
1151 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1153 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1154 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1156 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1157 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1159 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1160 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1161 cmdline_parse_token_num_t cmd_config_mtu_value =
1162 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1164 cmdline_parse_inst_t cmd_config_mtu = {
1165 .f = cmd_config_mtu_parsed,
1167 .help_str = "port config mtu value",
1169 (void *)&cmd_config_mtu_port,
1170 (void *)&cmd_config_mtu_keyword,
1171 (void *)&cmd_config_mtu_mtu,
1172 (void *)&cmd_config_mtu_port_id,
1173 (void *)&cmd_config_mtu_value,
1178 /* *** configure rx mode *** */
1179 struct cmd_config_rx_mode_flag {
1180 cmdline_fixed_string_t port;
1181 cmdline_fixed_string_t keyword;
1182 cmdline_fixed_string_t all;
1183 cmdline_fixed_string_t name;
1184 cmdline_fixed_string_t value;
1188 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1189 __attribute__((unused)) struct cmdline *cl,
1190 __attribute__((unused)) void *data)
1192 struct cmd_config_rx_mode_flag *res = parsed_result;
1194 if (!all_ports_stopped()) {
1195 printf("Please stop all ports first\n");
1199 if (!strcmp(res->name, "crc-strip")) {
1200 if (!strcmp(res->value, "on"))
1201 rx_mode.hw_strip_crc = 1;
1202 else if (!strcmp(res->value, "off"))
1203 rx_mode.hw_strip_crc = 0;
1205 printf("Unknown parameter\n");
1208 } else if (!strcmp(res->name, "rx-cksum")) {
1209 if (!strcmp(res->value, "on"))
1210 rx_mode.hw_ip_checksum = 1;
1211 else if (!strcmp(res->value, "off"))
1212 rx_mode.hw_ip_checksum = 0;
1214 printf("Unknown parameter\n");
1217 } else if (!strcmp(res->name, "hw-vlan")) {
1218 if (!strcmp(res->value, "on")) {
1219 rx_mode.hw_vlan_filter = 1;
1220 rx_mode.hw_vlan_strip = 1;
1222 else if (!strcmp(res->value, "off")) {
1223 rx_mode.hw_vlan_filter = 0;
1224 rx_mode.hw_vlan_strip = 0;
1227 printf("Unknown parameter\n");
1230 } else if (!strcmp(res->name, "drop-en")) {
1231 if (!strcmp(res->value, "on"))
1233 else if (!strcmp(res->value, "off"))
1236 printf("Unknown parameter\n");
1240 printf("Unknown parameter\n");
1246 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1249 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1250 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1251 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1252 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1254 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1255 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1256 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1257 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1258 "crc-strip#rx-cksum#hw-vlan");
1259 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1260 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1263 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1264 .f = cmd_config_rx_mode_flag_parsed,
1266 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1268 (void *)&cmd_config_rx_mode_flag_port,
1269 (void *)&cmd_config_rx_mode_flag_keyword,
1270 (void *)&cmd_config_rx_mode_flag_all,
1271 (void *)&cmd_config_rx_mode_flag_name,
1272 (void *)&cmd_config_rx_mode_flag_value,
1277 /* *** configure rss *** */
1278 struct cmd_config_rss {
1279 cmdline_fixed_string_t port;
1280 cmdline_fixed_string_t keyword;
1281 cmdline_fixed_string_t all;
1282 cmdline_fixed_string_t name;
1283 cmdline_fixed_string_t value;
1287 cmd_config_rss_parsed(void *parsed_result,
1288 __attribute__((unused)) struct cmdline *cl,
1289 __attribute__((unused)) void *data)
1291 struct cmd_config_rss *res = parsed_result;
1292 struct rte_eth_rss_conf rss_conf;
1295 if (!strcmp(res->value, "ip"))
1296 rss_conf.rss_hf = ETH_RSS_IP;
1297 else if (!strcmp(res->value, "udp"))
1298 rss_conf.rss_hf = ETH_RSS_UDP;
1299 else if (!strcmp(res->value, "none"))
1300 rss_conf.rss_hf = 0;
1302 printf("Unknown parameter\n");
1305 rss_conf.rss_key = NULL;
1306 for (i = 0; i < rte_eth_dev_count(); i++)
1307 rte_eth_dev_rss_hash_update(i, &rss_conf);
1310 cmdline_parse_token_string_t cmd_config_rss_port =
1311 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1312 cmdline_parse_token_string_t cmd_config_rss_keyword =
1313 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1314 cmdline_parse_token_string_t cmd_config_rss_all =
1315 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1316 cmdline_parse_token_string_t cmd_config_rss_name =
1317 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1318 cmdline_parse_token_string_t cmd_config_rss_value =
1319 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1321 cmdline_parse_inst_t cmd_config_rss = {
1322 .f = cmd_config_rss_parsed,
1324 .help_str = "port config all rss ip|udp|none",
1326 (void *)&cmd_config_rss_port,
1327 (void *)&cmd_config_rss_keyword,
1328 (void *)&cmd_config_rss_all,
1329 (void *)&cmd_config_rss_name,
1330 (void *)&cmd_config_rss_value,
1335 /* *** configure rss hash key *** */
1336 struct cmd_config_rss_hash_key {
1337 cmdline_fixed_string_t port;
1338 cmdline_fixed_string_t config;
1340 cmdline_fixed_string_t rss_hash_key;
1341 cmdline_fixed_string_t key;
1344 #define RSS_HASH_KEY_LENGTH 40
1346 hexa_digit_to_value(char hexa_digit)
1348 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1349 return (uint8_t) (hexa_digit - '0');
1350 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1351 return (uint8_t) ((hexa_digit - 'a') + 10);
1352 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1353 return (uint8_t) ((hexa_digit - 'A') + 10);
1354 /* Invalid hexa digit */
1359 parse_and_check_key_hexa_digit(char *key, int idx)
1363 hexa_v = hexa_digit_to_value(key[idx]);
1365 printf("invalid key: character %c at position %d is not a "
1366 "valid hexa digit\n", key[idx], idx);
1371 cmd_config_rss_hash_key_parsed(void *parsed_result,
1372 __attribute__((unused)) struct cmdline *cl,
1373 __attribute__((unused)) void *data)
1375 struct cmd_config_rss_hash_key *res = parsed_result;
1376 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1381 /* Check the length of the RSS hash key */
1382 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1383 printf("key length: %d invalid - key must be a string of %d"
1384 "hexa-decimal numbers\n", (int) strlen(res->key),
1385 RSS_HASH_KEY_LENGTH * 2);
1388 /* Translate RSS hash key into binary representation */
1389 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1390 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1393 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1396 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1398 port_rss_hash_key_update(res->port_id, hash_key);
1401 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1403 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1404 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1406 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1407 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1408 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1409 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1410 rss_hash_key, "rss-hash-key");
1411 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1412 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1414 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1415 .f = cmd_config_rss_hash_key_parsed,
1417 .help_str = "port config X rss-hash-key 80 hexa digits",
1419 (void *)&cmd_config_rss_hash_key_port,
1420 (void *)&cmd_config_rss_hash_key_config,
1421 (void *)&cmd_config_rss_hash_key_port_id,
1422 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1423 (void *)&cmd_config_rss_hash_key_value,
1428 /* *** Configure RSS RETA *** */
1429 struct cmd_config_rss_reta {
1430 cmdline_fixed_string_t port;
1431 cmdline_fixed_string_t keyword;
1433 cmdline_fixed_string_t name;
1434 cmdline_fixed_string_t list_name;
1435 cmdline_fixed_string_t list_of_items;
1439 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1446 const char *p, *p0 = str;
1453 unsigned long int_fld[_NUM_FLD];
1454 char *str_fld[_NUM_FLD];
1456 while ((p = strchr(p0,'(')) != NULL) {
1458 if((p0 = strchr(p,')')) == NULL)
1462 if(size >= sizeof(s))
1465 snprintf(s, sizeof(s), "%.*s", size, p);
1466 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1468 for (i = 0; i < _NUM_FLD; i++) {
1470 int_fld[i] = strtoul(str_fld[i], &end, 0);
1471 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1475 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1476 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1478 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1479 printf("Invalid RETA hash index=%d",hash_index);
1483 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1484 reta_conf->mask_lo |= (1ULL << hash_index);
1486 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1488 reta_conf->reta[hash_index] = nb_queue;
1495 cmd_set_rss_reta_parsed(void *parsed_result,
1496 __attribute__((unused)) struct cmdline *cl,
1497 __attribute__((unused)) void *data)
1500 struct rte_eth_rss_reta reta_conf;
1501 struct cmd_config_rss_reta *res = parsed_result;
1503 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1504 if (!strcmp(res->list_name, "reta")) {
1505 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1506 printf("Invalid RSS Redirection Table config entered\n");
1509 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1511 printf("Bad redirection table parameter, return code = %d \n",ret);
1515 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1516 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1517 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1518 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1519 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1520 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1521 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1522 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1523 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1524 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1525 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1526 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1528 cmdline_parse_inst_t cmd_config_rss_reta = {
1529 .f = cmd_set_rss_reta_parsed,
1531 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1533 (void *)&cmd_config_rss_reta_port,
1534 (void *)&cmd_config_rss_reta_keyword,
1535 (void *)&cmd_config_rss_reta_port_id,
1536 (void *)&cmd_config_rss_reta_name,
1537 (void *)&cmd_config_rss_reta_list_name,
1538 (void *)&cmd_config_rss_reta_list_of_items,
1543 /* *** SHOW PORT RETA INFO *** */
1544 struct cmd_showport_reta {
1545 cmdline_fixed_string_t show;
1546 cmdline_fixed_string_t port;
1548 cmdline_fixed_string_t rss;
1549 cmdline_fixed_string_t reta;
1554 static void cmd_showport_reta_parsed(void *parsed_result,
1555 __attribute__((unused)) struct cmdline *cl,
1556 __attribute__((unused)) void *data)
1558 struct cmd_showport_reta *res = parsed_result;
1559 struct rte_eth_rss_reta reta_conf;
1561 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1562 printf("Invalid RSS Redirection Table config entered\n");
1566 reta_conf.mask_lo = res->mask_lo;
1567 reta_conf.mask_hi = res->mask_hi;
1569 port_rss_reta_info(res->port_id,&reta_conf);
1572 cmdline_parse_token_string_t cmd_showport_reta_show =
1573 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1574 cmdline_parse_token_string_t cmd_showport_reta_port =
1575 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1576 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1577 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1578 cmdline_parse_token_string_t cmd_showport_reta_rss =
1579 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1580 cmdline_parse_token_string_t cmd_showport_reta_reta =
1581 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1582 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1583 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1584 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1585 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1587 cmdline_parse_inst_t cmd_showport_reta = {
1588 .f = cmd_showport_reta_parsed,
1590 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1591 (mask_lo and mask_hi is UINT64)",
1593 (void *)&cmd_showport_reta_show,
1594 (void *)&cmd_showport_reta_port,
1595 (void *)&cmd_showport_reta_port_id,
1596 (void *)&cmd_showport_reta_rss,
1597 (void *)&cmd_showport_reta_reta,
1598 (void *)&cmd_showport_reta_mask_lo,
1599 (void *)&cmd_showport_reta_mask_hi,
1604 /* *** Show RSS hash configuration *** */
1605 struct cmd_showport_rss_hash {
1606 cmdline_fixed_string_t show;
1607 cmdline_fixed_string_t port;
1609 cmdline_fixed_string_t rss_hash;
1610 cmdline_fixed_string_t key; /* optional argument */
1613 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1614 __attribute__((unused)) struct cmdline *cl,
1617 struct cmd_showport_rss_hash *res = parsed_result;
1619 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1622 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1623 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1624 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1625 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1626 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1627 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1628 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1629 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1631 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1632 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1634 cmdline_parse_inst_t cmd_showport_rss_hash = {
1635 .f = cmd_showport_rss_hash_parsed,
1637 .help_str = "show port X rss-hash (X = port number)\n",
1639 (void *)&cmd_showport_rss_hash_show,
1640 (void *)&cmd_showport_rss_hash_port,
1641 (void *)&cmd_showport_rss_hash_port_id,
1642 (void *)&cmd_showport_rss_hash_rss_hash,
1647 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1648 .f = cmd_showport_rss_hash_parsed,
1650 .help_str = "show port X rss-hash key (X = port number)\n",
1652 (void *)&cmd_showport_rss_hash_show,
1653 (void *)&cmd_showport_rss_hash_port,
1654 (void *)&cmd_showport_rss_hash_port_id,
1655 (void *)&cmd_showport_rss_hash_rss_hash,
1656 (void *)&cmd_showport_rss_hash_rss_key,
1661 /* *** Configure DCB *** */
1662 struct cmd_config_dcb {
1663 cmdline_fixed_string_t port;
1664 cmdline_fixed_string_t config;
1666 cmdline_fixed_string_t dcb;
1667 cmdline_fixed_string_t vt;
1668 cmdline_fixed_string_t vt_en;
1670 cmdline_fixed_string_t pfc;
1671 cmdline_fixed_string_t pfc_en;
1675 cmd_config_dcb_parsed(void *parsed_result,
1676 __attribute__((unused)) struct cmdline *cl,
1677 __attribute__((unused)) void *data)
1679 struct cmd_config_dcb *res = parsed_result;
1680 struct dcb_config dcb_conf;
1681 portid_t port_id = res->port_id;
1682 struct rte_port *port;
1684 port = &ports[port_id];
1685 /** Check if the port is not started **/
1686 if (port->port_status != RTE_PORT_STOPPED) {
1687 printf("Please stop port %d first\n",port_id);
1691 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1692 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1693 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1697 /* DCB in VT mode */
1698 if (!strncmp(res->vt_en, "on",2))
1699 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1701 dcb_conf.dcb_mode = DCB_ENABLED;
1703 if (!strncmp(res->pfc_en, "on",2)) {
1704 dcb_conf.pfc_en = 1;
1707 dcb_conf.pfc_en = 0;
1709 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1710 printf("Cannot initialize network ports\n");
1714 cmd_reconfig_device_queue(port_id, 1, 1);
1717 cmdline_parse_token_string_t cmd_config_dcb_port =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1719 cmdline_parse_token_string_t cmd_config_dcb_config =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1721 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1722 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1723 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1724 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1725 cmdline_parse_token_string_t cmd_config_dcb_vt =
1726 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1727 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1728 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1729 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1730 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1731 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1733 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1734 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1736 cmdline_parse_inst_t cmd_config_dcb = {
1737 .f = cmd_config_dcb_parsed,
1739 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1741 (void *)&cmd_config_dcb_port,
1742 (void *)&cmd_config_dcb_config,
1743 (void *)&cmd_config_dcb_port_id,
1744 (void *)&cmd_config_dcb_dcb,
1745 (void *)&cmd_config_dcb_vt,
1746 (void *)&cmd_config_dcb_vt_en,
1747 (void *)&cmd_config_dcb_num_tcs,
1748 (void *)&cmd_config_dcb_pfc,
1749 (void *)&cmd_config_dcb_pfc_en,
1754 /* *** configure number of packets per burst *** */
1755 struct cmd_config_burst {
1756 cmdline_fixed_string_t port;
1757 cmdline_fixed_string_t keyword;
1758 cmdline_fixed_string_t all;
1759 cmdline_fixed_string_t name;
1764 cmd_config_burst_parsed(void *parsed_result,
1765 __attribute__((unused)) struct cmdline *cl,
1766 __attribute__((unused)) void *data)
1768 struct cmd_config_burst *res = parsed_result;
1770 if (!all_ports_stopped()) {
1771 printf("Please stop all ports first\n");
1775 if (!strcmp(res->name, "burst")) {
1776 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1777 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1780 nb_pkt_per_burst = res->value;
1782 printf("Unknown parameter\n");
1788 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1791 cmdline_parse_token_string_t cmd_config_burst_port =
1792 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1793 cmdline_parse_token_string_t cmd_config_burst_keyword =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1795 cmdline_parse_token_string_t cmd_config_burst_all =
1796 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1797 cmdline_parse_token_string_t cmd_config_burst_name =
1798 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1799 cmdline_parse_token_num_t cmd_config_burst_value =
1800 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1802 cmdline_parse_inst_t cmd_config_burst = {
1803 .f = cmd_config_burst_parsed,
1805 .help_str = "port config all burst value",
1807 (void *)&cmd_config_burst_port,
1808 (void *)&cmd_config_burst_keyword,
1809 (void *)&cmd_config_burst_all,
1810 (void *)&cmd_config_burst_name,
1811 (void *)&cmd_config_burst_value,
1816 /* *** configure rx/tx queues *** */
1817 struct cmd_config_thresh {
1818 cmdline_fixed_string_t port;
1819 cmdline_fixed_string_t keyword;
1820 cmdline_fixed_string_t all;
1821 cmdline_fixed_string_t name;
1826 cmd_config_thresh_parsed(void *parsed_result,
1827 __attribute__((unused)) struct cmdline *cl,
1828 __attribute__((unused)) void *data)
1830 struct cmd_config_thresh *res = parsed_result;
1832 if (!all_ports_stopped()) {
1833 printf("Please stop all ports first\n");
1837 if (!strcmp(res->name, "txpt"))
1838 tx_thresh.pthresh = res->value;
1839 else if(!strcmp(res->name, "txht"))
1840 tx_thresh.hthresh = res->value;
1841 else if(!strcmp(res->name, "txwt"))
1842 tx_thresh.wthresh = res->value;
1843 else if(!strcmp(res->name, "rxpt"))
1844 rx_thresh.pthresh = res->value;
1845 else if(!strcmp(res->name, "rxht"))
1846 rx_thresh.hthresh = res->value;
1847 else if(!strcmp(res->name, "rxwt"))
1848 rx_thresh.wthresh = res->value;
1850 printf("Unknown parameter\n");
1856 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1859 cmdline_parse_token_string_t cmd_config_thresh_port =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1861 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1863 cmdline_parse_token_string_t cmd_config_thresh_all =
1864 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1865 cmdline_parse_token_string_t cmd_config_thresh_name =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1867 "txpt#txht#txwt#rxpt#rxht#rxwt");
1868 cmdline_parse_token_num_t cmd_config_thresh_value =
1869 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1871 cmdline_parse_inst_t cmd_config_thresh = {
1872 .f = cmd_config_thresh_parsed,
1874 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1876 (void *)&cmd_config_thresh_port,
1877 (void *)&cmd_config_thresh_keyword,
1878 (void *)&cmd_config_thresh_all,
1879 (void *)&cmd_config_thresh_name,
1880 (void *)&cmd_config_thresh_value,
1885 /* *** configure free/rs threshold *** */
1886 struct cmd_config_threshold {
1887 cmdline_fixed_string_t port;
1888 cmdline_fixed_string_t keyword;
1889 cmdline_fixed_string_t all;
1890 cmdline_fixed_string_t name;
1895 cmd_config_threshold_parsed(void *parsed_result,
1896 __attribute__((unused)) struct cmdline *cl,
1897 __attribute__((unused)) void *data)
1899 struct cmd_config_threshold *res = parsed_result;
1901 if (!all_ports_stopped()) {
1902 printf("Please stop all ports first\n");
1906 if (!strcmp(res->name, "txfreet"))
1907 tx_free_thresh = res->value;
1908 else if (!strcmp(res->name, "txrst"))
1909 tx_rs_thresh = res->value;
1910 else if (!strcmp(res->name, "rxfreet"))
1911 rx_free_thresh = res->value;
1913 printf("Unknown parameter\n");
1919 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1922 cmdline_parse_token_string_t cmd_config_threshold_port =
1923 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1924 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1925 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1927 cmdline_parse_token_string_t cmd_config_threshold_all =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1929 cmdline_parse_token_string_t cmd_config_threshold_name =
1930 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1931 "txfreet#txrst#rxfreet");
1932 cmdline_parse_token_num_t cmd_config_threshold_value =
1933 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1935 cmdline_parse_inst_t cmd_config_threshold = {
1936 .f = cmd_config_threshold_parsed,
1938 .help_str = "port config all txfreet|txrst|rxfreet value",
1940 (void *)&cmd_config_threshold_port,
1941 (void *)&cmd_config_threshold_keyword,
1942 (void *)&cmd_config_threshold_all,
1943 (void *)&cmd_config_threshold_name,
1944 (void *)&cmd_config_threshold_value,
1950 struct cmd_stop_result {
1951 cmdline_fixed_string_t stop;
1954 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1955 __attribute__((unused)) struct cmdline *cl,
1956 __attribute__((unused)) void *data)
1958 stop_packet_forwarding();
1961 cmdline_parse_token_string_t cmd_stop_stop =
1962 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1964 cmdline_parse_inst_t cmd_stop = {
1965 .f = cmd_stop_parsed,
1967 .help_str = "stop - stop packet forwarding",
1969 (void *)&cmd_stop_stop,
1974 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1977 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1978 unsigned int *parsed_items, int check_unique_values)
1980 unsigned int nb_item;
1988 * First parse all items in the list and store their value.
1993 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1995 if ((c >= '0') && (c <= '9')) {
1996 value = (unsigned int) (value * 10 + (c - '0'));
2001 printf("character %c is not a decimal digit\n", c);
2005 printf("No valid value before comma\n");
2008 if (nb_item < max_items) {
2009 parsed_items[nb_item] = value;
2015 if (nb_item >= max_items) {
2016 printf("Number of %s = %u > %u (maximum items)\n",
2017 item_name, nb_item + 1, max_items);
2020 parsed_items[nb_item++] = value;
2021 if (! check_unique_values)
2025 * Then, check that all values in the list are differents.
2026 * No optimization here...
2028 for (i = 0; i < nb_item; i++) {
2029 for (j = i + 1; j < nb_item; j++) {
2030 if (parsed_items[j] == parsed_items[i]) {
2031 printf("duplicated %s %u at index %u and %u\n",
2032 item_name, parsed_items[i], i, j);
2040 struct cmd_set_list_result {
2041 cmdline_fixed_string_t cmd_keyword;
2042 cmdline_fixed_string_t list_name;
2043 cmdline_fixed_string_t list_of_items;
2046 static void cmd_set_list_parsed(void *parsed_result,
2047 __attribute__((unused)) struct cmdline *cl,
2048 __attribute__((unused)) void *data)
2050 struct cmd_set_list_result *res;
2052 unsigned int lcorelist[RTE_MAX_LCORE];
2053 unsigned int portlist[RTE_MAX_ETHPORTS];
2055 unsigned int nb_item;
2057 res = parsed_result;
2058 if (!strcmp(res->list_name, "corelist")) {
2059 nb_item = parse_item_list(res->list_of_items, "core",
2061 parsed_items.lcorelist, 1);
2063 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2066 if (!strcmp(res->list_name, "portlist")) {
2067 nb_item = parse_item_list(res->list_of_items, "port",
2069 parsed_items.portlist, 1);
2071 set_fwd_ports_list(parsed_items.portlist, nb_item);
2075 cmdline_parse_token_string_t cmd_set_list_keyword =
2076 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2078 cmdline_parse_token_string_t cmd_set_list_name =
2079 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2080 "corelist#portlist");
2081 cmdline_parse_token_string_t cmd_set_list_of_items =
2082 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2085 cmdline_parse_inst_t cmd_set_fwd_list = {
2086 .f = cmd_set_list_parsed,
2088 .help_str = "set corelist|portlist x[,y]*",
2090 (void *)&cmd_set_list_keyword,
2091 (void *)&cmd_set_list_name,
2092 (void *)&cmd_set_list_of_items,
2097 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2099 struct cmd_setmask_result {
2100 cmdline_fixed_string_t set;
2101 cmdline_fixed_string_t mask;
2105 static void cmd_set_mask_parsed(void *parsed_result,
2106 __attribute__((unused)) struct cmdline *cl,
2107 __attribute__((unused)) void *data)
2109 struct cmd_setmask_result *res = parsed_result;
2111 if (!strcmp(res->mask, "coremask"))
2112 set_fwd_lcores_mask(res->hexavalue);
2113 else if (!strcmp(res->mask, "portmask"))
2114 set_fwd_ports_mask(res->hexavalue);
2117 cmdline_parse_token_string_t cmd_setmask_set =
2118 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2119 cmdline_parse_token_string_t cmd_setmask_mask =
2120 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2121 "coremask#portmask");
2122 cmdline_parse_token_num_t cmd_setmask_value =
2123 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2125 cmdline_parse_inst_t cmd_set_fwd_mask = {
2126 .f = cmd_set_mask_parsed,
2128 .help_str = "set coremask|portmask hexadecimal value",
2130 (void *)&cmd_setmask_set,
2131 (void *)&cmd_setmask_mask,
2132 (void *)&cmd_setmask_value,
2138 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2140 struct cmd_set_result {
2141 cmdline_fixed_string_t set;
2142 cmdline_fixed_string_t what;
2146 static void cmd_set_parsed(void *parsed_result,
2147 __attribute__((unused)) struct cmdline *cl,
2148 __attribute__((unused)) void *data)
2150 struct cmd_set_result *res = parsed_result;
2151 if (!strcmp(res->what, "nbport"))
2152 set_fwd_ports_number(res->value);
2153 else if (!strcmp(res->what, "nbcore"))
2154 set_fwd_lcores_number(res->value);
2155 else if (!strcmp(res->what, "burst"))
2156 set_nb_pkt_per_burst(res->value);
2157 else if (!strcmp(res->what, "verbose"))
2158 set_verbose_level(res->value);
2161 cmdline_parse_token_string_t cmd_set_set =
2162 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2163 cmdline_parse_token_string_t cmd_set_what =
2164 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2165 "nbport#nbcore#burst#verbose");
2166 cmdline_parse_token_num_t cmd_set_value =
2167 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2169 cmdline_parse_inst_t cmd_set_numbers = {
2170 .f = cmd_set_parsed,
2172 .help_str = "set nbport|nbcore|burst|verbose value",
2174 (void *)&cmd_set_set,
2175 (void *)&cmd_set_what,
2176 (void *)&cmd_set_value,
2181 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2183 struct cmd_set_txpkts_result {
2184 cmdline_fixed_string_t cmd_keyword;
2185 cmdline_fixed_string_t txpkts;
2186 cmdline_fixed_string_t seg_lengths;
2190 cmd_set_txpkts_parsed(void *parsed_result,
2191 __attribute__((unused)) struct cmdline *cl,
2192 __attribute__((unused)) void *data)
2194 struct cmd_set_txpkts_result *res;
2195 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2196 unsigned int nb_segs;
2198 res = parsed_result;
2199 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2200 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2202 set_tx_pkt_segments(seg_lengths, nb_segs);
2205 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2206 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2207 cmd_keyword, "set");
2208 cmdline_parse_token_string_t cmd_set_txpkts_name =
2209 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2211 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2212 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2215 cmdline_parse_inst_t cmd_set_txpkts = {
2216 .f = cmd_set_txpkts_parsed,
2218 .help_str = "set txpkts x[,y]*",
2220 (void *)&cmd_set_txpkts_keyword,
2221 (void *)&cmd_set_txpkts_name,
2222 (void *)&cmd_set_txpkts_lengths,
2227 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2228 struct cmd_rx_vlan_filter_all_result {
2229 cmdline_fixed_string_t rx_vlan;
2230 cmdline_fixed_string_t what;
2231 cmdline_fixed_string_t all;
2236 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2237 __attribute__((unused)) struct cmdline *cl,
2238 __attribute__((unused)) void *data)
2240 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2242 if (!strcmp(res->what, "add"))
2243 rx_vlan_all_filter_set(res->port_id, 1);
2245 rx_vlan_all_filter_set(res->port_id, 0);
2248 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2249 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2250 rx_vlan, "rx_vlan");
2251 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2252 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2254 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2255 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2257 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2258 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2261 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2262 .f = cmd_rx_vlan_filter_all_parsed,
2264 .help_str = "add/remove all identifiers to/from the set of VLAN "
2265 "Identifiers filtered by a port",
2267 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2268 (void *)&cmd_rx_vlan_filter_all_what,
2269 (void *)&cmd_rx_vlan_filter_all_all,
2270 (void *)&cmd_rx_vlan_filter_all_portid,
2275 /* *** VLAN OFFLOAD SET ON A PORT *** */
2276 struct cmd_vlan_offload_result {
2277 cmdline_fixed_string_t vlan;
2278 cmdline_fixed_string_t set;
2279 cmdline_fixed_string_t what;
2280 cmdline_fixed_string_t on;
2281 cmdline_fixed_string_t port_id;
2285 cmd_vlan_offload_parsed(void *parsed_result,
2286 __attribute__((unused)) struct cmdline *cl,
2287 __attribute__((unused)) void *data)
2290 struct cmd_vlan_offload_result *res = parsed_result;
2293 portid_t port_id = 0;
2297 len = strnlen(str, STR_TOKEN_SIZE);
2299 /* Get port_id first */
2307 tmp = strtoul(str, NULL, 0);
2308 /* If port_id greater that what portid_t can represent, return */
2309 if(tmp >= RTE_MAX_ETHPORTS)
2311 port_id = (portid_t)tmp;
2313 if (!strcmp(res->on, "on"))
2318 if (!strcmp(res->what, "strip"))
2319 rx_vlan_strip_set(port_id, on);
2320 else if(!strcmp(res->what, "stripq")){
2321 uint16_t queue_id = 0;
2323 /* No queue_id, return */
2325 printf("must specify (port,queue_id)\n");
2328 tmp = strtoul(str + i + 1, NULL, 0);
2329 /* If queue_id greater that what 16-bits can represent, return */
2333 queue_id = (uint16_t)tmp;
2334 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2336 else if (!strcmp(res->what, "filter"))
2337 rx_vlan_filter_set(port_id, on);
2339 vlan_extend_set(port_id, on);
2344 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2345 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2347 cmdline_parse_token_string_t cmd_vlan_offload_set =
2348 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2350 cmdline_parse_token_string_t cmd_vlan_offload_what =
2351 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2352 what, "strip#filter#qinq#stripq");
2353 cmdline_parse_token_string_t cmd_vlan_offload_on =
2354 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2356 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2357 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2360 cmdline_parse_inst_t cmd_vlan_offload = {
2361 .f = cmd_vlan_offload_parsed,
2363 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2364 " qinq(extended) for both rx/tx sides ",
2366 (void *)&cmd_vlan_offload_vlan,
2367 (void *)&cmd_vlan_offload_set,
2368 (void *)&cmd_vlan_offload_what,
2369 (void *)&cmd_vlan_offload_on,
2370 (void *)&cmd_vlan_offload_portid,
2375 /* *** VLAN TPID SET ON A PORT *** */
2376 struct cmd_vlan_tpid_result {
2377 cmdline_fixed_string_t vlan;
2378 cmdline_fixed_string_t set;
2379 cmdline_fixed_string_t what;
2385 cmd_vlan_tpid_parsed(void *parsed_result,
2386 __attribute__((unused)) struct cmdline *cl,
2387 __attribute__((unused)) void *data)
2389 struct cmd_vlan_tpid_result *res = parsed_result;
2390 vlan_tpid_set(res->port_id, res->tp_id);
2394 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2395 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2397 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2398 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2400 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2401 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2403 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2404 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2406 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2407 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2410 cmdline_parse_inst_t cmd_vlan_tpid = {
2411 .f = cmd_vlan_tpid_parsed,
2413 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2415 (void *)&cmd_vlan_tpid_vlan,
2416 (void *)&cmd_vlan_tpid_set,
2417 (void *)&cmd_vlan_tpid_what,
2418 (void *)&cmd_vlan_tpid_tpid,
2419 (void *)&cmd_vlan_tpid_portid,
2424 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2425 struct cmd_rx_vlan_filter_result {
2426 cmdline_fixed_string_t rx_vlan;
2427 cmdline_fixed_string_t what;
2433 cmd_rx_vlan_filter_parsed(void *parsed_result,
2434 __attribute__((unused)) struct cmdline *cl,
2435 __attribute__((unused)) void *data)
2437 struct cmd_rx_vlan_filter_result *res = parsed_result;
2439 if (!strcmp(res->what, "add"))
2440 rx_vft_set(res->port_id, res->vlan_id, 1);
2442 rx_vft_set(res->port_id, res->vlan_id, 0);
2445 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2446 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2447 rx_vlan, "rx_vlan");
2448 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2449 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2451 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2452 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2454 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2455 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2458 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2459 .f = cmd_rx_vlan_filter_parsed,
2461 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2462 "Identifiers filtered by a port",
2464 (void *)&cmd_rx_vlan_filter_rx_vlan,
2465 (void *)&cmd_rx_vlan_filter_what,
2466 (void *)&cmd_rx_vlan_filter_vlanid,
2467 (void *)&cmd_rx_vlan_filter_portid,
2472 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2473 struct cmd_tx_vlan_set_result {
2474 cmdline_fixed_string_t tx_vlan;
2475 cmdline_fixed_string_t set;
2481 cmd_tx_vlan_set_parsed(void *parsed_result,
2482 __attribute__((unused)) struct cmdline *cl,
2483 __attribute__((unused)) void *data)
2485 struct cmd_tx_vlan_set_result *res = parsed_result;
2486 tx_vlan_set(res->port_id, res->vlan_id);
2489 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2490 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2491 tx_vlan, "tx_vlan");
2492 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2493 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2495 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2496 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2498 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2499 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2502 cmdline_parse_inst_t cmd_tx_vlan_set = {
2503 .f = cmd_tx_vlan_set_parsed,
2505 .help_str = "enable hardware insertion of a VLAN header with a given "
2506 "TAG Identifier in packets sent on a port",
2508 (void *)&cmd_tx_vlan_set_tx_vlan,
2509 (void *)&cmd_tx_vlan_set_set,
2510 (void *)&cmd_tx_vlan_set_vlanid,
2511 (void *)&cmd_tx_vlan_set_portid,
2516 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2517 struct cmd_tx_vlan_set_pvid_result {
2518 cmdline_fixed_string_t tx_vlan;
2519 cmdline_fixed_string_t set;
2520 cmdline_fixed_string_t pvid;
2523 cmdline_fixed_string_t mode;
2527 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2528 __attribute__((unused)) struct cmdline *cl,
2529 __attribute__((unused)) void *data)
2531 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2533 if (strcmp(res->mode, "on") == 0)
2534 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2536 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2539 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2540 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2541 tx_vlan, "tx_vlan");
2542 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2543 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2545 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2546 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2548 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2549 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2551 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2552 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2554 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2555 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2558 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2559 .f = cmd_tx_vlan_set_pvid_parsed,
2561 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2563 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2564 (void *)&cmd_tx_vlan_set_pvid_set,
2565 (void *)&cmd_tx_vlan_set_pvid_pvid,
2566 (void *)&cmd_tx_vlan_set_pvid_port_id,
2567 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2568 (void *)&cmd_tx_vlan_set_pvid_mode,
2573 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2574 struct cmd_tx_vlan_reset_result {
2575 cmdline_fixed_string_t tx_vlan;
2576 cmdline_fixed_string_t reset;
2581 cmd_tx_vlan_reset_parsed(void *parsed_result,
2582 __attribute__((unused)) struct cmdline *cl,
2583 __attribute__((unused)) void *data)
2585 struct cmd_tx_vlan_reset_result *res = parsed_result;
2587 tx_vlan_reset(res->port_id);
2590 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2591 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2592 tx_vlan, "tx_vlan");
2593 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2594 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2596 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2597 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2600 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2601 .f = cmd_tx_vlan_reset_parsed,
2603 .help_str = "disable hardware insertion of a VLAN header in packets "
2606 (void *)&cmd_tx_vlan_reset_tx_vlan,
2607 (void *)&cmd_tx_vlan_reset_reset,
2608 (void *)&cmd_tx_vlan_reset_portid,
2614 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2615 struct cmd_tx_cksum_set_result {
2616 cmdline_fixed_string_t tx_cksum;
2617 cmdline_fixed_string_t set;
2623 cmd_tx_cksum_set_parsed(void *parsed_result,
2624 __attribute__((unused)) struct cmdline *cl,
2625 __attribute__((unused)) void *data)
2627 struct cmd_tx_cksum_set_result *res = parsed_result;
2629 tx_cksum_set(res->port_id, res->cksum_mask);
2632 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2633 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2634 tx_cksum, "tx_checksum");
2635 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2636 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2638 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2639 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2641 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2642 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2645 cmdline_parse_inst_t cmd_tx_cksum_set = {
2646 .f = cmd_tx_cksum_set_parsed,
2648 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2649 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2650 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2652 (void *)&cmd_tx_cksum_set_tx_cksum,
2653 (void *)&cmd_tx_cksum_set_set,
2654 (void *)&cmd_tx_cksum_set_cksum_mask,
2655 (void *)&cmd_tx_cksum_set_portid,
2660 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2661 struct cmd_set_flush_rx {
2662 cmdline_fixed_string_t set;
2663 cmdline_fixed_string_t flush_rx;
2664 cmdline_fixed_string_t mode;
2668 cmd_set_flush_rx_parsed(void *parsed_result,
2669 __attribute__((unused)) struct cmdline *cl,
2670 __attribute__((unused)) void *data)
2672 struct cmd_set_flush_rx *res = parsed_result;
2673 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2676 cmdline_parse_token_string_t cmd_setflushrx_set =
2677 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2679 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2680 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2681 flush_rx, "flush_rx");
2682 cmdline_parse_token_string_t cmd_setflushrx_mode =
2683 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2687 cmdline_parse_inst_t cmd_set_flush_rx = {
2688 .f = cmd_set_flush_rx_parsed,
2689 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2692 (void *)&cmd_setflushrx_set,
2693 (void *)&cmd_setflushrx_flush_rx,
2694 (void *)&cmd_setflushrx_mode,
2699 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2700 struct cmd_set_link_check {
2701 cmdline_fixed_string_t set;
2702 cmdline_fixed_string_t link_check;
2703 cmdline_fixed_string_t mode;
2707 cmd_set_link_check_parsed(void *parsed_result,
2708 __attribute__((unused)) struct cmdline *cl,
2709 __attribute__((unused)) void *data)
2711 struct cmd_set_link_check *res = parsed_result;
2712 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2715 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2716 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2718 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2719 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2720 link_check, "link_check");
2721 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2722 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2726 cmdline_parse_inst_t cmd_set_link_check = {
2727 .f = cmd_set_link_check_parsed,
2728 .help_str = "set link_check on|off: enable/disable link status check "
2729 "when starting/stopping a port",
2732 (void *)&cmd_setlinkcheck_set,
2733 (void *)&cmd_setlinkcheck_link_check,
2734 (void *)&cmd_setlinkcheck_mode,
2739 #ifdef RTE_NIC_BYPASS
2740 /* *** SET NIC BYPASS MODE *** */
2741 struct cmd_set_bypass_mode_result {
2742 cmdline_fixed_string_t set;
2743 cmdline_fixed_string_t bypass;
2744 cmdline_fixed_string_t mode;
2745 cmdline_fixed_string_t value;
2750 cmd_set_bypass_mode_parsed(void *parsed_result,
2751 __attribute__((unused)) struct cmdline *cl,
2752 __attribute__((unused)) void *data)
2754 struct cmd_set_bypass_mode_result *res = parsed_result;
2755 portid_t port_id = res->port_id;
2756 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2758 if (!bypass_is_supported(port_id))
2761 if (!strcmp(res->value, "bypass"))
2762 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2763 else if (!strcmp(res->value, "isolate"))
2764 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2766 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2768 /* Set the bypass mode for the relevant port. */
2769 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2770 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2774 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2775 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2777 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2778 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2780 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2781 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2783 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2784 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2785 value, "normal#bypass#isolate");
2786 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2787 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2790 cmdline_parse_inst_t cmd_set_bypass_mode = {
2791 .f = cmd_set_bypass_mode_parsed,
2792 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2793 "Set the NIC bypass mode for port_id",
2796 (void *)&cmd_setbypass_mode_set,
2797 (void *)&cmd_setbypass_mode_bypass,
2798 (void *)&cmd_setbypass_mode_mode,
2799 (void *)&cmd_setbypass_mode_value,
2800 (void *)&cmd_setbypass_mode_port,
2805 /* *** SET NIC BYPASS EVENT *** */
2806 struct cmd_set_bypass_event_result {
2807 cmdline_fixed_string_t set;
2808 cmdline_fixed_string_t bypass;
2809 cmdline_fixed_string_t event;
2810 cmdline_fixed_string_t event_value;
2811 cmdline_fixed_string_t mode;
2812 cmdline_fixed_string_t mode_value;
2817 cmd_set_bypass_event_parsed(void *parsed_result,
2818 __attribute__((unused)) struct cmdline *cl,
2819 __attribute__((unused)) void *data)
2822 struct cmd_set_bypass_event_result *res = parsed_result;
2823 portid_t port_id = res->port_id;
2824 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2825 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2827 if (!bypass_is_supported(port_id))
2830 if (!strcmp(res->event_value, "timeout"))
2831 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2832 else if (!strcmp(res->event_value, "os_on"))
2833 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2834 else if (!strcmp(res->event_value, "os_off"))
2835 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2836 else if (!strcmp(res->event_value, "power_on"))
2837 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2838 else if (!strcmp(res->event_value, "power_off"))
2839 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2841 bypass_event = RTE_BYPASS_EVENT_NONE;
2843 if (!strcmp(res->mode_value, "bypass"))
2844 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2845 else if (!strcmp(res->mode_value, "isolate"))
2846 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2848 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2850 /* Set the watchdog timeout. */
2851 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2854 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2855 (rc = rte_eth_dev_wd_timeout_store(port_id,
2856 bypass_timeout)) != 0) {
2857 printf("Failed to set timeout value %u "
2858 "for port %d, errto code: %d.\n",
2859 bypass_timeout, port_id, rc);
2863 /* Set the bypass event to transition to bypass mode. */
2864 if (0 != rte_eth_dev_bypass_event_store(port_id,
2865 bypass_event, bypass_mode)) {
2866 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2871 cmdline_parse_token_string_t cmd_setbypass_event_set =
2872 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2874 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2875 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2877 cmdline_parse_token_string_t cmd_setbypass_event_event =
2878 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2880 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2881 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2882 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2883 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2884 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2886 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2887 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2888 mode_value, "normal#bypass#isolate");
2889 cmdline_parse_token_num_t cmd_setbypass_event_port =
2890 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2893 cmdline_parse_inst_t cmd_set_bypass_event = {
2894 .f = cmd_set_bypass_event_parsed,
2895 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2896 "mode (normal|bypass|isolate) (port_id): "
2897 "Set the NIC bypass event mode for port_id",
2900 (void *)&cmd_setbypass_event_set,
2901 (void *)&cmd_setbypass_event_bypass,
2902 (void *)&cmd_setbypass_event_event,
2903 (void *)&cmd_setbypass_event_event_value,
2904 (void *)&cmd_setbypass_event_mode,
2905 (void *)&cmd_setbypass_event_mode_value,
2906 (void *)&cmd_setbypass_event_port,
2912 /* *** SET NIC BYPASS TIMEOUT *** */
2913 struct cmd_set_bypass_timeout_result {
2914 cmdline_fixed_string_t set;
2915 cmdline_fixed_string_t bypass;
2916 cmdline_fixed_string_t timeout;
2917 cmdline_fixed_string_t value;
2921 cmd_set_bypass_timeout_parsed(void *parsed_result,
2922 __attribute__((unused)) struct cmdline *cl,
2923 __attribute__((unused)) void *data)
2925 struct cmd_set_bypass_timeout_result *res = parsed_result;
2927 if (!strcmp(res->value, "1.5"))
2928 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2929 else if (!strcmp(res->value, "2"))
2930 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2931 else if (!strcmp(res->value, "3"))
2932 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2933 else if (!strcmp(res->value, "4"))
2934 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2935 else if (!strcmp(res->value, "8"))
2936 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2937 else if (!strcmp(res->value, "16"))
2938 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2939 else if (!strcmp(res->value, "32"))
2940 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2942 bypass_timeout = RTE_BYPASS_TMT_OFF;
2945 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2946 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2948 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2949 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2951 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2952 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2953 timeout, "timeout");
2954 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2955 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2956 value, "0#1.5#2#3#4#8#16#32");
2958 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2959 .f = cmd_set_bypass_timeout_parsed,
2960 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2961 "Set the NIC bypass watchdog timeout",
2964 (void *)&cmd_setbypass_timeout_set,
2965 (void *)&cmd_setbypass_timeout_bypass,
2966 (void *)&cmd_setbypass_timeout_timeout,
2967 (void *)&cmd_setbypass_timeout_value,
2972 /* *** SHOW NIC BYPASS MODE *** */
2973 struct cmd_show_bypass_config_result {
2974 cmdline_fixed_string_t show;
2975 cmdline_fixed_string_t bypass;
2976 cmdline_fixed_string_t config;
2981 cmd_show_bypass_config_parsed(void *parsed_result,
2982 __attribute__((unused)) struct cmdline *cl,
2983 __attribute__((unused)) void *data)
2985 struct cmd_show_bypass_config_result *res = parsed_result;
2986 uint32_t event_mode;
2987 uint32_t bypass_mode;
2988 portid_t port_id = res->port_id;
2989 uint32_t timeout = bypass_timeout;
2992 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2993 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2994 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2995 {"UNKNOWN", "normal", "bypass", "isolate"};
2996 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3003 int num_events = (sizeof events) / (sizeof events[0]);
3005 if (!bypass_is_supported(port_id))
3008 /* Display the bypass mode.*/
3009 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3010 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3014 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3015 bypass_mode = RTE_BYPASS_MODE_NONE;
3017 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3020 /* Display the bypass timeout.*/
3021 if (!RTE_BYPASS_TMT_VALID(timeout))
3022 timeout = RTE_BYPASS_TMT_OFF;
3024 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3026 /* Display the bypass events and associated modes. */
3027 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3029 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3030 printf("\tFailed to get bypass mode for event = %s\n",
3033 if (!RTE_BYPASS_MODE_VALID(event_mode))
3034 event_mode = RTE_BYPASS_MODE_NONE;
3036 printf("\tbypass event: %-16s = %s\n", events[i],
3042 cmdline_parse_token_string_t cmd_showbypass_config_show =
3043 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3045 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3046 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3048 cmdline_parse_token_string_t cmd_showbypass_config_config =
3049 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3051 cmdline_parse_token_num_t cmd_showbypass_config_port =
3052 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3055 cmdline_parse_inst_t cmd_show_bypass_config = {
3056 .f = cmd_show_bypass_config_parsed,
3057 .help_str = "show bypass config (port_id): "
3058 "Show the NIC bypass config for port_id",
3061 (void *)&cmd_showbypass_config_show,
3062 (void *)&cmd_showbypass_config_bypass,
3063 (void *)&cmd_showbypass_config_config,
3064 (void *)&cmd_showbypass_config_port,
3070 #ifdef RTE_LIBRTE_PMD_BOND
3071 /* *** SET BONDING MODE *** */
3072 struct cmd_set_bonding_mode_result {
3073 cmdline_fixed_string_t set;
3074 cmdline_fixed_string_t bonding;
3075 cmdline_fixed_string_t mode;
3080 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3081 __attribute__((unused)) struct cmdline *cl,
3082 __attribute__((unused)) void *data)
3084 struct cmd_set_bonding_mode_result *res = parsed_result;
3085 portid_t port_id = res->port_id;
3087 /* Set the bonding mode for the relevant port. */
3088 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3089 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3092 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3093 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3095 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3096 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3097 bonding, "bonding");
3098 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3099 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3101 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3102 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3104 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3105 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3108 cmdline_parse_inst_t cmd_set_bonding_mode = {
3109 .f = cmd_set_bonding_mode_parsed,
3110 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3113 (void *) &cmd_setbonding_mode_set,
3114 (void *) &cmd_setbonding_mode_bonding,
3115 (void *) &cmd_setbonding_mode_mode,
3116 (void *) &cmd_setbonding_mode_value,
3117 (void *) &cmd_setbonding_mode_port,
3122 /* *** SET BALANCE XMIT POLICY *** */
3123 struct cmd_set_bonding_balance_xmit_policy_result {
3124 cmdline_fixed_string_t set;
3125 cmdline_fixed_string_t bonding;
3126 cmdline_fixed_string_t balance_xmit_policy;
3128 cmdline_fixed_string_t policy;
3131 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3132 __attribute__((unused)) struct cmdline *cl,
3133 __attribute__((unused)) void *data)
3135 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3136 portid_t port_id = res->port_id;
3139 if (!strcmp(res->policy, "l2")) {
3140 policy = BALANCE_XMIT_POLICY_LAYER2;
3141 } else if (!strcmp(res->policy, "l23")) {
3142 policy = BALANCE_XMIT_POLICY_LAYER23;
3143 } else if (!strcmp(res->policy, "l34")) {
3144 policy = BALANCE_XMIT_POLICY_LAYER34;
3146 printf("\t Invalid xmit policy selection");
3150 /* Set the bonding mode for the relevant port. */
3151 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3152 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3157 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3158 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3160 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3161 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3162 bonding, "bonding");
3163 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3164 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3165 balance_xmit_policy, "balance_xmit_policy");
3166 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3167 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3169 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3170 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3171 policy, "l2#l23#l34");
3173 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3174 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3175 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3178 (void *)&cmd_setbonding_balance_xmit_policy_set,
3179 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3180 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3181 (void *)&cmd_setbonding_balance_xmit_policy_port,
3182 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3187 /* *** SHOW NIC BONDING CONFIGURATION *** */
3188 struct cmd_show_bonding_config_result {
3189 cmdline_fixed_string_t show;
3190 cmdline_fixed_string_t bonding;
3191 cmdline_fixed_string_t config;
3195 static void cmd_show_bonding_config_parsed(void *parsed_result,
3196 __attribute__((unused)) struct cmdline *cl,
3197 __attribute__((unused)) void *data)
3199 struct cmd_show_bonding_config_result *res = parsed_result;
3201 uint8_t slaves[RTE_MAX_ETHPORTS];
3202 int num_slaves, num_active_slaves;
3205 portid_t port_id = res->port_id;
3207 /* Display the bonding mode.*/
3208 bonding_mode = rte_eth_bond_mode_get(port_id);
3209 if (bonding_mode < 0) {
3210 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3213 printf("\tBonding mode: %d\n", bonding_mode);
3215 if (bonding_mode == BONDING_MODE_BALANCE) {
3216 int balance_xmit_policy;
3218 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3219 if (balance_xmit_policy < 0) {
3220 printf("\tFailed to get balance xmit policy for port = %d\n",
3224 printf("\tBalance Xmit Policy: ");
3226 switch (balance_xmit_policy) {
3227 case BALANCE_XMIT_POLICY_LAYER2:
3228 printf("BALANCE_XMIT_POLICY_LAYER2");
3230 case BALANCE_XMIT_POLICY_LAYER23:
3231 printf("BALANCE_XMIT_POLICY_LAYER23");
3233 case BALANCE_XMIT_POLICY_LAYER34:
3234 printf("BALANCE_XMIT_POLICY_LAYER34");
3241 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3243 if (num_slaves < 0) {
3244 printf("\tFailed to get slave list for port = %d\n", port_id);
3247 if (num_slaves > 0) {
3248 printf("\tSlaves (%d): [", num_slaves);
3249 for (i = 0; i < num_slaves - 1; i++)
3250 printf("%d ", slaves[i]);
3252 printf("%d]\n", slaves[num_slaves - 1]);
3254 printf("\tSlaves: []\n");
3258 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3261 if (num_active_slaves < 0) {
3262 printf("\tFailed to get active slave list for port = %d\n", port_id);
3265 if (num_active_slaves > 0) {
3266 printf("\tActive Slaves (%d): [", num_active_slaves);
3267 for (i = 0; i < num_active_slaves - 1; i++)
3268 printf("%d ", slaves[i]);
3270 printf("%d]\n", slaves[num_active_slaves - 1]);
3273 printf("\tActive Slaves: []\n");
3277 primary_id = rte_eth_bond_primary_get(port_id);
3278 if (primary_id < 0) {
3279 printf("\tFailed to get primary slave for port = %d\n", port_id);
3282 printf("\tPrimary: [%d]\n", primary_id);
3286 cmdline_parse_token_string_t cmd_showbonding_config_show =
3287 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3289 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3290 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3291 bonding, "bonding");
3292 cmdline_parse_token_string_t cmd_showbonding_config_config =
3293 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3295 cmdline_parse_token_num_t cmd_showbonding_config_port =
3296 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3299 cmdline_parse_inst_t cmd_show_bonding_config = {
3300 .f = cmd_show_bonding_config_parsed,
3301 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3304 (void *)&cmd_showbonding_config_show,
3305 (void *)&cmd_showbonding_config_bonding,
3306 (void *)&cmd_showbonding_config_config,
3307 (void *)&cmd_showbonding_config_port,
3312 /* *** SET BONDING PRIMARY *** */
3313 struct cmd_set_bonding_primary_result {
3314 cmdline_fixed_string_t set;
3315 cmdline_fixed_string_t bonding;
3316 cmdline_fixed_string_t primary;
3321 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3322 __attribute__((unused)) struct cmdline *cl,
3323 __attribute__((unused)) void *data)
3325 struct cmd_set_bonding_primary_result *res = parsed_result;
3326 portid_t master_port_id = res->port_id;
3327 portid_t slave_port_id = res->slave_id;
3329 /* Set the primary slave for a bonded device. */
3330 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3331 printf("\t Failed to set primary slave for port = %d.\n",
3338 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3339 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3341 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3342 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3343 bonding, "bonding");
3344 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3345 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3346 primary, "primary");
3347 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3348 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3350 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3351 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3354 cmdline_parse_inst_t cmd_set_bonding_primary = {
3355 .f = cmd_set_bonding_primary_parsed,
3356 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3359 (void *)&cmd_setbonding_primary_set,
3360 (void *)&cmd_setbonding_primary_bonding,
3361 (void *)&cmd_setbonding_primary_primary,
3362 (void *)&cmd_setbonding_primary_slave,
3363 (void *)&cmd_setbonding_primary_port,
3368 /* *** ADD SLAVE *** */
3369 struct cmd_add_bonding_slave_result {
3370 cmdline_fixed_string_t add;
3371 cmdline_fixed_string_t bonding;
3372 cmdline_fixed_string_t slave;
3377 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3378 __attribute__((unused)) struct cmdline *cl,
3379 __attribute__((unused)) void *data)
3381 struct cmd_add_bonding_slave_result *res = parsed_result;
3382 portid_t master_port_id = res->port_id;
3383 portid_t slave_port_id = res->slave_id;
3385 /* Set the primary slave for a bonded device. */
3386 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3387 printf("\t Failed to add slave %d to master port = %d.\n",
3388 slave_port_id, master_port_id);
3394 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3395 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3397 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3398 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3399 bonding, "bonding");
3400 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3401 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3403 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3404 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3406 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3407 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3410 cmdline_parse_inst_t cmd_add_bonding_slave = {
3411 .f = cmd_add_bonding_slave_parsed,
3412 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3415 (void *)&cmd_addbonding_slave_add,
3416 (void *)&cmd_addbonding_slave_bonding,
3417 (void *)&cmd_addbonding_slave_slave,
3418 (void *)&cmd_addbonding_slave_slaveid,
3419 (void *)&cmd_addbonding_slave_port,
3424 /* *** REMOVE SLAVE *** */
3425 struct cmd_remove_bonding_slave_result {
3426 cmdline_fixed_string_t remove;
3427 cmdline_fixed_string_t bonding;
3428 cmdline_fixed_string_t slave;
3433 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3434 __attribute__((unused)) struct cmdline *cl,
3435 __attribute__((unused)) void *data)
3437 struct cmd_remove_bonding_slave_result *res = parsed_result;
3438 portid_t master_port_id = res->port_id;
3439 portid_t slave_port_id = res->slave_id;
3441 /* Set the primary slave for a bonded device. */
3442 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3443 printf("\t Failed to remove slave %d from master port = %d.\n",
3444 slave_port_id, master_port_id);
3450 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3451 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3453 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3454 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3455 bonding, "bonding");
3456 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3457 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3459 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3460 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3462 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3463 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3466 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3467 .f = cmd_remove_bonding_slave_parsed,
3468 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3471 (void *)&cmd_removebonding_slave_remove,
3472 (void *)&cmd_removebonding_slave_bonding,
3473 (void *)&cmd_removebonding_slave_slave,
3474 (void *)&cmd_removebonding_slave_slaveid,
3475 (void *)&cmd_removebonding_slave_port,
3480 /* *** CREATE BONDED DEVICE *** */
3481 struct cmd_create_bonded_device_result {
3482 cmdline_fixed_string_t create;
3483 cmdline_fixed_string_t bonded;
3484 cmdline_fixed_string_t device;
3489 static int bond_dev_num = 0;
3491 static void cmd_create_bonded_device_parsed(void *parsed_result,
3492 __attribute__((unused)) struct cmdline *cl,
3493 __attribute__((unused)) void *data)
3495 struct cmd_create_bonded_device_result *res = parsed_result;
3496 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3499 if (test_done == 0) {
3500 printf("Please stop forwarding first\n");
3504 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3507 /* Create a new bonded device. */
3508 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3510 printf("\t Failed to create bonded device.\n");
3513 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3516 /* Update number of ports */
3517 nb_ports = rte_eth_dev_count();
3519 rte_eth_promiscuous_enable(port_id);
3524 cmdline_parse_token_string_t cmd_createbonded_device_create =
3525 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3527 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3528 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3530 cmdline_parse_token_string_t cmd_createbonded_device_device =
3531 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3533 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3534 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3536 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3537 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3540 cmdline_parse_inst_t cmd_create_bonded_device = {
3541 .f = cmd_create_bonded_device_parsed,
3542 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3545 (void *)&cmd_createbonded_device_create,
3546 (void *)&cmd_createbonded_device_bonded,
3547 (void *)&cmd_createbonded_device_device,
3548 (void *)&cmd_createbonded_device_mode,
3549 (void *)&cmd_createbonded_device_socket,
3554 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3555 struct cmd_set_bond_mac_addr_result {
3556 cmdline_fixed_string_t set;
3557 cmdline_fixed_string_t bonding;
3558 cmdline_fixed_string_t mac_addr;
3560 struct ether_addr address;
3563 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3564 __attribute__((unused)) struct cmdline *cl,
3565 __attribute__((unused)) void *data)
3567 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3570 if (res->port_num >= nb_ports) {
3571 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3575 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3577 /* check the return value and print it if is < 0 */
3579 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3582 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3583 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3584 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3585 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3587 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3588 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3590 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3591 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3592 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3593 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3595 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3596 .f = cmd_set_bond_mac_addr_parsed,
3598 .help_str = "set bonding mac_addr (port_id) (address): ",
3600 (void *)&cmd_set_bond_mac_addr_set,
3601 (void *)&cmd_set_bond_mac_addr_bonding,
3602 (void *)&cmd_set_bond_mac_addr_mac,
3603 (void *)&cmd_set_bond_mac_addr_portnum,
3604 (void *)&cmd_set_bond_mac_addr_addr,
3609 #endif /* RTE_LIBRTE_PMD_BOND */
3611 /* *** SET FORWARDING MODE *** */
3612 struct cmd_set_fwd_mode_result {
3613 cmdline_fixed_string_t set;
3614 cmdline_fixed_string_t fwd;
3615 cmdline_fixed_string_t mode;
3618 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3619 __attribute__((unused)) struct cmdline *cl,
3620 __attribute__((unused)) void *data)
3622 struct cmd_set_fwd_mode_result *res = parsed_result;
3624 set_pkt_forwarding_mode(res->mode);
3627 cmdline_parse_token_string_t cmd_setfwd_set =
3628 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3629 cmdline_parse_token_string_t cmd_setfwd_fwd =
3630 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3631 cmdline_parse_token_string_t cmd_setfwd_mode =
3632 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3633 "" /* defined at init */);
3635 cmdline_parse_inst_t cmd_set_fwd_mode = {
3636 .f = cmd_set_fwd_mode_parsed,
3638 .help_str = NULL, /* defined at init */
3640 (void *)&cmd_setfwd_set,
3641 (void *)&cmd_setfwd_fwd,
3642 (void *)&cmd_setfwd_mode,
3647 static void cmd_set_fwd_mode_init(void)
3650 static char token[128];
3651 static char help[256];
3652 cmdline_parse_token_string_t *token_struct;
3654 modes = list_pkt_forwarding_modes();
3655 snprintf(help, sizeof help, "set fwd %s - "
3656 "set packet forwarding mode", modes);
3657 cmd_set_fwd_mode.help_str = help;
3659 /* string token separator is # */
3660 for (c = token; *modes != '\0'; modes++)
3665 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3666 token_struct->string_data.str = token;
3669 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3670 struct cmd_set_burst_tx_retry_result {
3671 cmdline_fixed_string_t set;
3672 cmdline_fixed_string_t burst;
3673 cmdline_fixed_string_t tx;
3674 cmdline_fixed_string_t delay;
3676 cmdline_fixed_string_t retry;
3680 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3681 __attribute__((unused)) struct cmdline *cl,
3682 __attribute__((unused)) void *data)
3684 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3686 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3687 && !strcmp(res->tx, "tx")) {
3688 if (!strcmp(res->delay, "delay"))
3689 burst_tx_delay_time = res->time;
3690 if (!strcmp(res->retry, "retry"))
3691 burst_tx_retry_num = res->retry_num;
3696 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3697 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3698 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3699 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3701 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3702 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3703 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3704 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3705 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3706 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3707 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3708 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3709 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3710 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3712 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3713 .f = cmd_set_burst_tx_retry_parsed,
3714 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3716 (void *)&cmd_set_burst_tx_retry_set,
3717 (void *)&cmd_set_burst_tx_retry_burst,
3718 (void *)&cmd_set_burst_tx_retry_tx,
3719 (void *)&cmd_set_burst_tx_retry_delay,
3720 (void *)&cmd_set_burst_tx_retry_time,
3721 (void *)&cmd_set_burst_tx_retry_retry,
3722 (void *)&cmd_set_burst_tx_retry_retry_num,
3727 /* *** SET PROMISC MODE *** */
3728 struct cmd_set_promisc_mode_result {
3729 cmdline_fixed_string_t set;
3730 cmdline_fixed_string_t promisc;
3731 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3732 uint8_t port_num; /* valid if "allports" argument == 0 */
3733 cmdline_fixed_string_t mode;
3736 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3737 __attribute__((unused)) struct cmdline *cl,
3740 struct cmd_set_promisc_mode_result *res = parsed_result;
3744 if (!strcmp(res->mode, "on"))
3751 for (i = 0; i < nb_ports; i++) {
3753 rte_eth_promiscuous_enable(i);
3755 rte_eth_promiscuous_disable(i);
3760 rte_eth_promiscuous_enable(res->port_num);
3762 rte_eth_promiscuous_disable(res->port_num);
3766 cmdline_parse_token_string_t cmd_setpromisc_set =
3767 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3768 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3769 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3771 cmdline_parse_token_string_t cmd_setpromisc_portall =
3772 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3774 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3775 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3777 cmdline_parse_token_string_t cmd_setpromisc_mode =
3778 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3781 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3782 .f = cmd_set_promisc_mode_parsed,
3784 .help_str = "set promisc all on|off: set promisc mode for all ports",
3786 (void *)&cmd_setpromisc_set,
3787 (void *)&cmd_setpromisc_promisc,
3788 (void *)&cmd_setpromisc_portall,
3789 (void *)&cmd_setpromisc_mode,
3794 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3795 .f = cmd_set_promisc_mode_parsed,
3797 .help_str = "set promisc X on|off: set promisc mode on port X",
3799 (void *)&cmd_setpromisc_set,
3800 (void *)&cmd_setpromisc_promisc,
3801 (void *)&cmd_setpromisc_portnum,
3802 (void *)&cmd_setpromisc_mode,
3807 /* *** SET ALLMULTI MODE *** */
3808 struct cmd_set_allmulti_mode_result {
3809 cmdline_fixed_string_t set;
3810 cmdline_fixed_string_t allmulti;
3811 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3812 uint8_t port_num; /* valid if "allports" argument == 0 */
3813 cmdline_fixed_string_t mode;
3816 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3817 __attribute__((unused)) struct cmdline *cl,
3820 struct cmd_set_allmulti_mode_result *res = parsed_result;
3824 if (!strcmp(res->mode, "on"))
3831 for (i = 0; i < nb_ports; i++) {
3833 rte_eth_allmulticast_enable(i);
3835 rte_eth_allmulticast_disable(i);
3840 rte_eth_allmulticast_enable(res->port_num);
3842 rte_eth_allmulticast_disable(res->port_num);
3846 cmdline_parse_token_string_t cmd_setallmulti_set =
3847 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3848 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3849 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3851 cmdline_parse_token_string_t cmd_setallmulti_portall =
3852 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3854 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3855 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3857 cmdline_parse_token_string_t cmd_setallmulti_mode =
3858 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3861 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3862 .f = cmd_set_allmulti_mode_parsed,
3864 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3866 (void *)&cmd_setallmulti_set,
3867 (void *)&cmd_setallmulti_allmulti,
3868 (void *)&cmd_setallmulti_portall,
3869 (void *)&cmd_setallmulti_mode,
3874 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3875 .f = cmd_set_allmulti_mode_parsed,
3877 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3879 (void *)&cmd_setallmulti_set,
3880 (void *)&cmd_setallmulti_allmulti,
3881 (void *)&cmd_setallmulti_portnum,
3882 (void *)&cmd_setallmulti_mode,
3887 /* *** ADD/REMOVE A PKT FILTER *** */
3888 struct cmd_pkt_filter_result {
3889 cmdline_fixed_string_t pkt_filter;
3891 cmdline_fixed_string_t protocol;
3892 cmdline_fixed_string_t src;
3893 cmdline_ipaddr_t ip_src;
3895 cmdline_fixed_string_t dst;
3896 cmdline_ipaddr_t ip_dst;
3898 cmdline_fixed_string_t flexbytes;
3899 uint16_t flexbytes_value;
3900 cmdline_fixed_string_t vlan;
3902 cmdline_fixed_string_t queue;
3904 cmdline_fixed_string_t soft;
3909 cmd_pkt_filter_parsed(void *parsed_result,
3910 __attribute__((unused)) struct cmdline *cl,
3911 __attribute__((unused)) void *data)
3913 struct rte_fdir_filter fdir_filter;
3914 struct cmd_pkt_filter_result *res = parsed_result;
3916 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
3918 if (res->ip_src.family == AF_INET)
3919 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
3921 memcpy(&(fdir_filter.ip_src.ipv6_addr),
3922 &(res->ip_src.addr.ipv6),
3923 sizeof(struct in6_addr));
3925 if (res->ip_dst.family == AF_INET)
3926 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
3928 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
3929 &(res->ip_dst.addr.ipv6),
3930 sizeof(struct in6_addr));
3932 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
3933 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
3935 if (!strcmp(res->protocol, "udp"))
3936 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
3937 else if (!strcmp(res->protocol, "tcp"))
3938 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
3939 else if (!strcmp(res->protocol, "sctp"))
3940 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
3941 else /* default only IP */
3942 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
3944 if (res->ip_dst.family == AF_INET6)
3945 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
3947 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
3949 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
3950 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
3952 if (!strcmp(res->pkt_filter, "add_signature_filter"))
3953 fdir_add_signature_filter(res->port_id, res->queue_id,
3955 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3956 fdir_update_signature_filter(res->port_id, res->queue_id,
3958 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3959 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3960 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3961 fdir_add_perfect_filter(res->port_id, res->soft_id,
3963 (uint8_t) (res->queue_id < 0),
3965 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3966 fdir_update_perfect_filter(res->port_id, res->soft_id,
3968 (uint8_t) (res->queue_id < 0),
3970 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3971 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3977 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3978 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3980 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3981 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3982 protocol, "ip#tcp#udp#sctp");
3983 cmdline_parse_token_string_t cmd_pkt_filter_src =
3984 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3986 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3987 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3989 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3990 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3992 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3993 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3995 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3996 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3998 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3999 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4001 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4002 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4003 flexbytes, "flexbytes");
4004 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4005 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4006 flexbytes_value, UINT16);
4007 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4008 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4010 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4011 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4013 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4014 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4016 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4017 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4019 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4020 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4022 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4023 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4027 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4028 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4029 pkt_filter, "add_signature_filter");
4030 cmdline_parse_inst_t cmd_add_signature_filter = {
4031 .f = cmd_pkt_filter_parsed,
4033 .help_str = "add a signature filter",
4035 (void *)&cmd_pkt_filter_add_signature_filter,
4036 (void *)&cmd_pkt_filter_port_id,
4037 (void *)&cmd_pkt_filter_protocol,
4038 (void *)&cmd_pkt_filter_src,
4039 (void *)&cmd_pkt_filter_ip_src,
4040 (void *)&cmd_pkt_filter_port_src,
4041 (void *)&cmd_pkt_filter_dst,
4042 (void *)&cmd_pkt_filter_ip_dst,
4043 (void *)&cmd_pkt_filter_port_dst,
4044 (void *)&cmd_pkt_filter_flexbytes,
4045 (void *)&cmd_pkt_filter_flexbytes_value,
4046 (void *)&cmd_pkt_filter_vlan,
4047 (void *)&cmd_pkt_filter_vlan_id,
4048 (void *)&cmd_pkt_filter_queue,
4049 (void *)&cmd_pkt_filter_queue_id,
4055 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4056 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4057 pkt_filter, "upd_signature_filter");
4058 cmdline_parse_inst_t cmd_upd_signature_filter = {
4059 .f = cmd_pkt_filter_parsed,
4061 .help_str = "update a signature filter",
4063 (void *)&cmd_pkt_filter_upd_signature_filter,
4064 (void *)&cmd_pkt_filter_port_id,
4065 (void *)&cmd_pkt_filter_protocol,
4066 (void *)&cmd_pkt_filter_src,
4067 (void *)&cmd_pkt_filter_ip_src,
4068 (void *)&cmd_pkt_filter_port_src,
4069 (void *)&cmd_pkt_filter_dst,
4070 (void *)&cmd_pkt_filter_ip_dst,
4071 (void *)&cmd_pkt_filter_port_dst,
4072 (void *)&cmd_pkt_filter_flexbytes,
4073 (void *)&cmd_pkt_filter_flexbytes_value,
4074 (void *)&cmd_pkt_filter_vlan,
4075 (void *)&cmd_pkt_filter_vlan_id,
4076 (void *)&cmd_pkt_filter_queue,
4077 (void *)&cmd_pkt_filter_queue_id,
4083 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4084 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4085 pkt_filter, "rm_signature_filter");
4086 cmdline_parse_inst_t cmd_rm_signature_filter = {
4087 .f = cmd_pkt_filter_parsed,
4089 .help_str = "remove a signature filter",
4091 (void *)&cmd_pkt_filter_rm_signature_filter,
4092 (void *)&cmd_pkt_filter_port_id,
4093 (void *)&cmd_pkt_filter_protocol,
4094 (void *)&cmd_pkt_filter_src,
4095 (void *)&cmd_pkt_filter_ip_src,
4096 (void *)&cmd_pkt_filter_port_src,
4097 (void *)&cmd_pkt_filter_dst,
4098 (void *)&cmd_pkt_filter_ip_dst,
4099 (void *)&cmd_pkt_filter_port_dst,
4100 (void *)&cmd_pkt_filter_flexbytes,
4101 (void *)&cmd_pkt_filter_flexbytes_value,
4102 (void *)&cmd_pkt_filter_vlan,
4103 (void *)&cmd_pkt_filter_vlan_id,
4109 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4110 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4111 pkt_filter, "add_perfect_filter");
4112 cmdline_parse_inst_t cmd_add_perfect_filter = {
4113 .f = cmd_pkt_filter_parsed,
4115 .help_str = "add a perfect filter",
4117 (void *)&cmd_pkt_filter_add_perfect_filter,
4118 (void *)&cmd_pkt_filter_port_id,
4119 (void *)&cmd_pkt_filter_protocol,
4120 (void *)&cmd_pkt_filter_src,
4121 (void *)&cmd_pkt_filter_ip_src,
4122 (void *)&cmd_pkt_filter_port_src,
4123 (void *)&cmd_pkt_filter_dst,
4124 (void *)&cmd_pkt_filter_ip_dst,
4125 (void *)&cmd_pkt_filter_port_dst,
4126 (void *)&cmd_pkt_filter_flexbytes,
4127 (void *)&cmd_pkt_filter_flexbytes_value,
4128 (void *)&cmd_pkt_filter_vlan,
4129 (void *)&cmd_pkt_filter_vlan_id,
4130 (void *)&cmd_pkt_filter_queue,
4131 (void *)&cmd_pkt_filter_queue_id,
4132 (void *)&cmd_pkt_filter_soft,
4133 (void *)&cmd_pkt_filter_soft_id,
4139 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4140 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4141 pkt_filter, "upd_perfect_filter");
4142 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4143 .f = cmd_pkt_filter_parsed,
4145 .help_str = "update a perfect filter",
4147 (void *)&cmd_pkt_filter_upd_perfect_filter,
4148 (void *)&cmd_pkt_filter_port_id,
4149 (void *)&cmd_pkt_filter_protocol,
4150 (void *)&cmd_pkt_filter_src,
4151 (void *)&cmd_pkt_filter_ip_src,
4152 (void *)&cmd_pkt_filter_port_src,
4153 (void *)&cmd_pkt_filter_dst,
4154 (void *)&cmd_pkt_filter_ip_dst,
4155 (void *)&cmd_pkt_filter_port_dst,
4156 (void *)&cmd_pkt_filter_flexbytes,
4157 (void *)&cmd_pkt_filter_flexbytes_value,
4158 (void *)&cmd_pkt_filter_vlan,
4159 (void *)&cmd_pkt_filter_vlan_id,
4160 (void *)&cmd_pkt_filter_queue,
4161 (void *)&cmd_pkt_filter_queue_id,
4162 (void *)&cmd_pkt_filter_soft,
4163 (void *)&cmd_pkt_filter_soft_id,
4169 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4170 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4171 pkt_filter, "rm_perfect_filter");
4172 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4173 .f = cmd_pkt_filter_parsed,
4175 .help_str = "remove a perfect filter",
4177 (void *)&cmd_pkt_filter_rm_perfect_filter,
4178 (void *)&cmd_pkt_filter_port_id,
4179 (void *)&cmd_pkt_filter_protocol,
4180 (void *)&cmd_pkt_filter_src,
4181 (void *)&cmd_pkt_filter_ip_src,
4182 (void *)&cmd_pkt_filter_port_src,
4183 (void *)&cmd_pkt_filter_dst,
4184 (void *)&cmd_pkt_filter_ip_dst,
4185 (void *)&cmd_pkt_filter_port_dst,
4186 (void *)&cmd_pkt_filter_flexbytes,
4187 (void *)&cmd_pkt_filter_flexbytes_value,
4188 (void *)&cmd_pkt_filter_vlan,
4189 (void *)&cmd_pkt_filter_vlan_id,
4190 (void *)&cmd_pkt_filter_soft,
4191 (void *)&cmd_pkt_filter_soft_id,
4196 /* *** SETUP MASKS FILTER *** */
4197 struct cmd_pkt_filter_masks_result {
4198 cmdline_fixed_string_t filter_mask;
4200 cmdline_fixed_string_t src_mask;
4201 uint32_t ip_src_mask;
4202 uint16_t ipv6_src_mask;
4203 uint16_t port_src_mask;
4204 cmdline_fixed_string_t dst_mask;
4205 uint32_t ip_dst_mask;
4206 uint16_t ipv6_dst_mask;
4207 uint16_t port_dst_mask;
4208 cmdline_fixed_string_t flexbytes;
4209 uint8_t flexbytes_value;
4210 cmdline_fixed_string_t vlan_id;
4211 uint8_t vlan_id_value;
4212 cmdline_fixed_string_t vlan_prio;
4213 uint8_t vlan_prio_value;
4214 cmdline_fixed_string_t only_ip_flow;
4215 uint8_t only_ip_flow_value;
4216 cmdline_fixed_string_t comp_ipv6_dst;
4217 uint8_t comp_ipv6_dst_value;
4221 cmd_pkt_filter_masks_parsed(void *parsed_result,
4222 __attribute__((unused)) struct cmdline *cl,
4223 __attribute__((unused)) void *data)
4225 struct rte_fdir_masks fdir_masks;
4226 struct cmd_pkt_filter_masks_result *res = parsed_result;
4228 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4230 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4231 fdir_masks.vlan_id = res->vlan_id_value;
4232 fdir_masks.vlan_prio = res->vlan_prio_value;
4233 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4234 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4235 fdir_masks.src_port_mask = res->port_src_mask;
4236 fdir_masks.dst_port_mask = res->port_dst_mask;
4237 fdir_masks.flexbytes = res->flexbytes_value;
4239 fdir_set_masks(res->port_id, &fdir_masks);
4242 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4243 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4244 filter_mask, "set_masks_filter");
4245 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4246 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4248 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4249 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4250 only_ip_flow, "only_ip_flow");
4251 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4252 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4253 only_ip_flow_value, UINT8);
4254 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4255 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4256 src_mask, "src_mask");
4257 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4258 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4259 ip_src_mask, UINT32);
4260 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4261 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4262 port_src_mask, UINT16);
4263 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4264 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4265 dst_mask, "dst_mask");
4266 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4267 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4268 ip_dst_mask, UINT32);
4269 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4270 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4271 port_dst_mask, UINT16);
4272 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4273 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4274 flexbytes, "flexbytes");
4275 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4276 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4277 flexbytes_value, UINT8);
4278 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4279 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4280 vlan_id, "vlan_id");
4281 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4282 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4283 vlan_id_value, UINT8);
4284 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4285 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4286 vlan_prio, "vlan_prio");
4287 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4288 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4289 vlan_prio_value, UINT8);
4291 cmdline_parse_inst_t cmd_set_masks_filter = {
4292 .f = cmd_pkt_filter_masks_parsed,
4294 .help_str = "setup masks filter",
4296 (void *)&cmd_pkt_filter_masks_filter_mask,
4297 (void *)&cmd_pkt_filter_masks_port_id,
4298 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4299 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4300 (void *)&cmd_pkt_filter_masks_src_mask,
4301 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4302 (void *)&cmd_pkt_filter_masks_port_src_mask,
4303 (void *)&cmd_pkt_filter_masks_dst_mask,
4304 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4305 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4306 (void *)&cmd_pkt_filter_masks_flexbytes,
4307 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4308 (void *)&cmd_pkt_filter_masks_vlan_id,
4309 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4310 (void *)&cmd_pkt_filter_masks_vlan_prio,
4311 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4317 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4318 __attribute__((unused)) struct cmdline *cl,
4319 __attribute__((unused)) void *data)
4321 struct rte_fdir_masks fdir_masks;
4322 struct cmd_pkt_filter_masks_result *res = parsed_result;
4324 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4326 fdir_masks.set_ipv6_mask = 1;
4327 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4328 fdir_masks.vlan_id = res->vlan_id_value;
4329 fdir_masks.vlan_prio = res->vlan_prio_value;
4330 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4331 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4332 fdir_masks.src_port_mask = res->port_src_mask;
4333 fdir_masks.dst_port_mask = res->port_dst_mask;
4334 fdir_masks.flexbytes = res->flexbytes_value;
4335 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4337 fdir_set_masks(res->port_id, &fdir_masks);
4340 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4341 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4342 filter_mask, "set_ipv6_masks_filter");
4343 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4344 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4345 ipv6_src_mask, UINT16);
4346 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4347 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4348 ipv6_dst_mask, UINT16);
4350 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4351 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4352 comp_ipv6_dst, "compare_dst");
4353 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4354 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4355 comp_ipv6_dst_value, UINT8);
4357 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4358 .f = cmd_pkt_filter_masks_ipv6_parsed,
4360 .help_str = "setup ipv6 masks filter",
4362 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4363 (void *)&cmd_pkt_filter_masks_port_id,
4364 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4365 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4366 (void *)&cmd_pkt_filter_masks_src_mask,
4367 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4368 (void *)&cmd_pkt_filter_masks_port_src_mask,
4369 (void *)&cmd_pkt_filter_masks_dst_mask,
4370 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4371 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4372 (void *)&cmd_pkt_filter_masks_flexbytes,
4373 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4374 (void *)&cmd_pkt_filter_masks_vlan_id,
4375 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4376 (void *)&cmd_pkt_filter_masks_vlan_prio,
4377 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4378 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4379 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4384 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4385 struct cmd_link_flow_ctrl_set_result {
4386 cmdline_fixed_string_t set;
4387 cmdline_fixed_string_t flow_ctrl;
4388 cmdline_fixed_string_t rx;
4389 cmdline_fixed_string_t rx_lfc_mode;
4390 cmdline_fixed_string_t tx;
4391 cmdline_fixed_string_t tx_lfc_mode;
4392 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4393 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4394 cmdline_fixed_string_t autoneg_str;
4395 cmdline_fixed_string_t autoneg;
4396 cmdline_fixed_string_t hw_str;
4397 uint32_t high_water;
4398 cmdline_fixed_string_t lw_str;
4400 cmdline_fixed_string_t pt_str;
4401 uint16_t pause_time;
4402 cmdline_fixed_string_t xon_str;
4407 cmdline_parse_token_string_t cmd_lfc_set_set =
4408 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4410 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4411 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4412 flow_ctrl, "flow_ctrl");
4413 cmdline_parse_token_string_t cmd_lfc_set_rx =
4414 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4416 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4417 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4418 rx_lfc_mode, "on#off");
4419 cmdline_parse_token_string_t cmd_lfc_set_tx =
4420 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4422 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4423 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4424 tx_lfc_mode, "on#off");
4425 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4426 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4427 hw_str, "high_water");
4428 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4429 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4430 high_water, UINT32);
4431 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4432 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4433 lw_str, "low_water");
4434 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4435 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4437 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4438 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4439 pt_str, "pause_time");
4440 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4441 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4442 pause_time, UINT16);
4443 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4444 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4445 xon_str, "send_xon");
4446 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4447 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4449 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4450 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4451 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4452 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4453 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4454 mac_ctrl_frame_fwd_mode, "on#off");
4455 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4456 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4457 autoneg_str, "autoneg");
4458 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4459 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4461 cmdline_parse_token_num_t cmd_lfc_set_portid =
4462 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4465 /* forward declaration */
4467 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4470 cmdline_parse_inst_t cmd_link_flow_control_set = {
4471 .f = cmd_link_flow_ctrl_set_parsed,
4473 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4474 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4475 autoneg on|off port_id",
4477 (void *)&cmd_lfc_set_set,
4478 (void *)&cmd_lfc_set_flow_ctrl,
4479 (void *)&cmd_lfc_set_rx,
4480 (void *)&cmd_lfc_set_rx_mode,
4481 (void *)&cmd_lfc_set_tx,
4482 (void *)&cmd_lfc_set_tx_mode,
4483 (void *)&cmd_lfc_set_high_water,
4484 (void *)&cmd_lfc_set_low_water,
4485 (void *)&cmd_lfc_set_pause_time,
4486 (void *)&cmd_lfc_set_send_xon,
4487 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4488 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4489 (void *)&cmd_lfc_set_autoneg_str,
4490 (void *)&cmd_lfc_set_autoneg,
4491 (void *)&cmd_lfc_set_portid,
4496 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4497 .f = cmd_link_flow_ctrl_set_parsed,
4498 .data = (void *)&cmd_link_flow_control_set_rx,
4499 .help_str = "Change rx flow control parameter: set flow_ctrl "
4500 "rx on|off port_id",
4502 (void *)&cmd_lfc_set_set,
4503 (void *)&cmd_lfc_set_flow_ctrl,
4504 (void *)&cmd_lfc_set_rx,
4505 (void *)&cmd_lfc_set_rx_mode,
4506 (void *)&cmd_lfc_set_portid,
4511 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4512 .f = cmd_link_flow_ctrl_set_parsed,
4513 .data = (void *)&cmd_link_flow_control_set_tx,
4514 .help_str = "Change tx flow control parameter: set flow_ctrl "
4515 "tx on|off port_id",
4517 (void *)&cmd_lfc_set_set,
4518 (void *)&cmd_lfc_set_flow_ctrl,
4519 (void *)&cmd_lfc_set_tx,
4520 (void *)&cmd_lfc_set_tx_mode,
4521 (void *)&cmd_lfc_set_portid,
4526 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4527 .f = cmd_link_flow_ctrl_set_parsed,
4528 .data = (void *)&cmd_link_flow_control_set_hw,
4529 .help_str = "Change high water flow control parameter: set flow_ctrl "
4530 "high_water value port_id",
4532 (void *)&cmd_lfc_set_set,
4533 (void *)&cmd_lfc_set_flow_ctrl,
4534 (void *)&cmd_lfc_set_high_water_str,
4535 (void *)&cmd_lfc_set_high_water,
4536 (void *)&cmd_lfc_set_portid,
4541 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4542 .f = cmd_link_flow_ctrl_set_parsed,
4543 .data = (void *)&cmd_link_flow_control_set_lw,
4544 .help_str = "Change low water flow control parameter: set flow_ctrl "
4545 "low_water value port_id",
4547 (void *)&cmd_lfc_set_set,
4548 (void *)&cmd_lfc_set_flow_ctrl,
4549 (void *)&cmd_lfc_set_low_water_str,
4550 (void *)&cmd_lfc_set_low_water,
4551 (void *)&cmd_lfc_set_portid,
4556 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4557 .f = cmd_link_flow_ctrl_set_parsed,
4558 .data = (void *)&cmd_link_flow_control_set_pt,
4559 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4560 "pause_time value port_id",
4562 (void *)&cmd_lfc_set_set,
4563 (void *)&cmd_lfc_set_flow_ctrl,
4564 (void *)&cmd_lfc_set_pause_time_str,
4565 (void *)&cmd_lfc_set_pause_time,
4566 (void *)&cmd_lfc_set_portid,
4571 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4572 .f = cmd_link_flow_ctrl_set_parsed,
4573 .data = (void *)&cmd_link_flow_control_set_xon,
4574 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4575 "send_xon value port_id",
4577 (void *)&cmd_lfc_set_set,
4578 (void *)&cmd_lfc_set_flow_ctrl,
4579 (void *)&cmd_lfc_set_send_xon_str,
4580 (void *)&cmd_lfc_set_send_xon,
4581 (void *)&cmd_lfc_set_portid,
4586 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4587 .f = cmd_link_flow_ctrl_set_parsed,
4588 .data = (void *)&cmd_link_flow_control_set_macfwd,
4589 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4590 "mac_ctrl_frame_fwd on|off port_id",
4592 (void *)&cmd_lfc_set_set,
4593 (void *)&cmd_lfc_set_flow_ctrl,
4594 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4595 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4596 (void *)&cmd_lfc_set_portid,
4601 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4602 .f = cmd_link_flow_ctrl_set_parsed,
4603 .data = (void *)&cmd_link_flow_control_set_autoneg,
4604 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4605 "autoneg on|off port_id",
4607 (void *)&cmd_lfc_set_set,
4608 (void *)&cmd_lfc_set_flow_ctrl,
4609 (void *)&cmd_lfc_set_autoneg_str,
4610 (void *)&cmd_lfc_set_autoneg,
4611 (void *)&cmd_lfc_set_portid,
4617 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4618 __attribute__((unused)) struct cmdline *cl,
4621 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4622 cmdline_parse_inst_t *cmd = data;
4623 struct rte_eth_fc_conf fc_conf;
4624 int rx_fc_en, tx_fc_en;
4628 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4629 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4630 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4631 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4633 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4634 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4637 /* Partial command line, retrieve current configuration */
4639 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4641 printf("cannot get current flow ctrl parameters, return"
4642 "code = %d\n", ret);
4646 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4647 (fc_conf.mode == RTE_FC_FULL))
4649 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4650 (fc_conf.mode == RTE_FC_FULL))
4654 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4655 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4657 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4658 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4660 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4662 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4663 fc_conf.high_water = res->high_water;
4665 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4666 fc_conf.low_water = res->low_water;
4668 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4669 fc_conf.pause_time = res->pause_time;
4671 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4672 fc_conf.send_xon = res->send_xon;
4674 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4675 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4676 fc_conf.mac_ctrl_frame_fwd = 1;
4678 fc_conf.mac_ctrl_frame_fwd = 0;
4681 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4682 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4684 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4686 printf("bad flow contrl parameter, return code = %d \n", ret);
4689 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4690 struct cmd_priority_flow_ctrl_set_result {
4691 cmdline_fixed_string_t set;
4692 cmdline_fixed_string_t pfc_ctrl;
4693 cmdline_fixed_string_t rx;
4694 cmdline_fixed_string_t rx_pfc_mode;
4695 cmdline_fixed_string_t tx;
4696 cmdline_fixed_string_t tx_pfc_mode;
4697 uint32_t high_water;
4699 uint16_t pause_time;
4705 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4706 __attribute__((unused)) struct cmdline *cl,
4707 __attribute__((unused)) void *data)
4709 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4710 struct rte_eth_pfc_conf pfc_conf;
4711 int rx_fc_enable, tx_fc_enable;
4715 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4716 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4717 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4718 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4720 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4721 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4724 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4725 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4726 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4727 pfc_conf.fc.high_water = res->high_water;
4728 pfc_conf.fc.low_water = res->low_water;
4729 pfc_conf.fc.pause_time = res->pause_time;
4730 pfc_conf.priority = res->priority;
4732 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4734 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4737 cmdline_parse_token_string_t cmd_pfc_set_set =
4738 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4740 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4741 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4742 pfc_ctrl, "pfc_ctrl");
4743 cmdline_parse_token_string_t cmd_pfc_set_rx =
4744 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4746 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4747 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4748 rx_pfc_mode, "on#off");
4749 cmdline_parse_token_string_t cmd_pfc_set_tx =
4750 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4752 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4753 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4754 tx_pfc_mode, "on#off");
4755 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4756 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4757 high_water, UINT32);
4758 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4759 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4761 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4762 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4763 pause_time, UINT16);
4764 cmdline_parse_token_num_t cmd_pfc_set_priority =
4765 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4767 cmdline_parse_token_num_t cmd_pfc_set_portid =
4768 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4771 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4772 .f = cmd_priority_flow_ctrl_set_parsed,
4774 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4775 tx on|off high_water low_water pause_time priority port_id",
4777 (void *)&cmd_pfc_set_set,
4778 (void *)&cmd_pfc_set_flow_ctrl,
4779 (void *)&cmd_pfc_set_rx,
4780 (void *)&cmd_pfc_set_rx_mode,
4781 (void *)&cmd_pfc_set_tx,
4782 (void *)&cmd_pfc_set_tx_mode,
4783 (void *)&cmd_pfc_set_high_water,
4784 (void *)&cmd_pfc_set_low_water,
4785 (void *)&cmd_pfc_set_pause_time,
4786 (void *)&cmd_pfc_set_priority,
4787 (void *)&cmd_pfc_set_portid,
4792 /* *** RESET CONFIGURATION *** */
4793 struct cmd_reset_result {
4794 cmdline_fixed_string_t reset;
4795 cmdline_fixed_string_t def;
4798 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4800 __attribute__((unused)) void *data)
4802 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4803 set_def_fwd_config();
4806 cmdline_parse_token_string_t cmd_reset_set =
4807 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4808 cmdline_parse_token_string_t cmd_reset_def =
4809 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4812 cmdline_parse_inst_t cmd_reset = {
4813 .f = cmd_reset_parsed,
4815 .help_str = "set default: reset default forwarding configuration",
4817 (void *)&cmd_reset_set,
4818 (void *)&cmd_reset_def,
4823 /* *** START FORWARDING *** */
4824 struct cmd_start_result {
4825 cmdline_fixed_string_t start;
4828 cmdline_parse_token_string_t cmd_start_start =
4829 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4831 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4832 __attribute__((unused)) struct cmdline *cl,
4833 __attribute__((unused)) void *data)
4835 start_packet_forwarding(0);
4838 cmdline_parse_inst_t cmd_start = {
4839 .f = cmd_start_parsed,
4841 .help_str = "start packet forwarding",
4843 (void *)&cmd_start_start,
4848 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4849 struct cmd_start_tx_first_result {
4850 cmdline_fixed_string_t start;
4851 cmdline_fixed_string_t tx_first;
4855 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4856 __attribute__((unused)) struct cmdline *cl,
4857 __attribute__((unused)) void *data)
4859 start_packet_forwarding(1);
4862 cmdline_parse_token_string_t cmd_start_tx_first_start =
4863 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4865 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4866 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4867 tx_first, "tx_first");
4869 cmdline_parse_inst_t cmd_start_tx_first = {
4870 .f = cmd_start_tx_first_parsed,
4872 .help_str = "start packet forwarding, after sending 1 burst of packets",
4874 (void *)&cmd_start_tx_first_start,
4875 (void *)&cmd_start_tx_first_tx_first,
4880 /* *** SET LINK UP *** */
4881 struct cmd_set_link_up_result {
4882 cmdline_fixed_string_t set;
4883 cmdline_fixed_string_t link_up;
4884 cmdline_fixed_string_t port;
4888 cmdline_parse_token_string_t cmd_set_link_up_set =
4889 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4890 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4891 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4893 cmdline_parse_token_string_t cmd_set_link_up_port =
4894 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4895 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4896 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4898 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4899 __attribute__((unused)) struct cmdline *cl,
4900 __attribute__((unused)) void *data)
4902 struct cmd_set_link_up_result *res = parsed_result;
4903 dev_set_link_up(res->port_id);
4906 cmdline_parse_inst_t cmd_set_link_up = {
4907 .f = cmd_set_link_up_parsed,
4909 .help_str = "set link-up port (port id)",
4911 (void *)&cmd_set_link_up_set,
4912 (void *)&cmd_set_link_up_link_up,
4913 (void *)&cmd_set_link_up_port,
4914 (void *)&cmd_set_link_up_port_id,
4919 /* *** SET LINK DOWN *** */
4920 struct cmd_set_link_down_result {
4921 cmdline_fixed_string_t set;
4922 cmdline_fixed_string_t link_down;
4923 cmdline_fixed_string_t port;
4927 cmdline_parse_token_string_t cmd_set_link_down_set =
4928 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4929 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4930 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4932 cmdline_parse_token_string_t cmd_set_link_down_port =
4933 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4934 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4935 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4937 static void cmd_set_link_down_parsed(
4938 __attribute__((unused)) void *parsed_result,
4939 __attribute__((unused)) struct cmdline *cl,
4940 __attribute__((unused)) void *data)
4942 struct cmd_set_link_down_result *res = parsed_result;
4943 dev_set_link_down(res->port_id);
4946 cmdline_parse_inst_t cmd_set_link_down = {
4947 .f = cmd_set_link_down_parsed,
4949 .help_str = "set link-down port (port id)",
4951 (void *)&cmd_set_link_down_set,
4952 (void *)&cmd_set_link_down_link_down,
4953 (void *)&cmd_set_link_down_port,
4954 (void *)&cmd_set_link_down_port_id,
4959 /* *** SHOW CFG *** */
4960 struct cmd_showcfg_result {
4961 cmdline_fixed_string_t show;
4962 cmdline_fixed_string_t cfg;
4963 cmdline_fixed_string_t what;
4966 static void cmd_showcfg_parsed(void *parsed_result,
4967 __attribute__((unused)) struct cmdline *cl,
4968 __attribute__((unused)) void *data)
4970 struct cmd_showcfg_result *res = parsed_result;
4971 if (!strcmp(res->what, "rxtx"))
4972 rxtx_config_display();
4973 else if (!strcmp(res->what, "cores"))
4974 fwd_lcores_config_display();
4975 else if (!strcmp(res->what, "fwd"))
4976 fwd_config_display();
4979 cmdline_parse_token_string_t cmd_showcfg_show =
4980 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4981 cmdline_parse_token_string_t cmd_showcfg_port =
4982 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4983 cmdline_parse_token_string_t cmd_showcfg_what =
4984 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4987 cmdline_parse_inst_t cmd_showcfg = {
4988 .f = cmd_showcfg_parsed,
4990 .help_str = "show config rxtx|cores|fwd",
4992 (void *)&cmd_showcfg_show,
4993 (void *)&cmd_showcfg_port,
4994 (void *)&cmd_showcfg_what,
4999 /* *** SHOW ALL PORT INFO *** */
5000 struct cmd_showportall_result {
5001 cmdline_fixed_string_t show;
5002 cmdline_fixed_string_t port;
5003 cmdline_fixed_string_t what;
5004 cmdline_fixed_string_t all;
5007 static void cmd_showportall_parsed(void *parsed_result,
5008 __attribute__((unused)) struct cmdline *cl,
5009 __attribute__((unused)) void *data)
5013 struct cmd_showportall_result *res = parsed_result;
5014 if (!strcmp(res->show, "clear")) {
5015 if (!strcmp(res->what, "stats"))
5016 for (i = 0; i < nb_ports; i++)
5018 } else if (!strcmp(res->what, "info"))
5019 for (i = 0; i < nb_ports; i++)
5020 port_infos_display(i);
5021 else if (!strcmp(res->what, "stats"))
5022 for (i = 0; i < nb_ports; i++)
5023 nic_stats_display(i);
5024 else if (!strcmp(res->what, "fdir"))
5025 for (i = 0; i < nb_ports; i++)
5027 else if (!strcmp(res->what, "stat_qmap"))
5028 for (i = 0; i < nb_ports; i++)
5029 nic_stats_mapping_display(i);
5032 cmdline_parse_token_string_t cmd_showportall_show =
5033 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5035 cmdline_parse_token_string_t cmd_showportall_port =
5036 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5037 cmdline_parse_token_string_t cmd_showportall_what =
5038 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5039 "info#stats#fdir#stat_qmap");
5040 cmdline_parse_token_string_t cmd_showportall_all =
5041 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5042 cmdline_parse_inst_t cmd_showportall = {
5043 .f = cmd_showportall_parsed,
5045 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
5047 (void *)&cmd_showportall_show,
5048 (void *)&cmd_showportall_port,
5049 (void *)&cmd_showportall_what,
5050 (void *)&cmd_showportall_all,
5055 /* *** SHOW PORT INFO *** */
5056 struct cmd_showport_result {
5057 cmdline_fixed_string_t show;
5058 cmdline_fixed_string_t port;
5059 cmdline_fixed_string_t what;
5063 static void cmd_showport_parsed(void *parsed_result,
5064 __attribute__((unused)) struct cmdline *cl,
5065 __attribute__((unused)) void *data)
5067 struct cmd_showport_result *res = parsed_result;
5068 if (!strcmp(res->show, "clear")) {
5069 if (!strcmp(res->what, "stats"))
5070 nic_stats_clear(res->portnum);
5071 } else if (!strcmp(res->what, "info"))
5072 port_infos_display(res->portnum);
5073 else if (!strcmp(res->what, "stats"))
5074 nic_stats_display(res->portnum);
5075 else if (!strcmp(res->what, "fdir"))
5076 fdir_get_infos(res->portnum);
5077 else if (!strcmp(res->what, "stat_qmap"))
5078 nic_stats_mapping_display(res->portnum);
5081 cmdline_parse_token_string_t cmd_showport_show =
5082 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5084 cmdline_parse_token_string_t cmd_showport_port =
5085 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5086 cmdline_parse_token_string_t cmd_showport_what =
5087 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5088 "info#stats#fdir#stat_qmap");
5089 cmdline_parse_token_num_t cmd_showport_portnum =
5090 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5092 cmdline_parse_inst_t cmd_showport = {
5093 .f = cmd_showport_parsed,
5095 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
5097 (void *)&cmd_showport_show,
5098 (void *)&cmd_showport_port,
5099 (void *)&cmd_showport_what,
5100 (void *)&cmd_showport_portnum,
5105 /* *** READ PORT REGISTER *** */
5106 struct cmd_read_reg_result {
5107 cmdline_fixed_string_t read;
5108 cmdline_fixed_string_t reg;
5114 cmd_read_reg_parsed(void *parsed_result,
5115 __attribute__((unused)) struct cmdline *cl,
5116 __attribute__((unused)) void *data)
5118 struct cmd_read_reg_result *res = parsed_result;
5119 port_reg_display(res->port_id, res->reg_off);
5122 cmdline_parse_token_string_t cmd_read_reg_read =
5123 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5124 cmdline_parse_token_string_t cmd_read_reg_reg =
5125 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5126 cmdline_parse_token_num_t cmd_read_reg_port_id =
5127 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5128 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5129 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5131 cmdline_parse_inst_t cmd_read_reg = {
5132 .f = cmd_read_reg_parsed,
5134 .help_str = "read reg port_id reg_off",
5136 (void *)&cmd_read_reg_read,
5137 (void *)&cmd_read_reg_reg,
5138 (void *)&cmd_read_reg_port_id,
5139 (void *)&cmd_read_reg_reg_off,
5144 /* *** READ PORT REGISTER BIT FIELD *** */
5145 struct cmd_read_reg_bit_field_result {
5146 cmdline_fixed_string_t read;
5147 cmdline_fixed_string_t regfield;
5155 cmd_read_reg_bit_field_parsed(void *parsed_result,
5156 __attribute__((unused)) struct cmdline *cl,
5157 __attribute__((unused)) void *data)
5159 struct cmd_read_reg_bit_field_result *res = parsed_result;
5160 port_reg_bit_field_display(res->port_id, res->reg_off,
5161 res->bit1_pos, res->bit2_pos);
5164 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5165 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5167 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5168 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5169 regfield, "regfield");
5170 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5171 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5173 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5174 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5176 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5177 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5179 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5180 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5183 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5184 .f = cmd_read_reg_bit_field_parsed,
5186 .help_str = "read regfield port_id reg_off bit_x bit_y "
5187 "(read register bit field between bit_x and bit_y included)",
5189 (void *)&cmd_read_reg_bit_field_read,
5190 (void *)&cmd_read_reg_bit_field_regfield,
5191 (void *)&cmd_read_reg_bit_field_port_id,
5192 (void *)&cmd_read_reg_bit_field_reg_off,
5193 (void *)&cmd_read_reg_bit_field_bit1_pos,
5194 (void *)&cmd_read_reg_bit_field_bit2_pos,
5199 /* *** READ PORT REGISTER BIT *** */
5200 struct cmd_read_reg_bit_result {
5201 cmdline_fixed_string_t read;
5202 cmdline_fixed_string_t regbit;
5209 cmd_read_reg_bit_parsed(void *parsed_result,
5210 __attribute__((unused)) struct cmdline *cl,
5211 __attribute__((unused)) void *data)
5213 struct cmd_read_reg_bit_result *res = parsed_result;
5214 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5217 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5218 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5219 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5220 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5222 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5223 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5224 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5225 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5226 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5227 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5229 cmdline_parse_inst_t cmd_read_reg_bit = {
5230 .f = cmd_read_reg_bit_parsed,
5232 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5234 (void *)&cmd_read_reg_bit_read,
5235 (void *)&cmd_read_reg_bit_regbit,
5236 (void *)&cmd_read_reg_bit_port_id,
5237 (void *)&cmd_read_reg_bit_reg_off,
5238 (void *)&cmd_read_reg_bit_bit_pos,
5243 /* *** WRITE PORT REGISTER *** */
5244 struct cmd_write_reg_result {
5245 cmdline_fixed_string_t write;
5246 cmdline_fixed_string_t reg;
5253 cmd_write_reg_parsed(void *parsed_result,
5254 __attribute__((unused)) struct cmdline *cl,
5255 __attribute__((unused)) void *data)
5257 struct cmd_write_reg_result *res = parsed_result;
5258 port_reg_set(res->port_id, res->reg_off, res->value);
5261 cmdline_parse_token_string_t cmd_write_reg_write =
5262 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5263 cmdline_parse_token_string_t cmd_write_reg_reg =
5264 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5265 cmdline_parse_token_num_t cmd_write_reg_port_id =
5266 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5267 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5268 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5269 cmdline_parse_token_num_t cmd_write_reg_value =
5270 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5272 cmdline_parse_inst_t cmd_write_reg = {
5273 .f = cmd_write_reg_parsed,
5275 .help_str = "write reg port_id reg_off reg_value",
5277 (void *)&cmd_write_reg_write,
5278 (void *)&cmd_write_reg_reg,
5279 (void *)&cmd_write_reg_port_id,
5280 (void *)&cmd_write_reg_reg_off,
5281 (void *)&cmd_write_reg_value,
5286 /* *** WRITE PORT REGISTER BIT FIELD *** */
5287 struct cmd_write_reg_bit_field_result {
5288 cmdline_fixed_string_t write;
5289 cmdline_fixed_string_t regfield;
5298 cmd_write_reg_bit_field_parsed(void *parsed_result,
5299 __attribute__((unused)) struct cmdline *cl,
5300 __attribute__((unused)) void *data)
5302 struct cmd_write_reg_bit_field_result *res = parsed_result;
5303 port_reg_bit_field_set(res->port_id, res->reg_off,
5304 res->bit1_pos, res->bit2_pos, res->value);
5307 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5308 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5310 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5311 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5312 regfield, "regfield");
5313 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5314 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5316 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5317 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5319 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5320 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5322 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5323 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5325 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5326 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5329 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5330 .f = cmd_write_reg_bit_field_parsed,
5332 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5333 "(set register bit field between bit_x and bit_y included)",
5335 (void *)&cmd_write_reg_bit_field_write,
5336 (void *)&cmd_write_reg_bit_field_regfield,
5337 (void *)&cmd_write_reg_bit_field_port_id,
5338 (void *)&cmd_write_reg_bit_field_reg_off,
5339 (void *)&cmd_write_reg_bit_field_bit1_pos,
5340 (void *)&cmd_write_reg_bit_field_bit2_pos,
5341 (void *)&cmd_write_reg_bit_field_value,
5346 /* *** WRITE PORT REGISTER BIT *** */
5347 struct cmd_write_reg_bit_result {
5348 cmdline_fixed_string_t write;
5349 cmdline_fixed_string_t regbit;
5357 cmd_write_reg_bit_parsed(void *parsed_result,
5358 __attribute__((unused)) struct cmdline *cl,
5359 __attribute__((unused)) void *data)
5361 struct cmd_write_reg_bit_result *res = parsed_result;
5362 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5365 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5366 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5368 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5369 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5371 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5372 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5373 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5374 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5375 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5376 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5377 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5378 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5380 cmdline_parse_inst_t cmd_write_reg_bit = {
5381 .f = cmd_write_reg_bit_parsed,
5383 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5385 (void *)&cmd_write_reg_bit_write,
5386 (void *)&cmd_write_reg_bit_regbit,
5387 (void *)&cmd_write_reg_bit_port_id,
5388 (void *)&cmd_write_reg_bit_reg_off,
5389 (void *)&cmd_write_reg_bit_bit_pos,
5390 (void *)&cmd_write_reg_bit_value,
5395 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5396 struct cmd_read_rxd_txd_result {
5397 cmdline_fixed_string_t read;
5398 cmdline_fixed_string_t rxd_txd;
5405 cmd_read_rxd_txd_parsed(void *parsed_result,
5406 __attribute__((unused)) struct cmdline *cl,
5407 __attribute__((unused)) void *data)
5409 struct cmd_read_rxd_txd_result *res = parsed_result;
5411 if (!strcmp(res->rxd_txd, "rxd"))
5412 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5413 else if (!strcmp(res->rxd_txd, "txd"))
5414 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5417 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5418 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5419 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5420 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5422 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5423 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5424 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5425 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5426 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5427 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5429 cmdline_parse_inst_t cmd_read_rxd_txd = {
5430 .f = cmd_read_rxd_txd_parsed,
5432 .help_str = "read rxd|txd port_id queue_id rxd_id",
5434 (void *)&cmd_read_rxd_txd_read,
5435 (void *)&cmd_read_rxd_txd_rxd_txd,
5436 (void *)&cmd_read_rxd_txd_port_id,
5437 (void *)&cmd_read_rxd_txd_queue_id,
5438 (void *)&cmd_read_rxd_txd_desc_id,
5444 struct cmd_quit_result {
5445 cmdline_fixed_string_t quit;
5448 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5450 __attribute__((unused)) void *data)
5456 cmdline_parse_token_string_t cmd_quit_quit =
5457 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5459 cmdline_parse_inst_t cmd_quit = {
5460 .f = cmd_quit_parsed,
5462 .help_str = "exit application",
5464 (void *)&cmd_quit_quit,
5469 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5470 struct cmd_mac_addr_result {
5471 cmdline_fixed_string_t mac_addr_cmd;
5472 cmdline_fixed_string_t what;
5474 struct ether_addr address;
5477 static void cmd_mac_addr_parsed(void *parsed_result,
5478 __attribute__((unused)) struct cmdline *cl,
5479 __attribute__((unused)) void *data)
5481 struct cmd_mac_addr_result *res = parsed_result;
5484 if (strcmp(res->what, "add") == 0)
5485 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5487 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5489 /* check the return value and print it if is < 0 */
5491 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5495 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5496 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5498 cmdline_parse_token_string_t cmd_mac_addr_what =
5499 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5501 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5502 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5503 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5504 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5506 cmdline_parse_inst_t cmd_mac_addr = {
5507 .f = cmd_mac_addr_parsed,
5509 .help_str = "mac_addr add|remove X <address>: "
5510 "add/remove MAC address on port X",
5512 (void *)&cmd_mac_addr_cmd,
5513 (void *)&cmd_mac_addr_what,
5514 (void *)&cmd_mac_addr_portnum,
5515 (void *)&cmd_mac_addr_addr,
5521 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5522 struct cmd_set_qmap_result {
5523 cmdline_fixed_string_t set;
5524 cmdline_fixed_string_t qmap;
5525 cmdline_fixed_string_t what;
5532 cmd_set_qmap_parsed(void *parsed_result,
5533 __attribute__((unused)) struct cmdline *cl,
5534 __attribute__((unused)) void *data)
5536 struct cmd_set_qmap_result *res = parsed_result;
5537 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5539 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5542 cmdline_parse_token_string_t cmd_setqmap_set =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5545 cmdline_parse_token_string_t cmd_setqmap_qmap =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5548 cmdline_parse_token_string_t cmd_setqmap_what =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5551 cmdline_parse_token_num_t cmd_setqmap_portid =
5552 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5554 cmdline_parse_token_num_t cmd_setqmap_queueid =
5555 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5557 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5558 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5561 cmdline_parse_inst_t cmd_set_qmap = {
5562 .f = cmd_set_qmap_parsed,
5564 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5566 (void *)&cmd_setqmap_set,
5567 (void *)&cmd_setqmap_qmap,
5568 (void *)&cmd_setqmap_what,
5569 (void *)&cmd_setqmap_portid,
5570 (void *)&cmd_setqmap_queueid,
5571 (void *)&cmd_setqmap_mapvalue,
5576 /* *** CONFIGURE UNICAST HASH TABLE *** */
5577 struct cmd_set_uc_hash_table {
5578 cmdline_fixed_string_t set;
5579 cmdline_fixed_string_t port;
5581 cmdline_fixed_string_t what;
5582 struct ether_addr address;
5583 cmdline_fixed_string_t mode;
5587 cmd_set_uc_hash_parsed(void *parsed_result,
5588 __attribute__((unused)) struct cmdline *cl,
5589 __attribute__((unused)) void *data)
5592 struct cmd_set_uc_hash_table *res = parsed_result;
5594 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5596 if (strcmp(res->what, "uta") == 0)
5597 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5598 &res->address,(uint8_t)is_on);
5600 printf("bad unicast hash table parameter, return code = %d \n", ret);
5604 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5605 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5607 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5608 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5610 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5611 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5613 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5616 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5617 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5619 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5620 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5623 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5624 .f = cmd_set_uc_hash_parsed,
5626 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5628 (void *)&cmd_set_uc_hash_set,
5629 (void *)&cmd_set_uc_hash_port,
5630 (void *)&cmd_set_uc_hash_portid,
5631 (void *)&cmd_set_uc_hash_what,
5632 (void *)&cmd_set_uc_hash_mac,
5633 (void *)&cmd_set_uc_hash_mode,
5638 struct cmd_set_uc_all_hash_table {
5639 cmdline_fixed_string_t set;
5640 cmdline_fixed_string_t port;
5642 cmdline_fixed_string_t what;
5643 cmdline_fixed_string_t value;
5644 cmdline_fixed_string_t mode;
5648 cmd_set_uc_all_hash_parsed(void *parsed_result,
5649 __attribute__((unused)) struct cmdline *cl,
5650 __attribute__((unused)) void *data)
5653 struct cmd_set_uc_all_hash_table *res = parsed_result;
5655 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5657 if ((strcmp(res->what, "uta") == 0) &&
5658 (strcmp(res->value, "all") == 0))
5659 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5661 printf("bad unicast hash table parameter,"
5662 "return code = %d \n", ret);
5665 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5666 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5668 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5669 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5671 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5672 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5674 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5675 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5677 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5678 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5680 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5681 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5684 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5685 .f = cmd_set_uc_all_hash_parsed,
5687 .help_str = "set port X uta all on|off (X = port number)",
5689 (void *)&cmd_set_uc_all_hash_set,
5690 (void *)&cmd_set_uc_all_hash_port,
5691 (void *)&cmd_set_uc_all_hash_portid,
5692 (void *)&cmd_set_uc_all_hash_what,
5693 (void *)&cmd_set_uc_all_hash_value,
5694 (void *)&cmd_set_uc_all_hash_mode,
5699 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5700 struct cmd_set_vf_traffic {
5701 cmdline_fixed_string_t set;
5702 cmdline_fixed_string_t port;
5704 cmdline_fixed_string_t vf;
5706 cmdline_fixed_string_t what;
5707 cmdline_fixed_string_t mode;
5711 cmd_set_vf_traffic_parsed(void *parsed_result,
5712 __attribute__((unused)) struct cmdline *cl,
5713 __attribute__((unused)) void *data)
5715 struct cmd_set_vf_traffic *res = parsed_result;
5716 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5717 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5719 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5722 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5723 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5725 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5726 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5728 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5729 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5731 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5732 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5734 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5735 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5737 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5738 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5740 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5741 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5744 cmdline_parse_inst_t cmd_set_vf_traffic = {
5745 .f = cmd_set_vf_traffic_parsed,
5747 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
5749 (void *)&cmd_setvf_traffic_set,
5750 (void *)&cmd_setvf_traffic_port,
5751 (void *)&cmd_setvf_traffic_portid,
5752 (void *)&cmd_setvf_traffic_vf,
5753 (void *)&cmd_setvf_traffic_vfid,
5754 (void *)&cmd_setvf_traffic_what,
5755 (void *)&cmd_setvf_traffic_mode,
5760 /* *** CONFIGURE VF RECEIVE MODE *** */
5761 struct cmd_set_vf_rxmode {
5762 cmdline_fixed_string_t set;
5763 cmdline_fixed_string_t port;
5765 cmdline_fixed_string_t vf;
5767 cmdline_fixed_string_t what;
5768 cmdline_fixed_string_t mode;
5769 cmdline_fixed_string_t on;
5773 cmd_set_vf_rxmode_parsed(void *parsed_result,
5774 __attribute__((unused)) struct cmdline *cl,
5775 __attribute__((unused)) void *data)
5778 uint16_t rx_mode = 0;
5779 struct cmd_set_vf_rxmode *res = parsed_result;
5781 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5782 if (!strcmp(res->what,"rxmode")) {
5783 if (!strcmp(res->mode, "AUPE"))
5784 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5785 else if (!strcmp(res->mode, "ROPE"))
5786 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5787 else if (!strcmp(res->mode, "BAM"))
5788 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5789 else if (!strncmp(res->mode, "MPE",3))
5790 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5793 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5795 printf("bad VF receive mode parameter, return code = %d \n",
5799 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5800 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5802 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5803 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5805 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5806 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5808 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5809 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5811 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5812 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5814 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5815 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5817 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5818 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5819 mode, "AUPE#ROPE#BAM#MPE");
5820 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5821 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5824 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5825 .f = cmd_set_vf_rxmode_parsed,
5827 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5829 (void *)&cmd_set_vf_rxmode_set,
5830 (void *)&cmd_set_vf_rxmode_port,
5831 (void *)&cmd_set_vf_rxmode_portid,
5832 (void *)&cmd_set_vf_rxmode_vf,
5833 (void *)&cmd_set_vf_rxmode_vfid,
5834 (void *)&cmd_set_vf_rxmode_what,
5835 (void *)&cmd_set_vf_rxmode_mode,
5836 (void *)&cmd_set_vf_rxmode_on,
5841 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5842 struct cmd_vf_mac_addr_result {
5843 cmdline_fixed_string_t mac_addr_cmd;
5844 cmdline_fixed_string_t what;
5845 cmdline_fixed_string_t port;
5847 cmdline_fixed_string_t vf;
5849 struct ether_addr address;
5852 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5853 __attribute__((unused)) struct cmdline *cl,
5854 __attribute__((unused)) void *data)
5856 struct cmd_vf_mac_addr_result *res = parsed_result;
5859 if (strcmp(res->what, "add") == 0)
5860 ret = rte_eth_dev_mac_addr_add(res->port_num,
5861 &res->address, res->vf_num);
5863 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5867 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5868 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5869 mac_addr_cmd,"mac_addr");
5870 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5871 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5873 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5874 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5876 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5877 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5879 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5880 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5882 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
5883 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5885 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
5886 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
5889 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
5890 .f = cmd_vf_mac_addr_parsed,
5892 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
5893 "Y = VF number)add MAC address filtering for a VF on port X",
5895 (void *)&cmd_vf_mac_addr_cmd,
5896 (void *)&cmd_vf_mac_addr_what,
5897 (void *)&cmd_vf_mac_addr_port,
5898 (void *)&cmd_vf_mac_addr_portnum,
5899 (void *)&cmd_vf_mac_addr_vf,
5900 (void *)&cmd_vf_mac_addr_vfnum,
5901 (void *)&cmd_vf_mac_addr_addr,
5906 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
5907 struct cmd_vf_rx_vlan_filter {
5908 cmdline_fixed_string_t rx_vlan;
5909 cmdline_fixed_string_t what;
5911 cmdline_fixed_string_t port;
5913 cmdline_fixed_string_t vf;
5918 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
5919 __attribute__((unused)) struct cmdline *cl,
5920 __attribute__((unused)) void *data)
5922 struct cmd_vf_rx_vlan_filter *res = parsed_result;
5924 if (!strcmp(res->what, "add"))
5925 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
5927 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
5930 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
5931 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5932 rx_vlan, "rx_vlan");
5933 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
5934 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5936 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
5937 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5939 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
5940 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5942 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
5943 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5945 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
5946 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5948 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
5949 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5952 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
5953 .f = cmd_vf_rx_vlan_filter_parsed,
5955 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
5956 "Y = port number,Z = hexadecimal VF mask)",
5958 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
5959 (void *)&cmd_vf_rx_vlan_filter_what,
5960 (void *)&cmd_vf_rx_vlan_filter_vlanid,
5961 (void *)&cmd_vf_rx_vlan_filter_port,
5962 (void *)&cmd_vf_rx_vlan_filter_portid,
5963 (void *)&cmd_vf_rx_vlan_filter_vf,
5964 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
5969 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
5970 struct cmd_queue_rate_limit_result {
5971 cmdline_fixed_string_t set;
5972 cmdline_fixed_string_t port;
5974 cmdline_fixed_string_t queue;
5976 cmdline_fixed_string_t rate;
5980 static void cmd_queue_rate_limit_parsed(void *parsed_result,
5981 __attribute__((unused)) struct cmdline *cl,
5982 __attribute__((unused)) void *data)
5984 struct cmd_queue_rate_limit_result *res = parsed_result;
5987 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5988 && (strcmp(res->queue, "queue") == 0)
5989 && (strcmp(res->rate, "rate") == 0))
5990 ret = set_queue_rate_limit(res->port_num, res->queue_num,
5993 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
5997 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
5998 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6000 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6001 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6003 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6004 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6006 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6007 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6009 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6010 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6012 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6013 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6015 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6016 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6019 cmdline_parse_inst_t cmd_queue_rate_limit = {
6020 .f = cmd_queue_rate_limit_parsed,
6022 .help_str = "set port X queue Y rate Z:(X = port number,"
6023 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6025 (void *)&cmd_queue_rate_limit_set,
6026 (void *)&cmd_queue_rate_limit_port,
6027 (void *)&cmd_queue_rate_limit_portnum,
6028 (void *)&cmd_queue_rate_limit_queue,
6029 (void *)&cmd_queue_rate_limit_queuenum,
6030 (void *)&cmd_queue_rate_limit_rate,
6031 (void *)&cmd_queue_rate_limit_ratenum,
6036 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6037 struct cmd_vf_rate_limit_result {
6038 cmdline_fixed_string_t set;
6039 cmdline_fixed_string_t port;
6041 cmdline_fixed_string_t vf;
6043 cmdline_fixed_string_t rate;
6045 cmdline_fixed_string_t q_msk;
6049 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6050 __attribute__((unused)) struct cmdline *cl,
6051 __attribute__((unused)) void *data)
6053 struct cmd_vf_rate_limit_result *res = parsed_result;
6056 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6057 && (strcmp(res->vf, "vf") == 0)
6058 && (strcmp(res->rate, "rate") == 0)
6059 && (strcmp(res->q_msk, "queue_mask") == 0))
6060 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6061 res->rate_num, res->q_msk_val);
6063 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6067 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6068 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6070 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6071 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6073 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6074 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6076 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6077 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6079 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6080 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6082 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6083 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6085 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6086 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6088 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6089 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6090 q_msk, "queue_mask");
6091 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6092 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6095 cmdline_parse_inst_t cmd_vf_rate_limit = {
6096 .f = cmd_vf_rate_limit_parsed,
6098 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6099 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6100 "for queues of VF on port X",
6102 (void *)&cmd_vf_rate_limit_set,
6103 (void *)&cmd_vf_rate_limit_port,
6104 (void *)&cmd_vf_rate_limit_portnum,
6105 (void *)&cmd_vf_rate_limit_vf,
6106 (void *)&cmd_vf_rate_limit_vfnum,
6107 (void *)&cmd_vf_rate_limit_rate,
6108 (void *)&cmd_vf_rate_limit_ratenum,
6109 (void *)&cmd_vf_rate_limit_q_msk,
6110 (void *)&cmd_vf_rate_limit_q_msk_val,
6115 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6116 struct cmd_set_mirror_mask_result {
6117 cmdline_fixed_string_t set;
6118 cmdline_fixed_string_t port;
6120 cmdline_fixed_string_t mirror;
6122 cmdline_fixed_string_t what;
6123 cmdline_fixed_string_t value;
6124 cmdline_fixed_string_t dstpool;
6126 cmdline_fixed_string_t on;
6129 cmdline_parse_token_string_t cmd_mirror_mask_set =
6130 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6132 cmdline_parse_token_string_t cmd_mirror_mask_port =
6133 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6135 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6136 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6138 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6139 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6140 mirror, "mirror-rule");
6141 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6142 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6144 cmdline_parse_token_string_t cmd_mirror_mask_what =
6145 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6146 what, "pool-mirror#vlan-mirror");
6147 cmdline_parse_token_string_t cmd_mirror_mask_value =
6148 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6150 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6151 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6152 dstpool, "dst-pool");
6153 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6154 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6156 cmdline_parse_token_string_t cmd_mirror_mask_on =
6157 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6161 cmd_set_mirror_mask_parsed(void *parsed_result,
6162 __attribute__((unused)) struct cmdline *cl,
6163 __attribute__((unused)) void *data)
6166 struct cmd_set_mirror_mask_result *res = parsed_result;
6167 struct rte_eth_vmdq_mirror_conf mr_conf;
6169 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6171 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6173 mr_conf.dst_pool = res->dstpool_id;
6175 if (!strcmp(res->what, "pool-mirror")) {
6176 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6177 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6178 } else if(!strcmp(res->what, "vlan-mirror")) {
6179 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6180 nb_item = parse_item_list(res->value, "core",
6181 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6185 for(i=0; i < nb_item; i++) {
6186 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6187 printf("Invalid vlan_id: must be < 4096\n");
6191 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6192 mr_conf.vlan.vlan_mask |= 1ULL << i;
6196 if(!strcmp(res->on, "on"))
6197 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6200 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6203 printf("mirror rule add error: (%s)\n", strerror(-ret));
6206 cmdline_parse_inst_t cmd_set_mirror_mask = {
6207 .f = cmd_set_mirror_mask_parsed,
6209 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6210 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6212 (void *)&cmd_mirror_mask_set,
6213 (void *)&cmd_mirror_mask_port,
6214 (void *)&cmd_mirror_mask_portid,
6215 (void *)&cmd_mirror_mask_mirror,
6216 (void *)&cmd_mirror_mask_ruleid,
6217 (void *)&cmd_mirror_mask_what,
6218 (void *)&cmd_mirror_mask_value,
6219 (void *)&cmd_mirror_mask_dstpool,
6220 (void *)&cmd_mirror_mask_poolid,
6221 (void *)&cmd_mirror_mask_on,
6226 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6227 struct cmd_set_mirror_link_result {
6228 cmdline_fixed_string_t set;
6229 cmdline_fixed_string_t port;
6231 cmdline_fixed_string_t mirror;
6233 cmdline_fixed_string_t what;
6234 cmdline_fixed_string_t dstpool;
6236 cmdline_fixed_string_t on;
6239 cmdline_parse_token_string_t cmd_mirror_link_set =
6240 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6242 cmdline_parse_token_string_t cmd_mirror_link_port =
6243 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6245 cmdline_parse_token_num_t cmd_mirror_link_portid =
6246 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6248 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6249 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6250 mirror, "mirror-rule");
6251 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6252 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6254 cmdline_parse_token_string_t cmd_mirror_link_what =
6255 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6256 what, "uplink-mirror#downlink-mirror");
6257 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6258 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6259 dstpool, "dst-pool");
6260 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6261 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6263 cmdline_parse_token_string_t cmd_mirror_link_on =
6264 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6268 cmd_set_mirror_link_parsed(void *parsed_result,
6269 __attribute__((unused)) struct cmdline *cl,
6270 __attribute__((unused)) void *data)
6273 struct cmd_set_mirror_link_result *res = parsed_result;
6274 struct rte_eth_vmdq_mirror_conf mr_conf;
6276 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6277 if(!strcmp(res->what, "uplink-mirror")) {
6278 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6279 }else if(!strcmp(res->what, "downlink-mirror"))
6280 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6282 mr_conf.dst_pool = res->dstpool_id;
6284 if(!strcmp(res->on, "on"))
6285 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6288 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6291 /* check the return value and print it if is < 0 */
6293 printf("mirror rule add error: (%s)\n", strerror(-ret));
6297 cmdline_parse_inst_t cmd_set_mirror_link = {
6298 .f = cmd_set_mirror_link_parsed,
6300 .help_str = "set port X mirror-rule Y uplink-mirror|"
6301 "downlink-mirror dst-pool Z on|off",
6303 (void *)&cmd_mirror_link_set,
6304 (void *)&cmd_mirror_link_port,
6305 (void *)&cmd_mirror_link_portid,
6306 (void *)&cmd_mirror_link_mirror,
6307 (void *)&cmd_mirror_link_ruleid,
6308 (void *)&cmd_mirror_link_what,
6309 (void *)&cmd_mirror_link_dstpool,
6310 (void *)&cmd_mirror_link_poolid,
6311 (void *)&cmd_mirror_link_on,
6316 /* *** RESET VM MIRROR RULE *** */
6317 struct cmd_rm_mirror_rule_result {
6318 cmdline_fixed_string_t reset;
6319 cmdline_fixed_string_t port;
6321 cmdline_fixed_string_t mirror;
6325 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6326 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6328 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6329 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6331 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6332 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6334 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6335 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6336 mirror, "mirror-rule");
6337 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6338 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6342 cmd_reset_mirror_rule_parsed(void *parsed_result,
6343 __attribute__((unused)) struct cmdline *cl,
6344 __attribute__((unused)) void *data)
6347 struct cmd_set_mirror_link_result *res = parsed_result;
6349 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6351 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6354 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6355 .f = cmd_reset_mirror_rule_parsed,
6357 .help_str = "reset port X mirror-rule Y",
6359 (void *)&cmd_rm_mirror_rule_reset,
6360 (void *)&cmd_rm_mirror_rule_port,
6361 (void *)&cmd_rm_mirror_rule_portid,
6362 (void *)&cmd_rm_mirror_rule_mirror,
6363 (void *)&cmd_rm_mirror_rule_ruleid,
6368 /* ******************************************************************************** */
6370 struct cmd_dump_result {
6371 cmdline_fixed_string_t dump;
6375 dump_struct_sizes(void)
6377 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6378 DUMP_SIZE(struct rte_mbuf);
6379 DUMP_SIZE(struct rte_pktmbuf);
6380 DUMP_SIZE(struct rte_ctrlmbuf);
6381 DUMP_SIZE(struct rte_mempool);
6382 DUMP_SIZE(struct rte_ring);
6386 static void cmd_dump_parsed(void *parsed_result,
6387 __attribute__((unused)) struct cmdline *cl,
6388 __attribute__((unused)) void *data)
6390 struct cmd_dump_result *res = parsed_result;
6392 if (!strcmp(res->dump, "dump_physmem"))
6393 rte_dump_physmem_layout(stdout);
6394 else if (!strcmp(res->dump, "dump_memzone"))
6395 rte_memzone_dump(stdout);
6396 else if (!strcmp(res->dump, "dump_log_history"))
6397 rte_log_dump_history(stdout);
6398 else if (!strcmp(res->dump, "dump_struct_sizes"))
6399 dump_struct_sizes();
6400 else if (!strcmp(res->dump, "dump_ring"))
6401 rte_ring_list_dump(stdout);
6402 else if (!strcmp(res->dump, "dump_mempool"))
6403 rte_mempool_list_dump(stdout);
6404 else if (!strcmp(res->dump, "dump_devargs"))
6405 rte_eal_devargs_dump(stdout);
6408 cmdline_parse_token_string_t cmd_dump_dump =
6409 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6413 "dump_struct_sizes#"
6418 cmdline_parse_inst_t cmd_dump = {
6419 .f = cmd_dump_parsed, /* function to call */
6420 .data = NULL, /* 2nd arg of func */
6421 .help_str = "dump status",
6422 .tokens = { /* token list, NULL terminated */
6423 (void *)&cmd_dump_dump,
6428 /* ******************************************************************************** */
6430 struct cmd_dump_one_result {
6431 cmdline_fixed_string_t dump;
6432 cmdline_fixed_string_t name;
6435 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6436 __attribute__((unused)) void *data)
6438 struct cmd_dump_one_result *res = parsed_result;
6440 if (!strcmp(res->dump, "dump_ring")) {
6442 r = rte_ring_lookup(res->name);
6444 cmdline_printf(cl, "Cannot find ring\n");
6447 rte_ring_dump(stdout, r);
6448 } else if (!strcmp(res->dump, "dump_mempool")) {
6449 struct rte_mempool *mp;
6450 mp = rte_mempool_lookup(res->name);
6452 cmdline_printf(cl, "Cannot find mempool\n");
6455 rte_mempool_dump(stdout, mp);
6459 cmdline_parse_token_string_t cmd_dump_one_dump =
6460 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6461 "dump_ring#dump_mempool");
6463 cmdline_parse_token_string_t cmd_dump_one_name =
6464 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6466 cmdline_parse_inst_t cmd_dump_one = {
6467 .f = cmd_dump_one_parsed, /* function to call */
6468 .data = NULL, /* 2nd arg of func */
6469 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6470 .tokens = { /* token list, NULL terminated */
6471 (void *)&cmd_dump_one_dump,
6472 (void *)&cmd_dump_one_name,
6477 /* *** ADD/REMOVE an ethertype FILTER *** */
6478 struct cmd_ethertype_filter_result {
6479 cmdline_fixed_string_t filter;
6481 cmdline_fixed_string_t ethertype;
6482 uint16_t ethertype_value;
6483 cmdline_fixed_string_t priority;
6484 cmdline_fixed_string_t priority_en;
6485 uint8_t priority_value;
6486 cmdline_fixed_string_t queue;
6488 cmdline_fixed_string_t index;
6489 uint16_t index_value;
6493 cmd_ethertype_filter_parsed(void *parsed_result,
6494 __attribute__((unused)) struct cmdline *cl,
6495 __attribute__((unused)) void *data)
6498 struct cmd_ethertype_filter_result *res = parsed_result;
6499 struct rte_ethertype_filter filter;
6501 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
6502 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
6503 filter.priority = res->priority_value;
6505 if (!strcmp(res->priority_en, "enable"))
6506 filter.priority_en = 1;
6507 if (!strcmp(res->filter, "add_ethertype_filter"))
6508 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
6510 &filter, res->queue_id);
6511 else if (!strcmp(res->filter, "remove_ethertype_filter"))
6512 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
6514 else if (!strcmp(res->filter, "get_ethertype_filter"))
6515 get_ethertype_filter(res->port_id, res->index_value);
6518 printf("ethertype filter setting error: (%s)\n",
6522 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
6523 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6525 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
6526 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6527 ethertype, "ethertype");
6528 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
6529 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6530 ethertype_value, UINT16);
6531 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
6532 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6533 priority, "priority");
6534 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
6535 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6536 priority_en, "enable#disable");
6537 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
6538 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6539 priority_value, UINT8);
6540 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
6541 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6543 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
6544 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6546 cmdline_parse_token_string_t cmd_ethertype_filter_index =
6547 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6549 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
6550 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6551 index_value, UINT16);
6552 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
6553 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6554 filter, "add_ethertype_filter");
6555 cmdline_parse_inst_t cmd_add_ethertype_filter = {
6556 .f = cmd_ethertype_filter_parsed,
6558 .help_str = "add an ethertype filter",
6560 (void *)&cmd_ethertype_filter_add_filter,
6561 (void *)&cmd_ethertype_filter_port_id,
6562 (void *)&cmd_ethertype_filter_ethertype,
6563 (void *)&cmd_ethertype_filter_ethertype_value,
6564 (void *)&cmd_ethertype_filter_priority,
6565 (void *)&cmd_ethertype_filter_priority_en,
6566 (void *)&cmd_ethertype_filter_priority_value,
6567 (void *)&cmd_ethertype_filter_queue,
6568 (void *)&cmd_ethertype_filter_queue_id,
6569 (void *)&cmd_ethertype_filter_index,
6570 (void *)&cmd_ethertype_filter_index_value,
6575 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
6576 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6577 filter, "remove_ethertype_filter");
6578 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
6579 .f = cmd_ethertype_filter_parsed,
6581 .help_str = "remove an ethertype filter",
6583 (void *)&cmd_ethertype_filter_remove_filter,
6584 (void *)&cmd_ethertype_filter_port_id,
6585 (void *)&cmd_ethertype_filter_index,
6586 (void *)&cmd_ethertype_filter_index_value,
6590 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
6591 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6592 filter, "get_ethertype_filter");
6593 cmdline_parse_inst_t cmd_get_ethertype_filter = {
6594 .f = cmd_ethertype_filter_parsed,
6596 .help_str = "get an ethertype filter",
6598 (void *)&cmd_ethertype_filter_get_filter,
6599 (void *)&cmd_ethertype_filter_port_id,
6600 (void *)&cmd_ethertype_filter_index,
6601 (void *)&cmd_ethertype_filter_index_value,
6606 /* *** set SYN filter *** */
6607 struct cmd_set_syn_filter_result {
6608 cmdline_fixed_string_t filter;
6610 cmdline_fixed_string_t priority;
6611 cmdline_fixed_string_t high;
6612 cmdline_fixed_string_t queue;
6617 cmd_set_syn_filter_parsed(void *parsed_result,
6618 __attribute__((unused)) struct cmdline *cl,
6619 __attribute__((unused)) void *data)
6622 struct cmd_set_syn_filter_result *res = parsed_result;
6623 struct rte_syn_filter filter;
6625 if (!strcmp(res->filter, "add_syn_filter")) {
6626 if (!strcmp(res->high, "high"))
6630 ret = rte_eth_dev_add_syn_filter(res->port_id,
6631 &filter, res->queue_id);
6632 } else if (!strcmp(res->filter, "remove_syn_filter"))
6633 ret = rte_eth_dev_remove_syn_filter(res->port_id);
6634 else if (!strcmp(res->filter, "get_syn_filter"))
6635 get_syn_filter(res->port_id);
6637 printf("syn filter setting error: (%s)\n", strerror(-ret));
6640 cmdline_parse_token_num_t cmd_syn_filter_portid =
6641 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6643 cmdline_parse_token_string_t cmd_syn_filter_priority =
6644 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6645 priority, "priority");
6646 cmdline_parse_token_string_t cmd_syn_filter_high =
6647 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6649 cmdline_parse_token_string_t cmd_syn_filter_queue =
6650 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6652 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6653 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6655 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
6656 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6657 filter, "add_syn_filter");
6658 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
6659 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6660 filter, "remove_syn_filter");
6661 cmdline_parse_inst_t cmd_add_syn_filter = {
6662 .f = cmd_set_syn_filter_parsed,
6664 .help_str = "add syn filter",
6666 (void *)&cmd_syn_filter_add_filter,
6667 (void *)&cmd_syn_filter_portid,
6668 (void *)&cmd_syn_filter_priority,
6669 (void *)&cmd_syn_filter_high,
6670 (void *)&cmd_syn_filter_queue,
6671 (void *)&cmd_syn_filter_queue_id,
6675 cmdline_parse_inst_t cmd_remove_syn_filter = {
6676 .f = cmd_set_syn_filter_parsed,
6678 .help_str = "remove syn filter",
6680 (void *)&cmd_syn_filter_remove_filter,
6681 (void *)&cmd_syn_filter_portid,
6686 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
6687 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6688 filter, "get_syn_filter");
6690 cmdline_parse_inst_t cmd_get_syn_filter = {
6691 .f = cmd_set_syn_filter_parsed,
6693 .help_str = "get syn filter",
6695 (void *)&cmd_syn_filter_get_filter,
6696 (void *)&cmd_syn_filter_portid,
6701 /* *** ADD/REMOVE A 2tuple FILTER *** */
6702 struct cmd_2tuple_filter_result {
6703 cmdline_fixed_string_t filter;
6705 cmdline_fixed_string_t protocol;
6706 uint8_t protocol_value;
6707 uint8_t protocol_mask;
6708 cmdline_fixed_string_t dst_port;
6709 uint16_t dst_port_value;
6710 uint16_t dst_port_mask;
6711 cmdline_fixed_string_t flags;
6712 uint8_t flags_value;
6713 cmdline_fixed_string_t priority;
6714 uint8_t priority_value;
6715 cmdline_fixed_string_t queue;
6717 cmdline_fixed_string_t index;
6718 uint16_t index_value;
6722 cmd_2tuple_filter_parsed(void *parsed_result,
6723 __attribute__((unused)) struct cmdline *cl,
6724 __attribute__((unused)) void *data)
6727 struct rte_2tuple_filter filter;
6728 struct cmd_2tuple_filter_result *res = parsed_result;
6730 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
6732 if (!strcmp(res->filter, "add_2tuple_filter")) {
6733 /* need convert to big endian. */
6734 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6735 filter.protocol = res->protocol_value;
6736 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
6737 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
6738 filter.priority = res->priority_value;
6739 filter.tcp_flags = res->flags_value;
6740 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
6741 res->index_value, &filter, res->queue_id);
6742 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
6743 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
6745 else if (!strcmp(res->filter, "get_2tuple_filter"))
6746 get_2tuple_filter(res->port_id, res->index_value);
6749 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
6752 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6753 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6755 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6756 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6757 protocol, "protocol");
6758 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6759 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6760 protocol_value, UINT8);
6761 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
6762 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6763 protocol_mask, UINT8);
6764 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6765 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6766 dst_port, "dst_port");
6767 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6768 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6769 dst_port_value, UINT16);
6770 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
6771 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6772 dst_port_mask, UINT16);
6773 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
6774 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6776 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
6777 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6778 flags_value, UINT8);
6779 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6780 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6781 priority, "priority");
6782 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6783 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6784 priority_value, UINT8);
6785 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6786 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6788 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6789 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6791 cmdline_parse_token_string_t cmd_2tuple_filter_index =
6792 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6794 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
6795 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6796 index_value, UINT16);
6797 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
6798 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6799 filter, "add_2tuple_filter");
6800 cmdline_parse_inst_t cmd_add_2tuple_filter = {
6801 .f = cmd_2tuple_filter_parsed,
6803 .help_str = "add a 2tuple filter",
6805 (void *)&cmd_2tuple_filter_add_filter,
6806 (void *)&cmd_2tuple_filter_port_id,
6807 (void *)&cmd_2tuple_filter_protocol,
6808 (void *)&cmd_2tuple_filter_protocol_value,
6809 (void *)&cmd_2tuple_filter_protocol_mask,
6810 (void *)&cmd_2tuple_filter_dst_port,
6811 (void *)&cmd_2tuple_filter_dst_port_value,
6812 (void *)&cmd_2tuple_filter_dst_port_mask,
6813 (void *)&cmd_2tuple_filter_flags,
6814 (void *)&cmd_2tuple_filter_flags_value,
6815 (void *)&cmd_2tuple_filter_priority,
6816 (void *)&cmd_2tuple_filter_priority_value,
6817 (void *)&cmd_2tuple_filter_queue,
6818 (void *)&cmd_2tuple_filter_queue_id,
6819 (void *)&cmd_2tuple_filter_index,
6820 (void *)&cmd_2tuple_filter_index_value,
6825 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
6826 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6827 filter, "remove_2tuple_filter");
6828 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
6829 .f = cmd_2tuple_filter_parsed,
6831 .help_str = "remove a 2tuple filter",
6833 (void *)&cmd_2tuple_filter_remove_filter,
6834 (void *)&cmd_2tuple_filter_port_id,
6835 (void *)&cmd_2tuple_filter_index,
6836 (void *)&cmd_2tuple_filter_index_value,
6840 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
6841 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6842 filter, "get_2tuple_filter");
6843 cmdline_parse_inst_t cmd_get_2tuple_filter = {
6844 .f = cmd_2tuple_filter_parsed,
6846 .help_str = "get a 2tuple filter",
6848 (void *)&cmd_2tuple_filter_get_filter,
6849 (void *)&cmd_2tuple_filter_port_id,
6850 (void *)&cmd_2tuple_filter_index,
6851 (void *)&cmd_2tuple_filter_index_value,
6856 /* *** ADD/REMOVE A 5tuple FILTER *** */
6857 struct cmd_5tuple_filter_result {
6858 cmdline_fixed_string_t filter;
6860 cmdline_fixed_string_t dst_ip;
6861 cmdline_ipaddr_t dst_ip_value;
6862 cmdline_fixed_string_t src_ip;
6863 cmdline_ipaddr_t src_ip_value;
6864 cmdline_fixed_string_t dst_port;
6865 uint16_t dst_port_value;
6866 cmdline_fixed_string_t src_port;
6867 uint16_t src_port_value;
6868 cmdline_fixed_string_t protocol;
6869 uint8_t protocol_value;
6870 cmdline_fixed_string_t mask;
6872 cmdline_fixed_string_t flags;
6873 uint8_t flags_value;
6874 cmdline_fixed_string_t priority;
6875 uint8_t priority_value;
6876 cmdline_fixed_string_t queue;
6878 cmdline_fixed_string_t index;
6879 uint16_t index_value;
6883 cmd_5tuple_filter_parsed(void *parsed_result,
6884 __attribute__((unused)) struct cmdline *cl,
6885 __attribute__((unused)) void *data)
6888 struct rte_5tuple_filter filter;
6889 struct cmd_5tuple_filter_result *res = parsed_result;
6891 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
6893 if (!strcmp(res->filter, "add_5tuple_filter")) {
6894 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
6895 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
6896 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
6897 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
6898 filter.protocol = res->protocol_value;
6899 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
6900 filter.priority = res->priority_value;
6901 filter.tcp_flags = res->flags_value;
6903 if (res->dst_ip_value.family == AF_INET)
6904 /* no need to convert, already big endian. */
6905 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
6907 if (filter.dst_ip_mask == 0) {
6908 printf("can not support ipv6 involved compare.\n");
6914 if (res->src_ip_value.family == AF_INET)
6915 /* no need to convert, already big endian. */
6916 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
6918 if (filter.src_ip_mask == 0) {
6919 printf("can not support ipv6 involved compare.\n");
6924 /* need convert to big endian. */
6925 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6926 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
6928 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
6929 res->index_value, &filter, res->queue_id);
6930 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
6931 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
6933 else if (!strcmp(res->filter, "get_5tuple_filter"))
6934 get_5tuple_filter(res->port_id, res->index_value);
6936 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
6940 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
6941 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6943 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
6944 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6946 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
6947 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6949 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
6950 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6952 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
6953 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6955 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
6956 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6957 dst_port, "dst_port");
6958 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
6959 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6960 dst_port_value, UINT16);
6961 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
6962 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6963 src_port, "src_port");
6964 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
6965 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6966 src_port_value, UINT16);
6967 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
6968 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6969 protocol, "protocol");
6970 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
6971 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6972 protocol_value, UINT8);
6973 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
6974 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6976 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
6977 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6979 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
6980 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6982 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
6983 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6984 flags_value, UINT8);
6985 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
6986 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6987 priority, "priority");
6988 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
6989 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6990 priority_value, UINT8);
6991 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
6992 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6994 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
6995 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6997 cmdline_parse_token_string_t cmd_5tuple_filter_index =
6998 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7000 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7001 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7002 index_value, UINT16);
7004 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7005 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7006 filter, "add_5tuple_filter");
7007 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7008 .f = cmd_5tuple_filter_parsed,
7010 .help_str = "add a 5tuple filter",
7012 (void *)&cmd_5tuple_filter_add_filter,
7013 (void *)&cmd_5tuple_filter_port_id,
7014 (void *)&cmd_5tuple_filter_dst_ip,
7015 (void *)&cmd_5tuple_filter_dst_ip_value,
7016 (void *)&cmd_5tuple_filter_src_ip,
7017 (void *)&cmd_5tuple_filter_src_ip_value,
7018 (void *)&cmd_5tuple_filter_dst_port,
7019 (void *)&cmd_5tuple_filter_dst_port_value,
7020 (void *)&cmd_5tuple_filter_src_port,
7021 (void *)&cmd_5tuple_filter_src_port_value,
7022 (void *)&cmd_5tuple_filter_protocol,
7023 (void *)&cmd_5tuple_filter_protocol_value,
7024 (void *)&cmd_5tuple_filter_mask,
7025 (void *)&cmd_5tuple_filter_mask_value,
7026 (void *)&cmd_5tuple_filter_flags,
7027 (void *)&cmd_5tuple_filter_flags_value,
7028 (void *)&cmd_5tuple_filter_priority,
7029 (void *)&cmd_5tuple_filter_priority_value,
7030 (void *)&cmd_5tuple_filter_queue,
7031 (void *)&cmd_5tuple_filter_queue_id,
7032 (void *)&cmd_5tuple_filter_index,
7033 (void *)&cmd_5tuple_filter_index_value,
7038 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7039 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7040 filter, "remove_5tuple_filter");
7041 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7042 .f = cmd_5tuple_filter_parsed,
7044 .help_str = "remove a 5tuple filter",
7046 (void *)&cmd_5tuple_filter_remove_filter,
7047 (void *)&cmd_5tuple_filter_port_id,
7048 (void *)&cmd_5tuple_filter_index,
7049 (void *)&cmd_5tuple_filter_index_value,
7054 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7055 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7056 filter, "get_5tuple_filter");
7057 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7058 .f = cmd_5tuple_filter_parsed,
7060 .help_str = "get a 5tuple filter",
7062 (void *)&cmd_5tuple_filter_get_filter,
7063 (void *)&cmd_5tuple_filter_port_id,
7064 (void *)&cmd_5tuple_filter_index,
7065 (void *)&cmd_5tuple_filter_index_value,
7070 /* *** ADD/REMOVE A flex FILTER *** */
7071 struct cmd_flex_filter_result {
7072 cmdline_fixed_string_t filter;
7074 cmdline_fixed_string_t len;
7076 cmdline_fixed_string_t bytes;
7077 cmdline_fixed_string_t bytes_value;
7078 cmdline_fixed_string_t mask;
7079 cmdline_fixed_string_t mask_value;
7080 cmdline_fixed_string_t priority;
7081 uint8_t priority_value;
7082 cmdline_fixed_string_t queue;
7084 cmdline_fixed_string_t index;
7085 uint16_t index_value;
7088 static int xdigit2val(unsigned char c)
7093 else if (isupper(c))
7101 cmd_flex_filter_parsed(void *parsed_result,
7102 __attribute__((unused)) struct cmdline *cl,
7103 __attribute__((unused)) void *data)
7106 struct rte_flex_filter filter;
7107 struct cmd_flex_filter_result *res = parsed_result;
7108 char *bytes_ptr, *mask_ptr;
7116 if (!strcmp(res->filter, "add_flex_filter")) {
7117 if (res->len_value > 128) {
7118 printf("the len exceed the max length 128\n");
7121 memset(&filter, 0, sizeof(struct rte_flex_filter));
7122 filter.len = res->len_value;
7123 filter.priority = res->priority_value;
7124 bytes_ptr = res->bytes_value;
7125 mask_ptr = res->mask_value;
7128 /* translate bytes string to uint_32 array. */
7129 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7130 (bytes_ptr[1] == 'X')))
7132 len = strnlen(bytes_ptr, res->len_value * 2);
7133 if (len == 0 || (len % 8 != 0)) {
7134 printf("please check len and bytes input\n");
7137 for (i = 0; i < len; i++) {
7139 if (isxdigit(c) == 0) {
7140 /* invalid characters. */
7141 printf("invalid input\n");
7144 val = xdigit2val(c);
7148 dword |= byte << (4 * mod - 4);
7153 filter.dwords[j] = dword;
7154 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7160 /* translate mask string to uint8_t array. */
7162 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7163 (mask_ptr[1] == 'X')))
7165 len = strnlen(mask_ptr, (res->len_value+3)/4);
7167 printf("invalid input\n");
7170 for (i = 0; i < len; i++) {
7172 if (isxdigit(c) == 0) {
7173 /* invalid characters. */
7174 printf("invalid input\n");
7177 val = xdigit2val(c);
7178 hex |= (uint8_t)(val & 0x8) >> 3;
7179 hex |= (uint8_t)(val & 0x4) >> 1;
7180 hex |= (uint8_t)(val & 0x2) << 1;
7181 hex |= (uint8_t)(val & 0x1) << 3;
7184 filter.mask[j] = byte;
7185 printf("mask[%d]:%02x ", j, filter.mask[j]);
7193 printf("call function rte_eth_dev_add_flex_filter: "
7194 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7195 res->index_value, res->queue_id,
7196 filter.len, filter.priority);
7197 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7198 &filter, res->queue_id);
7200 } else if (!strcmp(res->filter, "remove_flex_filter"))
7201 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7203 else if (!strcmp(res->filter, "get_flex_filter"))
7204 get_flex_filter(res->port_id, res->index_value);
7207 printf("flex filter setting error: (%s)\n", strerror(-ret));
7210 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7211 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7213 cmdline_parse_token_string_t cmd_flex_filter_len =
7214 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7216 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7217 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7219 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7220 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7222 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7223 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7225 cmdline_parse_token_string_t cmd_flex_filter_mask =
7226 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7228 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7229 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7231 cmdline_parse_token_string_t cmd_flex_filter_priority =
7232 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7233 priority, "priority");
7234 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7235 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7236 priority_value, UINT8);
7237 cmdline_parse_token_string_t cmd_flex_filter_queue =
7238 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7240 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7241 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7243 cmdline_parse_token_string_t cmd_flex_filter_index =
7244 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7246 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7247 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7248 index_value, UINT16);
7249 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7250 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7251 filter, "add_flex_filter");
7252 cmdline_parse_inst_t cmd_add_flex_filter = {
7253 .f = cmd_flex_filter_parsed,
7255 .help_str = "add a flex filter",
7257 (void *)&cmd_flex_filter_add_filter,
7258 (void *)&cmd_flex_filter_port_id,
7259 (void *)&cmd_flex_filter_len,
7260 (void *)&cmd_flex_filter_len_value,
7261 (void *)&cmd_flex_filter_bytes,
7262 (void *)&cmd_flex_filter_bytes_value,
7263 (void *)&cmd_flex_filter_mask,
7264 (void *)&cmd_flex_filter_mask_value,
7265 (void *)&cmd_flex_filter_priority,
7266 (void *)&cmd_flex_filter_priority_value,
7267 (void *)&cmd_flex_filter_queue,
7268 (void *)&cmd_flex_filter_queue_id,
7269 (void *)&cmd_flex_filter_index,
7270 (void *)&cmd_flex_filter_index_value,
7275 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7276 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7277 filter, "remove_flex_filter");
7278 cmdline_parse_inst_t cmd_remove_flex_filter = {
7279 .f = cmd_flex_filter_parsed,
7281 .help_str = "remove a flex filter",
7283 (void *)&cmd_flex_filter_remove_filter,
7284 (void *)&cmd_flex_filter_port_id,
7285 (void *)&cmd_flex_filter_index,
7286 (void *)&cmd_flex_filter_index_value,
7291 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7292 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7293 filter, "get_flex_filter");
7294 cmdline_parse_inst_t cmd_get_flex_filter = {
7295 .f = cmd_flex_filter_parsed,
7297 .help_str = "get a flex filter",
7299 (void *)&cmd_flex_filter_get_filter,
7300 (void *)&cmd_flex_filter_port_id,
7301 (void *)&cmd_flex_filter_index,
7302 (void *)&cmd_flex_filter_index_value,
7307 /* ******************************************************************************** */
7309 /* list of instructions */
7310 cmdline_parse_ctx_t main_ctx[] = {
7311 (cmdline_parse_inst_t *)&cmd_help_brief,
7312 (cmdline_parse_inst_t *)&cmd_help_long,
7313 (cmdline_parse_inst_t *)&cmd_quit,
7314 (cmdline_parse_inst_t *)&cmd_showport,
7315 (cmdline_parse_inst_t *)&cmd_showportall,
7316 (cmdline_parse_inst_t *)&cmd_showcfg,
7317 (cmdline_parse_inst_t *)&cmd_start,
7318 (cmdline_parse_inst_t *)&cmd_start_tx_first,
7319 (cmdline_parse_inst_t *)&cmd_set_link_up,
7320 (cmdline_parse_inst_t *)&cmd_set_link_down,
7321 (cmdline_parse_inst_t *)&cmd_reset,
7322 (cmdline_parse_inst_t *)&cmd_set_numbers,
7323 (cmdline_parse_inst_t *)&cmd_set_txpkts,
7324 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
7325 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
7326 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
7327 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
7328 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
7329 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
7330 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
7331 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
7332 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
7333 (cmdline_parse_inst_t *)&cmd_set_link_check,
7334 #ifdef RTE_NIC_BYPASS
7335 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
7336 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
7337 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
7338 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
7340 #ifdef RTE_LIBRTE_PMD_BOND
7341 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
7342 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
7343 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
7344 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
7345 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
7346 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
7347 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
7348 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
7350 (cmdline_parse_inst_t *)&cmd_vlan_offload,
7351 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
7352 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
7353 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
7354 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
7355 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
7356 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
7357 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
7358 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
7359 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
7360 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
7361 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
7362 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
7363 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
7364 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
7365 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
7366 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
7367 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
7368 (cmdline_parse_inst_t *)&cmd_config_dcb,
7369 (cmdline_parse_inst_t *)&cmd_read_reg,
7370 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
7371 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
7372 (cmdline_parse_inst_t *)&cmd_write_reg,
7373 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
7374 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
7375 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
7376 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
7377 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
7378 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
7379 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
7380 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
7381 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
7382 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
7383 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
7384 (cmdline_parse_inst_t *)&cmd_stop,
7385 (cmdline_parse_inst_t *)&cmd_mac_addr,
7386 (cmdline_parse_inst_t *)&cmd_set_qmap,
7387 (cmdline_parse_inst_t *)&cmd_operate_port,
7388 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
7389 (cmdline_parse_inst_t *)&cmd_config_speed_all,
7390 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
7391 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
7392 (cmdline_parse_inst_t *)&cmd_config_mtu,
7393 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
7394 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
7395 (cmdline_parse_inst_t *)&cmd_config_rss,
7396 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
7397 (cmdline_parse_inst_t *)&cmd_showport_reta,
7398 (cmdline_parse_inst_t *)&cmd_config_burst,
7399 (cmdline_parse_inst_t *)&cmd_config_thresh,
7400 (cmdline_parse_inst_t *)&cmd_config_threshold,
7401 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
7402 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
7403 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
7404 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
7405 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
7406 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
7407 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
7408 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
7409 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
7410 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
7411 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
7412 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
7413 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
7414 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
7415 (cmdline_parse_inst_t *)&cmd_dump,
7416 (cmdline_parse_inst_t *)&cmd_dump_one,
7417 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
7418 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
7419 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
7420 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
7421 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
7422 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
7423 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
7424 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
7425 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
7426 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
7427 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
7428 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
7429 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
7430 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
7431 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
7435 /* prompt function, called from main on MASTER lcore */
7441 /* initialize non-constant commands */
7442 cmd_set_fwd_mode_init();
7444 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
7448 cmdline_interact(cl);
7449 cmdline_stdin_exit(cl);
7453 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
7455 if (id < nb_ports) {
7456 /* check if need_reconfig has been set to 1 */
7457 if (ports[id].need_reconfig == 0)
7458 ports[id].need_reconfig = dev;
7459 /* check if need_reconfig_queues has been set to 1 */
7460 if (ports[id].need_reconfig_queues == 0)
7461 ports[id].need_reconfig_queues = queue;
7465 for (pid = 0; pid < nb_ports; pid++) {
7466 /* check if need_reconfig has been set to 1 */
7467 if (ports[pid].need_reconfig == 0)
7468 ports[pid].need_reconfig = dev;
7469 /* check if need_reconfig_queues has been set to 1 */
7470 if (ports[pid].need_reconfig_queues == 0)
7471 ports[pid].need_reconfig_queues = queue;
7476 #ifdef RTE_NIC_BYPASS
7478 bypass_is_supported(portid_t port_id)
7480 struct rte_port *port;
7481 struct rte_pci_id *pci_id;
7483 if (port_id >= nb_ports) {
7484 printf("\tPort id must be less than %d.\n", nb_ports);
7488 /* Get the device id. */
7489 port = &ports[port_id];
7490 pci_id = &port->dev_info.pci_dev->id;
7492 /* Check if NIC supports bypass. */
7493 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
7497 printf("\tBypass not supported for port_id = %d.\n", port_id);