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 8-bit mask, 0~0xff, 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 " bit 4 - insert inner ip checksum offload if set\n"
321 " bit 5 - insert inner udp checksum offload if set\n"
322 " bit 6 - insert inner tcp checksum offload if set\n"
323 " bit 7 - insert inner sctp checksum offload if set\n"
324 " Please check the NIC datasheet for HW limits.\n\n"
327 " Set packet forwarding mode.\n\n"
329 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
330 " Add a MAC address on port_id.\n\n"
332 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
333 " Remove a MAC address from port_id.\n\n"
335 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
336 " Add a MAC address for a VF on the port.\n\n"
338 "set port (port_id) uta (mac_address|all) (on|off)\n"
339 " Add/Remove a or all unicast hash filter(s)"
342 "set promisc (port_id|all) (on|off)\n"
343 " Set the promiscuous mode on port_id, or all.\n\n"
345 "set allmulti (port_id|all) (on|off)\n"
346 " Set the allmulti mode on port_id, or all.\n\n"
348 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
349 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
350 " (on|off) autoneg (on|off) (port_id)\n"
351 "set flow_ctrl rx (on|off) (portid)\n"
352 "set flow_ctrl tx (on|off) (portid)\n"
353 "set flow_ctrl high_water (high_water) (portid)\n"
354 "set flow_ctrl low_water (low_water) (portid)\n"
355 "set flow_ctrl pause_time (pause_time) (portid)\n"
356 "set flow_ctrl send_xon (send_xon) (portid)\n"
357 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
358 "set flow_ctrl autoneg (on|off) (port_id)\n"
359 " Set the link flow control parameter on a port.\n\n"
361 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
362 " (low_water) (pause_time) (priority) (port_id)\n"
363 " Set the priority flow control parameter on a"
366 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
367 " Set statistics mapping (qmapping 0..15) for RX/TX"
369 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
370 " on port 0 to mapping 5.\n\n"
372 "set port (port_id) vf (vf_id) rx|tx on|off \n"
373 " Enable/Disable a VF receive/tranmit from a port\n\n"
375 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
377 " AUPE:accepts untagged VLAN;"
378 "ROPE:accept unicast hash\n\n"
379 " BAM:accepts broadcast packets;"
380 "MPE:accepts all multicast packets\n\n"
381 " Enable/Disable a VF receive mode of a port\n\n"
383 "set port (port_id) queue (queue_id) rate (rate_num)\n"
384 " Set rate limit for a queue of a port\n\n"
386 "set port (port_id) vf (vf_id) rate (rate_num) "
387 "queue_mask (queue_mask_value)\n"
388 " Set rate limit for queues in VF of a port\n\n"
390 "set port (port_id) mirror-rule (rule_id)"
391 "(pool-mirror|vlan-mirror)\n"
392 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
393 " Set pool or vlan type mirror rule on a port.\n"
394 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
395 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
398 "set port (port_id) mirror-rule (rule_id)"
399 " (uplink-mirror|downlink-mirror) dst-pool"
400 " (pool_id) (on|off)\n"
401 " Set uplink or downlink type mirror rule on a port.\n"
402 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
403 " 0 on' enable mirror income traffic to pool 0.\n\n"
405 "reset port (port_id) mirror-rule (rule_id)\n"
406 " Reset a mirror rule.\n\n"
408 "set flush_rx (on|off)\n"
409 " Flush (default) or don't flush RX streams before"
410 " forwarding. Mainly used with PCAP drivers.\n\n"
412 #ifdef RTE_NIC_BYPASS
413 "set bypass mode (normal|bypass|isolate) (port_id)\n"
414 " Set the bypass mode for the lowest port on bypass enabled"
417 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
418 "mode (normal|bypass|isolate) (port_id)\n"
419 " Set the event required to initiate specified bypass mode for"
420 " the lowest port on a bypass enabled NIC where:\n"
421 " timeout = enable bypass after watchdog timeout.\n"
422 " os_on = enable bypass when OS/board is powered on.\n"
423 " os_off = enable bypass when OS/board is powered off.\n"
424 " power_on = enable bypass when power supply is turned on.\n"
425 " power_off = enable bypass when power supply is turned off."
428 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
429 " Set the bypass watchdog timeout to 'n' seconds"
430 " where 0 = instant.\n\n"
432 "show bypass config (port_id)\n"
433 " Show the bypass configuration for a bypass enabled NIC"
434 " using the lowest port on the NIC.\n\n"
436 #ifdef RTE_LIBRTE_PMD_BOND
437 "create bonded device (mode) (socket)\n"
438 " Create a new bonded device with specific bonding mode and socket.\n\n"
440 "add bonding slave (slave_id) (port_id)\n"
441 " Add a slave device to a bonded device.\n\n"
443 "remove bonding slave (slave_id) (port_id)\n"
444 " Remove a slave device from a bonded device.\n\n"
446 "set bonding mode (value) (port_id)\n"
447 " Set the bonding mode on a bonded device.\n\n"
449 "set bonding primary (slave_id) (port_id)\n"
450 " Set the primary slave for a bonded device.\n\n"
452 "show bonding config (port_id)\n"
453 " Show the bonding config for port_id.\n\n"
455 "set bonding mac_addr (port_id) (address)\n"
456 " Set the MAC address of a bonded device.\n\n"
458 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
459 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
462 , list_pkt_forwarding_modes()
467 if (show_all || !strcmp(res->section, "flowdir")) {
472 "Flow director mode:\n"
473 "-------------------\n\n"
475 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
476 " src (src_ip_address) (src_port)"
477 " dst (dst_ip_address) (dst_port)"
478 " flexbytes (flexbytes_values) vlan (vlan_id)"
479 " queue (queue_id)\n"
480 " Add a signature filter.\n\n"
482 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
483 " src (src_ip_address) (src_port)"
484 " dst (dst_ip_address) (dst_port)"
485 " flexbytes (flexbytes_values) vlan (vlan_id)"
486 " queue (queue_id)\n"
487 " Update a signature filter.\n\n"
489 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
490 " src (src_ip_address) (src_port)"
491 " dst (dst_ip_address) (dst_port)"
492 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
493 " Remove a signature filter.\n\n"
495 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
496 " src (src_ip_address) (src_port)"
497 " dst (dst_ip_address) (dst_port)"
498 " flexbytes (flexbytes_values) vlan (vlan_id)"
499 " queue (queue_id) soft (soft_id)\n"
500 " Add a perfect filter.\n\n"
502 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
503 " src (src_ip_address) (src_port)"
504 " dst (dst_ip_address) (dst_port)"
505 " flexbytes (flexbytes_values) vlan (vlan_id)"
506 " queue (queue_id)\n"
507 " Update a perfect filter.\n\n"
509 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
510 " src (src_ip_address) (src_port)"
511 " dst (dst_ip_address) (dst_port)"
512 " flexbytes (flexbytes_values) vlan (vlan_id)"
514 " Remove a perfect filter.\n\n"
516 "set_masks_filter (port_id) only_ip_flow (0|1)"
517 " src_mask (ip_src_mask) (src_port_mask)"
518 " dst_mask (ip_dst_mask) (dst_port_mask)"
519 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
520 " Set IPv4 filter masks.\n\n"
522 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
523 " src_mask (ip_src_mask) (src_port_mask)"
524 " dst_mask (ip_dst_mask) (dst_port_mask)"
525 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
526 " compare_dst (0|1)\n"
527 " Set IPv6 filter masks.\n\n"
531 if (show_all || !strcmp(res->section, "ports")) {
537 "----------------\n\n"
539 "port start (port_id|all)\n"
540 " Start all ports or port_id.\n\n"
542 "port stop (port_id|all)\n"
543 " Stop all ports or port_id.\n\n"
545 "port close (port_id|all)\n"
546 " Close all ports or port_id.\n\n"
548 "port config (port_id|all)"
549 " speed (10|100|1000|10000|40000|auto)"
550 " duplex (half|full|auto)\n"
551 " Set speed and duplex for all ports or port_id\n\n"
553 "port config all (rxq|txq|rxd|txd) (value)\n"
554 " Set number for rxq/txq/rxd/txd.\n\n"
556 "port config all max-pkt-len (value)\n"
557 " Set the max packet length.\n\n"
559 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
561 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
564 "port config all rss (ip|udp|none)\n"
565 " Set the RSS mode.\n\n"
567 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
568 " Set the RSS redirection table.\n\n"
570 "port config (port_id) dcb vt (on|off) (traffic_class)"
572 " Set the DCB mode.\n\n"
574 "port config all burst (value)\n"
575 " Set the number of packets per burst.\n\n"
577 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
579 " Set the ring prefetch/host/writeback threshold"
580 " for tx/rx queue.\n\n"
582 "port config all (txfreet|txrst|rxfreet) (value)\n"
583 " Set free threshold for rx/tx, or set"
584 " tx rs bit threshold.\n\n"
585 "port config mtu X value\n"
586 " Set the MTU of port X to a given value\n\n"
588 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
589 " Start/stop a rx/tx queue of port X. Only take effect"
590 " when port X is started\n"
594 if (show_all || !strcmp(res->section, "registers")) {
602 "read reg (port_id) (address)\n"
603 " Display value of a port register.\n\n"
605 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
606 " Display a port register bit field.\n\n"
608 "read regbit (port_id) (address) (bit_x)\n"
609 " Display a single port register bit.\n\n"
611 "write reg (port_id) (address) (value)\n"
612 " Set value of a port register.\n\n"
614 "write regfield (port_id) (address) (bit_x) (bit_y)"
616 " Set bit field of a port register.\n\n"
618 "write regbit (port_id) (address) (bit_x) (value)\n"
619 " Set single bit value of a port register.\n\n"
622 if (show_all || !strcmp(res->section, "filters")) {
630 "add_ethertype_filter (port_id) ethertype (eth_value)"
631 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
632 " add an ethertype filter.\n\n"
634 "remove_ethertype_filter (port_id) index (idx)\n"
635 " remove an ethertype filter.\n\n"
637 "get_ethertype_filter (port_id) index (idx)\n"
638 " get info of a ethertype filter.\n\n"
640 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
641 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
642 " queue (queue_id) index (idx)\n"
643 " add a 2tuple filter.\n\n"
645 "remove_2tuple_filter (port_id) index (idx)\n"
646 " remove a 2tuple filter.\n\n"
648 "get_2tuple_filter (port_id) index (idx)\n"
649 " get info of a 2tuple filter.\n\n"
651 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
652 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
653 " mask (mask_value) flags (flags_value) priority (prio_value)"
654 " queue (queue_id) index (idx)\n"
655 " add a 5tuple filter.\n\n"
657 "remove_5tuple_filter (port_id) index (idx)\n"
658 " remove a 5tuple filter.\n\n"
660 "get_5tuple_filter (port_id) index (idx)\n"
661 " get info of a 5tuple filter.\n\n"
663 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
664 " add syn filter.\n\n"
666 "remove_syn_filter (port_id)"
667 " remove syn filter.\n\n"
669 "get_syn_filter (port_id) "
670 " get syn filter info.\n\n"
672 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
673 " priority (prio_value) queue (queue_id) index (idx)\n"
674 " add a flex filter.\n\n"
676 "remove_flex_filter (port_id) index (idx)\n"
677 " remove a flex filter.\n\n"
679 "get_flex_filter (port_id) index (idx)\n"
680 " get info of a flex filter.\n\n"
685 cmdline_parse_token_string_t cmd_help_long_help =
686 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
688 cmdline_parse_token_string_t cmd_help_long_section =
689 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
690 "all#control#display#config#flowdir#"
691 "ports#registers#filters");
693 cmdline_parse_inst_t cmd_help_long = {
694 .f = cmd_help_long_parsed,
696 .help_str = "show help",
698 (void *)&cmd_help_long_help,
699 (void *)&cmd_help_long_section,
705 /* *** start/stop/close all ports *** */
706 struct cmd_operate_port_result {
707 cmdline_fixed_string_t keyword;
708 cmdline_fixed_string_t name;
709 cmdline_fixed_string_t value;
712 static void cmd_operate_port_parsed(void *parsed_result,
713 __attribute__((unused)) struct cmdline *cl,
714 __attribute__((unused)) void *data)
716 struct cmd_operate_port_result *res = parsed_result;
718 if (!strcmp(res->name, "start"))
719 start_port(RTE_PORT_ALL);
720 else if (!strcmp(res->name, "stop"))
721 stop_port(RTE_PORT_ALL);
722 else if (!strcmp(res->name, "close"))
723 close_port(RTE_PORT_ALL);
725 printf("Unknown parameter\n");
728 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
729 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
731 cmdline_parse_token_string_t cmd_operate_port_all_port =
732 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
734 cmdline_parse_token_string_t cmd_operate_port_all_all =
735 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
737 cmdline_parse_inst_t cmd_operate_port = {
738 .f = cmd_operate_port_parsed,
740 .help_str = "port start|stop|close all: start/stop/close all ports",
742 (void *)&cmd_operate_port_all_cmd,
743 (void *)&cmd_operate_port_all_port,
744 (void *)&cmd_operate_port_all_all,
749 /* *** start/stop/close specific port *** */
750 struct cmd_operate_specific_port_result {
751 cmdline_fixed_string_t keyword;
752 cmdline_fixed_string_t name;
756 static void cmd_operate_specific_port_parsed(void *parsed_result,
757 __attribute__((unused)) struct cmdline *cl,
758 __attribute__((unused)) void *data)
760 struct cmd_operate_specific_port_result *res = parsed_result;
762 if (!strcmp(res->name, "start"))
763 start_port(res->value);
764 else if (!strcmp(res->name, "stop"))
765 stop_port(res->value);
766 else if (!strcmp(res->name, "close"))
767 close_port(res->value);
769 printf("Unknown parameter\n");
772 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
773 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
775 cmdline_parse_token_string_t cmd_operate_specific_port_port =
776 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
777 name, "start#stop#close");
778 cmdline_parse_token_num_t cmd_operate_specific_port_id =
779 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
782 cmdline_parse_inst_t cmd_operate_specific_port = {
783 .f = cmd_operate_specific_port_parsed,
785 .help_str = "port start|stop|close X: start/stop/close port X",
787 (void *)&cmd_operate_specific_port_cmd,
788 (void *)&cmd_operate_specific_port_port,
789 (void *)&cmd_operate_specific_port_id,
794 /* *** configure speed for all ports *** */
795 struct cmd_config_speed_all {
796 cmdline_fixed_string_t port;
797 cmdline_fixed_string_t keyword;
798 cmdline_fixed_string_t all;
799 cmdline_fixed_string_t item1;
800 cmdline_fixed_string_t item2;
801 cmdline_fixed_string_t value1;
802 cmdline_fixed_string_t value2;
806 cmd_config_speed_all_parsed(void *parsed_result,
807 __attribute__((unused)) struct cmdline *cl,
808 __attribute__((unused)) void *data)
810 struct cmd_config_speed_all *res = parsed_result;
811 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
812 uint16_t link_duplex = 0;
815 if (!all_ports_stopped()) {
816 printf("Please stop all ports first\n");
820 if (!strcmp(res->value1, "10"))
821 link_speed = ETH_LINK_SPEED_10;
822 else if (!strcmp(res->value1, "100"))
823 link_speed = ETH_LINK_SPEED_100;
824 else if (!strcmp(res->value1, "1000"))
825 link_speed = ETH_LINK_SPEED_1000;
826 else if (!strcmp(res->value1, "10000"))
827 link_speed = ETH_LINK_SPEED_10G;
828 else if (!strcmp(res->value1, "40000"))
829 link_speed = ETH_LINK_SPEED_40G;
830 else if (!strcmp(res->value1, "auto"))
831 link_speed = ETH_LINK_SPEED_AUTONEG;
833 printf("Unknown parameter\n");
837 if (!strcmp(res->value2, "half"))
838 link_duplex = ETH_LINK_HALF_DUPLEX;
839 else if (!strcmp(res->value2, "full"))
840 link_duplex = ETH_LINK_FULL_DUPLEX;
841 else if (!strcmp(res->value2, "auto"))
842 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
844 printf("Unknown parameter\n");
848 for (pid = 0; pid < nb_ports; pid++) {
849 ports[pid].dev_conf.link_speed = link_speed;
850 ports[pid].dev_conf.link_duplex = link_duplex;
853 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
856 cmdline_parse_token_string_t cmd_config_speed_all_port =
857 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
858 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
859 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
861 cmdline_parse_token_string_t cmd_config_speed_all_all =
862 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
863 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
864 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
865 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
866 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
867 "10#100#1000#10000#40000#auto");
868 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
869 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
870 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
871 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
874 cmdline_parse_inst_t cmd_config_speed_all = {
875 .f = cmd_config_speed_all_parsed,
877 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
880 (void *)&cmd_config_speed_all_port,
881 (void *)&cmd_config_speed_all_keyword,
882 (void *)&cmd_config_speed_all_all,
883 (void *)&cmd_config_speed_all_item1,
884 (void *)&cmd_config_speed_all_value1,
885 (void *)&cmd_config_speed_all_item2,
886 (void *)&cmd_config_speed_all_value2,
891 /* *** configure speed for specific port *** */
892 struct cmd_config_speed_specific {
893 cmdline_fixed_string_t port;
894 cmdline_fixed_string_t keyword;
896 cmdline_fixed_string_t item1;
897 cmdline_fixed_string_t item2;
898 cmdline_fixed_string_t value1;
899 cmdline_fixed_string_t value2;
903 cmd_config_speed_specific_parsed(void *parsed_result,
904 __attribute__((unused)) struct cmdline *cl,
905 __attribute__((unused)) void *data)
907 struct cmd_config_speed_specific *res = parsed_result;
908 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
909 uint16_t link_duplex = 0;
911 if (!all_ports_stopped()) {
912 printf("Please stop all ports first\n");
916 if (res->id >= nb_ports) {
917 printf("Port id %d must be less than %d\n", res->id, nb_ports);
921 if (!strcmp(res->value1, "10"))
922 link_speed = ETH_LINK_SPEED_10;
923 else if (!strcmp(res->value1, "100"))
924 link_speed = ETH_LINK_SPEED_100;
925 else if (!strcmp(res->value1, "1000"))
926 link_speed = ETH_LINK_SPEED_1000;
927 else if (!strcmp(res->value1, "10000"))
928 link_speed = ETH_LINK_SPEED_10000;
929 else if (!strcmp(res->value1, "40000"))
930 link_speed = ETH_LINK_SPEED_40G;
931 else if (!strcmp(res->value1, "auto"))
932 link_speed = ETH_LINK_SPEED_AUTONEG;
934 printf("Unknown parameter\n");
938 if (!strcmp(res->value2, "half"))
939 link_duplex = ETH_LINK_HALF_DUPLEX;
940 else if (!strcmp(res->value2, "full"))
941 link_duplex = ETH_LINK_FULL_DUPLEX;
942 else if (!strcmp(res->value2, "auto"))
943 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
945 printf("Unknown parameter\n");
949 ports[res->id].dev_conf.link_speed = link_speed;
950 ports[res->id].dev_conf.link_duplex = link_duplex;
952 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
956 cmdline_parse_token_string_t cmd_config_speed_specific_port =
957 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
959 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
960 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
962 cmdline_parse_token_num_t cmd_config_speed_specific_id =
963 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
964 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
965 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
967 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
968 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
969 "10#100#1000#10000#40000#auto");
970 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
971 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
973 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
974 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
977 cmdline_parse_inst_t cmd_config_speed_specific = {
978 .f = cmd_config_speed_specific_parsed,
980 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
983 (void *)&cmd_config_speed_specific_port,
984 (void *)&cmd_config_speed_specific_keyword,
985 (void *)&cmd_config_speed_specific_id,
986 (void *)&cmd_config_speed_specific_item1,
987 (void *)&cmd_config_speed_specific_value1,
988 (void *)&cmd_config_speed_specific_item2,
989 (void *)&cmd_config_speed_specific_value2,
994 /* *** configure txq/rxq, txd/rxd *** */
995 struct cmd_config_rx_tx {
996 cmdline_fixed_string_t port;
997 cmdline_fixed_string_t keyword;
998 cmdline_fixed_string_t all;
999 cmdline_fixed_string_t name;
1004 cmd_config_rx_tx_parsed(void *parsed_result,
1005 __attribute__((unused)) struct cmdline *cl,
1006 __attribute__((unused)) void *data)
1008 struct cmd_config_rx_tx *res = parsed_result;
1010 if (!all_ports_stopped()) {
1011 printf("Please stop all ports first\n");
1015 if (!strcmp(res->name, "rxq")) {
1016 if (res->value <= 0) {
1017 printf("rxq %d invalid - must be > 0\n", res->value);
1020 nb_rxq = res->value;
1022 else if (!strcmp(res->name, "txq")) {
1023 if (res->value <= 0) {
1024 printf("txq %d invalid - must be > 0\n", res->value);
1027 nb_txq = res->value;
1029 else if (!strcmp(res->name, "rxd")) {
1030 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1031 printf("rxd %d invalid - must be > 0 && <= %d\n",
1032 res->value, RTE_TEST_RX_DESC_MAX);
1035 nb_rxd = res->value;
1036 } else if (!strcmp(res->name, "txd")) {
1037 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1038 printf("txd %d invalid - must be > 0 && <= %d\n",
1039 res->value, RTE_TEST_TX_DESC_MAX);
1042 nb_txd = res->value;
1044 printf("Unknown parameter\n");
1050 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1053 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1054 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1055 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1056 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1057 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1058 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1059 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1060 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1062 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1063 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1065 cmdline_parse_inst_t cmd_config_rx_tx = {
1066 .f = cmd_config_rx_tx_parsed,
1068 .help_str = "port config all rxq|txq|rxd|txd value",
1070 (void *)&cmd_config_rx_tx_port,
1071 (void *)&cmd_config_rx_tx_keyword,
1072 (void *)&cmd_config_rx_tx_all,
1073 (void *)&cmd_config_rx_tx_name,
1074 (void *)&cmd_config_rx_tx_value,
1079 /* *** config max packet length *** */
1080 struct cmd_config_max_pkt_len_result {
1081 cmdline_fixed_string_t port;
1082 cmdline_fixed_string_t keyword;
1083 cmdline_fixed_string_t all;
1084 cmdline_fixed_string_t name;
1089 cmd_config_max_pkt_len_parsed(void *parsed_result,
1090 __attribute__((unused)) struct cmdline *cl,
1091 __attribute__((unused)) void *data)
1093 struct cmd_config_max_pkt_len_result *res = parsed_result;
1095 if (!all_ports_stopped()) {
1096 printf("Please stop all ports first\n");
1100 if (!strcmp(res->name, "max-pkt-len")) {
1101 if (res->value < ETHER_MIN_LEN) {
1102 printf("max-pkt-len can not be less than %d\n",
1106 if (res->value == rx_mode.max_rx_pkt_len)
1109 rx_mode.max_rx_pkt_len = res->value;
1110 if (res->value > ETHER_MAX_LEN)
1111 rx_mode.jumbo_frame = 1;
1113 rx_mode.jumbo_frame = 0;
1115 printf("Unknown parameter\n");
1121 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1124 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1125 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1127 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1128 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1130 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1131 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1133 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1134 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1136 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1137 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1140 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1141 .f = cmd_config_max_pkt_len_parsed,
1143 .help_str = "port config all max-pkt-len value",
1145 (void *)&cmd_config_max_pkt_len_port,
1146 (void *)&cmd_config_max_pkt_len_keyword,
1147 (void *)&cmd_config_max_pkt_len_all,
1148 (void *)&cmd_config_max_pkt_len_name,
1149 (void *)&cmd_config_max_pkt_len_value,
1154 /* *** configure port MTU *** */
1155 struct cmd_config_mtu_result {
1156 cmdline_fixed_string_t port;
1157 cmdline_fixed_string_t keyword;
1158 cmdline_fixed_string_t mtu;
1164 cmd_config_mtu_parsed(void *parsed_result,
1165 __attribute__((unused)) struct cmdline *cl,
1166 __attribute__((unused)) void *data)
1168 struct cmd_config_mtu_result *res = parsed_result;
1170 if (res->value < ETHER_MIN_LEN) {
1171 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1174 port_mtu_set(res->port_id, res->value);
1177 cmdline_parse_token_string_t cmd_config_mtu_port =
1178 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1180 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1181 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1183 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1184 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1186 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1187 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1188 cmdline_parse_token_num_t cmd_config_mtu_value =
1189 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1191 cmdline_parse_inst_t cmd_config_mtu = {
1192 .f = cmd_config_mtu_parsed,
1194 .help_str = "port config mtu value",
1196 (void *)&cmd_config_mtu_port,
1197 (void *)&cmd_config_mtu_keyword,
1198 (void *)&cmd_config_mtu_mtu,
1199 (void *)&cmd_config_mtu_port_id,
1200 (void *)&cmd_config_mtu_value,
1205 /* *** configure rx mode *** */
1206 struct cmd_config_rx_mode_flag {
1207 cmdline_fixed_string_t port;
1208 cmdline_fixed_string_t keyword;
1209 cmdline_fixed_string_t all;
1210 cmdline_fixed_string_t name;
1211 cmdline_fixed_string_t value;
1215 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1216 __attribute__((unused)) struct cmdline *cl,
1217 __attribute__((unused)) void *data)
1219 struct cmd_config_rx_mode_flag *res = parsed_result;
1221 if (!all_ports_stopped()) {
1222 printf("Please stop all ports first\n");
1226 if (!strcmp(res->name, "crc-strip")) {
1227 if (!strcmp(res->value, "on"))
1228 rx_mode.hw_strip_crc = 1;
1229 else if (!strcmp(res->value, "off"))
1230 rx_mode.hw_strip_crc = 0;
1232 printf("Unknown parameter\n");
1235 } else if (!strcmp(res->name, "rx-cksum")) {
1236 if (!strcmp(res->value, "on"))
1237 rx_mode.hw_ip_checksum = 1;
1238 else if (!strcmp(res->value, "off"))
1239 rx_mode.hw_ip_checksum = 0;
1241 printf("Unknown parameter\n");
1244 } else if (!strcmp(res->name, "hw-vlan")) {
1245 if (!strcmp(res->value, "on")) {
1246 rx_mode.hw_vlan_filter = 1;
1247 rx_mode.hw_vlan_strip = 1;
1249 else if (!strcmp(res->value, "off")) {
1250 rx_mode.hw_vlan_filter = 0;
1251 rx_mode.hw_vlan_strip = 0;
1254 printf("Unknown parameter\n");
1257 } else if (!strcmp(res->name, "drop-en")) {
1258 if (!strcmp(res->value, "on"))
1260 else if (!strcmp(res->value, "off"))
1263 printf("Unknown parameter\n");
1267 printf("Unknown parameter\n");
1273 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1276 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1277 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1278 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1279 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1281 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1282 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1283 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1284 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1285 "crc-strip#rx-cksum#hw-vlan");
1286 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1287 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1290 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1291 .f = cmd_config_rx_mode_flag_parsed,
1293 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1295 (void *)&cmd_config_rx_mode_flag_port,
1296 (void *)&cmd_config_rx_mode_flag_keyword,
1297 (void *)&cmd_config_rx_mode_flag_all,
1298 (void *)&cmd_config_rx_mode_flag_name,
1299 (void *)&cmd_config_rx_mode_flag_value,
1304 /* *** configure rss *** */
1305 struct cmd_config_rss {
1306 cmdline_fixed_string_t port;
1307 cmdline_fixed_string_t keyword;
1308 cmdline_fixed_string_t all;
1309 cmdline_fixed_string_t name;
1310 cmdline_fixed_string_t value;
1314 cmd_config_rss_parsed(void *parsed_result,
1315 __attribute__((unused)) struct cmdline *cl,
1316 __attribute__((unused)) void *data)
1318 struct cmd_config_rss *res = parsed_result;
1319 struct rte_eth_rss_conf rss_conf;
1322 if (!strcmp(res->value, "ip"))
1323 rss_conf.rss_hf = ETH_RSS_IP;
1324 else if (!strcmp(res->value, "udp"))
1325 rss_conf.rss_hf = ETH_RSS_UDP;
1326 else if (!strcmp(res->value, "none"))
1327 rss_conf.rss_hf = 0;
1329 printf("Unknown parameter\n");
1332 rss_conf.rss_key = NULL;
1333 for (i = 0; i < rte_eth_dev_count(); i++)
1334 rte_eth_dev_rss_hash_update(i, &rss_conf);
1337 cmdline_parse_token_string_t cmd_config_rss_port =
1338 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1339 cmdline_parse_token_string_t cmd_config_rss_keyword =
1340 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1341 cmdline_parse_token_string_t cmd_config_rss_all =
1342 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1343 cmdline_parse_token_string_t cmd_config_rss_name =
1344 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1345 cmdline_parse_token_string_t cmd_config_rss_value =
1346 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1348 cmdline_parse_inst_t cmd_config_rss = {
1349 .f = cmd_config_rss_parsed,
1351 .help_str = "port config all rss ip|udp|none",
1353 (void *)&cmd_config_rss_port,
1354 (void *)&cmd_config_rss_keyword,
1355 (void *)&cmd_config_rss_all,
1356 (void *)&cmd_config_rss_name,
1357 (void *)&cmd_config_rss_value,
1362 /* *** configure rss hash key *** */
1363 struct cmd_config_rss_hash_key {
1364 cmdline_fixed_string_t port;
1365 cmdline_fixed_string_t config;
1367 cmdline_fixed_string_t rss_hash_key;
1368 cmdline_fixed_string_t key;
1371 #define RSS_HASH_KEY_LENGTH 40
1373 hexa_digit_to_value(char hexa_digit)
1375 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1376 return (uint8_t) (hexa_digit - '0');
1377 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1378 return (uint8_t) ((hexa_digit - 'a') + 10);
1379 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1380 return (uint8_t) ((hexa_digit - 'A') + 10);
1381 /* Invalid hexa digit */
1386 parse_and_check_key_hexa_digit(char *key, int idx)
1390 hexa_v = hexa_digit_to_value(key[idx]);
1392 printf("invalid key: character %c at position %d is not a "
1393 "valid hexa digit\n", key[idx], idx);
1398 cmd_config_rss_hash_key_parsed(void *parsed_result,
1399 __attribute__((unused)) struct cmdline *cl,
1400 __attribute__((unused)) void *data)
1402 struct cmd_config_rss_hash_key *res = parsed_result;
1403 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1408 /* Check the length of the RSS hash key */
1409 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1410 printf("key length: %d invalid - key must be a string of %d"
1411 "hexa-decimal numbers\n", (int) strlen(res->key),
1412 RSS_HASH_KEY_LENGTH * 2);
1415 /* Translate RSS hash key into binary representation */
1416 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1417 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1420 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1423 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1425 port_rss_hash_key_update(res->port_id, hash_key);
1428 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1429 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1430 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1431 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1433 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1434 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1435 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1436 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1437 rss_hash_key, "rss-hash-key");
1438 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1439 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1441 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1442 .f = cmd_config_rss_hash_key_parsed,
1444 .help_str = "port config X rss-hash-key 80 hexa digits",
1446 (void *)&cmd_config_rss_hash_key_port,
1447 (void *)&cmd_config_rss_hash_key_config,
1448 (void *)&cmd_config_rss_hash_key_port_id,
1449 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1450 (void *)&cmd_config_rss_hash_key_value,
1455 /* *** configure port rxq/txq start/stop *** */
1456 struct cmd_config_rxtx_queue {
1457 cmdline_fixed_string_t port;
1459 cmdline_fixed_string_t rxtxq;
1461 cmdline_fixed_string_t opname;
1465 cmd_config_rxtx_queue_parsed(void *parsed_result,
1466 __attribute__((unused)) struct cmdline *cl,
1467 __attribute__((unused)) void *data)
1469 struct cmd_config_rxtx_queue *res = parsed_result;
1474 if (test_done == 0) {
1475 printf("Please stop forwarding first\n");
1479 if (port_id_is_invalid(res->portid))
1482 if (port_is_started(res->portid) != 1) {
1483 printf("Please start port %u first\n", res->portid);
1487 if (!strcmp(res->rxtxq, "rxq"))
1489 else if (!strcmp(res->rxtxq, "txq"))
1492 printf("Unknown parameter\n");
1496 if (isrx && rx_queue_id_is_invalid(res->qid))
1498 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1501 if (!strcmp(res->opname, "start"))
1503 else if (!strcmp(res->opname, "stop"))
1506 printf("Unknown parameter\n");
1510 if (isstart && isrx)
1511 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1512 else if (!isstart && isrx)
1513 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1514 else if (isstart && !isrx)
1515 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1517 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1519 if (ret == -ENOTSUP)
1520 printf("Function not supported in PMD driver\n");
1523 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1524 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1525 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1526 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1527 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1528 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1529 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1530 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1531 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1532 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1535 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1536 .f = cmd_config_rxtx_queue_parsed,
1538 .help_str = "port X rxq|txq ID start|stop",
1540 (void *)&cmd_config_speed_all_port,
1541 (void *)&cmd_config_rxtx_queue_portid,
1542 (void *)&cmd_config_rxtx_queue_rxtxq,
1543 (void *)&cmd_config_rxtx_queue_qid,
1544 (void *)&cmd_config_rxtx_queue_opname,
1549 /* *** Configure RSS RETA *** */
1550 struct cmd_config_rss_reta {
1551 cmdline_fixed_string_t port;
1552 cmdline_fixed_string_t keyword;
1554 cmdline_fixed_string_t name;
1555 cmdline_fixed_string_t list_name;
1556 cmdline_fixed_string_t list_of_items;
1560 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1567 const char *p, *p0 = str;
1574 unsigned long int_fld[_NUM_FLD];
1575 char *str_fld[_NUM_FLD];
1577 while ((p = strchr(p0,'(')) != NULL) {
1579 if((p0 = strchr(p,')')) == NULL)
1583 if(size >= sizeof(s))
1586 snprintf(s, sizeof(s), "%.*s", size, p);
1587 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1589 for (i = 0; i < _NUM_FLD; i++) {
1591 int_fld[i] = strtoul(str_fld[i], &end, 0);
1592 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1596 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1597 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1599 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1600 printf("Invalid RETA hash index=%d",hash_index);
1604 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1605 reta_conf->mask_lo |= (1ULL << hash_index);
1607 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1609 reta_conf->reta[hash_index] = nb_queue;
1616 cmd_set_rss_reta_parsed(void *parsed_result,
1617 __attribute__((unused)) struct cmdline *cl,
1618 __attribute__((unused)) void *data)
1621 struct rte_eth_rss_reta reta_conf;
1622 struct cmd_config_rss_reta *res = parsed_result;
1624 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1625 if (!strcmp(res->list_name, "reta")) {
1626 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1627 printf("Invalid RSS Redirection Table config entered\n");
1630 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1632 printf("Bad redirection table parameter, return code = %d \n",ret);
1636 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1638 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1639 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1640 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1641 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1642 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1644 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1645 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1646 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1649 cmdline_parse_inst_t cmd_config_rss_reta = {
1650 .f = cmd_set_rss_reta_parsed,
1652 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1654 (void *)&cmd_config_rss_reta_port,
1655 (void *)&cmd_config_rss_reta_keyword,
1656 (void *)&cmd_config_rss_reta_port_id,
1657 (void *)&cmd_config_rss_reta_name,
1658 (void *)&cmd_config_rss_reta_list_name,
1659 (void *)&cmd_config_rss_reta_list_of_items,
1664 /* *** SHOW PORT RETA INFO *** */
1665 struct cmd_showport_reta {
1666 cmdline_fixed_string_t show;
1667 cmdline_fixed_string_t port;
1669 cmdline_fixed_string_t rss;
1670 cmdline_fixed_string_t reta;
1675 static void cmd_showport_reta_parsed(void *parsed_result,
1676 __attribute__((unused)) struct cmdline *cl,
1677 __attribute__((unused)) void *data)
1679 struct cmd_showport_reta *res = parsed_result;
1680 struct rte_eth_rss_reta reta_conf;
1682 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1683 printf("Invalid RSS Redirection Table config entered\n");
1687 reta_conf.mask_lo = res->mask_lo;
1688 reta_conf.mask_hi = res->mask_hi;
1690 port_rss_reta_info(res->port_id,&reta_conf);
1693 cmdline_parse_token_string_t cmd_showport_reta_show =
1694 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1695 cmdline_parse_token_string_t cmd_showport_reta_port =
1696 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1697 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1698 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1699 cmdline_parse_token_string_t cmd_showport_reta_rss =
1700 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1701 cmdline_parse_token_string_t cmd_showport_reta_reta =
1702 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1703 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1704 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1705 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1706 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1708 cmdline_parse_inst_t cmd_showport_reta = {
1709 .f = cmd_showport_reta_parsed,
1711 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1712 (mask_lo and mask_hi is UINT64)",
1714 (void *)&cmd_showport_reta_show,
1715 (void *)&cmd_showport_reta_port,
1716 (void *)&cmd_showport_reta_port_id,
1717 (void *)&cmd_showport_reta_rss,
1718 (void *)&cmd_showport_reta_reta,
1719 (void *)&cmd_showport_reta_mask_lo,
1720 (void *)&cmd_showport_reta_mask_hi,
1725 /* *** Show RSS hash configuration *** */
1726 struct cmd_showport_rss_hash {
1727 cmdline_fixed_string_t show;
1728 cmdline_fixed_string_t port;
1730 cmdline_fixed_string_t rss_hash;
1731 cmdline_fixed_string_t key; /* optional argument */
1734 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1735 __attribute__((unused)) struct cmdline *cl,
1738 struct cmd_showport_rss_hash *res = parsed_result;
1740 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1743 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1744 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1745 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1746 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1747 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1748 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1749 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1750 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1752 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1753 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1755 cmdline_parse_inst_t cmd_showport_rss_hash = {
1756 .f = cmd_showport_rss_hash_parsed,
1758 .help_str = "show port X rss-hash (X = port number)\n",
1760 (void *)&cmd_showport_rss_hash_show,
1761 (void *)&cmd_showport_rss_hash_port,
1762 (void *)&cmd_showport_rss_hash_port_id,
1763 (void *)&cmd_showport_rss_hash_rss_hash,
1768 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1769 .f = cmd_showport_rss_hash_parsed,
1771 .help_str = "show port X rss-hash key (X = port number)\n",
1773 (void *)&cmd_showport_rss_hash_show,
1774 (void *)&cmd_showport_rss_hash_port,
1775 (void *)&cmd_showport_rss_hash_port_id,
1776 (void *)&cmd_showport_rss_hash_rss_hash,
1777 (void *)&cmd_showport_rss_hash_rss_key,
1782 /* *** Configure DCB *** */
1783 struct cmd_config_dcb {
1784 cmdline_fixed_string_t port;
1785 cmdline_fixed_string_t config;
1787 cmdline_fixed_string_t dcb;
1788 cmdline_fixed_string_t vt;
1789 cmdline_fixed_string_t vt_en;
1791 cmdline_fixed_string_t pfc;
1792 cmdline_fixed_string_t pfc_en;
1796 cmd_config_dcb_parsed(void *parsed_result,
1797 __attribute__((unused)) struct cmdline *cl,
1798 __attribute__((unused)) void *data)
1800 struct cmd_config_dcb *res = parsed_result;
1801 struct dcb_config dcb_conf;
1802 portid_t port_id = res->port_id;
1803 struct rte_port *port;
1805 port = &ports[port_id];
1806 /** Check if the port is not started **/
1807 if (port->port_status != RTE_PORT_STOPPED) {
1808 printf("Please stop port %d first\n",port_id);
1812 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1813 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1814 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1818 /* DCB in VT mode */
1819 if (!strncmp(res->vt_en, "on",2))
1820 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1822 dcb_conf.dcb_mode = DCB_ENABLED;
1824 if (!strncmp(res->pfc_en, "on",2)) {
1825 dcb_conf.pfc_en = 1;
1828 dcb_conf.pfc_en = 0;
1830 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1831 printf("Cannot initialize network ports\n");
1835 cmd_reconfig_device_queue(port_id, 1, 1);
1838 cmdline_parse_token_string_t cmd_config_dcb_port =
1839 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1840 cmdline_parse_token_string_t cmd_config_dcb_config =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1842 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1843 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1844 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1845 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1846 cmdline_parse_token_string_t cmd_config_dcb_vt =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1848 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1850 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1851 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1852 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1853 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1854 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1857 cmdline_parse_inst_t cmd_config_dcb = {
1858 .f = cmd_config_dcb_parsed,
1860 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1862 (void *)&cmd_config_dcb_port,
1863 (void *)&cmd_config_dcb_config,
1864 (void *)&cmd_config_dcb_port_id,
1865 (void *)&cmd_config_dcb_dcb,
1866 (void *)&cmd_config_dcb_vt,
1867 (void *)&cmd_config_dcb_vt_en,
1868 (void *)&cmd_config_dcb_num_tcs,
1869 (void *)&cmd_config_dcb_pfc,
1870 (void *)&cmd_config_dcb_pfc_en,
1875 /* *** configure number of packets per burst *** */
1876 struct cmd_config_burst {
1877 cmdline_fixed_string_t port;
1878 cmdline_fixed_string_t keyword;
1879 cmdline_fixed_string_t all;
1880 cmdline_fixed_string_t name;
1885 cmd_config_burst_parsed(void *parsed_result,
1886 __attribute__((unused)) struct cmdline *cl,
1887 __attribute__((unused)) void *data)
1889 struct cmd_config_burst *res = parsed_result;
1891 if (!all_ports_stopped()) {
1892 printf("Please stop all ports first\n");
1896 if (!strcmp(res->name, "burst")) {
1897 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1898 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1901 nb_pkt_per_burst = res->value;
1903 printf("Unknown parameter\n");
1909 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1912 cmdline_parse_token_string_t cmd_config_burst_port =
1913 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1914 cmdline_parse_token_string_t cmd_config_burst_keyword =
1915 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1916 cmdline_parse_token_string_t cmd_config_burst_all =
1917 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1918 cmdline_parse_token_string_t cmd_config_burst_name =
1919 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1920 cmdline_parse_token_num_t cmd_config_burst_value =
1921 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1923 cmdline_parse_inst_t cmd_config_burst = {
1924 .f = cmd_config_burst_parsed,
1926 .help_str = "port config all burst value",
1928 (void *)&cmd_config_burst_port,
1929 (void *)&cmd_config_burst_keyword,
1930 (void *)&cmd_config_burst_all,
1931 (void *)&cmd_config_burst_name,
1932 (void *)&cmd_config_burst_value,
1937 /* *** configure rx/tx queues *** */
1938 struct cmd_config_thresh {
1939 cmdline_fixed_string_t port;
1940 cmdline_fixed_string_t keyword;
1941 cmdline_fixed_string_t all;
1942 cmdline_fixed_string_t name;
1947 cmd_config_thresh_parsed(void *parsed_result,
1948 __attribute__((unused)) struct cmdline *cl,
1949 __attribute__((unused)) void *data)
1951 struct cmd_config_thresh *res = parsed_result;
1953 if (!all_ports_stopped()) {
1954 printf("Please stop all ports first\n");
1958 if (!strcmp(res->name, "txpt"))
1959 tx_thresh.pthresh = res->value;
1960 else if(!strcmp(res->name, "txht"))
1961 tx_thresh.hthresh = res->value;
1962 else if(!strcmp(res->name, "txwt"))
1963 tx_thresh.wthresh = res->value;
1964 else if(!strcmp(res->name, "rxpt"))
1965 rx_thresh.pthresh = res->value;
1966 else if(!strcmp(res->name, "rxht"))
1967 rx_thresh.hthresh = res->value;
1968 else if(!strcmp(res->name, "rxwt"))
1969 rx_thresh.wthresh = res->value;
1971 printf("Unknown parameter\n");
1977 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1980 cmdline_parse_token_string_t cmd_config_thresh_port =
1981 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1982 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1983 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1984 cmdline_parse_token_string_t cmd_config_thresh_all =
1985 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1986 cmdline_parse_token_string_t cmd_config_thresh_name =
1987 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1988 "txpt#txht#txwt#rxpt#rxht#rxwt");
1989 cmdline_parse_token_num_t cmd_config_thresh_value =
1990 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1992 cmdline_parse_inst_t cmd_config_thresh = {
1993 .f = cmd_config_thresh_parsed,
1995 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1997 (void *)&cmd_config_thresh_port,
1998 (void *)&cmd_config_thresh_keyword,
1999 (void *)&cmd_config_thresh_all,
2000 (void *)&cmd_config_thresh_name,
2001 (void *)&cmd_config_thresh_value,
2006 /* *** configure free/rs threshold *** */
2007 struct cmd_config_threshold {
2008 cmdline_fixed_string_t port;
2009 cmdline_fixed_string_t keyword;
2010 cmdline_fixed_string_t all;
2011 cmdline_fixed_string_t name;
2016 cmd_config_threshold_parsed(void *parsed_result,
2017 __attribute__((unused)) struct cmdline *cl,
2018 __attribute__((unused)) void *data)
2020 struct cmd_config_threshold *res = parsed_result;
2022 if (!all_ports_stopped()) {
2023 printf("Please stop all ports first\n");
2027 if (!strcmp(res->name, "txfreet"))
2028 tx_free_thresh = res->value;
2029 else if (!strcmp(res->name, "txrst"))
2030 tx_rs_thresh = res->value;
2031 else if (!strcmp(res->name, "rxfreet"))
2032 rx_free_thresh = res->value;
2034 printf("Unknown parameter\n");
2040 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2043 cmdline_parse_token_string_t cmd_config_threshold_port =
2044 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2045 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2046 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2048 cmdline_parse_token_string_t cmd_config_threshold_all =
2049 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2050 cmdline_parse_token_string_t cmd_config_threshold_name =
2051 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2052 "txfreet#txrst#rxfreet");
2053 cmdline_parse_token_num_t cmd_config_threshold_value =
2054 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2056 cmdline_parse_inst_t cmd_config_threshold = {
2057 .f = cmd_config_threshold_parsed,
2059 .help_str = "port config all txfreet|txrst|rxfreet value",
2061 (void *)&cmd_config_threshold_port,
2062 (void *)&cmd_config_threshold_keyword,
2063 (void *)&cmd_config_threshold_all,
2064 (void *)&cmd_config_threshold_name,
2065 (void *)&cmd_config_threshold_value,
2071 struct cmd_stop_result {
2072 cmdline_fixed_string_t stop;
2075 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2076 __attribute__((unused)) struct cmdline *cl,
2077 __attribute__((unused)) void *data)
2079 stop_packet_forwarding();
2082 cmdline_parse_token_string_t cmd_stop_stop =
2083 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2085 cmdline_parse_inst_t cmd_stop = {
2086 .f = cmd_stop_parsed,
2088 .help_str = "stop - stop packet forwarding",
2090 (void *)&cmd_stop_stop,
2095 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2098 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2099 unsigned int *parsed_items, int check_unique_values)
2101 unsigned int nb_item;
2109 * First parse all items in the list and store their value.
2114 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2116 if ((c >= '0') && (c <= '9')) {
2117 value = (unsigned int) (value * 10 + (c - '0'));
2122 printf("character %c is not a decimal digit\n", c);
2126 printf("No valid value before comma\n");
2129 if (nb_item < max_items) {
2130 parsed_items[nb_item] = value;
2136 if (nb_item >= max_items) {
2137 printf("Number of %s = %u > %u (maximum items)\n",
2138 item_name, nb_item + 1, max_items);
2141 parsed_items[nb_item++] = value;
2142 if (! check_unique_values)
2146 * Then, check that all values in the list are differents.
2147 * No optimization here...
2149 for (i = 0; i < nb_item; i++) {
2150 for (j = i + 1; j < nb_item; j++) {
2151 if (parsed_items[j] == parsed_items[i]) {
2152 printf("duplicated %s %u at index %u and %u\n",
2153 item_name, parsed_items[i], i, j);
2161 struct cmd_set_list_result {
2162 cmdline_fixed_string_t cmd_keyword;
2163 cmdline_fixed_string_t list_name;
2164 cmdline_fixed_string_t list_of_items;
2167 static void cmd_set_list_parsed(void *parsed_result,
2168 __attribute__((unused)) struct cmdline *cl,
2169 __attribute__((unused)) void *data)
2171 struct cmd_set_list_result *res;
2173 unsigned int lcorelist[RTE_MAX_LCORE];
2174 unsigned int portlist[RTE_MAX_ETHPORTS];
2176 unsigned int nb_item;
2178 res = parsed_result;
2179 if (!strcmp(res->list_name, "corelist")) {
2180 nb_item = parse_item_list(res->list_of_items, "core",
2182 parsed_items.lcorelist, 1);
2184 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2187 if (!strcmp(res->list_name, "portlist")) {
2188 nb_item = parse_item_list(res->list_of_items, "port",
2190 parsed_items.portlist, 1);
2192 set_fwd_ports_list(parsed_items.portlist, nb_item);
2196 cmdline_parse_token_string_t cmd_set_list_keyword =
2197 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2199 cmdline_parse_token_string_t cmd_set_list_name =
2200 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2201 "corelist#portlist");
2202 cmdline_parse_token_string_t cmd_set_list_of_items =
2203 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2206 cmdline_parse_inst_t cmd_set_fwd_list = {
2207 .f = cmd_set_list_parsed,
2209 .help_str = "set corelist|portlist x[,y]*",
2211 (void *)&cmd_set_list_keyword,
2212 (void *)&cmd_set_list_name,
2213 (void *)&cmd_set_list_of_items,
2218 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2220 struct cmd_setmask_result {
2221 cmdline_fixed_string_t set;
2222 cmdline_fixed_string_t mask;
2226 static void cmd_set_mask_parsed(void *parsed_result,
2227 __attribute__((unused)) struct cmdline *cl,
2228 __attribute__((unused)) void *data)
2230 struct cmd_setmask_result *res = parsed_result;
2232 if (!strcmp(res->mask, "coremask"))
2233 set_fwd_lcores_mask(res->hexavalue);
2234 else if (!strcmp(res->mask, "portmask"))
2235 set_fwd_ports_mask(res->hexavalue);
2238 cmdline_parse_token_string_t cmd_setmask_set =
2239 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2240 cmdline_parse_token_string_t cmd_setmask_mask =
2241 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2242 "coremask#portmask");
2243 cmdline_parse_token_num_t cmd_setmask_value =
2244 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2246 cmdline_parse_inst_t cmd_set_fwd_mask = {
2247 .f = cmd_set_mask_parsed,
2249 .help_str = "set coremask|portmask hexadecimal value",
2251 (void *)&cmd_setmask_set,
2252 (void *)&cmd_setmask_mask,
2253 (void *)&cmd_setmask_value,
2259 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2261 struct cmd_set_result {
2262 cmdline_fixed_string_t set;
2263 cmdline_fixed_string_t what;
2267 static void cmd_set_parsed(void *parsed_result,
2268 __attribute__((unused)) struct cmdline *cl,
2269 __attribute__((unused)) void *data)
2271 struct cmd_set_result *res = parsed_result;
2272 if (!strcmp(res->what, "nbport"))
2273 set_fwd_ports_number(res->value);
2274 else if (!strcmp(res->what, "nbcore"))
2275 set_fwd_lcores_number(res->value);
2276 else if (!strcmp(res->what, "burst"))
2277 set_nb_pkt_per_burst(res->value);
2278 else if (!strcmp(res->what, "verbose"))
2279 set_verbose_level(res->value);
2282 cmdline_parse_token_string_t cmd_set_set =
2283 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2284 cmdline_parse_token_string_t cmd_set_what =
2285 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2286 "nbport#nbcore#burst#verbose");
2287 cmdline_parse_token_num_t cmd_set_value =
2288 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2290 cmdline_parse_inst_t cmd_set_numbers = {
2291 .f = cmd_set_parsed,
2293 .help_str = "set nbport|nbcore|burst|verbose value",
2295 (void *)&cmd_set_set,
2296 (void *)&cmd_set_what,
2297 (void *)&cmd_set_value,
2302 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2304 struct cmd_set_txpkts_result {
2305 cmdline_fixed_string_t cmd_keyword;
2306 cmdline_fixed_string_t txpkts;
2307 cmdline_fixed_string_t seg_lengths;
2311 cmd_set_txpkts_parsed(void *parsed_result,
2312 __attribute__((unused)) struct cmdline *cl,
2313 __attribute__((unused)) void *data)
2315 struct cmd_set_txpkts_result *res;
2316 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2317 unsigned int nb_segs;
2319 res = parsed_result;
2320 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2321 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2323 set_tx_pkt_segments(seg_lengths, nb_segs);
2326 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2327 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2328 cmd_keyword, "set");
2329 cmdline_parse_token_string_t cmd_set_txpkts_name =
2330 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2332 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2333 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2336 cmdline_parse_inst_t cmd_set_txpkts = {
2337 .f = cmd_set_txpkts_parsed,
2339 .help_str = "set txpkts x[,y]*",
2341 (void *)&cmd_set_txpkts_keyword,
2342 (void *)&cmd_set_txpkts_name,
2343 (void *)&cmd_set_txpkts_lengths,
2348 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2349 struct cmd_rx_vlan_filter_all_result {
2350 cmdline_fixed_string_t rx_vlan;
2351 cmdline_fixed_string_t what;
2352 cmdline_fixed_string_t all;
2357 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2358 __attribute__((unused)) struct cmdline *cl,
2359 __attribute__((unused)) void *data)
2361 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2363 if (!strcmp(res->what, "add"))
2364 rx_vlan_all_filter_set(res->port_id, 1);
2366 rx_vlan_all_filter_set(res->port_id, 0);
2369 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2370 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2371 rx_vlan, "rx_vlan");
2372 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2373 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2375 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2376 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2378 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2379 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2382 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2383 .f = cmd_rx_vlan_filter_all_parsed,
2385 .help_str = "add/remove all identifiers to/from the set of VLAN "
2386 "Identifiers filtered by a port",
2388 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2389 (void *)&cmd_rx_vlan_filter_all_what,
2390 (void *)&cmd_rx_vlan_filter_all_all,
2391 (void *)&cmd_rx_vlan_filter_all_portid,
2396 /* *** VLAN OFFLOAD SET ON A PORT *** */
2397 struct cmd_vlan_offload_result {
2398 cmdline_fixed_string_t vlan;
2399 cmdline_fixed_string_t set;
2400 cmdline_fixed_string_t what;
2401 cmdline_fixed_string_t on;
2402 cmdline_fixed_string_t port_id;
2406 cmd_vlan_offload_parsed(void *parsed_result,
2407 __attribute__((unused)) struct cmdline *cl,
2408 __attribute__((unused)) void *data)
2411 struct cmd_vlan_offload_result *res = parsed_result;
2414 portid_t port_id = 0;
2418 len = strnlen(str, STR_TOKEN_SIZE);
2420 /* Get port_id first */
2428 tmp = strtoul(str, NULL, 0);
2429 /* If port_id greater that what portid_t can represent, return */
2430 if(tmp >= RTE_MAX_ETHPORTS)
2432 port_id = (portid_t)tmp;
2434 if (!strcmp(res->on, "on"))
2439 if (!strcmp(res->what, "strip"))
2440 rx_vlan_strip_set(port_id, on);
2441 else if(!strcmp(res->what, "stripq")){
2442 uint16_t queue_id = 0;
2444 /* No queue_id, return */
2446 printf("must specify (port,queue_id)\n");
2449 tmp = strtoul(str + i + 1, NULL, 0);
2450 /* If queue_id greater that what 16-bits can represent, return */
2454 queue_id = (uint16_t)tmp;
2455 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2457 else if (!strcmp(res->what, "filter"))
2458 rx_vlan_filter_set(port_id, on);
2460 vlan_extend_set(port_id, on);
2465 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2466 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2468 cmdline_parse_token_string_t cmd_vlan_offload_set =
2469 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2471 cmdline_parse_token_string_t cmd_vlan_offload_what =
2472 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2473 what, "strip#filter#qinq#stripq");
2474 cmdline_parse_token_string_t cmd_vlan_offload_on =
2475 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2477 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2478 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2481 cmdline_parse_inst_t cmd_vlan_offload = {
2482 .f = cmd_vlan_offload_parsed,
2484 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2485 " qinq(extended) for both rx/tx sides ",
2487 (void *)&cmd_vlan_offload_vlan,
2488 (void *)&cmd_vlan_offload_set,
2489 (void *)&cmd_vlan_offload_what,
2490 (void *)&cmd_vlan_offload_on,
2491 (void *)&cmd_vlan_offload_portid,
2496 /* *** VLAN TPID SET ON A PORT *** */
2497 struct cmd_vlan_tpid_result {
2498 cmdline_fixed_string_t vlan;
2499 cmdline_fixed_string_t set;
2500 cmdline_fixed_string_t what;
2506 cmd_vlan_tpid_parsed(void *parsed_result,
2507 __attribute__((unused)) struct cmdline *cl,
2508 __attribute__((unused)) void *data)
2510 struct cmd_vlan_tpid_result *res = parsed_result;
2511 vlan_tpid_set(res->port_id, res->tp_id);
2515 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2516 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2518 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2519 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2521 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2522 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2524 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2525 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2527 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2528 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2531 cmdline_parse_inst_t cmd_vlan_tpid = {
2532 .f = cmd_vlan_tpid_parsed,
2534 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2536 (void *)&cmd_vlan_tpid_vlan,
2537 (void *)&cmd_vlan_tpid_set,
2538 (void *)&cmd_vlan_tpid_what,
2539 (void *)&cmd_vlan_tpid_tpid,
2540 (void *)&cmd_vlan_tpid_portid,
2545 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2546 struct cmd_rx_vlan_filter_result {
2547 cmdline_fixed_string_t rx_vlan;
2548 cmdline_fixed_string_t what;
2554 cmd_rx_vlan_filter_parsed(void *parsed_result,
2555 __attribute__((unused)) struct cmdline *cl,
2556 __attribute__((unused)) void *data)
2558 struct cmd_rx_vlan_filter_result *res = parsed_result;
2560 if (!strcmp(res->what, "add"))
2561 rx_vft_set(res->port_id, res->vlan_id, 1);
2563 rx_vft_set(res->port_id, res->vlan_id, 0);
2566 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2567 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2568 rx_vlan, "rx_vlan");
2569 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2570 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2572 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2573 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2575 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2576 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2579 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2580 .f = cmd_rx_vlan_filter_parsed,
2582 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2583 "Identifiers filtered by a port",
2585 (void *)&cmd_rx_vlan_filter_rx_vlan,
2586 (void *)&cmd_rx_vlan_filter_what,
2587 (void *)&cmd_rx_vlan_filter_vlanid,
2588 (void *)&cmd_rx_vlan_filter_portid,
2593 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2594 struct cmd_tx_vlan_set_result {
2595 cmdline_fixed_string_t tx_vlan;
2596 cmdline_fixed_string_t set;
2602 cmd_tx_vlan_set_parsed(void *parsed_result,
2603 __attribute__((unused)) struct cmdline *cl,
2604 __attribute__((unused)) void *data)
2606 struct cmd_tx_vlan_set_result *res = parsed_result;
2607 tx_vlan_set(res->port_id, res->vlan_id);
2610 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2611 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2612 tx_vlan, "tx_vlan");
2613 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2614 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2616 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2617 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2619 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2620 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2623 cmdline_parse_inst_t cmd_tx_vlan_set = {
2624 .f = cmd_tx_vlan_set_parsed,
2626 .help_str = "enable hardware insertion of a VLAN header with a given "
2627 "TAG Identifier in packets sent on a port",
2629 (void *)&cmd_tx_vlan_set_tx_vlan,
2630 (void *)&cmd_tx_vlan_set_set,
2631 (void *)&cmd_tx_vlan_set_vlanid,
2632 (void *)&cmd_tx_vlan_set_portid,
2637 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2638 struct cmd_tx_vlan_set_pvid_result {
2639 cmdline_fixed_string_t tx_vlan;
2640 cmdline_fixed_string_t set;
2641 cmdline_fixed_string_t pvid;
2644 cmdline_fixed_string_t mode;
2648 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2649 __attribute__((unused)) struct cmdline *cl,
2650 __attribute__((unused)) void *data)
2652 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2654 if (strcmp(res->mode, "on") == 0)
2655 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2657 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2660 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2661 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2662 tx_vlan, "tx_vlan");
2663 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2664 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2666 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2667 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2669 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2670 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2672 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2673 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2675 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2676 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2679 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2680 .f = cmd_tx_vlan_set_pvid_parsed,
2682 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2684 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2685 (void *)&cmd_tx_vlan_set_pvid_set,
2686 (void *)&cmd_tx_vlan_set_pvid_pvid,
2687 (void *)&cmd_tx_vlan_set_pvid_port_id,
2688 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2689 (void *)&cmd_tx_vlan_set_pvid_mode,
2694 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2695 struct cmd_tx_vlan_reset_result {
2696 cmdline_fixed_string_t tx_vlan;
2697 cmdline_fixed_string_t reset;
2702 cmd_tx_vlan_reset_parsed(void *parsed_result,
2703 __attribute__((unused)) struct cmdline *cl,
2704 __attribute__((unused)) void *data)
2706 struct cmd_tx_vlan_reset_result *res = parsed_result;
2708 tx_vlan_reset(res->port_id);
2711 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2712 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2713 tx_vlan, "tx_vlan");
2714 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2715 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2717 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2718 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2721 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2722 .f = cmd_tx_vlan_reset_parsed,
2724 .help_str = "disable hardware insertion of a VLAN header in packets "
2727 (void *)&cmd_tx_vlan_reset_tx_vlan,
2728 (void *)&cmd_tx_vlan_reset_reset,
2729 (void *)&cmd_tx_vlan_reset_portid,
2735 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2736 struct cmd_tx_cksum_set_result {
2737 cmdline_fixed_string_t tx_cksum;
2738 cmdline_fixed_string_t set;
2744 cmd_tx_cksum_set_parsed(void *parsed_result,
2745 __attribute__((unused)) struct cmdline *cl,
2746 __attribute__((unused)) void *data)
2748 struct cmd_tx_cksum_set_result *res = parsed_result;
2750 tx_cksum_set(res->port_id, res->cksum_mask);
2753 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2754 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2755 tx_cksum, "tx_checksum");
2756 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2757 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2759 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2760 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2762 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2763 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2766 cmdline_parse_inst_t cmd_tx_cksum_set = {
2767 .f = cmd_tx_cksum_set_parsed,
2769 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2770 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip, "
2771 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip, "
2772 "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
2774 (void *)&cmd_tx_cksum_set_tx_cksum,
2775 (void *)&cmd_tx_cksum_set_set,
2776 (void *)&cmd_tx_cksum_set_cksum_mask,
2777 (void *)&cmd_tx_cksum_set_portid,
2782 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2783 struct cmd_set_flush_rx {
2784 cmdline_fixed_string_t set;
2785 cmdline_fixed_string_t flush_rx;
2786 cmdline_fixed_string_t mode;
2790 cmd_set_flush_rx_parsed(void *parsed_result,
2791 __attribute__((unused)) struct cmdline *cl,
2792 __attribute__((unused)) void *data)
2794 struct cmd_set_flush_rx *res = parsed_result;
2795 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2798 cmdline_parse_token_string_t cmd_setflushrx_set =
2799 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2801 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2802 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2803 flush_rx, "flush_rx");
2804 cmdline_parse_token_string_t cmd_setflushrx_mode =
2805 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2809 cmdline_parse_inst_t cmd_set_flush_rx = {
2810 .f = cmd_set_flush_rx_parsed,
2811 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2814 (void *)&cmd_setflushrx_set,
2815 (void *)&cmd_setflushrx_flush_rx,
2816 (void *)&cmd_setflushrx_mode,
2821 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2822 struct cmd_set_link_check {
2823 cmdline_fixed_string_t set;
2824 cmdline_fixed_string_t link_check;
2825 cmdline_fixed_string_t mode;
2829 cmd_set_link_check_parsed(void *parsed_result,
2830 __attribute__((unused)) struct cmdline *cl,
2831 __attribute__((unused)) void *data)
2833 struct cmd_set_link_check *res = parsed_result;
2834 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2837 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2838 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2840 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2841 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2842 link_check, "link_check");
2843 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2844 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2848 cmdline_parse_inst_t cmd_set_link_check = {
2849 .f = cmd_set_link_check_parsed,
2850 .help_str = "set link_check on|off: enable/disable link status check "
2851 "when starting/stopping a port",
2854 (void *)&cmd_setlinkcheck_set,
2855 (void *)&cmd_setlinkcheck_link_check,
2856 (void *)&cmd_setlinkcheck_mode,
2861 #ifdef RTE_NIC_BYPASS
2862 /* *** SET NIC BYPASS MODE *** */
2863 struct cmd_set_bypass_mode_result {
2864 cmdline_fixed_string_t set;
2865 cmdline_fixed_string_t bypass;
2866 cmdline_fixed_string_t mode;
2867 cmdline_fixed_string_t value;
2872 cmd_set_bypass_mode_parsed(void *parsed_result,
2873 __attribute__((unused)) struct cmdline *cl,
2874 __attribute__((unused)) void *data)
2876 struct cmd_set_bypass_mode_result *res = parsed_result;
2877 portid_t port_id = res->port_id;
2878 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2880 if (!bypass_is_supported(port_id))
2883 if (!strcmp(res->value, "bypass"))
2884 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2885 else if (!strcmp(res->value, "isolate"))
2886 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2888 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2890 /* Set the bypass mode for the relevant port. */
2891 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2892 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2896 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2897 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2899 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2900 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2902 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2903 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2905 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2906 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2907 value, "normal#bypass#isolate");
2908 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2909 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2912 cmdline_parse_inst_t cmd_set_bypass_mode = {
2913 .f = cmd_set_bypass_mode_parsed,
2914 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2915 "Set the NIC bypass mode for port_id",
2918 (void *)&cmd_setbypass_mode_set,
2919 (void *)&cmd_setbypass_mode_bypass,
2920 (void *)&cmd_setbypass_mode_mode,
2921 (void *)&cmd_setbypass_mode_value,
2922 (void *)&cmd_setbypass_mode_port,
2927 /* *** SET NIC BYPASS EVENT *** */
2928 struct cmd_set_bypass_event_result {
2929 cmdline_fixed_string_t set;
2930 cmdline_fixed_string_t bypass;
2931 cmdline_fixed_string_t event;
2932 cmdline_fixed_string_t event_value;
2933 cmdline_fixed_string_t mode;
2934 cmdline_fixed_string_t mode_value;
2939 cmd_set_bypass_event_parsed(void *parsed_result,
2940 __attribute__((unused)) struct cmdline *cl,
2941 __attribute__((unused)) void *data)
2944 struct cmd_set_bypass_event_result *res = parsed_result;
2945 portid_t port_id = res->port_id;
2946 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2947 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2949 if (!bypass_is_supported(port_id))
2952 if (!strcmp(res->event_value, "timeout"))
2953 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2954 else if (!strcmp(res->event_value, "os_on"))
2955 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2956 else if (!strcmp(res->event_value, "os_off"))
2957 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2958 else if (!strcmp(res->event_value, "power_on"))
2959 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2960 else if (!strcmp(res->event_value, "power_off"))
2961 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2963 bypass_event = RTE_BYPASS_EVENT_NONE;
2965 if (!strcmp(res->mode_value, "bypass"))
2966 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2967 else if (!strcmp(res->mode_value, "isolate"))
2968 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2970 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2972 /* Set the watchdog timeout. */
2973 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2976 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2977 (rc = rte_eth_dev_wd_timeout_store(port_id,
2978 bypass_timeout)) != 0) {
2979 printf("Failed to set timeout value %u "
2980 "for port %d, errto code: %d.\n",
2981 bypass_timeout, port_id, rc);
2985 /* Set the bypass event to transition to bypass mode. */
2986 if (0 != rte_eth_dev_bypass_event_store(port_id,
2987 bypass_event, bypass_mode)) {
2988 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2993 cmdline_parse_token_string_t cmd_setbypass_event_set =
2994 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2996 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2997 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2999 cmdline_parse_token_string_t cmd_setbypass_event_event =
3000 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3002 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3003 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3004 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3005 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3006 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3008 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3009 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3010 mode_value, "normal#bypass#isolate");
3011 cmdline_parse_token_num_t cmd_setbypass_event_port =
3012 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3015 cmdline_parse_inst_t cmd_set_bypass_event = {
3016 .f = cmd_set_bypass_event_parsed,
3017 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3018 "mode (normal|bypass|isolate) (port_id): "
3019 "Set the NIC bypass event mode for port_id",
3022 (void *)&cmd_setbypass_event_set,
3023 (void *)&cmd_setbypass_event_bypass,
3024 (void *)&cmd_setbypass_event_event,
3025 (void *)&cmd_setbypass_event_event_value,
3026 (void *)&cmd_setbypass_event_mode,
3027 (void *)&cmd_setbypass_event_mode_value,
3028 (void *)&cmd_setbypass_event_port,
3034 /* *** SET NIC BYPASS TIMEOUT *** */
3035 struct cmd_set_bypass_timeout_result {
3036 cmdline_fixed_string_t set;
3037 cmdline_fixed_string_t bypass;
3038 cmdline_fixed_string_t timeout;
3039 cmdline_fixed_string_t value;
3043 cmd_set_bypass_timeout_parsed(void *parsed_result,
3044 __attribute__((unused)) struct cmdline *cl,
3045 __attribute__((unused)) void *data)
3047 struct cmd_set_bypass_timeout_result *res = parsed_result;
3049 if (!strcmp(res->value, "1.5"))
3050 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3051 else if (!strcmp(res->value, "2"))
3052 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3053 else if (!strcmp(res->value, "3"))
3054 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3055 else if (!strcmp(res->value, "4"))
3056 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3057 else if (!strcmp(res->value, "8"))
3058 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3059 else if (!strcmp(res->value, "16"))
3060 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3061 else if (!strcmp(res->value, "32"))
3062 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3064 bypass_timeout = RTE_BYPASS_TMT_OFF;
3067 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3068 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3070 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3071 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3073 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3074 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3075 timeout, "timeout");
3076 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3077 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3078 value, "0#1.5#2#3#4#8#16#32");
3080 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3081 .f = cmd_set_bypass_timeout_parsed,
3082 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3083 "Set the NIC bypass watchdog timeout",
3086 (void *)&cmd_setbypass_timeout_set,
3087 (void *)&cmd_setbypass_timeout_bypass,
3088 (void *)&cmd_setbypass_timeout_timeout,
3089 (void *)&cmd_setbypass_timeout_value,
3094 /* *** SHOW NIC BYPASS MODE *** */
3095 struct cmd_show_bypass_config_result {
3096 cmdline_fixed_string_t show;
3097 cmdline_fixed_string_t bypass;
3098 cmdline_fixed_string_t config;
3103 cmd_show_bypass_config_parsed(void *parsed_result,
3104 __attribute__((unused)) struct cmdline *cl,
3105 __attribute__((unused)) void *data)
3107 struct cmd_show_bypass_config_result *res = parsed_result;
3108 uint32_t event_mode;
3109 uint32_t bypass_mode;
3110 portid_t port_id = res->port_id;
3111 uint32_t timeout = bypass_timeout;
3114 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3115 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3116 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3117 {"UNKNOWN", "normal", "bypass", "isolate"};
3118 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3125 int num_events = (sizeof events) / (sizeof events[0]);
3127 if (!bypass_is_supported(port_id))
3130 /* Display the bypass mode.*/
3131 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3132 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3136 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3137 bypass_mode = RTE_BYPASS_MODE_NONE;
3139 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3142 /* Display the bypass timeout.*/
3143 if (!RTE_BYPASS_TMT_VALID(timeout))
3144 timeout = RTE_BYPASS_TMT_OFF;
3146 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3148 /* Display the bypass events and associated modes. */
3149 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3151 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3152 printf("\tFailed to get bypass mode for event = %s\n",
3155 if (!RTE_BYPASS_MODE_VALID(event_mode))
3156 event_mode = RTE_BYPASS_MODE_NONE;
3158 printf("\tbypass event: %-16s = %s\n", events[i],
3164 cmdline_parse_token_string_t cmd_showbypass_config_show =
3165 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3167 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3168 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3170 cmdline_parse_token_string_t cmd_showbypass_config_config =
3171 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3173 cmdline_parse_token_num_t cmd_showbypass_config_port =
3174 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3177 cmdline_parse_inst_t cmd_show_bypass_config = {
3178 .f = cmd_show_bypass_config_parsed,
3179 .help_str = "show bypass config (port_id): "
3180 "Show the NIC bypass config for port_id",
3183 (void *)&cmd_showbypass_config_show,
3184 (void *)&cmd_showbypass_config_bypass,
3185 (void *)&cmd_showbypass_config_config,
3186 (void *)&cmd_showbypass_config_port,
3192 #ifdef RTE_LIBRTE_PMD_BOND
3193 /* *** SET BONDING MODE *** */
3194 struct cmd_set_bonding_mode_result {
3195 cmdline_fixed_string_t set;
3196 cmdline_fixed_string_t bonding;
3197 cmdline_fixed_string_t mode;
3202 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3203 __attribute__((unused)) struct cmdline *cl,
3204 __attribute__((unused)) void *data)
3206 struct cmd_set_bonding_mode_result *res = parsed_result;
3207 portid_t port_id = res->port_id;
3209 /* Set the bonding mode for the relevant port. */
3210 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3211 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3214 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3215 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3217 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3218 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3219 bonding, "bonding");
3220 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3221 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3223 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3224 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3226 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3227 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3230 cmdline_parse_inst_t cmd_set_bonding_mode = {
3231 .f = cmd_set_bonding_mode_parsed,
3232 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3235 (void *) &cmd_setbonding_mode_set,
3236 (void *) &cmd_setbonding_mode_bonding,
3237 (void *) &cmd_setbonding_mode_mode,
3238 (void *) &cmd_setbonding_mode_value,
3239 (void *) &cmd_setbonding_mode_port,
3244 /* *** SET BALANCE XMIT POLICY *** */
3245 struct cmd_set_bonding_balance_xmit_policy_result {
3246 cmdline_fixed_string_t set;
3247 cmdline_fixed_string_t bonding;
3248 cmdline_fixed_string_t balance_xmit_policy;
3250 cmdline_fixed_string_t policy;
3253 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3254 __attribute__((unused)) struct cmdline *cl,
3255 __attribute__((unused)) void *data)
3257 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3258 portid_t port_id = res->port_id;
3261 if (!strcmp(res->policy, "l2")) {
3262 policy = BALANCE_XMIT_POLICY_LAYER2;
3263 } else if (!strcmp(res->policy, "l23")) {
3264 policy = BALANCE_XMIT_POLICY_LAYER23;
3265 } else if (!strcmp(res->policy, "l34")) {
3266 policy = BALANCE_XMIT_POLICY_LAYER34;
3268 printf("\t Invalid xmit policy selection");
3272 /* Set the bonding mode for the relevant port. */
3273 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3274 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3279 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3280 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3282 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3283 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3284 bonding, "bonding");
3285 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3286 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3287 balance_xmit_policy, "balance_xmit_policy");
3288 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3289 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3291 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3292 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3293 policy, "l2#l23#l34");
3295 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3296 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3297 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3300 (void *)&cmd_setbonding_balance_xmit_policy_set,
3301 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3302 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3303 (void *)&cmd_setbonding_balance_xmit_policy_port,
3304 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3309 /* *** SHOW NIC BONDING CONFIGURATION *** */
3310 struct cmd_show_bonding_config_result {
3311 cmdline_fixed_string_t show;
3312 cmdline_fixed_string_t bonding;
3313 cmdline_fixed_string_t config;
3317 static void cmd_show_bonding_config_parsed(void *parsed_result,
3318 __attribute__((unused)) struct cmdline *cl,
3319 __attribute__((unused)) void *data)
3321 struct cmd_show_bonding_config_result *res = parsed_result;
3323 uint8_t slaves[RTE_MAX_ETHPORTS];
3324 int num_slaves, num_active_slaves;
3327 portid_t port_id = res->port_id;
3329 /* Display the bonding mode.*/
3330 bonding_mode = rte_eth_bond_mode_get(port_id);
3331 if (bonding_mode < 0) {
3332 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3335 printf("\tBonding mode: %d\n", bonding_mode);
3337 if (bonding_mode == BONDING_MODE_BALANCE) {
3338 int balance_xmit_policy;
3340 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3341 if (balance_xmit_policy < 0) {
3342 printf("\tFailed to get balance xmit policy for port = %d\n",
3346 printf("\tBalance Xmit Policy: ");
3348 switch (balance_xmit_policy) {
3349 case BALANCE_XMIT_POLICY_LAYER2:
3350 printf("BALANCE_XMIT_POLICY_LAYER2");
3352 case BALANCE_XMIT_POLICY_LAYER23:
3353 printf("BALANCE_XMIT_POLICY_LAYER23");
3355 case BALANCE_XMIT_POLICY_LAYER34:
3356 printf("BALANCE_XMIT_POLICY_LAYER34");
3363 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3365 if (num_slaves < 0) {
3366 printf("\tFailed to get slave list for port = %d\n", port_id);
3369 if (num_slaves > 0) {
3370 printf("\tSlaves (%d): [", num_slaves);
3371 for (i = 0; i < num_slaves - 1; i++)
3372 printf("%d ", slaves[i]);
3374 printf("%d]\n", slaves[num_slaves - 1]);
3376 printf("\tSlaves: []\n");
3380 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3383 if (num_active_slaves < 0) {
3384 printf("\tFailed to get active slave list for port = %d\n", port_id);
3387 if (num_active_slaves > 0) {
3388 printf("\tActive Slaves (%d): [", num_active_slaves);
3389 for (i = 0; i < num_active_slaves - 1; i++)
3390 printf("%d ", slaves[i]);
3392 printf("%d]\n", slaves[num_active_slaves - 1]);
3395 printf("\tActive Slaves: []\n");
3399 primary_id = rte_eth_bond_primary_get(port_id);
3400 if (primary_id < 0) {
3401 printf("\tFailed to get primary slave for port = %d\n", port_id);
3404 printf("\tPrimary: [%d]\n", primary_id);
3408 cmdline_parse_token_string_t cmd_showbonding_config_show =
3409 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3411 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3412 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3413 bonding, "bonding");
3414 cmdline_parse_token_string_t cmd_showbonding_config_config =
3415 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3417 cmdline_parse_token_num_t cmd_showbonding_config_port =
3418 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3421 cmdline_parse_inst_t cmd_show_bonding_config = {
3422 .f = cmd_show_bonding_config_parsed,
3423 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3426 (void *)&cmd_showbonding_config_show,
3427 (void *)&cmd_showbonding_config_bonding,
3428 (void *)&cmd_showbonding_config_config,
3429 (void *)&cmd_showbonding_config_port,
3434 /* *** SET BONDING PRIMARY *** */
3435 struct cmd_set_bonding_primary_result {
3436 cmdline_fixed_string_t set;
3437 cmdline_fixed_string_t bonding;
3438 cmdline_fixed_string_t primary;
3443 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3444 __attribute__((unused)) struct cmdline *cl,
3445 __attribute__((unused)) void *data)
3447 struct cmd_set_bonding_primary_result *res = parsed_result;
3448 portid_t master_port_id = res->port_id;
3449 portid_t slave_port_id = res->slave_id;
3451 /* Set the primary slave for a bonded device. */
3452 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3453 printf("\t Failed to set primary slave for port = %d.\n",
3460 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3461 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3463 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3464 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3465 bonding, "bonding");
3466 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3467 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3468 primary, "primary");
3469 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3470 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3472 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3473 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3476 cmdline_parse_inst_t cmd_set_bonding_primary = {
3477 .f = cmd_set_bonding_primary_parsed,
3478 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3481 (void *)&cmd_setbonding_primary_set,
3482 (void *)&cmd_setbonding_primary_bonding,
3483 (void *)&cmd_setbonding_primary_primary,
3484 (void *)&cmd_setbonding_primary_slave,
3485 (void *)&cmd_setbonding_primary_port,
3490 /* *** ADD SLAVE *** */
3491 struct cmd_add_bonding_slave_result {
3492 cmdline_fixed_string_t add;
3493 cmdline_fixed_string_t bonding;
3494 cmdline_fixed_string_t slave;
3499 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3500 __attribute__((unused)) struct cmdline *cl,
3501 __attribute__((unused)) void *data)
3503 struct cmd_add_bonding_slave_result *res = parsed_result;
3504 portid_t master_port_id = res->port_id;
3505 portid_t slave_port_id = res->slave_id;
3507 /* Set the primary slave for a bonded device. */
3508 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3509 printf("\t Failed to add slave %d to master port = %d.\n",
3510 slave_port_id, master_port_id);
3516 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3517 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3519 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3520 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3521 bonding, "bonding");
3522 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3523 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3525 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3526 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3528 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3529 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3532 cmdline_parse_inst_t cmd_add_bonding_slave = {
3533 .f = cmd_add_bonding_slave_parsed,
3534 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3537 (void *)&cmd_addbonding_slave_add,
3538 (void *)&cmd_addbonding_slave_bonding,
3539 (void *)&cmd_addbonding_slave_slave,
3540 (void *)&cmd_addbonding_slave_slaveid,
3541 (void *)&cmd_addbonding_slave_port,
3546 /* *** REMOVE SLAVE *** */
3547 struct cmd_remove_bonding_slave_result {
3548 cmdline_fixed_string_t remove;
3549 cmdline_fixed_string_t bonding;
3550 cmdline_fixed_string_t slave;
3555 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3556 __attribute__((unused)) struct cmdline *cl,
3557 __attribute__((unused)) void *data)
3559 struct cmd_remove_bonding_slave_result *res = parsed_result;
3560 portid_t master_port_id = res->port_id;
3561 portid_t slave_port_id = res->slave_id;
3563 /* Set the primary slave for a bonded device. */
3564 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3565 printf("\t Failed to remove slave %d from master port = %d.\n",
3566 slave_port_id, master_port_id);
3572 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3573 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3575 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3576 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3577 bonding, "bonding");
3578 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3579 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3581 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3582 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3584 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3585 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3588 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3589 .f = cmd_remove_bonding_slave_parsed,
3590 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3593 (void *)&cmd_removebonding_slave_remove,
3594 (void *)&cmd_removebonding_slave_bonding,
3595 (void *)&cmd_removebonding_slave_slave,
3596 (void *)&cmd_removebonding_slave_slaveid,
3597 (void *)&cmd_removebonding_slave_port,
3602 /* *** CREATE BONDED DEVICE *** */
3603 struct cmd_create_bonded_device_result {
3604 cmdline_fixed_string_t create;
3605 cmdline_fixed_string_t bonded;
3606 cmdline_fixed_string_t device;
3611 static int bond_dev_num = 0;
3613 static void cmd_create_bonded_device_parsed(void *parsed_result,
3614 __attribute__((unused)) struct cmdline *cl,
3615 __attribute__((unused)) void *data)
3617 struct cmd_create_bonded_device_result *res = parsed_result;
3618 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3621 if (test_done == 0) {
3622 printf("Please stop forwarding first\n");
3626 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3629 /* Create a new bonded device. */
3630 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3632 printf("\t Failed to create bonded device.\n");
3635 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3638 /* Update number of ports */
3639 nb_ports = rte_eth_dev_count();
3641 rte_eth_promiscuous_enable(port_id);
3646 cmdline_parse_token_string_t cmd_createbonded_device_create =
3647 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3649 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3650 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3652 cmdline_parse_token_string_t cmd_createbonded_device_device =
3653 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3655 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3656 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3658 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3659 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3662 cmdline_parse_inst_t cmd_create_bonded_device = {
3663 .f = cmd_create_bonded_device_parsed,
3664 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3667 (void *)&cmd_createbonded_device_create,
3668 (void *)&cmd_createbonded_device_bonded,
3669 (void *)&cmd_createbonded_device_device,
3670 (void *)&cmd_createbonded_device_mode,
3671 (void *)&cmd_createbonded_device_socket,
3676 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3677 struct cmd_set_bond_mac_addr_result {
3678 cmdline_fixed_string_t set;
3679 cmdline_fixed_string_t bonding;
3680 cmdline_fixed_string_t mac_addr;
3682 struct ether_addr address;
3685 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3686 __attribute__((unused)) struct cmdline *cl,
3687 __attribute__((unused)) void *data)
3689 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3692 if (res->port_num >= nb_ports) {
3693 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3697 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3699 /* check the return value and print it if is < 0 */
3701 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3704 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3705 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3706 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3707 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3709 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3710 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3712 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3713 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3714 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3715 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3717 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3718 .f = cmd_set_bond_mac_addr_parsed,
3720 .help_str = "set bonding mac_addr (port_id) (address): ",
3722 (void *)&cmd_set_bond_mac_addr_set,
3723 (void *)&cmd_set_bond_mac_addr_bonding,
3724 (void *)&cmd_set_bond_mac_addr_mac,
3725 (void *)&cmd_set_bond_mac_addr_portnum,
3726 (void *)&cmd_set_bond_mac_addr_addr,
3731 #endif /* RTE_LIBRTE_PMD_BOND */
3733 /* *** SET FORWARDING MODE *** */
3734 struct cmd_set_fwd_mode_result {
3735 cmdline_fixed_string_t set;
3736 cmdline_fixed_string_t fwd;
3737 cmdline_fixed_string_t mode;
3740 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3741 __attribute__((unused)) struct cmdline *cl,
3742 __attribute__((unused)) void *data)
3744 struct cmd_set_fwd_mode_result *res = parsed_result;
3746 set_pkt_forwarding_mode(res->mode);
3749 cmdline_parse_token_string_t cmd_setfwd_set =
3750 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3751 cmdline_parse_token_string_t cmd_setfwd_fwd =
3752 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3753 cmdline_parse_token_string_t cmd_setfwd_mode =
3754 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3755 "" /* defined at init */);
3757 cmdline_parse_inst_t cmd_set_fwd_mode = {
3758 .f = cmd_set_fwd_mode_parsed,
3760 .help_str = NULL, /* defined at init */
3762 (void *)&cmd_setfwd_set,
3763 (void *)&cmd_setfwd_fwd,
3764 (void *)&cmd_setfwd_mode,
3769 static void cmd_set_fwd_mode_init(void)
3772 static char token[128];
3773 static char help[256];
3774 cmdline_parse_token_string_t *token_struct;
3776 modes = list_pkt_forwarding_modes();
3777 snprintf(help, sizeof help, "set fwd %s - "
3778 "set packet forwarding mode", modes);
3779 cmd_set_fwd_mode.help_str = help;
3781 /* string token separator is # */
3782 for (c = token; *modes != '\0'; modes++)
3787 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3788 token_struct->string_data.str = token;
3791 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3792 struct cmd_set_burst_tx_retry_result {
3793 cmdline_fixed_string_t set;
3794 cmdline_fixed_string_t burst;
3795 cmdline_fixed_string_t tx;
3796 cmdline_fixed_string_t delay;
3798 cmdline_fixed_string_t retry;
3802 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3803 __attribute__((unused)) struct cmdline *cl,
3804 __attribute__((unused)) void *data)
3806 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3808 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3809 && !strcmp(res->tx, "tx")) {
3810 if (!strcmp(res->delay, "delay"))
3811 burst_tx_delay_time = res->time;
3812 if (!strcmp(res->retry, "retry"))
3813 burst_tx_retry_num = res->retry_num;
3818 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3819 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3820 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3821 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3823 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3824 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3825 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3826 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3827 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3828 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3829 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3830 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3831 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3832 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3834 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3835 .f = cmd_set_burst_tx_retry_parsed,
3836 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3838 (void *)&cmd_set_burst_tx_retry_set,
3839 (void *)&cmd_set_burst_tx_retry_burst,
3840 (void *)&cmd_set_burst_tx_retry_tx,
3841 (void *)&cmd_set_burst_tx_retry_delay,
3842 (void *)&cmd_set_burst_tx_retry_time,
3843 (void *)&cmd_set_burst_tx_retry_retry,
3844 (void *)&cmd_set_burst_tx_retry_retry_num,
3849 /* *** SET PROMISC MODE *** */
3850 struct cmd_set_promisc_mode_result {
3851 cmdline_fixed_string_t set;
3852 cmdline_fixed_string_t promisc;
3853 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3854 uint8_t port_num; /* valid if "allports" argument == 0 */
3855 cmdline_fixed_string_t mode;
3858 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3859 __attribute__((unused)) struct cmdline *cl,
3862 struct cmd_set_promisc_mode_result *res = parsed_result;
3866 if (!strcmp(res->mode, "on"))
3873 for (i = 0; i < nb_ports; i++) {
3875 rte_eth_promiscuous_enable(i);
3877 rte_eth_promiscuous_disable(i);
3882 rte_eth_promiscuous_enable(res->port_num);
3884 rte_eth_promiscuous_disable(res->port_num);
3888 cmdline_parse_token_string_t cmd_setpromisc_set =
3889 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3890 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3891 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3893 cmdline_parse_token_string_t cmd_setpromisc_portall =
3894 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3896 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3897 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3899 cmdline_parse_token_string_t cmd_setpromisc_mode =
3900 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3903 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3904 .f = cmd_set_promisc_mode_parsed,
3906 .help_str = "set promisc all on|off: set promisc mode for all ports",
3908 (void *)&cmd_setpromisc_set,
3909 (void *)&cmd_setpromisc_promisc,
3910 (void *)&cmd_setpromisc_portall,
3911 (void *)&cmd_setpromisc_mode,
3916 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3917 .f = cmd_set_promisc_mode_parsed,
3919 .help_str = "set promisc X on|off: set promisc mode on port X",
3921 (void *)&cmd_setpromisc_set,
3922 (void *)&cmd_setpromisc_promisc,
3923 (void *)&cmd_setpromisc_portnum,
3924 (void *)&cmd_setpromisc_mode,
3929 /* *** SET ALLMULTI MODE *** */
3930 struct cmd_set_allmulti_mode_result {
3931 cmdline_fixed_string_t set;
3932 cmdline_fixed_string_t allmulti;
3933 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3934 uint8_t port_num; /* valid if "allports" argument == 0 */
3935 cmdline_fixed_string_t mode;
3938 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3939 __attribute__((unused)) struct cmdline *cl,
3942 struct cmd_set_allmulti_mode_result *res = parsed_result;
3946 if (!strcmp(res->mode, "on"))
3953 for (i = 0; i < nb_ports; i++) {
3955 rte_eth_allmulticast_enable(i);
3957 rte_eth_allmulticast_disable(i);
3962 rte_eth_allmulticast_enable(res->port_num);
3964 rte_eth_allmulticast_disable(res->port_num);
3968 cmdline_parse_token_string_t cmd_setallmulti_set =
3969 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3970 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3971 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3973 cmdline_parse_token_string_t cmd_setallmulti_portall =
3974 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3976 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3977 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3979 cmdline_parse_token_string_t cmd_setallmulti_mode =
3980 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3983 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3984 .f = cmd_set_allmulti_mode_parsed,
3986 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3988 (void *)&cmd_setallmulti_set,
3989 (void *)&cmd_setallmulti_allmulti,
3990 (void *)&cmd_setallmulti_portall,
3991 (void *)&cmd_setallmulti_mode,
3996 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3997 .f = cmd_set_allmulti_mode_parsed,
3999 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4001 (void *)&cmd_setallmulti_set,
4002 (void *)&cmd_setallmulti_allmulti,
4003 (void *)&cmd_setallmulti_portnum,
4004 (void *)&cmd_setallmulti_mode,
4009 /* *** ADD/REMOVE A PKT FILTER *** */
4010 struct cmd_pkt_filter_result {
4011 cmdline_fixed_string_t pkt_filter;
4013 cmdline_fixed_string_t protocol;
4014 cmdline_fixed_string_t src;
4015 cmdline_ipaddr_t ip_src;
4017 cmdline_fixed_string_t dst;
4018 cmdline_ipaddr_t ip_dst;
4020 cmdline_fixed_string_t flexbytes;
4021 uint16_t flexbytes_value;
4022 cmdline_fixed_string_t vlan;
4024 cmdline_fixed_string_t queue;
4026 cmdline_fixed_string_t soft;
4031 cmd_pkt_filter_parsed(void *parsed_result,
4032 __attribute__((unused)) struct cmdline *cl,
4033 __attribute__((unused)) void *data)
4035 struct rte_fdir_filter fdir_filter;
4036 struct cmd_pkt_filter_result *res = parsed_result;
4038 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4040 if (res->ip_src.family == AF_INET)
4041 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4043 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4044 &(res->ip_src.addr.ipv6),
4045 sizeof(struct in6_addr));
4047 if (res->ip_dst.family == AF_INET)
4048 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4050 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4051 &(res->ip_dst.addr.ipv6),
4052 sizeof(struct in6_addr));
4054 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4055 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4057 if (!strcmp(res->protocol, "udp"))
4058 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4059 else if (!strcmp(res->protocol, "tcp"))
4060 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4061 else if (!strcmp(res->protocol, "sctp"))
4062 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4063 else /* default only IP */
4064 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4066 if (res->ip_dst.family == AF_INET6)
4067 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4069 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4071 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4072 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4074 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4075 fdir_add_signature_filter(res->port_id, res->queue_id,
4077 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4078 fdir_update_signature_filter(res->port_id, res->queue_id,
4080 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4081 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4082 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4083 fdir_add_perfect_filter(res->port_id, res->soft_id,
4085 (uint8_t) (res->queue_id < 0),
4087 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4088 fdir_update_perfect_filter(res->port_id, res->soft_id,
4090 (uint8_t) (res->queue_id < 0),
4092 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4093 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4099 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4100 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4102 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4103 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4104 protocol, "ip#tcp#udp#sctp");
4105 cmdline_parse_token_string_t cmd_pkt_filter_src =
4106 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4108 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4109 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4111 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4112 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4114 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4115 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4117 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4118 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4120 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4121 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4123 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4124 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4125 flexbytes, "flexbytes");
4126 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4127 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4128 flexbytes_value, UINT16);
4129 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4130 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4132 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4133 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4135 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4136 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4138 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4139 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4141 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4142 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4144 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4145 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4149 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4150 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4151 pkt_filter, "add_signature_filter");
4152 cmdline_parse_inst_t cmd_add_signature_filter = {
4153 .f = cmd_pkt_filter_parsed,
4155 .help_str = "add a signature filter",
4157 (void *)&cmd_pkt_filter_add_signature_filter,
4158 (void *)&cmd_pkt_filter_port_id,
4159 (void *)&cmd_pkt_filter_protocol,
4160 (void *)&cmd_pkt_filter_src,
4161 (void *)&cmd_pkt_filter_ip_src,
4162 (void *)&cmd_pkt_filter_port_src,
4163 (void *)&cmd_pkt_filter_dst,
4164 (void *)&cmd_pkt_filter_ip_dst,
4165 (void *)&cmd_pkt_filter_port_dst,
4166 (void *)&cmd_pkt_filter_flexbytes,
4167 (void *)&cmd_pkt_filter_flexbytes_value,
4168 (void *)&cmd_pkt_filter_vlan,
4169 (void *)&cmd_pkt_filter_vlan_id,
4170 (void *)&cmd_pkt_filter_queue,
4171 (void *)&cmd_pkt_filter_queue_id,
4177 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4178 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4179 pkt_filter, "upd_signature_filter");
4180 cmdline_parse_inst_t cmd_upd_signature_filter = {
4181 .f = cmd_pkt_filter_parsed,
4183 .help_str = "update a signature filter",
4185 (void *)&cmd_pkt_filter_upd_signature_filter,
4186 (void *)&cmd_pkt_filter_port_id,
4187 (void *)&cmd_pkt_filter_protocol,
4188 (void *)&cmd_pkt_filter_src,
4189 (void *)&cmd_pkt_filter_ip_src,
4190 (void *)&cmd_pkt_filter_port_src,
4191 (void *)&cmd_pkt_filter_dst,
4192 (void *)&cmd_pkt_filter_ip_dst,
4193 (void *)&cmd_pkt_filter_port_dst,
4194 (void *)&cmd_pkt_filter_flexbytes,
4195 (void *)&cmd_pkt_filter_flexbytes_value,
4196 (void *)&cmd_pkt_filter_vlan,
4197 (void *)&cmd_pkt_filter_vlan_id,
4198 (void *)&cmd_pkt_filter_queue,
4199 (void *)&cmd_pkt_filter_queue_id,
4205 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4206 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4207 pkt_filter, "rm_signature_filter");
4208 cmdline_parse_inst_t cmd_rm_signature_filter = {
4209 .f = cmd_pkt_filter_parsed,
4211 .help_str = "remove a signature filter",
4213 (void *)&cmd_pkt_filter_rm_signature_filter,
4214 (void *)&cmd_pkt_filter_port_id,
4215 (void *)&cmd_pkt_filter_protocol,
4216 (void *)&cmd_pkt_filter_src,
4217 (void *)&cmd_pkt_filter_ip_src,
4218 (void *)&cmd_pkt_filter_port_src,
4219 (void *)&cmd_pkt_filter_dst,
4220 (void *)&cmd_pkt_filter_ip_dst,
4221 (void *)&cmd_pkt_filter_port_dst,
4222 (void *)&cmd_pkt_filter_flexbytes,
4223 (void *)&cmd_pkt_filter_flexbytes_value,
4224 (void *)&cmd_pkt_filter_vlan,
4225 (void *)&cmd_pkt_filter_vlan_id,
4231 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4232 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4233 pkt_filter, "add_perfect_filter");
4234 cmdline_parse_inst_t cmd_add_perfect_filter = {
4235 .f = cmd_pkt_filter_parsed,
4237 .help_str = "add a perfect filter",
4239 (void *)&cmd_pkt_filter_add_perfect_filter,
4240 (void *)&cmd_pkt_filter_port_id,
4241 (void *)&cmd_pkt_filter_protocol,
4242 (void *)&cmd_pkt_filter_src,
4243 (void *)&cmd_pkt_filter_ip_src,
4244 (void *)&cmd_pkt_filter_port_src,
4245 (void *)&cmd_pkt_filter_dst,
4246 (void *)&cmd_pkt_filter_ip_dst,
4247 (void *)&cmd_pkt_filter_port_dst,
4248 (void *)&cmd_pkt_filter_flexbytes,
4249 (void *)&cmd_pkt_filter_flexbytes_value,
4250 (void *)&cmd_pkt_filter_vlan,
4251 (void *)&cmd_pkt_filter_vlan_id,
4252 (void *)&cmd_pkt_filter_queue,
4253 (void *)&cmd_pkt_filter_queue_id,
4254 (void *)&cmd_pkt_filter_soft,
4255 (void *)&cmd_pkt_filter_soft_id,
4261 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4262 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4263 pkt_filter, "upd_perfect_filter");
4264 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4265 .f = cmd_pkt_filter_parsed,
4267 .help_str = "update a perfect filter",
4269 (void *)&cmd_pkt_filter_upd_perfect_filter,
4270 (void *)&cmd_pkt_filter_port_id,
4271 (void *)&cmd_pkt_filter_protocol,
4272 (void *)&cmd_pkt_filter_src,
4273 (void *)&cmd_pkt_filter_ip_src,
4274 (void *)&cmd_pkt_filter_port_src,
4275 (void *)&cmd_pkt_filter_dst,
4276 (void *)&cmd_pkt_filter_ip_dst,
4277 (void *)&cmd_pkt_filter_port_dst,
4278 (void *)&cmd_pkt_filter_flexbytes,
4279 (void *)&cmd_pkt_filter_flexbytes_value,
4280 (void *)&cmd_pkt_filter_vlan,
4281 (void *)&cmd_pkt_filter_vlan_id,
4282 (void *)&cmd_pkt_filter_queue,
4283 (void *)&cmd_pkt_filter_queue_id,
4284 (void *)&cmd_pkt_filter_soft,
4285 (void *)&cmd_pkt_filter_soft_id,
4291 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4292 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4293 pkt_filter, "rm_perfect_filter");
4294 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4295 .f = cmd_pkt_filter_parsed,
4297 .help_str = "remove a perfect filter",
4299 (void *)&cmd_pkt_filter_rm_perfect_filter,
4300 (void *)&cmd_pkt_filter_port_id,
4301 (void *)&cmd_pkt_filter_protocol,
4302 (void *)&cmd_pkt_filter_src,
4303 (void *)&cmd_pkt_filter_ip_src,
4304 (void *)&cmd_pkt_filter_port_src,
4305 (void *)&cmd_pkt_filter_dst,
4306 (void *)&cmd_pkt_filter_ip_dst,
4307 (void *)&cmd_pkt_filter_port_dst,
4308 (void *)&cmd_pkt_filter_flexbytes,
4309 (void *)&cmd_pkt_filter_flexbytes_value,
4310 (void *)&cmd_pkt_filter_vlan,
4311 (void *)&cmd_pkt_filter_vlan_id,
4312 (void *)&cmd_pkt_filter_soft,
4313 (void *)&cmd_pkt_filter_soft_id,
4318 /* *** SETUP MASKS FILTER *** */
4319 struct cmd_pkt_filter_masks_result {
4320 cmdline_fixed_string_t filter_mask;
4322 cmdline_fixed_string_t src_mask;
4323 uint32_t ip_src_mask;
4324 uint16_t ipv6_src_mask;
4325 uint16_t port_src_mask;
4326 cmdline_fixed_string_t dst_mask;
4327 uint32_t ip_dst_mask;
4328 uint16_t ipv6_dst_mask;
4329 uint16_t port_dst_mask;
4330 cmdline_fixed_string_t flexbytes;
4331 uint8_t flexbytes_value;
4332 cmdline_fixed_string_t vlan_id;
4333 uint8_t vlan_id_value;
4334 cmdline_fixed_string_t vlan_prio;
4335 uint8_t vlan_prio_value;
4336 cmdline_fixed_string_t only_ip_flow;
4337 uint8_t only_ip_flow_value;
4338 cmdline_fixed_string_t comp_ipv6_dst;
4339 uint8_t comp_ipv6_dst_value;
4343 cmd_pkt_filter_masks_parsed(void *parsed_result,
4344 __attribute__((unused)) struct cmdline *cl,
4345 __attribute__((unused)) void *data)
4347 struct rte_fdir_masks fdir_masks;
4348 struct cmd_pkt_filter_masks_result *res = parsed_result;
4350 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4352 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4353 fdir_masks.vlan_id = res->vlan_id_value;
4354 fdir_masks.vlan_prio = res->vlan_prio_value;
4355 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4356 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4357 fdir_masks.src_port_mask = res->port_src_mask;
4358 fdir_masks.dst_port_mask = res->port_dst_mask;
4359 fdir_masks.flexbytes = res->flexbytes_value;
4361 fdir_set_masks(res->port_id, &fdir_masks);
4364 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4365 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4366 filter_mask, "set_masks_filter");
4367 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4368 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4370 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4371 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4372 only_ip_flow, "only_ip_flow");
4373 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4374 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4375 only_ip_flow_value, UINT8);
4376 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4377 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4378 src_mask, "src_mask");
4379 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4380 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4381 ip_src_mask, UINT32);
4382 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4383 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4384 port_src_mask, UINT16);
4385 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4386 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4387 dst_mask, "dst_mask");
4388 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4389 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4390 ip_dst_mask, UINT32);
4391 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4392 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4393 port_dst_mask, UINT16);
4394 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4395 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4396 flexbytes, "flexbytes");
4397 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4398 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4399 flexbytes_value, UINT8);
4400 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4401 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4402 vlan_id, "vlan_id");
4403 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4404 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4405 vlan_id_value, UINT8);
4406 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4407 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4408 vlan_prio, "vlan_prio");
4409 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4410 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4411 vlan_prio_value, UINT8);
4413 cmdline_parse_inst_t cmd_set_masks_filter = {
4414 .f = cmd_pkt_filter_masks_parsed,
4416 .help_str = "setup masks filter",
4418 (void *)&cmd_pkt_filter_masks_filter_mask,
4419 (void *)&cmd_pkt_filter_masks_port_id,
4420 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4421 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4422 (void *)&cmd_pkt_filter_masks_src_mask,
4423 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4424 (void *)&cmd_pkt_filter_masks_port_src_mask,
4425 (void *)&cmd_pkt_filter_masks_dst_mask,
4426 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4427 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4428 (void *)&cmd_pkt_filter_masks_flexbytes,
4429 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4430 (void *)&cmd_pkt_filter_masks_vlan_id,
4431 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4432 (void *)&cmd_pkt_filter_masks_vlan_prio,
4433 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4439 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4440 __attribute__((unused)) struct cmdline *cl,
4441 __attribute__((unused)) void *data)
4443 struct rte_fdir_masks fdir_masks;
4444 struct cmd_pkt_filter_masks_result *res = parsed_result;
4446 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4448 fdir_masks.set_ipv6_mask = 1;
4449 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4450 fdir_masks.vlan_id = res->vlan_id_value;
4451 fdir_masks.vlan_prio = res->vlan_prio_value;
4452 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4453 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4454 fdir_masks.src_port_mask = res->port_src_mask;
4455 fdir_masks.dst_port_mask = res->port_dst_mask;
4456 fdir_masks.flexbytes = res->flexbytes_value;
4457 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4459 fdir_set_masks(res->port_id, &fdir_masks);
4462 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4463 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4464 filter_mask, "set_ipv6_masks_filter");
4465 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4466 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4467 ipv6_src_mask, UINT16);
4468 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4469 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4470 ipv6_dst_mask, UINT16);
4472 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4473 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4474 comp_ipv6_dst, "compare_dst");
4475 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4476 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4477 comp_ipv6_dst_value, UINT8);
4479 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4480 .f = cmd_pkt_filter_masks_ipv6_parsed,
4482 .help_str = "setup ipv6 masks filter",
4484 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4485 (void *)&cmd_pkt_filter_masks_port_id,
4486 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4487 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4488 (void *)&cmd_pkt_filter_masks_src_mask,
4489 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4490 (void *)&cmd_pkt_filter_masks_port_src_mask,
4491 (void *)&cmd_pkt_filter_masks_dst_mask,
4492 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4493 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4494 (void *)&cmd_pkt_filter_masks_flexbytes,
4495 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4496 (void *)&cmd_pkt_filter_masks_vlan_id,
4497 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4498 (void *)&cmd_pkt_filter_masks_vlan_prio,
4499 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4500 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4501 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4506 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4507 struct cmd_link_flow_ctrl_set_result {
4508 cmdline_fixed_string_t set;
4509 cmdline_fixed_string_t flow_ctrl;
4510 cmdline_fixed_string_t rx;
4511 cmdline_fixed_string_t rx_lfc_mode;
4512 cmdline_fixed_string_t tx;
4513 cmdline_fixed_string_t tx_lfc_mode;
4514 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4515 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4516 cmdline_fixed_string_t autoneg_str;
4517 cmdline_fixed_string_t autoneg;
4518 cmdline_fixed_string_t hw_str;
4519 uint32_t high_water;
4520 cmdline_fixed_string_t lw_str;
4522 cmdline_fixed_string_t pt_str;
4523 uint16_t pause_time;
4524 cmdline_fixed_string_t xon_str;
4529 cmdline_parse_token_string_t cmd_lfc_set_set =
4530 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4532 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4533 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4534 flow_ctrl, "flow_ctrl");
4535 cmdline_parse_token_string_t cmd_lfc_set_rx =
4536 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4538 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4539 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4540 rx_lfc_mode, "on#off");
4541 cmdline_parse_token_string_t cmd_lfc_set_tx =
4542 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4544 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4545 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4546 tx_lfc_mode, "on#off");
4547 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4548 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4549 hw_str, "high_water");
4550 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4551 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4552 high_water, UINT32);
4553 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4554 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4555 lw_str, "low_water");
4556 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4557 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4559 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4560 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4561 pt_str, "pause_time");
4562 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4563 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4564 pause_time, UINT16);
4565 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4566 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4567 xon_str, "send_xon");
4568 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4569 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4571 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4572 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4573 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4574 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4575 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4576 mac_ctrl_frame_fwd_mode, "on#off");
4577 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4578 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4579 autoneg_str, "autoneg");
4580 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4581 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4583 cmdline_parse_token_num_t cmd_lfc_set_portid =
4584 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4587 /* forward declaration */
4589 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4592 cmdline_parse_inst_t cmd_link_flow_control_set = {
4593 .f = cmd_link_flow_ctrl_set_parsed,
4595 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4596 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4597 autoneg on|off port_id",
4599 (void *)&cmd_lfc_set_set,
4600 (void *)&cmd_lfc_set_flow_ctrl,
4601 (void *)&cmd_lfc_set_rx,
4602 (void *)&cmd_lfc_set_rx_mode,
4603 (void *)&cmd_lfc_set_tx,
4604 (void *)&cmd_lfc_set_tx_mode,
4605 (void *)&cmd_lfc_set_high_water,
4606 (void *)&cmd_lfc_set_low_water,
4607 (void *)&cmd_lfc_set_pause_time,
4608 (void *)&cmd_lfc_set_send_xon,
4609 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4610 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4611 (void *)&cmd_lfc_set_autoneg_str,
4612 (void *)&cmd_lfc_set_autoneg,
4613 (void *)&cmd_lfc_set_portid,
4618 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4619 .f = cmd_link_flow_ctrl_set_parsed,
4620 .data = (void *)&cmd_link_flow_control_set_rx,
4621 .help_str = "Change rx flow control parameter: set flow_ctrl "
4622 "rx on|off port_id",
4624 (void *)&cmd_lfc_set_set,
4625 (void *)&cmd_lfc_set_flow_ctrl,
4626 (void *)&cmd_lfc_set_rx,
4627 (void *)&cmd_lfc_set_rx_mode,
4628 (void *)&cmd_lfc_set_portid,
4633 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4634 .f = cmd_link_flow_ctrl_set_parsed,
4635 .data = (void *)&cmd_link_flow_control_set_tx,
4636 .help_str = "Change tx flow control parameter: set flow_ctrl "
4637 "tx on|off port_id",
4639 (void *)&cmd_lfc_set_set,
4640 (void *)&cmd_lfc_set_flow_ctrl,
4641 (void *)&cmd_lfc_set_tx,
4642 (void *)&cmd_lfc_set_tx_mode,
4643 (void *)&cmd_lfc_set_portid,
4648 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4649 .f = cmd_link_flow_ctrl_set_parsed,
4650 .data = (void *)&cmd_link_flow_control_set_hw,
4651 .help_str = "Change high water flow control parameter: set flow_ctrl "
4652 "high_water value port_id",
4654 (void *)&cmd_lfc_set_set,
4655 (void *)&cmd_lfc_set_flow_ctrl,
4656 (void *)&cmd_lfc_set_high_water_str,
4657 (void *)&cmd_lfc_set_high_water,
4658 (void *)&cmd_lfc_set_portid,
4663 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4664 .f = cmd_link_flow_ctrl_set_parsed,
4665 .data = (void *)&cmd_link_flow_control_set_lw,
4666 .help_str = "Change low water flow control parameter: set flow_ctrl "
4667 "low_water value port_id",
4669 (void *)&cmd_lfc_set_set,
4670 (void *)&cmd_lfc_set_flow_ctrl,
4671 (void *)&cmd_lfc_set_low_water_str,
4672 (void *)&cmd_lfc_set_low_water,
4673 (void *)&cmd_lfc_set_portid,
4678 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4679 .f = cmd_link_flow_ctrl_set_parsed,
4680 .data = (void *)&cmd_link_flow_control_set_pt,
4681 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4682 "pause_time value port_id",
4684 (void *)&cmd_lfc_set_set,
4685 (void *)&cmd_lfc_set_flow_ctrl,
4686 (void *)&cmd_lfc_set_pause_time_str,
4687 (void *)&cmd_lfc_set_pause_time,
4688 (void *)&cmd_lfc_set_portid,
4693 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4694 .f = cmd_link_flow_ctrl_set_parsed,
4695 .data = (void *)&cmd_link_flow_control_set_xon,
4696 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4697 "send_xon value port_id",
4699 (void *)&cmd_lfc_set_set,
4700 (void *)&cmd_lfc_set_flow_ctrl,
4701 (void *)&cmd_lfc_set_send_xon_str,
4702 (void *)&cmd_lfc_set_send_xon,
4703 (void *)&cmd_lfc_set_portid,
4708 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4709 .f = cmd_link_flow_ctrl_set_parsed,
4710 .data = (void *)&cmd_link_flow_control_set_macfwd,
4711 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4712 "mac_ctrl_frame_fwd on|off port_id",
4714 (void *)&cmd_lfc_set_set,
4715 (void *)&cmd_lfc_set_flow_ctrl,
4716 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4717 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4718 (void *)&cmd_lfc_set_portid,
4723 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4724 .f = cmd_link_flow_ctrl_set_parsed,
4725 .data = (void *)&cmd_link_flow_control_set_autoneg,
4726 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4727 "autoneg on|off port_id",
4729 (void *)&cmd_lfc_set_set,
4730 (void *)&cmd_lfc_set_flow_ctrl,
4731 (void *)&cmd_lfc_set_autoneg_str,
4732 (void *)&cmd_lfc_set_autoneg,
4733 (void *)&cmd_lfc_set_portid,
4739 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4740 __attribute__((unused)) struct cmdline *cl,
4743 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4744 cmdline_parse_inst_t *cmd = data;
4745 struct rte_eth_fc_conf fc_conf;
4746 int rx_fc_en, tx_fc_en;
4750 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4751 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4752 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4753 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4755 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4756 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4759 /* Partial command line, retrieve current configuration */
4761 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4763 printf("cannot get current flow ctrl parameters, return"
4764 "code = %d\n", ret);
4768 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4769 (fc_conf.mode == RTE_FC_FULL))
4771 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4772 (fc_conf.mode == RTE_FC_FULL))
4776 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4777 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4779 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4780 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4782 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4784 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4785 fc_conf.high_water = res->high_water;
4787 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4788 fc_conf.low_water = res->low_water;
4790 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4791 fc_conf.pause_time = res->pause_time;
4793 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4794 fc_conf.send_xon = res->send_xon;
4796 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4797 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4798 fc_conf.mac_ctrl_frame_fwd = 1;
4800 fc_conf.mac_ctrl_frame_fwd = 0;
4803 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4804 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4806 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4808 printf("bad flow contrl parameter, return code = %d \n", ret);
4811 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4812 struct cmd_priority_flow_ctrl_set_result {
4813 cmdline_fixed_string_t set;
4814 cmdline_fixed_string_t pfc_ctrl;
4815 cmdline_fixed_string_t rx;
4816 cmdline_fixed_string_t rx_pfc_mode;
4817 cmdline_fixed_string_t tx;
4818 cmdline_fixed_string_t tx_pfc_mode;
4819 uint32_t high_water;
4821 uint16_t pause_time;
4827 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4828 __attribute__((unused)) struct cmdline *cl,
4829 __attribute__((unused)) void *data)
4831 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4832 struct rte_eth_pfc_conf pfc_conf;
4833 int rx_fc_enable, tx_fc_enable;
4837 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4838 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4839 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4840 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4842 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4843 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4846 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4847 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4848 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4849 pfc_conf.fc.high_water = res->high_water;
4850 pfc_conf.fc.low_water = res->low_water;
4851 pfc_conf.fc.pause_time = res->pause_time;
4852 pfc_conf.priority = res->priority;
4854 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4856 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4859 cmdline_parse_token_string_t cmd_pfc_set_set =
4860 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4862 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4863 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4864 pfc_ctrl, "pfc_ctrl");
4865 cmdline_parse_token_string_t cmd_pfc_set_rx =
4866 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4868 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4869 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4870 rx_pfc_mode, "on#off");
4871 cmdline_parse_token_string_t cmd_pfc_set_tx =
4872 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4874 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4875 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4876 tx_pfc_mode, "on#off");
4877 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4878 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4879 high_water, UINT32);
4880 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4881 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4883 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4884 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4885 pause_time, UINT16);
4886 cmdline_parse_token_num_t cmd_pfc_set_priority =
4887 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4889 cmdline_parse_token_num_t cmd_pfc_set_portid =
4890 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4893 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4894 .f = cmd_priority_flow_ctrl_set_parsed,
4896 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4897 tx on|off high_water low_water pause_time priority port_id",
4899 (void *)&cmd_pfc_set_set,
4900 (void *)&cmd_pfc_set_flow_ctrl,
4901 (void *)&cmd_pfc_set_rx,
4902 (void *)&cmd_pfc_set_rx_mode,
4903 (void *)&cmd_pfc_set_tx,
4904 (void *)&cmd_pfc_set_tx_mode,
4905 (void *)&cmd_pfc_set_high_water,
4906 (void *)&cmd_pfc_set_low_water,
4907 (void *)&cmd_pfc_set_pause_time,
4908 (void *)&cmd_pfc_set_priority,
4909 (void *)&cmd_pfc_set_portid,
4914 /* *** RESET CONFIGURATION *** */
4915 struct cmd_reset_result {
4916 cmdline_fixed_string_t reset;
4917 cmdline_fixed_string_t def;
4920 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4922 __attribute__((unused)) void *data)
4924 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4925 set_def_fwd_config();
4928 cmdline_parse_token_string_t cmd_reset_set =
4929 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4930 cmdline_parse_token_string_t cmd_reset_def =
4931 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4934 cmdline_parse_inst_t cmd_reset = {
4935 .f = cmd_reset_parsed,
4937 .help_str = "set default: reset default forwarding configuration",
4939 (void *)&cmd_reset_set,
4940 (void *)&cmd_reset_def,
4945 /* *** START FORWARDING *** */
4946 struct cmd_start_result {
4947 cmdline_fixed_string_t start;
4950 cmdline_parse_token_string_t cmd_start_start =
4951 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4953 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4954 __attribute__((unused)) struct cmdline *cl,
4955 __attribute__((unused)) void *data)
4957 start_packet_forwarding(0);
4960 cmdline_parse_inst_t cmd_start = {
4961 .f = cmd_start_parsed,
4963 .help_str = "start packet forwarding",
4965 (void *)&cmd_start_start,
4970 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4971 struct cmd_start_tx_first_result {
4972 cmdline_fixed_string_t start;
4973 cmdline_fixed_string_t tx_first;
4977 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4978 __attribute__((unused)) struct cmdline *cl,
4979 __attribute__((unused)) void *data)
4981 start_packet_forwarding(1);
4984 cmdline_parse_token_string_t cmd_start_tx_first_start =
4985 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4987 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4988 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4989 tx_first, "tx_first");
4991 cmdline_parse_inst_t cmd_start_tx_first = {
4992 .f = cmd_start_tx_first_parsed,
4994 .help_str = "start packet forwarding, after sending 1 burst of packets",
4996 (void *)&cmd_start_tx_first_start,
4997 (void *)&cmd_start_tx_first_tx_first,
5002 /* *** SET LINK UP *** */
5003 struct cmd_set_link_up_result {
5004 cmdline_fixed_string_t set;
5005 cmdline_fixed_string_t link_up;
5006 cmdline_fixed_string_t port;
5010 cmdline_parse_token_string_t cmd_set_link_up_set =
5011 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5012 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5013 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5015 cmdline_parse_token_string_t cmd_set_link_up_port =
5016 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5017 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5018 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5020 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5021 __attribute__((unused)) struct cmdline *cl,
5022 __attribute__((unused)) void *data)
5024 struct cmd_set_link_up_result *res = parsed_result;
5025 dev_set_link_up(res->port_id);
5028 cmdline_parse_inst_t cmd_set_link_up = {
5029 .f = cmd_set_link_up_parsed,
5031 .help_str = "set link-up port (port id)",
5033 (void *)&cmd_set_link_up_set,
5034 (void *)&cmd_set_link_up_link_up,
5035 (void *)&cmd_set_link_up_port,
5036 (void *)&cmd_set_link_up_port_id,
5041 /* *** SET LINK DOWN *** */
5042 struct cmd_set_link_down_result {
5043 cmdline_fixed_string_t set;
5044 cmdline_fixed_string_t link_down;
5045 cmdline_fixed_string_t port;
5049 cmdline_parse_token_string_t cmd_set_link_down_set =
5050 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5051 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5052 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5054 cmdline_parse_token_string_t cmd_set_link_down_port =
5055 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5056 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5057 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5059 static void cmd_set_link_down_parsed(
5060 __attribute__((unused)) void *parsed_result,
5061 __attribute__((unused)) struct cmdline *cl,
5062 __attribute__((unused)) void *data)
5064 struct cmd_set_link_down_result *res = parsed_result;
5065 dev_set_link_down(res->port_id);
5068 cmdline_parse_inst_t cmd_set_link_down = {
5069 .f = cmd_set_link_down_parsed,
5071 .help_str = "set link-down port (port id)",
5073 (void *)&cmd_set_link_down_set,
5074 (void *)&cmd_set_link_down_link_down,
5075 (void *)&cmd_set_link_down_port,
5076 (void *)&cmd_set_link_down_port_id,
5081 /* *** SHOW CFG *** */
5082 struct cmd_showcfg_result {
5083 cmdline_fixed_string_t show;
5084 cmdline_fixed_string_t cfg;
5085 cmdline_fixed_string_t what;
5088 static void cmd_showcfg_parsed(void *parsed_result,
5089 __attribute__((unused)) struct cmdline *cl,
5090 __attribute__((unused)) void *data)
5092 struct cmd_showcfg_result *res = parsed_result;
5093 if (!strcmp(res->what, "rxtx"))
5094 rxtx_config_display();
5095 else if (!strcmp(res->what, "cores"))
5096 fwd_lcores_config_display();
5097 else if (!strcmp(res->what, "fwd"))
5098 fwd_config_display();
5101 cmdline_parse_token_string_t cmd_showcfg_show =
5102 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5103 cmdline_parse_token_string_t cmd_showcfg_port =
5104 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5105 cmdline_parse_token_string_t cmd_showcfg_what =
5106 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5109 cmdline_parse_inst_t cmd_showcfg = {
5110 .f = cmd_showcfg_parsed,
5112 .help_str = "show config rxtx|cores|fwd",
5114 (void *)&cmd_showcfg_show,
5115 (void *)&cmd_showcfg_port,
5116 (void *)&cmd_showcfg_what,
5121 /* *** SHOW ALL PORT INFO *** */
5122 struct cmd_showportall_result {
5123 cmdline_fixed_string_t show;
5124 cmdline_fixed_string_t port;
5125 cmdline_fixed_string_t what;
5126 cmdline_fixed_string_t all;
5129 static void cmd_showportall_parsed(void *parsed_result,
5130 __attribute__((unused)) struct cmdline *cl,
5131 __attribute__((unused)) void *data)
5135 struct cmd_showportall_result *res = parsed_result;
5136 if (!strcmp(res->show, "clear")) {
5137 if (!strcmp(res->what, "stats"))
5138 for (i = 0; i < nb_ports; i++)
5140 else if (!strcmp(res->what, "xstats"))
5141 for (i = 0; i < nb_ports; i++)
5142 nic_xstats_clear(i);
5143 } else if (!strcmp(res->what, "info"))
5144 for (i = 0; i < nb_ports; i++)
5145 port_infos_display(i);
5146 else if (!strcmp(res->what, "stats"))
5147 for (i = 0; i < nb_ports; i++)
5148 nic_stats_display(i);
5149 else if (!strcmp(res->what, "xstats"))
5150 for (i = 0; i < nb_ports; i++)
5151 nic_xstats_display(i);
5152 else if (!strcmp(res->what, "fdir"))
5153 for (i = 0; i < nb_ports; i++)
5155 else if (!strcmp(res->what, "stat_qmap"))
5156 for (i = 0; i < nb_ports; i++)
5157 nic_stats_mapping_display(i);
5160 cmdline_parse_token_string_t cmd_showportall_show =
5161 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5163 cmdline_parse_token_string_t cmd_showportall_port =
5164 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5165 cmdline_parse_token_string_t cmd_showportall_what =
5166 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5167 "info#stats#xstats#fdir#stat_qmap");
5168 cmdline_parse_token_string_t cmd_showportall_all =
5169 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5170 cmdline_parse_inst_t cmd_showportall = {
5171 .f = cmd_showportall_parsed,
5173 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5175 (void *)&cmd_showportall_show,
5176 (void *)&cmd_showportall_port,
5177 (void *)&cmd_showportall_what,
5178 (void *)&cmd_showportall_all,
5183 /* *** SHOW PORT INFO *** */
5184 struct cmd_showport_result {
5185 cmdline_fixed_string_t show;
5186 cmdline_fixed_string_t port;
5187 cmdline_fixed_string_t what;
5191 static void cmd_showport_parsed(void *parsed_result,
5192 __attribute__((unused)) struct cmdline *cl,
5193 __attribute__((unused)) void *data)
5195 struct cmd_showport_result *res = parsed_result;
5196 if (!strcmp(res->show, "clear")) {
5197 if (!strcmp(res->what, "stats"))
5198 nic_stats_clear(res->portnum);
5199 else if (!strcmp(res->what, "xstats"))
5200 nic_xstats_clear(res->portnum);
5201 } else if (!strcmp(res->what, "info"))
5202 port_infos_display(res->portnum);
5203 else if (!strcmp(res->what, "stats"))
5204 nic_stats_display(res->portnum);
5205 else if (!strcmp(res->what, "xstats"))
5206 nic_xstats_display(res->portnum);
5207 else if (!strcmp(res->what, "fdir"))
5208 fdir_get_infos(res->portnum);
5209 else if (!strcmp(res->what, "stat_qmap"))
5210 nic_stats_mapping_display(res->portnum);
5213 cmdline_parse_token_string_t cmd_showport_show =
5214 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5216 cmdline_parse_token_string_t cmd_showport_port =
5217 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5218 cmdline_parse_token_string_t cmd_showport_what =
5219 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5220 "info#stats#xstats#fdir#stat_qmap");
5221 cmdline_parse_token_num_t cmd_showport_portnum =
5222 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5224 cmdline_parse_inst_t cmd_showport = {
5225 .f = cmd_showport_parsed,
5227 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5229 (void *)&cmd_showport_show,
5230 (void *)&cmd_showport_port,
5231 (void *)&cmd_showport_what,
5232 (void *)&cmd_showport_portnum,
5237 /* *** READ PORT REGISTER *** */
5238 struct cmd_read_reg_result {
5239 cmdline_fixed_string_t read;
5240 cmdline_fixed_string_t reg;
5246 cmd_read_reg_parsed(void *parsed_result,
5247 __attribute__((unused)) struct cmdline *cl,
5248 __attribute__((unused)) void *data)
5250 struct cmd_read_reg_result *res = parsed_result;
5251 port_reg_display(res->port_id, res->reg_off);
5254 cmdline_parse_token_string_t cmd_read_reg_read =
5255 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5256 cmdline_parse_token_string_t cmd_read_reg_reg =
5257 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5258 cmdline_parse_token_num_t cmd_read_reg_port_id =
5259 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5260 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5261 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5263 cmdline_parse_inst_t cmd_read_reg = {
5264 .f = cmd_read_reg_parsed,
5266 .help_str = "read reg port_id reg_off",
5268 (void *)&cmd_read_reg_read,
5269 (void *)&cmd_read_reg_reg,
5270 (void *)&cmd_read_reg_port_id,
5271 (void *)&cmd_read_reg_reg_off,
5276 /* *** READ PORT REGISTER BIT FIELD *** */
5277 struct cmd_read_reg_bit_field_result {
5278 cmdline_fixed_string_t read;
5279 cmdline_fixed_string_t regfield;
5287 cmd_read_reg_bit_field_parsed(void *parsed_result,
5288 __attribute__((unused)) struct cmdline *cl,
5289 __attribute__((unused)) void *data)
5291 struct cmd_read_reg_bit_field_result *res = parsed_result;
5292 port_reg_bit_field_display(res->port_id, res->reg_off,
5293 res->bit1_pos, res->bit2_pos);
5296 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5297 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5299 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5300 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5301 regfield, "regfield");
5302 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5303 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5305 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5306 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5308 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5309 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5311 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5312 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5315 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5316 .f = cmd_read_reg_bit_field_parsed,
5318 .help_str = "read regfield port_id reg_off bit_x bit_y "
5319 "(read register bit field between bit_x and bit_y included)",
5321 (void *)&cmd_read_reg_bit_field_read,
5322 (void *)&cmd_read_reg_bit_field_regfield,
5323 (void *)&cmd_read_reg_bit_field_port_id,
5324 (void *)&cmd_read_reg_bit_field_reg_off,
5325 (void *)&cmd_read_reg_bit_field_bit1_pos,
5326 (void *)&cmd_read_reg_bit_field_bit2_pos,
5331 /* *** READ PORT REGISTER BIT *** */
5332 struct cmd_read_reg_bit_result {
5333 cmdline_fixed_string_t read;
5334 cmdline_fixed_string_t regbit;
5341 cmd_read_reg_bit_parsed(void *parsed_result,
5342 __attribute__((unused)) struct cmdline *cl,
5343 __attribute__((unused)) void *data)
5345 struct cmd_read_reg_bit_result *res = parsed_result;
5346 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5349 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5350 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5351 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5352 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5354 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5355 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5356 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5357 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5358 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5359 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5361 cmdline_parse_inst_t cmd_read_reg_bit = {
5362 .f = cmd_read_reg_bit_parsed,
5364 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5366 (void *)&cmd_read_reg_bit_read,
5367 (void *)&cmd_read_reg_bit_regbit,
5368 (void *)&cmd_read_reg_bit_port_id,
5369 (void *)&cmd_read_reg_bit_reg_off,
5370 (void *)&cmd_read_reg_bit_bit_pos,
5375 /* *** WRITE PORT REGISTER *** */
5376 struct cmd_write_reg_result {
5377 cmdline_fixed_string_t write;
5378 cmdline_fixed_string_t reg;
5385 cmd_write_reg_parsed(void *parsed_result,
5386 __attribute__((unused)) struct cmdline *cl,
5387 __attribute__((unused)) void *data)
5389 struct cmd_write_reg_result *res = parsed_result;
5390 port_reg_set(res->port_id, res->reg_off, res->value);
5393 cmdline_parse_token_string_t cmd_write_reg_write =
5394 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5395 cmdline_parse_token_string_t cmd_write_reg_reg =
5396 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5397 cmdline_parse_token_num_t cmd_write_reg_port_id =
5398 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5399 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5400 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5401 cmdline_parse_token_num_t cmd_write_reg_value =
5402 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5404 cmdline_parse_inst_t cmd_write_reg = {
5405 .f = cmd_write_reg_parsed,
5407 .help_str = "write reg port_id reg_off reg_value",
5409 (void *)&cmd_write_reg_write,
5410 (void *)&cmd_write_reg_reg,
5411 (void *)&cmd_write_reg_port_id,
5412 (void *)&cmd_write_reg_reg_off,
5413 (void *)&cmd_write_reg_value,
5418 /* *** WRITE PORT REGISTER BIT FIELD *** */
5419 struct cmd_write_reg_bit_field_result {
5420 cmdline_fixed_string_t write;
5421 cmdline_fixed_string_t regfield;
5430 cmd_write_reg_bit_field_parsed(void *parsed_result,
5431 __attribute__((unused)) struct cmdline *cl,
5432 __attribute__((unused)) void *data)
5434 struct cmd_write_reg_bit_field_result *res = parsed_result;
5435 port_reg_bit_field_set(res->port_id, res->reg_off,
5436 res->bit1_pos, res->bit2_pos, res->value);
5439 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5440 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5442 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5443 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5444 regfield, "regfield");
5445 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5446 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5448 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5449 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5451 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5452 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5454 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5455 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5457 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5458 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5461 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5462 .f = cmd_write_reg_bit_field_parsed,
5464 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5465 "(set register bit field between bit_x and bit_y included)",
5467 (void *)&cmd_write_reg_bit_field_write,
5468 (void *)&cmd_write_reg_bit_field_regfield,
5469 (void *)&cmd_write_reg_bit_field_port_id,
5470 (void *)&cmd_write_reg_bit_field_reg_off,
5471 (void *)&cmd_write_reg_bit_field_bit1_pos,
5472 (void *)&cmd_write_reg_bit_field_bit2_pos,
5473 (void *)&cmd_write_reg_bit_field_value,
5478 /* *** WRITE PORT REGISTER BIT *** */
5479 struct cmd_write_reg_bit_result {
5480 cmdline_fixed_string_t write;
5481 cmdline_fixed_string_t regbit;
5489 cmd_write_reg_bit_parsed(void *parsed_result,
5490 __attribute__((unused)) struct cmdline *cl,
5491 __attribute__((unused)) void *data)
5493 struct cmd_write_reg_bit_result *res = parsed_result;
5494 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5497 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5498 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5500 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5501 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5503 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5504 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5505 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5506 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5507 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5508 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5509 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5510 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5512 cmdline_parse_inst_t cmd_write_reg_bit = {
5513 .f = cmd_write_reg_bit_parsed,
5515 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5517 (void *)&cmd_write_reg_bit_write,
5518 (void *)&cmd_write_reg_bit_regbit,
5519 (void *)&cmd_write_reg_bit_port_id,
5520 (void *)&cmd_write_reg_bit_reg_off,
5521 (void *)&cmd_write_reg_bit_bit_pos,
5522 (void *)&cmd_write_reg_bit_value,
5527 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5528 struct cmd_read_rxd_txd_result {
5529 cmdline_fixed_string_t read;
5530 cmdline_fixed_string_t rxd_txd;
5537 cmd_read_rxd_txd_parsed(void *parsed_result,
5538 __attribute__((unused)) struct cmdline *cl,
5539 __attribute__((unused)) void *data)
5541 struct cmd_read_rxd_txd_result *res = parsed_result;
5543 if (!strcmp(res->rxd_txd, "rxd"))
5544 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5545 else if (!strcmp(res->rxd_txd, "txd"))
5546 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5549 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5550 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5551 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5552 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5554 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5555 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5556 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5557 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5558 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5559 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5561 cmdline_parse_inst_t cmd_read_rxd_txd = {
5562 .f = cmd_read_rxd_txd_parsed,
5564 .help_str = "read rxd|txd port_id queue_id rxd_id",
5566 (void *)&cmd_read_rxd_txd_read,
5567 (void *)&cmd_read_rxd_txd_rxd_txd,
5568 (void *)&cmd_read_rxd_txd_port_id,
5569 (void *)&cmd_read_rxd_txd_queue_id,
5570 (void *)&cmd_read_rxd_txd_desc_id,
5576 struct cmd_quit_result {
5577 cmdline_fixed_string_t quit;
5580 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5582 __attribute__((unused)) void *data)
5588 cmdline_parse_token_string_t cmd_quit_quit =
5589 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5591 cmdline_parse_inst_t cmd_quit = {
5592 .f = cmd_quit_parsed,
5594 .help_str = "exit application",
5596 (void *)&cmd_quit_quit,
5601 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5602 struct cmd_mac_addr_result {
5603 cmdline_fixed_string_t mac_addr_cmd;
5604 cmdline_fixed_string_t what;
5606 struct ether_addr address;
5609 static void cmd_mac_addr_parsed(void *parsed_result,
5610 __attribute__((unused)) struct cmdline *cl,
5611 __attribute__((unused)) void *data)
5613 struct cmd_mac_addr_result *res = parsed_result;
5616 if (strcmp(res->what, "add") == 0)
5617 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5619 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5621 /* check the return value and print it if is < 0 */
5623 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5627 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5628 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5630 cmdline_parse_token_string_t cmd_mac_addr_what =
5631 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5633 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5634 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5635 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5636 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5638 cmdline_parse_inst_t cmd_mac_addr = {
5639 .f = cmd_mac_addr_parsed,
5641 .help_str = "mac_addr add|remove X <address>: "
5642 "add/remove MAC address on port X",
5644 (void *)&cmd_mac_addr_cmd,
5645 (void *)&cmd_mac_addr_what,
5646 (void *)&cmd_mac_addr_portnum,
5647 (void *)&cmd_mac_addr_addr,
5653 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5654 struct cmd_set_qmap_result {
5655 cmdline_fixed_string_t set;
5656 cmdline_fixed_string_t qmap;
5657 cmdline_fixed_string_t what;
5664 cmd_set_qmap_parsed(void *parsed_result,
5665 __attribute__((unused)) struct cmdline *cl,
5666 __attribute__((unused)) void *data)
5668 struct cmd_set_qmap_result *res = parsed_result;
5669 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5671 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5674 cmdline_parse_token_string_t cmd_setqmap_set =
5675 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5677 cmdline_parse_token_string_t cmd_setqmap_qmap =
5678 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5680 cmdline_parse_token_string_t cmd_setqmap_what =
5681 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5683 cmdline_parse_token_num_t cmd_setqmap_portid =
5684 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5686 cmdline_parse_token_num_t cmd_setqmap_queueid =
5687 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5689 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5690 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5693 cmdline_parse_inst_t cmd_set_qmap = {
5694 .f = cmd_set_qmap_parsed,
5696 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5698 (void *)&cmd_setqmap_set,
5699 (void *)&cmd_setqmap_qmap,
5700 (void *)&cmd_setqmap_what,
5701 (void *)&cmd_setqmap_portid,
5702 (void *)&cmd_setqmap_queueid,
5703 (void *)&cmd_setqmap_mapvalue,
5708 /* *** CONFIGURE UNICAST HASH TABLE *** */
5709 struct cmd_set_uc_hash_table {
5710 cmdline_fixed_string_t set;
5711 cmdline_fixed_string_t port;
5713 cmdline_fixed_string_t what;
5714 struct ether_addr address;
5715 cmdline_fixed_string_t mode;
5719 cmd_set_uc_hash_parsed(void *parsed_result,
5720 __attribute__((unused)) struct cmdline *cl,
5721 __attribute__((unused)) void *data)
5724 struct cmd_set_uc_hash_table *res = parsed_result;
5726 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5728 if (strcmp(res->what, "uta") == 0)
5729 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5730 &res->address,(uint8_t)is_on);
5732 printf("bad unicast hash table parameter, return code = %d \n", ret);
5736 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5737 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5739 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5740 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5742 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5743 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5745 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5746 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5748 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5749 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5751 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5752 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5755 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5756 .f = cmd_set_uc_hash_parsed,
5758 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5760 (void *)&cmd_set_uc_hash_set,
5761 (void *)&cmd_set_uc_hash_port,
5762 (void *)&cmd_set_uc_hash_portid,
5763 (void *)&cmd_set_uc_hash_what,
5764 (void *)&cmd_set_uc_hash_mac,
5765 (void *)&cmd_set_uc_hash_mode,
5770 struct cmd_set_uc_all_hash_table {
5771 cmdline_fixed_string_t set;
5772 cmdline_fixed_string_t port;
5774 cmdline_fixed_string_t what;
5775 cmdline_fixed_string_t value;
5776 cmdline_fixed_string_t mode;
5780 cmd_set_uc_all_hash_parsed(void *parsed_result,
5781 __attribute__((unused)) struct cmdline *cl,
5782 __attribute__((unused)) void *data)
5785 struct cmd_set_uc_all_hash_table *res = parsed_result;
5787 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5789 if ((strcmp(res->what, "uta") == 0) &&
5790 (strcmp(res->value, "all") == 0))
5791 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5793 printf("bad unicast hash table parameter,"
5794 "return code = %d \n", ret);
5797 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5798 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5800 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5801 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5803 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5804 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5806 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5807 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5809 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5810 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5812 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5813 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5816 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5817 .f = cmd_set_uc_all_hash_parsed,
5819 .help_str = "set port X uta all on|off (X = port number)",
5821 (void *)&cmd_set_uc_all_hash_set,
5822 (void *)&cmd_set_uc_all_hash_port,
5823 (void *)&cmd_set_uc_all_hash_portid,
5824 (void *)&cmd_set_uc_all_hash_what,
5825 (void *)&cmd_set_uc_all_hash_value,
5826 (void *)&cmd_set_uc_all_hash_mode,
5831 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5832 struct cmd_set_vf_traffic {
5833 cmdline_fixed_string_t set;
5834 cmdline_fixed_string_t port;
5836 cmdline_fixed_string_t vf;
5838 cmdline_fixed_string_t what;
5839 cmdline_fixed_string_t mode;
5843 cmd_set_vf_traffic_parsed(void *parsed_result,
5844 __attribute__((unused)) struct cmdline *cl,
5845 __attribute__((unused)) void *data)
5847 struct cmd_set_vf_traffic *res = parsed_result;
5848 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5849 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5851 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5854 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5855 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5857 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5858 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5860 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5861 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5863 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5864 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5866 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5867 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5869 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5870 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5872 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5873 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5876 cmdline_parse_inst_t cmd_set_vf_traffic = {
5877 .f = cmd_set_vf_traffic_parsed,
5879 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
5881 (void *)&cmd_setvf_traffic_set,
5882 (void *)&cmd_setvf_traffic_port,
5883 (void *)&cmd_setvf_traffic_portid,
5884 (void *)&cmd_setvf_traffic_vf,
5885 (void *)&cmd_setvf_traffic_vfid,
5886 (void *)&cmd_setvf_traffic_what,
5887 (void *)&cmd_setvf_traffic_mode,
5892 /* *** CONFIGURE VF RECEIVE MODE *** */
5893 struct cmd_set_vf_rxmode {
5894 cmdline_fixed_string_t set;
5895 cmdline_fixed_string_t port;
5897 cmdline_fixed_string_t vf;
5899 cmdline_fixed_string_t what;
5900 cmdline_fixed_string_t mode;
5901 cmdline_fixed_string_t on;
5905 cmd_set_vf_rxmode_parsed(void *parsed_result,
5906 __attribute__((unused)) struct cmdline *cl,
5907 __attribute__((unused)) void *data)
5910 uint16_t rx_mode = 0;
5911 struct cmd_set_vf_rxmode *res = parsed_result;
5913 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5914 if (!strcmp(res->what,"rxmode")) {
5915 if (!strcmp(res->mode, "AUPE"))
5916 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5917 else if (!strcmp(res->mode, "ROPE"))
5918 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5919 else if (!strcmp(res->mode, "BAM"))
5920 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5921 else if (!strncmp(res->mode, "MPE",3))
5922 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5925 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5927 printf("bad VF receive mode parameter, return code = %d \n",
5931 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5932 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5934 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5935 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5937 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5938 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5940 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5941 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5943 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5944 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5946 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5947 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5949 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5950 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5951 mode, "AUPE#ROPE#BAM#MPE");
5952 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5953 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5956 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5957 .f = cmd_set_vf_rxmode_parsed,
5959 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5961 (void *)&cmd_set_vf_rxmode_set,
5962 (void *)&cmd_set_vf_rxmode_port,
5963 (void *)&cmd_set_vf_rxmode_portid,
5964 (void *)&cmd_set_vf_rxmode_vf,
5965 (void *)&cmd_set_vf_rxmode_vfid,
5966 (void *)&cmd_set_vf_rxmode_what,
5967 (void *)&cmd_set_vf_rxmode_mode,
5968 (void *)&cmd_set_vf_rxmode_on,
5973 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5974 struct cmd_vf_mac_addr_result {
5975 cmdline_fixed_string_t mac_addr_cmd;
5976 cmdline_fixed_string_t what;
5977 cmdline_fixed_string_t port;
5979 cmdline_fixed_string_t vf;
5981 struct ether_addr address;
5984 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5985 __attribute__((unused)) struct cmdline *cl,
5986 __attribute__((unused)) void *data)
5988 struct cmd_vf_mac_addr_result *res = parsed_result;
5991 if (strcmp(res->what, "add") == 0)
5992 ret = rte_eth_dev_mac_addr_add(res->port_num,
5993 &res->address, res->vf_num);
5995 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5999 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6000 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6001 mac_addr_cmd,"mac_addr");
6002 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6003 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6005 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6006 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6008 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6009 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6011 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6012 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6014 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6015 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6017 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6018 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6021 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6022 .f = cmd_vf_mac_addr_parsed,
6024 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6025 "Y = VF number)add MAC address filtering for a VF on port X",
6027 (void *)&cmd_vf_mac_addr_cmd,
6028 (void *)&cmd_vf_mac_addr_what,
6029 (void *)&cmd_vf_mac_addr_port,
6030 (void *)&cmd_vf_mac_addr_portnum,
6031 (void *)&cmd_vf_mac_addr_vf,
6032 (void *)&cmd_vf_mac_addr_vfnum,
6033 (void *)&cmd_vf_mac_addr_addr,
6038 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6039 struct cmd_vf_rx_vlan_filter {
6040 cmdline_fixed_string_t rx_vlan;
6041 cmdline_fixed_string_t what;
6043 cmdline_fixed_string_t port;
6045 cmdline_fixed_string_t vf;
6050 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6051 __attribute__((unused)) struct cmdline *cl,
6052 __attribute__((unused)) void *data)
6054 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6056 if (!strcmp(res->what, "add"))
6057 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6059 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6062 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6063 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6064 rx_vlan, "rx_vlan");
6065 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6066 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6068 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6069 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6071 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6072 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6074 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6075 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6077 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6078 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6080 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6081 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6084 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6085 .f = cmd_vf_rx_vlan_filter_parsed,
6087 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6088 "Y = port number,Z = hexadecimal VF mask)",
6090 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6091 (void *)&cmd_vf_rx_vlan_filter_what,
6092 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6093 (void *)&cmd_vf_rx_vlan_filter_port,
6094 (void *)&cmd_vf_rx_vlan_filter_portid,
6095 (void *)&cmd_vf_rx_vlan_filter_vf,
6096 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6101 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6102 struct cmd_queue_rate_limit_result {
6103 cmdline_fixed_string_t set;
6104 cmdline_fixed_string_t port;
6106 cmdline_fixed_string_t queue;
6108 cmdline_fixed_string_t rate;
6112 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6113 __attribute__((unused)) struct cmdline *cl,
6114 __attribute__((unused)) void *data)
6116 struct cmd_queue_rate_limit_result *res = parsed_result;
6119 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6120 && (strcmp(res->queue, "queue") == 0)
6121 && (strcmp(res->rate, "rate") == 0))
6122 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6125 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6129 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6130 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6132 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6133 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6135 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6136 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6138 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6139 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6141 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6142 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6144 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6145 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6147 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6148 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6151 cmdline_parse_inst_t cmd_queue_rate_limit = {
6152 .f = cmd_queue_rate_limit_parsed,
6154 .help_str = "set port X queue Y rate Z:(X = port number,"
6155 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6157 (void *)&cmd_queue_rate_limit_set,
6158 (void *)&cmd_queue_rate_limit_port,
6159 (void *)&cmd_queue_rate_limit_portnum,
6160 (void *)&cmd_queue_rate_limit_queue,
6161 (void *)&cmd_queue_rate_limit_queuenum,
6162 (void *)&cmd_queue_rate_limit_rate,
6163 (void *)&cmd_queue_rate_limit_ratenum,
6168 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6169 struct cmd_vf_rate_limit_result {
6170 cmdline_fixed_string_t set;
6171 cmdline_fixed_string_t port;
6173 cmdline_fixed_string_t vf;
6175 cmdline_fixed_string_t rate;
6177 cmdline_fixed_string_t q_msk;
6181 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6182 __attribute__((unused)) struct cmdline *cl,
6183 __attribute__((unused)) void *data)
6185 struct cmd_vf_rate_limit_result *res = parsed_result;
6188 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6189 && (strcmp(res->vf, "vf") == 0)
6190 && (strcmp(res->rate, "rate") == 0)
6191 && (strcmp(res->q_msk, "queue_mask") == 0))
6192 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6193 res->rate_num, res->q_msk_val);
6195 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6199 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6200 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6202 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6203 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6205 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6206 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6208 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6209 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6211 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6212 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6214 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6215 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6217 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6218 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6220 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6221 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6222 q_msk, "queue_mask");
6223 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6224 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6227 cmdline_parse_inst_t cmd_vf_rate_limit = {
6228 .f = cmd_vf_rate_limit_parsed,
6230 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6231 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6232 "for queues of VF on port X",
6234 (void *)&cmd_vf_rate_limit_set,
6235 (void *)&cmd_vf_rate_limit_port,
6236 (void *)&cmd_vf_rate_limit_portnum,
6237 (void *)&cmd_vf_rate_limit_vf,
6238 (void *)&cmd_vf_rate_limit_vfnum,
6239 (void *)&cmd_vf_rate_limit_rate,
6240 (void *)&cmd_vf_rate_limit_ratenum,
6241 (void *)&cmd_vf_rate_limit_q_msk,
6242 (void *)&cmd_vf_rate_limit_q_msk_val,
6247 /* *** ADD TUNNEL FILTER OF A PORT *** */
6248 struct cmd_tunnel_filter_result {
6249 cmdline_fixed_string_t cmd;
6250 cmdline_fixed_string_t what;
6252 struct ether_addr outer_mac;
6253 struct ether_addr inner_mac;
6254 cmdline_ipaddr_t ip_value;
6255 uint16_t inner_vlan;
6256 cmdline_fixed_string_t tunnel_type;
6257 cmdline_fixed_string_t filter_type;
6263 cmd_tunnel_filter_parsed(void *parsed_result,
6264 __attribute__((unused)) struct cmdline *cl,
6265 __attribute__((unused)) void *data)
6267 struct cmd_tunnel_filter_result *res = parsed_result;
6268 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6271 tunnel_filter_conf.outer_mac = &res->outer_mac;
6272 tunnel_filter_conf.inner_mac = &res->inner_mac;
6273 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6275 if (res->ip_value.family == AF_INET) {
6276 tunnel_filter_conf.ip_addr.ipv4_addr =
6277 res->ip_value.addr.ipv4.s_addr;
6278 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6280 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6281 &(res->ip_value.addr.ipv6),
6282 sizeof(struct in6_addr));
6283 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6286 if (!strcmp(res->filter_type, "imac-ivlan"))
6287 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6288 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6289 tunnel_filter_conf.filter_type =
6290 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6291 else if (!strcmp(res->filter_type, "imac-tenid"))
6292 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6293 else if (!strcmp(res->filter_type, "imac"))
6294 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6295 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6296 tunnel_filter_conf.filter_type =
6297 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6299 printf("The filter type is not supported");
6303 if (!strcmp(res->tunnel_type, "vxlan"))
6304 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6306 printf("Only VXLAN is supported now.\n");
6310 tunnel_filter_conf.tenant_id = res->tenant_id;
6311 tunnel_filter_conf.queue_id = res->queue_num;
6312 if (!strcmp(res->what, "add"))
6313 ret = rte_eth_dev_filter_ctrl(res->port_id,
6314 RTE_ETH_FILTER_TUNNEL,
6316 &tunnel_filter_conf);
6318 ret = rte_eth_dev_filter_ctrl(res->port_id,
6319 RTE_ETH_FILTER_TUNNEL,
6320 RTE_ETH_FILTER_DELETE,
6321 &tunnel_filter_conf);
6323 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6327 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6328 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6329 cmd, "tunnel_filter");
6330 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6331 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6333 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6334 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6336 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6337 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6339 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6340 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6342 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6343 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6344 inner_vlan, UINT16);
6345 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6346 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6348 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6349 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6350 tunnel_type, "vxlan");
6352 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6353 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6354 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6355 "imac#omac-imac-tenid");
6356 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6357 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6359 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6360 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6363 cmdline_parse_inst_t cmd_tunnel_filter = {
6364 .f = cmd_tunnel_filter_parsed,
6366 .help_str = "add/rm tunnel filter of a port: "
6367 "tunnel_filter add port_id outer_mac inner_mac ip "
6368 "inner_vlan tunnel_type(vxlan) filter_type "
6369 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6370 "imac|omac-imac-tenid) "
6371 "tenant_id queue_num",
6373 (void *)&cmd_tunnel_filter_cmd,
6374 (void *)&cmd_tunnel_filter_what,
6375 (void *)&cmd_tunnel_filter_port_id,
6376 (void *)&cmd_tunnel_filter_outer_mac,
6377 (void *)&cmd_tunnel_filter_inner_mac,
6378 (void *)&cmd_tunnel_filter_ip_value,
6379 (void *)&cmd_tunnel_filter_innner_vlan,
6380 (void *)&cmd_tunnel_filter_tunnel_type,
6381 (void *)&cmd_tunnel_filter_filter_type,
6382 (void *)&cmd_tunnel_filter_tenant_id,
6383 (void *)&cmd_tunnel_filter_queue_num,
6388 /* *** CONFIGURE TUNNEL UDP PORT *** */
6389 struct cmd_tunnel_udp_config {
6390 cmdline_fixed_string_t cmd;
6391 cmdline_fixed_string_t what;
6397 cmd_tunnel_udp_config_parsed(void *parsed_result,
6398 __attribute__((unused)) struct cmdline *cl,
6399 __attribute__((unused)) void *data)
6401 struct cmd_tunnel_udp_config *res = parsed_result;
6402 struct rte_eth_udp_tunnel tunnel_udp;
6405 tunnel_udp.udp_port = res->udp_port;
6407 if (!strcmp(res->cmd, "rx_vxlan_port"))
6408 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6410 if (!strcmp(res->what, "add"))
6411 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6413 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6416 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6419 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6420 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6421 cmd, "rx_vxlan_port");
6422 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6423 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6425 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6426 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6428 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6429 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6432 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6433 .f = cmd_tunnel_udp_config_parsed,
6435 .help_str = "add/rm an tunneling UDP port filter: "
6436 "rx_vxlan_port add udp_port port_id",
6438 (void *)&cmd_tunnel_udp_config_cmd,
6439 (void *)&cmd_tunnel_udp_config_what,
6440 (void *)&cmd_tunnel_udp_config_udp_port,
6441 (void *)&cmd_tunnel_udp_config_port_id,
6446 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6447 struct cmd_set_mirror_mask_result {
6448 cmdline_fixed_string_t set;
6449 cmdline_fixed_string_t port;
6451 cmdline_fixed_string_t mirror;
6453 cmdline_fixed_string_t what;
6454 cmdline_fixed_string_t value;
6455 cmdline_fixed_string_t dstpool;
6457 cmdline_fixed_string_t on;
6460 cmdline_parse_token_string_t cmd_mirror_mask_set =
6461 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6463 cmdline_parse_token_string_t cmd_mirror_mask_port =
6464 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6466 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6467 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6469 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6470 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6471 mirror, "mirror-rule");
6472 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6473 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6475 cmdline_parse_token_string_t cmd_mirror_mask_what =
6476 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6477 what, "pool-mirror#vlan-mirror");
6478 cmdline_parse_token_string_t cmd_mirror_mask_value =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6481 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6482 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6483 dstpool, "dst-pool");
6484 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6485 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6487 cmdline_parse_token_string_t cmd_mirror_mask_on =
6488 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6492 cmd_set_mirror_mask_parsed(void *parsed_result,
6493 __attribute__((unused)) struct cmdline *cl,
6494 __attribute__((unused)) void *data)
6497 struct cmd_set_mirror_mask_result *res = parsed_result;
6498 struct rte_eth_vmdq_mirror_conf mr_conf;
6500 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6502 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6504 mr_conf.dst_pool = res->dstpool_id;
6506 if (!strcmp(res->what, "pool-mirror")) {
6507 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6508 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6509 } else if(!strcmp(res->what, "vlan-mirror")) {
6510 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6511 nb_item = parse_item_list(res->value, "core",
6512 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6516 for(i=0; i < nb_item; i++) {
6517 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6518 printf("Invalid vlan_id: must be < 4096\n");
6522 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6523 mr_conf.vlan.vlan_mask |= 1ULL << i;
6527 if(!strcmp(res->on, "on"))
6528 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6531 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6534 printf("mirror rule add error: (%s)\n", strerror(-ret));
6537 cmdline_parse_inst_t cmd_set_mirror_mask = {
6538 .f = cmd_set_mirror_mask_parsed,
6540 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6541 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6543 (void *)&cmd_mirror_mask_set,
6544 (void *)&cmd_mirror_mask_port,
6545 (void *)&cmd_mirror_mask_portid,
6546 (void *)&cmd_mirror_mask_mirror,
6547 (void *)&cmd_mirror_mask_ruleid,
6548 (void *)&cmd_mirror_mask_what,
6549 (void *)&cmd_mirror_mask_value,
6550 (void *)&cmd_mirror_mask_dstpool,
6551 (void *)&cmd_mirror_mask_poolid,
6552 (void *)&cmd_mirror_mask_on,
6557 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6558 struct cmd_set_mirror_link_result {
6559 cmdline_fixed_string_t set;
6560 cmdline_fixed_string_t port;
6562 cmdline_fixed_string_t mirror;
6564 cmdline_fixed_string_t what;
6565 cmdline_fixed_string_t dstpool;
6567 cmdline_fixed_string_t on;
6570 cmdline_parse_token_string_t cmd_mirror_link_set =
6571 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6573 cmdline_parse_token_string_t cmd_mirror_link_port =
6574 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6576 cmdline_parse_token_num_t cmd_mirror_link_portid =
6577 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6579 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6580 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6581 mirror, "mirror-rule");
6582 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6583 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6585 cmdline_parse_token_string_t cmd_mirror_link_what =
6586 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6587 what, "uplink-mirror#downlink-mirror");
6588 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6589 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6590 dstpool, "dst-pool");
6591 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6592 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6594 cmdline_parse_token_string_t cmd_mirror_link_on =
6595 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6599 cmd_set_mirror_link_parsed(void *parsed_result,
6600 __attribute__((unused)) struct cmdline *cl,
6601 __attribute__((unused)) void *data)
6604 struct cmd_set_mirror_link_result *res = parsed_result;
6605 struct rte_eth_vmdq_mirror_conf mr_conf;
6607 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6608 if(!strcmp(res->what, "uplink-mirror")) {
6609 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6610 }else if(!strcmp(res->what, "downlink-mirror"))
6611 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6613 mr_conf.dst_pool = res->dstpool_id;
6615 if(!strcmp(res->on, "on"))
6616 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6619 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6622 /* check the return value and print it if is < 0 */
6624 printf("mirror rule add error: (%s)\n", strerror(-ret));
6628 cmdline_parse_inst_t cmd_set_mirror_link = {
6629 .f = cmd_set_mirror_link_parsed,
6631 .help_str = "set port X mirror-rule Y uplink-mirror|"
6632 "downlink-mirror dst-pool Z on|off",
6634 (void *)&cmd_mirror_link_set,
6635 (void *)&cmd_mirror_link_port,
6636 (void *)&cmd_mirror_link_portid,
6637 (void *)&cmd_mirror_link_mirror,
6638 (void *)&cmd_mirror_link_ruleid,
6639 (void *)&cmd_mirror_link_what,
6640 (void *)&cmd_mirror_link_dstpool,
6641 (void *)&cmd_mirror_link_poolid,
6642 (void *)&cmd_mirror_link_on,
6647 /* *** RESET VM MIRROR RULE *** */
6648 struct cmd_rm_mirror_rule_result {
6649 cmdline_fixed_string_t reset;
6650 cmdline_fixed_string_t port;
6652 cmdline_fixed_string_t mirror;
6656 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6657 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6659 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6660 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6662 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6663 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6665 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6666 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6667 mirror, "mirror-rule");
6668 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6669 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6673 cmd_reset_mirror_rule_parsed(void *parsed_result,
6674 __attribute__((unused)) struct cmdline *cl,
6675 __attribute__((unused)) void *data)
6678 struct cmd_set_mirror_link_result *res = parsed_result;
6680 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6682 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6685 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6686 .f = cmd_reset_mirror_rule_parsed,
6688 .help_str = "reset port X mirror-rule Y",
6690 (void *)&cmd_rm_mirror_rule_reset,
6691 (void *)&cmd_rm_mirror_rule_port,
6692 (void *)&cmd_rm_mirror_rule_portid,
6693 (void *)&cmd_rm_mirror_rule_mirror,
6694 (void *)&cmd_rm_mirror_rule_ruleid,
6699 /* ******************************************************************************** */
6701 struct cmd_dump_result {
6702 cmdline_fixed_string_t dump;
6706 dump_struct_sizes(void)
6708 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6709 DUMP_SIZE(struct rte_mbuf);
6710 DUMP_SIZE(struct rte_mempool);
6711 DUMP_SIZE(struct rte_ring);
6715 static void cmd_dump_parsed(void *parsed_result,
6716 __attribute__((unused)) struct cmdline *cl,
6717 __attribute__((unused)) void *data)
6719 struct cmd_dump_result *res = parsed_result;
6721 if (!strcmp(res->dump, "dump_physmem"))
6722 rte_dump_physmem_layout(stdout);
6723 else if (!strcmp(res->dump, "dump_memzone"))
6724 rte_memzone_dump(stdout);
6725 else if (!strcmp(res->dump, "dump_log_history"))
6726 rte_log_dump_history(stdout);
6727 else if (!strcmp(res->dump, "dump_struct_sizes"))
6728 dump_struct_sizes();
6729 else if (!strcmp(res->dump, "dump_ring"))
6730 rte_ring_list_dump(stdout);
6731 else if (!strcmp(res->dump, "dump_mempool"))
6732 rte_mempool_list_dump(stdout);
6733 else if (!strcmp(res->dump, "dump_devargs"))
6734 rte_eal_devargs_dump(stdout);
6737 cmdline_parse_token_string_t cmd_dump_dump =
6738 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6742 "dump_struct_sizes#"
6747 cmdline_parse_inst_t cmd_dump = {
6748 .f = cmd_dump_parsed, /* function to call */
6749 .data = NULL, /* 2nd arg of func */
6750 .help_str = "dump status",
6751 .tokens = { /* token list, NULL terminated */
6752 (void *)&cmd_dump_dump,
6757 /* ******************************************************************************** */
6759 struct cmd_dump_one_result {
6760 cmdline_fixed_string_t dump;
6761 cmdline_fixed_string_t name;
6764 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6765 __attribute__((unused)) void *data)
6767 struct cmd_dump_one_result *res = parsed_result;
6769 if (!strcmp(res->dump, "dump_ring")) {
6771 r = rte_ring_lookup(res->name);
6773 cmdline_printf(cl, "Cannot find ring\n");
6776 rte_ring_dump(stdout, r);
6777 } else if (!strcmp(res->dump, "dump_mempool")) {
6778 struct rte_mempool *mp;
6779 mp = rte_mempool_lookup(res->name);
6781 cmdline_printf(cl, "Cannot find mempool\n");
6784 rte_mempool_dump(stdout, mp);
6788 cmdline_parse_token_string_t cmd_dump_one_dump =
6789 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6790 "dump_ring#dump_mempool");
6792 cmdline_parse_token_string_t cmd_dump_one_name =
6793 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6795 cmdline_parse_inst_t cmd_dump_one = {
6796 .f = cmd_dump_one_parsed, /* function to call */
6797 .data = NULL, /* 2nd arg of func */
6798 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6799 .tokens = { /* token list, NULL terminated */
6800 (void *)&cmd_dump_one_dump,
6801 (void *)&cmd_dump_one_name,
6806 /* *** ADD/REMOVE an ethertype FILTER *** */
6807 struct cmd_ethertype_filter_result {
6808 cmdline_fixed_string_t filter;
6810 cmdline_fixed_string_t ethertype;
6811 uint16_t ethertype_value;
6812 cmdline_fixed_string_t priority;
6813 cmdline_fixed_string_t priority_en;
6814 uint8_t priority_value;
6815 cmdline_fixed_string_t queue;
6817 cmdline_fixed_string_t index;
6818 uint16_t index_value;
6822 cmd_ethertype_filter_parsed(void *parsed_result,
6823 __attribute__((unused)) struct cmdline *cl,
6824 __attribute__((unused)) void *data)
6827 struct cmd_ethertype_filter_result *res = parsed_result;
6828 struct rte_ethertype_filter filter;
6830 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
6831 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
6832 filter.priority = res->priority_value;
6834 if (!strcmp(res->priority_en, "enable"))
6835 filter.priority_en = 1;
6836 if (!strcmp(res->filter, "add_ethertype_filter"))
6837 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
6839 &filter, res->queue_id);
6840 else if (!strcmp(res->filter, "remove_ethertype_filter"))
6841 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
6843 else if (!strcmp(res->filter, "get_ethertype_filter"))
6844 get_ethertype_filter(res->port_id, res->index_value);
6847 printf("ethertype filter setting error: (%s)\n",
6851 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
6852 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6854 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
6855 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6856 ethertype, "ethertype");
6857 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
6858 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6859 ethertype_value, UINT16);
6860 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
6861 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6862 priority, "priority");
6863 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
6864 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6865 priority_en, "enable#disable");
6866 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
6867 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6868 priority_value, UINT8);
6869 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
6870 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6872 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
6873 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6875 cmdline_parse_token_string_t cmd_ethertype_filter_index =
6876 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6878 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
6879 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6880 index_value, UINT16);
6881 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
6882 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6883 filter, "add_ethertype_filter");
6884 cmdline_parse_inst_t cmd_add_ethertype_filter = {
6885 .f = cmd_ethertype_filter_parsed,
6887 .help_str = "add an ethertype filter",
6889 (void *)&cmd_ethertype_filter_add_filter,
6890 (void *)&cmd_ethertype_filter_port_id,
6891 (void *)&cmd_ethertype_filter_ethertype,
6892 (void *)&cmd_ethertype_filter_ethertype_value,
6893 (void *)&cmd_ethertype_filter_priority,
6894 (void *)&cmd_ethertype_filter_priority_en,
6895 (void *)&cmd_ethertype_filter_priority_value,
6896 (void *)&cmd_ethertype_filter_queue,
6897 (void *)&cmd_ethertype_filter_queue_id,
6898 (void *)&cmd_ethertype_filter_index,
6899 (void *)&cmd_ethertype_filter_index_value,
6904 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
6905 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6906 filter, "remove_ethertype_filter");
6907 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
6908 .f = cmd_ethertype_filter_parsed,
6910 .help_str = "remove an ethertype filter",
6912 (void *)&cmd_ethertype_filter_remove_filter,
6913 (void *)&cmd_ethertype_filter_port_id,
6914 (void *)&cmd_ethertype_filter_index,
6915 (void *)&cmd_ethertype_filter_index_value,
6919 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
6920 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6921 filter, "get_ethertype_filter");
6922 cmdline_parse_inst_t cmd_get_ethertype_filter = {
6923 .f = cmd_ethertype_filter_parsed,
6925 .help_str = "get an ethertype filter",
6927 (void *)&cmd_ethertype_filter_get_filter,
6928 (void *)&cmd_ethertype_filter_port_id,
6929 (void *)&cmd_ethertype_filter_index,
6930 (void *)&cmd_ethertype_filter_index_value,
6935 /* *** set SYN filter *** */
6936 struct cmd_set_syn_filter_result {
6937 cmdline_fixed_string_t filter;
6939 cmdline_fixed_string_t priority;
6940 cmdline_fixed_string_t high;
6941 cmdline_fixed_string_t queue;
6946 cmd_set_syn_filter_parsed(void *parsed_result,
6947 __attribute__((unused)) struct cmdline *cl,
6948 __attribute__((unused)) void *data)
6951 struct cmd_set_syn_filter_result *res = parsed_result;
6952 struct rte_syn_filter filter;
6954 if (!strcmp(res->filter, "add_syn_filter")) {
6955 if (!strcmp(res->high, "high"))
6959 ret = rte_eth_dev_add_syn_filter(res->port_id,
6960 &filter, res->queue_id);
6961 } else if (!strcmp(res->filter, "remove_syn_filter"))
6962 ret = rte_eth_dev_remove_syn_filter(res->port_id);
6963 else if (!strcmp(res->filter, "get_syn_filter"))
6964 get_syn_filter(res->port_id);
6966 printf("syn filter setting error: (%s)\n", strerror(-ret));
6969 cmdline_parse_token_num_t cmd_syn_filter_portid =
6970 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6972 cmdline_parse_token_string_t cmd_syn_filter_priority =
6973 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6974 priority, "priority");
6975 cmdline_parse_token_string_t cmd_syn_filter_high =
6976 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6978 cmdline_parse_token_string_t cmd_syn_filter_queue =
6979 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6981 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6982 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6984 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
6985 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6986 filter, "add_syn_filter");
6987 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
6988 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6989 filter, "remove_syn_filter");
6990 cmdline_parse_inst_t cmd_add_syn_filter = {
6991 .f = cmd_set_syn_filter_parsed,
6993 .help_str = "add syn filter",
6995 (void *)&cmd_syn_filter_add_filter,
6996 (void *)&cmd_syn_filter_portid,
6997 (void *)&cmd_syn_filter_priority,
6998 (void *)&cmd_syn_filter_high,
6999 (void *)&cmd_syn_filter_queue,
7000 (void *)&cmd_syn_filter_queue_id,
7004 cmdline_parse_inst_t cmd_remove_syn_filter = {
7005 .f = cmd_set_syn_filter_parsed,
7007 .help_str = "remove syn filter",
7009 (void *)&cmd_syn_filter_remove_filter,
7010 (void *)&cmd_syn_filter_portid,
7015 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7016 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7017 filter, "get_syn_filter");
7019 cmdline_parse_inst_t cmd_get_syn_filter = {
7020 .f = cmd_set_syn_filter_parsed,
7022 .help_str = "get syn filter",
7024 (void *)&cmd_syn_filter_get_filter,
7025 (void *)&cmd_syn_filter_portid,
7030 /* *** ADD/REMOVE A 2tuple FILTER *** */
7031 struct cmd_2tuple_filter_result {
7032 cmdline_fixed_string_t filter;
7034 cmdline_fixed_string_t protocol;
7035 uint8_t protocol_value;
7036 uint8_t protocol_mask;
7037 cmdline_fixed_string_t dst_port;
7038 uint16_t dst_port_value;
7039 uint16_t dst_port_mask;
7040 cmdline_fixed_string_t flags;
7041 uint8_t flags_value;
7042 cmdline_fixed_string_t priority;
7043 uint8_t priority_value;
7044 cmdline_fixed_string_t queue;
7046 cmdline_fixed_string_t index;
7047 uint16_t index_value;
7051 cmd_2tuple_filter_parsed(void *parsed_result,
7052 __attribute__((unused)) struct cmdline *cl,
7053 __attribute__((unused)) void *data)
7056 struct rte_2tuple_filter filter;
7057 struct cmd_2tuple_filter_result *res = parsed_result;
7059 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7061 if (!strcmp(res->filter, "add_2tuple_filter")) {
7062 /* need convert to big endian. */
7063 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7064 filter.protocol = res->protocol_value;
7065 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7066 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7067 filter.priority = res->priority_value;
7068 filter.tcp_flags = res->flags_value;
7069 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7070 res->index_value, &filter, res->queue_id);
7071 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7072 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7074 else if (!strcmp(res->filter, "get_2tuple_filter"))
7075 get_2tuple_filter(res->port_id, res->index_value);
7078 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7081 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7082 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7084 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7085 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7086 protocol, "protocol");
7087 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7088 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7089 protocol_value, UINT8);
7090 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7091 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7092 protocol_mask, UINT8);
7093 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7094 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7095 dst_port, "dst_port");
7096 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7097 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7098 dst_port_value, UINT16);
7099 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7100 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7101 dst_port_mask, UINT16);
7102 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7103 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7105 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7106 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7107 flags_value, UINT8);
7108 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7109 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7110 priority, "priority");
7111 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7112 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7113 priority_value, UINT8);
7114 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7115 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7117 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7118 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7120 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7121 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7123 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7124 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7125 index_value, UINT16);
7126 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7127 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7128 filter, "add_2tuple_filter");
7129 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7130 .f = cmd_2tuple_filter_parsed,
7132 .help_str = "add a 2tuple filter",
7134 (void *)&cmd_2tuple_filter_add_filter,
7135 (void *)&cmd_2tuple_filter_port_id,
7136 (void *)&cmd_2tuple_filter_protocol,
7137 (void *)&cmd_2tuple_filter_protocol_value,
7138 (void *)&cmd_2tuple_filter_protocol_mask,
7139 (void *)&cmd_2tuple_filter_dst_port,
7140 (void *)&cmd_2tuple_filter_dst_port_value,
7141 (void *)&cmd_2tuple_filter_dst_port_mask,
7142 (void *)&cmd_2tuple_filter_flags,
7143 (void *)&cmd_2tuple_filter_flags_value,
7144 (void *)&cmd_2tuple_filter_priority,
7145 (void *)&cmd_2tuple_filter_priority_value,
7146 (void *)&cmd_2tuple_filter_queue,
7147 (void *)&cmd_2tuple_filter_queue_id,
7148 (void *)&cmd_2tuple_filter_index,
7149 (void *)&cmd_2tuple_filter_index_value,
7154 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7155 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7156 filter, "remove_2tuple_filter");
7157 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7158 .f = cmd_2tuple_filter_parsed,
7160 .help_str = "remove a 2tuple filter",
7162 (void *)&cmd_2tuple_filter_remove_filter,
7163 (void *)&cmd_2tuple_filter_port_id,
7164 (void *)&cmd_2tuple_filter_index,
7165 (void *)&cmd_2tuple_filter_index_value,
7169 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7170 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7171 filter, "get_2tuple_filter");
7172 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7173 .f = cmd_2tuple_filter_parsed,
7175 .help_str = "get a 2tuple filter",
7177 (void *)&cmd_2tuple_filter_get_filter,
7178 (void *)&cmd_2tuple_filter_port_id,
7179 (void *)&cmd_2tuple_filter_index,
7180 (void *)&cmd_2tuple_filter_index_value,
7185 /* *** ADD/REMOVE A 5tuple FILTER *** */
7186 struct cmd_5tuple_filter_result {
7187 cmdline_fixed_string_t filter;
7189 cmdline_fixed_string_t dst_ip;
7190 cmdline_ipaddr_t dst_ip_value;
7191 cmdline_fixed_string_t src_ip;
7192 cmdline_ipaddr_t src_ip_value;
7193 cmdline_fixed_string_t dst_port;
7194 uint16_t dst_port_value;
7195 cmdline_fixed_string_t src_port;
7196 uint16_t src_port_value;
7197 cmdline_fixed_string_t protocol;
7198 uint8_t protocol_value;
7199 cmdline_fixed_string_t mask;
7201 cmdline_fixed_string_t flags;
7202 uint8_t flags_value;
7203 cmdline_fixed_string_t priority;
7204 uint8_t priority_value;
7205 cmdline_fixed_string_t queue;
7207 cmdline_fixed_string_t index;
7208 uint16_t index_value;
7212 cmd_5tuple_filter_parsed(void *parsed_result,
7213 __attribute__((unused)) struct cmdline *cl,
7214 __attribute__((unused)) void *data)
7217 struct rte_5tuple_filter filter;
7218 struct cmd_5tuple_filter_result *res = parsed_result;
7220 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7222 if (!strcmp(res->filter, "add_5tuple_filter")) {
7223 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7224 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7225 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7226 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7227 filter.protocol = res->protocol_value;
7228 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7229 filter.priority = res->priority_value;
7230 filter.tcp_flags = res->flags_value;
7232 if (res->dst_ip_value.family == AF_INET)
7233 /* no need to convert, already big endian. */
7234 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7236 if (filter.dst_ip_mask == 0) {
7237 printf("can not support ipv6 involved compare.\n");
7243 if (res->src_ip_value.family == AF_INET)
7244 /* no need to convert, already big endian. */
7245 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7247 if (filter.src_ip_mask == 0) {
7248 printf("can not support ipv6 involved compare.\n");
7253 /* need convert to big endian. */
7254 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7255 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7257 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7258 res->index_value, &filter, res->queue_id);
7259 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7260 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7262 else if (!strcmp(res->filter, "get_5tuple_filter"))
7263 get_5tuple_filter(res->port_id, res->index_value);
7265 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7269 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7270 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7272 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7273 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7275 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7276 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7278 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7279 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7281 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7282 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7284 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7285 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7286 dst_port, "dst_port");
7287 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7288 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7289 dst_port_value, UINT16);
7290 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7291 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7292 src_port, "src_port");
7293 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7294 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7295 src_port_value, UINT16);
7296 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7297 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7298 protocol, "protocol");
7299 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7300 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7301 protocol_value, UINT8);
7302 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7303 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7305 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7306 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7308 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7309 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7311 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7312 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7313 flags_value, UINT8);
7314 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7315 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7316 priority, "priority");
7317 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7318 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7319 priority_value, UINT8);
7320 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7321 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7323 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7324 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7326 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7327 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7329 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7330 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7331 index_value, UINT16);
7333 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7334 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7335 filter, "add_5tuple_filter");
7336 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7337 .f = cmd_5tuple_filter_parsed,
7339 .help_str = "add a 5tuple filter",
7341 (void *)&cmd_5tuple_filter_add_filter,
7342 (void *)&cmd_5tuple_filter_port_id,
7343 (void *)&cmd_5tuple_filter_dst_ip,
7344 (void *)&cmd_5tuple_filter_dst_ip_value,
7345 (void *)&cmd_5tuple_filter_src_ip,
7346 (void *)&cmd_5tuple_filter_src_ip_value,
7347 (void *)&cmd_5tuple_filter_dst_port,
7348 (void *)&cmd_5tuple_filter_dst_port_value,
7349 (void *)&cmd_5tuple_filter_src_port,
7350 (void *)&cmd_5tuple_filter_src_port_value,
7351 (void *)&cmd_5tuple_filter_protocol,
7352 (void *)&cmd_5tuple_filter_protocol_value,
7353 (void *)&cmd_5tuple_filter_mask,
7354 (void *)&cmd_5tuple_filter_mask_value,
7355 (void *)&cmd_5tuple_filter_flags,
7356 (void *)&cmd_5tuple_filter_flags_value,
7357 (void *)&cmd_5tuple_filter_priority,
7358 (void *)&cmd_5tuple_filter_priority_value,
7359 (void *)&cmd_5tuple_filter_queue,
7360 (void *)&cmd_5tuple_filter_queue_id,
7361 (void *)&cmd_5tuple_filter_index,
7362 (void *)&cmd_5tuple_filter_index_value,
7367 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7368 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7369 filter, "remove_5tuple_filter");
7370 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7371 .f = cmd_5tuple_filter_parsed,
7373 .help_str = "remove a 5tuple filter",
7375 (void *)&cmd_5tuple_filter_remove_filter,
7376 (void *)&cmd_5tuple_filter_port_id,
7377 (void *)&cmd_5tuple_filter_index,
7378 (void *)&cmd_5tuple_filter_index_value,
7383 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7384 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7385 filter, "get_5tuple_filter");
7386 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7387 .f = cmd_5tuple_filter_parsed,
7389 .help_str = "get a 5tuple filter",
7391 (void *)&cmd_5tuple_filter_get_filter,
7392 (void *)&cmd_5tuple_filter_port_id,
7393 (void *)&cmd_5tuple_filter_index,
7394 (void *)&cmd_5tuple_filter_index_value,
7399 /* *** ADD/REMOVE A flex FILTER *** */
7400 struct cmd_flex_filter_result {
7401 cmdline_fixed_string_t filter;
7403 cmdline_fixed_string_t len;
7405 cmdline_fixed_string_t bytes;
7406 cmdline_fixed_string_t bytes_value;
7407 cmdline_fixed_string_t mask;
7408 cmdline_fixed_string_t mask_value;
7409 cmdline_fixed_string_t priority;
7410 uint8_t priority_value;
7411 cmdline_fixed_string_t queue;
7413 cmdline_fixed_string_t index;
7414 uint16_t index_value;
7417 static int xdigit2val(unsigned char c)
7422 else if (isupper(c))
7430 cmd_flex_filter_parsed(void *parsed_result,
7431 __attribute__((unused)) struct cmdline *cl,
7432 __attribute__((unused)) void *data)
7435 struct rte_flex_filter filter;
7436 struct cmd_flex_filter_result *res = parsed_result;
7437 char *bytes_ptr, *mask_ptr;
7445 if (!strcmp(res->filter, "add_flex_filter")) {
7446 if (res->len_value > 128) {
7447 printf("the len exceed the max length 128\n");
7450 memset(&filter, 0, sizeof(struct rte_flex_filter));
7451 filter.len = res->len_value;
7452 filter.priority = res->priority_value;
7453 bytes_ptr = res->bytes_value;
7454 mask_ptr = res->mask_value;
7457 /* translate bytes string to uint_32 array. */
7458 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7459 (bytes_ptr[1] == 'X')))
7461 len = strnlen(bytes_ptr, res->len_value * 2);
7462 if (len == 0 || (len % 8 != 0)) {
7463 printf("please check len and bytes input\n");
7466 for (i = 0; i < len; i++) {
7468 if (isxdigit(c) == 0) {
7469 /* invalid characters. */
7470 printf("invalid input\n");
7473 val = xdigit2val(c);
7477 dword |= byte << (4 * mod - 4);
7482 filter.dwords[j] = dword;
7483 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7489 /* translate mask string to uint8_t array. */
7491 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7492 (mask_ptr[1] == 'X')))
7494 len = strnlen(mask_ptr, (res->len_value+3)/4);
7496 printf("invalid input\n");
7499 for (i = 0; i < len; i++) {
7501 if (isxdigit(c) == 0) {
7502 /* invalid characters. */
7503 printf("invalid input\n");
7506 val = xdigit2val(c);
7507 hex |= (uint8_t)(val & 0x8) >> 3;
7508 hex |= (uint8_t)(val & 0x4) >> 1;
7509 hex |= (uint8_t)(val & 0x2) << 1;
7510 hex |= (uint8_t)(val & 0x1) << 3;
7513 filter.mask[j] = byte;
7514 printf("mask[%d]:%02x ", j, filter.mask[j]);
7522 printf("call function rte_eth_dev_add_flex_filter: "
7523 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7524 res->index_value, res->queue_id,
7525 filter.len, filter.priority);
7526 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7527 &filter, res->queue_id);
7529 } else if (!strcmp(res->filter, "remove_flex_filter"))
7530 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7532 else if (!strcmp(res->filter, "get_flex_filter"))
7533 get_flex_filter(res->port_id, res->index_value);
7536 printf("flex filter setting error: (%s)\n", strerror(-ret));
7539 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7540 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7542 cmdline_parse_token_string_t cmd_flex_filter_len =
7543 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7545 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7546 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7548 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7549 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7551 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7552 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7554 cmdline_parse_token_string_t cmd_flex_filter_mask =
7555 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7557 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7558 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7560 cmdline_parse_token_string_t cmd_flex_filter_priority =
7561 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7562 priority, "priority");
7563 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7564 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7565 priority_value, UINT8);
7566 cmdline_parse_token_string_t cmd_flex_filter_queue =
7567 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7569 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7570 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7572 cmdline_parse_token_string_t cmd_flex_filter_index =
7573 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7575 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7576 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7577 index_value, UINT16);
7578 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7579 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7580 filter, "add_flex_filter");
7581 cmdline_parse_inst_t cmd_add_flex_filter = {
7582 .f = cmd_flex_filter_parsed,
7584 .help_str = "add a flex filter",
7586 (void *)&cmd_flex_filter_add_filter,
7587 (void *)&cmd_flex_filter_port_id,
7588 (void *)&cmd_flex_filter_len,
7589 (void *)&cmd_flex_filter_len_value,
7590 (void *)&cmd_flex_filter_bytes,
7591 (void *)&cmd_flex_filter_bytes_value,
7592 (void *)&cmd_flex_filter_mask,
7593 (void *)&cmd_flex_filter_mask_value,
7594 (void *)&cmd_flex_filter_priority,
7595 (void *)&cmd_flex_filter_priority_value,
7596 (void *)&cmd_flex_filter_queue,
7597 (void *)&cmd_flex_filter_queue_id,
7598 (void *)&cmd_flex_filter_index,
7599 (void *)&cmd_flex_filter_index_value,
7604 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7605 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7606 filter, "remove_flex_filter");
7607 cmdline_parse_inst_t cmd_remove_flex_filter = {
7608 .f = cmd_flex_filter_parsed,
7610 .help_str = "remove a flex filter",
7612 (void *)&cmd_flex_filter_remove_filter,
7613 (void *)&cmd_flex_filter_port_id,
7614 (void *)&cmd_flex_filter_index,
7615 (void *)&cmd_flex_filter_index_value,
7620 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7621 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7622 filter, "get_flex_filter");
7623 cmdline_parse_inst_t cmd_get_flex_filter = {
7624 .f = cmd_flex_filter_parsed,
7626 .help_str = "get a flex filter",
7628 (void *)&cmd_flex_filter_get_filter,
7629 (void *)&cmd_flex_filter_port_id,
7630 (void *)&cmd_flex_filter_index,
7631 (void *)&cmd_flex_filter_index_value,
7636 /* ******************************************************************************** */
7638 /* list of instructions */
7639 cmdline_parse_ctx_t main_ctx[] = {
7640 (cmdline_parse_inst_t *)&cmd_help_brief,
7641 (cmdline_parse_inst_t *)&cmd_help_long,
7642 (cmdline_parse_inst_t *)&cmd_quit,
7643 (cmdline_parse_inst_t *)&cmd_showport,
7644 (cmdline_parse_inst_t *)&cmd_showportall,
7645 (cmdline_parse_inst_t *)&cmd_showcfg,
7646 (cmdline_parse_inst_t *)&cmd_start,
7647 (cmdline_parse_inst_t *)&cmd_start_tx_first,
7648 (cmdline_parse_inst_t *)&cmd_set_link_up,
7649 (cmdline_parse_inst_t *)&cmd_set_link_down,
7650 (cmdline_parse_inst_t *)&cmd_reset,
7651 (cmdline_parse_inst_t *)&cmd_set_numbers,
7652 (cmdline_parse_inst_t *)&cmd_set_txpkts,
7653 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
7654 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
7655 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
7656 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
7657 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
7658 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
7659 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
7660 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
7661 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
7662 (cmdline_parse_inst_t *)&cmd_set_link_check,
7663 #ifdef RTE_NIC_BYPASS
7664 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
7665 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
7666 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
7667 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
7669 #ifdef RTE_LIBRTE_PMD_BOND
7670 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
7671 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
7672 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
7673 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
7674 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
7675 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
7676 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
7677 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
7679 (cmdline_parse_inst_t *)&cmd_vlan_offload,
7680 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
7681 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
7682 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
7683 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
7684 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
7685 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
7686 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
7687 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
7688 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
7689 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
7690 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
7691 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
7692 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
7693 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
7694 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
7695 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
7696 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
7697 (cmdline_parse_inst_t *)&cmd_config_dcb,
7698 (cmdline_parse_inst_t *)&cmd_read_reg,
7699 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
7700 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
7701 (cmdline_parse_inst_t *)&cmd_write_reg,
7702 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
7703 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
7704 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
7705 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
7706 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
7707 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
7708 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
7709 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
7710 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
7711 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
7712 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
7713 (cmdline_parse_inst_t *)&cmd_stop,
7714 (cmdline_parse_inst_t *)&cmd_mac_addr,
7715 (cmdline_parse_inst_t *)&cmd_set_qmap,
7716 (cmdline_parse_inst_t *)&cmd_operate_port,
7717 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
7718 (cmdline_parse_inst_t *)&cmd_config_speed_all,
7719 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
7720 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
7721 (cmdline_parse_inst_t *)&cmd_config_mtu,
7722 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
7723 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
7724 (cmdline_parse_inst_t *)&cmd_config_rss,
7725 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
7726 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
7727 (cmdline_parse_inst_t *)&cmd_showport_reta,
7728 (cmdline_parse_inst_t *)&cmd_config_burst,
7729 (cmdline_parse_inst_t *)&cmd_config_thresh,
7730 (cmdline_parse_inst_t *)&cmd_config_threshold,
7731 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
7732 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
7733 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
7734 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
7735 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
7736 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
7737 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
7738 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
7739 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
7740 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
7741 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
7742 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
7743 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
7744 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
7745 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
7746 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
7747 (cmdline_parse_inst_t *)&cmd_dump,
7748 (cmdline_parse_inst_t *)&cmd_dump_one,
7749 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
7750 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
7751 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
7752 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
7753 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
7754 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
7755 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
7756 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
7757 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
7758 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
7759 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
7760 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
7761 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
7762 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
7763 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
7767 /* prompt function, called from main on MASTER lcore */
7773 /* initialize non-constant commands */
7774 cmd_set_fwd_mode_init();
7776 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
7780 cmdline_interact(cl);
7781 cmdline_stdin_exit(cl);
7785 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
7787 if (id < nb_ports) {
7788 /* check if need_reconfig has been set to 1 */
7789 if (ports[id].need_reconfig == 0)
7790 ports[id].need_reconfig = dev;
7791 /* check if need_reconfig_queues has been set to 1 */
7792 if (ports[id].need_reconfig_queues == 0)
7793 ports[id].need_reconfig_queues = queue;
7797 for (pid = 0; pid < nb_ports; pid++) {
7798 /* check if need_reconfig has been set to 1 */
7799 if (ports[pid].need_reconfig == 0)
7800 ports[pid].need_reconfig = dev;
7801 /* check if need_reconfig_queues has been set to 1 */
7802 if (ports[pid].need_reconfig_queues == 0)
7803 ports[pid].need_reconfig_queues = queue;
7808 #ifdef RTE_NIC_BYPASS
7810 bypass_is_supported(portid_t port_id)
7812 struct rte_port *port;
7813 struct rte_pci_id *pci_id;
7815 if (port_id >= nb_ports) {
7816 printf("\tPort id must be less than %d.\n", nb_ports);
7820 /* Get the device id. */
7821 port = &ports[port_id];
7822 pci_id = &port->dev_info.pci_dev->id;
7824 /* Check if NIC supports bypass. */
7825 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
7829 printf("\tBypass not supported for port_id = %d.\n", port_id);