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 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
289 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
290 " add a tunnel filter of a port.\n\n"
292 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
293 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
294 " remove a tunnel filter of a port.\n\n"
296 "rx_vxlan_port add (udp_port) (port_id)\n"
297 " Add an UDP port for VxLAN packet filter on a port\n\n"
299 "rx_vxlan_port rm (udp_port) (port_id)\n"
300 " Remove an UDP port for VxLAN packet filter on a port\n\n"
302 "tx_vlan set vlan_id (port_id)\n"
303 " Set hardware insertion of VLAN ID in packets sent"
306 "tx_vlan set pvid port_id vlan_id (on|off)\n"
307 " Set port based TX VLAN insertion.\n\n"
309 "tx_vlan reset (port_id)\n"
310 " Disable hardware insertion of a VLAN header in"
311 " packets sent on a port.\n\n"
313 "tx_checksum set mask (port_id)\n"
314 " Enable hardware insertion of checksum offload with"
315 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
316 " bit 0 - insert ip checksum offload if set\n"
317 " bit 1 - insert udp checksum offload if set\n"
318 " bit 2 - insert tcp checksum offload if set\n"
319 " bit 3 - insert sctp checksum offload if set\n"
320 " Please check the NIC datasheet for HW limits.\n\n"
323 " Set packet forwarding mode.\n\n"
325 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
326 " Add a MAC address on port_id.\n\n"
328 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
329 " Remove a MAC address from port_id.\n\n"
331 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
332 " Add a MAC address for a VF on the port.\n\n"
334 "set port (port_id) uta (mac_address|all) (on|off)\n"
335 " Add/Remove a or all unicast hash filter(s)"
338 "set promisc (port_id|all) (on|off)\n"
339 " Set the promiscuous mode on port_id, or all.\n\n"
341 "set allmulti (port_id|all) (on|off)\n"
342 " Set the allmulti mode on port_id, or all.\n\n"
344 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
345 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
346 " (on|off) autoneg (on|off) (port_id)\n"
347 "set flow_ctrl rx (on|off) (portid)\n"
348 "set flow_ctrl tx (on|off) (portid)\n"
349 "set flow_ctrl high_water (high_water) (portid)\n"
350 "set flow_ctrl low_water (low_water) (portid)\n"
351 "set flow_ctrl pause_time (pause_time) (portid)\n"
352 "set flow_ctrl send_xon (send_xon) (portid)\n"
353 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
354 "set flow_ctrl autoneg (on|off) (port_id)\n"
355 " Set the link flow control parameter on a port.\n\n"
357 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
358 " (low_water) (pause_time) (priority) (port_id)\n"
359 " Set the priority flow control parameter on a"
362 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
363 " Set statistics mapping (qmapping 0..15) for RX/TX"
365 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
366 " on port 0 to mapping 5.\n\n"
368 "set port (port_id) vf (vf_id) rx|tx on|off \n"
369 " Enable/Disable a VF receive/tranmit from a port\n\n"
371 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
373 " AUPE:accepts untagged VLAN;"
374 "ROPE:accept unicast hash\n\n"
375 " BAM:accepts broadcast packets;"
376 "MPE:accepts all multicast packets\n\n"
377 " Enable/Disable a VF receive mode of a port\n\n"
379 "set port (port_id) queue (queue_id) rate (rate_num)\n"
380 " Set rate limit for a queue of a port\n\n"
382 "set port (port_id) vf (vf_id) rate (rate_num) "
383 "queue_mask (queue_mask_value)\n"
384 " Set rate limit for queues in VF of a port\n\n"
386 "set port (port_id) mirror-rule (rule_id)"
387 "(pool-mirror|vlan-mirror)\n"
388 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
389 " Set pool or vlan type mirror rule on a port.\n"
390 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
391 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
394 "set port (port_id) mirror-rule (rule_id)"
395 " (uplink-mirror|downlink-mirror) dst-pool"
396 " (pool_id) (on|off)\n"
397 " Set uplink or downlink type mirror rule on a port.\n"
398 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
399 " 0 on' enable mirror income traffic to pool 0.\n\n"
401 "reset port (port_id) mirror-rule (rule_id)\n"
402 " Reset a mirror rule.\n\n"
404 "set flush_rx (on|off)\n"
405 " Flush (default) or don't flush RX streams before"
406 " forwarding. Mainly used with PCAP drivers.\n\n"
408 #ifdef RTE_NIC_BYPASS
409 "set bypass mode (normal|bypass|isolate) (port_id)\n"
410 " Set the bypass mode for the lowest port on bypass enabled"
413 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
414 "mode (normal|bypass|isolate) (port_id)\n"
415 " Set the event required to initiate specified bypass mode for"
416 " the lowest port on a bypass enabled NIC where:\n"
417 " timeout = enable bypass after watchdog timeout.\n"
418 " os_on = enable bypass when OS/board is powered on.\n"
419 " os_off = enable bypass when OS/board is powered off.\n"
420 " power_on = enable bypass when power supply is turned on.\n"
421 " power_off = enable bypass when power supply is turned off."
424 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
425 " Set the bypass watchdog timeout to 'n' seconds"
426 " where 0 = instant.\n\n"
428 "show bypass config (port_id)\n"
429 " Show the bypass configuration for a bypass enabled NIC"
430 " using the lowest port on the NIC.\n\n"
432 #ifdef RTE_LIBRTE_PMD_BOND
433 "create bonded device (mode) (socket)\n"
434 " Create a new bonded device with specific bonding mode and socket.\n\n"
436 "add bonding slave (slave_id) (port_id)\n"
437 " Add a slave device to a bonded device.\n\n"
439 "remove bonding slave (slave_id) (port_id)\n"
440 " Remove a slave device from a bonded device.\n\n"
442 "set bonding mode (value) (port_id)\n"
443 " Set the bonding mode on a bonded device.\n\n"
445 "set bonding primary (slave_id) (port_id)\n"
446 " Set the primary slave for a bonded device.\n\n"
448 "show bonding config (port_id)\n"
449 " Show the bonding config for port_id.\n\n"
451 "set bonding mac_addr (port_id) (address)\n"
452 " Set the MAC address of a bonded device.\n\n"
454 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
455 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
458 , list_pkt_forwarding_modes()
463 if (show_all || !strcmp(res->section, "flowdir")) {
468 "Flow director mode:\n"
469 "-------------------\n\n"
471 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
472 " src (src_ip_address) (src_port)"
473 " dst (dst_ip_address) (dst_port)"
474 " flexbytes (flexbytes_values) vlan (vlan_id)"
475 " queue (queue_id)\n"
476 " Add a signature filter.\n\n"
478 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
479 " src (src_ip_address) (src_port)"
480 " dst (dst_ip_address) (dst_port)"
481 " flexbytes (flexbytes_values) vlan (vlan_id)"
482 " queue (queue_id)\n"
483 " Update a signature filter.\n\n"
485 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
486 " src (src_ip_address) (src_port)"
487 " dst (dst_ip_address) (dst_port)"
488 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
489 " Remove a signature filter.\n\n"
491 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
492 " src (src_ip_address) (src_port)"
493 " dst (dst_ip_address) (dst_port)"
494 " flexbytes (flexbytes_values) vlan (vlan_id)"
495 " queue (queue_id) soft (soft_id)\n"
496 " Add a perfect filter.\n\n"
498 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
499 " src (src_ip_address) (src_port)"
500 " dst (dst_ip_address) (dst_port)"
501 " flexbytes (flexbytes_values) vlan (vlan_id)"
502 " queue (queue_id)\n"
503 " Update a perfect filter.\n\n"
505 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
506 " src (src_ip_address) (src_port)"
507 " dst (dst_ip_address) (dst_port)"
508 " flexbytes (flexbytes_values) vlan (vlan_id)"
510 " Remove a perfect filter.\n\n"
512 "set_masks_filter (port_id) only_ip_flow (0|1)"
513 " src_mask (ip_src_mask) (src_port_mask)"
514 " dst_mask (ip_dst_mask) (dst_port_mask)"
515 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
516 " Set IPv4 filter masks.\n\n"
518 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
519 " src_mask (ip_src_mask) (src_port_mask)"
520 " dst_mask (ip_dst_mask) (dst_port_mask)"
521 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
522 " compare_dst (0|1)\n"
523 " Set IPv6 filter masks.\n\n"
527 if (show_all || !strcmp(res->section, "ports")) {
533 "----------------\n\n"
535 "port start (port_id|all)\n"
536 " Start all ports or port_id.\n\n"
538 "port stop (port_id|all)\n"
539 " Stop all ports or port_id.\n\n"
541 "port close (port_id|all)\n"
542 " Close all ports or port_id.\n\n"
544 "port config (port_id|all)"
545 " speed (10|100|1000|10000|40000|auto)"
546 " duplex (half|full|auto)\n"
547 " Set speed and duplex for all ports or port_id\n\n"
549 "port config all (rxq|txq|rxd|txd) (value)\n"
550 " Set number for rxq/txq/rxd/txd.\n\n"
552 "port config all max-pkt-len (value)\n"
553 " Set the max packet length.\n\n"
555 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
557 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
560 "port config all rss (ip|udp|none)\n"
561 " Set the RSS mode.\n\n"
563 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
564 " Set the RSS redirection table.\n\n"
566 "port config (port_id) dcb vt (on|off) (traffic_class)"
568 " Set the DCB mode.\n\n"
570 "port config all burst (value)\n"
571 " Set the number of packets per burst.\n\n"
573 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
575 " Set the ring prefetch/host/writeback threshold"
576 " for tx/rx queue.\n\n"
578 "port config all (txfreet|txrst|rxfreet) (value)\n"
579 " Set free threshold for rx/tx, or set"
580 " tx rs bit threshold.\n\n"
581 "port config mtu X value\n"
582 " Set the MTU of port X to a given value\n\n"
584 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
585 " Start/stop a rx/tx queue of port X. Only take effect"
586 " when port X is started\n"
590 if (show_all || !strcmp(res->section, "registers")) {
598 "read reg (port_id) (address)\n"
599 " Display value of a port register.\n\n"
601 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
602 " Display a port register bit field.\n\n"
604 "read regbit (port_id) (address) (bit_x)\n"
605 " Display a single port register bit.\n\n"
607 "write reg (port_id) (address) (value)\n"
608 " Set value of a port register.\n\n"
610 "write regfield (port_id) (address) (bit_x) (bit_y)"
612 " Set bit field of a port register.\n\n"
614 "write regbit (port_id) (address) (bit_x) (value)\n"
615 " Set single bit value of a port register.\n\n"
618 if (show_all || !strcmp(res->section, "filters")) {
626 "add_ethertype_filter (port_id) ethertype (eth_value)"
627 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
628 " add an ethertype filter.\n\n"
630 "remove_ethertype_filter (port_id) index (idx)\n"
631 " remove an ethertype filter.\n\n"
633 "get_ethertype_filter (port_id) index (idx)\n"
634 " get info of a ethertype filter.\n\n"
636 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
637 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
638 " queue (queue_id) index (idx)\n"
639 " add a 2tuple filter.\n\n"
641 "remove_2tuple_filter (port_id) index (idx)\n"
642 " remove a 2tuple filter.\n\n"
644 "get_2tuple_filter (port_id) index (idx)\n"
645 " get info of a 2tuple filter.\n\n"
647 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
648 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
649 " mask (mask_value) flags (flags_value) priority (prio_value)"
650 " queue (queue_id) index (idx)\n"
651 " add a 5tuple filter.\n\n"
653 "remove_5tuple_filter (port_id) index (idx)\n"
654 " remove a 5tuple filter.\n\n"
656 "get_5tuple_filter (port_id) index (idx)\n"
657 " get info of a 5tuple filter.\n\n"
659 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
660 " add syn filter.\n\n"
662 "remove_syn_filter (port_id)"
663 " remove syn filter.\n\n"
665 "get_syn_filter (port_id) "
666 " get syn filter info.\n\n"
668 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
669 " priority (prio_value) queue (queue_id) index (idx)\n"
670 " add a flex filter.\n\n"
672 "remove_flex_filter (port_id) index (idx)\n"
673 " remove a flex filter.\n\n"
675 "get_flex_filter (port_id) index (idx)\n"
676 " get info of a flex filter.\n\n"
681 cmdline_parse_token_string_t cmd_help_long_help =
682 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
684 cmdline_parse_token_string_t cmd_help_long_section =
685 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
686 "all#control#display#config#flowdir#"
687 "ports#registers#filters");
689 cmdline_parse_inst_t cmd_help_long = {
690 .f = cmd_help_long_parsed,
692 .help_str = "show help",
694 (void *)&cmd_help_long_help,
695 (void *)&cmd_help_long_section,
701 /* *** start/stop/close all ports *** */
702 struct cmd_operate_port_result {
703 cmdline_fixed_string_t keyword;
704 cmdline_fixed_string_t name;
705 cmdline_fixed_string_t value;
708 static void cmd_operate_port_parsed(void *parsed_result,
709 __attribute__((unused)) struct cmdline *cl,
710 __attribute__((unused)) void *data)
712 struct cmd_operate_port_result *res = parsed_result;
714 if (!strcmp(res->name, "start"))
715 start_port(RTE_PORT_ALL);
716 else if (!strcmp(res->name, "stop"))
717 stop_port(RTE_PORT_ALL);
718 else if (!strcmp(res->name, "close"))
719 close_port(RTE_PORT_ALL);
721 printf("Unknown parameter\n");
724 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
725 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
727 cmdline_parse_token_string_t cmd_operate_port_all_port =
728 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
730 cmdline_parse_token_string_t cmd_operate_port_all_all =
731 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
733 cmdline_parse_inst_t cmd_operate_port = {
734 .f = cmd_operate_port_parsed,
736 .help_str = "port start|stop|close all: start/stop/close all ports",
738 (void *)&cmd_operate_port_all_cmd,
739 (void *)&cmd_operate_port_all_port,
740 (void *)&cmd_operate_port_all_all,
745 /* *** start/stop/close specific port *** */
746 struct cmd_operate_specific_port_result {
747 cmdline_fixed_string_t keyword;
748 cmdline_fixed_string_t name;
752 static void cmd_operate_specific_port_parsed(void *parsed_result,
753 __attribute__((unused)) struct cmdline *cl,
754 __attribute__((unused)) void *data)
756 struct cmd_operate_specific_port_result *res = parsed_result;
758 if (!strcmp(res->name, "start"))
759 start_port(res->value);
760 else if (!strcmp(res->name, "stop"))
761 stop_port(res->value);
762 else if (!strcmp(res->name, "close"))
763 close_port(res->value);
765 printf("Unknown parameter\n");
768 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
769 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
771 cmdline_parse_token_string_t cmd_operate_specific_port_port =
772 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
773 name, "start#stop#close");
774 cmdline_parse_token_num_t cmd_operate_specific_port_id =
775 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
778 cmdline_parse_inst_t cmd_operate_specific_port = {
779 .f = cmd_operate_specific_port_parsed,
781 .help_str = "port start|stop|close X: start/stop/close port X",
783 (void *)&cmd_operate_specific_port_cmd,
784 (void *)&cmd_operate_specific_port_port,
785 (void *)&cmd_operate_specific_port_id,
790 /* *** configure speed for all ports *** */
791 struct cmd_config_speed_all {
792 cmdline_fixed_string_t port;
793 cmdline_fixed_string_t keyword;
794 cmdline_fixed_string_t all;
795 cmdline_fixed_string_t item1;
796 cmdline_fixed_string_t item2;
797 cmdline_fixed_string_t value1;
798 cmdline_fixed_string_t value2;
802 cmd_config_speed_all_parsed(void *parsed_result,
803 __attribute__((unused)) struct cmdline *cl,
804 __attribute__((unused)) void *data)
806 struct cmd_config_speed_all *res = parsed_result;
807 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
808 uint16_t link_duplex = 0;
811 if (!all_ports_stopped()) {
812 printf("Please stop all ports first\n");
816 if (!strcmp(res->value1, "10"))
817 link_speed = ETH_LINK_SPEED_10;
818 else if (!strcmp(res->value1, "100"))
819 link_speed = ETH_LINK_SPEED_100;
820 else if (!strcmp(res->value1, "1000"))
821 link_speed = ETH_LINK_SPEED_1000;
822 else if (!strcmp(res->value1, "10000"))
823 link_speed = ETH_LINK_SPEED_10G;
824 else if (!strcmp(res->value1, "40000"))
825 link_speed = ETH_LINK_SPEED_40G;
826 else if (!strcmp(res->value1, "auto"))
827 link_speed = ETH_LINK_SPEED_AUTONEG;
829 printf("Unknown parameter\n");
833 if (!strcmp(res->value2, "half"))
834 link_duplex = ETH_LINK_HALF_DUPLEX;
835 else if (!strcmp(res->value2, "full"))
836 link_duplex = ETH_LINK_FULL_DUPLEX;
837 else if (!strcmp(res->value2, "auto"))
838 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
840 printf("Unknown parameter\n");
844 for (pid = 0; pid < nb_ports; pid++) {
845 ports[pid].dev_conf.link_speed = link_speed;
846 ports[pid].dev_conf.link_duplex = link_duplex;
849 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
852 cmdline_parse_token_string_t cmd_config_speed_all_port =
853 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
854 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
855 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
857 cmdline_parse_token_string_t cmd_config_speed_all_all =
858 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
859 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
860 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
861 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
862 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
863 "10#100#1000#10000#40000#auto");
864 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
865 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
866 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
867 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
870 cmdline_parse_inst_t cmd_config_speed_all = {
871 .f = cmd_config_speed_all_parsed,
873 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
876 (void *)&cmd_config_speed_all_port,
877 (void *)&cmd_config_speed_all_keyword,
878 (void *)&cmd_config_speed_all_all,
879 (void *)&cmd_config_speed_all_item1,
880 (void *)&cmd_config_speed_all_value1,
881 (void *)&cmd_config_speed_all_item2,
882 (void *)&cmd_config_speed_all_value2,
887 /* *** configure speed for specific port *** */
888 struct cmd_config_speed_specific {
889 cmdline_fixed_string_t port;
890 cmdline_fixed_string_t keyword;
892 cmdline_fixed_string_t item1;
893 cmdline_fixed_string_t item2;
894 cmdline_fixed_string_t value1;
895 cmdline_fixed_string_t value2;
899 cmd_config_speed_specific_parsed(void *parsed_result,
900 __attribute__((unused)) struct cmdline *cl,
901 __attribute__((unused)) void *data)
903 struct cmd_config_speed_specific *res = parsed_result;
904 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
905 uint16_t link_duplex = 0;
907 if (!all_ports_stopped()) {
908 printf("Please stop all ports first\n");
912 if (res->id >= nb_ports) {
913 printf("Port id %d must be less than %d\n", res->id, nb_ports);
917 if (!strcmp(res->value1, "10"))
918 link_speed = ETH_LINK_SPEED_10;
919 else if (!strcmp(res->value1, "100"))
920 link_speed = ETH_LINK_SPEED_100;
921 else if (!strcmp(res->value1, "1000"))
922 link_speed = ETH_LINK_SPEED_1000;
923 else if (!strcmp(res->value1, "10000"))
924 link_speed = ETH_LINK_SPEED_10000;
925 else if (!strcmp(res->value1, "40000"))
926 link_speed = ETH_LINK_SPEED_40G;
927 else if (!strcmp(res->value1, "auto"))
928 link_speed = ETH_LINK_SPEED_AUTONEG;
930 printf("Unknown parameter\n");
934 if (!strcmp(res->value2, "half"))
935 link_duplex = ETH_LINK_HALF_DUPLEX;
936 else if (!strcmp(res->value2, "full"))
937 link_duplex = ETH_LINK_FULL_DUPLEX;
938 else if (!strcmp(res->value2, "auto"))
939 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
941 printf("Unknown parameter\n");
945 ports[res->id].dev_conf.link_speed = link_speed;
946 ports[res->id].dev_conf.link_duplex = link_duplex;
948 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
952 cmdline_parse_token_string_t cmd_config_speed_specific_port =
953 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
955 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
956 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
958 cmdline_parse_token_num_t cmd_config_speed_specific_id =
959 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
960 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
961 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
963 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
964 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
965 "10#100#1000#10000#40000#auto");
966 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
967 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
969 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
970 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
973 cmdline_parse_inst_t cmd_config_speed_specific = {
974 .f = cmd_config_speed_specific_parsed,
976 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
979 (void *)&cmd_config_speed_specific_port,
980 (void *)&cmd_config_speed_specific_keyword,
981 (void *)&cmd_config_speed_specific_id,
982 (void *)&cmd_config_speed_specific_item1,
983 (void *)&cmd_config_speed_specific_value1,
984 (void *)&cmd_config_speed_specific_item2,
985 (void *)&cmd_config_speed_specific_value2,
990 /* *** configure txq/rxq, txd/rxd *** */
991 struct cmd_config_rx_tx {
992 cmdline_fixed_string_t port;
993 cmdline_fixed_string_t keyword;
994 cmdline_fixed_string_t all;
995 cmdline_fixed_string_t name;
1000 cmd_config_rx_tx_parsed(void *parsed_result,
1001 __attribute__((unused)) struct cmdline *cl,
1002 __attribute__((unused)) void *data)
1004 struct cmd_config_rx_tx *res = parsed_result;
1006 if (!all_ports_stopped()) {
1007 printf("Please stop all ports first\n");
1011 if (!strcmp(res->name, "rxq")) {
1012 if (res->value <= 0) {
1013 printf("rxq %d invalid - must be > 0\n", res->value);
1016 nb_rxq = res->value;
1018 else if (!strcmp(res->name, "txq")) {
1019 if (res->value <= 0) {
1020 printf("txq %d invalid - must be > 0\n", res->value);
1023 nb_txq = res->value;
1025 else if (!strcmp(res->name, "rxd")) {
1026 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1027 printf("rxd %d invalid - must be > 0 && <= %d\n",
1028 res->value, RTE_TEST_RX_DESC_MAX);
1031 nb_rxd = res->value;
1032 } else if (!strcmp(res->name, "txd")) {
1033 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1034 printf("txd %d invalid - must be > 0 && <= %d\n",
1035 res->value, RTE_TEST_TX_DESC_MAX);
1038 nb_txd = res->value;
1040 printf("Unknown parameter\n");
1046 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1049 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1050 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1051 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1052 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1053 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1054 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1055 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1056 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1058 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1059 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1061 cmdline_parse_inst_t cmd_config_rx_tx = {
1062 .f = cmd_config_rx_tx_parsed,
1064 .help_str = "port config all rxq|txq|rxd|txd value",
1066 (void *)&cmd_config_rx_tx_port,
1067 (void *)&cmd_config_rx_tx_keyword,
1068 (void *)&cmd_config_rx_tx_all,
1069 (void *)&cmd_config_rx_tx_name,
1070 (void *)&cmd_config_rx_tx_value,
1075 /* *** config max packet length *** */
1076 struct cmd_config_max_pkt_len_result {
1077 cmdline_fixed_string_t port;
1078 cmdline_fixed_string_t keyword;
1079 cmdline_fixed_string_t all;
1080 cmdline_fixed_string_t name;
1085 cmd_config_max_pkt_len_parsed(void *parsed_result,
1086 __attribute__((unused)) struct cmdline *cl,
1087 __attribute__((unused)) void *data)
1089 struct cmd_config_max_pkt_len_result *res = parsed_result;
1091 if (!all_ports_stopped()) {
1092 printf("Please stop all ports first\n");
1096 if (!strcmp(res->name, "max-pkt-len")) {
1097 if (res->value < ETHER_MIN_LEN) {
1098 printf("max-pkt-len can not be less than %d\n",
1102 if (res->value == rx_mode.max_rx_pkt_len)
1105 rx_mode.max_rx_pkt_len = res->value;
1106 if (res->value > ETHER_MAX_LEN)
1107 rx_mode.jumbo_frame = 1;
1109 rx_mode.jumbo_frame = 0;
1111 printf("Unknown parameter\n");
1117 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1120 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1121 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1123 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1124 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1126 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1127 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1129 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1130 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1132 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1133 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1136 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1137 .f = cmd_config_max_pkt_len_parsed,
1139 .help_str = "port config all max-pkt-len value",
1141 (void *)&cmd_config_max_pkt_len_port,
1142 (void *)&cmd_config_max_pkt_len_keyword,
1143 (void *)&cmd_config_max_pkt_len_all,
1144 (void *)&cmd_config_max_pkt_len_name,
1145 (void *)&cmd_config_max_pkt_len_value,
1150 /* *** configure port MTU *** */
1151 struct cmd_config_mtu_result {
1152 cmdline_fixed_string_t port;
1153 cmdline_fixed_string_t keyword;
1154 cmdline_fixed_string_t mtu;
1160 cmd_config_mtu_parsed(void *parsed_result,
1161 __attribute__((unused)) struct cmdline *cl,
1162 __attribute__((unused)) void *data)
1164 struct cmd_config_mtu_result *res = parsed_result;
1166 if (res->value < ETHER_MIN_LEN) {
1167 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1170 port_mtu_set(res->port_id, res->value);
1173 cmdline_parse_token_string_t cmd_config_mtu_port =
1174 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1176 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1177 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1179 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1180 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1182 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1183 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1184 cmdline_parse_token_num_t cmd_config_mtu_value =
1185 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1187 cmdline_parse_inst_t cmd_config_mtu = {
1188 .f = cmd_config_mtu_parsed,
1190 .help_str = "port config mtu value",
1192 (void *)&cmd_config_mtu_port,
1193 (void *)&cmd_config_mtu_keyword,
1194 (void *)&cmd_config_mtu_mtu,
1195 (void *)&cmd_config_mtu_port_id,
1196 (void *)&cmd_config_mtu_value,
1201 /* *** configure rx mode *** */
1202 struct cmd_config_rx_mode_flag {
1203 cmdline_fixed_string_t port;
1204 cmdline_fixed_string_t keyword;
1205 cmdline_fixed_string_t all;
1206 cmdline_fixed_string_t name;
1207 cmdline_fixed_string_t value;
1211 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1212 __attribute__((unused)) struct cmdline *cl,
1213 __attribute__((unused)) void *data)
1215 struct cmd_config_rx_mode_flag *res = parsed_result;
1217 if (!all_ports_stopped()) {
1218 printf("Please stop all ports first\n");
1222 if (!strcmp(res->name, "crc-strip")) {
1223 if (!strcmp(res->value, "on"))
1224 rx_mode.hw_strip_crc = 1;
1225 else if (!strcmp(res->value, "off"))
1226 rx_mode.hw_strip_crc = 0;
1228 printf("Unknown parameter\n");
1231 } else if (!strcmp(res->name, "rx-cksum")) {
1232 if (!strcmp(res->value, "on"))
1233 rx_mode.hw_ip_checksum = 1;
1234 else if (!strcmp(res->value, "off"))
1235 rx_mode.hw_ip_checksum = 0;
1237 printf("Unknown parameter\n");
1240 } else if (!strcmp(res->name, "hw-vlan")) {
1241 if (!strcmp(res->value, "on")) {
1242 rx_mode.hw_vlan_filter = 1;
1243 rx_mode.hw_vlan_strip = 1;
1245 else if (!strcmp(res->value, "off")) {
1246 rx_mode.hw_vlan_filter = 0;
1247 rx_mode.hw_vlan_strip = 0;
1250 printf("Unknown parameter\n");
1253 } else if (!strcmp(res->name, "drop-en")) {
1254 if (!strcmp(res->value, "on"))
1256 else if (!strcmp(res->value, "off"))
1259 printf("Unknown parameter\n");
1263 printf("Unknown parameter\n");
1269 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1272 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1273 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1274 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1275 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1277 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1278 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1279 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1280 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1281 "crc-strip#rx-cksum#hw-vlan");
1282 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1283 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1286 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1287 .f = cmd_config_rx_mode_flag_parsed,
1289 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1291 (void *)&cmd_config_rx_mode_flag_port,
1292 (void *)&cmd_config_rx_mode_flag_keyword,
1293 (void *)&cmd_config_rx_mode_flag_all,
1294 (void *)&cmd_config_rx_mode_flag_name,
1295 (void *)&cmd_config_rx_mode_flag_value,
1300 /* *** configure rss *** */
1301 struct cmd_config_rss {
1302 cmdline_fixed_string_t port;
1303 cmdline_fixed_string_t keyword;
1304 cmdline_fixed_string_t all;
1305 cmdline_fixed_string_t name;
1306 cmdline_fixed_string_t value;
1310 cmd_config_rss_parsed(void *parsed_result,
1311 __attribute__((unused)) struct cmdline *cl,
1312 __attribute__((unused)) void *data)
1314 struct cmd_config_rss *res = parsed_result;
1315 struct rte_eth_rss_conf rss_conf;
1318 if (!strcmp(res->value, "ip"))
1319 rss_conf.rss_hf = ETH_RSS_IP;
1320 else if (!strcmp(res->value, "udp"))
1321 rss_conf.rss_hf = ETH_RSS_UDP;
1322 else if (!strcmp(res->value, "none"))
1323 rss_conf.rss_hf = 0;
1325 printf("Unknown parameter\n");
1328 rss_conf.rss_key = NULL;
1329 for (i = 0; i < rte_eth_dev_count(); i++)
1330 rte_eth_dev_rss_hash_update(i, &rss_conf);
1333 cmdline_parse_token_string_t cmd_config_rss_port =
1334 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1335 cmdline_parse_token_string_t cmd_config_rss_keyword =
1336 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1337 cmdline_parse_token_string_t cmd_config_rss_all =
1338 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1339 cmdline_parse_token_string_t cmd_config_rss_name =
1340 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1341 cmdline_parse_token_string_t cmd_config_rss_value =
1342 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1344 cmdline_parse_inst_t cmd_config_rss = {
1345 .f = cmd_config_rss_parsed,
1347 .help_str = "port config all rss ip|udp|none",
1349 (void *)&cmd_config_rss_port,
1350 (void *)&cmd_config_rss_keyword,
1351 (void *)&cmd_config_rss_all,
1352 (void *)&cmd_config_rss_name,
1353 (void *)&cmd_config_rss_value,
1358 /* *** configure rss hash key *** */
1359 struct cmd_config_rss_hash_key {
1360 cmdline_fixed_string_t port;
1361 cmdline_fixed_string_t config;
1363 cmdline_fixed_string_t rss_hash_key;
1364 cmdline_fixed_string_t key;
1367 #define RSS_HASH_KEY_LENGTH 40
1369 hexa_digit_to_value(char hexa_digit)
1371 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1372 return (uint8_t) (hexa_digit - '0');
1373 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1374 return (uint8_t) ((hexa_digit - 'a') + 10);
1375 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1376 return (uint8_t) ((hexa_digit - 'A') + 10);
1377 /* Invalid hexa digit */
1382 parse_and_check_key_hexa_digit(char *key, int idx)
1386 hexa_v = hexa_digit_to_value(key[idx]);
1388 printf("invalid key: character %c at position %d is not a "
1389 "valid hexa digit\n", key[idx], idx);
1394 cmd_config_rss_hash_key_parsed(void *parsed_result,
1395 __attribute__((unused)) struct cmdline *cl,
1396 __attribute__((unused)) void *data)
1398 struct cmd_config_rss_hash_key *res = parsed_result;
1399 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1404 /* Check the length of the RSS hash key */
1405 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1406 printf("key length: %d invalid - key must be a string of %d"
1407 "hexa-decimal numbers\n", (int) strlen(res->key),
1408 RSS_HASH_KEY_LENGTH * 2);
1411 /* Translate RSS hash key into binary representation */
1412 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1413 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1416 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1419 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1421 port_rss_hash_key_update(res->port_id, hash_key);
1424 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1425 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1426 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1427 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1429 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1430 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1431 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1432 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1433 rss_hash_key, "rss-hash-key");
1434 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1435 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1437 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1438 .f = cmd_config_rss_hash_key_parsed,
1440 .help_str = "port config X rss-hash-key 80 hexa digits",
1442 (void *)&cmd_config_rss_hash_key_port,
1443 (void *)&cmd_config_rss_hash_key_config,
1444 (void *)&cmd_config_rss_hash_key_port_id,
1445 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1446 (void *)&cmd_config_rss_hash_key_value,
1451 /* *** configure port rxq/txq start/stop *** */
1452 struct cmd_config_rxtx_queue {
1453 cmdline_fixed_string_t port;
1455 cmdline_fixed_string_t rxtxq;
1457 cmdline_fixed_string_t opname;
1461 cmd_config_rxtx_queue_parsed(void *parsed_result,
1462 __attribute__((unused)) struct cmdline *cl,
1463 __attribute__((unused)) void *data)
1465 struct cmd_config_rxtx_queue *res = parsed_result;
1470 if (test_done == 0) {
1471 printf("Please stop forwarding first\n");
1475 if (port_id_is_invalid(res->portid))
1478 if (port_is_started(res->portid) != 1) {
1479 printf("Please start port %u first\n", res->portid);
1483 if (!strcmp(res->rxtxq, "rxq"))
1485 else if (!strcmp(res->rxtxq, "txq"))
1488 printf("Unknown parameter\n");
1492 if (isrx && rx_queue_id_is_invalid(res->qid))
1494 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1497 if (!strcmp(res->opname, "start"))
1499 else if (!strcmp(res->opname, "stop"))
1502 printf("Unknown parameter\n");
1506 if (isstart && isrx)
1507 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1508 else if (!isstart && isrx)
1509 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1510 else if (isstart && !isrx)
1511 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1513 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1515 if (ret == -ENOTSUP)
1516 printf("Function not supported in PMD driver\n");
1519 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1520 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1521 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1522 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1523 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1524 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1525 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1526 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1527 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1528 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1531 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1532 .f = cmd_config_rxtx_queue_parsed,
1534 .help_str = "port X rxq|txq ID start|stop",
1536 (void *)&cmd_config_speed_all_port,
1537 (void *)&cmd_config_rxtx_queue_portid,
1538 (void *)&cmd_config_rxtx_queue_rxtxq,
1539 (void *)&cmd_config_rxtx_queue_qid,
1540 (void *)&cmd_config_rxtx_queue_opname,
1545 /* *** Configure RSS RETA *** */
1546 struct cmd_config_rss_reta {
1547 cmdline_fixed_string_t port;
1548 cmdline_fixed_string_t keyword;
1550 cmdline_fixed_string_t name;
1551 cmdline_fixed_string_t list_name;
1552 cmdline_fixed_string_t list_of_items;
1556 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1563 const char *p, *p0 = str;
1570 unsigned long int_fld[_NUM_FLD];
1571 char *str_fld[_NUM_FLD];
1573 while ((p = strchr(p0,'(')) != NULL) {
1575 if((p0 = strchr(p,')')) == NULL)
1579 if(size >= sizeof(s))
1582 snprintf(s, sizeof(s), "%.*s", size, p);
1583 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1585 for (i = 0; i < _NUM_FLD; i++) {
1587 int_fld[i] = strtoul(str_fld[i], &end, 0);
1588 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1592 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1593 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1595 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1596 printf("Invalid RETA hash index=%d",hash_index);
1600 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1601 reta_conf->mask_lo |= (1ULL << hash_index);
1603 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1605 reta_conf->reta[hash_index] = nb_queue;
1612 cmd_set_rss_reta_parsed(void *parsed_result,
1613 __attribute__((unused)) struct cmdline *cl,
1614 __attribute__((unused)) void *data)
1617 struct rte_eth_rss_reta reta_conf;
1618 struct cmd_config_rss_reta *res = parsed_result;
1620 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1621 if (!strcmp(res->list_name, "reta")) {
1622 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1623 printf("Invalid RSS Redirection Table config entered\n");
1626 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1628 printf("Bad redirection table parameter, return code = %d \n",ret);
1632 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1633 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1634 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1635 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1636 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1637 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1638 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1639 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1640 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1641 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1642 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1645 cmdline_parse_inst_t cmd_config_rss_reta = {
1646 .f = cmd_set_rss_reta_parsed,
1648 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1650 (void *)&cmd_config_rss_reta_port,
1651 (void *)&cmd_config_rss_reta_keyword,
1652 (void *)&cmd_config_rss_reta_port_id,
1653 (void *)&cmd_config_rss_reta_name,
1654 (void *)&cmd_config_rss_reta_list_name,
1655 (void *)&cmd_config_rss_reta_list_of_items,
1660 /* *** SHOW PORT RETA INFO *** */
1661 struct cmd_showport_reta {
1662 cmdline_fixed_string_t show;
1663 cmdline_fixed_string_t port;
1665 cmdline_fixed_string_t rss;
1666 cmdline_fixed_string_t reta;
1671 static void cmd_showport_reta_parsed(void *parsed_result,
1672 __attribute__((unused)) struct cmdline *cl,
1673 __attribute__((unused)) void *data)
1675 struct cmd_showport_reta *res = parsed_result;
1676 struct rte_eth_rss_reta reta_conf;
1678 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1679 printf("Invalid RSS Redirection Table config entered\n");
1683 reta_conf.mask_lo = res->mask_lo;
1684 reta_conf.mask_hi = res->mask_hi;
1686 port_rss_reta_info(res->port_id,&reta_conf);
1689 cmdline_parse_token_string_t cmd_showport_reta_show =
1690 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1691 cmdline_parse_token_string_t cmd_showport_reta_port =
1692 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1693 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1694 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1695 cmdline_parse_token_string_t cmd_showport_reta_rss =
1696 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1697 cmdline_parse_token_string_t cmd_showport_reta_reta =
1698 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1699 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1700 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1701 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1702 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1704 cmdline_parse_inst_t cmd_showport_reta = {
1705 .f = cmd_showport_reta_parsed,
1707 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1708 (mask_lo and mask_hi is UINT64)",
1710 (void *)&cmd_showport_reta_show,
1711 (void *)&cmd_showport_reta_port,
1712 (void *)&cmd_showport_reta_port_id,
1713 (void *)&cmd_showport_reta_rss,
1714 (void *)&cmd_showport_reta_reta,
1715 (void *)&cmd_showport_reta_mask_lo,
1716 (void *)&cmd_showport_reta_mask_hi,
1721 /* *** Show RSS hash configuration *** */
1722 struct cmd_showport_rss_hash {
1723 cmdline_fixed_string_t show;
1724 cmdline_fixed_string_t port;
1726 cmdline_fixed_string_t rss_hash;
1727 cmdline_fixed_string_t key; /* optional argument */
1730 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1731 __attribute__((unused)) struct cmdline *cl,
1734 struct cmd_showport_rss_hash *res = parsed_result;
1736 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1739 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1740 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1741 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1742 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1743 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1744 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1745 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1746 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1748 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1749 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1751 cmdline_parse_inst_t cmd_showport_rss_hash = {
1752 .f = cmd_showport_rss_hash_parsed,
1754 .help_str = "show port X rss-hash (X = port number)\n",
1756 (void *)&cmd_showport_rss_hash_show,
1757 (void *)&cmd_showport_rss_hash_port,
1758 (void *)&cmd_showport_rss_hash_port_id,
1759 (void *)&cmd_showport_rss_hash_rss_hash,
1764 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1765 .f = cmd_showport_rss_hash_parsed,
1767 .help_str = "show port X rss-hash key (X = port number)\n",
1769 (void *)&cmd_showport_rss_hash_show,
1770 (void *)&cmd_showport_rss_hash_port,
1771 (void *)&cmd_showport_rss_hash_port_id,
1772 (void *)&cmd_showport_rss_hash_rss_hash,
1773 (void *)&cmd_showport_rss_hash_rss_key,
1778 /* *** Configure DCB *** */
1779 struct cmd_config_dcb {
1780 cmdline_fixed_string_t port;
1781 cmdline_fixed_string_t config;
1783 cmdline_fixed_string_t dcb;
1784 cmdline_fixed_string_t vt;
1785 cmdline_fixed_string_t vt_en;
1787 cmdline_fixed_string_t pfc;
1788 cmdline_fixed_string_t pfc_en;
1792 cmd_config_dcb_parsed(void *parsed_result,
1793 __attribute__((unused)) struct cmdline *cl,
1794 __attribute__((unused)) void *data)
1796 struct cmd_config_dcb *res = parsed_result;
1797 struct dcb_config dcb_conf;
1798 portid_t port_id = res->port_id;
1799 struct rte_port *port;
1801 port = &ports[port_id];
1802 /** Check if the port is not started **/
1803 if (port->port_status != RTE_PORT_STOPPED) {
1804 printf("Please stop port %d first\n",port_id);
1808 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1809 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1810 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1814 /* DCB in VT mode */
1815 if (!strncmp(res->vt_en, "on",2))
1816 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1818 dcb_conf.dcb_mode = DCB_ENABLED;
1820 if (!strncmp(res->pfc_en, "on",2)) {
1821 dcb_conf.pfc_en = 1;
1824 dcb_conf.pfc_en = 0;
1826 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1827 printf("Cannot initialize network ports\n");
1831 cmd_reconfig_device_queue(port_id, 1, 1);
1834 cmdline_parse_token_string_t cmd_config_dcb_port =
1835 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1836 cmdline_parse_token_string_t cmd_config_dcb_config =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1838 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1839 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1840 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1842 cmdline_parse_token_string_t cmd_config_dcb_vt =
1843 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1844 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1845 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1846 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1847 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1848 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1850 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1851 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1853 cmdline_parse_inst_t cmd_config_dcb = {
1854 .f = cmd_config_dcb_parsed,
1856 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1858 (void *)&cmd_config_dcb_port,
1859 (void *)&cmd_config_dcb_config,
1860 (void *)&cmd_config_dcb_port_id,
1861 (void *)&cmd_config_dcb_dcb,
1862 (void *)&cmd_config_dcb_vt,
1863 (void *)&cmd_config_dcb_vt_en,
1864 (void *)&cmd_config_dcb_num_tcs,
1865 (void *)&cmd_config_dcb_pfc,
1866 (void *)&cmd_config_dcb_pfc_en,
1871 /* *** configure number of packets per burst *** */
1872 struct cmd_config_burst {
1873 cmdline_fixed_string_t port;
1874 cmdline_fixed_string_t keyword;
1875 cmdline_fixed_string_t all;
1876 cmdline_fixed_string_t name;
1881 cmd_config_burst_parsed(void *parsed_result,
1882 __attribute__((unused)) struct cmdline *cl,
1883 __attribute__((unused)) void *data)
1885 struct cmd_config_burst *res = parsed_result;
1887 if (!all_ports_stopped()) {
1888 printf("Please stop all ports first\n");
1892 if (!strcmp(res->name, "burst")) {
1893 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1894 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1897 nb_pkt_per_burst = res->value;
1899 printf("Unknown parameter\n");
1905 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1908 cmdline_parse_token_string_t cmd_config_burst_port =
1909 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1910 cmdline_parse_token_string_t cmd_config_burst_keyword =
1911 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1912 cmdline_parse_token_string_t cmd_config_burst_all =
1913 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1914 cmdline_parse_token_string_t cmd_config_burst_name =
1915 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1916 cmdline_parse_token_num_t cmd_config_burst_value =
1917 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1919 cmdline_parse_inst_t cmd_config_burst = {
1920 .f = cmd_config_burst_parsed,
1922 .help_str = "port config all burst value",
1924 (void *)&cmd_config_burst_port,
1925 (void *)&cmd_config_burst_keyword,
1926 (void *)&cmd_config_burst_all,
1927 (void *)&cmd_config_burst_name,
1928 (void *)&cmd_config_burst_value,
1933 /* *** configure rx/tx queues *** */
1934 struct cmd_config_thresh {
1935 cmdline_fixed_string_t port;
1936 cmdline_fixed_string_t keyword;
1937 cmdline_fixed_string_t all;
1938 cmdline_fixed_string_t name;
1943 cmd_config_thresh_parsed(void *parsed_result,
1944 __attribute__((unused)) struct cmdline *cl,
1945 __attribute__((unused)) void *data)
1947 struct cmd_config_thresh *res = parsed_result;
1949 if (!all_ports_stopped()) {
1950 printf("Please stop all ports first\n");
1954 if (!strcmp(res->name, "txpt"))
1955 tx_thresh.pthresh = res->value;
1956 else if(!strcmp(res->name, "txht"))
1957 tx_thresh.hthresh = res->value;
1958 else if(!strcmp(res->name, "txwt"))
1959 tx_thresh.wthresh = res->value;
1960 else if(!strcmp(res->name, "rxpt"))
1961 rx_thresh.pthresh = res->value;
1962 else if(!strcmp(res->name, "rxht"))
1963 rx_thresh.hthresh = res->value;
1964 else if(!strcmp(res->name, "rxwt"))
1965 rx_thresh.wthresh = res->value;
1967 printf("Unknown parameter\n");
1973 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1976 cmdline_parse_token_string_t cmd_config_thresh_port =
1977 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1978 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1979 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1980 cmdline_parse_token_string_t cmd_config_thresh_all =
1981 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1982 cmdline_parse_token_string_t cmd_config_thresh_name =
1983 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1984 "txpt#txht#txwt#rxpt#rxht#rxwt");
1985 cmdline_parse_token_num_t cmd_config_thresh_value =
1986 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1988 cmdline_parse_inst_t cmd_config_thresh = {
1989 .f = cmd_config_thresh_parsed,
1991 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1993 (void *)&cmd_config_thresh_port,
1994 (void *)&cmd_config_thresh_keyword,
1995 (void *)&cmd_config_thresh_all,
1996 (void *)&cmd_config_thresh_name,
1997 (void *)&cmd_config_thresh_value,
2002 /* *** configure free/rs threshold *** */
2003 struct cmd_config_threshold {
2004 cmdline_fixed_string_t port;
2005 cmdline_fixed_string_t keyword;
2006 cmdline_fixed_string_t all;
2007 cmdline_fixed_string_t name;
2012 cmd_config_threshold_parsed(void *parsed_result,
2013 __attribute__((unused)) struct cmdline *cl,
2014 __attribute__((unused)) void *data)
2016 struct cmd_config_threshold *res = parsed_result;
2018 if (!all_ports_stopped()) {
2019 printf("Please stop all ports first\n");
2023 if (!strcmp(res->name, "txfreet"))
2024 tx_free_thresh = res->value;
2025 else if (!strcmp(res->name, "txrst"))
2026 tx_rs_thresh = res->value;
2027 else if (!strcmp(res->name, "rxfreet"))
2028 rx_free_thresh = res->value;
2030 printf("Unknown parameter\n");
2036 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2039 cmdline_parse_token_string_t cmd_config_threshold_port =
2040 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2041 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2042 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2044 cmdline_parse_token_string_t cmd_config_threshold_all =
2045 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2046 cmdline_parse_token_string_t cmd_config_threshold_name =
2047 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2048 "txfreet#txrst#rxfreet");
2049 cmdline_parse_token_num_t cmd_config_threshold_value =
2050 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2052 cmdline_parse_inst_t cmd_config_threshold = {
2053 .f = cmd_config_threshold_parsed,
2055 .help_str = "port config all txfreet|txrst|rxfreet value",
2057 (void *)&cmd_config_threshold_port,
2058 (void *)&cmd_config_threshold_keyword,
2059 (void *)&cmd_config_threshold_all,
2060 (void *)&cmd_config_threshold_name,
2061 (void *)&cmd_config_threshold_value,
2067 struct cmd_stop_result {
2068 cmdline_fixed_string_t stop;
2071 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2072 __attribute__((unused)) struct cmdline *cl,
2073 __attribute__((unused)) void *data)
2075 stop_packet_forwarding();
2078 cmdline_parse_token_string_t cmd_stop_stop =
2079 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2081 cmdline_parse_inst_t cmd_stop = {
2082 .f = cmd_stop_parsed,
2084 .help_str = "stop - stop packet forwarding",
2086 (void *)&cmd_stop_stop,
2091 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2094 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2095 unsigned int *parsed_items, int check_unique_values)
2097 unsigned int nb_item;
2105 * First parse all items in the list and store their value.
2110 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2112 if ((c >= '0') && (c <= '9')) {
2113 value = (unsigned int) (value * 10 + (c - '0'));
2118 printf("character %c is not a decimal digit\n", c);
2122 printf("No valid value before comma\n");
2125 if (nb_item < max_items) {
2126 parsed_items[nb_item] = value;
2132 if (nb_item >= max_items) {
2133 printf("Number of %s = %u > %u (maximum items)\n",
2134 item_name, nb_item + 1, max_items);
2137 parsed_items[nb_item++] = value;
2138 if (! check_unique_values)
2142 * Then, check that all values in the list are differents.
2143 * No optimization here...
2145 for (i = 0; i < nb_item; i++) {
2146 for (j = i + 1; j < nb_item; j++) {
2147 if (parsed_items[j] == parsed_items[i]) {
2148 printf("duplicated %s %u at index %u and %u\n",
2149 item_name, parsed_items[i], i, j);
2157 struct cmd_set_list_result {
2158 cmdline_fixed_string_t cmd_keyword;
2159 cmdline_fixed_string_t list_name;
2160 cmdline_fixed_string_t list_of_items;
2163 static void cmd_set_list_parsed(void *parsed_result,
2164 __attribute__((unused)) struct cmdline *cl,
2165 __attribute__((unused)) void *data)
2167 struct cmd_set_list_result *res;
2169 unsigned int lcorelist[RTE_MAX_LCORE];
2170 unsigned int portlist[RTE_MAX_ETHPORTS];
2172 unsigned int nb_item;
2174 res = parsed_result;
2175 if (!strcmp(res->list_name, "corelist")) {
2176 nb_item = parse_item_list(res->list_of_items, "core",
2178 parsed_items.lcorelist, 1);
2180 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2183 if (!strcmp(res->list_name, "portlist")) {
2184 nb_item = parse_item_list(res->list_of_items, "port",
2186 parsed_items.portlist, 1);
2188 set_fwd_ports_list(parsed_items.portlist, nb_item);
2192 cmdline_parse_token_string_t cmd_set_list_keyword =
2193 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2195 cmdline_parse_token_string_t cmd_set_list_name =
2196 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2197 "corelist#portlist");
2198 cmdline_parse_token_string_t cmd_set_list_of_items =
2199 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2202 cmdline_parse_inst_t cmd_set_fwd_list = {
2203 .f = cmd_set_list_parsed,
2205 .help_str = "set corelist|portlist x[,y]*",
2207 (void *)&cmd_set_list_keyword,
2208 (void *)&cmd_set_list_name,
2209 (void *)&cmd_set_list_of_items,
2214 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2216 struct cmd_setmask_result {
2217 cmdline_fixed_string_t set;
2218 cmdline_fixed_string_t mask;
2222 static void cmd_set_mask_parsed(void *parsed_result,
2223 __attribute__((unused)) struct cmdline *cl,
2224 __attribute__((unused)) void *data)
2226 struct cmd_setmask_result *res = parsed_result;
2228 if (!strcmp(res->mask, "coremask"))
2229 set_fwd_lcores_mask(res->hexavalue);
2230 else if (!strcmp(res->mask, "portmask"))
2231 set_fwd_ports_mask(res->hexavalue);
2234 cmdline_parse_token_string_t cmd_setmask_set =
2235 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2236 cmdline_parse_token_string_t cmd_setmask_mask =
2237 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2238 "coremask#portmask");
2239 cmdline_parse_token_num_t cmd_setmask_value =
2240 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2242 cmdline_parse_inst_t cmd_set_fwd_mask = {
2243 .f = cmd_set_mask_parsed,
2245 .help_str = "set coremask|portmask hexadecimal value",
2247 (void *)&cmd_setmask_set,
2248 (void *)&cmd_setmask_mask,
2249 (void *)&cmd_setmask_value,
2255 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2257 struct cmd_set_result {
2258 cmdline_fixed_string_t set;
2259 cmdline_fixed_string_t what;
2263 static void cmd_set_parsed(void *parsed_result,
2264 __attribute__((unused)) struct cmdline *cl,
2265 __attribute__((unused)) void *data)
2267 struct cmd_set_result *res = parsed_result;
2268 if (!strcmp(res->what, "nbport"))
2269 set_fwd_ports_number(res->value);
2270 else if (!strcmp(res->what, "nbcore"))
2271 set_fwd_lcores_number(res->value);
2272 else if (!strcmp(res->what, "burst"))
2273 set_nb_pkt_per_burst(res->value);
2274 else if (!strcmp(res->what, "verbose"))
2275 set_verbose_level(res->value);
2278 cmdline_parse_token_string_t cmd_set_set =
2279 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2280 cmdline_parse_token_string_t cmd_set_what =
2281 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2282 "nbport#nbcore#burst#verbose");
2283 cmdline_parse_token_num_t cmd_set_value =
2284 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2286 cmdline_parse_inst_t cmd_set_numbers = {
2287 .f = cmd_set_parsed,
2289 .help_str = "set nbport|nbcore|burst|verbose value",
2291 (void *)&cmd_set_set,
2292 (void *)&cmd_set_what,
2293 (void *)&cmd_set_value,
2298 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2300 struct cmd_set_txpkts_result {
2301 cmdline_fixed_string_t cmd_keyword;
2302 cmdline_fixed_string_t txpkts;
2303 cmdline_fixed_string_t seg_lengths;
2307 cmd_set_txpkts_parsed(void *parsed_result,
2308 __attribute__((unused)) struct cmdline *cl,
2309 __attribute__((unused)) void *data)
2311 struct cmd_set_txpkts_result *res;
2312 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2313 unsigned int nb_segs;
2315 res = parsed_result;
2316 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2317 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2319 set_tx_pkt_segments(seg_lengths, nb_segs);
2322 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2323 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2324 cmd_keyword, "set");
2325 cmdline_parse_token_string_t cmd_set_txpkts_name =
2326 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2328 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2329 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2332 cmdline_parse_inst_t cmd_set_txpkts = {
2333 .f = cmd_set_txpkts_parsed,
2335 .help_str = "set txpkts x[,y]*",
2337 (void *)&cmd_set_txpkts_keyword,
2338 (void *)&cmd_set_txpkts_name,
2339 (void *)&cmd_set_txpkts_lengths,
2344 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2345 struct cmd_rx_vlan_filter_all_result {
2346 cmdline_fixed_string_t rx_vlan;
2347 cmdline_fixed_string_t what;
2348 cmdline_fixed_string_t all;
2353 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2354 __attribute__((unused)) struct cmdline *cl,
2355 __attribute__((unused)) void *data)
2357 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2359 if (!strcmp(res->what, "add"))
2360 rx_vlan_all_filter_set(res->port_id, 1);
2362 rx_vlan_all_filter_set(res->port_id, 0);
2365 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2366 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2367 rx_vlan, "rx_vlan");
2368 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2369 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2371 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2372 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2374 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2375 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2378 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2379 .f = cmd_rx_vlan_filter_all_parsed,
2381 .help_str = "add/remove all identifiers to/from the set of VLAN "
2382 "Identifiers filtered by a port",
2384 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2385 (void *)&cmd_rx_vlan_filter_all_what,
2386 (void *)&cmd_rx_vlan_filter_all_all,
2387 (void *)&cmd_rx_vlan_filter_all_portid,
2392 /* *** VLAN OFFLOAD SET ON A PORT *** */
2393 struct cmd_vlan_offload_result {
2394 cmdline_fixed_string_t vlan;
2395 cmdline_fixed_string_t set;
2396 cmdline_fixed_string_t what;
2397 cmdline_fixed_string_t on;
2398 cmdline_fixed_string_t port_id;
2402 cmd_vlan_offload_parsed(void *parsed_result,
2403 __attribute__((unused)) struct cmdline *cl,
2404 __attribute__((unused)) void *data)
2407 struct cmd_vlan_offload_result *res = parsed_result;
2410 portid_t port_id = 0;
2414 len = strnlen(str, STR_TOKEN_SIZE);
2416 /* Get port_id first */
2424 tmp = strtoul(str, NULL, 0);
2425 /* If port_id greater that what portid_t can represent, return */
2426 if(tmp >= RTE_MAX_ETHPORTS)
2428 port_id = (portid_t)tmp;
2430 if (!strcmp(res->on, "on"))
2435 if (!strcmp(res->what, "strip"))
2436 rx_vlan_strip_set(port_id, on);
2437 else if(!strcmp(res->what, "stripq")){
2438 uint16_t queue_id = 0;
2440 /* No queue_id, return */
2442 printf("must specify (port,queue_id)\n");
2445 tmp = strtoul(str + i + 1, NULL, 0);
2446 /* If queue_id greater that what 16-bits can represent, return */
2450 queue_id = (uint16_t)tmp;
2451 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2453 else if (!strcmp(res->what, "filter"))
2454 rx_vlan_filter_set(port_id, on);
2456 vlan_extend_set(port_id, on);
2461 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2462 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2464 cmdline_parse_token_string_t cmd_vlan_offload_set =
2465 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2467 cmdline_parse_token_string_t cmd_vlan_offload_what =
2468 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2469 what, "strip#filter#qinq#stripq");
2470 cmdline_parse_token_string_t cmd_vlan_offload_on =
2471 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2473 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2474 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2477 cmdline_parse_inst_t cmd_vlan_offload = {
2478 .f = cmd_vlan_offload_parsed,
2480 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2481 " qinq(extended) for both rx/tx sides ",
2483 (void *)&cmd_vlan_offload_vlan,
2484 (void *)&cmd_vlan_offload_set,
2485 (void *)&cmd_vlan_offload_what,
2486 (void *)&cmd_vlan_offload_on,
2487 (void *)&cmd_vlan_offload_portid,
2492 /* *** VLAN TPID SET ON A PORT *** */
2493 struct cmd_vlan_tpid_result {
2494 cmdline_fixed_string_t vlan;
2495 cmdline_fixed_string_t set;
2496 cmdline_fixed_string_t what;
2502 cmd_vlan_tpid_parsed(void *parsed_result,
2503 __attribute__((unused)) struct cmdline *cl,
2504 __attribute__((unused)) void *data)
2506 struct cmd_vlan_tpid_result *res = parsed_result;
2507 vlan_tpid_set(res->port_id, res->tp_id);
2511 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2512 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2514 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2515 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2517 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2518 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2520 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2521 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2523 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2524 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2527 cmdline_parse_inst_t cmd_vlan_tpid = {
2528 .f = cmd_vlan_tpid_parsed,
2530 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2532 (void *)&cmd_vlan_tpid_vlan,
2533 (void *)&cmd_vlan_tpid_set,
2534 (void *)&cmd_vlan_tpid_what,
2535 (void *)&cmd_vlan_tpid_tpid,
2536 (void *)&cmd_vlan_tpid_portid,
2541 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2542 struct cmd_rx_vlan_filter_result {
2543 cmdline_fixed_string_t rx_vlan;
2544 cmdline_fixed_string_t what;
2550 cmd_rx_vlan_filter_parsed(void *parsed_result,
2551 __attribute__((unused)) struct cmdline *cl,
2552 __attribute__((unused)) void *data)
2554 struct cmd_rx_vlan_filter_result *res = parsed_result;
2556 if (!strcmp(res->what, "add"))
2557 rx_vft_set(res->port_id, res->vlan_id, 1);
2559 rx_vft_set(res->port_id, res->vlan_id, 0);
2562 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2563 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2564 rx_vlan, "rx_vlan");
2565 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2566 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2568 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2569 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2571 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2572 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2575 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2576 .f = cmd_rx_vlan_filter_parsed,
2578 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2579 "Identifiers filtered by a port",
2581 (void *)&cmd_rx_vlan_filter_rx_vlan,
2582 (void *)&cmd_rx_vlan_filter_what,
2583 (void *)&cmd_rx_vlan_filter_vlanid,
2584 (void *)&cmd_rx_vlan_filter_portid,
2589 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2590 struct cmd_tx_vlan_set_result {
2591 cmdline_fixed_string_t tx_vlan;
2592 cmdline_fixed_string_t set;
2598 cmd_tx_vlan_set_parsed(void *parsed_result,
2599 __attribute__((unused)) struct cmdline *cl,
2600 __attribute__((unused)) void *data)
2602 struct cmd_tx_vlan_set_result *res = parsed_result;
2603 tx_vlan_set(res->port_id, res->vlan_id);
2606 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2607 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2608 tx_vlan, "tx_vlan");
2609 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2610 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2612 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2613 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2615 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2616 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2619 cmdline_parse_inst_t cmd_tx_vlan_set = {
2620 .f = cmd_tx_vlan_set_parsed,
2622 .help_str = "enable hardware insertion of a VLAN header with a given "
2623 "TAG Identifier in packets sent on a port",
2625 (void *)&cmd_tx_vlan_set_tx_vlan,
2626 (void *)&cmd_tx_vlan_set_set,
2627 (void *)&cmd_tx_vlan_set_vlanid,
2628 (void *)&cmd_tx_vlan_set_portid,
2633 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2634 struct cmd_tx_vlan_set_pvid_result {
2635 cmdline_fixed_string_t tx_vlan;
2636 cmdline_fixed_string_t set;
2637 cmdline_fixed_string_t pvid;
2640 cmdline_fixed_string_t mode;
2644 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2645 __attribute__((unused)) struct cmdline *cl,
2646 __attribute__((unused)) void *data)
2648 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2650 if (strcmp(res->mode, "on") == 0)
2651 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2653 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2656 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2657 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2658 tx_vlan, "tx_vlan");
2659 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2660 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2662 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2663 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2665 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2666 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2668 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2669 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2671 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2672 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2675 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2676 .f = cmd_tx_vlan_set_pvid_parsed,
2678 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2680 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2681 (void *)&cmd_tx_vlan_set_pvid_set,
2682 (void *)&cmd_tx_vlan_set_pvid_pvid,
2683 (void *)&cmd_tx_vlan_set_pvid_port_id,
2684 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2685 (void *)&cmd_tx_vlan_set_pvid_mode,
2690 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2691 struct cmd_tx_vlan_reset_result {
2692 cmdline_fixed_string_t tx_vlan;
2693 cmdline_fixed_string_t reset;
2698 cmd_tx_vlan_reset_parsed(void *parsed_result,
2699 __attribute__((unused)) struct cmdline *cl,
2700 __attribute__((unused)) void *data)
2702 struct cmd_tx_vlan_reset_result *res = parsed_result;
2704 tx_vlan_reset(res->port_id);
2707 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2708 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2709 tx_vlan, "tx_vlan");
2710 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2711 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2713 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2714 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2717 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2718 .f = cmd_tx_vlan_reset_parsed,
2720 .help_str = "disable hardware insertion of a VLAN header in packets "
2723 (void *)&cmd_tx_vlan_reset_tx_vlan,
2724 (void *)&cmd_tx_vlan_reset_reset,
2725 (void *)&cmd_tx_vlan_reset_portid,
2731 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2732 struct cmd_tx_cksum_set_result {
2733 cmdline_fixed_string_t tx_cksum;
2734 cmdline_fixed_string_t set;
2740 cmd_tx_cksum_set_parsed(void *parsed_result,
2741 __attribute__((unused)) struct cmdline *cl,
2742 __attribute__((unused)) void *data)
2744 struct cmd_tx_cksum_set_result *res = parsed_result;
2746 tx_cksum_set(res->port_id, res->cksum_mask);
2749 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2750 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2751 tx_cksum, "tx_checksum");
2752 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2753 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2755 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2756 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2758 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2759 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2762 cmdline_parse_inst_t cmd_tx_cksum_set = {
2763 .f = cmd_tx_cksum_set_parsed,
2765 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2766 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2767 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2769 (void *)&cmd_tx_cksum_set_tx_cksum,
2770 (void *)&cmd_tx_cksum_set_set,
2771 (void *)&cmd_tx_cksum_set_cksum_mask,
2772 (void *)&cmd_tx_cksum_set_portid,
2777 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2778 struct cmd_set_flush_rx {
2779 cmdline_fixed_string_t set;
2780 cmdline_fixed_string_t flush_rx;
2781 cmdline_fixed_string_t mode;
2785 cmd_set_flush_rx_parsed(void *parsed_result,
2786 __attribute__((unused)) struct cmdline *cl,
2787 __attribute__((unused)) void *data)
2789 struct cmd_set_flush_rx *res = parsed_result;
2790 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2793 cmdline_parse_token_string_t cmd_setflushrx_set =
2794 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2796 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2797 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2798 flush_rx, "flush_rx");
2799 cmdline_parse_token_string_t cmd_setflushrx_mode =
2800 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2804 cmdline_parse_inst_t cmd_set_flush_rx = {
2805 .f = cmd_set_flush_rx_parsed,
2806 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2809 (void *)&cmd_setflushrx_set,
2810 (void *)&cmd_setflushrx_flush_rx,
2811 (void *)&cmd_setflushrx_mode,
2816 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2817 struct cmd_set_link_check {
2818 cmdline_fixed_string_t set;
2819 cmdline_fixed_string_t link_check;
2820 cmdline_fixed_string_t mode;
2824 cmd_set_link_check_parsed(void *parsed_result,
2825 __attribute__((unused)) struct cmdline *cl,
2826 __attribute__((unused)) void *data)
2828 struct cmd_set_link_check *res = parsed_result;
2829 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2832 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2833 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2835 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2836 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2837 link_check, "link_check");
2838 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2839 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2843 cmdline_parse_inst_t cmd_set_link_check = {
2844 .f = cmd_set_link_check_parsed,
2845 .help_str = "set link_check on|off: enable/disable link status check "
2846 "when starting/stopping a port",
2849 (void *)&cmd_setlinkcheck_set,
2850 (void *)&cmd_setlinkcheck_link_check,
2851 (void *)&cmd_setlinkcheck_mode,
2856 #ifdef RTE_NIC_BYPASS
2857 /* *** SET NIC BYPASS MODE *** */
2858 struct cmd_set_bypass_mode_result {
2859 cmdline_fixed_string_t set;
2860 cmdline_fixed_string_t bypass;
2861 cmdline_fixed_string_t mode;
2862 cmdline_fixed_string_t value;
2867 cmd_set_bypass_mode_parsed(void *parsed_result,
2868 __attribute__((unused)) struct cmdline *cl,
2869 __attribute__((unused)) void *data)
2871 struct cmd_set_bypass_mode_result *res = parsed_result;
2872 portid_t port_id = res->port_id;
2873 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2875 if (!bypass_is_supported(port_id))
2878 if (!strcmp(res->value, "bypass"))
2879 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2880 else if (!strcmp(res->value, "isolate"))
2881 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2883 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2885 /* Set the bypass mode for the relevant port. */
2886 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2887 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2891 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2892 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2894 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2895 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2897 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2898 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2900 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2901 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2902 value, "normal#bypass#isolate");
2903 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2904 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2907 cmdline_parse_inst_t cmd_set_bypass_mode = {
2908 .f = cmd_set_bypass_mode_parsed,
2909 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2910 "Set the NIC bypass mode for port_id",
2913 (void *)&cmd_setbypass_mode_set,
2914 (void *)&cmd_setbypass_mode_bypass,
2915 (void *)&cmd_setbypass_mode_mode,
2916 (void *)&cmd_setbypass_mode_value,
2917 (void *)&cmd_setbypass_mode_port,
2922 /* *** SET NIC BYPASS EVENT *** */
2923 struct cmd_set_bypass_event_result {
2924 cmdline_fixed_string_t set;
2925 cmdline_fixed_string_t bypass;
2926 cmdline_fixed_string_t event;
2927 cmdline_fixed_string_t event_value;
2928 cmdline_fixed_string_t mode;
2929 cmdline_fixed_string_t mode_value;
2934 cmd_set_bypass_event_parsed(void *parsed_result,
2935 __attribute__((unused)) struct cmdline *cl,
2936 __attribute__((unused)) void *data)
2939 struct cmd_set_bypass_event_result *res = parsed_result;
2940 portid_t port_id = res->port_id;
2941 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2942 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2944 if (!bypass_is_supported(port_id))
2947 if (!strcmp(res->event_value, "timeout"))
2948 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2949 else if (!strcmp(res->event_value, "os_on"))
2950 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2951 else if (!strcmp(res->event_value, "os_off"))
2952 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2953 else if (!strcmp(res->event_value, "power_on"))
2954 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2955 else if (!strcmp(res->event_value, "power_off"))
2956 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2958 bypass_event = RTE_BYPASS_EVENT_NONE;
2960 if (!strcmp(res->mode_value, "bypass"))
2961 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2962 else if (!strcmp(res->mode_value, "isolate"))
2963 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2965 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2967 /* Set the watchdog timeout. */
2968 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2971 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2972 (rc = rte_eth_dev_wd_timeout_store(port_id,
2973 bypass_timeout)) != 0) {
2974 printf("Failed to set timeout value %u "
2975 "for port %d, errto code: %d.\n",
2976 bypass_timeout, port_id, rc);
2980 /* Set the bypass event to transition to bypass mode. */
2981 if (0 != rte_eth_dev_bypass_event_store(port_id,
2982 bypass_event, bypass_mode)) {
2983 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2988 cmdline_parse_token_string_t cmd_setbypass_event_set =
2989 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2991 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2992 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2994 cmdline_parse_token_string_t cmd_setbypass_event_event =
2995 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2997 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2998 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2999 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3000 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3001 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3003 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3004 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3005 mode_value, "normal#bypass#isolate");
3006 cmdline_parse_token_num_t cmd_setbypass_event_port =
3007 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3010 cmdline_parse_inst_t cmd_set_bypass_event = {
3011 .f = cmd_set_bypass_event_parsed,
3012 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3013 "mode (normal|bypass|isolate) (port_id): "
3014 "Set the NIC bypass event mode for port_id",
3017 (void *)&cmd_setbypass_event_set,
3018 (void *)&cmd_setbypass_event_bypass,
3019 (void *)&cmd_setbypass_event_event,
3020 (void *)&cmd_setbypass_event_event_value,
3021 (void *)&cmd_setbypass_event_mode,
3022 (void *)&cmd_setbypass_event_mode_value,
3023 (void *)&cmd_setbypass_event_port,
3029 /* *** SET NIC BYPASS TIMEOUT *** */
3030 struct cmd_set_bypass_timeout_result {
3031 cmdline_fixed_string_t set;
3032 cmdline_fixed_string_t bypass;
3033 cmdline_fixed_string_t timeout;
3034 cmdline_fixed_string_t value;
3038 cmd_set_bypass_timeout_parsed(void *parsed_result,
3039 __attribute__((unused)) struct cmdline *cl,
3040 __attribute__((unused)) void *data)
3042 struct cmd_set_bypass_timeout_result *res = parsed_result;
3044 if (!strcmp(res->value, "1.5"))
3045 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3046 else if (!strcmp(res->value, "2"))
3047 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3048 else if (!strcmp(res->value, "3"))
3049 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3050 else if (!strcmp(res->value, "4"))
3051 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3052 else if (!strcmp(res->value, "8"))
3053 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3054 else if (!strcmp(res->value, "16"))
3055 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3056 else if (!strcmp(res->value, "32"))
3057 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3059 bypass_timeout = RTE_BYPASS_TMT_OFF;
3062 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3063 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3065 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3066 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3068 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3069 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3070 timeout, "timeout");
3071 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3072 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3073 value, "0#1.5#2#3#4#8#16#32");
3075 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3076 .f = cmd_set_bypass_timeout_parsed,
3077 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3078 "Set the NIC bypass watchdog timeout",
3081 (void *)&cmd_setbypass_timeout_set,
3082 (void *)&cmd_setbypass_timeout_bypass,
3083 (void *)&cmd_setbypass_timeout_timeout,
3084 (void *)&cmd_setbypass_timeout_value,
3089 /* *** SHOW NIC BYPASS MODE *** */
3090 struct cmd_show_bypass_config_result {
3091 cmdline_fixed_string_t show;
3092 cmdline_fixed_string_t bypass;
3093 cmdline_fixed_string_t config;
3098 cmd_show_bypass_config_parsed(void *parsed_result,
3099 __attribute__((unused)) struct cmdline *cl,
3100 __attribute__((unused)) void *data)
3102 struct cmd_show_bypass_config_result *res = parsed_result;
3103 uint32_t event_mode;
3104 uint32_t bypass_mode;
3105 portid_t port_id = res->port_id;
3106 uint32_t timeout = bypass_timeout;
3109 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3110 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3111 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3112 {"UNKNOWN", "normal", "bypass", "isolate"};
3113 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3120 int num_events = (sizeof events) / (sizeof events[0]);
3122 if (!bypass_is_supported(port_id))
3125 /* Display the bypass mode.*/
3126 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3127 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3131 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3132 bypass_mode = RTE_BYPASS_MODE_NONE;
3134 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3137 /* Display the bypass timeout.*/
3138 if (!RTE_BYPASS_TMT_VALID(timeout))
3139 timeout = RTE_BYPASS_TMT_OFF;
3141 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3143 /* Display the bypass events and associated modes. */
3144 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3146 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3147 printf("\tFailed to get bypass mode for event = %s\n",
3150 if (!RTE_BYPASS_MODE_VALID(event_mode))
3151 event_mode = RTE_BYPASS_MODE_NONE;
3153 printf("\tbypass event: %-16s = %s\n", events[i],
3159 cmdline_parse_token_string_t cmd_showbypass_config_show =
3160 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3162 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3163 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3165 cmdline_parse_token_string_t cmd_showbypass_config_config =
3166 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3168 cmdline_parse_token_num_t cmd_showbypass_config_port =
3169 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3172 cmdline_parse_inst_t cmd_show_bypass_config = {
3173 .f = cmd_show_bypass_config_parsed,
3174 .help_str = "show bypass config (port_id): "
3175 "Show the NIC bypass config for port_id",
3178 (void *)&cmd_showbypass_config_show,
3179 (void *)&cmd_showbypass_config_bypass,
3180 (void *)&cmd_showbypass_config_config,
3181 (void *)&cmd_showbypass_config_port,
3187 #ifdef RTE_LIBRTE_PMD_BOND
3188 /* *** SET BONDING MODE *** */
3189 struct cmd_set_bonding_mode_result {
3190 cmdline_fixed_string_t set;
3191 cmdline_fixed_string_t bonding;
3192 cmdline_fixed_string_t mode;
3197 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3198 __attribute__((unused)) struct cmdline *cl,
3199 __attribute__((unused)) void *data)
3201 struct cmd_set_bonding_mode_result *res = parsed_result;
3202 portid_t port_id = res->port_id;
3204 /* Set the bonding mode for the relevant port. */
3205 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3206 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3209 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3210 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3212 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3213 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3214 bonding, "bonding");
3215 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3216 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3218 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3219 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3221 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3222 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3225 cmdline_parse_inst_t cmd_set_bonding_mode = {
3226 .f = cmd_set_bonding_mode_parsed,
3227 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3230 (void *) &cmd_setbonding_mode_set,
3231 (void *) &cmd_setbonding_mode_bonding,
3232 (void *) &cmd_setbonding_mode_mode,
3233 (void *) &cmd_setbonding_mode_value,
3234 (void *) &cmd_setbonding_mode_port,
3239 /* *** SET BALANCE XMIT POLICY *** */
3240 struct cmd_set_bonding_balance_xmit_policy_result {
3241 cmdline_fixed_string_t set;
3242 cmdline_fixed_string_t bonding;
3243 cmdline_fixed_string_t balance_xmit_policy;
3245 cmdline_fixed_string_t policy;
3248 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3249 __attribute__((unused)) struct cmdline *cl,
3250 __attribute__((unused)) void *data)
3252 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3253 portid_t port_id = res->port_id;
3256 if (!strcmp(res->policy, "l2")) {
3257 policy = BALANCE_XMIT_POLICY_LAYER2;
3258 } else if (!strcmp(res->policy, "l23")) {
3259 policy = BALANCE_XMIT_POLICY_LAYER23;
3260 } else if (!strcmp(res->policy, "l34")) {
3261 policy = BALANCE_XMIT_POLICY_LAYER34;
3263 printf("\t Invalid xmit policy selection");
3267 /* Set the bonding mode for the relevant port. */
3268 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3269 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3274 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3275 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3277 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3278 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3279 bonding, "bonding");
3280 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3281 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3282 balance_xmit_policy, "balance_xmit_policy");
3283 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3284 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3286 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3287 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3288 policy, "l2#l23#l34");
3290 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3291 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3292 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3295 (void *)&cmd_setbonding_balance_xmit_policy_set,
3296 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3297 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3298 (void *)&cmd_setbonding_balance_xmit_policy_port,
3299 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3304 /* *** SHOW NIC BONDING CONFIGURATION *** */
3305 struct cmd_show_bonding_config_result {
3306 cmdline_fixed_string_t show;
3307 cmdline_fixed_string_t bonding;
3308 cmdline_fixed_string_t config;
3312 static void cmd_show_bonding_config_parsed(void *parsed_result,
3313 __attribute__((unused)) struct cmdline *cl,
3314 __attribute__((unused)) void *data)
3316 struct cmd_show_bonding_config_result *res = parsed_result;
3318 uint8_t slaves[RTE_MAX_ETHPORTS];
3319 int num_slaves, num_active_slaves;
3322 portid_t port_id = res->port_id;
3324 /* Display the bonding mode.*/
3325 bonding_mode = rte_eth_bond_mode_get(port_id);
3326 if (bonding_mode < 0) {
3327 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3330 printf("\tBonding mode: %d\n", bonding_mode);
3332 if (bonding_mode == BONDING_MODE_BALANCE) {
3333 int balance_xmit_policy;
3335 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3336 if (balance_xmit_policy < 0) {
3337 printf("\tFailed to get balance xmit policy for port = %d\n",
3341 printf("\tBalance Xmit Policy: ");
3343 switch (balance_xmit_policy) {
3344 case BALANCE_XMIT_POLICY_LAYER2:
3345 printf("BALANCE_XMIT_POLICY_LAYER2");
3347 case BALANCE_XMIT_POLICY_LAYER23:
3348 printf("BALANCE_XMIT_POLICY_LAYER23");
3350 case BALANCE_XMIT_POLICY_LAYER34:
3351 printf("BALANCE_XMIT_POLICY_LAYER34");
3358 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3360 if (num_slaves < 0) {
3361 printf("\tFailed to get slave list for port = %d\n", port_id);
3364 if (num_slaves > 0) {
3365 printf("\tSlaves (%d): [", num_slaves);
3366 for (i = 0; i < num_slaves - 1; i++)
3367 printf("%d ", slaves[i]);
3369 printf("%d]\n", slaves[num_slaves - 1]);
3371 printf("\tSlaves: []\n");
3375 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3378 if (num_active_slaves < 0) {
3379 printf("\tFailed to get active slave list for port = %d\n", port_id);
3382 if (num_active_slaves > 0) {
3383 printf("\tActive Slaves (%d): [", num_active_slaves);
3384 for (i = 0; i < num_active_slaves - 1; i++)
3385 printf("%d ", slaves[i]);
3387 printf("%d]\n", slaves[num_active_slaves - 1]);
3390 printf("\tActive Slaves: []\n");
3394 primary_id = rte_eth_bond_primary_get(port_id);
3395 if (primary_id < 0) {
3396 printf("\tFailed to get primary slave for port = %d\n", port_id);
3399 printf("\tPrimary: [%d]\n", primary_id);
3403 cmdline_parse_token_string_t cmd_showbonding_config_show =
3404 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3406 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3407 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3408 bonding, "bonding");
3409 cmdline_parse_token_string_t cmd_showbonding_config_config =
3410 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3412 cmdline_parse_token_num_t cmd_showbonding_config_port =
3413 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3416 cmdline_parse_inst_t cmd_show_bonding_config = {
3417 .f = cmd_show_bonding_config_parsed,
3418 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3421 (void *)&cmd_showbonding_config_show,
3422 (void *)&cmd_showbonding_config_bonding,
3423 (void *)&cmd_showbonding_config_config,
3424 (void *)&cmd_showbonding_config_port,
3429 /* *** SET BONDING PRIMARY *** */
3430 struct cmd_set_bonding_primary_result {
3431 cmdline_fixed_string_t set;
3432 cmdline_fixed_string_t bonding;
3433 cmdline_fixed_string_t primary;
3438 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3439 __attribute__((unused)) struct cmdline *cl,
3440 __attribute__((unused)) void *data)
3442 struct cmd_set_bonding_primary_result *res = parsed_result;
3443 portid_t master_port_id = res->port_id;
3444 portid_t slave_port_id = res->slave_id;
3446 /* Set the primary slave for a bonded device. */
3447 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3448 printf("\t Failed to set primary slave for port = %d.\n",
3455 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3456 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3458 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3459 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3460 bonding, "bonding");
3461 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3462 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3463 primary, "primary");
3464 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3465 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3467 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3468 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3471 cmdline_parse_inst_t cmd_set_bonding_primary = {
3472 .f = cmd_set_bonding_primary_parsed,
3473 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3476 (void *)&cmd_setbonding_primary_set,
3477 (void *)&cmd_setbonding_primary_bonding,
3478 (void *)&cmd_setbonding_primary_primary,
3479 (void *)&cmd_setbonding_primary_slave,
3480 (void *)&cmd_setbonding_primary_port,
3485 /* *** ADD SLAVE *** */
3486 struct cmd_add_bonding_slave_result {
3487 cmdline_fixed_string_t add;
3488 cmdline_fixed_string_t bonding;
3489 cmdline_fixed_string_t slave;
3494 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3495 __attribute__((unused)) struct cmdline *cl,
3496 __attribute__((unused)) void *data)
3498 struct cmd_add_bonding_slave_result *res = parsed_result;
3499 portid_t master_port_id = res->port_id;
3500 portid_t slave_port_id = res->slave_id;
3502 /* Set the primary slave for a bonded device. */
3503 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3504 printf("\t Failed to add slave %d to master port = %d.\n",
3505 slave_port_id, master_port_id);
3511 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3512 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3514 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3515 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3516 bonding, "bonding");
3517 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3518 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3520 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3521 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3523 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3524 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3527 cmdline_parse_inst_t cmd_add_bonding_slave = {
3528 .f = cmd_add_bonding_slave_parsed,
3529 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3532 (void *)&cmd_addbonding_slave_add,
3533 (void *)&cmd_addbonding_slave_bonding,
3534 (void *)&cmd_addbonding_slave_slave,
3535 (void *)&cmd_addbonding_slave_slaveid,
3536 (void *)&cmd_addbonding_slave_port,
3541 /* *** REMOVE SLAVE *** */
3542 struct cmd_remove_bonding_slave_result {
3543 cmdline_fixed_string_t remove;
3544 cmdline_fixed_string_t bonding;
3545 cmdline_fixed_string_t slave;
3550 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3551 __attribute__((unused)) struct cmdline *cl,
3552 __attribute__((unused)) void *data)
3554 struct cmd_remove_bonding_slave_result *res = parsed_result;
3555 portid_t master_port_id = res->port_id;
3556 portid_t slave_port_id = res->slave_id;
3558 /* Set the primary slave for a bonded device. */
3559 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3560 printf("\t Failed to remove slave %d from master port = %d.\n",
3561 slave_port_id, master_port_id);
3567 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3568 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3570 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3571 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3572 bonding, "bonding");
3573 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3574 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3576 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3577 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3579 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3580 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3583 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3584 .f = cmd_remove_bonding_slave_parsed,
3585 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3588 (void *)&cmd_removebonding_slave_remove,
3589 (void *)&cmd_removebonding_slave_bonding,
3590 (void *)&cmd_removebonding_slave_slave,
3591 (void *)&cmd_removebonding_slave_slaveid,
3592 (void *)&cmd_removebonding_slave_port,
3597 /* *** CREATE BONDED DEVICE *** */
3598 struct cmd_create_bonded_device_result {
3599 cmdline_fixed_string_t create;
3600 cmdline_fixed_string_t bonded;
3601 cmdline_fixed_string_t device;
3606 static int bond_dev_num = 0;
3608 static void cmd_create_bonded_device_parsed(void *parsed_result,
3609 __attribute__((unused)) struct cmdline *cl,
3610 __attribute__((unused)) void *data)
3612 struct cmd_create_bonded_device_result *res = parsed_result;
3613 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3616 if (test_done == 0) {
3617 printf("Please stop forwarding first\n");
3621 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3624 /* Create a new bonded device. */
3625 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3627 printf("\t Failed to create bonded device.\n");
3630 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3633 /* Update number of ports */
3634 nb_ports = rte_eth_dev_count();
3636 rte_eth_promiscuous_enable(port_id);
3641 cmdline_parse_token_string_t cmd_createbonded_device_create =
3642 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3644 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3645 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3647 cmdline_parse_token_string_t cmd_createbonded_device_device =
3648 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3650 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3651 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3653 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3654 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3657 cmdline_parse_inst_t cmd_create_bonded_device = {
3658 .f = cmd_create_bonded_device_parsed,
3659 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3662 (void *)&cmd_createbonded_device_create,
3663 (void *)&cmd_createbonded_device_bonded,
3664 (void *)&cmd_createbonded_device_device,
3665 (void *)&cmd_createbonded_device_mode,
3666 (void *)&cmd_createbonded_device_socket,
3671 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3672 struct cmd_set_bond_mac_addr_result {
3673 cmdline_fixed_string_t set;
3674 cmdline_fixed_string_t bonding;
3675 cmdline_fixed_string_t mac_addr;
3677 struct ether_addr address;
3680 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3681 __attribute__((unused)) struct cmdline *cl,
3682 __attribute__((unused)) void *data)
3684 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3687 if (res->port_num >= nb_ports) {
3688 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3692 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3694 /* check the return value and print it if is < 0 */
3696 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3699 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3700 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3701 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3702 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3704 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3705 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3707 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3708 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3709 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3710 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3712 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3713 .f = cmd_set_bond_mac_addr_parsed,
3715 .help_str = "set bonding mac_addr (port_id) (address): ",
3717 (void *)&cmd_set_bond_mac_addr_set,
3718 (void *)&cmd_set_bond_mac_addr_bonding,
3719 (void *)&cmd_set_bond_mac_addr_mac,
3720 (void *)&cmd_set_bond_mac_addr_portnum,
3721 (void *)&cmd_set_bond_mac_addr_addr,
3726 #endif /* RTE_LIBRTE_PMD_BOND */
3728 /* *** SET FORWARDING MODE *** */
3729 struct cmd_set_fwd_mode_result {
3730 cmdline_fixed_string_t set;
3731 cmdline_fixed_string_t fwd;
3732 cmdline_fixed_string_t mode;
3735 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3736 __attribute__((unused)) struct cmdline *cl,
3737 __attribute__((unused)) void *data)
3739 struct cmd_set_fwd_mode_result *res = parsed_result;
3741 set_pkt_forwarding_mode(res->mode);
3744 cmdline_parse_token_string_t cmd_setfwd_set =
3745 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3746 cmdline_parse_token_string_t cmd_setfwd_fwd =
3747 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3748 cmdline_parse_token_string_t cmd_setfwd_mode =
3749 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3750 "" /* defined at init */);
3752 cmdline_parse_inst_t cmd_set_fwd_mode = {
3753 .f = cmd_set_fwd_mode_parsed,
3755 .help_str = NULL, /* defined at init */
3757 (void *)&cmd_setfwd_set,
3758 (void *)&cmd_setfwd_fwd,
3759 (void *)&cmd_setfwd_mode,
3764 static void cmd_set_fwd_mode_init(void)
3767 static char token[128];
3768 static char help[256];
3769 cmdline_parse_token_string_t *token_struct;
3771 modes = list_pkt_forwarding_modes();
3772 snprintf(help, sizeof help, "set fwd %s - "
3773 "set packet forwarding mode", modes);
3774 cmd_set_fwd_mode.help_str = help;
3776 /* string token separator is # */
3777 for (c = token; *modes != '\0'; modes++)
3782 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3783 token_struct->string_data.str = token;
3786 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3787 struct cmd_set_burst_tx_retry_result {
3788 cmdline_fixed_string_t set;
3789 cmdline_fixed_string_t burst;
3790 cmdline_fixed_string_t tx;
3791 cmdline_fixed_string_t delay;
3793 cmdline_fixed_string_t retry;
3797 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3798 __attribute__((unused)) struct cmdline *cl,
3799 __attribute__((unused)) void *data)
3801 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3803 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3804 && !strcmp(res->tx, "tx")) {
3805 if (!strcmp(res->delay, "delay"))
3806 burst_tx_delay_time = res->time;
3807 if (!strcmp(res->retry, "retry"))
3808 burst_tx_retry_num = res->retry_num;
3813 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3814 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3815 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3816 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3818 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3819 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3820 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3821 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3822 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3823 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3824 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3826 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3827 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3829 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3830 .f = cmd_set_burst_tx_retry_parsed,
3831 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3833 (void *)&cmd_set_burst_tx_retry_set,
3834 (void *)&cmd_set_burst_tx_retry_burst,
3835 (void *)&cmd_set_burst_tx_retry_tx,
3836 (void *)&cmd_set_burst_tx_retry_delay,
3837 (void *)&cmd_set_burst_tx_retry_time,
3838 (void *)&cmd_set_burst_tx_retry_retry,
3839 (void *)&cmd_set_burst_tx_retry_retry_num,
3844 /* *** SET PROMISC MODE *** */
3845 struct cmd_set_promisc_mode_result {
3846 cmdline_fixed_string_t set;
3847 cmdline_fixed_string_t promisc;
3848 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3849 uint8_t port_num; /* valid if "allports" argument == 0 */
3850 cmdline_fixed_string_t mode;
3853 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3854 __attribute__((unused)) struct cmdline *cl,
3857 struct cmd_set_promisc_mode_result *res = parsed_result;
3861 if (!strcmp(res->mode, "on"))
3868 for (i = 0; i < nb_ports; i++) {
3870 rte_eth_promiscuous_enable(i);
3872 rte_eth_promiscuous_disable(i);
3877 rte_eth_promiscuous_enable(res->port_num);
3879 rte_eth_promiscuous_disable(res->port_num);
3883 cmdline_parse_token_string_t cmd_setpromisc_set =
3884 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3885 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3886 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3888 cmdline_parse_token_string_t cmd_setpromisc_portall =
3889 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3891 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3892 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3894 cmdline_parse_token_string_t cmd_setpromisc_mode =
3895 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3898 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3899 .f = cmd_set_promisc_mode_parsed,
3901 .help_str = "set promisc all on|off: set promisc mode for all ports",
3903 (void *)&cmd_setpromisc_set,
3904 (void *)&cmd_setpromisc_promisc,
3905 (void *)&cmd_setpromisc_portall,
3906 (void *)&cmd_setpromisc_mode,
3911 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3912 .f = cmd_set_promisc_mode_parsed,
3914 .help_str = "set promisc X on|off: set promisc mode on port X",
3916 (void *)&cmd_setpromisc_set,
3917 (void *)&cmd_setpromisc_promisc,
3918 (void *)&cmd_setpromisc_portnum,
3919 (void *)&cmd_setpromisc_mode,
3924 /* *** SET ALLMULTI MODE *** */
3925 struct cmd_set_allmulti_mode_result {
3926 cmdline_fixed_string_t set;
3927 cmdline_fixed_string_t allmulti;
3928 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3929 uint8_t port_num; /* valid if "allports" argument == 0 */
3930 cmdline_fixed_string_t mode;
3933 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3934 __attribute__((unused)) struct cmdline *cl,
3937 struct cmd_set_allmulti_mode_result *res = parsed_result;
3941 if (!strcmp(res->mode, "on"))
3948 for (i = 0; i < nb_ports; i++) {
3950 rte_eth_allmulticast_enable(i);
3952 rte_eth_allmulticast_disable(i);
3957 rte_eth_allmulticast_enable(res->port_num);
3959 rte_eth_allmulticast_disable(res->port_num);
3963 cmdline_parse_token_string_t cmd_setallmulti_set =
3964 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3965 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3966 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3968 cmdline_parse_token_string_t cmd_setallmulti_portall =
3969 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3971 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3972 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3974 cmdline_parse_token_string_t cmd_setallmulti_mode =
3975 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3978 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3979 .f = cmd_set_allmulti_mode_parsed,
3981 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3983 (void *)&cmd_setallmulti_set,
3984 (void *)&cmd_setallmulti_allmulti,
3985 (void *)&cmd_setallmulti_portall,
3986 (void *)&cmd_setallmulti_mode,
3991 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3992 .f = cmd_set_allmulti_mode_parsed,
3994 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3996 (void *)&cmd_setallmulti_set,
3997 (void *)&cmd_setallmulti_allmulti,
3998 (void *)&cmd_setallmulti_portnum,
3999 (void *)&cmd_setallmulti_mode,
4004 /* *** ADD/REMOVE A PKT FILTER *** */
4005 struct cmd_pkt_filter_result {
4006 cmdline_fixed_string_t pkt_filter;
4008 cmdline_fixed_string_t protocol;
4009 cmdline_fixed_string_t src;
4010 cmdline_ipaddr_t ip_src;
4012 cmdline_fixed_string_t dst;
4013 cmdline_ipaddr_t ip_dst;
4015 cmdline_fixed_string_t flexbytes;
4016 uint16_t flexbytes_value;
4017 cmdline_fixed_string_t vlan;
4019 cmdline_fixed_string_t queue;
4021 cmdline_fixed_string_t soft;
4026 cmd_pkt_filter_parsed(void *parsed_result,
4027 __attribute__((unused)) struct cmdline *cl,
4028 __attribute__((unused)) void *data)
4030 struct rte_fdir_filter fdir_filter;
4031 struct cmd_pkt_filter_result *res = parsed_result;
4033 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4035 if (res->ip_src.family == AF_INET)
4036 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4038 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4039 &(res->ip_src.addr.ipv6),
4040 sizeof(struct in6_addr));
4042 if (res->ip_dst.family == AF_INET)
4043 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4045 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4046 &(res->ip_dst.addr.ipv6),
4047 sizeof(struct in6_addr));
4049 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4050 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4052 if (!strcmp(res->protocol, "udp"))
4053 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4054 else if (!strcmp(res->protocol, "tcp"))
4055 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4056 else if (!strcmp(res->protocol, "sctp"))
4057 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4058 else /* default only IP */
4059 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4061 if (res->ip_dst.family == AF_INET6)
4062 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4064 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4066 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4067 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4069 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4070 fdir_add_signature_filter(res->port_id, res->queue_id,
4072 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4073 fdir_update_signature_filter(res->port_id, res->queue_id,
4075 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4076 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4077 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4078 fdir_add_perfect_filter(res->port_id, res->soft_id,
4080 (uint8_t) (res->queue_id < 0),
4082 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4083 fdir_update_perfect_filter(res->port_id, res->soft_id,
4085 (uint8_t) (res->queue_id < 0),
4087 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4088 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4094 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4095 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4097 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4098 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4099 protocol, "ip#tcp#udp#sctp");
4100 cmdline_parse_token_string_t cmd_pkt_filter_src =
4101 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4103 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4104 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4106 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4107 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4109 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4110 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4112 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4113 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4115 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4116 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4118 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4119 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4120 flexbytes, "flexbytes");
4121 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4122 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4123 flexbytes_value, UINT16);
4124 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4125 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4127 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4128 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4130 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4131 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4133 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4134 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4136 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4137 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4139 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4140 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4144 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4145 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4146 pkt_filter, "add_signature_filter");
4147 cmdline_parse_inst_t cmd_add_signature_filter = {
4148 .f = cmd_pkt_filter_parsed,
4150 .help_str = "add a signature filter",
4152 (void *)&cmd_pkt_filter_add_signature_filter,
4153 (void *)&cmd_pkt_filter_port_id,
4154 (void *)&cmd_pkt_filter_protocol,
4155 (void *)&cmd_pkt_filter_src,
4156 (void *)&cmd_pkt_filter_ip_src,
4157 (void *)&cmd_pkt_filter_port_src,
4158 (void *)&cmd_pkt_filter_dst,
4159 (void *)&cmd_pkt_filter_ip_dst,
4160 (void *)&cmd_pkt_filter_port_dst,
4161 (void *)&cmd_pkt_filter_flexbytes,
4162 (void *)&cmd_pkt_filter_flexbytes_value,
4163 (void *)&cmd_pkt_filter_vlan,
4164 (void *)&cmd_pkt_filter_vlan_id,
4165 (void *)&cmd_pkt_filter_queue,
4166 (void *)&cmd_pkt_filter_queue_id,
4172 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4173 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4174 pkt_filter, "upd_signature_filter");
4175 cmdline_parse_inst_t cmd_upd_signature_filter = {
4176 .f = cmd_pkt_filter_parsed,
4178 .help_str = "update a signature filter",
4180 (void *)&cmd_pkt_filter_upd_signature_filter,
4181 (void *)&cmd_pkt_filter_port_id,
4182 (void *)&cmd_pkt_filter_protocol,
4183 (void *)&cmd_pkt_filter_src,
4184 (void *)&cmd_pkt_filter_ip_src,
4185 (void *)&cmd_pkt_filter_port_src,
4186 (void *)&cmd_pkt_filter_dst,
4187 (void *)&cmd_pkt_filter_ip_dst,
4188 (void *)&cmd_pkt_filter_port_dst,
4189 (void *)&cmd_pkt_filter_flexbytes,
4190 (void *)&cmd_pkt_filter_flexbytes_value,
4191 (void *)&cmd_pkt_filter_vlan,
4192 (void *)&cmd_pkt_filter_vlan_id,
4193 (void *)&cmd_pkt_filter_queue,
4194 (void *)&cmd_pkt_filter_queue_id,
4200 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4201 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4202 pkt_filter, "rm_signature_filter");
4203 cmdline_parse_inst_t cmd_rm_signature_filter = {
4204 .f = cmd_pkt_filter_parsed,
4206 .help_str = "remove a signature filter",
4208 (void *)&cmd_pkt_filter_rm_signature_filter,
4209 (void *)&cmd_pkt_filter_port_id,
4210 (void *)&cmd_pkt_filter_protocol,
4211 (void *)&cmd_pkt_filter_src,
4212 (void *)&cmd_pkt_filter_ip_src,
4213 (void *)&cmd_pkt_filter_port_src,
4214 (void *)&cmd_pkt_filter_dst,
4215 (void *)&cmd_pkt_filter_ip_dst,
4216 (void *)&cmd_pkt_filter_port_dst,
4217 (void *)&cmd_pkt_filter_flexbytes,
4218 (void *)&cmd_pkt_filter_flexbytes_value,
4219 (void *)&cmd_pkt_filter_vlan,
4220 (void *)&cmd_pkt_filter_vlan_id,
4226 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4227 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4228 pkt_filter, "add_perfect_filter");
4229 cmdline_parse_inst_t cmd_add_perfect_filter = {
4230 .f = cmd_pkt_filter_parsed,
4232 .help_str = "add a perfect filter",
4234 (void *)&cmd_pkt_filter_add_perfect_filter,
4235 (void *)&cmd_pkt_filter_port_id,
4236 (void *)&cmd_pkt_filter_protocol,
4237 (void *)&cmd_pkt_filter_src,
4238 (void *)&cmd_pkt_filter_ip_src,
4239 (void *)&cmd_pkt_filter_port_src,
4240 (void *)&cmd_pkt_filter_dst,
4241 (void *)&cmd_pkt_filter_ip_dst,
4242 (void *)&cmd_pkt_filter_port_dst,
4243 (void *)&cmd_pkt_filter_flexbytes,
4244 (void *)&cmd_pkt_filter_flexbytes_value,
4245 (void *)&cmd_pkt_filter_vlan,
4246 (void *)&cmd_pkt_filter_vlan_id,
4247 (void *)&cmd_pkt_filter_queue,
4248 (void *)&cmd_pkt_filter_queue_id,
4249 (void *)&cmd_pkt_filter_soft,
4250 (void *)&cmd_pkt_filter_soft_id,
4256 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4257 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4258 pkt_filter, "upd_perfect_filter");
4259 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4260 .f = cmd_pkt_filter_parsed,
4262 .help_str = "update a perfect filter",
4264 (void *)&cmd_pkt_filter_upd_perfect_filter,
4265 (void *)&cmd_pkt_filter_port_id,
4266 (void *)&cmd_pkt_filter_protocol,
4267 (void *)&cmd_pkt_filter_src,
4268 (void *)&cmd_pkt_filter_ip_src,
4269 (void *)&cmd_pkt_filter_port_src,
4270 (void *)&cmd_pkt_filter_dst,
4271 (void *)&cmd_pkt_filter_ip_dst,
4272 (void *)&cmd_pkt_filter_port_dst,
4273 (void *)&cmd_pkt_filter_flexbytes,
4274 (void *)&cmd_pkt_filter_flexbytes_value,
4275 (void *)&cmd_pkt_filter_vlan,
4276 (void *)&cmd_pkt_filter_vlan_id,
4277 (void *)&cmd_pkt_filter_queue,
4278 (void *)&cmd_pkt_filter_queue_id,
4279 (void *)&cmd_pkt_filter_soft,
4280 (void *)&cmd_pkt_filter_soft_id,
4286 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4287 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4288 pkt_filter, "rm_perfect_filter");
4289 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4290 .f = cmd_pkt_filter_parsed,
4292 .help_str = "remove a perfect filter",
4294 (void *)&cmd_pkt_filter_rm_perfect_filter,
4295 (void *)&cmd_pkt_filter_port_id,
4296 (void *)&cmd_pkt_filter_protocol,
4297 (void *)&cmd_pkt_filter_src,
4298 (void *)&cmd_pkt_filter_ip_src,
4299 (void *)&cmd_pkt_filter_port_src,
4300 (void *)&cmd_pkt_filter_dst,
4301 (void *)&cmd_pkt_filter_ip_dst,
4302 (void *)&cmd_pkt_filter_port_dst,
4303 (void *)&cmd_pkt_filter_flexbytes,
4304 (void *)&cmd_pkt_filter_flexbytes_value,
4305 (void *)&cmd_pkt_filter_vlan,
4306 (void *)&cmd_pkt_filter_vlan_id,
4307 (void *)&cmd_pkt_filter_soft,
4308 (void *)&cmd_pkt_filter_soft_id,
4313 /* *** SETUP MASKS FILTER *** */
4314 struct cmd_pkt_filter_masks_result {
4315 cmdline_fixed_string_t filter_mask;
4317 cmdline_fixed_string_t src_mask;
4318 uint32_t ip_src_mask;
4319 uint16_t ipv6_src_mask;
4320 uint16_t port_src_mask;
4321 cmdline_fixed_string_t dst_mask;
4322 uint32_t ip_dst_mask;
4323 uint16_t ipv6_dst_mask;
4324 uint16_t port_dst_mask;
4325 cmdline_fixed_string_t flexbytes;
4326 uint8_t flexbytes_value;
4327 cmdline_fixed_string_t vlan_id;
4328 uint8_t vlan_id_value;
4329 cmdline_fixed_string_t vlan_prio;
4330 uint8_t vlan_prio_value;
4331 cmdline_fixed_string_t only_ip_flow;
4332 uint8_t only_ip_flow_value;
4333 cmdline_fixed_string_t comp_ipv6_dst;
4334 uint8_t comp_ipv6_dst_value;
4338 cmd_pkt_filter_masks_parsed(void *parsed_result,
4339 __attribute__((unused)) struct cmdline *cl,
4340 __attribute__((unused)) void *data)
4342 struct rte_fdir_masks fdir_masks;
4343 struct cmd_pkt_filter_masks_result *res = parsed_result;
4345 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4347 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4348 fdir_masks.vlan_id = res->vlan_id_value;
4349 fdir_masks.vlan_prio = res->vlan_prio_value;
4350 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4351 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4352 fdir_masks.src_port_mask = res->port_src_mask;
4353 fdir_masks.dst_port_mask = res->port_dst_mask;
4354 fdir_masks.flexbytes = res->flexbytes_value;
4356 fdir_set_masks(res->port_id, &fdir_masks);
4359 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4360 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4361 filter_mask, "set_masks_filter");
4362 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4363 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4365 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4366 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4367 only_ip_flow, "only_ip_flow");
4368 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4369 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4370 only_ip_flow_value, UINT8);
4371 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4372 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4373 src_mask, "src_mask");
4374 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4375 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4376 ip_src_mask, UINT32);
4377 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4378 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4379 port_src_mask, UINT16);
4380 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4381 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4382 dst_mask, "dst_mask");
4383 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4384 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4385 ip_dst_mask, UINT32);
4386 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4387 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4388 port_dst_mask, UINT16);
4389 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4390 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4391 flexbytes, "flexbytes");
4392 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4393 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4394 flexbytes_value, UINT8);
4395 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4396 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4397 vlan_id, "vlan_id");
4398 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4399 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4400 vlan_id_value, UINT8);
4401 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4402 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4403 vlan_prio, "vlan_prio");
4404 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4405 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4406 vlan_prio_value, UINT8);
4408 cmdline_parse_inst_t cmd_set_masks_filter = {
4409 .f = cmd_pkt_filter_masks_parsed,
4411 .help_str = "setup masks filter",
4413 (void *)&cmd_pkt_filter_masks_filter_mask,
4414 (void *)&cmd_pkt_filter_masks_port_id,
4415 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4416 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4417 (void *)&cmd_pkt_filter_masks_src_mask,
4418 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4419 (void *)&cmd_pkt_filter_masks_port_src_mask,
4420 (void *)&cmd_pkt_filter_masks_dst_mask,
4421 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4422 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4423 (void *)&cmd_pkt_filter_masks_flexbytes,
4424 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4425 (void *)&cmd_pkt_filter_masks_vlan_id,
4426 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4427 (void *)&cmd_pkt_filter_masks_vlan_prio,
4428 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4434 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4435 __attribute__((unused)) struct cmdline *cl,
4436 __attribute__((unused)) void *data)
4438 struct rte_fdir_masks fdir_masks;
4439 struct cmd_pkt_filter_masks_result *res = parsed_result;
4441 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4443 fdir_masks.set_ipv6_mask = 1;
4444 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4445 fdir_masks.vlan_id = res->vlan_id_value;
4446 fdir_masks.vlan_prio = res->vlan_prio_value;
4447 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4448 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4449 fdir_masks.src_port_mask = res->port_src_mask;
4450 fdir_masks.dst_port_mask = res->port_dst_mask;
4451 fdir_masks.flexbytes = res->flexbytes_value;
4452 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4454 fdir_set_masks(res->port_id, &fdir_masks);
4457 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4458 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4459 filter_mask, "set_ipv6_masks_filter");
4460 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4461 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4462 ipv6_src_mask, UINT16);
4463 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4464 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4465 ipv6_dst_mask, UINT16);
4467 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4468 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4469 comp_ipv6_dst, "compare_dst");
4470 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4471 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4472 comp_ipv6_dst_value, UINT8);
4474 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4475 .f = cmd_pkt_filter_masks_ipv6_parsed,
4477 .help_str = "setup ipv6 masks filter",
4479 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4480 (void *)&cmd_pkt_filter_masks_port_id,
4481 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4482 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4483 (void *)&cmd_pkt_filter_masks_src_mask,
4484 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4485 (void *)&cmd_pkt_filter_masks_port_src_mask,
4486 (void *)&cmd_pkt_filter_masks_dst_mask,
4487 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4488 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4489 (void *)&cmd_pkt_filter_masks_flexbytes,
4490 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4491 (void *)&cmd_pkt_filter_masks_vlan_id,
4492 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4493 (void *)&cmd_pkt_filter_masks_vlan_prio,
4494 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4495 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4496 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4501 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4502 struct cmd_link_flow_ctrl_set_result {
4503 cmdline_fixed_string_t set;
4504 cmdline_fixed_string_t flow_ctrl;
4505 cmdline_fixed_string_t rx;
4506 cmdline_fixed_string_t rx_lfc_mode;
4507 cmdline_fixed_string_t tx;
4508 cmdline_fixed_string_t tx_lfc_mode;
4509 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4510 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4511 cmdline_fixed_string_t autoneg_str;
4512 cmdline_fixed_string_t autoneg;
4513 cmdline_fixed_string_t hw_str;
4514 uint32_t high_water;
4515 cmdline_fixed_string_t lw_str;
4517 cmdline_fixed_string_t pt_str;
4518 uint16_t pause_time;
4519 cmdline_fixed_string_t xon_str;
4524 cmdline_parse_token_string_t cmd_lfc_set_set =
4525 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4527 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4528 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4529 flow_ctrl, "flow_ctrl");
4530 cmdline_parse_token_string_t cmd_lfc_set_rx =
4531 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4533 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4534 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4535 rx_lfc_mode, "on#off");
4536 cmdline_parse_token_string_t cmd_lfc_set_tx =
4537 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4539 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4540 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4541 tx_lfc_mode, "on#off");
4542 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4543 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4544 hw_str, "high_water");
4545 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4546 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4547 high_water, UINT32);
4548 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4549 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4550 lw_str, "low_water");
4551 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4552 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4554 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4555 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4556 pt_str, "pause_time");
4557 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4558 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4559 pause_time, UINT16);
4560 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4561 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4562 xon_str, "send_xon");
4563 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4564 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4566 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4567 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4568 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4569 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4570 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4571 mac_ctrl_frame_fwd_mode, "on#off");
4572 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4573 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4574 autoneg_str, "autoneg");
4575 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4576 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4578 cmdline_parse_token_num_t cmd_lfc_set_portid =
4579 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4582 /* forward declaration */
4584 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4587 cmdline_parse_inst_t cmd_link_flow_control_set = {
4588 .f = cmd_link_flow_ctrl_set_parsed,
4590 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4591 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4592 autoneg on|off port_id",
4594 (void *)&cmd_lfc_set_set,
4595 (void *)&cmd_lfc_set_flow_ctrl,
4596 (void *)&cmd_lfc_set_rx,
4597 (void *)&cmd_lfc_set_rx_mode,
4598 (void *)&cmd_lfc_set_tx,
4599 (void *)&cmd_lfc_set_tx_mode,
4600 (void *)&cmd_lfc_set_high_water,
4601 (void *)&cmd_lfc_set_low_water,
4602 (void *)&cmd_lfc_set_pause_time,
4603 (void *)&cmd_lfc_set_send_xon,
4604 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4605 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4606 (void *)&cmd_lfc_set_autoneg_str,
4607 (void *)&cmd_lfc_set_autoneg,
4608 (void *)&cmd_lfc_set_portid,
4613 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4614 .f = cmd_link_flow_ctrl_set_parsed,
4615 .data = (void *)&cmd_link_flow_control_set_rx,
4616 .help_str = "Change rx flow control parameter: set flow_ctrl "
4617 "rx on|off port_id",
4619 (void *)&cmd_lfc_set_set,
4620 (void *)&cmd_lfc_set_flow_ctrl,
4621 (void *)&cmd_lfc_set_rx,
4622 (void *)&cmd_lfc_set_rx_mode,
4623 (void *)&cmd_lfc_set_portid,
4628 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4629 .f = cmd_link_flow_ctrl_set_parsed,
4630 .data = (void *)&cmd_link_flow_control_set_tx,
4631 .help_str = "Change tx flow control parameter: set flow_ctrl "
4632 "tx on|off port_id",
4634 (void *)&cmd_lfc_set_set,
4635 (void *)&cmd_lfc_set_flow_ctrl,
4636 (void *)&cmd_lfc_set_tx,
4637 (void *)&cmd_lfc_set_tx_mode,
4638 (void *)&cmd_lfc_set_portid,
4643 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4644 .f = cmd_link_flow_ctrl_set_parsed,
4645 .data = (void *)&cmd_link_flow_control_set_hw,
4646 .help_str = "Change high water flow control parameter: set flow_ctrl "
4647 "high_water value port_id",
4649 (void *)&cmd_lfc_set_set,
4650 (void *)&cmd_lfc_set_flow_ctrl,
4651 (void *)&cmd_lfc_set_high_water_str,
4652 (void *)&cmd_lfc_set_high_water,
4653 (void *)&cmd_lfc_set_portid,
4658 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4659 .f = cmd_link_flow_ctrl_set_parsed,
4660 .data = (void *)&cmd_link_flow_control_set_lw,
4661 .help_str = "Change low water flow control parameter: set flow_ctrl "
4662 "low_water value port_id",
4664 (void *)&cmd_lfc_set_set,
4665 (void *)&cmd_lfc_set_flow_ctrl,
4666 (void *)&cmd_lfc_set_low_water_str,
4667 (void *)&cmd_lfc_set_low_water,
4668 (void *)&cmd_lfc_set_portid,
4673 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4674 .f = cmd_link_flow_ctrl_set_parsed,
4675 .data = (void *)&cmd_link_flow_control_set_pt,
4676 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4677 "pause_time value port_id",
4679 (void *)&cmd_lfc_set_set,
4680 (void *)&cmd_lfc_set_flow_ctrl,
4681 (void *)&cmd_lfc_set_pause_time_str,
4682 (void *)&cmd_lfc_set_pause_time,
4683 (void *)&cmd_lfc_set_portid,
4688 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4689 .f = cmd_link_flow_ctrl_set_parsed,
4690 .data = (void *)&cmd_link_flow_control_set_xon,
4691 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4692 "send_xon value port_id",
4694 (void *)&cmd_lfc_set_set,
4695 (void *)&cmd_lfc_set_flow_ctrl,
4696 (void *)&cmd_lfc_set_send_xon_str,
4697 (void *)&cmd_lfc_set_send_xon,
4698 (void *)&cmd_lfc_set_portid,
4703 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4704 .f = cmd_link_flow_ctrl_set_parsed,
4705 .data = (void *)&cmd_link_flow_control_set_macfwd,
4706 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4707 "mac_ctrl_frame_fwd on|off port_id",
4709 (void *)&cmd_lfc_set_set,
4710 (void *)&cmd_lfc_set_flow_ctrl,
4711 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4712 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4713 (void *)&cmd_lfc_set_portid,
4718 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4719 .f = cmd_link_flow_ctrl_set_parsed,
4720 .data = (void *)&cmd_link_flow_control_set_autoneg,
4721 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4722 "autoneg on|off port_id",
4724 (void *)&cmd_lfc_set_set,
4725 (void *)&cmd_lfc_set_flow_ctrl,
4726 (void *)&cmd_lfc_set_autoneg_str,
4727 (void *)&cmd_lfc_set_autoneg,
4728 (void *)&cmd_lfc_set_portid,
4734 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4735 __attribute__((unused)) struct cmdline *cl,
4738 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4739 cmdline_parse_inst_t *cmd = data;
4740 struct rte_eth_fc_conf fc_conf;
4741 int rx_fc_en, tx_fc_en;
4745 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4746 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4747 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4748 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4750 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4751 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4754 /* Partial command line, retrieve current configuration */
4756 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4758 printf("cannot get current flow ctrl parameters, return"
4759 "code = %d\n", ret);
4763 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4764 (fc_conf.mode == RTE_FC_FULL))
4766 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4767 (fc_conf.mode == RTE_FC_FULL))
4771 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4772 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4774 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4775 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4777 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4779 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4780 fc_conf.high_water = res->high_water;
4782 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4783 fc_conf.low_water = res->low_water;
4785 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4786 fc_conf.pause_time = res->pause_time;
4788 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4789 fc_conf.send_xon = res->send_xon;
4791 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4792 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4793 fc_conf.mac_ctrl_frame_fwd = 1;
4795 fc_conf.mac_ctrl_frame_fwd = 0;
4798 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4799 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4801 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4803 printf("bad flow contrl parameter, return code = %d \n", ret);
4806 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4807 struct cmd_priority_flow_ctrl_set_result {
4808 cmdline_fixed_string_t set;
4809 cmdline_fixed_string_t pfc_ctrl;
4810 cmdline_fixed_string_t rx;
4811 cmdline_fixed_string_t rx_pfc_mode;
4812 cmdline_fixed_string_t tx;
4813 cmdline_fixed_string_t tx_pfc_mode;
4814 uint32_t high_water;
4816 uint16_t pause_time;
4822 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4823 __attribute__((unused)) struct cmdline *cl,
4824 __attribute__((unused)) void *data)
4826 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4827 struct rte_eth_pfc_conf pfc_conf;
4828 int rx_fc_enable, tx_fc_enable;
4832 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4833 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4834 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4835 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4837 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4838 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4841 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4842 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4843 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4844 pfc_conf.fc.high_water = res->high_water;
4845 pfc_conf.fc.low_water = res->low_water;
4846 pfc_conf.fc.pause_time = res->pause_time;
4847 pfc_conf.priority = res->priority;
4849 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4851 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4854 cmdline_parse_token_string_t cmd_pfc_set_set =
4855 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4857 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4858 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4859 pfc_ctrl, "pfc_ctrl");
4860 cmdline_parse_token_string_t cmd_pfc_set_rx =
4861 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4863 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4864 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4865 rx_pfc_mode, "on#off");
4866 cmdline_parse_token_string_t cmd_pfc_set_tx =
4867 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4869 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4870 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4871 tx_pfc_mode, "on#off");
4872 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4873 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4874 high_water, UINT32);
4875 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4876 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4878 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4879 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4880 pause_time, UINT16);
4881 cmdline_parse_token_num_t cmd_pfc_set_priority =
4882 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4884 cmdline_parse_token_num_t cmd_pfc_set_portid =
4885 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4888 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4889 .f = cmd_priority_flow_ctrl_set_parsed,
4891 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4892 tx on|off high_water low_water pause_time priority port_id",
4894 (void *)&cmd_pfc_set_set,
4895 (void *)&cmd_pfc_set_flow_ctrl,
4896 (void *)&cmd_pfc_set_rx,
4897 (void *)&cmd_pfc_set_rx_mode,
4898 (void *)&cmd_pfc_set_tx,
4899 (void *)&cmd_pfc_set_tx_mode,
4900 (void *)&cmd_pfc_set_high_water,
4901 (void *)&cmd_pfc_set_low_water,
4902 (void *)&cmd_pfc_set_pause_time,
4903 (void *)&cmd_pfc_set_priority,
4904 (void *)&cmd_pfc_set_portid,
4909 /* *** RESET CONFIGURATION *** */
4910 struct cmd_reset_result {
4911 cmdline_fixed_string_t reset;
4912 cmdline_fixed_string_t def;
4915 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4917 __attribute__((unused)) void *data)
4919 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4920 set_def_fwd_config();
4923 cmdline_parse_token_string_t cmd_reset_set =
4924 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4925 cmdline_parse_token_string_t cmd_reset_def =
4926 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4929 cmdline_parse_inst_t cmd_reset = {
4930 .f = cmd_reset_parsed,
4932 .help_str = "set default: reset default forwarding configuration",
4934 (void *)&cmd_reset_set,
4935 (void *)&cmd_reset_def,
4940 /* *** START FORWARDING *** */
4941 struct cmd_start_result {
4942 cmdline_fixed_string_t start;
4945 cmdline_parse_token_string_t cmd_start_start =
4946 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4948 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4949 __attribute__((unused)) struct cmdline *cl,
4950 __attribute__((unused)) void *data)
4952 start_packet_forwarding(0);
4955 cmdline_parse_inst_t cmd_start = {
4956 .f = cmd_start_parsed,
4958 .help_str = "start packet forwarding",
4960 (void *)&cmd_start_start,
4965 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4966 struct cmd_start_tx_first_result {
4967 cmdline_fixed_string_t start;
4968 cmdline_fixed_string_t tx_first;
4972 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4973 __attribute__((unused)) struct cmdline *cl,
4974 __attribute__((unused)) void *data)
4976 start_packet_forwarding(1);
4979 cmdline_parse_token_string_t cmd_start_tx_first_start =
4980 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4982 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4983 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4984 tx_first, "tx_first");
4986 cmdline_parse_inst_t cmd_start_tx_first = {
4987 .f = cmd_start_tx_first_parsed,
4989 .help_str = "start packet forwarding, after sending 1 burst of packets",
4991 (void *)&cmd_start_tx_first_start,
4992 (void *)&cmd_start_tx_first_tx_first,
4997 /* *** SET LINK UP *** */
4998 struct cmd_set_link_up_result {
4999 cmdline_fixed_string_t set;
5000 cmdline_fixed_string_t link_up;
5001 cmdline_fixed_string_t port;
5005 cmdline_parse_token_string_t cmd_set_link_up_set =
5006 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5007 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5008 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5010 cmdline_parse_token_string_t cmd_set_link_up_port =
5011 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5012 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5013 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5015 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5016 __attribute__((unused)) struct cmdline *cl,
5017 __attribute__((unused)) void *data)
5019 struct cmd_set_link_up_result *res = parsed_result;
5020 dev_set_link_up(res->port_id);
5023 cmdline_parse_inst_t cmd_set_link_up = {
5024 .f = cmd_set_link_up_parsed,
5026 .help_str = "set link-up port (port id)",
5028 (void *)&cmd_set_link_up_set,
5029 (void *)&cmd_set_link_up_link_up,
5030 (void *)&cmd_set_link_up_port,
5031 (void *)&cmd_set_link_up_port_id,
5036 /* *** SET LINK DOWN *** */
5037 struct cmd_set_link_down_result {
5038 cmdline_fixed_string_t set;
5039 cmdline_fixed_string_t link_down;
5040 cmdline_fixed_string_t port;
5044 cmdline_parse_token_string_t cmd_set_link_down_set =
5045 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5046 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5047 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5049 cmdline_parse_token_string_t cmd_set_link_down_port =
5050 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5051 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5052 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5054 static void cmd_set_link_down_parsed(
5055 __attribute__((unused)) void *parsed_result,
5056 __attribute__((unused)) struct cmdline *cl,
5057 __attribute__((unused)) void *data)
5059 struct cmd_set_link_down_result *res = parsed_result;
5060 dev_set_link_down(res->port_id);
5063 cmdline_parse_inst_t cmd_set_link_down = {
5064 .f = cmd_set_link_down_parsed,
5066 .help_str = "set link-down port (port id)",
5068 (void *)&cmd_set_link_down_set,
5069 (void *)&cmd_set_link_down_link_down,
5070 (void *)&cmd_set_link_down_port,
5071 (void *)&cmd_set_link_down_port_id,
5076 /* *** SHOW CFG *** */
5077 struct cmd_showcfg_result {
5078 cmdline_fixed_string_t show;
5079 cmdline_fixed_string_t cfg;
5080 cmdline_fixed_string_t what;
5083 static void cmd_showcfg_parsed(void *parsed_result,
5084 __attribute__((unused)) struct cmdline *cl,
5085 __attribute__((unused)) void *data)
5087 struct cmd_showcfg_result *res = parsed_result;
5088 if (!strcmp(res->what, "rxtx"))
5089 rxtx_config_display();
5090 else if (!strcmp(res->what, "cores"))
5091 fwd_lcores_config_display();
5092 else if (!strcmp(res->what, "fwd"))
5093 fwd_config_display();
5096 cmdline_parse_token_string_t cmd_showcfg_show =
5097 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5098 cmdline_parse_token_string_t cmd_showcfg_port =
5099 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5100 cmdline_parse_token_string_t cmd_showcfg_what =
5101 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5104 cmdline_parse_inst_t cmd_showcfg = {
5105 .f = cmd_showcfg_parsed,
5107 .help_str = "show config rxtx|cores|fwd",
5109 (void *)&cmd_showcfg_show,
5110 (void *)&cmd_showcfg_port,
5111 (void *)&cmd_showcfg_what,
5116 /* *** SHOW ALL PORT INFO *** */
5117 struct cmd_showportall_result {
5118 cmdline_fixed_string_t show;
5119 cmdline_fixed_string_t port;
5120 cmdline_fixed_string_t what;
5121 cmdline_fixed_string_t all;
5124 static void cmd_showportall_parsed(void *parsed_result,
5125 __attribute__((unused)) struct cmdline *cl,
5126 __attribute__((unused)) void *data)
5130 struct cmd_showportall_result *res = parsed_result;
5131 if (!strcmp(res->show, "clear")) {
5132 if (!strcmp(res->what, "stats"))
5133 for (i = 0; i < nb_ports; i++)
5135 else if (!strcmp(res->what, "xstats"))
5136 for (i = 0; i < nb_ports; i++)
5137 nic_xstats_clear(i);
5138 } else if (!strcmp(res->what, "info"))
5139 for (i = 0; i < nb_ports; i++)
5140 port_infos_display(i);
5141 else if (!strcmp(res->what, "stats"))
5142 for (i = 0; i < nb_ports; i++)
5143 nic_stats_display(i);
5144 else if (!strcmp(res->what, "xstats"))
5145 for (i = 0; i < nb_ports; i++)
5146 nic_xstats_display(i);
5147 else if (!strcmp(res->what, "fdir"))
5148 for (i = 0; i < nb_ports; i++)
5150 else if (!strcmp(res->what, "stat_qmap"))
5151 for (i = 0; i < nb_ports; i++)
5152 nic_stats_mapping_display(i);
5155 cmdline_parse_token_string_t cmd_showportall_show =
5156 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5158 cmdline_parse_token_string_t cmd_showportall_port =
5159 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5160 cmdline_parse_token_string_t cmd_showportall_what =
5161 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5162 "info#stats#xstats#fdir#stat_qmap");
5163 cmdline_parse_token_string_t cmd_showportall_all =
5164 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5165 cmdline_parse_inst_t cmd_showportall = {
5166 .f = cmd_showportall_parsed,
5168 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5170 (void *)&cmd_showportall_show,
5171 (void *)&cmd_showportall_port,
5172 (void *)&cmd_showportall_what,
5173 (void *)&cmd_showportall_all,
5178 /* *** SHOW PORT INFO *** */
5179 struct cmd_showport_result {
5180 cmdline_fixed_string_t show;
5181 cmdline_fixed_string_t port;
5182 cmdline_fixed_string_t what;
5186 static void cmd_showport_parsed(void *parsed_result,
5187 __attribute__((unused)) struct cmdline *cl,
5188 __attribute__((unused)) void *data)
5190 struct cmd_showport_result *res = parsed_result;
5191 if (!strcmp(res->show, "clear")) {
5192 if (!strcmp(res->what, "stats"))
5193 nic_stats_clear(res->portnum);
5194 else if (!strcmp(res->what, "xstats"))
5195 nic_xstats_clear(res->portnum);
5196 } else if (!strcmp(res->what, "info"))
5197 port_infos_display(res->portnum);
5198 else if (!strcmp(res->what, "stats"))
5199 nic_stats_display(res->portnum);
5200 else if (!strcmp(res->what, "xstats"))
5201 nic_xstats_display(res->portnum);
5202 else if (!strcmp(res->what, "fdir"))
5203 fdir_get_infos(res->portnum);
5204 else if (!strcmp(res->what, "stat_qmap"))
5205 nic_stats_mapping_display(res->portnum);
5208 cmdline_parse_token_string_t cmd_showport_show =
5209 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5211 cmdline_parse_token_string_t cmd_showport_port =
5212 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5213 cmdline_parse_token_string_t cmd_showport_what =
5214 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5215 "info#stats#xstats#fdir#stat_qmap");
5216 cmdline_parse_token_num_t cmd_showport_portnum =
5217 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5219 cmdline_parse_inst_t cmd_showport = {
5220 .f = cmd_showport_parsed,
5222 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5224 (void *)&cmd_showport_show,
5225 (void *)&cmd_showport_port,
5226 (void *)&cmd_showport_what,
5227 (void *)&cmd_showport_portnum,
5232 /* *** READ PORT REGISTER *** */
5233 struct cmd_read_reg_result {
5234 cmdline_fixed_string_t read;
5235 cmdline_fixed_string_t reg;
5241 cmd_read_reg_parsed(void *parsed_result,
5242 __attribute__((unused)) struct cmdline *cl,
5243 __attribute__((unused)) void *data)
5245 struct cmd_read_reg_result *res = parsed_result;
5246 port_reg_display(res->port_id, res->reg_off);
5249 cmdline_parse_token_string_t cmd_read_reg_read =
5250 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5251 cmdline_parse_token_string_t cmd_read_reg_reg =
5252 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5253 cmdline_parse_token_num_t cmd_read_reg_port_id =
5254 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5255 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5256 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5258 cmdline_parse_inst_t cmd_read_reg = {
5259 .f = cmd_read_reg_parsed,
5261 .help_str = "read reg port_id reg_off",
5263 (void *)&cmd_read_reg_read,
5264 (void *)&cmd_read_reg_reg,
5265 (void *)&cmd_read_reg_port_id,
5266 (void *)&cmd_read_reg_reg_off,
5271 /* *** READ PORT REGISTER BIT FIELD *** */
5272 struct cmd_read_reg_bit_field_result {
5273 cmdline_fixed_string_t read;
5274 cmdline_fixed_string_t regfield;
5282 cmd_read_reg_bit_field_parsed(void *parsed_result,
5283 __attribute__((unused)) struct cmdline *cl,
5284 __attribute__((unused)) void *data)
5286 struct cmd_read_reg_bit_field_result *res = parsed_result;
5287 port_reg_bit_field_display(res->port_id, res->reg_off,
5288 res->bit1_pos, res->bit2_pos);
5291 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5292 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5294 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5295 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5296 regfield, "regfield");
5297 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5298 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5300 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5301 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5303 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5304 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5306 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5307 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5310 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5311 .f = cmd_read_reg_bit_field_parsed,
5313 .help_str = "read regfield port_id reg_off bit_x bit_y "
5314 "(read register bit field between bit_x and bit_y included)",
5316 (void *)&cmd_read_reg_bit_field_read,
5317 (void *)&cmd_read_reg_bit_field_regfield,
5318 (void *)&cmd_read_reg_bit_field_port_id,
5319 (void *)&cmd_read_reg_bit_field_reg_off,
5320 (void *)&cmd_read_reg_bit_field_bit1_pos,
5321 (void *)&cmd_read_reg_bit_field_bit2_pos,
5326 /* *** READ PORT REGISTER BIT *** */
5327 struct cmd_read_reg_bit_result {
5328 cmdline_fixed_string_t read;
5329 cmdline_fixed_string_t regbit;
5336 cmd_read_reg_bit_parsed(void *parsed_result,
5337 __attribute__((unused)) struct cmdline *cl,
5338 __attribute__((unused)) void *data)
5340 struct cmd_read_reg_bit_result *res = parsed_result;
5341 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5344 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5345 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5346 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5347 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5349 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5350 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5351 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5352 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5353 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5354 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5356 cmdline_parse_inst_t cmd_read_reg_bit = {
5357 .f = cmd_read_reg_bit_parsed,
5359 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5361 (void *)&cmd_read_reg_bit_read,
5362 (void *)&cmd_read_reg_bit_regbit,
5363 (void *)&cmd_read_reg_bit_port_id,
5364 (void *)&cmd_read_reg_bit_reg_off,
5365 (void *)&cmd_read_reg_bit_bit_pos,
5370 /* *** WRITE PORT REGISTER *** */
5371 struct cmd_write_reg_result {
5372 cmdline_fixed_string_t write;
5373 cmdline_fixed_string_t reg;
5380 cmd_write_reg_parsed(void *parsed_result,
5381 __attribute__((unused)) struct cmdline *cl,
5382 __attribute__((unused)) void *data)
5384 struct cmd_write_reg_result *res = parsed_result;
5385 port_reg_set(res->port_id, res->reg_off, res->value);
5388 cmdline_parse_token_string_t cmd_write_reg_write =
5389 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5390 cmdline_parse_token_string_t cmd_write_reg_reg =
5391 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5392 cmdline_parse_token_num_t cmd_write_reg_port_id =
5393 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5394 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5395 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5396 cmdline_parse_token_num_t cmd_write_reg_value =
5397 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5399 cmdline_parse_inst_t cmd_write_reg = {
5400 .f = cmd_write_reg_parsed,
5402 .help_str = "write reg port_id reg_off reg_value",
5404 (void *)&cmd_write_reg_write,
5405 (void *)&cmd_write_reg_reg,
5406 (void *)&cmd_write_reg_port_id,
5407 (void *)&cmd_write_reg_reg_off,
5408 (void *)&cmd_write_reg_value,
5413 /* *** WRITE PORT REGISTER BIT FIELD *** */
5414 struct cmd_write_reg_bit_field_result {
5415 cmdline_fixed_string_t write;
5416 cmdline_fixed_string_t regfield;
5425 cmd_write_reg_bit_field_parsed(void *parsed_result,
5426 __attribute__((unused)) struct cmdline *cl,
5427 __attribute__((unused)) void *data)
5429 struct cmd_write_reg_bit_field_result *res = parsed_result;
5430 port_reg_bit_field_set(res->port_id, res->reg_off,
5431 res->bit1_pos, res->bit2_pos, res->value);
5434 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5435 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5437 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5438 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5439 regfield, "regfield");
5440 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5441 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5443 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5444 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5446 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5447 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5449 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5450 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5452 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5453 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5456 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5457 .f = cmd_write_reg_bit_field_parsed,
5459 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5460 "(set register bit field between bit_x and bit_y included)",
5462 (void *)&cmd_write_reg_bit_field_write,
5463 (void *)&cmd_write_reg_bit_field_regfield,
5464 (void *)&cmd_write_reg_bit_field_port_id,
5465 (void *)&cmd_write_reg_bit_field_reg_off,
5466 (void *)&cmd_write_reg_bit_field_bit1_pos,
5467 (void *)&cmd_write_reg_bit_field_bit2_pos,
5468 (void *)&cmd_write_reg_bit_field_value,
5473 /* *** WRITE PORT REGISTER BIT *** */
5474 struct cmd_write_reg_bit_result {
5475 cmdline_fixed_string_t write;
5476 cmdline_fixed_string_t regbit;
5484 cmd_write_reg_bit_parsed(void *parsed_result,
5485 __attribute__((unused)) struct cmdline *cl,
5486 __attribute__((unused)) void *data)
5488 struct cmd_write_reg_bit_result *res = parsed_result;
5489 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5492 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5493 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5495 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5496 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5498 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5499 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5500 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5501 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5502 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5503 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5504 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5505 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5507 cmdline_parse_inst_t cmd_write_reg_bit = {
5508 .f = cmd_write_reg_bit_parsed,
5510 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5512 (void *)&cmd_write_reg_bit_write,
5513 (void *)&cmd_write_reg_bit_regbit,
5514 (void *)&cmd_write_reg_bit_port_id,
5515 (void *)&cmd_write_reg_bit_reg_off,
5516 (void *)&cmd_write_reg_bit_bit_pos,
5517 (void *)&cmd_write_reg_bit_value,
5522 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5523 struct cmd_read_rxd_txd_result {
5524 cmdline_fixed_string_t read;
5525 cmdline_fixed_string_t rxd_txd;
5532 cmd_read_rxd_txd_parsed(void *parsed_result,
5533 __attribute__((unused)) struct cmdline *cl,
5534 __attribute__((unused)) void *data)
5536 struct cmd_read_rxd_txd_result *res = parsed_result;
5538 if (!strcmp(res->rxd_txd, "rxd"))
5539 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5540 else if (!strcmp(res->rxd_txd, "txd"))
5541 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5544 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5545 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5546 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5547 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5549 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5550 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5551 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5552 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5553 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5554 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5556 cmdline_parse_inst_t cmd_read_rxd_txd = {
5557 .f = cmd_read_rxd_txd_parsed,
5559 .help_str = "read rxd|txd port_id queue_id rxd_id",
5561 (void *)&cmd_read_rxd_txd_read,
5562 (void *)&cmd_read_rxd_txd_rxd_txd,
5563 (void *)&cmd_read_rxd_txd_port_id,
5564 (void *)&cmd_read_rxd_txd_queue_id,
5565 (void *)&cmd_read_rxd_txd_desc_id,
5571 struct cmd_quit_result {
5572 cmdline_fixed_string_t quit;
5575 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5577 __attribute__((unused)) void *data)
5583 cmdline_parse_token_string_t cmd_quit_quit =
5584 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5586 cmdline_parse_inst_t cmd_quit = {
5587 .f = cmd_quit_parsed,
5589 .help_str = "exit application",
5591 (void *)&cmd_quit_quit,
5596 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5597 struct cmd_mac_addr_result {
5598 cmdline_fixed_string_t mac_addr_cmd;
5599 cmdline_fixed_string_t what;
5601 struct ether_addr address;
5604 static void cmd_mac_addr_parsed(void *parsed_result,
5605 __attribute__((unused)) struct cmdline *cl,
5606 __attribute__((unused)) void *data)
5608 struct cmd_mac_addr_result *res = parsed_result;
5611 if (strcmp(res->what, "add") == 0)
5612 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5614 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5616 /* check the return value and print it if is < 0 */
5618 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5622 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5623 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5625 cmdline_parse_token_string_t cmd_mac_addr_what =
5626 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5628 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5629 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5630 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5631 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5633 cmdline_parse_inst_t cmd_mac_addr = {
5634 .f = cmd_mac_addr_parsed,
5636 .help_str = "mac_addr add|remove X <address>: "
5637 "add/remove MAC address on port X",
5639 (void *)&cmd_mac_addr_cmd,
5640 (void *)&cmd_mac_addr_what,
5641 (void *)&cmd_mac_addr_portnum,
5642 (void *)&cmd_mac_addr_addr,
5648 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5649 struct cmd_set_qmap_result {
5650 cmdline_fixed_string_t set;
5651 cmdline_fixed_string_t qmap;
5652 cmdline_fixed_string_t what;
5659 cmd_set_qmap_parsed(void *parsed_result,
5660 __attribute__((unused)) struct cmdline *cl,
5661 __attribute__((unused)) void *data)
5663 struct cmd_set_qmap_result *res = parsed_result;
5664 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5666 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5669 cmdline_parse_token_string_t cmd_setqmap_set =
5670 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5672 cmdline_parse_token_string_t cmd_setqmap_qmap =
5673 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5675 cmdline_parse_token_string_t cmd_setqmap_what =
5676 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5678 cmdline_parse_token_num_t cmd_setqmap_portid =
5679 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5681 cmdline_parse_token_num_t cmd_setqmap_queueid =
5682 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5684 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5685 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5688 cmdline_parse_inst_t cmd_set_qmap = {
5689 .f = cmd_set_qmap_parsed,
5691 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5693 (void *)&cmd_setqmap_set,
5694 (void *)&cmd_setqmap_qmap,
5695 (void *)&cmd_setqmap_what,
5696 (void *)&cmd_setqmap_portid,
5697 (void *)&cmd_setqmap_queueid,
5698 (void *)&cmd_setqmap_mapvalue,
5703 /* *** CONFIGURE UNICAST HASH TABLE *** */
5704 struct cmd_set_uc_hash_table {
5705 cmdline_fixed_string_t set;
5706 cmdline_fixed_string_t port;
5708 cmdline_fixed_string_t what;
5709 struct ether_addr address;
5710 cmdline_fixed_string_t mode;
5714 cmd_set_uc_hash_parsed(void *parsed_result,
5715 __attribute__((unused)) struct cmdline *cl,
5716 __attribute__((unused)) void *data)
5719 struct cmd_set_uc_hash_table *res = parsed_result;
5721 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5723 if (strcmp(res->what, "uta") == 0)
5724 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5725 &res->address,(uint8_t)is_on);
5727 printf("bad unicast hash table parameter, return code = %d \n", ret);
5731 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5732 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5734 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5735 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5737 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5738 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5740 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5741 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5743 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5744 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5746 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5750 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5751 .f = cmd_set_uc_hash_parsed,
5753 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5755 (void *)&cmd_set_uc_hash_set,
5756 (void *)&cmd_set_uc_hash_port,
5757 (void *)&cmd_set_uc_hash_portid,
5758 (void *)&cmd_set_uc_hash_what,
5759 (void *)&cmd_set_uc_hash_mac,
5760 (void *)&cmd_set_uc_hash_mode,
5765 struct cmd_set_uc_all_hash_table {
5766 cmdline_fixed_string_t set;
5767 cmdline_fixed_string_t port;
5769 cmdline_fixed_string_t what;
5770 cmdline_fixed_string_t value;
5771 cmdline_fixed_string_t mode;
5775 cmd_set_uc_all_hash_parsed(void *parsed_result,
5776 __attribute__((unused)) struct cmdline *cl,
5777 __attribute__((unused)) void *data)
5780 struct cmd_set_uc_all_hash_table *res = parsed_result;
5782 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5784 if ((strcmp(res->what, "uta") == 0) &&
5785 (strcmp(res->value, "all") == 0))
5786 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5788 printf("bad unicast hash table parameter,"
5789 "return code = %d \n", ret);
5792 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5793 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5795 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5796 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5798 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5799 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5801 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5802 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5804 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5805 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5807 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5808 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5811 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5812 .f = cmd_set_uc_all_hash_parsed,
5814 .help_str = "set port X uta all on|off (X = port number)",
5816 (void *)&cmd_set_uc_all_hash_set,
5817 (void *)&cmd_set_uc_all_hash_port,
5818 (void *)&cmd_set_uc_all_hash_portid,
5819 (void *)&cmd_set_uc_all_hash_what,
5820 (void *)&cmd_set_uc_all_hash_value,
5821 (void *)&cmd_set_uc_all_hash_mode,
5826 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5827 struct cmd_set_vf_traffic {
5828 cmdline_fixed_string_t set;
5829 cmdline_fixed_string_t port;
5831 cmdline_fixed_string_t vf;
5833 cmdline_fixed_string_t what;
5834 cmdline_fixed_string_t mode;
5838 cmd_set_vf_traffic_parsed(void *parsed_result,
5839 __attribute__((unused)) struct cmdline *cl,
5840 __attribute__((unused)) void *data)
5842 struct cmd_set_vf_traffic *res = parsed_result;
5843 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5844 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5846 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5849 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5852 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5855 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5856 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5858 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5859 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5861 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5862 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5864 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5865 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5867 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5868 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5871 cmdline_parse_inst_t cmd_set_vf_traffic = {
5872 .f = cmd_set_vf_traffic_parsed,
5874 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
5876 (void *)&cmd_setvf_traffic_set,
5877 (void *)&cmd_setvf_traffic_port,
5878 (void *)&cmd_setvf_traffic_portid,
5879 (void *)&cmd_setvf_traffic_vf,
5880 (void *)&cmd_setvf_traffic_vfid,
5881 (void *)&cmd_setvf_traffic_what,
5882 (void *)&cmd_setvf_traffic_mode,
5887 /* *** CONFIGURE VF RECEIVE MODE *** */
5888 struct cmd_set_vf_rxmode {
5889 cmdline_fixed_string_t set;
5890 cmdline_fixed_string_t port;
5892 cmdline_fixed_string_t vf;
5894 cmdline_fixed_string_t what;
5895 cmdline_fixed_string_t mode;
5896 cmdline_fixed_string_t on;
5900 cmd_set_vf_rxmode_parsed(void *parsed_result,
5901 __attribute__((unused)) struct cmdline *cl,
5902 __attribute__((unused)) void *data)
5905 uint16_t rx_mode = 0;
5906 struct cmd_set_vf_rxmode *res = parsed_result;
5908 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5909 if (!strcmp(res->what,"rxmode")) {
5910 if (!strcmp(res->mode, "AUPE"))
5911 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5912 else if (!strcmp(res->mode, "ROPE"))
5913 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5914 else if (!strcmp(res->mode, "BAM"))
5915 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5916 else if (!strncmp(res->mode, "MPE",3))
5917 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5920 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5922 printf("bad VF receive mode parameter, return code = %d \n",
5926 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5929 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5930 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5932 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5933 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5935 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5936 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5938 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5939 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5941 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5942 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5944 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5945 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5946 mode, "AUPE#ROPE#BAM#MPE");
5947 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5948 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5951 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5952 .f = cmd_set_vf_rxmode_parsed,
5954 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5956 (void *)&cmd_set_vf_rxmode_set,
5957 (void *)&cmd_set_vf_rxmode_port,
5958 (void *)&cmd_set_vf_rxmode_portid,
5959 (void *)&cmd_set_vf_rxmode_vf,
5960 (void *)&cmd_set_vf_rxmode_vfid,
5961 (void *)&cmd_set_vf_rxmode_what,
5962 (void *)&cmd_set_vf_rxmode_mode,
5963 (void *)&cmd_set_vf_rxmode_on,
5968 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5969 struct cmd_vf_mac_addr_result {
5970 cmdline_fixed_string_t mac_addr_cmd;
5971 cmdline_fixed_string_t what;
5972 cmdline_fixed_string_t port;
5974 cmdline_fixed_string_t vf;
5976 struct ether_addr address;
5979 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5980 __attribute__((unused)) struct cmdline *cl,
5981 __attribute__((unused)) void *data)
5983 struct cmd_vf_mac_addr_result *res = parsed_result;
5986 if (strcmp(res->what, "add") == 0)
5987 ret = rte_eth_dev_mac_addr_add(res->port_num,
5988 &res->address, res->vf_num);
5990 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5994 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5995 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5996 mac_addr_cmd,"mac_addr");
5997 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5998 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6000 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6001 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6003 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6004 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6006 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6007 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6009 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6010 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6012 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6013 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6016 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6017 .f = cmd_vf_mac_addr_parsed,
6019 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6020 "Y = VF number)add MAC address filtering for a VF on port X",
6022 (void *)&cmd_vf_mac_addr_cmd,
6023 (void *)&cmd_vf_mac_addr_what,
6024 (void *)&cmd_vf_mac_addr_port,
6025 (void *)&cmd_vf_mac_addr_portnum,
6026 (void *)&cmd_vf_mac_addr_vf,
6027 (void *)&cmd_vf_mac_addr_vfnum,
6028 (void *)&cmd_vf_mac_addr_addr,
6033 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6034 struct cmd_vf_rx_vlan_filter {
6035 cmdline_fixed_string_t rx_vlan;
6036 cmdline_fixed_string_t what;
6038 cmdline_fixed_string_t port;
6040 cmdline_fixed_string_t vf;
6045 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6046 __attribute__((unused)) struct cmdline *cl,
6047 __attribute__((unused)) void *data)
6049 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6051 if (!strcmp(res->what, "add"))
6052 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6054 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6057 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6058 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6059 rx_vlan, "rx_vlan");
6060 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6061 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6063 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6064 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6066 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6067 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6069 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6070 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6072 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6073 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6075 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6076 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6079 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6080 .f = cmd_vf_rx_vlan_filter_parsed,
6082 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6083 "Y = port number,Z = hexadecimal VF mask)",
6085 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6086 (void *)&cmd_vf_rx_vlan_filter_what,
6087 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6088 (void *)&cmd_vf_rx_vlan_filter_port,
6089 (void *)&cmd_vf_rx_vlan_filter_portid,
6090 (void *)&cmd_vf_rx_vlan_filter_vf,
6091 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6096 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6097 struct cmd_queue_rate_limit_result {
6098 cmdline_fixed_string_t set;
6099 cmdline_fixed_string_t port;
6101 cmdline_fixed_string_t queue;
6103 cmdline_fixed_string_t rate;
6107 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6108 __attribute__((unused)) struct cmdline *cl,
6109 __attribute__((unused)) void *data)
6111 struct cmd_queue_rate_limit_result *res = parsed_result;
6114 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6115 && (strcmp(res->queue, "queue") == 0)
6116 && (strcmp(res->rate, "rate") == 0))
6117 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6120 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6124 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6125 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6127 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6128 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6130 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6131 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6133 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6134 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6136 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6137 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6139 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6140 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6142 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6143 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6146 cmdline_parse_inst_t cmd_queue_rate_limit = {
6147 .f = cmd_queue_rate_limit_parsed,
6149 .help_str = "set port X queue Y rate Z:(X = port number,"
6150 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6152 (void *)&cmd_queue_rate_limit_set,
6153 (void *)&cmd_queue_rate_limit_port,
6154 (void *)&cmd_queue_rate_limit_portnum,
6155 (void *)&cmd_queue_rate_limit_queue,
6156 (void *)&cmd_queue_rate_limit_queuenum,
6157 (void *)&cmd_queue_rate_limit_rate,
6158 (void *)&cmd_queue_rate_limit_ratenum,
6163 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6164 struct cmd_vf_rate_limit_result {
6165 cmdline_fixed_string_t set;
6166 cmdline_fixed_string_t port;
6168 cmdline_fixed_string_t vf;
6170 cmdline_fixed_string_t rate;
6172 cmdline_fixed_string_t q_msk;
6176 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6177 __attribute__((unused)) struct cmdline *cl,
6178 __attribute__((unused)) void *data)
6180 struct cmd_vf_rate_limit_result *res = parsed_result;
6183 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6184 && (strcmp(res->vf, "vf") == 0)
6185 && (strcmp(res->rate, "rate") == 0)
6186 && (strcmp(res->q_msk, "queue_mask") == 0))
6187 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6188 res->rate_num, res->q_msk_val);
6190 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6194 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6195 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6197 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6198 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6200 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6201 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6203 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6204 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6206 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6207 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6209 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6210 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6212 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6213 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6215 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6216 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6217 q_msk, "queue_mask");
6218 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6219 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6222 cmdline_parse_inst_t cmd_vf_rate_limit = {
6223 .f = cmd_vf_rate_limit_parsed,
6225 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6226 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6227 "for queues of VF on port X",
6229 (void *)&cmd_vf_rate_limit_set,
6230 (void *)&cmd_vf_rate_limit_port,
6231 (void *)&cmd_vf_rate_limit_portnum,
6232 (void *)&cmd_vf_rate_limit_vf,
6233 (void *)&cmd_vf_rate_limit_vfnum,
6234 (void *)&cmd_vf_rate_limit_rate,
6235 (void *)&cmd_vf_rate_limit_ratenum,
6236 (void *)&cmd_vf_rate_limit_q_msk,
6237 (void *)&cmd_vf_rate_limit_q_msk_val,
6242 /* *** ADD TUNNEL FILTER OF A PORT *** */
6243 struct cmd_tunnel_filter_result {
6244 cmdline_fixed_string_t cmd;
6245 cmdline_fixed_string_t what;
6247 struct ether_addr outer_mac;
6248 struct ether_addr inner_mac;
6249 cmdline_ipaddr_t ip_value;
6250 uint16_t inner_vlan;
6251 cmdline_fixed_string_t tunnel_type;
6252 cmdline_fixed_string_t filter_type;
6258 cmd_tunnel_filter_parsed(void *parsed_result,
6259 __attribute__((unused)) struct cmdline *cl,
6260 __attribute__((unused)) void *data)
6262 struct cmd_tunnel_filter_result *res = parsed_result;
6263 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6266 tunnel_filter_conf.outer_mac = &res->outer_mac;
6267 tunnel_filter_conf.inner_mac = &res->inner_mac;
6268 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6270 if (res->ip_value.family == AF_INET) {
6271 tunnel_filter_conf.ip_addr.ipv4_addr =
6272 res->ip_value.addr.ipv4.s_addr;
6273 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6275 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6276 &(res->ip_value.addr.ipv6),
6277 sizeof(struct in6_addr));
6278 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6281 if (!strcmp(res->filter_type, "imac-ivlan"))
6282 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6283 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6284 tunnel_filter_conf.filter_type =
6285 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6286 else if (!strcmp(res->filter_type, "imac-tenid"))
6287 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6288 else if (!strcmp(res->filter_type, "imac"))
6289 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6290 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6291 tunnel_filter_conf.filter_type =
6292 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6294 printf("The filter type is not supported");
6298 if (!strcmp(res->tunnel_type, "vxlan"))
6299 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6301 printf("Only VxLAN is supported now.\n");
6305 tunnel_filter_conf.tenant_id = res->tenant_id;
6306 tunnel_filter_conf.queue_id = res->queue_num;
6307 if (!strcmp(res->what, "add"))
6308 ret = rte_eth_dev_filter_ctrl(res->port_id,
6309 RTE_ETH_FILTER_TUNNEL,
6311 &tunnel_filter_conf);
6313 ret = rte_eth_dev_filter_ctrl(res->port_id,
6314 RTE_ETH_FILTER_TUNNEL,
6315 RTE_ETH_FILTER_DELETE,
6316 &tunnel_filter_conf);
6318 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6322 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6323 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6324 cmd, "tunnel_filter");
6325 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6326 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6328 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6329 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6331 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6332 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6334 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6335 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6337 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6338 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6339 inner_vlan, UINT16);
6340 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6341 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6343 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6344 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6345 tunnel_type, "vxlan");
6347 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6348 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6349 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6350 "imac#omac-imac-tenid");
6351 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6352 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6354 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6355 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6358 cmdline_parse_inst_t cmd_tunnel_filter = {
6359 .f = cmd_tunnel_filter_parsed,
6361 .help_str = "add/rm tunnel filter of a port: "
6362 "tunnel_filter add port_id outer_mac inner_mac ip "
6363 "inner_vlan tunnel_type(vxlan) filter_type "
6364 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6365 "imac|omac-imac-tenid) "
6366 "tenant_id queue_num",
6368 (void *)&cmd_tunnel_filter_cmd,
6369 (void *)&cmd_tunnel_filter_what,
6370 (void *)&cmd_tunnel_filter_port_id,
6371 (void *)&cmd_tunnel_filter_outer_mac,
6372 (void *)&cmd_tunnel_filter_inner_mac,
6373 (void *)&cmd_tunnel_filter_ip_value,
6374 (void *)&cmd_tunnel_filter_innner_vlan,
6375 (void *)&cmd_tunnel_filter_tunnel_type,
6376 (void *)&cmd_tunnel_filter_filter_type,
6377 (void *)&cmd_tunnel_filter_tenant_id,
6378 (void *)&cmd_tunnel_filter_queue_num,
6383 /* *** CONFIGURE TUNNEL UDP PORT *** */
6384 struct cmd_tunnel_udp_config {
6385 cmdline_fixed_string_t cmd;
6386 cmdline_fixed_string_t what;
6392 cmd_tunnel_udp_config_parsed(void *parsed_result,
6393 __attribute__((unused)) struct cmdline *cl,
6394 __attribute__((unused)) void *data)
6396 struct cmd_tunnel_udp_config *res = parsed_result;
6397 struct rte_eth_udp_tunnel tunnel_udp;
6400 tunnel_udp.udp_port = res->udp_port;
6402 if (!strcmp(res->cmd, "rx_vxlan_port"))
6403 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6405 if (!strcmp(res->what, "add"))
6406 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6408 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6411 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6414 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6415 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6416 cmd, "rx_vxlan_port");
6417 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6418 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6420 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6421 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6423 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6424 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6427 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6428 .f = cmd_tunnel_udp_config_parsed,
6430 .help_str = "add/rm an tunneling UDP port filter: "
6431 "rx_vxlan_port add udp_port port_id",
6433 (void *)&cmd_tunnel_udp_config_cmd,
6434 (void *)&cmd_tunnel_udp_config_what,
6435 (void *)&cmd_tunnel_udp_config_udp_port,
6436 (void *)&cmd_tunnel_udp_config_port_id,
6441 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6442 struct cmd_set_mirror_mask_result {
6443 cmdline_fixed_string_t set;
6444 cmdline_fixed_string_t port;
6446 cmdline_fixed_string_t mirror;
6448 cmdline_fixed_string_t what;
6449 cmdline_fixed_string_t value;
6450 cmdline_fixed_string_t dstpool;
6452 cmdline_fixed_string_t on;
6455 cmdline_parse_token_string_t cmd_mirror_mask_set =
6456 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6458 cmdline_parse_token_string_t cmd_mirror_mask_port =
6459 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6461 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6462 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6464 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6465 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6466 mirror, "mirror-rule");
6467 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6468 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6470 cmdline_parse_token_string_t cmd_mirror_mask_what =
6471 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6472 what, "pool-mirror#vlan-mirror");
6473 cmdline_parse_token_string_t cmd_mirror_mask_value =
6474 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6476 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6478 dstpool, "dst-pool");
6479 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6480 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6482 cmdline_parse_token_string_t cmd_mirror_mask_on =
6483 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6487 cmd_set_mirror_mask_parsed(void *parsed_result,
6488 __attribute__((unused)) struct cmdline *cl,
6489 __attribute__((unused)) void *data)
6492 struct cmd_set_mirror_mask_result *res = parsed_result;
6493 struct rte_eth_vmdq_mirror_conf mr_conf;
6495 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6497 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6499 mr_conf.dst_pool = res->dstpool_id;
6501 if (!strcmp(res->what, "pool-mirror")) {
6502 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6503 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6504 } else if(!strcmp(res->what, "vlan-mirror")) {
6505 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6506 nb_item = parse_item_list(res->value, "core",
6507 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6511 for(i=0; i < nb_item; i++) {
6512 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6513 printf("Invalid vlan_id: must be < 4096\n");
6517 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6518 mr_conf.vlan.vlan_mask |= 1ULL << i;
6522 if(!strcmp(res->on, "on"))
6523 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6526 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6529 printf("mirror rule add error: (%s)\n", strerror(-ret));
6532 cmdline_parse_inst_t cmd_set_mirror_mask = {
6533 .f = cmd_set_mirror_mask_parsed,
6535 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6536 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6538 (void *)&cmd_mirror_mask_set,
6539 (void *)&cmd_mirror_mask_port,
6540 (void *)&cmd_mirror_mask_portid,
6541 (void *)&cmd_mirror_mask_mirror,
6542 (void *)&cmd_mirror_mask_ruleid,
6543 (void *)&cmd_mirror_mask_what,
6544 (void *)&cmd_mirror_mask_value,
6545 (void *)&cmd_mirror_mask_dstpool,
6546 (void *)&cmd_mirror_mask_poolid,
6547 (void *)&cmd_mirror_mask_on,
6552 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6553 struct cmd_set_mirror_link_result {
6554 cmdline_fixed_string_t set;
6555 cmdline_fixed_string_t port;
6557 cmdline_fixed_string_t mirror;
6559 cmdline_fixed_string_t what;
6560 cmdline_fixed_string_t dstpool;
6562 cmdline_fixed_string_t on;
6565 cmdline_parse_token_string_t cmd_mirror_link_set =
6566 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6568 cmdline_parse_token_string_t cmd_mirror_link_port =
6569 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6571 cmdline_parse_token_num_t cmd_mirror_link_portid =
6572 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6574 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6575 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6576 mirror, "mirror-rule");
6577 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6578 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6580 cmdline_parse_token_string_t cmd_mirror_link_what =
6581 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6582 what, "uplink-mirror#downlink-mirror");
6583 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6584 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6585 dstpool, "dst-pool");
6586 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6587 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6589 cmdline_parse_token_string_t cmd_mirror_link_on =
6590 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6594 cmd_set_mirror_link_parsed(void *parsed_result,
6595 __attribute__((unused)) struct cmdline *cl,
6596 __attribute__((unused)) void *data)
6599 struct cmd_set_mirror_link_result *res = parsed_result;
6600 struct rte_eth_vmdq_mirror_conf mr_conf;
6602 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6603 if(!strcmp(res->what, "uplink-mirror")) {
6604 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6605 }else if(!strcmp(res->what, "downlink-mirror"))
6606 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6608 mr_conf.dst_pool = res->dstpool_id;
6610 if(!strcmp(res->on, "on"))
6611 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6614 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6617 /* check the return value and print it if is < 0 */
6619 printf("mirror rule add error: (%s)\n", strerror(-ret));
6623 cmdline_parse_inst_t cmd_set_mirror_link = {
6624 .f = cmd_set_mirror_link_parsed,
6626 .help_str = "set port X mirror-rule Y uplink-mirror|"
6627 "downlink-mirror dst-pool Z on|off",
6629 (void *)&cmd_mirror_link_set,
6630 (void *)&cmd_mirror_link_port,
6631 (void *)&cmd_mirror_link_portid,
6632 (void *)&cmd_mirror_link_mirror,
6633 (void *)&cmd_mirror_link_ruleid,
6634 (void *)&cmd_mirror_link_what,
6635 (void *)&cmd_mirror_link_dstpool,
6636 (void *)&cmd_mirror_link_poolid,
6637 (void *)&cmd_mirror_link_on,
6642 /* *** RESET VM MIRROR RULE *** */
6643 struct cmd_rm_mirror_rule_result {
6644 cmdline_fixed_string_t reset;
6645 cmdline_fixed_string_t port;
6647 cmdline_fixed_string_t mirror;
6651 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6652 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6654 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6655 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6657 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6658 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6660 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6661 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6662 mirror, "mirror-rule");
6663 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6664 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6668 cmd_reset_mirror_rule_parsed(void *parsed_result,
6669 __attribute__((unused)) struct cmdline *cl,
6670 __attribute__((unused)) void *data)
6673 struct cmd_set_mirror_link_result *res = parsed_result;
6675 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6677 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6680 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6681 .f = cmd_reset_mirror_rule_parsed,
6683 .help_str = "reset port X mirror-rule Y",
6685 (void *)&cmd_rm_mirror_rule_reset,
6686 (void *)&cmd_rm_mirror_rule_port,
6687 (void *)&cmd_rm_mirror_rule_portid,
6688 (void *)&cmd_rm_mirror_rule_mirror,
6689 (void *)&cmd_rm_mirror_rule_ruleid,
6694 /* ******************************************************************************** */
6696 struct cmd_dump_result {
6697 cmdline_fixed_string_t dump;
6701 dump_struct_sizes(void)
6703 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6704 DUMP_SIZE(struct rte_mbuf);
6705 DUMP_SIZE(struct rte_mempool);
6706 DUMP_SIZE(struct rte_ring);
6710 static void cmd_dump_parsed(void *parsed_result,
6711 __attribute__((unused)) struct cmdline *cl,
6712 __attribute__((unused)) void *data)
6714 struct cmd_dump_result *res = parsed_result;
6716 if (!strcmp(res->dump, "dump_physmem"))
6717 rte_dump_physmem_layout(stdout);
6718 else if (!strcmp(res->dump, "dump_memzone"))
6719 rte_memzone_dump(stdout);
6720 else if (!strcmp(res->dump, "dump_log_history"))
6721 rte_log_dump_history(stdout);
6722 else if (!strcmp(res->dump, "dump_struct_sizes"))
6723 dump_struct_sizes();
6724 else if (!strcmp(res->dump, "dump_ring"))
6725 rte_ring_list_dump(stdout);
6726 else if (!strcmp(res->dump, "dump_mempool"))
6727 rte_mempool_list_dump(stdout);
6728 else if (!strcmp(res->dump, "dump_devargs"))
6729 rte_eal_devargs_dump(stdout);
6732 cmdline_parse_token_string_t cmd_dump_dump =
6733 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6737 "dump_struct_sizes#"
6742 cmdline_parse_inst_t cmd_dump = {
6743 .f = cmd_dump_parsed, /* function to call */
6744 .data = NULL, /* 2nd arg of func */
6745 .help_str = "dump status",
6746 .tokens = { /* token list, NULL terminated */
6747 (void *)&cmd_dump_dump,
6752 /* ******************************************************************************** */
6754 struct cmd_dump_one_result {
6755 cmdline_fixed_string_t dump;
6756 cmdline_fixed_string_t name;
6759 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6760 __attribute__((unused)) void *data)
6762 struct cmd_dump_one_result *res = parsed_result;
6764 if (!strcmp(res->dump, "dump_ring")) {
6766 r = rte_ring_lookup(res->name);
6768 cmdline_printf(cl, "Cannot find ring\n");
6771 rte_ring_dump(stdout, r);
6772 } else if (!strcmp(res->dump, "dump_mempool")) {
6773 struct rte_mempool *mp;
6774 mp = rte_mempool_lookup(res->name);
6776 cmdline_printf(cl, "Cannot find mempool\n");
6779 rte_mempool_dump(stdout, mp);
6783 cmdline_parse_token_string_t cmd_dump_one_dump =
6784 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6785 "dump_ring#dump_mempool");
6787 cmdline_parse_token_string_t cmd_dump_one_name =
6788 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6790 cmdline_parse_inst_t cmd_dump_one = {
6791 .f = cmd_dump_one_parsed, /* function to call */
6792 .data = NULL, /* 2nd arg of func */
6793 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6794 .tokens = { /* token list, NULL terminated */
6795 (void *)&cmd_dump_one_dump,
6796 (void *)&cmd_dump_one_name,
6801 /* *** ADD/REMOVE an ethertype FILTER *** */
6802 struct cmd_ethertype_filter_result {
6803 cmdline_fixed_string_t filter;
6805 cmdline_fixed_string_t ethertype;
6806 uint16_t ethertype_value;
6807 cmdline_fixed_string_t priority;
6808 cmdline_fixed_string_t priority_en;
6809 uint8_t priority_value;
6810 cmdline_fixed_string_t queue;
6812 cmdline_fixed_string_t index;
6813 uint16_t index_value;
6817 cmd_ethertype_filter_parsed(void *parsed_result,
6818 __attribute__((unused)) struct cmdline *cl,
6819 __attribute__((unused)) void *data)
6822 struct cmd_ethertype_filter_result *res = parsed_result;
6823 struct rte_ethertype_filter filter;
6825 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
6826 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
6827 filter.priority = res->priority_value;
6829 if (!strcmp(res->priority_en, "enable"))
6830 filter.priority_en = 1;
6831 if (!strcmp(res->filter, "add_ethertype_filter"))
6832 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
6834 &filter, res->queue_id);
6835 else if (!strcmp(res->filter, "remove_ethertype_filter"))
6836 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
6838 else if (!strcmp(res->filter, "get_ethertype_filter"))
6839 get_ethertype_filter(res->port_id, res->index_value);
6842 printf("ethertype filter setting error: (%s)\n",
6846 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
6847 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6849 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
6850 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6851 ethertype, "ethertype");
6852 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
6853 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6854 ethertype_value, UINT16);
6855 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
6856 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6857 priority, "priority");
6858 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
6859 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6860 priority_en, "enable#disable");
6861 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
6862 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6863 priority_value, UINT8);
6864 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
6865 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6867 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
6868 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6870 cmdline_parse_token_string_t cmd_ethertype_filter_index =
6871 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6873 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
6874 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6875 index_value, UINT16);
6876 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
6877 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6878 filter, "add_ethertype_filter");
6879 cmdline_parse_inst_t cmd_add_ethertype_filter = {
6880 .f = cmd_ethertype_filter_parsed,
6882 .help_str = "add an ethertype filter",
6884 (void *)&cmd_ethertype_filter_add_filter,
6885 (void *)&cmd_ethertype_filter_port_id,
6886 (void *)&cmd_ethertype_filter_ethertype,
6887 (void *)&cmd_ethertype_filter_ethertype_value,
6888 (void *)&cmd_ethertype_filter_priority,
6889 (void *)&cmd_ethertype_filter_priority_en,
6890 (void *)&cmd_ethertype_filter_priority_value,
6891 (void *)&cmd_ethertype_filter_queue,
6892 (void *)&cmd_ethertype_filter_queue_id,
6893 (void *)&cmd_ethertype_filter_index,
6894 (void *)&cmd_ethertype_filter_index_value,
6899 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
6900 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6901 filter, "remove_ethertype_filter");
6902 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
6903 .f = cmd_ethertype_filter_parsed,
6905 .help_str = "remove an ethertype filter",
6907 (void *)&cmd_ethertype_filter_remove_filter,
6908 (void *)&cmd_ethertype_filter_port_id,
6909 (void *)&cmd_ethertype_filter_index,
6910 (void *)&cmd_ethertype_filter_index_value,
6914 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
6915 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6916 filter, "get_ethertype_filter");
6917 cmdline_parse_inst_t cmd_get_ethertype_filter = {
6918 .f = cmd_ethertype_filter_parsed,
6920 .help_str = "get an ethertype filter",
6922 (void *)&cmd_ethertype_filter_get_filter,
6923 (void *)&cmd_ethertype_filter_port_id,
6924 (void *)&cmd_ethertype_filter_index,
6925 (void *)&cmd_ethertype_filter_index_value,
6930 /* *** set SYN filter *** */
6931 struct cmd_set_syn_filter_result {
6932 cmdline_fixed_string_t filter;
6934 cmdline_fixed_string_t priority;
6935 cmdline_fixed_string_t high;
6936 cmdline_fixed_string_t queue;
6941 cmd_set_syn_filter_parsed(void *parsed_result,
6942 __attribute__((unused)) struct cmdline *cl,
6943 __attribute__((unused)) void *data)
6946 struct cmd_set_syn_filter_result *res = parsed_result;
6947 struct rte_syn_filter filter;
6949 if (!strcmp(res->filter, "add_syn_filter")) {
6950 if (!strcmp(res->high, "high"))
6954 ret = rte_eth_dev_add_syn_filter(res->port_id,
6955 &filter, res->queue_id);
6956 } else if (!strcmp(res->filter, "remove_syn_filter"))
6957 ret = rte_eth_dev_remove_syn_filter(res->port_id);
6958 else if (!strcmp(res->filter, "get_syn_filter"))
6959 get_syn_filter(res->port_id);
6961 printf("syn filter setting error: (%s)\n", strerror(-ret));
6964 cmdline_parse_token_num_t cmd_syn_filter_portid =
6965 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6967 cmdline_parse_token_string_t cmd_syn_filter_priority =
6968 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6969 priority, "priority");
6970 cmdline_parse_token_string_t cmd_syn_filter_high =
6971 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6973 cmdline_parse_token_string_t cmd_syn_filter_queue =
6974 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6976 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6977 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6979 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
6980 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6981 filter, "add_syn_filter");
6982 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
6983 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6984 filter, "remove_syn_filter");
6985 cmdline_parse_inst_t cmd_add_syn_filter = {
6986 .f = cmd_set_syn_filter_parsed,
6988 .help_str = "add syn filter",
6990 (void *)&cmd_syn_filter_add_filter,
6991 (void *)&cmd_syn_filter_portid,
6992 (void *)&cmd_syn_filter_priority,
6993 (void *)&cmd_syn_filter_high,
6994 (void *)&cmd_syn_filter_queue,
6995 (void *)&cmd_syn_filter_queue_id,
6999 cmdline_parse_inst_t cmd_remove_syn_filter = {
7000 .f = cmd_set_syn_filter_parsed,
7002 .help_str = "remove syn filter",
7004 (void *)&cmd_syn_filter_remove_filter,
7005 (void *)&cmd_syn_filter_portid,
7010 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7011 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7012 filter, "get_syn_filter");
7014 cmdline_parse_inst_t cmd_get_syn_filter = {
7015 .f = cmd_set_syn_filter_parsed,
7017 .help_str = "get syn filter",
7019 (void *)&cmd_syn_filter_get_filter,
7020 (void *)&cmd_syn_filter_portid,
7025 /* *** ADD/REMOVE A 2tuple FILTER *** */
7026 struct cmd_2tuple_filter_result {
7027 cmdline_fixed_string_t filter;
7029 cmdline_fixed_string_t protocol;
7030 uint8_t protocol_value;
7031 uint8_t protocol_mask;
7032 cmdline_fixed_string_t dst_port;
7033 uint16_t dst_port_value;
7034 uint16_t dst_port_mask;
7035 cmdline_fixed_string_t flags;
7036 uint8_t flags_value;
7037 cmdline_fixed_string_t priority;
7038 uint8_t priority_value;
7039 cmdline_fixed_string_t queue;
7041 cmdline_fixed_string_t index;
7042 uint16_t index_value;
7046 cmd_2tuple_filter_parsed(void *parsed_result,
7047 __attribute__((unused)) struct cmdline *cl,
7048 __attribute__((unused)) void *data)
7051 struct rte_2tuple_filter filter;
7052 struct cmd_2tuple_filter_result *res = parsed_result;
7054 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7056 if (!strcmp(res->filter, "add_2tuple_filter")) {
7057 /* need convert to big endian. */
7058 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7059 filter.protocol = res->protocol_value;
7060 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7061 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7062 filter.priority = res->priority_value;
7063 filter.tcp_flags = res->flags_value;
7064 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7065 res->index_value, &filter, res->queue_id);
7066 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7067 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7069 else if (!strcmp(res->filter, "get_2tuple_filter"))
7070 get_2tuple_filter(res->port_id, res->index_value);
7073 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7076 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7077 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7079 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7080 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7081 protocol, "protocol");
7082 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7083 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7084 protocol_value, UINT8);
7085 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7086 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7087 protocol_mask, UINT8);
7088 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7089 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7090 dst_port, "dst_port");
7091 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7092 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7093 dst_port_value, UINT16);
7094 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7095 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7096 dst_port_mask, UINT16);
7097 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7098 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7100 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7101 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7102 flags_value, UINT8);
7103 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7104 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7105 priority, "priority");
7106 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7107 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7108 priority_value, UINT8);
7109 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7110 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7112 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7113 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7115 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7116 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7118 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7119 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7120 index_value, UINT16);
7121 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7122 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7123 filter, "add_2tuple_filter");
7124 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7125 .f = cmd_2tuple_filter_parsed,
7127 .help_str = "add a 2tuple filter",
7129 (void *)&cmd_2tuple_filter_add_filter,
7130 (void *)&cmd_2tuple_filter_port_id,
7131 (void *)&cmd_2tuple_filter_protocol,
7132 (void *)&cmd_2tuple_filter_protocol_value,
7133 (void *)&cmd_2tuple_filter_protocol_mask,
7134 (void *)&cmd_2tuple_filter_dst_port,
7135 (void *)&cmd_2tuple_filter_dst_port_value,
7136 (void *)&cmd_2tuple_filter_dst_port_mask,
7137 (void *)&cmd_2tuple_filter_flags,
7138 (void *)&cmd_2tuple_filter_flags_value,
7139 (void *)&cmd_2tuple_filter_priority,
7140 (void *)&cmd_2tuple_filter_priority_value,
7141 (void *)&cmd_2tuple_filter_queue,
7142 (void *)&cmd_2tuple_filter_queue_id,
7143 (void *)&cmd_2tuple_filter_index,
7144 (void *)&cmd_2tuple_filter_index_value,
7149 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7150 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7151 filter, "remove_2tuple_filter");
7152 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7153 .f = cmd_2tuple_filter_parsed,
7155 .help_str = "remove a 2tuple filter",
7157 (void *)&cmd_2tuple_filter_remove_filter,
7158 (void *)&cmd_2tuple_filter_port_id,
7159 (void *)&cmd_2tuple_filter_index,
7160 (void *)&cmd_2tuple_filter_index_value,
7164 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7165 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7166 filter, "get_2tuple_filter");
7167 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7168 .f = cmd_2tuple_filter_parsed,
7170 .help_str = "get a 2tuple filter",
7172 (void *)&cmd_2tuple_filter_get_filter,
7173 (void *)&cmd_2tuple_filter_port_id,
7174 (void *)&cmd_2tuple_filter_index,
7175 (void *)&cmd_2tuple_filter_index_value,
7180 /* *** ADD/REMOVE A 5tuple FILTER *** */
7181 struct cmd_5tuple_filter_result {
7182 cmdline_fixed_string_t filter;
7184 cmdline_fixed_string_t dst_ip;
7185 cmdline_ipaddr_t dst_ip_value;
7186 cmdline_fixed_string_t src_ip;
7187 cmdline_ipaddr_t src_ip_value;
7188 cmdline_fixed_string_t dst_port;
7189 uint16_t dst_port_value;
7190 cmdline_fixed_string_t src_port;
7191 uint16_t src_port_value;
7192 cmdline_fixed_string_t protocol;
7193 uint8_t protocol_value;
7194 cmdline_fixed_string_t mask;
7196 cmdline_fixed_string_t flags;
7197 uint8_t flags_value;
7198 cmdline_fixed_string_t priority;
7199 uint8_t priority_value;
7200 cmdline_fixed_string_t queue;
7202 cmdline_fixed_string_t index;
7203 uint16_t index_value;
7207 cmd_5tuple_filter_parsed(void *parsed_result,
7208 __attribute__((unused)) struct cmdline *cl,
7209 __attribute__((unused)) void *data)
7212 struct rte_5tuple_filter filter;
7213 struct cmd_5tuple_filter_result *res = parsed_result;
7215 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7217 if (!strcmp(res->filter, "add_5tuple_filter")) {
7218 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7219 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7220 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7221 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7222 filter.protocol = res->protocol_value;
7223 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7224 filter.priority = res->priority_value;
7225 filter.tcp_flags = res->flags_value;
7227 if (res->dst_ip_value.family == AF_INET)
7228 /* no need to convert, already big endian. */
7229 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7231 if (filter.dst_ip_mask == 0) {
7232 printf("can not support ipv6 involved compare.\n");
7238 if (res->src_ip_value.family == AF_INET)
7239 /* no need to convert, already big endian. */
7240 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7242 if (filter.src_ip_mask == 0) {
7243 printf("can not support ipv6 involved compare.\n");
7248 /* need convert to big endian. */
7249 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7250 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7252 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7253 res->index_value, &filter, res->queue_id);
7254 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7255 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7257 else if (!strcmp(res->filter, "get_5tuple_filter"))
7258 get_5tuple_filter(res->port_id, res->index_value);
7260 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7264 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7265 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7267 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7268 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7270 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7271 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7273 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7274 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7276 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7277 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7279 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7280 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7281 dst_port, "dst_port");
7282 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7283 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7284 dst_port_value, UINT16);
7285 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7286 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7287 src_port, "src_port");
7288 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7289 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7290 src_port_value, UINT16);
7291 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7292 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7293 protocol, "protocol");
7294 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7295 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7296 protocol_value, UINT8);
7297 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7298 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7300 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7301 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7303 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7304 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7306 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7307 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7308 flags_value, UINT8);
7309 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7310 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7311 priority, "priority");
7312 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7313 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7314 priority_value, UINT8);
7315 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7316 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7318 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7319 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7321 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7322 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7324 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7325 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7326 index_value, UINT16);
7328 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7329 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7330 filter, "add_5tuple_filter");
7331 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7332 .f = cmd_5tuple_filter_parsed,
7334 .help_str = "add a 5tuple filter",
7336 (void *)&cmd_5tuple_filter_add_filter,
7337 (void *)&cmd_5tuple_filter_port_id,
7338 (void *)&cmd_5tuple_filter_dst_ip,
7339 (void *)&cmd_5tuple_filter_dst_ip_value,
7340 (void *)&cmd_5tuple_filter_src_ip,
7341 (void *)&cmd_5tuple_filter_src_ip_value,
7342 (void *)&cmd_5tuple_filter_dst_port,
7343 (void *)&cmd_5tuple_filter_dst_port_value,
7344 (void *)&cmd_5tuple_filter_src_port,
7345 (void *)&cmd_5tuple_filter_src_port_value,
7346 (void *)&cmd_5tuple_filter_protocol,
7347 (void *)&cmd_5tuple_filter_protocol_value,
7348 (void *)&cmd_5tuple_filter_mask,
7349 (void *)&cmd_5tuple_filter_mask_value,
7350 (void *)&cmd_5tuple_filter_flags,
7351 (void *)&cmd_5tuple_filter_flags_value,
7352 (void *)&cmd_5tuple_filter_priority,
7353 (void *)&cmd_5tuple_filter_priority_value,
7354 (void *)&cmd_5tuple_filter_queue,
7355 (void *)&cmd_5tuple_filter_queue_id,
7356 (void *)&cmd_5tuple_filter_index,
7357 (void *)&cmd_5tuple_filter_index_value,
7362 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7363 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7364 filter, "remove_5tuple_filter");
7365 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7366 .f = cmd_5tuple_filter_parsed,
7368 .help_str = "remove a 5tuple filter",
7370 (void *)&cmd_5tuple_filter_remove_filter,
7371 (void *)&cmd_5tuple_filter_port_id,
7372 (void *)&cmd_5tuple_filter_index,
7373 (void *)&cmd_5tuple_filter_index_value,
7378 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7379 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7380 filter, "get_5tuple_filter");
7381 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7382 .f = cmd_5tuple_filter_parsed,
7384 .help_str = "get a 5tuple filter",
7386 (void *)&cmd_5tuple_filter_get_filter,
7387 (void *)&cmd_5tuple_filter_port_id,
7388 (void *)&cmd_5tuple_filter_index,
7389 (void *)&cmd_5tuple_filter_index_value,
7394 /* *** ADD/REMOVE A flex FILTER *** */
7395 struct cmd_flex_filter_result {
7396 cmdline_fixed_string_t filter;
7398 cmdline_fixed_string_t len;
7400 cmdline_fixed_string_t bytes;
7401 cmdline_fixed_string_t bytes_value;
7402 cmdline_fixed_string_t mask;
7403 cmdline_fixed_string_t mask_value;
7404 cmdline_fixed_string_t priority;
7405 uint8_t priority_value;
7406 cmdline_fixed_string_t queue;
7408 cmdline_fixed_string_t index;
7409 uint16_t index_value;
7412 static int xdigit2val(unsigned char c)
7417 else if (isupper(c))
7425 cmd_flex_filter_parsed(void *parsed_result,
7426 __attribute__((unused)) struct cmdline *cl,
7427 __attribute__((unused)) void *data)
7430 struct rte_flex_filter filter;
7431 struct cmd_flex_filter_result *res = parsed_result;
7432 char *bytes_ptr, *mask_ptr;
7440 if (!strcmp(res->filter, "add_flex_filter")) {
7441 if (res->len_value > 128) {
7442 printf("the len exceed the max length 128\n");
7445 memset(&filter, 0, sizeof(struct rte_flex_filter));
7446 filter.len = res->len_value;
7447 filter.priority = res->priority_value;
7448 bytes_ptr = res->bytes_value;
7449 mask_ptr = res->mask_value;
7452 /* translate bytes string to uint_32 array. */
7453 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7454 (bytes_ptr[1] == 'X')))
7456 len = strnlen(bytes_ptr, res->len_value * 2);
7457 if (len == 0 || (len % 8 != 0)) {
7458 printf("please check len and bytes input\n");
7461 for (i = 0; i < len; i++) {
7463 if (isxdigit(c) == 0) {
7464 /* invalid characters. */
7465 printf("invalid input\n");
7468 val = xdigit2val(c);
7472 dword |= byte << (4 * mod - 4);
7477 filter.dwords[j] = dword;
7478 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7484 /* translate mask string to uint8_t array. */
7486 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7487 (mask_ptr[1] == 'X')))
7489 len = strnlen(mask_ptr, (res->len_value+3)/4);
7491 printf("invalid input\n");
7494 for (i = 0; i < len; i++) {
7496 if (isxdigit(c) == 0) {
7497 /* invalid characters. */
7498 printf("invalid input\n");
7501 val = xdigit2val(c);
7502 hex |= (uint8_t)(val & 0x8) >> 3;
7503 hex |= (uint8_t)(val & 0x4) >> 1;
7504 hex |= (uint8_t)(val & 0x2) << 1;
7505 hex |= (uint8_t)(val & 0x1) << 3;
7508 filter.mask[j] = byte;
7509 printf("mask[%d]:%02x ", j, filter.mask[j]);
7517 printf("call function rte_eth_dev_add_flex_filter: "
7518 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7519 res->index_value, res->queue_id,
7520 filter.len, filter.priority);
7521 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7522 &filter, res->queue_id);
7524 } else if (!strcmp(res->filter, "remove_flex_filter"))
7525 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7527 else if (!strcmp(res->filter, "get_flex_filter"))
7528 get_flex_filter(res->port_id, res->index_value);
7531 printf("flex filter setting error: (%s)\n", strerror(-ret));
7534 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7535 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7537 cmdline_parse_token_string_t cmd_flex_filter_len =
7538 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7540 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7541 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7543 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7544 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7546 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7547 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7549 cmdline_parse_token_string_t cmd_flex_filter_mask =
7550 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7552 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7553 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7555 cmdline_parse_token_string_t cmd_flex_filter_priority =
7556 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7557 priority, "priority");
7558 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7559 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7560 priority_value, UINT8);
7561 cmdline_parse_token_string_t cmd_flex_filter_queue =
7562 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7564 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7565 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7567 cmdline_parse_token_string_t cmd_flex_filter_index =
7568 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7570 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7571 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7572 index_value, UINT16);
7573 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7574 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7575 filter, "add_flex_filter");
7576 cmdline_parse_inst_t cmd_add_flex_filter = {
7577 .f = cmd_flex_filter_parsed,
7579 .help_str = "add a flex filter",
7581 (void *)&cmd_flex_filter_add_filter,
7582 (void *)&cmd_flex_filter_port_id,
7583 (void *)&cmd_flex_filter_len,
7584 (void *)&cmd_flex_filter_len_value,
7585 (void *)&cmd_flex_filter_bytes,
7586 (void *)&cmd_flex_filter_bytes_value,
7587 (void *)&cmd_flex_filter_mask,
7588 (void *)&cmd_flex_filter_mask_value,
7589 (void *)&cmd_flex_filter_priority,
7590 (void *)&cmd_flex_filter_priority_value,
7591 (void *)&cmd_flex_filter_queue,
7592 (void *)&cmd_flex_filter_queue_id,
7593 (void *)&cmd_flex_filter_index,
7594 (void *)&cmd_flex_filter_index_value,
7599 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7600 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7601 filter, "remove_flex_filter");
7602 cmdline_parse_inst_t cmd_remove_flex_filter = {
7603 .f = cmd_flex_filter_parsed,
7605 .help_str = "remove a flex filter",
7607 (void *)&cmd_flex_filter_remove_filter,
7608 (void *)&cmd_flex_filter_port_id,
7609 (void *)&cmd_flex_filter_index,
7610 (void *)&cmd_flex_filter_index_value,
7615 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7616 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7617 filter, "get_flex_filter");
7618 cmdline_parse_inst_t cmd_get_flex_filter = {
7619 .f = cmd_flex_filter_parsed,
7621 .help_str = "get a flex filter",
7623 (void *)&cmd_flex_filter_get_filter,
7624 (void *)&cmd_flex_filter_port_id,
7625 (void *)&cmd_flex_filter_index,
7626 (void *)&cmd_flex_filter_index_value,
7631 /* ******************************************************************************** */
7633 /* list of instructions */
7634 cmdline_parse_ctx_t main_ctx[] = {
7635 (cmdline_parse_inst_t *)&cmd_help_brief,
7636 (cmdline_parse_inst_t *)&cmd_help_long,
7637 (cmdline_parse_inst_t *)&cmd_quit,
7638 (cmdline_parse_inst_t *)&cmd_showport,
7639 (cmdline_parse_inst_t *)&cmd_showportall,
7640 (cmdline_parse_inst_t *)&cmd_showcfg,
7641 (cmdline_parse_inst_t *)&cmd_start,
7642 (cmdline_parse_inst_t *)&cmd_start_tx_first,
7643 (cmdline_parse_inst_t *)&cmd_set_link_up,
7644 (cmdline_parse_inst_t *)&cmd_set_link_down,
7645 (cmdline_parse_inst_t *)&cmd_reset,
7646 (cmdline_parse_inst_t *)&cmd_set_numbers,
7647 (cmdline_parse_inst_t *)&cmd_set_txpkts,
7648 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
7649 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
7650 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
7651 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
7652 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
7653 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
7654 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
7655 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
7656 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
7657 (cmdline_parse_inst_t *)&cmd_set_link_check,
7658 #ifdef RTE_NIC_BYPASS
7659 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
7660 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
7661 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
7662 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
7664 #ifdef RTE_LIBRTE_PMD_BOND
7665 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
7666 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
7667 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
7668 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
7669 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
7670 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
7671 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
7672 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
7674 (cmdline_parse_inst_t *)&cmd_vlan_offload,
7675 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
7676 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
7677 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
7678 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
7679 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
7680 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
7681 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
7682 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
7683 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
7684 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
7685 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
7686 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
7687 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
7688 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
7689 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
7690 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
7691 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
7692 (cmdline_parse_inst_t *)&cmd_config_dcb,
7693 (cmdline_parse_inst_t *)&cmd_read_reg,
7694 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
7695 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
7696 (cmdline_parse_inst_t *)&cmd_write_reg,
7697 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
7698 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
7699 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
7700 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
7701 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
7702 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
7703 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
7704 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
7705 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
7706 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
7707 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
7708 (cmdline_parse_inst_t *)&cmd_stop,
7709 (cmdline_parse_inst_t *)&cmd_mac_addr,
7710 (cmdline_parse_inst_t *)&cmd_set_qmap,
7711 (cmdline_parse_inst_t *)&cmd_operate_port,
7712 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
7713 (cmdline_parse_inst_t *)&cmd_config_speed_all,
7714 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
7715 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
7716 (cmdline_parse_inst_t *)&cmd_config_mtu,
7717 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
7718 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
7719 (cmdline_parse_inst_t *)&cmd_config_rss,
7720 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
7721 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
7722 (cmdline_parse_inst_t *)&cmd_showport_reta,
7723 (cmdline_parse_inst_t *)&cmd_config_burst,
7724 (cmdline_parse_inst_t *)&cmd_config_thresh,
7725 (cmdline_parse_inst_t *)&cmd_config_threshold,
7726 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
7727 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
7728 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
7729 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
7730 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
7731 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
7732 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
7733 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
7734 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
7735 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
7736 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
7737 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
7738 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
7739 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
7740 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
7741 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
7742 (cmdline_parse_inst_t *)&cmd_dump,
7743 (cmdline_parse_inst_t *)&cmd_dump_one,
7744 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
7745 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
7746 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
7747 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
7748 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
7749 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
7750 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
7751 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
7752 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
7753 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
7754 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
7755 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
7756 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
7757 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
7758 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
7762 /* prompt function, called from main on MASTER lcore */
7768 /* initialize non-constant commands */
7769 cmd_set_fwd_mode_init();
7771 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
7775 cmdline_interact(cl);
7776 cmdline_stdin_exit(cl);
7780 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
7782 if (id < nb_ports) {
7783 /* check if need_reconfig has been set to 1 */
7784 if (ports[id].need_reconfig == 0)
7785 ports[id].need_reconfig = dev;
7786 /* check if need_reconfig_queues has been set to 1 */
7787 if (ports[id].need_reconfig_queues == 0)
7788 ports[id].need_reconfig_queues = queue;
7792 for (pid = 0; pid < nb_ports; pid++) {
7793 /* check if need_reconfig has been set to 1 */
7794 if (ports[pid].need_reconfig == 0)
7795 ports[pid].need_reconfig = dev;
7796 /* check if need_reconfig_queues has been set to 1 */
7797 if (ports[pid].need_reconfig_queues == 0)
7798 ports[pid].need_reconfig_queues = queue;
7803 #ifdef RTE_NIC_BYPASS
7805 bypass_is_supported(portid_t port_id)
7807 struct rte_port *port;
7808 struct rte_pci_id *pci_id;
7810 if (port_id >= nb_ports) {
7811 printf("\tPort id must be less than %d.\n", nb_ports);
7815 /* Get the device id. */
7816 port = &ports[port_id];
7817 pci_id = &port->dev_info.pci_dev->id;
7819 /* Check if NIC supports bypass. */
7820 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
7824 printf("\tBypass not supported for port_id = %d.\n", port_id);