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|xstats|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|xstats|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 "rx_vxlan_port add (udp_port) (port_id)\n"
289 " Add an UDP port for VxLAN packet filter on a port\n\n"
291 "rx_vxlan_port rm (udp_port) (port_id)\n"
292 " Remove an UDP port for VxLAN packet filter on a port\n\n"
294 "tx_vlan set vlan_id (port_id)\n"
295 " Set hardware insertion of VLAN ID in packets sent"
298 "tx_vlan set pvid port_id vlan_id (on|off)\n"
299 " Set port based TX VLAN insertion.\n\n"
301 "tx_vlan reset (port_id)\n"
302 " Disable hardware insertion of a VLAN header in"
303 " packets sent on a port.\n\n"
305 "tx_checksum set mask (port_id)\n"
306 " Enable hardware insertion of checksum offload with"
307 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
308 " bit 0 - insert ip checksum offload if set\n"
309 " bit 1 - insert udp checksum offload if set\n"
310 " bit 2 - insert tcp checksum offload if set\n"
311 " bit 3 - insert sctp checksum offload if set\n"
312 " Please check the NIC datasheet for HW limits.\n\n"
315 " Set packet forwarding mode.\n\n"
317 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
318 " Add a MAC address on port_id.\n\n"
320 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
321 " Remove a MAC address from port_id.\n\n"
323 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
324 " Add a MAC address for a VF on the port.\n\n"
326 "set port (port_id) uta (mac_address|all) (on|off)\n"
327 " Add/Remove a or all unicast hash filter(s)"
330 "set promisc (port_id|all) (on|off)\n"
331 " Set the promiscuous mode on port_id, or all.\n\n"
333 "set allmulti (port_id|all) (on|off)\n"
334 " Set the allmulti mode on port_id, or all.\n\n"
336 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
337 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
338 " (on|off) autoneg (on|off) (port_id)\n"
339 "set flow_ctrl rx (on|off) (portid)\n"
340 "set flow_ctrl tx (on|off) (portid)\n"
341 "set flow_ctrl high_water (high_water) (portid)\n"
342 "set flow_ctrl low_water (low_water) (portid)\n"
343 "set flow_ctrl pause_time (pause_time) (portid)\n"
344 "set flow_ctrl send_xon (send_xon) (portid)\n"
345 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
346 "set flow_ctrl autoneg (on|off) (port_id)\n"
347 " Set the link flow control parameter on a port.\n\n"
349 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
350 " (low_water) (pause_time) (priority) (port_id)\n"
351 " Set the priority flow control parameter on a"
354 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
355 " Set statistics mapping (qmapping 0..15) for RX/TX"
357 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
358 " on port 0 to mapping 5.\n\n"
360 "set port (port_id) vf (vf_id) rx|tx on|off \n"
361 " Enable/Disable a VF receive/tranmit from a port\n\n"
363 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
365 " AUPE:accepts untagged VLAN;"
366 "ROPE:accept unicast hash\n\n"
367 " BAM:accepts broadcast packets;"
368 "MPE:accepts all multicast packets\n\n"
369 " Enable/Disable a VF receive mode of a port\n\n"
371 "set port (port_id) queue (queue_id) rate (rate_num)\n"
372 " Set rate limit for a queue of a port\n\n"
374 "set port (port_id) vf (vf_id) rate (rate_num) "
375 "queue_mask (queue_mask_value)\n"
376 " Set rate limit for queues in VF of a port\n\n"
378 "set port (port_id) mirror-rule (rule_id)"
379 "(pool-mirror|vlan-mirror)\n"
380 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
381 " Set pool or vlan type mirror rule on a port.\n"
382 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
383 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
386 "set port (port_id) mirror-rule (rule_id)"
387 " (uplink-mirror|downlink-mirror) dst-pool"
388 " (pool_id) (on|off)\n"
389 " Set uplink or downlink type mirror rule on a port.\n"
390 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
391 " 0 on' enable mirror income traffic to pool 0.\n\n"
393 "reset port (port_id) mirror-rule (rule_id)\n"
394 " Reset a mirror rule.\n\n"
396 "set flush_rx (on|off)\n"
397 " Flush (default) or don't flush RX streams before"
398 " forwarding. Mainly used with PCAP drivers.\n\n"
400 #ifdef RTE_NIC_BYPASS
401 "set bypass mode (normal|bypass|isolate) (port_id)\n"
402 " Set the bypass mode for the lowest port on bypass enabled"
405 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
406 "mode (normal|bypass|isolate) (port_id)\n"
407 " Set the event required to initiate specified bypass mode for"
408 " the lowest port on a bypass enabled NIC where:\n"
409 " timeout = enable bypass after watchdog timeout.\n"
410 " os_on = enable bypass when OS/board is powered on.\n"
411 " os_off = enable bypass when OS/board is powered off.\n"
412 " power_on = enable bypass when power supply is turned on.\n"
413 " power_off = enable bypass when power supply is turned off."
416 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
417 " Set the bypass watchdog timeout to 'n' seconds"
418 " where 0 = instant.\n\n"
420 "show bypass config (port_id)\n"
421 " Show the bypass configuration for a bypass enabled NIC"
422 " using the lowest port on the NIC.\n\n"
424 #ifdef RTE_LIBRTE_PMD_BOND
425 "create bonded device (mode) (socket)\n"
426 " Create a new bonded device with specific bonding mode and socket.\n\n"
428 "add bonding slave (slave_id) (port_id)\n"
429 " Add a slave device to a bonded device.\n\n"
431 "remove bonding slave (slave_id) (port_id)\n"
432 " Remove a slave device from a bonded device.\n\n"
434 "set bonding mode (value) (port_id)\n"
435 " Set the bonding mode on a bonded device.\n\n"
437 "set bonding primary (slave_id) (port_id)\n"
438 " Set the primary slave for a bonded device.\n\n"
440 "show bonding config (port_id)\n"
441 " Show the bonding config for port_id.\n\n"
443 "set bonding mac_addr (port_id) (address)\n"
444 " Set the MAC address of a bonded device.\n\n"
446 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
447 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
450 , list_pkt_forwarding_modes()
455 if (show_all || !strcmp(res->section, "flowdir")) {
460 "Flow director mode:\n"
461 "-------------------\n\n"
463 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
464 " src (src_ip_address) (src_port)"
465 " dst (dst_ip_address) (dst_port)"
466 " flexbytes (flexbytes_values) vlan (vlan_id)"
467 " queue (queue_id)\n"
468 " Add a signature filter.\n\n"
470 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
471 " src (src_ip_address) (src_port)"
472 " dst (dst_ip_address) (dst_port)"
473 " flexbytes (flexbytes_values) vlan (vlan_id)"
474 " queue (queue_id)\n"
475 " Update a signature filter.\n\n"
477 "rm_signature_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)\n"
481 " Remove a signature filter.\n\n"
483 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
484 " src (src_ip_address) (src_port)"
485 " dst (dst_ip_address) (dst_port)"
486 " flexbytes (flexbytes_values) vlan (vlan_id)"
487 " queue (queue_id) soft (soft_id)\n"
488 " Add a perfect filter.\n\n"
490 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
491 " src (src_ip_address) (src_port)"
492 " dst (dst_ip_address) (dst_port)"
493 " flexbytes (flexbytes_values) vlan (vlan_id)"
494 " queue (queue_id)\n"
495 " Update a perfect filter.\n\n"
497 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
498 " src (src_ip_address) (src_port)"
499 " dst (dst_ip_address) (dst_port)"
500 " flexbytes (flexbytes_values) vlan (vlan_id)"
502 " Remove a perfect filter.\n\n"
504 "set_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)\n"
508 " Set IPv4 filter masks.\n\n"
510 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
511 " src_mask (ip_src_mask) (src_port_mask)"
512 " dst_mask (ip_dst_mask) (dst_port_mask)"
513 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
514 " compare_dst (0|1)\n"
515 " Set IPv6 filter masks.\n\n"
519 if (show_all || !strcmp(res->section, "ports")) {
525 "----------------\n\n"
527 "port start (port_id|all)\n"
528 " Start all ports or port_id.\n\n"
530 "port stop (port_id|all)\n"
531 " Stop all ports or port_id.\n\n"
533 "port close (port_id|all)\n"
534 " Close all ports or port_id.\n\n"
536 "port config (port_id|all)"
537 " speed (10|100|1000|10000|40000|auto)"
538 " duplex (half|full|auto)\n"
539 " Set speed and duplex for all ports or port_id\n\n"
541 "port config all (rxq|txq|rxd|txd) (value)\n"
542 " Set number for rxq/txq/rxd/txd.\n\n"
544 "port config all max-pkt-len (value)\n"
545 " Set the max packet length.\n\n"
547 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
549 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
552 "port config all rss (ip|udp|none)\n"
553 " Set the RSS mode.\n\n"
555 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
556 " Set the RSS redirection table.\n\n"
558 "port config (port_id) dcb vt (on|off) (traffic_class)"
560 " Set the DCB mode.\n\n"
562 "port config all burst (value)\n"
563 " Set the number of packets per burst.\n\n"
565 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
567 " Set the ring prefetch/host/writeback threshold"
568 " for tx/rx queue.\n\n"
570 "port config all (txfreet|txrst|rxfreet) (value)\n"
571 " Set free threshold for rx/tx, or set"
572 " tx rs bit threshold.\n\n"
573 "port config mtu X value\n"
574 " Set the MTU of port X to a given value\n\n"
576 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
577 " Start/stop a rx/tx queue of port X. Only take effect"
578 " when port X is started\n"
582 if (show_all || !strcmp(res->section, "registers")) {
590 "read reg (port_id) (address)\n"
591 " Display value of a port register.\n\n"
593 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
594 " Display a port register bit field.\n\n"
596 "read regbit (port_id) (address) (bit_x)\n"
597 " Display a single port register bit.\n\n"
599 "write reg (port_id) (address) (value)\n"
600 " Set value of a port register.\n\n"
602 "write regfield (port_id) (address) (bit_x) (bit_y)"
604 " Set bit field of a port register.\n\n"
606 "write regbit (port_id) (address) (bit_x) (value)\n"
607 " Set single bit value of a port register.\n\n"
610 if (show_all || !strcmp(res->section, "filters")) {
618 "add_ethertype_filter (port_id) ethertype (eth_value)"
619 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
620 " add an ethertype filter.\n\n"
622 "remove_ethertype_filter (port_id) index (idx)\n"
623 " remove an ethertype filter.\n\n"
625 "get_ethertype_filter (port_id) index (idx)\n"
626 " get info of a ethertype filter.\n\n"
628 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
629 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
630 " queue (queue_id) index (idx)\n"
631 " add a 2tuple filter.\n\n"
633 "remove_2tuple_filter (port_id) index (idx)\n"
634 " remove a 2tuple filter.\n\n"
636 "get_2tuple_filter (port_id) index (idx)\n"
637 " get info of a 2tuple filter.\n\n"
639 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
640 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
641 " mask (mask_value) flags (flags_value) priority (prio_value)"
642 " queue (queue_id) index (idx)\n"
643 " add a 5tuple filter.\n\n"
645 "remove_5tuple_filter (port_id) index (idx)\n"
646 " remove a 5tuple filter.\n\n"
648 "get_5tuple_filter (port_id) index (idx)\n"
649 " get info of a 5tuple filter.\n\n"
651 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
652 " add syn filter.\n\n"
654 "remove_syn_filter (port_id)"
655 " remove syn filter.\n\n"
657 "get_syn_filter (port_id) "
658 " get syn filter info.\n\n"
660 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
661 " priority (prio_value) queue (queue_id) index (idx)\n"
662 " add a flex filter.\n\n"
664 "remove_flex_filter (port_id) index (idx)\n"
665 " remove a flex filter.\n\n"
667 "get_flex_filter (port_id) index (idx)\n"
668 " get info of a flex filter.\n\n"
673 cmdline_parse_token_string_t cmd_help_long_help =
674 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
676 cmdline_parse_token_string_t cmd_help_long_section =
677 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
678 "all#control#display#config#flowdir#"
679 "ports#registers#filters");
681 cmdline_parse_inst_t cmd_help_long = {
682 .f = cmd_help_long_parsed,
684 .help_str = "show help",
686 (void *)&cmd_help_long_help,
687 (void *)&cmd_help_long_section,
693 /* *** start/stop/close all ports *** */
694 struct cmd_operate_port_result {
695 cmdline_fixed_string_t keyword;
696 cmdline_fixed_string_t name;
697 cmdline_fixed_string_t value;
700 static void cmd_operate_port_parsed(void *parsed_result,
701 __attribute__((unused)) struct cmdline *cl,
702 __attribute__((unused)) void *data)
704 struct cmd_operate_port_result *res = parsed_result;
706 if (!strcmp(res->name, "start"))
707 start_port(RTE_PORT_ALL);
708 else if (!strcmp(res->name, "stop"))
709 stop_port(RTE_PORT_ALL);
710 else if (!strcmp(res->name, "close"))
711 close_port(RTE_PORT_ALL);
713 printf("Unknown parameter\n");
716 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
717 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
719 cmdline_parse_token_string_t cmd_operate_port_all_port =
720 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
722 cmdline_parse_token_string_t cmd_operate_port_all_all =
723 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
725 cmdline_parse_inst_t cmd_operate_port = {
726 .f = cmd_operate_port_parsed,
728 .help_str = "port start|stop|close all: start/stop/close all ports",
730 (void *)&cmd_operate_port_all_cmd,
731 (void *)&cmd_operate_port_all_port,
732 (void *)&cmd_operate_port_all_all,
737 /* *** start/stop/close specific port *** */
738 struct cmd_operate_specific_port_result {
739 cmdline_fixed_string_t keyword;
740 cmdline_fixed_string_t name;
744 static void cmd_operate_specific_port_parsed(void *parsed_result,
745 __attribute__((unused)) struct cmdline *cl,
746 __attribute__((unused)) void *data)
748 struct cmd_operate_specific_port_result *res = parsed_result;
750 if (!strcmp(res->name, "start"))
751 start_port(res->value);
752 else if (!strcmp(res->name, "stop"))
753 stop_port(res->value);
754 else if (!strcmp(res->name, "close"))
755 close_port(res->value);
757 printf("Unknown parameter\n");
760 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
761 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
763 cmdline_parse_token_string_t cmd_operate_specific_port_port =
764 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
765 name, "start#stop#close");
766 cmdline_parse_token_num_t cmd_operate_specific_port_id =
767 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
770 cmdline_parse_inst_t cmd_operate_specific_port = {
771 .f = cmd_operate_specific_port_parsed,
773 .help_str = "port start|stop|close X: start/stop/close port X",
775 (void *)&cmd_operate_specific_port_cmd,
776 (void *)&cmd_operate_specific_port_port,
777 (void *)&cmd_operate_specific_port_id,
782 /* *** configure speed for all ports *** */
783 struct cmd_config_speed_all {
784 cmdline_fixed_string_t port;
785 cmdline_fixed_string_t keyword;
786 cmdline_fixed_string_t all;
787 cmdline_fixed_string_t item1;
788 cmdline_fixed_string_t item2;
789 cmdline_fixed_string_t value1;
790 cmdline_fixed_string_t value2;
794 cmd_config_speed_all_parsed(void *parsed_result,
795 __attribute__((unused)) struct cmdline *cl,
796 __attribute__((unused)) void *data)
798 struct cmd_config_speed_all *res = parsed_result;
799 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
800 uint16_t link_duplex = 0;
803 if (!all_ports_stopped()) {
804 printf("Please stop all ports first\n");
808 if (!strcmp(res->value1, "10"))
809 link_speed = ETH_LINK_SPEED_10;
810 else if (!strcmp(res->value1, "100"))
811 link_speed = ETH_LINK_SPEED_100;
812 else if (!strcmp(res->value1, "1000"))
813 link_speed = ETH_LINK_SPEED_1000;
814 else if (!strcmp(res->value1, "10000"))
815 link_speed = ETH_LINK_SPEED_10G;
816 else if (!strcmp(res->value1, "40000"))
817 link_speed = ETH_LINK_SPEED_40G;
818 else if (!strcmp(res->value1, "auto"))
819 link_speed = ETH_LINK_SPEED_AUTONEG;
821 printf("Unknown parameter\n");
825 if (!strcmp(res->value2, "half"))
826 link_duplex = ETH_LINK_HALF_DUPLEX;
827 else if (!strcmp(res->value2, "full"))
828 link_duplex = ETH_LINK_FULL_DUPLEX;
829 else if (!strcmp(res->value2, "auto"))
830 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
832 printf("Unknown parameter\n");
836 for (pid = 0; pid < nb_ports; pid++) {
837 ports[pid].dev_conf.link_speed = link_speed;
838 ports[pid].dev_conf.link_duplex = link_duplex;
841 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
844 cmdline_parse_token_string_t cmd_config_speed_all_port =
845 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
846 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
847 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
849 cmdline_parse_token_string_t cmd_config_speed_all_all =
850 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
851 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
852 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
853 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
854 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
855 "10#100#1000#10000#40000#auto");
856 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
857 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
858 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
859 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
862 cmdline_parse_inst_t cmd_config_speed_all = {
863 .f = cmd_config_speed_all_parsed,
865 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
868 (void *)&cmd_config_speed_all_port,
869 (void *)&cmd_config_speed_all_keyword,
870 (void *)&cmd_config_speed_all_all,
871 (void *)&cmd_config_speed_all_item1,
872 (void *)&cmd_config_speed_all_value1,
873 (void *)&cmd_config_speed_all_item2,
874 (void *)&cmd_config_speed_all_value2,
879 /* *** configure speed for specific port *** */
880 struct cmd_config_speed_specific {
881 cmdline_fixed_string_t port;
882 cmdline_fixed_string_t keyword;
884 cmdline_fixed_string_t item1;
885 cmdline_fixed_string_t item2;
886 cmdline_fixed_string_t value1;
887 cmdline_fixed_string_t value2;
891 cmd_config_speed_specific_parsed(void *parsed_result,
892 __attribute__((unused)) struct cmdline *cl,
893 __attribute__((unused)) void *data)
895 struct cmd_config_speed_specific *res = parsed_result;
896 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
897 uint16_t link_duplex = 0;
899 if (!all_ports_stopped()) {
900 printf("Please stop all ports first\n");
904 if (res->id >= nb_ports) {
905 printf("Port id %d must be less than %d\n", res->id, nb_ports);
909 if (!strcmp(res->value1, "10"))
910 link_speed = ETH_LINK_SPEED_10;
911 else if (!strcmp(res->value1, "100"))
912 link_speed = ETH_LINK_SPEED_100;
913 else if (!strcmp(res->value1, "1000"))
914 link_speed = ETH_LINK_SPEED_1000;
915 else if (!strcmp(res->value1, "10000"))
916 link_speed = ETH_LINK_SPEED_10000;
917 else if (!strcmp(res->value1, "40000"))
918 link_speed = ETH_LINK_SPEED_40G;
919 else if (!strcmp(res->value1, "auto"))
920 link_speed = ETH_LINK_SPEED_AUTONEG;
922 printf("Unknown parameter\n");
926 if (!strcmp(res->value2, "half"))
927 link_duplex = ETH_LINK_HALF_DUPLEX;
928 else if (!strcmp(res->value2, "full"))
929 link_duplex = ETH_LINK_FULL_DUPLEX;
930 else if (!strcmp(res->value2, "auto"))
931 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
933 printf("Unknown parameter\n");
937 ports[res->id].dev_conf.link_speed = link_speed;
938 ports[res->id].dev_conf.link_duplex = link_duplex;
940 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
944 cmdline_parse_token_string_t cmd_config_speed_specific_port =
945 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
947 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
948 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
950 cmdline_parse_token_num_t cmd_config_speed_specific_id =
951 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
952 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
953 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
955 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
956 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
957 "10#100#1000#10000#40000#auto");
958 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
959 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
961 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
962 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
965 cmdline_parse_inst_t cmd_config_speed_specific = {
966 .f = cmd_config_speed_specific_parsed,
968 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
971 (void *)&cmd_config_speed_specific_port,
972 (void *)&cmd_config_speed_specific_keyword,
973 (void *)&cmd_config_speed_specific_id,
974 (void *)&cmd_config_speed_specific_item1,
975 (void *)&cmd_config_speed_specific_value1,
976 (void *)&cmd_config_speed_specific_item2,
977 (void *)&cmd_config_speed_specific_value2,
982 /* *** configure txq/rxq, txd/rxd *** */
983 struct cmd_config_rx_tx {
984 cmdline_fixed_string_t port;
985 cmdline_fixed_string_t keyword;
986 cmdline_fixed_string_t all;
987 cmdline_fixed_string_t name;
992 cmd_config_rx_tx_parsed(void *parsed_result,
993 __attribute__((unused)) struct cmdline *cl,
994 __attribute__((unused)) void *data)
996 struct cmd_config_rx_tx *res = parsed_result;
998 if (!all_ports_stopped()) {
999 printf("Please stop all ports first\n");
1003 if (!strcmp(res->name, "rxq")) {
1004 if (res->value <= 0) {
1005 printf("rxq %d invalid - must be > 0\n", res->value);
1008 nb_rxq = res->value;
1010 else if (!strcmp(res->name, "txq")) {
1011 if (res->value <= 0) {
1012 printf("txq %d invalid - must be > 0\n", res->value);
1015 nb_txq = res->value;
1017 else if (!strcmp(res->name, "rxd")) {
1018 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1019 printf("rxd %d invalid - must be > 0 && <= %d\n",
1020 res->value, RTE_TEST_RX_DESC_MAX);
1023 nb_rxd = res->value;
1024 } else if (!strcmp(res->name, "txd")) {
1025 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1026 printf("txd %d invalid - must be > 0 && <= %d\n",
1027 res->value, RTE_TEST_TX_DESC_MAX);
1030 nb_txd = res->value;
1032 printf("Unknown parameter\n");
1038 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1041 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1042 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1043 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1044 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1045 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1046 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1047 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1048 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1050 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1051 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1053 cmdline_parse_inst_t cmd_config_rx_tx = {
1054 .f = cmd_config_rx_tx_parsed,
1056 .help_str = "port config all rxq|txq|rxd|txd value",
1058 (void *)&cmd_config_rx_tx_port,
1059 (void *)&cmd_config_rx_tx_keyword,
1060 (void *)&cmd_config_rx_tx_all,
1061 (void *)&cmd_config_rx_tx_name,
1062 (void *)&cmd_config_rx_tx_value,
1067 /* *** config max packet length *** */
1068 struct cmd_config_max_pkt_len_result {
1069 cmdline_fixed_string_t port;
1070 cmdline_fixed_string_t keyword;
1071 cmdline_fixed_string_t all;
1072 cmdline_fixed_string_t name;
1077 cmd_config_max_pkt_len_parsed(void *parsed_result,
1078 __attribute__((unused)) struct cmdline *cl,
1079 __attribute__((unused)) void *data)
1081 struct cmd_config_max_pkt_len_result *res = parsed_result;
1083 if (!all_ports_stopped()) {
1084 printf("Please stop all ports first\n");
1088 if (!strcmp(res->name, "max-pkt-len")) {
1089 if (res->value < ETHER_MIN_LEN) {
1090 printf("max-pkt-len can not be less than %d\n",
1094 if (res->value == rx_mode.max_rx_pkt_len)
1097 rx_mode.max_rx_pkt_len = res->value;
1098 if (res->value > ETHER_MAX_LEN)
1099 rx_mode.jumbo_frame = 1;
1101 rx_mode.jumbo_frame = 0;
1103 printf("Unknown parameter\n");
1109 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1112 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1113 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1115 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1116 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1118 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1119 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1121 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1122 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1124 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1125 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1128 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1129 .f = cmd_config_max_pkt_len_parsed,
1131 .help_str = "port config all max-pkt-len value",
1133 (void *)&cmd_config_max_pkt_len_port,
1134 (void *)&cmd_config_max_pkt_len_keyword,
1135 (void *)&cmd_config_max_pkt_len_all,
1136 (void *)&cmd_config_max_pkt_len_name,
1137 (void *)&cmd_config_max_pkt_len_value,
1142 /* *** configure port MTU *** */
1143 struct cmd_config_mtu_result {
1144 cmdline_fixed_string_t port;
1145 cmdline_fixed_string_t keyword;
1146 cmdline_fixed_string_t mtu;
1152 cmd_config_mtu_parsed(void *parsed_result,
1153 __attribute__((unused)) struct cmdline *cl,
1154 __attribute__((unused)) void *data)
1156 struct cmd_config_mtu_result *res = parsed_result;
1158 if (res->value < ETHER_MIN_LEN) {
1159 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1162 port_mtu_set(res->port_id, res->value);
1165 cmdline_parse_token_string_t cmd_config_mtu_port =
1166 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1168 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1169 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1171 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1172 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1174 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1175 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1176 cmdline_parse_token_num_t cmd_config_mtu_value =
1177 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1179 cmdline_parse_inst_t cmd_config_mtu = {
1180 .f = cmd_config_mtu_parsed,
1182 .help_str = "port config mtu value",
1184 (void *)&cmd_config_mtu_port,
1185 (void *)&cmd_config_mtu_keyword,
1186 (void *)&cmd_config_mtu_mtu,
1187 (void *)&cmd_config_mtu_port_id,
1188 (void *)&cmd_config_mtu_value,
1193 /* *** configure rx mode *** */
1194 struct cmd_config_rx_mode_flag {
1195 cmdline_fixed_string_t port;
1196 cmdline_fixed_string_t keyword;
1197 cmdline_fixed_string_t all;
1198 cmdline_fixed_string_t name;
1199 cmdline_fixed_string_t value;
1203 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1204 __attribute__((unused)) struct cmdline *cl,
1205 __attribute__((unused)) void *data)
1207 struct cmd_config_rx_mode_flag *res = parsed_result;
1209 if (!all_ports_stopped()) {
1210 printf("Please stop all ports first\n");
1214 if (!strcmp(res->name, "crc-strip")) {
1215 if (!strcmp(res->value, "on"))
1216 rx_mode.hw_strip_crc = 1;
1217 else if (!strcmp(res->value, "off"))
1218 rx_mode.hw_strip_crc = 0;
1220 printf("Unknown parameter\n");
1223 } else if (!strcmp(res->name, "rx-cksum")) {
1224 if (!strcmp(res->value, "on"))
1225 rx_mode.hw_ip_checksum = 1;
1226 else if (!strcmp(res->value, "off"))
1227 rx_mode.hw_ip_checksum = 0;
1229 printf("Unknown parameter\n");
1232 } else if (!strcmp(res->name, "hw-vlan")) {
1233 if (!strcmp(res->value, "on")) {
1234 rx_mode.hw_vlan_filter = 1;
1235 rx_mode.hw_vlan_strip = 1;
1237 else if (!strcmp(res->value, "off")) {
1238 rx_mode.hw_vlan_filter = 0;
1239 rx_mode.hw_vlan_strip = 0;
1242 printf("Unknown parameter\n");
1245 } else if (!strcmp(res->name, "drop-en")) {
1246 if (!strcmp(res->value, "on"))
1248 else if (!strcmp(res->value, "off"))
1251 printf("Unknown parameter\n");
1255 printf("Unknown parameter\n");
1261 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1264 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1265 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1266 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1267 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1269 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1270 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1271 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1272 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1273 "crc-strip#rx-cksum#hw-vlan");
1274 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1275 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1278 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1279 .f = cmd_config_rx_mode_flag_parsed,
1281 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1283 (void *)&cmd_config_rx_mode_flag_port,
1284 (void *)&cmd_config_rx_mode_flag_keyword,
1285 (void *)&cmd_config_rx_mode_flag_all,
1286 (void *)&cmd_config_rx_mode_flag_name,
1287 (void *)&cmd_config_rx_mode_flag_value,
1292 /* *** configure rss *** */
1293 struct cmd_config_rss {
1294 cmdline_fixed_string_t port;
1295 cmdline_fixed_string_t keyword;
1296 cmdline_fixed_string_t all;
1297 cmdline_fixed_string_t name;
1298 cmdline_fixed_string_t value;
1302 cmd_config_rss_parsed(void *parsed_result,
1303 __attribute__((unused)) struct cmdline *cl,
1304 __attribute__((unused)) void *data)
1306 struct cmd_config_rss *res = parsed_result;
1307 struct rte_eth_rss_conf rss_conf;
1310 if (!strcmp(res->value, "ip"))
1311 rss_conf.rss_hf = ETH_RSS_IP;
1312 else if (!strcmp(res->value, "udp"))
1313 rss_conf.rss_hf = ETH_RSS_UDP;
1314 else if (!strcmp(res->value, "none"))
1315 rss_conf.rss_hf = 0;
1317 printf("Unknown parameter\n");
1320 rss_conf.rss_key = NULL;
1321 for (i = 0; i < rte_eth_dev_count(); i++)
1322 rte_eth_dev_rss_hash_update(i, &rss_conf);
1325 cmdline_parse_token_string_t cmd_config_rss_port =
1326 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1327 cmdline_parse_token_string_t cmd_config_rss_keyword =
1328 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1329 cmdline_parse_token_string_t cmd_config_rss_all =
1330 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1331 cmdline_parse_token_string_t cmd_config_rss_name =
1332 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1333 cmdline_parse_token_string_t cmd_config_rss_value =
1334 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1336 cmdline_parse_inst_t cmd_config_rss = {
1337 .f = cmd_config_rss_parsed,
1339 .help_str = "port config all rss ip|udp|none",
1341 (void *)&cmd_config_rss_port,
1342 (void *)&cmd_config_rss_keyword,
1343 (void *)&cmd_config_rss_all,
1344 (void *)&cmd_config_rss_name,
1345 (void *)&cmd_config_rss_value,
1350 /* *** configure rss hash key *** */
1351 struct cmd_config_rss_hash_key {
1352 cmdline_fixed_string_t port;
1353 cmdline_fixed_string_t config;
1355 cmdline_fixed_string_t rss_hash_key;
1356 cmdline_fixed_string_t key;
1359 #define RSS_HASH_KEY_LENGTH 40
1361 hexa_digit_to_value(char hexa_digit)
1363 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1364 return (uint8_t) (hexa_digit - '0');
1365 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1366 return (uint8_t) ((hexa_digit - 'a') + 10);
1367 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1368 return (uint8_t) ((hexa_digit - 'A') + 10);
1369 /* Invalid hexa digit */
1374 parse_and_check_key_hexa_digit(char *key, int idx)
1378 hexa_v = hexa_digit_to_value(key[idx]);
1380 printf("invalid key: character %c at position %d is not a "
1381 "valid hexa digit\n", key[idx], idx);
1386 cmd_config_rss_hash_key_parsed(void *parsed_result,
1387 __attribute__((unused)) struct cmdline *cl,
1388 __attribute__((unused)) void *data)
1390 struct cmd_config_rss_hash_key *res = parsed_result;
1391 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1396 /* Check the length of the RSS hash key */
1397 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1398 printf("key length: %d invalid - key must be a string of %d"
1399 "hexa-decimal numbers\n", (int) strlen(res->key),
1400 RSS_HASH_KEY_LENGTH * 2);
1403 /* Translate RSS hash key into binary representation */
1404 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1405 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1408 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1411 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1413 port_rss_hash_key_update(res->port_id, hash_key);
1416 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1418 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1421 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1422 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1423 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1424 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1425 rss_hash_key, "rss-hash-key");
1426 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1427 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1429 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1430 .f = cmd_config_rss_hash_key_parsed,
1432 .help_str = "port config X rss-hash-key 80 hexa digits",
1434 (void *)&cmd_config_rss_hash_key_port,
1435 (void *)&cmd_config_rss_hash_key_config,
1436 (void *)&cmd_config_rss_hash_key_port_id,
1437 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1438 (void *)&cmd_config_rss_hash_key_value,
1443 /* *** configure port rxq/txq start/stop *** */
1444 struct cmd_config_rxtx_queue {
1445 cmdline_fixed_string_t port;
1447 cmdline_fixed_string_t rxtxq;
1449 cmdline_fixed_string_t opname;
1453 cmd_config_rxtx_queue_parsed(void *parsed_result,
1454 __attribute__((unused)) struct cmdline *cl,
1455 __attribute__((unused)) void *data)
1457 struct cmd_config_rxtx_queue *res = parsed_result;
1462 if (test_done == 0) {
1463 printf("Please stop forwarding first\n");
1467 if (port_id_is_invalid(res->portid))
1470 if (port_is_started(res->portid) != 1) {
1471 printf("Please start port %u first\n", res->portid);
1475 if (!strcmp(res->rxtxq, "rxq"))
1477 else if (!strcmp(res->rxtxq, "txq"))
1480 printf("Unknown parameter\n");
1484 if (isrx && rx_queue_id_is_invalid(res->qid))
1486 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1489 if (!strcmp(res->opname, "start"))
1491 else if (!strcmp(res->opname, "stop"))
1494 printf("Unknown parameter\n");
1498 if (isstart && isrx)
1499 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1500 else if (!isstart && isrx)
1501 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1502 else if (isstart && !isrx)
1503 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1505 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1507 if (ret == -ENOTSUP)
1508 printf("Function not supported in PMD driver\n");
1511 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1512 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1513 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1514 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1515 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1516 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1517 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1518 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1519 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1520 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1523 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1524 .f = cmd_config_rxtx_queue_parsed,
1526 .help_str = "port X rxq|txq ID start|stop",
1528 (void *)&cmd_config_speed_all_port,
1529 (void *)&cmd_config_rxtx_queue_portid,
1530 (void *)&cmd_config_rxtx_queue_rxtxq,
1531 (void *)&cmd_config_rxtx_queue_qid,
1532 (void *)&cmd_config_rxtx_queue_opname,
1537 /* *** Configure RSS RETA *** */
1538 struct cmd_config_rss_reta {
1539 cmdline_fixed_string_t port;
1540 cmdline_fixed_string_t keyword;
1542 cmdline_fixed_string_t name;
1543 cmdline_fixed_string_t list_name;
1544 cmdline_fixed_string_t list_of_items;
1548 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1555 const char *p, *p0 = str;
1562 unsigned long int_fld[_NUM_FLD];
1563 char *str_fld[_NUM_FLD];
1565 while ((p = strchr(p0,'(')) != NULL) {
1567 if((p0 = strchr(p,')')) == NULL)
1571 if(size >= sizeof(s))
1574 snprintf(s, sizeof(s), "%.*s", size, p);
1575 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1577 for (i = 0; i < _NUM_FLD; i++) {
1579 int_fld[i] = strtoul(str_fld[i], &end, 0);
1580 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1584 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1585 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1587 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1588 printf("Invalid RETA hash index=%d",hash_index);
1592 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1593 reta_conf->mask_lo |= (1ULL << hash_index);
1595 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1597 reta_conf->reta[hash_index] = nb_queue;
1604 cmd_set_rss_reta_parsed(void *parsed_result,
1605 __attribute__((unused)) struct cmdline *cl,
1606 __attribute__((unused)) void *data)
1609 struct rte_eth_rss_reta reta_conf;
1610 struct cmd_config_rss_reta *res = parsed_result;
1612 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1613 if (!strcmp(res->list_name, "reta")) {
1614 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1615 printf("Invalid RSS Redirection Table config entered\n");
1618 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1620 printf("Bad redirection table parameter, return code = %d \n",ret);
1624 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1625 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1626 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1627 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1628 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1629 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1630 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1632 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1633 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1634 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1635 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1637 cmdline_parse_inst_t cmd_config_rss_reta = {
1638 .f = cmd_set_rss_reta_parsed,
1640 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1642 (void *)&cmd_config_rss_reta_port,
1643 (void *)&cmd_config_rss_reta_keyword,
1644 (void *)&cmd_config_rss_reta_port_id,
1645 (void *)&cmd_config_rss_reta_name,
1646 (void *)&cmd_config_rss_reta_list_name,
1647 (void *)&cmd_config_rss_reta_list_of_items,
1652 /* *** SHOW PORT RETA INFO *** */
1653 struct cmd_showport_reta {
1654 cmdline_fixed_string_t show;
1655 cmdline_fixed_string_t port;
1657 cmdline_fixed_string_t rss;
1658 cmdline_fixed_string_t reta;
1663 static void cmd_showport_reta_parsed(void *parsed_result,
1664 __attribute__((unused)) struct cmdline *cl,
1665 __attribute__((unused)) void *data)
1667 struct cmd_showport_reta *res = parsed_result;
1668 struct rte_eth_rss_reta reta_conf;
1670 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1671 printf("Invalid RSS Redirection Table config entered\n");
1675 reta_conf.mask_lo = res->mask_lo;
1676 reta_conf.mask_hi = res->mask_hi;
1678 port_rss_reta_info(res->port_id,&reta_conf);
1681 cmdline_parse_token_string_t cmd_showport_reta_show =
1682 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1683 cmdline_parse_token_string_t cmd_showport_reta_port =
1684 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1685 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1686 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1687 cmdline_parse_token_string_t cmd_showport_reta_rss =
1688 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1689 cmdline_parse_token_string_t cmd_showport_reta_reta =
1690 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1691 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1692 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1693 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1694 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1696 cmdline_parse_inst_t cmd_showport_reta = {
1697 .f = cmd_showport_reta_parsed,
1699 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1700 (mask_lo and mask_hi is UINT64)",
1702 (void *)&cmd_showport_reta_show,
1703 (void *)&cmd_showport_reta_port,
1704 (void *)&cmd_showport_reta_port_id,
1705 (void *)&cmd_showport_reta_rss,
1706 (void *)&cmd_showport_reta_reta,
1707 (void *)&cmd_showport_reta_mask_lo,
1708 (void *)&cmd_showport_reta_mask_hi,
1713 /* *** Show RSS hash configuration *** */
1714 struct cmd_showport_rss_hash {
1715 cmdline_fixed_string_t show;
1716 cmdline_fixed_string_t port;
1718 cmdline_fixed_string_t rss_hash;
1719 cmdline_fixed_string_t key; /* optional argument */
1722 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1723 __attribute__((unused)) struct cmdline *cl,
1726 struct cmd_showport_rss_hash *res = parsed_result;
1728 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1731 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1732 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1733 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1734 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1735 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1736 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1737 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1738 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1740 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1741 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1743 cmdline_parse_inst_t cmd_showport_rss_hash = {
1744 .f = cmd_showport_rss_hash_parsed,
1746 .help_str = "show port X rss-hash (X = port number)\n",
1748 (void *)&cmd_showport_rss_hash_show,
1749 (void *)&cmd_showport_rss_hash_port,
1750 (void *)&cmd_showport_rss_hash_port_id,
1751 (void *)&cmd_showport_rss_hash_rss_hash,
1756 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1757 .f = cmd_showport_rss_hash_parsed,
1759 .help_str = "show port X rss-hash key (X = port number)\n",
1761 (void *)&cmd_showport_rss_hash_show,
1762 (void *)&cmd_showport_rss_hash_port,
1763 (void *)&cmd_showport_rss_hash_port_id,
1764 (void *)&cmd_showport_rss_hash_rss_hash,
1765 (void *)&cmd_showport_rss_hash_rss_key,
1770 /* *** Configure DCB *** */
1771 struct cmd_config_dcb {
1772 cmdline_fixed_string_t port;
1773 cmdline_fixed_string_t config;
1775 cmdline_fixed_string_t dcb;
1776 cmdline_fixed_string_t vt;
1777 cmdline_fixed_string_t vt_en;
1779 cmdline_fixed_string_t pfc;
1780 cmdline_fixed_string_t pfc_en;
1784 cmd_config_dcb_parsed(void *parsed_result,
1785 __attribute__((unused)) struct cmdline *cl,
1786 __attribute__((unused)) void *data)
1788 struct cmd_config_dcb *res = parsed_result;
1789 struct dcb_config dcb_conf;
1790 portid_t port_id = res->port_id;
1791 struct rte_port *port;
1793 port = &ports[port_id];
1794 /** Check if the port is not started **/
1795 if (port->port_status != RTE_PORT_STOPPED) {
1796 printf("Please stop port %d first\n",port_id);
1800 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1801 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1802 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1806 /* DCB in VT mode */
1807 if (!strncmp(res->vt_en, "on",2))
1808 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1810 dcb_conf.dcb_mode = DCB_ENABLED;
1812 if (!strncmp(res->pfc_en, "on",2)) {
1813 dcb_conf.pfc_en = 1;
1816 dcb_conf.pfc_en = 0;
1818 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1819 printf("Cannot initialize network ports\n");
1823 cmd_reconfig_device_queue(port_id, 1, 1);
1826 cmdline_parse_token_string_t cmd_config_dcb_port =
1827 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1828 cmdline_parse_token_string_t cmd_config_dcb_config =
1829 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1830 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1831 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1832 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1833 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1834 cmdline_parse_token_string_t cmd_config_dcb_vt =
1835 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1836 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1838 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1839 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1840 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1842 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1843 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1845 cmdline_parse_inst_t cmd_config_dcb = {
1846 .f = cmd_config_dcb_parsed,
1848 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1850 (void *)&cmd_config_dcb_port,
1851 (void *)&cmd_config_dcb_config,
1852 (void *)&cmd_config_dcb_port_id,
1853 (void *)&cmd_config_dcb_dcb,
1854 (void *)&cmd_config_dcb_vt,
1855 (void *)&cmd_config_dcb_vt_en,
1856 (void *)&cmd_config_dcb_num_tcs,
1857 (void *)&cmd_config_dcb_pfc,
1858 (void *)&cmd_config_dcb_pfc_en,
1863 /* *** configure number of packets per burst *** */
1864 struct cmd_config_burst {
1865 cmdline_fixed_string_t port;
1866 cmdline_fixed_string_t keyword;
1867 cmdline_fixed_string_t all;
1868 cmdline_fixed_string_t name;
1873 cmd_config_burst_parsed(void *parsed_result,
1874 __attribute__((unused)) struct cmdline *cl,
1875 __attribute__((unused)) void *data)
1877 struct cmd_config_burst *res = parsed_result;
1879 if (!all_ports_stopped()) {
1880 printf("Please stop all ports first\n");
1884 if (!strcmp(res->name, "burst")) {
1885 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1886 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1889 nb_pkt_per_burst = res->value;
1891 printf("Unknown parameter\n");
1897 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1900 cmdline_parse_token_string_t cmd_config_burst_port =
1901 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1902 cmdline_parse_token_string_t cmd_config_burst_keyword =
1903 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1904 cmdline_parse_token_string_t cmd_config_burst_all =
1905 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1906 cmdline_parse_token_string_t cmd_config_burst_name =
1907 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1908 cmdline_parse_token_num_t cmd_config_burst_value =
1909 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1911 cmdline_parse_inst_t cmd_config_burst = {
1912 .f = cmd_config_burst_parsed,
1914 .help_str = "port config all burst value",
1916 (void *)&cmd_config_burst_port,
1917 (void *)&cmd_config_burst_keyword,
1918 (void *)&cmd_config_burst_all,
1919 (void *)&cmd_config_burst_name,
1920 (void *)&cmd_config_burst_value,
1925 /* *** configure rx/tx queues *** */
1926 struct cmd_config_thresh {
1927 cmdline_fixed_string_t port;
1928 cmdline_fixed_string_t keyword;
1929 cmdline_fixed_string_t all;
1930 cmdline_fixed_string_t name;
1935 cmd_config_thresh_parsed(void *parsed_result,
1936 __attribute__((unused)) struct cmdline *cl,
1937 __attribute__((unused)) void *data)
1939 struct cmd_config_thresh *res = parsed_result;
1941 if (!all_ports_stopped()) {
1942 printf("Please stop all ports first\n");
1946 if (!strcmp(res->name, "txpt"))
1947 tx_thresh.pthresh = res->value;
1948 else if(!strcmp(res->name, "txht"))
1949 tx_thresh.hthresh = res->value;
1950 else if(!strcmp(res->name, "txwt"))
1951 tx_thresh.wthresh = res->value;
1952 else if(!strcmp(res->name, "rxpt"))
1953 rx_thresh.pthresh = res->value;
1954 else if(!strcmp(res->name, "rxht"))
1955 rx_thresh.hthresh = res->value;
1956 else if(!strcmp(res->name, "rxwt"))
1957 rx_thresh.wthresh = res->value;
1959 printf("Unknown parameter\n");
1965 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1968 cmdline_parse_token_string_t cmd_config_thresh_port =
1969 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1970 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1971 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1972 cmdline_parse_token_string_t cmd_config_thresh_all =
1973 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1974 cmdline_parse_token_string_t cmd_config_thresh_name =
1975 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1976 "txpt#txht#txwt#rxpt#rxht#rxwt");
1977 cmdline_parse_token_num_t cmd_config_thresh_value =
1978 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1980 cmdline_parse_inst_t cmd_config_thresh = {
1981 .f = cmd_config_thresh_parsed,
1983 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1985 (void *)&cmd_config_thresh_port,
1986 (void *)&cmd_config_thresh_keyword,
1987 (void *)&cmd_config_thresh_all,
1988 (void *)&cmd_config_thresh_name,
1989 (void *)&cmd_config_thresh_value,
1994 /* *** configure free/rs threshold *** */
1995 struct cmd_config_threshold {
1996 cmdline_fixed_string_t port;
1997 cmdline_fixed_string_t keyword;
1998 cmdline_fixed_string_t all;
1999 cmdline_fixed_string_t name;
2004 cmd_config_threshold_parsed(void *parsed_result,
2005 __attribute__((unused)) struct cmdline *cl,
2006 __attribute__((unused)) void *data)
2008 struct cmd_config_threshold *res = parsed_result;
2010 if (!all_ports_stopped()) {
2011 printf("Please stop all ports first\n");
2015 if (!strcmp(res->name, "txfreet"))
2016 tx_free_thresh = res->value;
2017 else if (!strcmp(res->name, "txrst"))
2018 tx_rs_thresh = res->value;
2019 else if (!strcmp(res->name, "rxfreet"))
2020 rx_free_thresh = res->value;
2022 printf("Unknown parameter\n");
2028 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2031 cmdline_parse_token_string_t cmd_config_threshold_port =
2032 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2033 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2034 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2036 cmdline_parse_token_string_t cmd_config_threshold_all =
2037 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2038 cmdline_parse_token_string_t cmd_config_threshold_name =
2039 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2040 "txfreet#txrst#rxfreet");
2041 cmdline_parse_token_num_t cmd_config_threshold_value =
2042 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2044 cmdline_parse_inst_t cmd_config_threshold = {
2045 .f = cmd_config_threshold_parsed,
2047 .help_str = "port config all txfreet|txrst|rxfreet value",
2049 (void *)&cmd_config_threshold_port,
2050 (void *)&cmd_config_threshold_keyword,
2051 (void *)&cmd_config_threshold_all,
2052 (void *)&cmd_config_threshold_name,
2053 (void *)&cmd_config_threshold_value,
2059 struct cmd_stop_result {
2060 cmdline_fixed_string_t stop;
2063 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2064 __attribute__((unused)) struct cmdline *cl,
2065 __attribute__((unused)) void *data)
2067 stop_packet_forwarding();
2070 cmdline_parse_token_string_t cmd_stop_stop =
2071 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2073 cmdline_parse_inst_t cmd_stop = {
2074 .f = cmd_stop_parsed,
2076 .help_str = "stop - stop packet forwarding",
2078 (void *)&cmd_stop_stop,
2083 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2086 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2087 unsigned int *parsed_items, int check_unique_values)
2089 unsigned int nb_item;
2097 * First parse all items in the list and store their value.
2102 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2104 if ((c >= '0') && (c <= '9')) {
2105 value = (unsigned int) (value * 10 + (c - '0'));
2110 printf("character %c is not a decimal digit\n", c);
2114 printf("No valid value before comma\n");
2117 if (nb_item < max_items) {
2118 parsed_items[nb_item] = value;
2124 if (nb_item >= max_items) {
2125 printf("Number of %s = %u > %u (maximum items)\n",
2126 item_name, nb_item + 1, max_items);
2129 parsed_items[nb_item++] = value;
2130 if (! check_unique_values)
2134 * Then, check that all values in the list are differents.
2135 * No optimization here...
2137 for (i = 0; i < nb_item; i++) {
2138 for (j = i + 1; j < nb_item; j++) {
2139 if (parsed_items[j] == parsed_items[i]) {
2140 printf("duplicated %s %u at index %u and %u\n",
2141 item_name, parsed_items[i], i, j);
2149 struct cmd_set_list_result {
2150 cmdline_fixed_string_t cmd_keyword;
2151 cmdline_fixed_string_t list_name;
2152 cmdline_fixed_string_t list_of_items;
2155 static void cmd_set_list_parsed(void *parsed_result,
2156 __attribute__((unused)) struct cmdline *cl,
2157 __attribute__((unused)) void *data)
2159 struct cmd_set_list_result *res;
2161 unsigned int lcorelist[RTE_MAX_LCORE];
2162 unsigned int portlist[RTE_MAX_ETHPORTS];
2164 unsigned int nb_item;
2166 res = parsed_result;
2167 if (!strcmp(res->list_name, "corelist")) {
2168 nb_item = parse_item_list(res->list_of_items, "core",
2170 parsed_items.lcorelist, 1);
2172 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2175 if (!strcmp(res->list_name, "portlist")) {
2176 nb_item = parse_item_list(res->list_of_items, "port",
2178 parsed_items.portlist, 1);
2180 set_fwd_ports_list(parsed_items.portlist, nb_item);
2184 cmdline_parse_token_string_t cmd_set_list_keyword =
2185 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2187 cmdline_parse_token_string_t cmd_set_list_name =
2188 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2189 "corelist#portlist");
2190 cmdline_parse_token_string_t cmd_set_list_of_items =
2191 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2194 cmdline_parse_inst_t cmd_set_fwd_list = {
2195 .f = cmd_set_list_parsed,
2197 .help_str = "set corelist|portlist x[,y]*",
2199 (void *)&cmd_set_list_keyword,
2200 (void *)&cmd_set_list_name,
2201 (void *)&cmd_set_list_of_items,
2206 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2208 struct cmd_setmask_result {
2209 cmdline_fixed_string_t set;
2210 cmdline_fixed_string_t mask;
2214 static void cmd_set_mask_parsed(void *parsed_result,
2215 __attribute__((unused)) struct cmdline *cl,
2216 __attribute__((unused)) void *data)
2218 struct cmd_setmask_result *res = parsed_result;
2220 if (!strcmp(res->mask, "coremask"))
2221 set_fwd_lcores_mask(res->hexavalue);
2222 else if (!strcmp(res->mask, "portmask"))
2223 set_fwd_ports_mask(res->hexavalue);
2226 cmdline_parse_token_string_t cmd_setmask_set =
2227 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2228 cmdline_parse_token_string_t cmd_setmask_mask =
2229 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2230 "coremask#portmask");
2231 cmdline_parse_token_num_t cmd_setmask_value =
2232 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2234 cmdline_parse_inst_t cmd_set_fwd_mask = {
2235 .f = cmd_set_mask_parsed,
2237 .help_str = "set coremask|portmask hexadecimal value",
2239 (void *)&cmd_setmask_set,
2240 (void *)&cmd_setmask_mask,
2241 (void *)&cmd_setmask_value,
2247 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2249 struct cmd_set_result {
2250 cmdline_fixed_string_t set;
2251 cmdline_fixed_string_t what;
2255 static void cmd_set_parsed(void *parsed_result,
2256 __attribute__((unused)) struct cmdline *cl,
2257 __attribute__((unused)) void *data)
2259 struct cmd_set_result *res = parsed_result;
2260 if (!strcmp(res->what, "nbport"))
2261 set_fwd_ports_number(res->value);
2262 else if (!strcmp(res->what, "nbcore"))
2263 set_fwd_lcores_number(res->value);
2264 else if (!strcmp(res->what, "burst"))
2265 set_nb_pkt_per_burst(res->value);
2266 else if (!strcmp(res->what, "verbose"))
2267 set_verbose_level(res->value);
2270 cmdline_parse_token_string_t cmd_set_set =
2271 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2272 cmdline_parse_token_string_t cmd_set_what =
2273 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2274 "nbport#nbcore#burst#verbose");
2275 cmdline_parse_token_num_t cmd_set_value =
2276 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2278 cmdline_parse_inst_t cmd_set_numbers = {
2279 .f = cmd_set_parsed,
2281 .help_str = "set nbport|nbcore|burst|verbose value",
2283 (void *)&cmd_set_set,
2284 (void *)&cmd_set_what,
2285 (void *)&cmd_set_value,
2290 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2292 struct cmd_set_txpkts_result {
2293 cmdline_fixed_string_t cmd_keyword;
2294 cmdline_fixed_string_t txpkts;
2295 cmdline_fixed_string_t seg_lengths;
2299 cmd_set_txpkts_parsed(void *parsed_result,
2300 __attribute__((unused)) struct cmdline *cl,
2301 __attribute__((unused)) void *data)
2303 struct cmd_set_txpkts_result *res;
2304 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2305 unsigned int nb_segs;
2307 res = parsed_result;
2308 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2309 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2311 set_tx_pkt_segments(seg_lengths, nb_segs);
2314 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2315 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2316 cmd_keyword, "set");
2317 cmdline_parse_token_string_t cmd_set_txpkts_name =
2318 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2320 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2321 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2324 cmdline_parse_inst_t cmd_set_txpkts = {
2325 .f = cmd_set_txpkts_parsed,
2327 .help_str = "set txpkts x[,y]*",
2329 (void *)&cmd_set_txpkts_keyword,
2330 (void *)&cmd_set_txpkts_name,
2331 (void *)&cmd_set_txpkts_lengths,
2336 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2337 struct cmd_rx_vlan_filter_all_result {
2338 cmdline_fixed_string_t rx_vlan;
2339 cmdline_fixed_string_t what;
2340 cmdline_fixed_string_t all;
2345 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2346 __attribute__((unused)) struct cmdline *cl,
2347 __attribute__((unused)) void *data)
2349 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2351 if (!strcmp(res->what, "add"))
2352 rx_vlan_all_filter_set(res->port_id, 1);
2354 rx_vlan_all_filter_set(res->port_id, 0);
2357 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2358 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2359 rx_vlan, "rx_vlan");
2360 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2361 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2363 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2364 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2366 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2367 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2370 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2371 .f = cmd_rx_vlan_filter_all_parsed,
2373 .help_str = "add/remove all identifiers to/from the set of VLAN "
2374 "Identifiers filtered by a port",
2376 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2377 (void *)&cmd_rx_vlan_filter_all_what,
2378 (void *)&cmd_rx_vlan_filter_all_all,
2379 (void *)&cmd_rx_vlan_filter_all_portid,
2384 /* *** VLAN OFFLOAD SET ON A PORT *** */
2385 struct cmd_vlan_offload_result {
2386 cmdline_fixed_string_t vlan;
2387 cmdline_fixed_string_t set;
2388 cmdline_fixed_string_t what;
2389 cmdline_fixed_string_t on;
2390 cmdline_fixed_string_t port_id;
2394 cmd_vlan_offload_parsed(void *parsed_result,
2395 __attribute__((unused)) struct cmdline *cl,
2396 __attribute__((unused)) void *data)
2399 struct cmd_vlan_offload_result *res = parsed_result;
2402 portid_t port_id = 0;
2406 len = strnlen(str, STR_TOKEN_SIZE);
2408 /* Get port_id first */
2416 tmp = strtoul(str, NULL, 0);
2417 /* If port_id greater that what portid_t can represent, return */
2418 if(tmp >= RTE_MAX_ETHPORTS)
2420 port_id = (portid_t)tmp;
2422 if (!strcmp(res->on, "on"))
2427 if (!strcmp(res->what, "strip"))
2428 rx_vlan_strip_set(port_id, on);
2429 else if(!strcmp(res->what, "stripq")){
2430 uint16_t queue_id = 0;
2432 /* No queue_id, return */
2434 printf("must specify (port,queue_id)\n");
2437 tmp = strtoul(str + i + 1, NULL, 0);
2438 /* If queue_id greater that what 16-bits can represent, return */
2442 queue_id = (uint16_t)tmp;
2443 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2445 else if (!strcmp(res->what, "filter"))
2446 rx_vlan_filter_set(port_id, on);
2448 vlan_extend_set(port_id, on);
2453 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2454 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2456 cmdline_parse_token_string_t cmd_vlan_offload_set =
2457 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2459 cmdline_parse_token_string_t cmd_vlan_offload_what =
2460 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2461 what, "strip#filter#qinq#stripq");
2462 cmdline_parse_token_string_t cmd_vlan_offload_on =
2463 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2465 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2466 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2469 cmdline_parse_inst_t cmd_vlan_offload = {
2470 .f = cmd_vlan_offload_parsed,
2472 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2473 " qinq(extended) for both rx/tx sides ",
2475 (void *)&cmd_vlan_offload_vlan,
2476 (void *)&cmd_vlan_offload_set,
2477 (void *)&cmd_vlan_offload_what,
2478 (void *)&cmd_vlan_offload_on,
2479 (void *)&cmd_vlan_offload_portid,
2484 /* *** VLAN TPID SET ON A PORT *** */
2485 struct cmd_vlan_tpid_result {
2486 cmdline_fixed_string_t vlan;
2487 cmdline_fixed_string_t set;
2488 cmdline_fixed_string_t what;
2494 cmd_vlan_tpid_parsed(void *parsed_result,
2495 __attribute__((unused)) struct cmdline *cl,
2496 __attribute__((unused)) void *data)
2498 struct cmd_vlan_tpid_result *res = parsed_result;
2499 vlan_tpid_set(res->port_id, res->tp_id);
2503 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2504 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2506 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2507 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2509 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2510 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2512 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2513 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2515 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2516 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2519 cmdline_parse_inst_t cmd_vlan_tpid = {
2520 .f = cmd_vlan_tpid_parsed,
2522 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2524 (void *)&cmd_vlan_tpid_vlan,
2525 (void *)&cmd_vlan_tpid_set,
2526 (void *)&cmd_vlan_tpid_what,
2527 (void *)&cmd_vlan_tpid_tpid,
2528 (void *)&cmd_vlan_tpid_portid,
2533 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2534 struct cmd_rx_vlan_filter_result {
2535 cmdline_fixed_string_t rx_vlan;
2536 cmdline_fixed_string_t what;
2542 cmd_rx_vlan_filter_parsed(void *parsed_result,
2543 __attribute__((unused)) struct cmdline *cl,
2544 __attribute__((unused)) void *data)
2546 struct cmd_rx_vlan_filter_result *res = parsed_result;
2548 if (!strcmp(res->what, "add"))
2549 rx_vft_set(res->port_id, res->vlan_id, 1);
2551 rx_vft_set(res->port_id, res->vlan_id, 0);
2554 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2555 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2556 rx_vlan, "rx_vlan");
2557 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2558 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2560 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2561 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2563 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2564 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2567 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2568 .f = cmd_rx_vlan_filter_parsed,
2570 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2571 "Identifiers filtered by a port",
2573 (void *)&cmd_rx_vlan_filter_rx_vlan,
2574 (void *)&cmd_rx_vlan_filter_what,
2575 (void *)&cmd_rx_vlan_filter_vlanid,
2576 (void *)&cmd_rx_vlan_filter_portid,
2581 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2582 struct cmd_tx_vlan_set_result {
2583 cmdline_fixed_string_t tx_vlan;
2584 cmdline_fixed_string_t set;
2590 cmd_tx_vlan_set_parsed(void *parsed_result,
2591 __attribute__((unused)) struct cmdline *cl,
2592 __attribute__((unused)) void *data)
2594 struct cmd_tx_vlan_set_result *res = parsed_result;
2595 tx_vlan_set(res->port_id, res->vlan_id);
2598 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2599 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2600 tx_vlan, "tx_vlan");
2601 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2602 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2604 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2605 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2607 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2608 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2611 cmdline_parse_inst_t cmd_tx_vlan_set = {
2612 .f = cmd_tx_vlan_set_parsed,
2614 .help_str = "enable hardware insertion of a VLAN header with a given "
2615 "TAG Identifier in packets sent on a port",
2617 (void *)&cmd_tx_vlan_set_tx_vlan,
2618 (void *)&cmd_tx_vlan_set_set,
2619 (void *)&cmd_tx_vlan_set_vlanid,
2620 (void *)&cmd_tx_vlan_set_portid,
2625 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2626 struct cmd_tx_vlan_set_pvid_result {
2627 cmdline_fixed_string_t tx_vlan;
2628 cmdline_fixed_string_t set;
2629 cmdline_fixed_string_t pvid;
2632 cmdline_fixed_string_t mode;
2636 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2637 __attribute__((unused)) struct cmdline *cl,
2638 __attribute__((unused)) void *data)
2640 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2642 if (strcmp(res->mode, "on") == 0)
2643 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2645 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2648 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2649 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2650 tx_vlan, "tx_vlan");
2651 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2652 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2654 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2655 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2657 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2658 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2660 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2661 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2663 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2664 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2667 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2668 .f = cmd_tx_vlan_set_pvid_parsed,
2670 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2672 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2673 (void *)&cmd_tx_vlan_set_pvid_set,
2674 (void *)&cmd_tx_vlan_set_pvid_pvid,
2675 (void *)&cmd_tx_vlan_set_pvid_port_id,
2676 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2677 (void *)&cmd_tx_vlan_set_pvid_mode,
2682 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2683 struct cmd_tx_vlan_reset_result {
2684 cmdline_fixed_string_t tx_vlan;
2685 cmdline_fixed_string_t reset;
2690 cmd_tx_vlan_reset_parsed(void *parsed_result,
2691 __attribute__((unused)) struct cmdline *cl,
2692 __attribute__((unused)) void *data)
2694 struct cmd_tx_vlan_reset_result *res = parsed_result;
2696 tx_vlan_reset(res->port_id);
2699 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2700 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2701 tx_vlan, "tx_vlan");
2702 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2703 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2705 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2706 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2709 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2710 .f = cmd_tx_vlan_reset_parsed,
2712 .help_str = "disable hardware insertion of a VLAN header in packets "
2715 (void *)&cmd_tx_vlan_reset_tx_vlan,
2716 (void *)&cmd_tx_vlan_reset_reset,
2717 (void *)&cmd_tx_vlan_reset_portid,
2723 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2724 struct cmd_tx_cksum_set_result {
2725 cmdline_fixed_string_t tx_cksum;
2726 cmdline_fixed_string_t set;
2732 cmd_tx_cksum_set_parsed(void *parsed_result,
2733 __attribute__((unused)) struct cmdline *cl,
2734 __attribute__((unused)) void *data)
2736 struct cmd_tx_cksum_set_result *res = parsed_result;
2738 tx_cksum_set(res->port_id, res->cksum_mask);
2741 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2742 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2743 tx_cksum, "tx_checksum");
2744 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2745 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2747 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2748 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2750 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2751 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2754 cmdline_parse_inst_t cmd_tx_cksum_set = {
2755 .f = cmd_tx_cksum_set_parsed,
2757 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2758 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2759 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2761 (void *)&cmd_tx_cksum_set_tx_cksum,
2762 (void *)&cmd_tx_cksum_set_set,
2763 (void *)&cmd_tx_cksum_set_cksum_mask,
2764 (void *)&cmd_tx_cksum_set_portid,
2769 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2770 struct cmd_set_flush_rx {
2771 cmdline_fixed_string_t set;
2772 cmdline_fixed_string_t flush_rx;
2773 cmdline_fixed_string_t mode;
2777 cmd_set_flush_rx_parsed(void *parsed_result,
2778 __attribute__((unused)) struct cmdline *cl,
2779 __attribute__((unused)) void *data)
2781 struct cmd_set_flush_rx *res = parsed_result;
2782 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2785 cmdline_parse_token_string_t cmd_setflushrx_set =
2786 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2788 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2789 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2790 flush_rx, "flush_rx");
2791 cmdline_parse_token_string_t cmd_setflushrx_mode =
2792 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2796 cmdline_parse_inst_t cmd_set_flush_rx = {
2797 .f = cmd_set_flush_rx_parsed,
2798 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2801 (void *)&cmd_setflushrx_set,
2802 (void *)&cmd_setflushrx_flush_rx,
2803 (void *)&cmd_setflushrx_mode,
2808 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2809 struct cmd_set_link_check {
2810 cmdline_fixed_string_t set;
2811 cmdline_fixed_string_t link_check;
2812 cmdline_fixed_string_t mode;
2816 cmd_set_link_check_parsed(void *parsed_result,
2817 __attribute__((unused)) struct cmdline *cl,
2818 __attribute__((unused)) void *data)
2820 struct cmd_set_link_check *res = parsed_result;
2821 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2824 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2825 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2827 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2828 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2829 link_check, "link_check");
2830 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2831 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2835 cmdline_parse_inst_t cmd_set_link_check = {
2836 .f = cmd_set_link_check_parsed,
2837 .help_str = "set link_check on|off: enable/disable link status check "
2838 "when starting/stopping a port",
2841 (void *)&cmd_setlinkcheck_set,
2842 (void *)&cmd_setlinkcheck_link_check,
2843 (void *)&cmd_setlinkcheck_mode,
2848 #ifdef RTE_NIC_BYPASS
2849 /* *** SET NIC BYPASS MODE *** */
2850 struct cmd_set_bypass_mode_result {
2851 cmdline_fixed_string_t set;
2852 cmdline_fixed_string_t bypass;
2853 cmdline_fixed_string_t mode;
2854 cmdline_fixed_string_t value;
2859 cmd_set_bypass_mode_parsed(void *parsed_result,
2860 __attribute__((unused)) struct cmdline *cl,
2861 __attribute__((unused)) void *data)
2863 struct cmd_set_bypass_mode_result *res = parsed_result;
2864 portid_t port_id = res->port_id;
2865 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2867 if (!bypass_is_supported(port_id))
2870 if (!strcmp(res->value, "bypass"))
2871 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2872 else if (!strcmp(res->value, "isolate"))
2873 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2875 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2877 /* Set the bypass mode for the relevant port. */
2878 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2879 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2883 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2884 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2886 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2887 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2889 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2890 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2892 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2893 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2894 value, "normal#bypass#isolate");
2895 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2896 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2899 cmdline_parse_inst_t cmd_set_bypass_mode = {
2900 .f = cmd_set_bypass_mode_parsed,
2901 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2902 "Set the NIC bypass mode for port_id",
2905 (void *)&cmd_setbypass_mode_set,
2906 (void *)&cmd_setbypass_mode_bypass,
2907 (void *)&cmd_setbypass_mode_mode,
2908 (void *)&cmd_setbypass_mode_value,
2909 (void *)&cmd_setbypass_mode_port,
2914 /* *** SET NIC BYPASS EVENT *** */
2915 struct cmd_set_bypass_event_result {
2916 cmdline_fixed_string_t set;
2917 cmdline_fixed_string_t bypass;
2918 cmdline_fixed_string_t event;
2919 cmdline_fixed_string_t event_value;
2920 cmdline_fixed_string_t mode;
2921 cmdline_fixed_string_t mode_value;
2926 cmd_set_bypass_event_parsed(void *parsed_result,
2927 __attribute__((unused)) struct cmdline *cl,
2928 __attribute__((unused)) void *data)
2931 struct cmd_set_bypass_event_result *res = parsed_result;
2932 portid_t port_id = res->port_id;
2933 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2934 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2936 if (!bypass_is_supported(port_id))
2939 if (!strcmp(res->event_value, "timeout"))
2940 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2941 else if (!strcmp(res->event_value, "os_on"))
2942 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2943 else if (!strcmp(res->event_value, "os_off"))
2944 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2945 else if (!strcmp(res->event_value, "power_on"))
2946 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2947 else if (!strcmp(res->event_value, "power_off"))
2948 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2950 bypass_event = RTE_BYPASS_EVENT_NONE;
2952 if (!strcmp(res->mode_value, "bypass"))
2953 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2954 else if (!strcmp(res->mode_value, "isolate"))
2955 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2957 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2959 /* Set the watchdog timeout. */
2960 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2963 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2964 (rc = rte_eth_dev_wd_timeout_store(port_id,
2965 bypass_timeout)) != 0) {
2966 printf("Failed to set timeout value %u "
2967 "for port %d, errto code: %d.\n",
2968 bypass_timeout, port_id, rc);
2972 /* Set the bypass event to transition to bypass mode. */
2973 if (0 != rte_eth_dev_bypass_event_store(port_id,
2974 bypass_event, bypass_mode)) {
2975 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2980 cmdline_parse_token_string_t cmd_setbypass_event_set =
2981 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2983 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2984 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2986 cmdline_parse_token_string_t cmd_setbypass_event_event =
2987 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2989 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2990 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2991 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2992 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2993 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2995 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2996 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2997 mode_value, "normal#bypass#isolate");
2998 cmdline_parse_token_num_t cmd_setbypass_event_port =
2999 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3002 cmdline_parse_inst_t cmd_set_bypass_event = {
3003 .f = cmd_set_bypass_event_parsed,
3004 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3005 "mode (normal|bypass|isolate) (port_id): "
3006 "Set the NIC bypass event mode for port_id",
3009 (void *)&cmd_setbypass_event_set,
3010 (void *)&cmd_setbypass_event_bypass,
3011 (void *)&cmd_setbypass_event_event,
3012 (void *)&cmd_setbypass_event_event_value,
3013 (void *)&cmd_setbypass_event_mode,
3014 (void *)&cmd_setbypass_event_mode_value,
3015 (void *)&cmd_setbypass_event_port,
3021 /* *** SET NIC BYPASS TIMEOUT *** */
3022 struct cmd_set_bypass_timeout_result {
3023 cmdline_fixed_string_t set;
3024 cmdline_fixed_string_t bypass;
3025 cmdline_fixed_string_t timeout;
3026 cmdline_fixed_string_t value;
3030 cmd_set_bypass_timeout_parsed(void *parsed_result,
3031 __attribute__((unused)) struct cmdline *cl,
3032 __attribute__((unused)) void *data)
3034 struct cmd_set_bypass_timeout_result *res = parsed_result;
3036 if (!strcmp(res->value, "1.5"))
3037 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3038 else if (!strcmp(res->value, "2"))
3039 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3040 else if (!strcmp(res->value, "3"))
3041 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3042 else if (!strcmp(res->value, "4"))
3043 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3044 else if (!strcmp(res->value, "8"))
3045 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3046 else if (!strcmp(res->value, "16"))
3047 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3048 else if (!strcmp(res->value, "32"))
3049 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3051 bypass_timeout = RTE_BYPASS_TMT_OFF;
3054 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3055 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3057 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3058 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3060 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3061 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3062 timeout, "timeout");
3063 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3064 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3065 value, "0#1.5#2#3#4#8#16#32");
3067 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3068 .f = cmd_set_bypass_timeout_parsed,
3069 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3070 "Set the NIC bypass watchdog timeout",
3073 (void *)&cmd_setbypass_timeout_set,
3074 (void *)&cmd_setbypass_timeout_bypass,
3075 (void *)&cmd_setbypass_timeout_timeout,
3076 (void *)&cmd_setbypass_timeout_value,
3081 /* *** SHOW NIC BYPASS MODE *** */
3082 struct cmd_show_bypass_config_result {
3083 cmdline_fixed_string_t show;
3084 cmdline_fixed_string_t bypass;
3085 cmdline_fixed_string_t config;
3090 cmd_show_bypass_config_parsed(void *parsed_result,
3091 __attribute__((unused)) struct cmdline *cl,
3092 __attribute__((unused)) void *data)
3094 struct cmd_show_bypass_config_result *res = parsed_result;
3095 uint32_t event_mode;
3096 uint32_t bypass_mode;
3097 portid_t port_id = res->port_id;
3098 uint32_t timeout = bypass_timeout;
3101 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3102 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3103 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3104 {"UNKNOWN", "normal", "bypass", "isolate"};
3105 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3112 int num_events = (sizeof events) / (sizeof events[0]);
3114 if (!bypass_is_supported(port_id))
3117 /* Display the bypass mode.*/
3118 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3119 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3123 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3124 bypass_mode = RTE_BYPASS_MODE_NONE;
3126 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3129 /* Display the bypass timeout.*/
3130 if (!RTE_BYPASS_TMT_VALID(timeout))
3131 timeout = RTE_BYPASS_TMT_OFF;
3133 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3135 /* Display the bypass events and associated modes. */
3136 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3138 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3139 printf("\tFailed to get bypass mode for event = %s\n",
3142 if (!RTE_BYPASS_MODE_VALID(event_mode))
3143 event_mode = RTE_BYPASS_MODE_NONE;
3145 printf("\tbypass event: %-16s = %s\n", events[i],
3151 cmdline_parse_token_string_t cmd_showbypass_config_show =
3152 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3154 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3155 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3157 cmdline_parse_token_string_t cmd_showbypass_config_config =
3158 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3160 cmdline_parse_token_num_t cmd_showbypass_config_port =
3161 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3164 cmdline_parse_inst_t cmd_show_bypass_config = {
3165 .f = cmd_show_bypass_config_parsed,
3166 .help_str = "show bypass config (port_id): "
3167 "Show the NIC bypass config for port_id",
3170 (void *)&cmd_showbypass_config_show,
3171 (void *)&cmd_showbypass_config_bypass,
3172 (void *)&cmd_showbypass_config_config,
3173 (void *)&cmd_showbypass_config_port,
3179 #ifdef RTE_LIBRTE_PMD_BOND
3180 /* *** SET BONDING MODE *** */
3181 struct cmd_set_bonding_mode_result {
3182 cmdline_fixed_string_t set;
3183 cmdline_fixed_string_t bonding;
3184 cmdline_fixed_string_t mode;
3189 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3190 __attribute__((unused)) struct cmdline *cl,
3191 __attribute__((unused)) void *data)
3193 struct cmd_set_bonding_mode_result *res = parsed_result;
3194 portid_t port_id = res->port_id;
3196 /* Set the bonding mode for the relevant port. */
3197 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3198 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3201 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3202 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3204 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3205 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3206 bonding, "bonding");
3207 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3208 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3210 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3211 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3213 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3214 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3217 cmdline_parse_inst_t cmd_set_bonding_mode = {
3218 .f = cmd_set_bonding_mode_parsed,
3219 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3222 (void *) &cmd_setbonding_mode_set,
3223 (void *) &cmd_setbonding_mode_bonding,
3224 (void *) &cmd_setbonding_mode_mode,
3225 (void *) &cmd_setbonding_mode_value,
3226 (void *) &cmd_setbonding_mode_port,
3231 /* *** SET BALANCE XMIT POLICY *** */
3232 struct cmd_set_bonding_balance_xmit_policy_result {
3233 cmdline_fixed_string_t set;
3234 cmdline_fixed_string_t bonding;
3235 cmdline_fixed_string_t balance_xmit_policy;
3237 cmdline_fixed_string_t policy;
3240 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3241 __attribute__((unused)) struct cmdline *cl,
3242 __attribute__((unused)) void *data)
3244 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3245 portid_t port_id = res->port_id;
3248 if (!strcmp(res->policy, "l2")) {
3249 policy = BALANCE_XMIT_POLICY_LAYER2;
3250 } else if (!strcmp(res->policy, "l23")) {
3251 policy = BALANCE_XMIT_POLICY_LAYER23;
3252 } else if (!strcmp(res->policy, "l34")) {
3253 policy = BALANCE_XMIT_POLICY_LAYER34;
3255 printf("\t Invalid xmit policy selection");
3259 /* Set the bonding mode for the relevant port. */
3260 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3261 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3266 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3267 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3269 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3270 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3271 bonding, "bonding");
3272 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3273 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3274 balance_xmit_policy, "balance_xmit_policy");
3275 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3276 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3278 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3279 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3280 policy, "l2#l23#l34");
3282 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3283 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3284 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3287 (void *)&cmd_setbonding_balance_xmit_policy_set,
3288 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3289 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3290 (void *)&cmd_setbonding_balance_xmit_policy_port,
3291 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3296 /* *** SHOW NIC BONDING CONFIGURATION *** */
3297 struct cmd_show_bonding_config_result {
3298 cmdline_fixed_string_t show;
3299 cmdline_fixed_string_t bonding;
3300 cmdline_fixed_string_t config;
3304 static void cmd_show_bonding_config_parsed(void *parsed_result,
3305 __attribute__((unused)) struct cmdline *cl,
3306 __attribute__((unused)) void *data)
3308 struct cmd_show_bonding_config_result *res = parsed_result;
3310 uint8_t slaves[RTE_MAX_ETHPORTS];
3311 int num_slaves, num_active_slaves;
3314 portid_t port_id = res->port_id;
3316 /* Display the bonding mode.*/
3317 bonding_mode = rte_eth_bond_mode_get(port_id);
3318 if (bonding_mode < 0) {
3319 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3322 printf("\tBonding mode: %d\n", bonding_mode);
3324 if (bonding_mode == BONDING_MODE_BALANCE) {
3325 int balance_xmit_policy;
3327 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3328 if (balance_xmit_policy < 0) {
3329 printf("\tFailed to get balance xmit policy for port = %d\n",
3333 printf("\tBalance Xmit Policy: ");
3335 switch (balance_xmit_policy) {
3336 case BALANCE_XMIT_POLICY_LAYER2:
3337 printf("BALANCE_XMIT_POLICY_LAYER2");
3339 case BALANCE_XMIT_POLICY_LAYER23:
3340 printf("BALANCE_XMIT_POLICY_LAYER23");
3342 case BALANCE_XMIT_POLICY_LAYER34:
3343 printf("BALANCE_XMIT_POLICY_LAYER34");
3350 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3352 if (num_slaves < 0) {
3353 printf("\tFailed to get slave list for port = %d\n", port_id);
3356 if (num_slaves > 0) {
3357 printf("\tSlaves (%d): [", num_slaves);
3358 for (i = 0; i < num_slaves - 1; i++)
3359 printf("%d ", slaves[i]);
3361 printf("%d]\n", slaves[num_slaves - 1]);
3363 printf("\tSlaves: []\n");
3367 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3370 if (num_active_slaves < 0) {
3371 printf("\tFailed to get active slave list for port = %d\n", port_id);
3374 if (num_active_slaves > 0) {
3375 printf("\tActive Slaves (%d): [", num_active_slaves);
3376 for (i = 0; i < num_active_slaves - 1; i++)
3377 printf("%d ", slaves[i]);
3379 printf("%d]\n", slaves[num_active_slaves - 1]);
3382 printf("\tActive Slaves: []\n");
3386 primary_id = rte_eth_bond_primary_get(port_id);
3387 if (primary_id < 0) {
3388 printf("\tFailed to get primary slave for port = %d\n", port_id);
3391 printf("\tPrimary: [%d]\n", primary_id);
3395 cmdline_parse_token_string_t cmd_showbonding_config_show =
3396 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3398 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3399 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3400 bonding, "bonding");
3401 cmdline_parse_token_string_t cmd_showbonding_config_config =
3402 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3404 cmdline_parse_token_num_t cmd_showbonding_config_port =
3405 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3408 cmdline_parse_inst_t cmd_show_bonding_config = {
3409 .f = cmd_show_bonding_config_parsed,
3410 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3413 (void *)&cmd_showbonding_config_show,
3414 (void *)&cmd_showbonding_config_bonding,
3415 (void *)&cmd_showbonding_config_config,
3416 (void *)&cmd_showbonding_config_port,
3421 /* *** SET BONDING PRIMARY *** */
3422 struct cmd_set_bonding_primary_result {
3423 cmdline_fixed_string_t set;
3424 cmdline_fixed_string_t bonding;
3425 cmdline_fixed_string_t primary;
3430 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3431 __attribute__((unused)) struct cmdline *cl,
3432 __attribute__((unused)) void *data)
3434 struct cmd_set_bonding_primary_result *res = parsed_result;
3435 portid_t master_port_id = res->port_id;
3436 portid_t slave_port_id = res->slave_id;
3438 /* Set the primary slave for a bonded device. */
3439 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3440 printf("\t Failed to set primary slave for port = %d.\n",
3447 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3448 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3450 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3451 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3452 bonding, "bonding");
3453 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3454 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3455 primary, "primary");
3456 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3457 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3459 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3460 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3463 cmdline_parse_inst_t cmd_set_bonding_primary = {
3464 .f = cmd_set_bonding_primary_parsed,
3465 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3468 (void *)&cmd_setbonding_primary_set,
3469 (void *)&cmd_setbonding_primary_bonding,
3470 (void *)&cmd_setbonding_primary_primary,
3471 (void *)&cmd_setbonding_primary_slave,
3472 (void *)&cmd_setbonding_primary_port,
3477 /* *** ADD SLAVE *** */
3478 struct cmd_add_bonding_slave_result {
3479 cmdline_fixed_string_t add;
3480 cmdline_fixed_string_t bonding;
3481 cmdline_fixed_string_t slave;
3486 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3487 __attribute__((unused)) struct cmdline *cl,
3488 __attribute__((unused)) void *data)
3490 struct cmd_add_bonding_slave_result *res = parsed_result;
3491 portid_t master_port_id = res->port_id;
3492 portid_t slave_port_id = res->slave_id;
3494 /* Set the primary slave for a bonded device. */
3495 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3496 printf("\t Failed to add slave %d to master port = %d.\n",
3497 slave_port_id, master_port_id);
3503 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3504 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3506 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3507 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3508 bonding, "bonding");
3509 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3510 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3512 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3513 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3515 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3516 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3519 cmdline_parse_inst_t cmd_add_bonding_slave = {
3520 .f = cmd_add_bonding_slave_parsed,
3521 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3524 (void *)&cmd_addbonding_slave_add,
3525 (void *)&cmd_addbonding_slave_bonding,
3526 (void *)&cmd_addbonding_slave_slave,
3527 (void *)&cmd_addbonding_slave_slaveid,
3528 (void *)&cmd_addbonding_slave_port,
3533 /* *** REMOVE SLAVE *** */
3534 struct cmd_remove_bonding_slave_result {
3535 cmdline_fixed_string_t remove;
3536 cmdline_fixed_string_t bonding;
3537 cmdline_fixed_string_t slave;
3542 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3543 __attribute__((unused)) struct cmdline *cl,
3544 __attribute__((unused)) void *data)
3546 struct cmd_remove_bonding_slave_result *res = parsed_result;
3547 portid_t master_port_id = res->port_id;
3548 portid_t slave_port_id = res->slave_id;
3550 /* Set the primary slave for a bonded device. */
3551 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3552 printf("\t Failed to remove slave %d from master port = %d.\n",
3553 slave_port_id, master_port_id);
3559 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3560 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3562 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3563 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3564 bonding, "bonding");
3565 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3566 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3568 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3569 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3571 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3572 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3575 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3576 .f = cmd_remove_bonding_slave_parsed,
3577 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3580 (void *)&cmd_removebonding_slave_remove,
3581 (void *)&cmd_removebonding_slave_bonding,
3582 (void *)&cmd_removebonding_slave_slave,
3583 (void *)&cmd_removebonding_slave_slaveid,
3584 (void *)&cmd_removebonding_slave_port,
3589 /* *** CREATE BONDED DEVICE *** */
3590 struct cmd_create_bonded_device_result {
3591 cmdline_fixed_string_t create;
3592 cmdline_fixed_string_t bonded;
3593 cmdline_fixed_string_t device;
3598 static int bond_dev_num = 0;
3600 static void cmd_create_bonded_device_parsed(void *parsed_result,
3601 __attribute__((unused)) struct cmdline *cl,
3602 __attribute__((unused)) void *data)
3604 struct cmd_create_bonded_device_result *res = parsed_result;
3605 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3608 if (test_done == 0) {
3609 printf("Please stop forwarding first\n");
3613 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3616 /* Create a new bonded device. */
3617 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3619 printf("\t Failed to create bonded device.\n");
3622 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3625 /* Update number of ports */
3626 nb_ports = rte_eth_dev_count();
3628 rte_eth_promiscuous_enable(port_id);
3633 cmdline_parse_token_string_t cmd_createbonded_device_create =
3634 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3636 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3637 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3639 cmdline_parse_token_string_t cmd_createbonded_device_device =
3640 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3642 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3643 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3645 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3646 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3649 cmdline_parse_inst_t cmd_create_bonded_device = {
3650 .f = cmd_create_bonded_device_parsed,
3651 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3654 (void *)&cmd_createbonded_device_create,
3655 (void *)&cmd_createbonded_device_bonded,
3656 (void *)&cmd_createbonded_device_device,
3657 (void *)&cmd_createbonded_device_mode,
3658 (void *)&cmd_createbonded_device_socket,
3663 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3664 struct cmd_set_bond_mac_addr_result {
3665 cmdline_fixed_string_t set;
3666 cmdline_fixed_string_t bonding;
3667 cmdline_fixed_string_t mac_addr;
3669 struct ether_addr address;
3672 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3673 __attribute__((unused)) struct cmdline *cl,
3674 __attribute__((unused)) void *data)
3676 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3679 if (res->port_num >= nb_ports) {
3680 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3684 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3686 /* check the return value and print it if is < 0 */
3688 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3691 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3692 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3693 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3694 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3696 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3697 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3699 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3700 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3701 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3702 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3704 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3705 .f = cmd_set_bond_mac_addr_parsed,
3707 .help_str = "set bonding mac_addr (port_id) (address): ",
3709 (void *)&cmd_set_bond_mac_addr_set,
3710 (void *)&cmd_set_bond_mac_addr_bonding,
3711 (void *)&cmd_set_bond_mac_addr_mac,
3712 (void *)&cmd_set_bond_mac_addr_portnum,
3713 (void *)&cmd_set_bond_mac_addr_addr,
3718 #endif /* RTE_LIBRTE_PMD_BOND */
3720 /* *** SET FORWARDING MODE *** */
3721 struct cmd_set_fwd_mode_result {
3722 cmdline_fixed_string_t set;
3723 cmdline_fixed_string_t fwd;
3724 cmdline_fixed_string_t mode;
3727 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3728 __attribute__((unused)) struct cmdline *cl,
3729 __attribute__((unused)) void *data)
3731 struct cmd_set_fwd_mode_result *res = parsed_result;
3733 set_pkt_forwarding_mode(res->mode);
3736 cmdline_parse_token_string_t cmd_setfwd_set =
3737 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3738 cmdline_parse_token_string_t cmd_setfwd_fwd =
3739 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3740 cmdline_parse_token_string_t cmd_setfwd_mode =
3741 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3742 "" /* defined at init */);
3744 cmdline_parse_inst_t cmd_set_fwd_mode = {
3745 .f = cmd_set_fwd_mode_parsed,
3747 .help_str = NULL, /* defined at init */
3749 (void *)&cmd_setfwd_set,
3750 (void *)&cmd_setfwd_fwd,
3751 (void *)&cmd_setfwd_mode,
3756 static void cmd_set_fwd_mode_init(void)
3759 static char token[128];
3760 static char help[256];
3761 cmdline_parse_token_string_t *token_struct;
3763 modes = list_pkt_forwarding_modes();
3764 snprintf(help, sizeof help, "set fwd %s - "
3765 "set packet forwarding mode", modes);
3766 cmd_set_fwd_mode.help_str = help;
3768 /* string token separator is # */
3769 for (c = token; *modes != '\0'; modes++)
3774 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3775 token_struct->string_data.str = token;
3778 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3779 struct cmd_set_burst_tx_retry_result {
3780 cmdline_fixed_string_t set;
3781 cmdline_fixed_string_t burst;
3782 cmdline_fixed_string_t tx;
3783 cmdline_fixed_string_t delay;
3785 cmdline_fixed_string_t retry;
3789 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3790 __attribute__((unused)) struct cmdline *cl,
3791 __attribute__((unused)) void *data)
3793 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3795 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3796 && !strcmp(res->tx, "tx")) {
3797 if (!strcmp(res->delay, "delay"))
3798 burst_tx_delay_time = res->time;
3799 if (!strcmp(res->retry, "retry"))
3800 burst_tx_retry_num = res->retry_num;
3805 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3806 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3807 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3808 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3810 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3811 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3812 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3813 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3814 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3815 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3816 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3817 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3818 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3819 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3821 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3822 .f = cmd_set_burst_tx_retry_parsed,
3823 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3825 (void *)&cmd_set_burst_tx_retry_set,
3826 (void *)&cmd_set_burst_tx_retry_burst,
3827 (void *)&cmd_set_burst_tx_retry_tx,
3828 (void *)&cmd_set_burst_tx_retry_delay,
3829 (void *)&cmd_set_burst_tx_retry_time,
3830 (void *)&cmd_set_burst_tx_retry_retry,
3831 (void *)&cmd_set_burst_tx_retry_retry_num,
3836 /* *** SET PROMISC MODE *** */
3837 struct cmd_set_promisc_mode_result {
3838 cmdline_fixed_string_t set;
3839 cmdline_fixed_string_t promisc;
3840 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3841 uint8_t port_num; /* valid if "allports" argument == 0 */
3842 cmdline_fixed_string_t mode;
3845 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3846 __attribute__((unused)) struct cmdline *cl,
3849 struct cmd_set_promisc_mode_result *res = parsed_result;
3853 if (!strcmp(res->mode, "on"))
3860 for (i = 0; i < nb_ports; i++) {
3862 rte_eth_promiscuous_enable(i);
3864 rte_eth_promiscuous_disable(i);
3869 rte_eth_promiscuous_enable(res->port_num);
3871 rte_eth_promiscuous_disable(res->port_num);
3875 cmdline_parse_token_string_t cmd_setpromisc_set =
3876 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3877 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3878 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3880 cmdline_parse_token_string_t cmd_setpromisc_portall =
3881 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3883 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3884 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3886 cmdline_parse_token_string_t cmd_setpromisc_mode =
3887 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3890 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3891 .f = cmd_set_promisc_mode_parsed,
3893 .help_str = "set promisc all on|off: set promisc mode for all ports",
3895 (void *)&cmd_setpromisc_set,
3896 (void *)&cmd_setpromisc_promisc,
3897 (void *)&cmd_setpromisc_portall,
3898 (void *)&cmd_setpromisc_mode,
3903 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3904 .f = cmd_set_promisc_mode_parsed,
3906 .help_str = "set promisc X on|off: set promisc mode on port X",
3908 (void *)&cmd_setpromisc_set,
3909 (void *)&cmd_setpromisc_promisc,
3910 (void *)&cmd_setpromisc_portnum,
3911 (void *)&cmd_setpromisc_mode,
3916 /* *** SET ALLMULTI MODE *** */
3917 struct cmd_set_allmulti_mode_result {
3918 cmdline_fixed_string_t set;
3919 cmdline_fixed_string_t allmulti;
3920 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3921 uint8_t port_num; /* valid if "allports" argument == 0 */
3922 cmdline_fixed_string_t mode;
3925 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3926 __attribute__((unused)) struct cmdline *cl,
3929 struct cmd_set_allmulti_mode_result *res = parsed_result;
3933 if (!strcmp(res->mode, "on"))
3940 for (i = 0; i < nb_ports; i++) {
3942 rte_eth_allmulticast_enable(i);
3944 rte_eth_allmulticast_disable(i);
3949 rte_eth_allmulticast_enable(res->port_num);
3951 rte_eth_allmulticast_disable(res->port_num);
3955 cmdline_parse_token_string_t cmd_setallmulti_set =
3956 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3957 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3958 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3960 cmdline_parse_token_string_t cmd_setallmulti_portall =
3961 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3963 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3964 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3966 cmdline_parse_token_string_t cmd_setallmulti_mode =
3967 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3970 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3971 .f = cmd_set_allmulti_mode_parsed,
3973 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3975 (void *)&cmd_setallmulti_set,
3976 (void *)&cmd_setallmulti_allmulti,
3977 (void *)&cmd_setallmulti_portall,
3978 (void *)&cmd_setallmulti_mode,
3983 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3984 .f = cmd_set_allmulti_mode_parsed,
3986 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3988 (void *)&cmd_setallmulti_set,
3989 (void *)&cmd_setallmulti_allmulti,
3990 (void *)&cmd_setallmulti_portnum,
3991 (void *)&cmd_setallmulti_mode,
3996 /* *** ADD/REMOVE A PKT FILTER *** */
3997 struct cmd_pkt_filter_result {
3998 cmdline_fixed_string_t pkt_filter;
4000 cmdline_fixed_string_t protocol;
4001 cmdline_fixed_string_t src;
4002 cmdline_ipaddr_t ip_src;
4004 cmdline_fixed_string_t dst;
4005 cmdline_ipaddr_t ip_dst;
4007 cmdline_fixed_string_t flexbytes;
4008 uint16_t flexbytes_value;
4009 cmdline_fixed_string_t vlan;
4011 cmdline_fixed_string_t queue;
4013 cmdline_fixed_string_t soft;
4018 cmd_pkt_filter_parsed(void *parsed_result,
4019 __attribute__((unused)) struct cmdline *cl,
4020 __attribute__((unused)) void *data)
4022 struct rte_fdir_filter fdir_filter;
4023 struct cmd_pkt_filter_result *res = parsed_result;
4025 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4027 if (res->ip_src.family == AF_INET)
4028 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4030 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4031 &(res->ip_src.addr.ipv6),
4032 sizeof(struct in6_addr));
4034 if (res->ip_dst.family == AF_INET)
4035 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4037 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4038 &(res->ip_dst.addr.ipv6),
4039 sizeof(struct in6_addr));
4041 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4042 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4044 if (!strcmp(res->protocol, "udp"))
4045 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4046 else if (!strcmp(res->protocol, "tcp"))
4047 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4048 else if (!strcmp(res->protocol, "sctp"))
4049 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4050 else /* default only IP */
4051 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4053 if (res->ip_dst.family == AF_INET6)
4054 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4056 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4058 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4059 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4061 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4062 fdir_add_signature_filter(res->port_id, res->queue_id,
4064 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4065 fdir_update_signature_filter(res->port_id, res->queue_id,
4067 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4068 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4069 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4070 fdir_add_perfect_filter(res->port_id, res->soft_id,
4072 (uint8_t) (res->queue_id < 0),
4074 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4075 fdir_update_perfect_filter(res->port_id, res->soft_id,
4077 (uint8_t) (res->queue_id < 0),
4079 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4080 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4086 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4087 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4089 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4090 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4091 protocol, "ip#tcp#udp#sctp");
4092 cmdline_parse_token_string_t cmd_pkt_filter_src =
4093 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4095 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4096 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4098 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4099 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4101 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4102 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4104 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4105 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4107 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4108 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4110 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4111 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4112 flexbytes, "flexbytes");
4113 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4114 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4115 flexbytes_value, UINT16);
4116 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4117 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4119 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4120 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4122 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4123 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4125 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4126 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4128 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4129 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4131 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4132 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4136 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4137 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4138 pkt_filter, "add_signature_filter");
4139 cmdline_parse_inst_t cmd_add_signature_filter = {
4140 .f = cmd_pkt_filter_parsed,
4142 .help_str = "add a signature filter",
4144 (void *)&cmd_pkt_filter_add_signature_filter,
4145 (void *)&cmd_pkt_filter_port_id,
4146 (void *)&cmd_pkt_filter_protocol,
4147 (void *)&cmd_pkt_filter_src,
4148 (void *)&cmd_pkt_filter_ip_src,
4149 (void *)&cmd_pkt_filter_port_src,
4150 (void *)&cmd_pkt_filter_dst,
4151 (void *)&cmd_pkt_filter_ip_dst,
4152 (void *)&cmd_pkt_filter_port_dst,
4153 (void *)&cmd_pkt_filter_flexbytes,
4154 (void *)&cmd_pkt_filter_flexbytes_value,
4155 (void *)&cmd_pkt_filter_vlan,
4156 (void *)&cmd_pkt_filter_vlan_id,
4157 (void *)&cmd_pkt_filter_queue,
4158 (void *)&cmd_pkt_filter_queue_id,
4164 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4165 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4166 pkt_filter, "upd_signature_filter");
4167 cmdline_parse_inst_t cmd_upd_signature_filter = {
4168 .f = cmd_pkt_filter_parsed,
4170 .help_str = "update a signature filter",
4172 (void *)&cmd_pkt_filter_upd_signature_filter,
4173 (void *)&cmd_pkt_filter_port_id,
4174 (void *)&cmd_pkt_filter_protocol,
4175 (void *)&cmd_pkt_filter_src,
4176 (void *)&cmd_pkt_filter_ip_src,
4177 (void *)&cmd_pkt_filter_port_src,
4178 (void *)&cmd_pkt_filter_dst,
4179 (void *)&cmd_pkt_filter_ip_dst,
4180 (void *)&cmd_pkt_filter_port_dst,
4181 (void *)&cmd_pkt_filter_flexbytes,
4182 (void *)&cmd_pkt_filter_flexbytes_value,
4183 (void *)&cmd_pkt_filter_vlan,
4184 (void *)&cmd_pkt_filter_vlan_id,
4185 (void *)&cmd_pkt_filter_queue,
4186 (void *)&cmd_pkt_filter_queue_id,
4192 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4193 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4194 pkt_filter, "rm_signature_filter");
4195 cmdline_parse_inst_t cmd_rm_signature_filter = {
4196 .f = cmd_pkt_filter_parsed,
4198 .help_str = "remove a signature filter",
4200 (void *)&cmd_pkt_filter_rm_signature_filter,
4201 (void *)&cmd_pkt_filter_port_id,
4202 (void *)&cmd_pkt_filter_protocol,
4203 (void *)&cmd_pkt_filter_src,
4204 (void *)&cmd_pkt_filter_ip_src,
4205 (void *)&cmd_pkt_filter_port_src,
4206 (void *)&cmd_pkt_filter_dst,
4207 (void *)&cmd_pkt_filter_ip_dst,
4208 (void *)&cmd_pkt_filter_port_dst,
4209 (void *)&cmd_pkt_filter_flexbytes,
4210 (void *)&cmd_pkt_filter_flexbytes_value,
4211 (void *)&cmd_pkt_filter_vlan,
4212 (void *)&cmd_pkt_filter_vlan_id,
4218 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4219 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4220 pkt_filter, "add_perfect_filter");
4221 cmdline_parse_inst_t cmd_add_perfect_filter = {
4222 .f = cmd_pkt_filter_parsed,
4224 .help_str = "add a perfect filter",
4226 (void *)&cmd_pkt_filter_add_perfect_filter,
4227 (void *)&cmd_pkt_filter_port_id,
4228 (void *)&cmd_pkt_filter_protocol,
4229 (void *)&cmd_pkt_filter_src,
4230 (void *)&cmd_pkt_filter_ip_src,
4231 (void *)&cmd_pkt_filter_port_src,
4232 (void *)&cmd_pkt_filter_dst,
4233 (void *)&cmd_pkt_filter_ip_dst,
4234 (void *)&cmd_pkt_filter_port_dst,
4235 (void *)&cmd_pkt_filter_flexbytes,
4236 (void *)&cmd_pkt_filter_flexbytes_value,
4237 (void *)&cmd_pkt_filter_vlan,
4238 (void *)&cmd_pkt_filter_vlan_id,
4239 (void *)&cmd_pkt_filter_queue,
4240 (void *)&cmd_pkt_filter_queue_id,
4241 (void *)&cmd_pkt_filter_soft,
4242 (void *)&cmd_pkt_filter_soft_id,
4248 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4249 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4250 pkt_filter, "upd_perfect_filter");
4251 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4252 .f = cmd_pkt_filter_parsed,
4254 .help_str = "update a perfect filter",
4256 (void *)&cmd_pkt_filter_upd_perfect_filter,
4257 (void *)&cmd_pkt_filter_port_id,
4258 (void *)&cmd_pkt_filter_protocol,
4259 (void *)&cmd_pkt_filter_src,
4260 (void *)&cmd_pkt_filter_ip_src,
4261 (void *)&cmd_pkt_filter_port_src,
4262 (void *)&cmd_pkt_filter_dst,
4263 (void *)&cmd_pkt_filter_ip_dst,
4264 (void *)&cmd_pkt_filter_port_dst,
4265 (void *)&cmd_pkt_filter_flexbytes,
4266 (void *)&cmd_pkt_filter_flexbytes_value,
4267 (void *)&cmd_pkt_filter_vlan,
4268 (void *)&cmd_pkt_filter_vlan_id,
4269 (void *)&cmd_pkt_filter_queue,
4270 (void *)&cmd_pkt_filter_queue_id,
4271 (void *)&cmd_pkt_filter_soft,
4272 (void *)&cmd_pkt_filter_soft_id,
4278 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4279 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4280 pkt_filter, "rm_perfect_filter");
4281 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4282 .f = cmd_pkt_filter_parsed,
4284 .help_str = "remove a perfect filter",
4286 (void *)&cmd_pkt_filter_rm_perfect_filter,
4287 (void *)&cmd_pkt_filter_port_id,
4288 (void *)&cmd_pkt_filter_protocol,
4289 (void *)&cmd_pkt_filter_src,
4290 (void *)&cmd_pkt_filter_ip_src,
4291 (void *)&cmd_pkt_filter_port_src,
4292 (void *)&cmd_pkt_filter_dst,
4293 (void *)&cmd_pkt_filter_ip_dst,
4294 (void *)&cmd_pkt_filter_port_dst,
4295 (void *)&cmd_pkt_filter_flexbytes,
4296 (void *)&cmd_pkt_filter_flexbytes_value,
4297 (void *)&cmd_pkt_filter_vlan,
4298 (void *)&cmd_pkt_filter_vlan_id,
4299 (void *)&cmd_pkt_filter_soft,
4300 (void *)&cmd_pkt_filter_soft_id,
4305 /* *** SETUP MASKS FILTER *** */
4306 struct cmd_pkt_filter_masks_result {
4307 cmdline_fixed_string_t filter_mask;
4309 cmdline_fixed_string_t src_mask;
4310 uint32_t ip_src_mask;
4311 uint16_t ipv6_src_mask;
4312 uint16_t port_src_mask;
4313 cmdline_fixed_string_t dst_mask;
4314 uint32_t ip_dst_mask;
4315 uint16_t ipv6_dst_mask;
4316 uint16_t port_dst_mask;
4317 cmdline_fixed_string_t flexbytes;
4318 uint8_t flexbytes_value;
4319 cmdline_fixed_string_t vlan_id;
4320 uint8_t vlan_id_value;
4321 cmdline_fixed_string_t vlan_prio;
4322 uint8_t vlan_prio_value;
4323 cmdline_fixed_string_t only_ip_flow;
4324 uint8_t only_ip_flow_value;
4325 cmdline_fixed_string_t comp_ipv6_dst;
4326 uint8_t comp_ipv6_dst_value;
4330 cmd_pkt_filter_masks_parsed(void *parsed_result,
4331 __attribute__((unused)) struct cmdline *cl,
4332 __attribute__((unused)) void *data)
4334 struct rte_fdir_masks fdir_masks;
4335 struct cmd_pkt_filter_masks_result *res = parsed_result;
4337 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4339 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4340 fdir_masks.vlan_id = res->vlan_id_value;
4341 fdir_masks.vlan_prio = res->vlan_prio_value;
4342 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4343 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4344 fdir_masks.src_port_mask = res->port_src_mask;
4345 fdir_masks.dst_port_mask = res->port_dst_mask;
4346 fdir_masks.flexbytes = res->flexbytes_value;
4348 fdir_set_masks(res->port_id, &fdir_masks);
4351 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4352 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4353 filter_mask, "set_masks_filter");
4354 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4355 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4357 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4358 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4359 only_ip_flow, "only_ip_flow");
4360 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4361 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4362 only_ip_flow_value, UINT8);
4363 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4364 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4365 src_mask, "src_mask");
4366 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4367 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4368 ip_src_mask, UINT32);
4369 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4370 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4371 port_src_mask, UINT16);
4372 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4373 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4374 dst_mask, "dst_mask");
4375 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4376 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4377 ip_dst_mask, UINT32);
4378 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4379 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4380 port_dst_mask, UINT16);
4381 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4382 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4383 flexbytes, "flexbytes");
4384 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4385 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4386 flexbytes_value, UINT8);
4387 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4388 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4389 vlan_id, "vlan_id");
4390 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4391 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4392 vlan_id_value, UINT8);
4393 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4394 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4395 vlan_prio, "vlan_prio");
4396 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4397 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4398 vlan_prio_value, UINT8);
4400 cmdline_parse_inst_t cmd_set_masks_filter = {
4401 .f = cmd_pkt_filter_masks_parsed,
4403 .help_str = "setup masks filter",
4405 (void *)&cmd_pkt_filter_masks_filter_mask,
4406 (void *)&cmd_pkt_filter_masks_port_id,
4407 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4408 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4409 (void *)&cmd_pkt_filter_masks_src_mask,
4410 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4411 (void *)&cmd_pkt_filter_masks_port_src_mask,
4412 (void *)&cmd_pkt_filter_masks_dst_mask,
4413 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4414 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4415 (void *)&cmd_pkt_filter_masks_flexbytes,
4416 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4417 (void *)&cmd_pkt_filter_masks_vlan_id,
4418 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4419 (void *)&cmd_pkt_filter_masks_vlan_prio,
4420 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4426 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4427 __attribute__((unused)) struct cmdline *cl,
4428 __attribute__((unused)) void *data)
4430 struct rte_fdir_masks fdir_masks;
4431 struct cmd_pkt_filter_masks_result *res = parsed_result;
4433 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4435 fdir_masks.set_ipv6_mask = 1;
4436 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4437 fdir_masks.vlan_id = res->vlan_id_value;
4438 fdir_masks.vlan_prio = res->vlan_prio_value;
4439 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4440 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4441 fdir_masks.src_port_mask = res->port_src_mask;
4442 fdir_masks.dst_port_mask = res->port_dst_mask;
4443 fdir_masks.flexbytes = res->flexbytes_value;
4444 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4446 fdir_set_masks(res->port_id, &fdir_masks);
4449 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4450 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4451 filter_mask, "set_ipv6_masks_filter");
4452 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4453 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4454 ipv6_src_mask, UINT16);
4455 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4456 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4457 ipv6_dst_mask, UINT16);
4459 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4460 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4461 comp_ipv6_dst, "compare_dst");
4462 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4463 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4464 comp_ipv6_dst_value, UINT8);
4466 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4467 .f = cmd_pkt_filter_masks_ipv6_parsed,
4469 .help_str = "setup ipv6 masks filter",
4471 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4472 (void *)&cmd_pkt_filter_masks_port_id,
4473 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4474 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4475 (void *)&cmd_pkt_filter_masks_src_mask,
4476 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4477 (void *)&cmd_pkt_filter_masks_port_src_mask,
4478 (void *)&cmd_pkt_filter_masks_dst_mask,
4479 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4480 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4481 (void *)&cmd_pkt_filter_masks_flexbytes,
4482 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4483 (void *)&cmd_pkt_filter_masks_vlan_id,
4484 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4485 (void *)&cmd_pkt_filter_masks_vlan_prio,
4486 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4487 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4488 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4493 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4494 struct cmd_link_flow_ctrl_set_result {
4495 cmdline_fixed_string_t set;
4496 cmdline_fixed_string_t flow_ctrl;
4497 cmdline_fixed_string_t rx;
4498 cmdline_fixed_string_t rx_lfc_mode;
4499 cmdline_fixed_string_t tx;
4500 cmdline_fixed_string_t tx_lfc_mode;
4501 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4502 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4503 cmdline_fixed_string_t autoneg_str;
4504 cmdline_fixed_string_t autoneg;
4505 cmdline_fixed_string_t hw_str;
4506 uint32_t high_water;
4507 cmdline_fixed_string_t lw_str;
4509 cmdline_fixed_string_t pt_str;
4510 uint16_t pause_time;
4511 cmdline_fixed_string_t xon_str;
4516 cmdline_parse_token_string_t cmd_lfc_set_set =
4517 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4519 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4520 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4521 flow_ctrl, "flow_ctrl");
4522 cmdline_parse_token_string_t cmd_lfc_set_rx =
4523 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4525 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4526 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4527 rx_lfc_mode, "on#off");
4528 cmdline_parse_token_string_t cmd_lfc_set_tx =
4529 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4531 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4532 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4533 tx_lfc_mode, "on#off");
4534 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4535 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4536 hw_str, "high_water");
4537 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4538 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4539 high_water, UINT32);
4540 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4541 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4542 lw_str, "low_water");
4543 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4544 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4546 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4547 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4548 pt_str, "pause_time");
4549 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4550 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4551 pause_time, UINT16);
4552 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4553 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4554 xon_str, "send_xon");
4555 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4556 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4558 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4559 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4560 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4561 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4562 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4563 mac_ctrl_frame_fwd_mode, "on#off");
4564 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4565 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4566 autoneg_str, "autoneg");
4567 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4568 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4570 cmdline_parse_token_num_t cmd_lfc_set_portid =
4571 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4574 /* forward declaration */
4576 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4579 cmdline_parse_inst_t cmd_link_flow_control_set = {
4580 .f = cmd_link_flow_ctrl_set_parsed,
4582 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4583 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4584 autoneg on|off port_id",
4586 (void *)&cmd_lfc_set_set,
4587 (void *)&cmd_lfc_set_flow_ctrl,
4588 (void *)&cmd_lfc_set_rx,
4589 (void *)&cmd_lfc_set_rx_mode,
4590 (void *)&cmd_lfc_set_tx,
4591 (void *)&cmd_lfc_set_tx_mode,
4592 (void *)&cmd_lfc_set_high_water,
4593 (void *)&cmd_lfc_set_low_water,
4594 (void *)&cmd_lfc_set_pause_time,
4595 (void *)&cmd_lfc_set_send_xon,
4596 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4597 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4598 (void *)&cmd_lfc_set_autoneg_str,
4599 (void *)&cmd_lfc_set_autoneg,
4600 (void *)&cmd_lfc_set_portid,
4605 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4606 .f = cmd_link_flow_ctrl_set_parsed,
4607 .data = (void *)&cmd_link_flow_control_set_rx,
4608 .help_str = "Change rx flow control parameter: set flow_ctrl "
4609 "rx on|off port_id",
4611 (void *)&cmd_lfc_set_set,
4612 (void *)&cmd_lfc_set_flow_ctrl,
4613 (void *)&cmd_lfc_set_rx,
4614 (void *)&cmd_lfc_set_rx_mode,
4615 (void *)&cmd_lfc_set_portid,
4620 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4621 .f = cmd_link_flow_ctrl_set_parsed,
4622 .data = (void *)&cmd_link_flow_control_set_tx,
4623 .help_str = "Change tx flow control parameter: set flow_ctrl "
4624 "tx on|off port_id",
4626 (void *)&cmd_lfc_set_set,
4627 (void *)&cmd_lfc_set_flow_ctrl,
4628 (void *)&cmd_lfc_set_tx,
4629 (void *)&cmd_lfc_set_tx_mode,
4630 (void *)&cmd_lfc_set_portid,
4635 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4636 .f = cmd_link_flow_ctrl_set_parsed,
4637 .data = (void *)&cmd_link_flow_control_set_hw,
4638 .help_str = "Change high water flow control parameter: set flow_ctrl "
4639 "high_water value port_id",
4641 (void *)&cmd_lfc_set_set,
4642 (void *)&cmd_lfc_set_flow_ctrl,
4643 (void *)&cmd_lfc_set_high_water_str,
4644 (void *)&cmd_lfc_set_high_water,
4645 (void *)&cmd_lfc_set_portid,
4650 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4651 .f = cmd_link_flow_ctrl_set_parsed,
4652 .data = (void *)&cmd_link_flow_control_set_lw,
4653 .help_str = "Change low water flow control parameter: set flow_ctrl "
4654 "low_water value port_id",
4656 (void *)&cmd_lfc_set_set,
4657 (void *)&cmd_lfc_set_flow_ctrl,
4658 (void *)&cmd_lfc_set_low_water_str,
4659 (void *)&cmd_lfc_set_low_water,
4660 (void *)&cmd_lfc_set_portid,
4665 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4666 .f = cmd_link_flow_ctrl_set_parsed,
4667 .data = (void *)&cmd_link_flow_control_set_pt,
4668 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4669 "pause_time value port_id",
4671 (void *)&cmd_lfc_set_set,
4672 (void *)&cmd_lfc_set_flow_ctrl,
4673 (void *)&cmd_lfc_set_pause_time_str,
4674 (void *)&cmd_lfc_set_pause_time,
4675 (void *)&cmd_lfc_set_portid,
4680 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4681 .f = cmd_link_flow_ctrl_set_parsed,
4682 .data = (void *)&cmd_link_flow_control_set_xon,
4683 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4684 "send_xon value port_id",
4686 (void *)&cmd_lfc_set_set,
4687 (void *)&cmd_lfc_set_flow_ctrl,
4688 (void *)&cmd_lfc_set_send_xon_str,
4689 (void *)&cmd_lfc_set_send_xon,
4690 (void *)&cmd_lfc_set_portid,
4695 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4696 .f = cmd_link_flow_ctrl_set_parsed,
4697 .data = (void *)&cmd_link_flow_control_set_macfwd,
4698 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4699 "mac_ctrl_frame_fwd on|off port_id",
4701 (void *)&cmd_lfc_set_set,
4702 (void *)&cmd_lfc_set_flow_ctrl,
4703 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4704 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4705 (void *)&cmd_lfc_set_portid,
4710 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4711 .f = cmd_link_flow_ctrl_set_parsed,
4712 .data = (void *)&cmd_link_flow_control_set_autoneg,
4713 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4714 "autoneg on|off port_id",
4716 (void *)&cmd_lfc_set_set,
4717 (void *)&cmd_lfc_set_flow_ctrl,
4718 (void *)&cmd_lfc_set_autoneg_str,
4719 (void *)&cmd_lfc_set_autoneg,
4720 (void *)&cmd_lfc_set_portid,
4726 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4727 __attribute__((unused)) struct cmdline *cl,
4730 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4731 cmdline_parse_inst_t *cmd = data;
4732 struct rte_eth_fc_conf fc_conf;
4733 int rx_fc_en, tx_fc_en;
4737 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4738 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4739 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4740 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4742 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4743 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4746 /* Partial command line, retrieve current configuration */
4748 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4750 printf("cannot get current flow ctrl parameters, return"
4751 "code = %d\n", ret);
4755 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4756 (fc_conf.mode == RTE_FC_FULL))
4758 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4759 (fc_conf.mode == RTE_FC_FULL))
4763 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4764 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4766 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4767 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4769 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4771 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4772 fc_conf.high_water = res->high_water;
4774 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4775 fc_conf.low_water = res->low_water;
4777 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4778 fc_conf.pause_time = res->pause_time;
4780 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4781 fc_conf.send_xon = res->send_xon;
4783 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4784 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4785 fc_conf.mac_ctrl_frame_fwd = 1;
4787 fc_conf.mac_ctrl_frame_fwd = 0;
4790 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4791 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4793 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4795 printf("bad flow contrl parameter, return code = %d \n", ret);
4798 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4799 struct cmd_priority_flow_ctrl_set_result {
4800 cmdline_fixed_string_t set;
4801 cmdline_fixed_string_t pfc_ctrl;
4802 cmdline_fixed_string_t rx;
4803 cmdline_fixed_string_t rx_pfc_mode;
4804 cmdline_fixed_string_t tx;
4805 cmdline_fixed_string_t tx_pfc_mode;
4806 uint32_t high_water;
4808 uint16_t pause_time;
4814 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4815 __attribute__((unused)) struct cmdline *cl,
4816 __attribute__((unused)) void *data)
4818 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4819 struct rte_eth_pfc_conf pfc_conf;
4820 int rx_fc_enable, tx_fc_enable;
4824 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4825 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4826 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4827 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4829 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4830 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4833 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4834 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4835 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4836 pfc_conf.fc.high_water = res->high_water;
4837 pfc_conf.fc.low_water = res->low_water;
4838 pfc_conf.fc.pause_time = res->pause_time;
4839 pfc_conf.priority = res->priority;
4841 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4843 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4846 cmdline_parse_token_string_t cmd_pfc_set_set =
4847 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4849 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4850 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4851 pfc_ctrl, "pfc_ctrl");
4852 cmdline_parse_token_string_t cmd_pfc_set_rx =
4853 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4855 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4856 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4857 rx_pfc_mode, "on#off");
4858 cmdline_parse_token_string_t cmd_pfc_set_tx =
4859 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4861 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4862 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4863 tx_pfc_mode, "on#off");
4864 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4865 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4866 high_water, UINT32);
4867 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4868 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4870 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4871 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4872 pause_time, UINT16);
4873 cmdline_parse_token_num_t cmd_pfc_set_priority =
4874 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4876 cmdline_parse_token_num_t cmd_pfc_set_portid =
4877 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4880 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4881 .f = cmd_priority_flow_ctrl_set_parsed,
4883 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4884 tx on|off high_water low_water pause_time priority port_id",
4886 (void *)&cmd_pfc_set_set,
4887 (void *)&cmd_pfc_set_flow_ctrl,
4888 (void *)&cmd_pfc_set_rx,
4889 (void *)&cmd_pfc_set_rx_mode,
4890 (void *)&cmd_pfc_set_tx,
4891 (void *)&cmd_pfc_set_tx_mode,
4892 (void *)&cmd_pfc_set_high_water,
4893 (void *)&cmd_pfc_set_low_water,
4894 (void *)&cmd_pfc_set_pause_time,
4895 (void *)&cmd_pfc_set_priority,
4896 (void *)&cmd_pfc_set_portid,
4901 /* *** RESET CONFIGURATION *** */
4902 struct cmd_reset_result {
4903 cmdline_fixed_string_t reset;
4904 cmdline_fixed_string_t def;
4907 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4909 __attribute__((unused)) void *data)
4911 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4912 set_def_fwd_config();
4915 cmdline_parse_token_string_t cmd_reset_set =
4916 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4917 cmdline_parse_token_string_t cmd_reset_def =
4918 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4921 cmdline_parse_inst_t cmd_reset = {
4922 .f = cmd_reset_parsed,
4924 .help_str = "set default: reset default forwarding configuration",
4926 (void *)&cmd_reset_set,
4927 (void *)&cmd_reset_def,
4932 /* *** START FORWARDING *** */
4933 struct cmd_start_result {
4934 cmdline_fixed_string_t start;
4937 cmdline_parse_token_string_t cmd_start_start =
4938 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4940 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4941 __attribute__((unused)) struct cmdline *cl,
4942 __attribute__((unused)) void *data)
4944 start_packet_forwarding(0);
4947 cmdline_parse_inst_t cmd_start = {
4948 .f = cmd_start_parsed,
4950 .help_str = "start packet forwarding",
4952 (void *)&cmd_start_start,
4957 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4958 struct cmd_start_tx_first_result {
4959 cmdline_fixed_string_t start;
4960 cmdline_fixed_string_t tx_first;
4964 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4965 __attribute__((unused)) struct cmdline *cl,
4966 __attribute__((unused)) void *data)
4968 start_packet_forwarding(1);
4971 cmdline_parse_token_string_t cmd_start_tx_first_start =
4972 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4974 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4975 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4976 tx_first, "tx_first");
4978 cmdline_parse_inst_t cmd_start_tx_first = {
4979 .f = cmd_start_tx_first_parsed,
4981 .help_str = "start packet forwarding, after sending 1 burst of packets",
4983 (void *)&cmd_start_tx_first_start,
4984 (void *)&cmd_start_tx_first_tx_first,
4989 /* *** SET LINK UP *** */
4990 struct cmd_set_link_up_result {
4991 cmdline_fixed_string_t set;
4992 cmdline_fixed_string_t link_up;
4993 cmdline_fixed_string_t port;
4997 cmdline_parse_token_string_t cmd_set_link_up_set =
4998 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4999 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5000 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5002 cmdline_parse_token_string_t cmd_set_link_up_port =
5003 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5004 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5005 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5007 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5008 __attribute__((unused)) struct cmdline *cl,
5009 __attribute__((unused)) void *data)
5011 struct cmd_set_link_up_result *res = parsed_result;
5012 dev_set_link_up(res->port_id);
5015 cmdline_parse_inst_t cmd_set_link_up = {
5016 .f = cmd_set_link_up_parsed,
5018 .help_str = "set link-up port (port id)",
5020 (void *)&cmd_set_link_up_set,
5021 (void *)&cmd_set_link_up_link_up,
5022 (void *)&cmd_set_link_up_port,
5023 (void *)&cmd_set_link_up_port_id,
5028 /* *** SET LINK DOWN *** */
5029 struct cmd_set_link_down_result {
5030 cmdline_fixed_string_t set;
5031 cmdline_fixed_string_t link_down;
5032 cmdline_fixed_string_t port;
5036 cmdline_parse_token_string_t cmd_set_link_down_set =
5037 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5038 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5039 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5041 cmdline_parse_token_string_t cmd_set_link_down_port =
5042 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5043 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5044 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5046 static void cmd_set_link_down_parsed(
5047 __attribute__((unused)) void *parsed_result,
5048 __attribute__((unused)) struct cmdline *cl,
5049 __attribute__((unused)) void *data)
5051 struct cmd_set_link_down_result *res = parsed_result;
5052 dev_set_link_down(res->port_id);
5055 cmdline_parse_inst_t cmd_set_link_down = {
5056 .f = cmd_set_link_down_parsed,
5058 .help_str = "set link-down port (port id)",
5060 (void *)&cmd_set_link_down_set,
5061 (void *)&cmd_set_link_down_link_down,
5062 (void *)&cmd_set_link_down_port,
5063 (void *)&cmd_set_link_down_port_id,
5068 /* *** SHOW CFG *** */
5069 struct cmd_showcfg_result {
5070 cmdline_fixed_string_t show;
5071 cmdline_fixed_string_t cfg;
5072 cmdline_fixed_string_t what;
5075 static void cmd_showcfg_parsed(void *parsed_result,
5076 __attribute__((unused)) struct cmdline *cl,
5077 __attribute__((unused)) void *data)
5079 struct cmd_showcfg_result *res = parsed_result;
5080 if (!strcmp(res->what, "rxtx"))
5081 rxtx_config_display();
5082 else if (!strcmp(res->what, "cores"))
5083 fwd_lcores_config_display();
5084 else if (!strcmp(res->what, "fwd"))
5085 fwd_config_display();
5088 cmdline_parse_token_string_t cmd_showcfg_show =
5089 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5090 cmdline_parse_token_string_t cmd_showcfg_port =
5091 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5092 cmdline_parse_token_string_t cmd_showcfg_what =
5093 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5096 cmdline_parse_inst_t cmd_showcfg = {
5097 .f = cmd_showcfg_parsed,
5099 .help_str = "show config rxtx|cores|fwd",
5101 (void *)&cmd_showcfg_show,
5102 (void *)&cmd_showcfg_port,
5103 (void *)&cmd_showcfg_what,
5108 /* *** SHOW ALL PORT INFO *** */
5109 struct cmd_showportall_result {
5110 cmdline_fixed_string_t show;
5111 cmdline_fixed_string_t port;
5112 cmdline_fixed_string_t what;
5113 cmdline_fixed_string_t all;
5116 static void cmd_showportall_parsed(void *parsed_result,
5117 __attribute__((unused)) struct cmdline *cl,
5118 __attribute__((unused)) void *data)
5122 struct cmd_showportall_result *res = parsed_result;
5123 if (!strcmp(res->show, "clear")) {
5124 if (!strcmp(res->what, "stats"))
5125 for (i = 0; i < nb_ports; i++)
5127 else if (!strcmp(res->what, "xstats"))
5128 for (i = 0; i < nb_ports; i++)
5129 nic_xstats_clear(i);
5130 } else if (!strcmp(res->what, "info"))
5131 for (i = 0; i < nb_ports; i++)
5132 port_infos_display(i);
5133 else if (!strcmp(res->what, "stats"))
5134 for (i = 0; i < nb_ports; i++)
5135 nic_stats_display(i);
5136 else if (!strcmp(res->what, "xstats"))
5137 for (i = 0; i < nb_ports; i++)
5138 nic_xstats_display(i);
5139 else if (!strcmp(res->what, "fdir"))
5140 for (i = 0; i < nb_ports; i++)
5142 else if (!strcmp(res->what, "stat_qmap"))
5143 for (i = 0; i < nb_ports; i++)
5144 nic_stats_mapping_display(i);
5147 cmdline_parse_token_string_t cmd_showportall_show =
5148 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5150 cmdline_parse_token_string_t cmd_showportall_port =
5151 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5152 cmdline_parse_token_string_t cmd_showportall_what =
5153 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5154 "info#stats#xstats#fdir#stat_qmap");
5155 cmdline_parse_token_string_t cmd_showportall_all =
5156 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5157 cmdline_parse_inst_t cmd_showportall = {
5158 .f = cmd_showportall_parsed,
5160 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5162 (void *)&cmd_showportall_show,
5163 (void *)&cmd_showportall_port,
5164 (void *)&cmd_showportall_what,
5165 (void *)&cmd_showportall_all,
5170 /* *** SHOW PORT INFO *** */
5171 struct cmd_showport_result {
5172 cmdline_fixed_string_t show;
5173 cmdline_fixed_string_t port;
5174 cmdline_fixed_string_t what;
5178 static void cmd_showport_parsed(void *parsed_result,
5179 __attribute__((unused)) struct cmdline *cl,
5180 __attribute__((unused)) void *data)
5182 struct cmd_showport_result *res = parsed_result;
5183 if (!strcmp(res->show, "clear")) {
5184 if (!strcmp(res->what, "stats"))
5185 nic_stats_clear(res->portnum);
5186 else if (!strcmp(res->what, "xstats"))
5187 nic_xstats_clear(res->portnum);
5188 } else if (!strcmp(res->what, "info"))
5189 port_infos_display(res->portnum);
5190 else if (!strcmp(res->what, "stats"))
5191 nic_stats_display(res->portnum);
5192 else if (!strcmp(res->what, "xstats"))
5193 nic_xstats_display(res->portnum);
5194 else if (!strcmp(res->what, "fdir"))
5195 fdir_get_infos(res->portnum);
5196 else if (!strcmp(res->what, "stat_qmap"))
5197 nic_stats_mapping_display(res->portnum);
5200 cmdline_parse_token_string_t cmd_showport_show =
5201 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5203 cmdline_parse_token_string_t cmd_showport_port =
5204 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5205 cmdline_parse_token_string_t cmd_showport_what =
5206 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5207 "info#stats#xstats#fdir#stat_qmap");
5208 cmdline_parse_token_num_t cmd_showport_portnum =
5209 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5211 cmdline_parse_inst_t cmd_showport = {
5212 .f = cmd_showport_parsed,
5214 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5216 (void *)&cmd_showport_show,
5217 (void *)&cmd_showport_port,
5218 (void *)&cmd_showport_what,
5219 (void *)&cmd_showport_portnum,
5224 /* *** READ PORT REGISTER *** */
5225 struct cmd_read_reg_result {
5226 cmdline_fixed_string_t read;
5227 cmdline_fixed_string_t reg;
5233 cmd_read_reg_parsed(void *parsed_result,
5234 __attribute__((unused)) struct cmdline *cl,
5235 __attribute__((unused)) void *data)
5237 struct cmd_read_reg_result *res = parsed_result;
5238 port_reg_display(res->port_id, res->reg_off);
5241 cmdline_parse_token_string_t cmd_read_reg_read =
5242 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5243 cmdline_parse_token_string_t cmd_read_reg_reg =
5244 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5245 cmdline_parse_token_num_t cmd_read_reg_port_id =
5246 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5247 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5248 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5250 cmdline_parse_inst_t cmd_read_reg = {
5251 .f = cmd_read_reg_parsed,
5253 .help_str = "read reg port_id reg_off",
5255 (void *)&cmd_read_reg_read,
5256 (void *)&cmd_read_reg_reg,
5257 (void *)&cmd_read_reg_port_id,
5258 (void *)&cmd_read_reg_reg_off,
5263 /* *** READ PORT REGISTER BIT FIELD *** */
5264 struct cmd_read_reg_bit_field_result {
5265 cmdline_fixed_string_t read;
5266 cmdline_fixed_string_t regfield;
5274 cmd_read_reg_bit_field_parsed(void *parsed_result,
5275 __attribute__((unused)) struct cmdline *cl,
5276 __attribute__((unused)) void *data)
5278 struct cmd_read_reg_bit_field_result *res = parsed_result;
5279 port_reg_bit_field_display(res->port_id, res->reg_off,
5280 res->bit1_pos, res->bit2_pos);
5283 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5284 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5286 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5287 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5288 regfield, "regfield");
5289 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5290 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5292 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5293 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5295 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5296 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5298 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5299 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5302 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5303 .f = cmd_read_reg_bit_field_parsed,
5305 .help_str = "read regfield port_id reg_off bit_x bit_y "
5306 "(read register bit field between bit_x and bit_y included)",
5308 (void *)&cmd_read_reg_bit_field_read,
5309 (void *)&cmd_read_reg_bit_field_regfield,
5310 (void *)&cmd_read_reg_bit_field_port_id,
5311 (void *)&cmd_read_reg_bit_field_reg_off,
5312 (void *)&cmd_read_reg_bit_field_bit1_pos,
5313 (void *)&cmd_read_reg_bit_field_bit2_pos,
5318 /* *** READ PORT REGISTER BIT *** */
5319 struct cmd_read_reg_bit_result {
5320 cmdline_fixed_string_t read;
5321 cmdline_fixed_string_t regbit;
5328 cmd_read_reg_bit_parsed(void *parsed_result,
5329 __attribute__((unused)) struct cmdline *cl,
5330 __attribute__((unused)) void *data)
5332 struct cmd_read_reg_bit_result *res = parsed_result;
5333 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5336 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5337 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5338 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5339 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5341 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5342 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5343 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5344 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5345 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5346 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5348 cmdline_parse_inst_t cmd_read_reg_bit = {
5349 .f = cmd_read_reg_bit_parsed,
5351 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5353 (void *)&cmd_read_reg_bit_read,
5354 (void *)&cmd_read_reg_bit_regbit,
5355 (void *)&cmd_read_reg_bit_port_id,
5356 (void *)&cmd_read_reg_bit_reg_off,
5357 (void *)&cmd_read_reg_bit_bit_pos,
5362 /* *** WRITE PORT REGISTER *** */
5363 struct cmd_write_reg_result {
5364 cmdline_fixed_string_t write;
5365 cmdline_fixed_string_t reg;
5372 cmd_write_reg_parsed(void *parsed_result,
5373 __attribute__((unused)) struct cmdline *cl,
5374 __attribute__((unused)) void *data)
5376 struct cmd_write_reg_result *res = parsed_result;
5377 port_reg_set(res->port_id, res->reg_off, res->value);
5380 cmdline_parse_token_string_t cmd_write_reg_write =
5381 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5382 cmdline_parse_token_string_t cmd_write_reg_reg =
5383 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5384 cmdline_parse_token_num_t cmd_write_reg_port_id =
5385 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5386 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5387 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5388 cmdline_parse_token_num_t cmd_write_reg_value =
5389 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5391 cmdline_parse_inst_t cmd_write_reg = {
5392 .f = cmd_write_reg_parsed,
5394 .help_str = "write reg port_id reg_off reg_value",
5396 (void *)&cmd_write_reg_write,
5397 (void *)&cmd_write_reg_reg,
5398 (void *)&cmd_write_reg_port_id,
5399 (void *)&cmd_write_reg_reg_off,
5400 (void *)&cmd_write_reg_value,
5405 /* *** WRITE PORT REGISTER BIT FIELD *** */
5406 struct cmd_write_reg_bit_field_result {
5407 cmdline_fixed_string_t write;
5408 cmdline_fixed_string_t regfield;
5417 cmd_write_reg_bit_field_parsed(void *parsed_result,
5418 __attribute__((unused)) struct cmdline *cl,
5419 __attribute__((unused)) void *data)
5421 struct cmd_write_reg_bit_field_result *res = parsed_result;
5422 port_reg_bit_field_set(res->port_id, res->reg_off,
5423 res->bit1_pos, res->bit2_pos, res->value);
5426 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5427 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5429 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5430 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5431 regfield, "regfield");
5432 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5433 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5435 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5436 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5438 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5439 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5441 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5442 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5444 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5445 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5448 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5449 .f = cmd_write_reg_bit_field_parsed,
5451 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5452 "(set register bit field between bit_x and bit_y included)",
5454 (void *)&cmd_write_reg_bit_field_write,
5455 (void *)&cmd_write_reg_bit_field_regfield,
5456 (void *)&cmd_write_reg_bit_field_port_id,
5457 (void *)&cmd_write_reg_bit_field_reg_off,
5458 (void *)&cmd_write_reg_bit_field_bit1_pos,
5459 (void *)&cmd_write_reg_bit_field_bit2_pos,
5460 (void *)&cmd_write_reg_bit_field_value,
5465 /* *** WRITE PORT REGISTER BIT *** */
5466 struct cmd_write_reg_bit_result {
5467 cmdline_fixed_string_t write;
5468 cmdline_fixed_string_t regbit;
5476 cmd_write_reg_bit_parsed(void *parsed_result,
5477 __attribute__((unused)) struct cmdline *cl,
5478 __attribute__((unused)) void *data)
5480 struct cmd_write_reg_bit_result *res = parsed_result;
5481 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5484 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5485 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5487 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5488 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5490 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5491 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5492 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5493 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5494 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5495 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5496 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5497 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5499 cmdline_parse_inst_t cmd_write_reg_bit = {
5500 .f = cmd_write_reg_bit_parsed,
5502 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5504 (void *)&cmd_write_reg_bit_write,
5505 (void *)&cmd_write_reg_bit_regbit,
5506 (void *)&cmd_write_reg_bit_port_id,
5507 (void *)&cmd_write_reg_bit_reg_off,
5508 (void *)&cmd_write_reg_bit_bit_pos,
5509 (void *)&cmd_write_reg_bit_value,
5514 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5515 struct cmd_read_rxd_txd_result {
5516 cmdline_fixed_string_t read;
5517 cmdline_fixed_string_t rxd_txd;
5524 cmd_read_rxd_txd_parsed(void *parsed_result,
5525 __attribute__((unused)) struct cmdline *cl,
5526 __attribute__((unused)) void *data)
5528 struct cmd_read_rxd_txd_result *res = parsed_result;
5530 if (!strcmp(res->rxd_txd, "rxd"))
5531 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5532 else if (!strcmp(res->rxd_txd, "txd"))
5533 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5536 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5537 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5538 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5539 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5541 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5542 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5543 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5544 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5545 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5546 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5548 cmdline_parse_inst_t cmd_read_rxd_txd = {
5549 .f = cmd_read_rxd_txd_parsed,
5551 .help_str = "read rxd|txd port_id queue_id rxd_id",
5553 (void *)&cmd_read_rxd_txd_read,
5554 (void *)&cmd_read_rxd_txd_rxd_txd,
5555 (void *)&cmd_read_rxd_txd_port_id,
5556 (void *)&cmd_read_rxd_txd_queue_id,
5557 (void *)&cmd_read_rxd_txd_desc_id,
5563 struct cmd_quit_result {
5564 cmdline_fixed_string_t quit;
5567 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5569 __attribute__((unused)) void *data)
5575 cmdline_parse_token_string_t cmd_quit_quit =
5576 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5578 cmdline_parse_inst_t cmd_quit = {
5579 .f = cmd_quit_parsed,
5581 .help_str = "exit application",
5583 (void *)&cmd_quit_quit,
5588 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5589 struct cmd_mac_addr_result {
5590 cmdline_fixed_string_t mac_addr_cmd;
5591 cmdline_fixed_string_t what;
5593 struct ether_addr address;
5596 static void cmd_mac_addr_parsed(void *parsed_result,
5597 __attribute__((unused)) struct cmdline *cl,
5598 __attribute__((unused)) void *data)
5600 struct cmd_mac_addr_result *res = parsed_result;
5603 if (strcmp(res->what, "add") == 0)
5604 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5606 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5608 /* check the return value and print it if is < 0 */
5610 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5614 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5615 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5617 cmdline_parse_token_string_t cmd_mac_addr_what =
5618 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5620 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5621 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5622 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5623 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5625 cmdline_parse_inst_t cmd_mac_addr = {
5626 .f = cmd_mac_addr_parsed,
5628 .help_str = "mac_addr add|remove X <address>: "
5629 "add/remove MAC address on port X",
5631 (void *)&cmd_mac_addr_cmd,
5632 (void *)&cmd_mac_addr_what,
5633 (void *)&cmd_mac_addr_portnum,
5634 (void *)&cmd_mac_addr_addr,
5640 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5641 struct cmd_set_qmap_result {
5642 cmdline_fixed_string_t set;
5643 cmdline_fixed_string_t qmap;
5644 cmdline_fixed_string_t what;
5651 cmd_set_qmap_parsed(void *parsed_result,
5652 __attribute__((unused)) struct cmdline *cl,
5653 __attribute__((unused)) void *data)
5655 struct cmd_set_qmap_result *res = parsed_result;
5656 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5658 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5661 cmdline_parse_token_string_t cmd_setqmap_set =
5662 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5664 cmdline_parse_token_string_t cmd_setqmap_qmap =
5665 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5667 cmdline_parse_token_string_t cmd_setqmap_what =
5668 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5670 cmdline_parse_token_num_t cmd_setqmap_portid =
5671 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5673 cmdline_parse_token_num_t cmd_setqmap_queueid =
5674 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5676 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5677 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5680 cmdline_parse_inst_t cmd_set_qmap = {
5681 .f = cmd_set_qmap_parsed,
5683 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5685 (void *)&cmd_setqmap_set,
5686 (void *)&cmd_setqmap_qmap,
5687 (void *)&cmd_setqmap_what,
5688 (void *)&cmd_setqmap_portid,
5689 (void *)&cmd_setqmap_queueid,
5690 (void *)&cmd_setqmap_mapvalue,
5695 /* *** CONFIGURE UNICAST HASH TABLE *** */
5696 struct cmd_set_uc_hash_table {
5697 cmdline_fixed_string_t set;
5698 cmdline_fixed_string_t port;
5700 cmdline_fixed_string_t what;
5701 struct ether_addr address;
5702 cmdline_fixed_string_t mode;
5706 cmd_set_uc_hash_parsed(void *parsed_result,
5707 __attribute__((unused)) struct cmdline *cl,
5708 __attribute__((unused)) void *data)
5711 struct cmd_set_uc_hash_table *res = parsed_result;
5713 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5715 if (strcmp(res->what, "uta") == 0)
5716 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5717 &res->address,(uint8_t)is_on);
5719 printf("bad unicast hash table parameter, return code = %d \n", ret);
5723 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5724 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5726 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5727 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5729 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5730 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5732 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5733 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5735 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5736 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5738 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5739 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5742 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5743 .f = cmd_set_uc_hash_parsed,
5745 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5747 (void *)&cmd_set_uc_hash_set,
5748 (void *)&cmd_set_uc_hash_port,
5749 (void *)&cmd_set_uc_hash_portid,
5750 (void *)&cmd_set_uc_hash_what,
5751 (void *)&cmd_set_uc_hash_mac,
5752 (void *)&cmd_set_uc_hash_mode,
5757 struct cmd_set_uc_all_hash_table {
5758 cmdline_fixed_string_t set;
5759 cmdline_fixed_string_t port;
5761 cmdline_fixed_string_t what;
5762 cmdline_fixed_string_t value;
5763 cmdline_fixed_string_t mode;
5767 cmd_set_uc_all_hash_parsed(void *parsed_result,
5768 __attribute__((unused)) struct cmdline *cl,
5769 __attribute__((unused)) void *data)
5772 struct cmd_set_uc_all_hash_table *res = parsed_result;
5774 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5776 if ((strcmp(res->what, "uta") == 0) &&
5777 (strcmp(res->value, "all") == 0))
5778 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5780 printf("bad unicast hash table parameter,"
5781 "return code = %d \n", ret);
5784 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5785 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5787 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5788 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5790 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5791 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5793 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5794 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5796 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5797 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5799 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5800 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5803 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5804 .f = cmd_set_uc_all_hash_parsed,
5806 .help_str = "set port X uta all on|off (X = port number)",
5808 (void *)&cmd_set_uc_all_hash_set,
5809 (void *)&cmd_set_uc_all_hash_port,
5810 (void *)&cmd_set_uc_all_hash_portid,
5811 (void *)&cmd_set_uc_all_hash_what,
5812 (void *)&cmd_set_uc_all_hash_value,
5813 (void *)&cmd_set_uc_all_hash_mode,
5818 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5819 struct cmd_set_vf_traffic {
5820 cmdline_fixed_string_t set;
5821 cmdline_fixed_string_t port;
5823 cmdline_fixed_string_t vf;
5825 cmdline_fixed_string_t what;
5826 cmdline_fixed_string_t mode;
5830 cmd_set_vf_traffic_parsed(void *parsed_result,
5831 __attribute__((unused)) struct cmdline *cl,
5832 __attribute__((unused)) void *data)
5834 struct cmd_set_vf_traffic *res = parsed_result;
5835 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5836 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5838 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5841 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5842 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5844 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5845 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5847 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5848 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5850 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5851 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5853 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5854 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5856 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5857 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5859 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5860 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5863 cmdline_parse_inst_t cmd_set_vf_traffic = {
5864 .f = cmd_set_vf_traffic_parsed,
5866 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
5868 (void *)&cmd_setvf_traffic_set,
5869 (void *)&cmd_setvf_traffic_port,
5870 (void *)&cmd_setvf_traffic_portid,
5871 (void *)&cmd_setvf_traffic_vf,
5872 (void *)&cmd_setvf_traffic_vfid,
5873 (void *)&cmd_setvf_traffic_what,
5874 (void *)&cmd_setvf_traffic_mode,
5879 /* *** CONFIGURE VF RECEIVE MODE *** */
5880 struct cmd_set_vf_rxmode {
5881 cmdline_fixed_string_t set;
5882 cmdline_fixed_string_t port;
5884 cmdline_fixed_string_t vf;
5886 cmdline_fixed_string_t what;
5887 cmdline_fixed_string_t mode;
5888 cmdline_fixed_string_t on;
5892 cmd_set_vf_rxmode_parsed(void *parsed_result,
5893 __attribute__((unused)) struct cmdline *cl,
5894 __attribute__((unused)) void *data)
5897 uint16_t rx_mode = 0;
5898 struct cmd_set_vf_rxmode *res = parsed_result;
5900 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5901 if (!strcmp(res->what,"rxmode")) {
5902 if (!strcmp(res->mode, "AUPE"))
5903 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5904 else if (!strcmp(res->mode, "ROPE"))
5905 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5906 else if (!strcmp(res->mode, "BAM"))
5907 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5908 else if (!strncmp(res->mode, "MPE",3))
5909 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5912 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5914 printf("bad VF receive mode parameter, return code = %d \n",
5918 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5919 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5921 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5922 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5924 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5925 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5927 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5930 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5931 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5933 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5934 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5936 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5937 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5938 mode, "AUPE#ROPE#BAM#MPE");
5939 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5940 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5943 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5944 .f = cmd_set_vf_rxmode_parsed,
5946 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5948 (void *)&cmd_set_vf_rxmode_set,
5949 (void *)&cmd_set_vf_rxmode_port,
5950 (void *)&cmd_set_vf_rxmode_portid,
5951 (void *)&cmd_set_vf_rxmode_vf,
5952 (void *)&cmd_set_vf_rxmode_vfid,
5953 (void *)&cmd_set_vf_rxmode_what,
5954 (void *)&cmd_set_vf_rxmode_mode,
5955 (void *)&cmd_set_vf_rxmode_on,
5960 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5961 struct cmd_vf_mac_addr_result {
5962 cmdline_fixed_string_t mac_addr_cmd;
5963 cmdline_fixed_string_t what;
5964 cmdline_fixed_string_t port;
5966 cmdline_fixed_string_t vf;
5968 struct ether_addr address;
5971 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5972 __attribute__((unused)) struct cmdline *cl,
5973 __attribute__((unused)) void *data)
5975 struct cmd_vf_mac_addr_result *res = parsed_result;
5978 if (strcmp(res->what, "add") == 0)
5979 ret = rte_eth_dev_mac_addr_add(res->port_num,
5980 &res->address, res->vf_num);
5982 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5986 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5987 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5988 mac_addr_cmd,"mac_addr");
5989 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5990 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5992 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5993 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5995 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5996 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5998 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5999 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6001 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6002 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6004 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6005 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6008 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6009 .f = cmd_vf_mac_addr_parsed,
6011 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6012 "Y = VF number)add MAC address filtering for a VF on port X",
6014 (void *)&cmd_vf_mac_addr_cmd,
6015 (void *)&cmd_vf_mac_addr_what,
6016 (void *)&cmd_vf_mac_addr_port,
6017 (void *)&cmd_vf_mac_addr_portnum,
6018 (void *)&cmd_vf_mac_addr_vf,
6019 (void *)&cmd_vf_mac_addr_vfnum,
6020 (void *)&cmd_vf_mac_addr_addr,
6025 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6026 struct cmd_vf_rx_vlan_filter {
6027 cmdline_fixed_string_t rx_vlan;
6028 cmdline_fixed_string_t what;
6030 cmdline_fixed_string_t port;
6032 cmdline_fixed_string_t vf;
6037 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6038 __attribute__((unused)) struct cmdline *cl,
6039 __attribute__((unused)) void *data)
6041 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6043 if (!strcmp(res->what, "add"))
6044 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6046 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6049 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6050 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6051 rx_vlan, "rx_vlan");
6052 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6053 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6055 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6056 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6058 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6059 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6061 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6062 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6064 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6065 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6067 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6068 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6071 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6072 .f = cmd_vf_rx_vlan_filter_parsed,
6074 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6075 "Y = port number,Z = hexadecimal VF mask)",
6077 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6078 (void *)&cmd_vf_rx_vlan_filter_what,
6079 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6080 (void *)&cmd_vf_rx_vlan_filter_port,
6081 (void *)&cmd_vf_rx_vlan_filter_portid,
6082 (void *)&cmd_vf_rx_vlan_filter_vf,
6083 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6088 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6089 struct cmd_queue_rate_limit_result {
6090 cmdline_fixed_string_t set;
6091 cmdline_fixed_string_t port;
6093 cmdline_fixed_string_t queue;
6095 cmdline_fixed_string_t rate;
6099 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6100 __attribute__((unused)) struct cmdline *cl,
6101 __attribute__((unused)) void *data)
6103 struct cmd_queue_rate_limit_result *res = parsed_result;
6106 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6107 && (strcmp(res->queue, "queue") == 0)
6108 && (strcmp(res->rate, "rate") == 0))
6109 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6112 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6116 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6117 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6119 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6120 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6122 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6123 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6125 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6126 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6128 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6129 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6131 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6132 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6134 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6135 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6138 cmdline_parse_inst_t cmd_queue_rate_limit = {
6139 .f = cmd_queue_rate_limit_parsed,
6141 .help_str = "set port X queue Y rate Z:(X = port number,"
6142 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6144 (void *)&cmd_queue_rate_limit_set,
6145 (void *)&cmd_queue_rate_limit_port,
6146 (void *)&cmd_queue_rate_limit_portnum,
6147 (void *)&cmd_queue_rate_limit_queue,
6148 (void *)&cmd_queue_rate_limit_queuenum,
6149 (void *)&cmd_queue_rate_limit_rate,
6150 (void *)&cmd_queue_rate_limit_ratenum,
6155 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6156 struct cmd_vf_rate_limit_result {
6157 cmdline_fixed_string_t set;
6158 cmdline_fixed_string_t port;
6160 cmdline_fixed_string_t vf;
6162 cmdline_fixed_string_t rate;
6164 cmdline_fixed_string_t q_msk;
6168 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6169 __attribute__((unused)) struct cmdline *cl,
6170 __attribute__((unused)) void *data)
6172 struct cmd_vf_rate_limit_result *res = parsed_result;
6175 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6176 && (strcmp(res->vf, "vf") == 0)
6177 && (strcmp(res->rate, "rate") == 0)
6178 && (strcmp(res->q_msk, "queue_mask") == 0))
6179 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6180 res->rate_num, res->q_msk_val);
6182 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6186 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6187 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6189 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6190 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6192 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6193 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6195 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6196 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6198 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6199 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6201 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6202 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6204 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6205 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6207 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6208 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6209 q_msk, "queue_mask");
6210 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6211 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6214 cmdline_parse_inst_t cmd_vf_rate_limit = {
6215 .f = cmd_vf_rate_limit_parsed,
6217 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6218 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6219 "for queues of VF on port X",
6221 (void *)&cmd_vf_rate_limit_set,
6222 (void *)&cmd_vf_rate_limit_port,
6223 (void *)&cmd_vf_rate_limit_portnum,
6224 (void *)&cmd_vf_rate_limit_vf,
6225 (void *)&cmd_vf_rate_limit_vfnum,
6226 (void *)&cmd_vf_rate_limit_rate,
6227 (void *)&cmd_vf_rate_limit_ratenum,
6228 (void *)&cmd_vf_rate_limit_q_msk,
6229 (void *)&cmd_vf_rate_limit_q_msk_val,
6234 /* *** CONFIGURE TUNNEL UDP PORT *** */
6235 struct cmd_tunnel_udp_config {
6236 cmdline_fixed_string_t cmd;
6237 cmdline_fixed_string_t what;
6243 cmd_tunnel_udp_config_parsed(void *parsed_result,
6244 __attribute__((unused)) struct cmdline *cl,
6245 __attribute__((unused)) void *data)
6247 struct cmd_tunnel_udp_config *res = parsed_result;
6248 struct rte_eth_udp_tunnel tunnel_udp;
6251 tunnel_udp.udp_port = res->udp_port;
6253 if (!strcmp(res->cmd, "rx_vxlan_port"))
6254 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6256 if (!strcmp(res->what, "add"))
6257 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6259 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6262 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6265 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6266 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6267 cmd, "rx_vxlan_port");
6268 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6269 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6271 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6272 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6274 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6275 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6278 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6279 .f = cmd_tunnel_udp_config_parsed,
6281 .help_str = "add/rm an tunneling UDP port filter: "
6282 "rx_vxlan_port add udp_port port_id",
6284 (void *)&cmd_tunnel_udp_config_cmd,
6285 (void *)&cmd_tunnel_udp_config_what,
6286 (void *)&cmd_tunnel_udp_config_udp_port,
6287 (void *)&cmd_tunnel_udp_config_port_id,
6292 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6293 struct cmd_set_mirror_mask_result {
6294 cmdline_fixed_string_t set;
6295 cmdline_fixed_string_t port;
6297 cmdline_fixed_string_t mirror;
6299 cmdline_fixed_string_t what;
6300 cmdline_fixed_string_t value;
6301 cmdline_fixed_string_t dstpool;
6303 cmdline_fixed_string_t on;
6306 cmdline_parse_token_string_t cmd_mirror_mask_set =
6307 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6309 cmdline_parse_token_string_t cmd_mirror_mask_port =
6310 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6312 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6313 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6315 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6316 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6317 mirror, "mirror-rule");
6318 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6319 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6321 cmdline_parse_token_string_t cmd_mirror_mask_what =
6322 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6323 what, "pool-mirror#vlan-mirror");
6324 cmdline_parse_token_string_t cmd_mirror_mask_value =
6325 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6327 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6328 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6329 dstpool, "dst-pool");
6330 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6331 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6333 cmdline_parse_token_string_t cmd_mirror_mask_on =
6334 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6338 cmd_set_mirror_mask_parsed(void *parsed_result,
6339 __attribute__((unused)) struct cmdline *cl,
6340 __attribute__((unused)) void *data)
6343 struct cmd_set_mirror_mask_result *res = parsed_result;
6344 struct rte_eth_vmdq_mirror_conf mr_conf;
6346 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6348 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6350 mr_conf.dst_pool = res->dstpool_id;
6352 if (!strcmp(res->what, "pool-mirror")) {
6353 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6354 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6355 } else if(!strcmp(res->what, "vlan-mirror")) {
6356 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6357 nb_item = parse_item_list(res->value, "core",
6358 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6362 for(i=0; i < nb_item; i++) {
6363 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6364 printf("Invalid vlan_id: must be < 4096\n");
6368 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6369 mr_conf.vlan.vlan_mask |= 1ULL << i;
6373 if(!strcmp(res->on, "on"))
6374 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6377 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6380 printf("mirror rule add error: (%s)\n", strerror(-ret));
6383 cmdline_parse_inst_t cmd_set_mirror_mask = {
6384 .f = cmd_set_mirror_mask_parsed,
6386 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6387 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6389 (void *)&cmd_mirror_mask_set,
6390 (void *)&cmd_mirror_mask_port,
6391 (void *)&cmd_mirror_mask_portid,
6392 (void *)&cmd_mirror_mask_mirror,
6393 (void *)&cmd_mirror_mask_ruleid,
6394 (void *)&cmd_mirror_mask_what,
6395 (void *)&cmd_mirror_mask_value,
6396 (void *)&cmd_mirror_mask_dstpool,
6397 (void *)&cmd_mirror_mask_poolid,
6398 (void *)&cmd_mirror_mask_on,
6403 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6404 struct cmd_set_mirror_link_result {
6405 cmdline_fixed_string_t set;
6406 cmdline_fixed_string_t port;
6408 cmdline_fixed_string_t mirror;
6410 cmdline_fixed_string_t what;
6411 cmdline_fixed_string_t dstpool;
6413 cmdline_fixed_string_t on;
6416 cmdline_parse_token_string_t cmd_mirror_link_set =
6417 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6419 cmdline_parse_token_string_t cmd_mirror_link_port =
6420 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6422 cmdline_parse_token_num_t cmd_mirror_link_portid =
6423 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6425 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6426 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6427 mirror, "mirror-rule");
6428 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6429 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6431 cmdline_parse_token_string_t cmd_mirror_link_what =
6432 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6433 what, "uplink-mirror#downlink-mirror");
6434 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6435 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6436 dstpool, "dst-pool");
6437 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6438 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6440 cmdline_parse_token_string_t cmd_mirror_link_on =
6441 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6445 cmd_set_mirror_link_parsed(void *parsed_result,
6446 __attribute__((unused)) struct cmdline *cl,
6447 __attribute__((unused)) void *data)
6450 struct cmd_set_mirror_link_result *res = parsed_result;
6451 struct rte_eth_vmdq_mirror_conf mr_conf;
6453 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6454 if(!strcmp(res->what, "uplink-mirror")) {
6455 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6456 }else if(!strcmp(res->what, "downlink-mirror"))
6457 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6459 mr_conf.dst_pool = res->dstpool_id;
6461 if(!strcmp(res->on, "on"))
6462 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6465 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6468 /* check the return value and print it if is < 0 */
6470 printf("mirror rule add error: (%s)\n", strerror(-ret));
6474 cmdline_parse_inst_t cmd_set_mirror_link = {
6475 .f = cmd_set_mirror_link_parsed,
6477 .help_str = "set port X mirror-rule Y uplink-mirror|"
6478 "downlink-mirror dst-pool Z on|off",
6480 (void *)&cmd_mirror_link_set,
6481 (void *)&cmd_mirror_link_port,
6482 (void *)&cmd_mirror_link_portid,
6483 (void *)&cmd_mirror_link_mirror,
6484 (void *)&cmd_mirror_link_ruleid,
6485 (void *)&cmd_mirror_link_what,
6486 (void *)&cmd_mirror_link_dstpool,
6487 (void *)&cmd_mirror_link_poolid,
6488 (void *)&cmd_mirror_link_on,
6493 /* *** RESET VM MIRROR RULE *** */
6494 struct cmd_rm_mirror_rule_result {
6495 cmdline_fixed_string_t reset;
6496 cmdline_fixed_string_t port;
6498 cmdline_fixed_string_t mirror;
6502 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6503 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6505 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6506 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6508 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6509 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6511 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6512 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6513 mirror, "mirror-rule");
6514 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6515 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6519 cmd_reset_mirror_rule_parsed(void *parsed_result,
6520 __attribute__((unused)) struct cmdline *cl,
6521 __attribute__((unused)) void *data)
6524 struct cmd_set_mirror_link_result *res = parsed_result;
6526 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6528 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6531 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6532 .f = cmd_reset_mirror_rule_parsed,
6534 .help_str = "reset port X mirror-rule Y",
6536 (void *)&cmd_rm_mirror_rule_reset,
6537 (void *)&cmd_rm_mirror_rule_port,
6538 (void *)&cmd_rm_mirror_rule_portid,
6539 (void *)&cmd_rm_mirror_rule_mirror,
6540 (void *)&cmd_rm_mirror_rule_ruleid,
6545 /* ******************************************************************************** */
6547 struct cmd_dump_result {
6548 cmdline_fixed_string_t dump;
6552 dump_struct_sizes(void)
6554 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6555 DUMP_SIZE(struct rte_mbuf);
6556 DUMP_SIZE(struct rte_mempool);
6557 DUMP_SIZE(struct rte_ring);
6561 static void cmd_dump_parsed(void *parsed_result,
6562 __attribute__((unused)) struct cmdline *cl,
6563 __attribute__((unused)) void *data)
6565 struct cmd_dump_result *res = parsed_result;
6567 if (!strcmp(res->dump, "dump_physmem"))
6568 rte_dump_physmem_layout(stdout);
6569 else if (!strcmp(res->dump, "dump_memzone"))
6570 rte_memzone_dump(stdout);
6571 else if (!strcmp(res->dump, "dump_log_history"))
6572 rte_log_dump_history(stdout);
6573 else if (!strcmp(res->dump, "dump_struct_sizes"))
6574 dump_struct_sizes();
6575 else if (!strcmp(res->dump, "dump_ring"))
6576 rte_ring_list_dump(stdout);
6577 else if (!strcmp(res->dump, "dump_mempool"))
6578 rte_mempool_list_dump(stdout);
6579 else if (!strcmp(res->dump, "dump_devargs"))
6580 rte_eal_devargs_dump(stdout);
6583 cmdline_parse_token_string_t cmd_dump_dump =
6584 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6588 "dump_struct_sizes#"
6593 cmdline_parse_inst_t cmd_dump = {
6594 .f = cmd_dump_parsed, /* function to call */
6595 .data = NULL, /* 2nd arg of func */
6596 .help_str = "dump status",
6597 .tokens = { /* token list, NULL terminated */
6598 (void *)&cmd_dump_dump,
6603 /* ******************************************************************************** */
6605 struct cmd_dump_one_result {
6606 cmdline_fixed_string_t dump;
6607 cmdline_fixed_string_t name;
6610 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6611 __attribute__((unused)) void *data)
6613 struct cmd_dump_one_result *res = parsed_result;
6615 if (!strcmp(res->dump, "dump_ring")) {
6617 r = rte_ring_lookup(res->name);
6619 cmdline_printf(cl, "Cannot find ring\n");
6622 rte_ring_dump(stdout, r);
6623 } else if (!strcmp(res->dump, "dump_mempool")) {
6624 struct rte_mempool *mp;
6625 mp = rte_mempool_lookup(res->name);
6627 cmdline_printf(cl, "Cannot find mempool\n");
6630 rte_mempool_dump(stdout, mp);
6634 cmdline_parse_token_string_t cmd_dump_one_dump =
6635 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6636 "dump_ring#dump_mempool");
6638 cmdline_parse_token_string_t cmd_dump_one_name =
6639 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6641 cmdline_parse_inst_t cmd_dump_one = {
6642 .f = cmd_dump_one_parsed, /* function to call */
6643 .data = NULL, /* 2nd arg of func */
6644 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6645 .tokens = { /* token list, NULL terminated */
6646 (void *)&cmd_dump_one_dump,
6647 (void *)&cmd_dump_one_name,
6652 /* *** ADD/REMOVE an ethertype FILTER *** */
6653 struct cmd_ethertype_filter_result {
6654 cmdline_fixed_string_t filter;
6656 cmdline_fixed_string_t ethertype;
6657 uint16_t ethertype_value;
6658 cmdline_fixed_string_t priority;
6659 cmdline_fixed_string_t priority_en;
6660 uint8_t priority_value;
6661 cmdline_fixed_string_t queue;
6663 cmdline_fixed_string_t index;
6664 uint16_t index_value;
6668 cmd_ethertype_filter_parsed(void *parsed_result,
6669 __attribute__((unused)) struct cmdline *cl,
6670 __attribute__((unused)) void *data)
6673 struct cmd_ethertype_filter_result *res = parsed_result;
6674 struct rte_ethertype_filter filter;
6676 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
6677 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
6678 filter.priority = res->priority_value;
6680 if (!strcmp(res->priority_en, "enable"))
6681 filter.priority_en = 1;
6682 if (!strcmp(res->filter, "add_ethertype_filter"))
6683 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
6685 &filter, res->queue_id);
6686 else if (!strcmp(res->filter, "remove_ethertype_filter"))
6687 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
6689 else if (!strcmp(res->filter, "get_ethertype_filter"))
6690 get_ethertype_filter(res->port_id, res->index_value);
6693 printf("ethertype filter setting error: (%s)\n",
6697 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
6698 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6700 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
6701 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6702 ethertype, "ethertype");
6703 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
6704 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6705 ethertype_value, UINT16);
6706 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
6707 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6708 priority, "priority");
6709 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
6710 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6711 priority_en, "enable#disable");
6712 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
6713 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6714 priority_value, UINT8);
6715 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
6716 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6718 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
6719 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6721 cmdline_parse_token_string_t cmd_ethertype_filter_index =
6722 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6724 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
6725 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6726 index_value, UINT16);
6727 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
6728 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6729 filter, "add_ethertype_filter");
6730 cmdline_parse_inst_t cmd_add_ethertype_filter = {
6731 .f = cmd_ethertype_filter_parsed,
6733 .help_str = "add an ethertype filter",
6735 (void *)&cmd_ethertype_filter_add_filter,
6736 (void *)&cmd_ethertype_filter_port_id,
6737 (void *)&cmd_ethertype_filter_ethertype,
6738 (void *)&cmd_ethertype_filter_ethertype_value,
6739 (void *)&cmd_ethertype_filter_priority,
6740 (void *)&cmd_ethertype_filter_priority_en,
6741 (void *)&cmd_ethertype_filter_priority_value,
6742 (void *)&cmd_ethertype_filter_queue,
6743 (void *)&cmd_ethertype_filter_queue_id,
6744 (void *)&cmd_ethertype_filter_index,
6745 (void *)&cmd_ethertype_filter_index_value,
6750 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
6751 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6752 filter, "remove_ethertype_filter");
6753 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
6754 .f = cmd_ethertype_filter_parsed,
6756 .help_str = "remove an ethertype filter",
6758 (void *)&cmd_ethertype_filter_remove_filter,
6759 (void *)&cmd_ethertype_filter_port_id,
6760 (void *)&cmd_ethertype_filter_index,
6761 (void *)&cmd_ethertype_filter_index_value,
6765 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
6766 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6767 filter, "get_ethertype_filter");
6768 cmdline_parse_inst_t cmd_get_ethertype_filter = {
6769 .f = cmd_ethertype_filter_parsed,
6771 .help_str = "get an ethertype filter",
6773 (void *)&cmd_ethertype_filter_get_filter,
6774 (void *)&cmd_ethertype_filter_port_id,
6775 (void *)&cmd_ethertype_filter_index,
6776 (void *)&cmd_ethertype_filter_index_value,
6781 /* *** set SYN filter *** */
6782 struct cmd_set_syn_filter_result {
6783 cmdline_fixed_string_t filter;
6785 cmdline_fixed_string_t priority;
6786 cmdline_fixed_string_t high;
6787 cmdline_fixed_string_t queue;
6792 cmd_set_syn_filter_parsed(void *parsed_result,
6793 __attribute__((unused)) struct cmdline *cl,
6794 __attribute__((unused)) void *data)
6797 struct cmd_set_syn_filter_result *res = parsed_result;
6798 struct rte_syn_filter filter;
6800 if (!strcmp(res->filter, "add_syn_filter")) {
6801 if (!strcmp(res->high, "high"))
6805 ret = rte_eth_dev_add_syn_filter(res->port_id,
6806 &filter, res->queue_id);
6807 } else if (!strcmp(res->filter, "remove_syn_filter"))
6808 ret = rte_eth_dev_remove_syn_filter(res->port_id);
6809 else if (!strcmp(res->filter, "get_syn_filter"))
6810 get_syn_filter(res->port_id);
6812 printf("syn filter setting error: (%s)\n", strerror(-ret));
6815 cmdline_parse_token_num_t cmd_syn_filter_portid =
6816 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6818 cmdline_parse_token_string_t cmd_syn_filter_priority =
6819 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6820 priority, "priority");
6821 cmdline_parse_token_string_t cmd_syn_filter_high =
6822 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6824 cmdline_parse_token_string_t cmd_syn_filter_queue =
6825 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6827 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6828 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6830 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
6831 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6832 filter, "add_syn_filter");
6833 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
6834 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6835 filter, "remove_syn_filter");
6836 cmdline_parse_inst_t cmd_add_syn_filter = {
6837 .f = cmd_set_syn_filter_parsed,
6839 .help_str = "add syn filter",
6841 (void *)&cmd_syn_filter_add_filter,
6842 (void *)&cmd_syn_filter_portid,
6843 (void *)&cmd_syn_filter_priority,
6844 (void *)&cmd_syn_filter_high,
6845 (void *)&cmd_syn_filter_queue,
6846 (void *)&cmd_syn_filter_queue_id,
6850 cmdline_parse_inst_t cmd_remove_syn_filter = {
6851 .f = cmd_set_syn_filter_parsed,
6853 .help_str = "remove syn filter",
6855 (void *)&cmd_syn_filter_remove_filter,
6856 (void *)&cmd_syn_filter_portid,
6861 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
6862 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6863 filter, "get_syn_filter");
6865 cmdline_parse_inst_t cmd_get_syn_filter = {
6866 .f = cmd_set_syn_filter_parsed,
6868 .help_str = "get syn filter",
6870 (void *)&cmd_syn_filter_get_filter,
6871 (void *)&cmd_syn_filter_portid,
6876 /* *** ADD/REMOVE A 2tuple FILTER *** */
6877 struct cmd_2tuple_filter_result {
6878 cmdline_fixed_string_t filter;
6880 cmdline_fixed_string_t protocol;
6881 uint8_t protocol_value;
6882 uint8_t protocol_mask;
6883 cmdline_fixed_string_t dst_port;
6884 uint16_t dst_port_value;
6885 uint16_t dst_port_mask;
6886 cmdline_fixed_string_t flags;
6887 uint8_t flags_value;
6888 cmdline_fixed_string_t priority;
6889 uint8_t priority_value;
6890 cmdline_fixed_string_t queue;
6892 cmdline_fixed_string_t index;
6893 uint16_t index_value;
6897 cmd_2tuple_filter_parsed(void *parsed_result,
6898 __attribute__((unused)) struct cmdline *cl,
6899 __attribute__((unused)) void *data)
6902 struct rte_2tuple_filter filter;
6903 struct cmd_2tuple_filter_result *res = parsed_result;
6905 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
6907 if (!strcmp(res->filter, "add_2tuple_filter")) {
6908 /* need convert to big endian. */
6909 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6910 filter.protocol = res->protocol_value;
6911 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
6912 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
6913 filter.priority = res->priority_value;
6914 filter.tcp_flags = res->flags_value;
6915 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
6916 res->index_value, &filter, res->queue_id);
6917 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
6918 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
6920 else if (!strcmp(res->filter, "get_2tuple_filter"))
6921 get_2tuple_filter(res->port_id, res->index_value);
6924 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
6927 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6928 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6930 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6931 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6932 protocol, "protocol");
6933 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6934 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6935 protocol_value, UINT8);
6936 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
6937 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6938 protocol_mask, UINT8);
6939 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6940 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6941 dst_port, "dst_port");
6942 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6943 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6944 dst_port_value, UINT16);
6945 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
6946 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6947 dst_port_mask, UINT16);
6948 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
6949 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6951 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
6952 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6953 flags_value, UINT8);
6954 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6955 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6956 priority, "priority");
6957 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6958 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6959 priority_value, UINT8);
6960 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6961 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6963 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6964 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6966 cmdline_parse_token_string_t cmd_2tuple_filter_index =
6967 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6969 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
6970 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6971 index_value, UINT16);
6972 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
6973 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6974 filter, "add_2tuple_filter");
6975 cmdline_parse_inst_t cmd_add_2tuple_filter = {
6976 .f = cmd_2tuple_filter_parsed,
6978 .help_str = "add a 2tuple filter",
6980 (void *)&cmd_2tuple_filter_add_filter,
6981 (void *)&cmd_2tuple_filter_port_id,
6982 (void *)&cmd_2tuple_filter_protocol,
6983 (void *)&cmd_2tuple_filter_protocol_value,
6984 (void *)&cmd_2tuple_filter_protocol_mask,
6985 (void *)&cmd_2tuple_filter_dst_port,
6986 (void *)&cmd_2tuple_filter_dst_port_value,
6987 (void *)&cmd_2tuple_filter_dst_port_mask,
6988 (void *)&cmd_2tuple_filter_flags,
6989 (void *)&cmd_2tuple_filter_flags_value,
6990 (void *)&cmd_2tuple_filter_priority,
6991 (void *)&cmd_2tuple_filter_priority_value,
6992 (void *)&cmd_2tuple_filter_queue,
6993 (void *)&cmd_2tuple_filter_queue_id,
6994 (void *)&cmd_2tuple_filter_index,
6995 (void *)&cmd_2tuple_filter_index_value,
7000 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7001 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7002 filter, "remove_2tuple_filter");
7003 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7004 .f = cmd_2tuple_filter_parsed,
7006 .help_str = "remove a 2tuple filter",
7008 (void *)&cmd_2tuple_filter_remove_filter,
7009 (void *)&cmd_2tuple_filter_port_id,
7010 (void *)&cmd_2tuple_filter_index,
7011 (void *)&cmd_2tuple_filter_index_value,
7015 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7016 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7017 filter, "get_2tuple_filter");
7018 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7019 .f = cmd_2tuple_filter_parsed,
7021 .help_str = "get a 2tuple filter",
7023 (void *)&cmd_2tuple_filter_get_filter,
7024 (void *)&cmd_2tuple_filter_port_id,
7025 (void *)&cmd_2tuple_filter_index,
7026 (void *)&cmd_2tuple_filter_index_value,
7031 /* *** ADD/REMOVE A 5tuple FILTER *** */
7032 struct cmd_5tuple_filter_result {
7033 cmdline_fixed_string_t filter;
7035 cmdline_fixed_string_t dst_ip;
7036 cmdline_ipaddr_t dst_ip_value;
7037 cmdline_fixed_string_t src_ip;
7038 cmdline_ipaddr_t src_ip_value;
7039 cmdline_fixed_string_t dst_port;
7040 uint16_t dst_port_value;
7041 cmdline_fixed_string_t src_port;
7042 uint16_t src_port_value;
7043 cmdline_fixed_string_t protocol;
7044 uint8_t protocol_value;
7045 cmdline_fixed_string_t mask;
7047 cmdline_fixed_string_t flags;
7048 uint8_t flags_value;
7049 cmdline_fixed_string_t priority;
7050 uint8_t priority_value;
7051 cmdline_fixed_string_t queue;
7053 cmdline_fixed_string_t index;
7054 uint16_t index_value;
7058 cmd_5tuple_filter_parsed(void *parsed_result,
7059 __attribute__((unused)) struct cmdline *cl,
7060 __attribute__((unused)) void *data)
7063 struct rte_5tuple_filter filter;
7064 struct cmd_5tuple_filter_result *res = parsed_result;
7066 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7068 if (!strcmp(res->filter, "add_5tuple_filter")) {
7069 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7070 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7071 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7072 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7073 filter.protocol = res->protocol_value;
7074 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7075 filter.priority = res->priority_value;
7076 filter.tcp_flags = res->flags_value;
7078 if (res->dst_ip_value.family == AF_INET)
7079 /* no need to convert, already big endian. */
7080 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7082 if (filter.dst_ip_mask == 0) {
7083 printf("can not support ipv6 involved compare.\n");
7089 if (res->src_ip_value.family == AF_INET)
7090 /* no need to convert, already big endian. */
7091 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7093 if (filter.src_ip_mask == 0) {
7094 printf("can not support ipv6 involved compare.\n");
7099 /* need convert to big endian. */
7100 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7101 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7103 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7104 res->index_value, &filter, res->queue_id);
7105 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7106 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7108 else if (!strcmp(res->filter, "get_5tuple_filter"))
7109 get_5tuple_filter(res->port_id, res->index_value);
7111 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7115 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7116 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7118 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7119 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7121 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7122 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7124 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7125 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7127 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7128 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7130 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7131 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7132 dst_port, "dst_port");
7133 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7134 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7135 dst_port_value, UINT16);
7136 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7137 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7138 src_port, "src_port");
7139 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7140 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7141 src_port_value, UINT16);
7142 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7143 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7144 protocol, "protocol");
7145 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7146 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7147 protocol_value, UINT8);
7148 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7149 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7151 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7152 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7154 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7155 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7157 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7158 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7159 flags_value, UINT8);
7160 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7161 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7162 priority, "priority");
7163 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7164 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7165 priority_value, UINT8);
7166 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7167 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7169 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7170 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7172 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7173 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7175 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7176 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7177 index_value, UINT16);
7179 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7180 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7181 filter, "add_5tuple_filter");
7182 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7183 .f = cmd_5tuple_filter_parsed,
7185 .help_str = "add a 5tuple filter",
7187 (void *)&cmd_5tuple_filter_add_filter,
7188 (void *)&cmd_5tuple_filter_port_id,
7189 (void *)&cmd_5tuple_filter_dst_ip,
7190 (void *)&cmd_5tuple_filter_dst_ip_value,
7191 (void *)&cmd_5tuple_filter_src_ip,
7192 (void *)&cmd_5tuple_filter_src_ip_value,
7193 (void *)&cmd_5tuple_filter_dst_port,
7194 (void *)&cmd_5tuple_filter_dst_port_value,
7195 (void *)&cmd_5tuple_filter_src_port,
7196 (void *)&cmd_5tuple_filter_src_port_value,
7197 (void *)&cmd_5tuple_filter_protocol,
7198 (void *)&cmd_5tuple_filter_protocol_value,
7199 (void *)&cmd_5tuple_filter_mask,
7200 (void *)&cmd_5tuple_filter_mask_value,
7201 (void *)&cmd_5tuple_filter_flags,
7202 (void *)&cmd_5tuple_filter_flags_value,
7203 (void *)&cmd_5tuple_filter_priority,
7204 (void *)&cmd_5tuple_filter_priority_value,
7205 (void *)&cmd_5tuple_filter_queue,
7206 (void *)&cmd_5tuple_filter_queue_id,
7207 (void *)&cmd_5tuple_filter_index,
7208 (void *)&cmd_5tuple_filter_index_value,
7213 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7214 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7215 filter, "remove_5tuple_filter");
7216 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7217 .f = cmd_5tuple_filter_parsed,
7219 .help_str = "remove a 5tuple filter",
7221 (void *)&cmd_5tuple_filter_remove_filter,
7222 (void *)&cmd_5tuple_filter_port_id,
7223 (void *)&cmd_5tuple_filter_index,
7224 (void *)&cmd_5tuple_filter_index_value,
7229 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7230 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7231 filter, "get_5tuple_filter");
7232 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7233 .f = cmd_5tuple_filter_parsed,
7235 .help_str = "get a 5tuple filter",
7237 (void *)&cmd_5tuple_filter_get_filter,
7238 (void *)&cmd_5tuple_filter_port_id,
7239 (void *)&cmd_5tuple_filter_index,
7240 (void *)&cmd_5tuple_filter_index_value,
7245 /* *** ADD/REMOVE A flex FILTER *** */
7246 struct cmd_flex_filter_result {
7247 cmdline_fixed_string_t filter;
7249 cmdline_fixed_string_t len;
7251 cmdline_fixed_string_t bytes;
7252 cmdline_fixed_string_t bytes_value;
7253 cmdline_fixed_string_t mask;
7254 cmdline_fixed_string_t mask_value;
7255 cmdline_fixed_string_t priority;
7256 uint8_t priority_value;
7257 cmdline_fixed_string_t queue;
7259 cmdline_fixed_string_t index;
7260 uint16_t index_value;
7263 static int xdigit2val(unsigned char c)
7268 else if (isupper(c))
7276 cmd_flex_filter_parsed(void *parsed_result,
7277 __attribute__((unused)) struct cmdline *cl,
7278 __attribute__((unused)) void *data)
7281 struct rte_flex_filter filter;
7282 struct cmd_flex_filter_result *res = parsed_result;
7283 char *bytes_ptr, *mask_ptr;
7291 if (!strcmp(res->filter, "add_flex_filter")) {
7292 if (res->len_value > 128) {
7293 printf("the len exceed the max length 128\n");
7296 memset(&filter, 0, sizeof(struct rte_flex_filter));
7297 filter.len = res->len_value;
7298 filter.priority = res->priority_value;
7299 bytes_ptr = res->bytes_value;
7300 mask_ptr = res->mask_value;
7303 /* translate bytes string to uint_32 array. */
7304 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7305 (bytes_ptr[1] == 'X')))
7307 len = strnlen(bytes_ptr, res->len_value * 2);
7308 if (len == 0 || (len % 8 != 0)) {
7309 printf("please check len and bytes input\n");
7312 for (i = 0; i < len; i++) {
7314 if (isxdigit(c) == 0) {
7315 /* invalid characters. */
7316 printf("invalid input\n");
7319 val = xdigit2val(c);
7323 dword |= byte << (4 * mod - 4);
7328 filter.dwords[j] = dword;
7329 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7335 /* translate mask string to uint8_t array. */
7337 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7338 (mask_ptr[1] == 'X')))
7340 len = strnlen(mask_ptr, (res->len_value+3)/4);
7342 printf("invalid input\n");
7345 for (i = 0; i < len; i++) {
7347 if (isxdigit(c) == 0) {
7348 /* invalid characters. */
7349 printf("invalid input\n");
7352 val = xdigit2val(c);
7353 hex |= (uint8_t)(val & 0x8) >> 3;
7354 hex |= (uint8_t)(val & 0x4) >> 1;
7355 hex |= (uint8_t)(val & 0x2) << 1;
7356 hex |= (uint8_t)(val & 0x1) << 3;
7359 filter.mask[j] = byte;
7360 printf("mask[%d]:%02x ", j, filter.mask[j]);
7368 printf("call function rte_eth_dev_add_flex_filter: "
7369 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7370 res->index_value, res->queue_id,
7371 filter.len, filter.priority);
7372 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7373 &filter, res->queue_id);
7375 } else if (!strcmp(res->filter, "remove_flex_filter"))
7376 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7378 else if (!strcmp(res->filter, "get_flex_filter"))
7379 get_flex_filter(res->port_id, res->index_value);
7382 printf("flex filter setting error: (%s)\n", strerror(-ret));
7385 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7386 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7388 cmdline_parse_token_string_t cmd_flex_filter_len =
7389 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7391 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7392 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7394 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7395 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7397 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7398 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7400 cmdline_parse_token_string_t cmd_flex_filter_mask =
7401 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7403 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7404 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7406 cmdline_parse_token_string_t cmd_flex_filter_priority =
7407 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7408 priority, "priority");
7409 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7410 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7411 priority_value, UINT8);
7412 cmdline_parse_token_string_t cmd_flex_filter_queue =
7413 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7415 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7416 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7418 cmdline_parse_token_string_t cmd_flex_filter_index =
7419 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7421 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7422 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7423 index_value, UINT16);
7424 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7425 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7426 filter, "add_flex_filter");
7427 cmdline_parse_inst_t cmd_add_flex_filter = {
7428 .f = cmd_flex_filter_parsed,
7430 .help_str = "add a flex filter",
7432 (void *)&cmd_flex_filter_add_filter,
7433 (void *)&cmd_flex_filter_port_id,
7434 (void *)&cmd_flex_filter_len,
7435 (void *)&cmd_flex_filter_len_value,
7436 (void *)&cmd_flex_filter_bytes,
7437 (void *)&cmd_flex_filter_bytes_value,
7438 (void *)&cmd_flex_filter_mask,
7439 (void *)&cmd_flex_filter_mask_value,
7440 (void *)&cmd_flex_filter_priority,
7441 (void *)&cmd_flex_filter_priority_value,
7442 (void *)&cmd_flex_filter_queue,
7443 (void *)&cmd_flex_filter_queue_id,
7444 (void *)&cmd_flex_filter_index,
7445 (void *)&cmd_flex_filter_index_value,
7450 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7451 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7452 filter, "remove_flex_filter");
7453 cmdline_parse_inst_t cmd_remove_flex_filter = {
7454 .f = cmd_flex_filter_parsed,
7456 .help_str = "remove a flex filter",
7458 (void *)&cmd_flex_filter_remove_filter,
7459 (void *)&cmd_flex_filter_port_id,
7460 (void *)&cmd_flex_filter_index,
7461 (void *)&cmd_flex_filter_index_value,
7466 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7467 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7468 filter, "get_flex_filter");
7469 cmdline_parse_inst_t cmd_get_flex_filter = {
7470 .f = cmd_flex_filter_parsed,
7472 .help_str = "get a flex filter",
7474 (void *)&cmd_flex_filter_get_filter,
7475 (void *)&cmd_flex_filter_port_id,
7476 (void *)&cmd_flex_filter_index,
7477 (void *)&cmd_flex_filter_index_value,
7482 /* ******************************************************************************** */
7484 /* list of instructions */
7485 cmdline_parse_ctx_t main_ctx[] = {
7486 (cmdline_parse_inst_t *)&cmd_help_brief,
7487 (cmdline_parse_inst_t *)&cmd_help_long,
7488 (cmdline_parse_inst_t *)&cmd_quit,
7489 (cmdline_parse_inst_t *)&cmd_showport,
7490 (cmdline_parse_inst_t *)&cmd_showportall,
7491 (cmdline_parse_inst_t *)&cmd_showcfg,
7492 (cmdline_parse_inst_t *)&cmd_start,
7493 (cmdline_parse_inst_t *)&cmd_start_tx_first,
7494 (cmdline_parse_inst_t *)&cmd_set_link_up,
7495 (cmdline_parse_inst_t *)&cmd_set_link_down,
7496 (cmdline_parse_inst_t *)&cmd_reset,
7497 (cmdline_parse_inst_t *)&cmd_set_numbers,
7498 (cmdline_parse_inst_t *)&cmd_set_txpkts,
7499 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
7500 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
7501 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
7502 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
7503 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
7504 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
7505 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
7506 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
7507 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
7508 (cmdline_parse_inst_t *)&cmd_set_link_check,
7509 #ifdef RTE_NIC_BYPASS
7510 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
7511 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
7512 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
7513 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
7515 #ifdef RTE_LIBRTE_PMD_BOND
7516 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
7517 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
7518 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
7519 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
7520 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
7521 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
7522 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
7523 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
7525 (cmdline_parse_inst_t *)&cmd_vlan_offload,
7526 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
7527 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
7528 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
7529 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
7530 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
7531 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
7532 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
7533 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
7534 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
7535 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
7536 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
7537 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
7538 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
7539 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
7540 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
7541 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
7542 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
7543 (cmdline_parse_inst_t *)&cmd_config_dcb,
7544 (cmdline_parse_inst_t *)&cmd_read_reg,
7545 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
7546 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
7547 (cmdline_parse_inst_t *)&cmd_write_reg,
7548 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
7549 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
7550 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
7551 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
7552 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
7553 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
7554 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
7555 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
7556 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
7557 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
7558 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
7559 (cmdline_parse_inst_t *)&cmd_stop,
7560 (cmdline_parse_inst_t *)&cmd_mac_addr,
7561 (cmdline_parse_inst_t *)&cmd_set_qmap,
7562 (cmdline_parse_inst_t *)&cmd_operate_port,
7563 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
7564 (cmdline_parse_inst_t *)&cmd_config_speed_all,
7565 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
7566 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
7567 (cmdline_parse_inst_t *)&cmd_config_mtu,
7568 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
7569 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
7570 (cmdline_parse_inst_t *)&cmd_config_rss,
7571 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
7572 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
7573 (cmdline_parse_inst_t *)&cmd_showport_reta,
7574 (cmdline_parse_inst_t *)&cmd_config_burst,
7575 (cmdline_parse_inst_t *)&cmd_config_thresh,
7576 (cmdline_parse_inst_t *)&cmd_config_threshold,
7577 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
7578 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
7579 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
7580 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
7581 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
7582 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
7583 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
7584 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
7585 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
7586 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
7587 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
7588 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
7589 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
7590 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
7591 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
7592 (cmdline_parse_inst_t *)&cmd_dump,
7593 (cmdline_parse_inst_t *)&cmd_dump_one,
7594 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
7595 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
7596 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
7597 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
7598 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
7599 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
7600 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
7601 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
7602 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
7603 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
7604 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
7605 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
7606 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
7607 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
7608 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
7612 /* prompt function, called from main on MASTER lcore */
7618 /* initialize non-constant commands */
7619 cmd_set_fwd_mode_init();
7621 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
7625 cmdline_interact(cl);
7626 cmdline_stdin_exit(cl);
7630 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
7632 if (id < nb_ports) {
7633 /* check if need_reconfig has been set to 1 */
7634 if (ports[id].need_reconfig == 0)
7635 ports[id].need_reconfig = dev;
7636 /* check if need_reconfig_queues has been set to 1 */
7637 if (ports[id].need_reconfig_queues == 0)
7638 ports[id].need_reconfig_queues = queue;
7642 for (pid = 0; pid < nb_ports; pid++) {
7643 /* check if need_reconfig has been set to 1 */
7644 if (ports[pid].need_reconfig == 0)
7645 ports[pid].need_reconfig = dev;
7646 /* check if need_reconfig_queues has been set to 1 */
7647 if (ports[pid].need_reconfig_queues == 0)
7648 ports[pid].need_reconfig_queues = queue;
7653 #ifdef RTE_NIC_BYPASS
7655 bypass_is_supported(portid_t port_id)
7657 struct rte_port *port;
7658 struct rte_pci_id *pci_id;
7660 if (port_id >= nb_ports) {
7661 printf("\tPort id must be less than %d.\n", nb_ports);
7665 /* Get the device id. */
7666 port = &ports[port_id];
7667 pci_id = &port->dev_info.pci_dev->id;
7669 /* Check if NIC supports bypass. */
7670 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
7674 printf("\tBypass not supported for port_id = %d.\n", port_id);