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) (mac_addr)"
376 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
377 " Add/Remove unicast or multicast MAC addr filter"
380 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
382 " AUPE:accepts untagged VLAN;"
383 "ROPE:accept unicast hash\n\n"
384 " BAM:accepts broadcast packets;"
385 "MPE:accepts all multicast packets\n\n"
386 " Enable/Disable a VF receive mode of a port\n\n"
388 "set port (port_id) queue (queue_id) rate (rate_num)\n"
389 " Set rate limit for a queue of a port\n\n"
391 "set port (port_id) vf (vf_id) rate (rate_num) "
392 "queue_mask (queue_mask_value)\n"
393 " Set rate limit for queues in VF of a port\n\n"
395 "set port (port_id) mirror-rule (rule_id)"
396 "(pool-mirror|vlan-mirror)\n"
397 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
398 " Set pool or vlan type mirror rule on a port.\n"
399 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
400 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
403 "set port (port_id) mirror-rule (rule_id)"
404 " (uplink-mirror|downlink-mirror) dst-pool"
405 " (pool_id) (on|off)\n"
406 " Set uplink or downlink type mirror rule on a port.\n"
407 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
408 " 0 on' enable mirror income traffic to pool 0.\n\n"
410 "reset port (port_id) mirror-rule (rule_id)\n"
411 " Reset a mirror rule.\n\n"
413 "set flush_rx (on|off)\n"
414 " Flush (default) or don't flush RX streams before"
415 " forwarding. Mainly used with PCAP drivers.\n\n"
417 #ifdef RTE_NIC_BYPASS
418 "set bypass mode (normal|bypass|isolate) (port_id)\n"
419 " Set the bypass mode for the lowest port on bypass enabled"
422 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
423 "mode (normal|bypass|isolate) (port_id)\n"
424 " Set the event required to initiate specified bypass mode for"
425 " the lowest port on a bypass enabled NIC where:\n"
426 " timeout = enable bypass after watchdog timeout.\n"
427 " os_on = enable bypass when OS/board is powered on.\n"
428 " os_off = enable bypass when OS/board is powered off.\n"
429 " power_on = enable bypass when power supply is turned on.\n"
430 " power_off = enable bypass when power supply is turned off."
433 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
434 " Set the bypass watchdog timeout to 'n' seconds"
435 " where 0 = instant.\n\n"
437 "show bypass config (port_id)\n"
438 " Show the bypass configuration for a bypass enabled NIC"
439 " using the lowest port on the NIC.\n\n"
441 #ifdef RTE_LIBRTE_PMD_BOND
442 "create bonded device (mode) (socket)\n"
443 " Create a new bonded device with specific bonding mode and socket.\n\n"
445 "add bonding slave (slave_id) (port_id)\n"
446 " Add a slave device to a bonded device.\n\n"
448 "remove bonding slave (slave_id) (port_id)\n"
449 " Remove a slave device from a bonded device.\n\n"
451 "set bonding mode (value) (port_id)\n"
452 " Set the bonding mode on a bonded device.\n\n"
454 "set bonding primary (slave_id) (port_id)\n"
455 " Set the primary slave for a bonded device.\n\n"
457 "show bonding config (port_id)\n"
458 " Show the bonding config for port_id.\n\n"
460 "set bonding mac_addr (port_id) (address)\n"
461 " Set the MAC address of a bonded device.\n\n"
463 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
464 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
466 "set bonding mon_period (port_id) (value)\n"
467 " Set the bonding link status monitoring polling period in ms.\n\n"
469 "set link-up port (port_id)\n"
470 " Set link up for a port.\n\n"
472 "set link-down port (port_id)\n"
473 " Set link down for a port.\n\n"
475 , list_pkt_forwarding_modes()
480 if (show_all || !strcmp(res->section, "flowdir")) {
485 "Flow director mode:\n"
486 "-------------------\n\n"
488 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
489 " src (src_ip_address) (src_port)"
490 " dst (dst_ip_address) (dst_port)"
491 " flexbytes (flexbytes_values) vlan (vlan_id)"
492 " queue (queue_id)\n"
493 " Add a signature filter.\n\n"
495 "upd_signature_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)\n"
500 " Update a signature filter.\n\n"
502 "rm_signature_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)\n"
506 " Remove a signature filter.\n\n"
508 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
509 " src (src_ip_address) (src_port)"
510 " dst (dst_ip_address) (dst_port)"
511 " flexbytes (flexbytes_values) vlan (vlan_id)"
512 " queue (queue_id) soft (soft_id)\n"
513 " Add a perfect filter.\n\n"
515 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
516 " src (src_ip_address) (src_port)"
517 " dst (dst_ip_address) (dst_port)"
518 " flexbytes (flexbytes_values) vlan (vlan_id)"
519 " queue (queue_id)\n"
520 " Update a perfect filter.\n\n"
522 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
523 " src (src_ip_address) (src_port)"
524 " dst (dst_ip_address) (dst_port)"
525 " flexbytes (flexbytes_values) vlan (vlan_id)"
527 " Remove a perfect filter.\n\n"
529 "set_masks_filter (port_id) only_ip_flow (0|1)"
530 " src_mask (ip_src_mask) (src_port_mask)"
531 " dst_mask (ip_dst_mask) (dst_port_mask)"
532 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
533 " Set IPv4 filter masks.\n\n"
535 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
536 " src_mask (ip_src_mask) (src_port_mask)"
537 " dst_mask (ip_dst_mask) (dst_port_mask)"
538 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
539 " compare_dst (0|1)\n"
540 " Set IPv6 filter masks.\n\n"
544 if (show_all || !strcmp(res->section, "ports")) {
550 "----------------\n\n"
552 "port start (port_id|all)\n"
553 " Start all ports or port_id.\n\n"
555 "port stop (port_id|all)\n"
556 " Stop all ports or port_id.\n\n"
558 "port close (port_id|all)\n"
559 " Close all ports or port_id.\n\n"
561 "port config (port_id|all)"
562 " speed (10|100|1000|10000|40000|auto)"
563 " duplex (half|full|auto)\n"
564 " Set speed and duplex for all ports or port_id\n\n"
566 "port config all (rxq|txq|rxd|txd) (value)\n"
567 " Set number for rxq/txq/rxd/txd.\n\n"
569 "port config all max-pkt-len (value)\n"
570 " Set the max packet length.\n\n"
572 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
574 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
577 "port config all rss (ip|udp|none)\n"
578 " Set the RSS mode.\n\n"
580 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
581 " Set the RSS redirection table.\n\n"
583 "port config (port_id) dcb vt (on|off) (traffic_class)"
585 " Set the DCB mode.\n\n"
587 "port config all burst (value)\n"
588 " Set the number of packets per burst.\n\n"
590 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
592 " Set the ring prefetch/host/writeback threshold"
593 " for tx/rx queue.\n\n"
595 "port config all (txfreet|txrst|rxfreet) (value)\n"
596 " Set free threshold for rx/tx, or set"
597 " tx rs bit threshold.\n\n"
598 "port config mtu X value\n"
599 " Set the MTU of port X to a given value\n\n"
601 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
602 " Start/stop a rx/tx queue of port X. Only take effect"
603 " when port X is started\n"
607 if (show_all || !strcmp(res->section, "registers")) {
615 "read reg (port_id) (address)\n"
616 " Display value of a port register.\n\n"
618 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
619 " Display a port register bit field.\n\n"
621 "read regbit (port_id) (address) (bit_x)\n"
622 " Display a single port register bit.\n\n"
624 "write reg (port_id) (address) (value)\n"
625 " Set value of a port register.\n\n"
627 "write regfield (port_id) (address) (bit_x) (bit_y)"
629 " Set bit field of a port register.\n\n"
631 "write regbit (port_id) (address) (bit_x) (value)\n"
632 " Set single bit value of a port register.\n\n"
635 if (show_all || !strcmp(res->section, "filters")) {
643 "add_ethertype_filter (port_id) ethertype (eth_value)"
644 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
645 " add an ethertype filter.\n\n"
647 "remove_ethertype_filter (port_id) index (idx)\n"
648 " remove an ethertype filter.\n\n"
650 "get_ethertype_filter (port_id) index (idx)\n"
651 " get info of a ethertype filter.\n\n"
653 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
654 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
655 " queue (queue_id) index (idx)\n"
656 " add a 2tuple filter.\n\n"
658 "remove_2tuple_filter (port_id) index (idx)\n"
659 " remove a 2tuple filter.\n\n"
661 "get_2tuple_filter (port_id) index (idx)\n"
662 " get info of a 2tuple filter.\n\n"
664 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
665 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
666 " mask (mask_value) flags (flags_value) priority (prio_value)"
667 " queue (queue_id) index (idx)\n"
668 " add a 5tuple filter.\n\n"
670 "remove_5tuple_filter (port_id) index (idx)\n"
671 " remove a 5tuple filter.\n\n"
673 "get_5tuple_filter (port_id) index (idx)\n"
674 " get info of a 5tuple filter.\n\n"
676 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
677 " add syn filter.\n\n"
679 "remove_syn_filter (port_id)"
680 " remove syn filter.\n\n"
682 "get_syn_filter (port_id) "
683 " get syn filter info.\n\n"
685 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
686 " priority (prio_value) queue (queue_id) index (idx)\n"
687 " add a flex filter.\n\n"
689 "remove_flex_filter (port_id) index (idx)\n"
690 " remove a flex filter.\n\n"
692 "get_flex_filter (port_id) index (idx)\n"
693 " get info of a flex filter.\n\n"
698 cmdline_parse_token_string_t cmd_help_long_help =
699 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
701 cmdline_parse_token_string_t cmd_help_long_section =
702 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
703 "all#control#display#config#flowdir#"
704 "ports#registers#filters");
706 cmdline_parse_inst_t cmd_help_long = {
707 .f = cmd_help_long_parsed,
709 .help_str = "show help",
711 (void *)&cmd_help_long_help,
712 (void *)&cmd_help_long_section,
718 /* *** start/stop/close all ports *** */
719 struct cmd_operate_port_result {
720 cmdline_fixed_string_t keyword;
721 cmdline_fixed_string_t name;
722 cmdline_fixed_string_t value;
725 static void cmd_operate_port_parsed(void *parsed_result,
726 __attribute__((unused)) struct cmdline *cl,
727 __attribute__((unused)) void *data)
729 struct cmd_operate_port_result *res = parsed_result;
731 if (!strcmp(res->name, "start"))
732 start_port(RTE_PORT_ALL);
733 else if (!strcmp(res->name, "stop"))
734 stop_port(RTE_PORT_ALL);
735 else if (!strcmp(res->name, "close"))
736 close_port(RTE_PORT_ALL);
738 printf("Unknown parameter\n");
741 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
742 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
744 cmdline_parse_token_string_t cmd_operate_port_all_port =
745 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
747 cmdline_parse_token_string_t cmd_operate_port_all_all =
748 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
750 cmdline_parse_inst_t cmd_operate_port = {
751 .f = cmd_operate_port_parsed,
753 .help_str = "port start|stop|close all: start/stop/close all ports",
755 (void *)&cmd_operate_port_all_cmd,
756 (void *)&cmd_operate_port_all_port,
757 (void *)&cmd_operate_port_all_all,
762 /* *** start/stop/close specific port *** */
763 struct cmd_operate_specific_port_result {
764 cmdline_fixed_string_t keyword;
765 cmdline_fixed_string_t name;
769 static void cmd_operate_specific_port_parsed(void *parsed_result,
770 __attribute__((unused)) struct cmdline *cl,
771 __attribute__((unused)) void *data)
773 struct cmd_operate_specific_port_result *res = parsed_result;
775 if (!strcmp(res->name, "start"))
776 start_port(res->value);
777 else if (!strcmp(res->name, "stop"))
778 stop_port(res->value);
779 else if (!strcmp(res->name, "close"))
780 close_port(res->value);
782 printf("Unknown parameter\n");
785 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
786 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
788 cmdline_parse_token_string_t cmd_operate_specific_port_port =
789 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
790 name, "start#stop#close");
791 cmdline_parse_token_num_t cmd_operate_specific_port_id =
792 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
795 cmdline_parse_inst_t cmd_operate_specific_port = {
796 .f = cmd_operate_specific_port_parsed,
798 .help_str = "port start|stop|close X: start/stop/close port X",
800 (void *)&cmd_operate_specific_port_cmd,
801 (void *)&cmd_operate_specific_port_port,
802 (void *)&cmd_operate_specific_port_id,
807 /* *** configure speed for all ports *** */
808 struct cmd_config_speed_all {
809 cmdline_fixed_string_t port;
810 cmdline_fixed_string_t keyword;
811 cmdline_fixed_string_t all;
812 cmdline_fixed_string_t item1;
813 cmdline_fixed_string_t item2;
814 cmdline_fixed_string_t value1;
815 cmdline_fixed_string_t value2;
819 cmd_config_speed_all_parsed(void *parsed_result,
820 __attribute__((unused)) struct cmdline *cl,
821 __attribute__((unused)) void *data)
823 struct cmd_config_speed_all *res = parsed_result;
824 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
825 uint16_t link_duplex = 0;
828 if (!all_ports_stopped()) {
829 printf("Please stop all ports first\n");
833 if (!strcmp(res->value1, "10"))
834 link_speed = ETH_LINK_SPEED_10;
835 else if (!strcmp(res->value1, "100"))
836 link_speed = ETH_LINK_SPEED_100;
837 else if (!strcmp(res->value1, "1000"))
838 link_speed = ETH_LINK_SPEED_1000;
839 else if (!strcmp(res->value1, "10000"))
840 link_speed = ETH_LINK_SPEED_10G;
841 else if (!strcmp(res->value1, "40000"))
842 link_speed = ETH_LINK_SPEED_40G;
843 else if (!strcmp(res->value1, "auto"))
844 link_speed = ETH_LINK_SPEED_AUTONEG;
846 printf("Unknown parameter\n");
850 if (!strcmp(res->value2, "half"))
851 link_duplex = ETH_LINK_HALF_DUPLEX;
852 else if (!strcmp(res->value2, "full"))
853 link_duplex = ETH_LINK_FULL_DUPLEX;
854 else if (!strcmp(res->value2, "auto"))
855 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
857 printf("Unknown parameter\n");
861 for (pid = 0; pid < nb_ports; pid++) {
862 ports[pid].dev_conf.link_speed = link_speed;
863 ports[pid].dev_conf.link_duplex = link_duplex;
866 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
869 cmdline_parse_token_string_t cmd_config_speed_all_port =
870 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
871 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
872 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
874 cmdline_parse_token_string_t cmd_config_speed_all_all =
875 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
876 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
877 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
878 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
879 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
880 "10#100#1000#10000#40000#auto");
881 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
882 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
883 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
884 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
887 cmdline_parse_inst_t cmd_config_speed_all = {
888 .f = cmd_config_speed_all_parsed,
890 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
893 (void *)&cmd_config_speed_all_port,
894 (void *)&cmd_config_speed_all_keyword,
895 (void *)&cmd_config_speed_all_all,
896 (void *)&cmd_config_speed_all_item1,
897 (void *)&cmd_config_speed_all_value1,
898 (void *)&cmd_config_speed_all_item2,
899 (void *)&cmd_config_speed_all_value2,
904 /* *** configure speed for specific port *** */
905 struct cmd_config_speed_specific {
906 cmdline_fixed_string_t port;
907 cmdline_fixed_string_t keyword;
909 cmdline_fixed_string_t item1;
910 cmdline_fixed_string_t item2;
911 cmdline_fixed_string_t value1;
912 cmdline_fixed_string_t value2;
916 cmd_config_speed_specific_parsed(void *parsed_result,
917 __attribute__((unused)) struct cmdline *cl,
918 __attribute__((unused)) void *data)
920 struct cmd_config_speed_specific *res = parsed_result;
921 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
922 uint16_t link_duplex = 0;
924 if (!all_ports_stopped()) {
925 printf("Please stop all ports first\n");
929 if (res->id >= nb_ports) {
930 printf("Port id %d must be less than %d\n", res->id, nb_ports);
934 if (!strcmp(res->value1, "10"))
935 link_speed = ETH_LINK_SPEED_10;
936 else if (!strcmp(res->value1, "100"))
937 link_speed = ETH_LINK_SPEED_100;
938 else if (!strcmp(res->value1, "1000"))
939 link_speed = ETH_LINK_SPEED_1000;
940 else if (!strcmp(res->value1, "10000"))
941 link_speed = ETH_LINK_SPEED_10000;
942 else if (!strcmp(res->value1, "40000"))
943 link_speed = ETH_LINK_SPEED_40G;
944 else if (!strcmp(res->value1, "auto"))
945 link_speed = ETH_LINK_SPEED_AUTONEG;
947 printf("Unknown parameter\n");
951 if (!strcmp(res->value2, "half"))
952 link_duplex = ETH_LINK_HALF_DUPLEX;
953 else if (!strcmp(res->value2, "full"))
954 link_duplex = ETH_LINK_FULL_DUPLEX;
955 else if (!strcmp(res->value2, "auto"))
956 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
958 printf("Unknown parameter\n");
962 ports[res->id].dev_conf.link_speed = link_speed;
963 ports[res->id].dev_conf.link_duplex = link_duplex;
965 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
969 cmdline_parse_token_string_t cmd_config_speed_specific_port =
970 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
972 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
973 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
975 cmdline_parse_token_num_t cmd_config_speed_specific_id =
976 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
977 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
978 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
980 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
981 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
982 "10#100#1000#10000#40000#auto");
983 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
984 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
986 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
987 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
990 cmdline_parse_inst_t cmd_config_speed_specific = {
991 .f = cmd_config_speed_specific_parsed,
993 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
996 (void *)&cmd_config_speed_specific_port,
997 (void *)&cmd_config_speed_specific_keyword,
998 (void *)&cmd_config_speed_specific_id,
999 (void *)&cmd_config_speed_specific_item1,
1000 (void *)&cmd_config_speed_specific_value1,
1001 (void *)&cmd_config_speed_specific_item2,
1002 (void *)&cmd_config_speed_specific_value2,
1007 /* *** configure txq/rxq, txd/rxd *** */
1008 struct cmd_config_rx_tx {
1009 cmdline_fixed_string_t port;
1010 cmdline_fixed_string_t keyword;
1011 cmdline_fixed_string_t all;
1012 cmdline_fixed_string_t name;
1017 cmd_config_rx_tx_parsed(void *parsed_result,
1018 __attribute__((unused)) struct cmdline *cl,
1019 __attribute__((unused)) void *data)
1021 struct cmd_config_rx_tx *res = parsed_result;
1023 if (!all_ports_stopped()) {
1024 printf("Please stop all ports first\n");
1028 if (!strcmp(res->name, "rxq")) {
1029 if (res->value <= 0) {
1030 printf("rxq %d invalid - must be > 0\n", res->value);
1033 nb_rxq = res->value;
1035 else if (!strcmp(res->name, "txq")) {
1036 if (res->value <= 0) {
1037 printf("txq %d invalid - must be > 0\n", res->value);
1040 nb_txq = res->value;
1042 else if (!strcmp(res->name, "rxd")) {
1043 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1044 printf("rxd %d invalid - must be > 0 && <= %d\n",
1045 res->value, RTE_TEST_RX_DESC_MAX);
1048 nb_rxd = res->value;
1049 } else if (!strcmp(res->name, "txd")) {
1050 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1051 printf("txd %d invalid - must be > 0 && <= %d\n",
1052 res->value, RTE_TEST_TX_DESC_MAX);
1055 nb_txd = res->value;
1057 printf("Unknown parameter\n");
1063 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1066 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1067 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1068 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1069 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1070 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1071 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1072 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1073 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1075 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1076 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1078 cmdline_parse_inst_t cmd_config_rx_tx = {
1079 .f = cmd_config_rx_tx_parsed,
1081 .help_str = "port config all rxq|txq|rxd|txd value",
1083 (void *)&cmd_config_rx_tx_port,
1084 (void *)&cmd_config_rx_tx_keyword,
1085 (void *)&cmd_config_rx_tx_all,
1086 (void *)&cmd_config_rx_tx_name,
1087 (void *)&cmd_config_rx_tx_value,
1092 /* *** config max packet length *** */
1093 struct cmd_config_max_pkt_len_result {
1094 cmdline_fixed_string_t port;
1095 cmdline_fixed_string_t keyword;
1096 cmdline_fixed_string_t all;
1097 cmdline_fixed_string_t name;
1102 cmd_config_max_pkt_len_parsed(void *parsed_result,
1103 __attribute__((unused)) struct cmdline *cl,
1104 __attribute__((unused)) void *data)
1106 struct cmd_config_max_pkt_len_result *res = parsed_result;
1108 if (!all_ports_stopped()) {
1109 printf("Please stop all ports first\n");
1113 if (!strcmp(res->name, "max-pkt-len")) {
1114 if (res->value < ETHER_MIN_LEN) {
1115 printf("max-pkt-len can not be less than %d\n",
1119 if (res->value == rx_mode.max_rx_pkt_len)
1122 rx_mode.max_rx_pkt_len = res->value;
1123 if (res->value > ETHER_MAX_LEN)
1124 rx_mode.jumbo_frame = 1;
1126 rx_mode.jumbo_frame = 0;
1128 printf("Unknown parameter\n");
1134 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1137 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1138 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1140 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1141 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1143 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1144 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1146 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1147 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1149 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1150 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1153 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1154 .f = cmd_config_max_pkt_len_parsed,
1156 .help_str = "port config all max-pkt-len value",
1158 (void *)&cmd_config_max_pkt_len_port,
1159 (void *)&cmd_config_max_pkt_len_keyword,
1160 (void *)&cmd_config_max_pkt_len_all,
1161 (void *)&cmd_config_max_pkt_len_name,
1162 (void *)&cmd_config_max_pkt_len_value,
1167 /* *** configure port MTU *** */
1168 struct cmd_config_mtu_result {
1169 cmdline_fixed_string_t port;
1170 cmdline_fixed_string_t keyword;
1171 cmdline_fixed_string_t mtu;
1177 cmd_config_mtu_parsed(void *parsed_result,
1178 __attribute__((unused)) struct cmdline *cl,
1179 __attribute__((unused)) void *data)
1181 struct cmd_config_mtu_result *res = parsed_result;
1183 if (res->value < ETHER_MIN_LEN) {
1184 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1187 port_mtu_set(res->port_id, res->value);
1190 cmdline_parse_token_string_t cmd_config_mtu_port =
1191 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1193 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1194 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1196 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1197 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1199 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1200 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1201 cmdline_parse_token_num_t cmd_config_mtu_value =
1202 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1204 cmdline_parse_inst_t cmd_config_mtu = {
1205 .f = cmd_config_mtu_parsed,
1207 .help_str = "port config mtu value",
1209 (void *)&cmd_config_mtu_port,
1210 (void *)&cmd_config_mtu_keyword,
1211 (void *)&cmd_config_mtu_mtu,
1212 (void *)&cmd_config_mtu_port_id,
1213 (void *)&cmd_config_mtu_value,
1218 /* *** configure rx mode *** */
1219 struct cmd_config_rx_mode_flag {
1220 cmdline_fixed_string_t port;
1221 cmdline_fixed_string_t keyword;
1222 cmdline_fixed_string_t all;
1223 cmdline_fixed_string_t name;
1224 cmdline_fixed_string_t value;
1228 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1229 __attribute__((unused)) struct cmdline *cl,
1230 __attribute__((unused)) void *data)
1232 struct cmd_config_rx_mode_flag *res = parsed_result;
1234 if (!all_ports_stopped()) {
1235 printf("Please stop all ports first\n");
1239 if (!strcmp(res->name, "crc-strip")) {
1240 if (!strcmp(res->value, "on"))
1241 rx_mode.hw_strip_crc = 1;
1242 else if (!strcmp(res->value, "off"))
1243 rx_mode.hw_strip_crc = 0;
1245 printf("Unknown parameter\n");
1248 } else if (!strcmp(res->name, "rx-cksum")) {
1249 if (!strcmp(res->value, "on"))
1250 rx_mode.hw_ip_checksum = 1;
1251 else if (!strcmp(res->value, "off"))
1252 rx_mode.hw_ip_checksum = 0;
1254 printf("Unknown parameter\n");
1257 } else if (!strcmp(res->name, "hw-vlan")) {
1258 if (!strcmp(res->value, "on")) {
1259 rx_mode.hw_vlan_filter = 1;
1260 rx_mode.hw_vlan_strip = 1;
1262 else if (!strcmp(res->value, "off")) {
1263 rx_mode.hw_vlan_filter = 0;
1264 rx_mode.hw_vlan_strip = 0;
1267 printf("Unknown parameter\n");
1270 } else if (!strcmp(res->name, "drop-en")) {
1271 if (!strcmp(res->value, "on"))
1273 else if (!strcmp(res->value, "off"))
1276 printf("Unknown parameter\n");
1280 printf("Unknown parameter\n");
1286 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1289 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1290 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1291 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1292 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1294 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1295 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1296 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1297 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1298 "crc-strip#rx-cksum#hw-vlan");
1299 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1300 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1303 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1304 .f = cmd_config_rx_mode_flag_parsed,
1306 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1308 (void *)&cmd_config_rx_mode_flag_port,
1309 (void *)&cmd_config_rx_mode_flag_keyword,
1310 (void *)&cmd_config_rx_mode_flag_all,
1311 (void *)&cmd_config_rx_mode_flag_name,
1312 (void *)&cmd_config_rx_mode_flag_value,
1317 /* *** configure rss *** */
1318 struct cmd_config_rss {
1319 cmdline_fixed_string_t port;
1320 cmdline_fixed_string_t keyword;
1321 cmdline_fixed_string_t all;
1322 cmdline_fixed_string_t name;
1323 cmdline_fixed_string_t value;
1327 cmd_config_rss_parsed(void *parsed_result,
1328 __attribute__((unused)) struct cmdline *cl,
1329 __attribute__((unused)) void *data)
1331 struct cmd_config_rss *res = parsed_result;
1332 struct rte_eth_rss_conf rss_conf;
1335 if (!strcmp(res->value, "ip"))
1336 rss_conf.rss_hf = ETH_RSS_IP;
1337 else if (!strcmp(res->value, "udp"))
1338 rss_conf.rss_hf = ETH_RSS_UDP;
1339 else if (!strcmp(res->value, "none"))
1340 rss_conf.rss_hf = 0;
1342 printf("Unknown parameter\n");
1345 rss_conf.rss_key = NULL;
1346 for (i = 0; i < rte_eth_dev_count(); i++)
1347 rte_eth_dev_rss_hash_update(i, &rss_conf);
1350 cmdline_parse_token_string_t cmd_config_rss_port =
1351 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1352 cmdline_parse_token_string_t cmd_config_rss_keyword =
1353 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1354 cmdline_parse_token_string_t cmd_config_rss_all =
1355 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1356 cmdline_parse_token_string_t cmd_config_rss_name =
1357 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1358 cmdline_parse_token_string_t cmd_config_rss_value =
1359 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1361 cmdline_parse_inst_t cmd_config_rss = {
1362 .f = cmd_config_rss_parsed,
1364 .help_str = "port config all rss ip|udp|none",
1366 (void *)&cmd_config_rss_port,
1367 (void *)&cmd_config_rss_keyword,
1368 (void *)&cmd_config_rss_all,
1369 (void *)&cmd_config_rss_name,
1370 (void *)&cmd_config_rss_value,
1375 /* *** configure rss hash key *** */
1376 struct cmd_config_rss_hash_key {
1377 cmdline_fixed_string_t port;
1378 cmdline_fixed_string_t config;
1380 cmdline_fixed_string_t rss_hash_key;
1381 cmdline_fixed_string_t key;
1384 #define RSS_HASH_KEY_LENGTH 40
1386 hexa_digit_to_value(char hexa_digit)
1388 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1389 return (uint8_t) (hexa_digit - '0');
1390 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1391 return (uint8_t) ((hexa_digit - 'a') + 10);
1392 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1393 return (uint8_t) ((hexa_digit - 'A') + 10);
1394 /* Invalid hexa digit */
1399 parse_and_check_key_hexa_digit(char *key, int idx)
1403 hexa_v = hexa_digit_to_value(key[idx]);
1405 printf("invalid key: character %c at position %d is not a "
1406 "valid hexa digit\n", key[idx], idx);
1411 cmd_config_rss_hash_key_parsed(void *parsed_result,
1412 __attribute__((unused)) struct cmdline *cl,
1413 __attribute__((unused)) void *data)
1415 struct cmd_config_rss_hash_key *res = parsed_result;
1416 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1421 /* Check the length of the RSS hash key */
1422 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1423 printf("key length: %d invalid - key must be a string of %d"
1424 "hexa-decimal numbers\n", (int) strlen(res->key),
1425 RSS_HASH_KEY_LENGTH * 2);
1428 /* Translate RSS hash key into binary representation */
1429 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1430 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1433 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1436 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1438 port_rss_hash_key_update(res->port_id, hash_key);
1441 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1442 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1443 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1444 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1446 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1447 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1448 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1449 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1450 rss_hash_key, "rss-hash-key");
1451 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1452 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1454 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1455 .f = cmd_config_rss_hash_key_parsed,
1457 .help_str = "port config X rss-hash-key 80 hexa digits",
1459 (void *)&cmd_config_rss_hash_key_port,
1460 (void *)&cmd_config_rss_hash_key_config,
1461 (void *)&cmd_config_rss_hash_key_port_id,
1462 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1463 (void *)&cmd_config_rss_hash_key_value,
1468 /* *** configure port rxq/txq start/stop *** */
1469 struct cmd_config_rxtx_queue {
1470 cmdline_fixed_string_t port;
1472 cmdline_fixed_string_t rxtxq;
1474 cmdline_fixed_string_t opname;
1478 cmd_config_rxtx_queue_parsed(void *parsed_result,
1479 __attribute__((unused)) struct cmdline *cl,
1480 __attribute__((unused)) void *data)
1482 struct cmd_config_rxtx_queue *res = parsed_result;
1487 if (test_done == 0) {
1488 printf("Please stop forwarding first\n");
1492 if (port_id_is_invalid(res->portid))
1495 if (port_is_started(res->portid) != 1) {
1496 printf("Please start port %u first\n", res->portid);
1500 if (!strcmp(res->rxtxq, "rxq"))
1502 else if (!strcmp(res->rxtxq, "txq"))
1505 printf("Unknown parameter\n");
1509 if (isrx && rx_queue_id_is_invalid(res->qid))
1511 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1514 if (!strcmp(res->opname, "start"))
1516 else if (!strcmp(res->opname, "stop"))
1519 printf("Unknown parameter\n");
1523 if (isstart && isrx)
1524 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1525 else if (!isstart && isrx)
1526 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1527 else if (isstart && !isrx)
1528 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1530 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1532 if (ret == -ENOTSUP)
1533 printf("Function not supported in PMD driver\n");
1536 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1537 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1538 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1539 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1540 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1541 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1542 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1543 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1544 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1545 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1548 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1549 .f = cmd_config_rxtx_queue_parsed,
1551 .help_str = "port X rxq|txq ID start|stop",
1553 (void *)&cmd_config_speed_all_port,
1554 (void *)&cmd_config_rxtx_queue_portid,
1555 (void *)&cmd_config_rxtx_queue_rxtxq,
1556 (void *)&cmd_config_rxtx_queue_qid,
1557 (void *)&cmd_config_rxtx_queue_opname,
1562 /* *** Configure RSS RETA *** */
1563 struct cmd_config_rss_reta {
1564 cmdline_fixed_string_t port;
1565 cmdline_fixed_string_t keyword;
1567 cmdline_fixed_string_t name;
1568 cmdline_fixed_string_t list_name;
1569 cmdline_fixed_string_t list_of_items;
1573 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1580 const char *p, *p0 = str;
1587 unsigned long int_fld[_NUM_FLD];
1588 char *str_fld[_NUM_FLD];
1590 while ((p = strchr(p0,'(')) != NULL) {
1592 if((p0 = strchr(p,')')) == NULL)
1596 if(size >= sizeof(s))
1599 snprintf(s, sizeof(s), "%.*s", size, p);
1600 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1602 for (i = 0; i < _NUM_FLD; i++) {
1604 int_fld[i] = strtoul(str_fld[i], &end, 0);
1605 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1609 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1610 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1612 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1613 printf("Invalid RETA hash index=%d",hash_index);
1617 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1618 reta_conf->mask_lo |= (1ULL << hash_index);
1620 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1622 reta_conf->reta[hash_index] = nb_queue;
1629 cmd_set_rss_reta_parsed(void *parsed_result,
1630 __attribute__((unused)) struct cmdline *cl,
1631 __attribute__((unused)) void *data)
1634 struct rte_eth_rss_reta reta_conf;
1635 struct cmd_config_rss_reta *res = parsed_result;
1637 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1638 if (!strcmp(res->list_name, "reta")) {
1639 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1640 printf("Invalid RSS Redirection Table config entered\n");
1643 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1645 printf("Bad redirection table parameter, return code = %d \n",ret);
1649 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1651 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1653 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1654 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1655 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1657 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1659 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1662 cmdline_parse_inst_t cmd_config_rss_reta = {
1663 .f = cmd_set_rss_reta_parsed,
1665 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1667 (void *)&cmd_config_rss_reta_port,
1668 (void *)&cmd_config_rss_reta_keyword,
1669 (void *)&cmd_config_rss_reta_port_id,
1670 (void *)&cmd_config_rss_reta_name,
1671 (void *)&cmd_config_rss_reta_list_name,
1672 (void *)&cmd_config_rss_reta_list_of_items,
1677 /* *** SHOW PORT RETA INFO *** */
1678 struct cmd_showport_reta {
1679 cmdline_fixed_string_t show;
1680 cmdline_fixed_string_t port;
1682 cmdline_fixed_string_t rss;
1683 cmdline_fixed_string_t reta;
1688 static void cmd_showport_reta_parsed(void *parsed_result,
1689 __attribute__((unused)) struct cmdline *cl,
1690 __attribute__((unused)) void *data)
1692 struct cmd_showport_reta *res = parsed_result;
1693 struct rte_eth_rss_reta reta_conf;
1695 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1696 printf("Invalid RSS Redirection Table config entered\n");
1700 reta_conf.mask_lo = res->mask_lo;
1701 reta_conf.mask_hi = res->mask_hi;
1703 port_rss_reta_info(res->port_id,&reta_conf);
1706 cmdline_parse_token_string_t cmd_showport_reta_show =
1707 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1708 cmdline_parse_token_string_t cmd_showport_reta_port =
1709 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1710 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1711 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1712 cmdline_parse_token_string_t cmd_showport_reta_rss =
1713 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1714 cmdline_parse_token_string_t cmd_showport_reta_reta =
1715 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1716 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1717 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1718 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1719 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1721 cmdline_parse_inst_t cmd_showport_reta = {
1722 .f = cmd_showport_reta_parsed,
1724 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1725 (mask_lo and mask_hi is UINT64)",
1727 (void *)&cmd_showport_reta_show,
1728 (void *)&cmd_showport_reta_port,
1729 (void *)&cmd_showport_reta_port_id,
1730 (void *)&cmd_showport_reta_rss,
1731 (void *)&cmd_showport_reta_reta,
1732 (void *)&cmd_showport_reta_mask_lo,
1733 (void *)&cmd_showport_reta_mask_hi,
1738 /* *** Show RSS hash configuration *** */
1739 struct cmd_showport_rss_hash {
1740 cmdline_fixed_string_t show;
1741 cmdline_fixed_string_t port;
1743 cmdline_fixed_string_t rss_hash;
1744 cmdline_fixed_string_t key; /* optional argument */
1747 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1748 __attribute__((unused)) struct cmdline *cl,
1751 struct cmd_showport_rss_hash *res = parsed_result;
1753 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1756 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1757 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1758 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1759 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1760 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1761 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1762 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1763 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1765 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1766 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1768 cmdline_parse_inst_t cmd_showport_rss_hash = {
1769 .f = cmd_showport_rss_hash_parsed,
1771 .help_str = "show port X rss-hash (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,
1781 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1782 .f = cmd_showport_rss_hash_parsed,
1784 .help_str = "show port X rss-hash key (X = port number)\n",
1786 (void *)&cmd_showport_rss_hash_show,
1787 (void *)&cmd_showport_rss_hash_port,
1788 (void *)&cmd_showport_rss_hash_port_id,
1789 (void *)&cmd_showport_rss_hash_rss_hash,
1790 (void *)&cmd_showport_rss_hash_rss_key,
1795 /* *** Configure DCB *** */
1796 struct cmd_config_dcb {
1797 cmdline_fixed_string_t port;
1798 cmdline_fixed_string_t config;
1800 cmdline_fixed_string_t dcb;
1801 cmdline_fixed_string_t vt;
1802 cmdline_fixed_string_t vt_en;
1804 cmdline_fixed_string_t pfc;
1805 cmdline_fixed_string_t pfc_en;
1809 cmd_config_dcb_parsed(void *parsed_result,
1810 __attribute__((unused)) struct cmdline *cl,
1811 __attribute__((unused)) void *data)
1813 struct cmd_config_dcb *res = parsed_result;
1814 struct dcb_config dcb_conf;
1815 portid_t port_id = res->port_id;
1816 struct rte_port *port;
1818 port = &ports[port_id];
1819 /** Check if the port is not started **/
1820 if (port->port_status != RTE_PORT_STOPPED) {
1821 printf("Please stop port %d first\n",port_id);
1825 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1826 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1827 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1831 /* DCB in VT mode */
1832 if (!strncmp(res->vt_en, "on",2))
1833 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1835 dcb_conf.dcb_mode = DCB_ENABLED;
1837 if (!strncmp(res->pfc_en, "on",2)) {
1838 dcb_conf.pfc_en = 1;
1841 dcb_conf.pfc_en = 0;
1843 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1844 printf("Cannot initialize network ports\n");
1848 cmd_reconfig_device_queue(port_id, 1, 1);
1851 cmdline_parse_token_string_t cmd_config_dcb_port =
1852 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1853 cmdline_parse_token_string_t cmd_config_dcb_config =
1854 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1855 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1856 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1857 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1859 cmdline_parse_token_string_t cmd_config_dcb_vt =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1861 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1863 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1864 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1865 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1867 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1868 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1870 cmdline_parse_inst_t cmd_config_dcb = {
1871 .f = cmd_config_dcb_parsed,
1873 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1875 (void *)&cmd_config_dcb_port,
1876 (void *)&cmd_config_dcb_config,
1877 (void *)&cmd_config_dcb_port_id,
1878 (void *)&cmd_config_dcb_dcb,
1879 (void *)&cmd_config_dcb_vt,
1880 (void *)&cmd_config_dcb_vt_en,
1881 (void *)&cmd_config_dcb_num_tcs,
1882 (void *)&cmd_config_dcb_pfc,
1883 (void *)&cmd_config_dcb_pfc_en,
1888 /* *** configure number of packets per burst *** */
1889 struct cmd_config_burst {
1890 cmdline_fixed_string_t port;
1891 cmdline_fixed_string_t keyword;
1892 cmdline_fixed_string_t all;
1893 cmdline_fixed_string_t name;
1898 cmd_config_burst_parsed(void *parsed_result,
1899 __attribute__((unused)) struct cmdline *cl,
1900 __attribute__((unused)) void *data)
1902 struct cmd_config_burst *res = parsed_result;
1904 if (!all_ports_stopped()) {
1905 printf("Please stop all ports first\n");
1909 if (!strcmp(res->name, "burst")) {
1910 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1911 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1914 nb_pkt_per_burst = res->value;
1916 printf("Unknown parameter\n");
1922 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1925 cmdline_parse_token_string_t cmd_config_burst_port =
1926 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1927 cmdline_parse_token_string_t cmd_config_burst_keyword =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1929 cmdline_parse_token_string_t cmd_config_burst_all =
1930 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1931 cmdline_parse_token_string_t cmd_config_burst_name =
1932 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1933 cmdline_parse_token_num_t cmd_config_burst_value =
1934 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1936 cmdline_parse_inst_t cmd_config_burst = {
1937 .f = cmd_config_burst_parsed,
1939 .help_str = "port config all burst value",
1941 (void *)&cmd_config_burst_port,
1942 (void *)&cmd_config_burst_keyword,
1943 (void *)&cmd_config_burst_all,
1944 (void *)&cmd_config_burst_name,
1945 (void *)&cmd_config_burst_value,
1950 /* *** configure rx/tx queues *** */
1951 struct cmd_config_thresh {
1952 cmdline_fixed_string_t port;
1953 cmdline_fixed_string_t keyword;
1954 cmdline_fixed_string_t all;
1955 cmdline_fixed_string_t name;
1960 cmd_config_thresh_parsed(void *parsed_result,
1961 __attribute__((unused)) struct cmdline *cl,
1962 __attribute__((unused)) void *data)
1964 struct cmd_config_thresh *res = parsed_result;
1966 if (!all_ports_stopped()) {
1967 printf("Please stop all ports first\n");
1971 if (!strcmp(res->name, "txpt"))
1972 tx_thresh.pthresh = res->value;
1973 else if(!strcmp(res->name, "txht"))
1974 tx_thresh.hthresh = res->value;
1975 else if(!strcmp(res->name, "txwt"))
1976 tx_thresh.wthresh = res->value;
1977 else if(!strcmp(res->name, "rxpt"))
1978 rx_thresh.pthresh = res->value;
1979 else if(!strcmp(res->name, "rxht"))
1980 rx_thresh.hthresh = res->value;
1981 else if(!strcmp(res->name, "rxwt"))
1982 rx_thresh.wthresh = res->value;
1984 printf("Unknown parameter\n");
1990 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1993 cmdline_parse_token_string_t cmd_config_thresh_port =
1994 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1995 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1996 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1997 cmdline_parse_token_string_t cmd_config_thresh_all =
1998 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1999 cmdline_parse_token_string_t cmd_config_thresh_name =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2001 "txpt#txht#txwt#rxpt#rxht#rxwt");
2002 cmdline_parse_token_num_t cmd_config_thresh_value =
2003 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2005 cmdline_parse_inst_t cmd_config_thresh = {
2006 .f = cmd_config_thresh_parsed,
2008 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2010 (void *)&cmd_config_thresh_port,
2011 (void *)&cmd_config_thresh_keyword,
2012 (void *)&cmd_config_thresh_all,
2013 (void *)&cmd_config_thresh_name,
2014 (void *)&cmd_config_thresh_value,
2019 /* *** configure free/rs threshold *** */
2020 struct cmd_config_threshold {
2021 cmdline_fixed_string_t port;
2022 cmdline_fixed_string_t keyword;
2023 cmdline_fixed_string_t all;
2024 cmdline_fixed_string_t name;
2029 cmd_config_threshold_parsed(void *parsed_result,
2030 __attribute__((unused)) struct cmdline *cl,
2031 __attribute__((unused)) void *data)
2033 struct cmd_config_threshold *res = parsed_result;
2035 if (!all_ports_stopped()) {
2036 printf("Please stop all ports first\n");
2040 if (!strcmp(res->name, "txfreet"))
2041 tx_free_thresh = res->value;
2042 else if (!strcmp(res->name, "txrst"))
2043 tx_rs_thresh = res->value;
2044 else if (!strcmp(res->name, "rxfreet"))
2045 rx_free_thresh = res->value;
2047 printf("Unknown parameter\n");
2053 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2056 cmdline_parse_token_string_t cmd_config_threshold_port =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2058 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2059 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2061 cmdline_parse_token_string_t cmd_config_threshold_all =
2062 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2063 cmdline_parse_token_string_t cmd_config_threshold_name =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2065 "txfreet#txrst#rxfreet");
2066 cmdline_parse_token_num_t cmd_config_threshold_value =
2067 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2069 cmdline_parse_inst_t cmd_config_threshold = {
2070 .f = cmd_config_threshold_parsed,
2072 .help_str = "port config all txfreet|txrst|rxfreet value",
2074 (void *)&cmd_config_threshold_port,
2075 (void *)&cmd_config_threshold_keyword,
2076 (void *)&cmd_config_threshold_all,
2077 (void *)&cmd_config_threshold_name,
2078 (void *)&cmd_config_threshold_value,
2084 struct cmd_stop_result {
2085 cmdline_fixed_string_t stop;
2088 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2089 __attribute__((unused)) struct cmdline *cl,
2090 __attribute__((unused)) void *data)
2092 stop_packet_forwarding();
2095 cmdline_parse_token_string_t cmd_stop_stop =
2096 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2098 cmdline_parse_inst_t cmd_stop = {
2099 .f = cmd_stop_parsed,
2101 .help_str = "stop - stop packet forwarding",
2103 (void *)&cmd_stop_stop,
2108 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2111 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2112 unsigned int *parsed_items, int check_unique_values)
2114 unsigned int nb_item;
2122 * First parse all items in the list and store their value.
2127 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2129 if ((c >= '0') && (c <= '9')) {
2130 value = (unsigned int) (value * 10 + (c - '0'));
2135 printf("character %c is not a decimal digit\n", c);
2139 printf("No valid value before comma\n");
2142 if (nb_item < max_items) {
2143 parsed_items[nb_item] = value;
2149 if (nb_item >= max_items) {
2150 printf("Number of %s = %u > %u (maximum items)\n",
2151 item_name, nb_item + 1, max_items);
2154 parsed_items[nb_item++] = value;
2155 if (! check_unique_values)
2159 * Then, check that all values in the list are differents.
2160 * No optimization here...
2162 for (i = 0; i < nb_item; i++) {
2163 for (j = i + 1; j < nb_item; j++) {
2164 if (parsed_items[j] == parsed_items[i]) {
2165 printf("duplicated %s %u at index %u and %u\n",
2166 item_name, parsed_items[i], i, j);
2174 struct cmd_set_list_result {
2175 cmdline_fixed_string_t cmd_keyword;
2176 cmdline_fixed_string_t list_name;
2177 cmdline_fixed_string_t list_of_items;
2180 static void cmd_set_list_parsed(void *parsed_result,
2181 __attribute__((unused)) struct cmdline *cl,
2182 __attribute__((unused)) void *data)
2184 struct cmd_set_list_result *res;
2186 unsigned int lcorelist[RTE_MAX_LCORE];
2187 unsigned int portlist[RTE_MAX_ETHPORTS];
2189 unsigned int nb_item;
2191 res = parsed_result;
2192 if (!strcmp(res->list_name, "corelist")) {
2193 nb_item = parse_item_list(res->list_of_items, "core",
2195 parsed_items.lcorelist, 1);
2197 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2200 if (!strcmp(res->list_name, "portlist")) {
2201 nb_item = parse_item_list(res->list_of_items, "port",
2203 parsed_items.portlist, 1);
2205 set_fwd_ports_list(parsed_items.portlist, nb_item);
2209 cmdline_parse_token_string_t cmd_set_list_keyword =
2210 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2212 cmdline_parse_token_string_t cmd_set_list_name =
2213 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2214 "corelist#portlist");
2215 cmdline_parse_token_string_t cmd_set_list_of_items =
2216 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2219 cmdline_parse_inst_t cmd_set_fwd_list = {
2220 .f = cmd_set_list_parsed,
2222 .help_str = "set corelist|portlist x[,y]*",
2224 (void *)&cmd_set_list_keyword,
2225 (void *)&cmd_set_list_name,
2226 (void *)&cmd_set_list_of_items,
2231 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2233 struct cmd_setmask_result {
2234 cmdline_fixed_string_t set;
2235 cmdline_fixed_string_t mask;
2239 static void cmd_set_mask_parsed(void *parsed_result,
2240 __attribute__((unused)) struct cmdline *cl,
2241 __attribute__((unused)) void *data)
2243 struct cmd_setmask_result *res = parsed_result;
2245 if (!strcmp(res->mask, "coremask"))
2246 set_fwd_lcores_mask(res->hexavalue);
2247 else if (!strcmp(res->mask, "portmask"))
2248 set_fwd_ports_mask(res->hexavalue);
2251 cmdline_parse_token_string_t cmd_setmask_set =
2252 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2253 cmdline_parse_token_string_t cmd_setmask_mask =
2254 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2255 "coremask#portmask");
2256 cmdline_parse_token_num_t cmd_setmask_value =
2257 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2259 cmdline_parse_inst_t cmd_set_fwd_mask = {
2260 .f = cmd_set_mask_parsed,
2262 .help_str = "set coremask|portmask hexadecimal value",
2264 (void *)&cmd_setmask_set,
2265 (void *)&cmd_setmask_mask,
2266 (void *)&cmd_setmask_value,
2272 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2274 struct cmd_set_result {
2275 cmdline_fixed_string_t set;
2276 cmdline_fixed_string_t what;
2280 static void cmd_set_parsed(void *parsed_result,
2281 __attribute__((unused)) struct cmdline *cl,
2282 __attribute__((unused)) void *data)
2284 struct cmd_set_result *res = parsed_result;
2285 if (!strcmp(res->what, "nbport"))
2286 set_fwd_ports_number(res->value);
2287 else if (!strcmp(res->what, "nbcore"))
2288 set_fwd_lcores_number(res->value);
2289 else if (!strcmp(res->what, "burst"))
2290 set_nb_pkt_per_burst(res->value);
2291 else if (!strcmp(res->what, "verbose"))
2292 set_verbose_level(res->value);
2295 cmdline_parse_token_string_t cmd_set_set =
2296 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2297 cmdline_parse_token_string_t cmd_set_what =
2298 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2299 "nbport#nbcore#burst#verbose");
2300 cmdline_parse_token_num_t cmd_set_value =
2301 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2303 cmdline_parse_inst_t cmd_set_numbers = {
2304 .f = cmd_set_parsed,
2306 .help_str = "set nbport|nbcore|burst|verbose value",
2308 (void *)&cmd_set_set,
2309 (void *)&cmd_set_what,
2310 (void *)&cmd_set_value,
2315 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2317 struct cmd_set_txpkts_result {
2318 cmdline_fixed_string_t cmd_keyword;
2319 cmdline_fixed_string_t txpkts;
2320 cmdline_fixed_string_t seg_lengths;
2324 cmd_set_txpkts_parsed(void *parsed_result,
2325 __attribute__((unused)) struct cmdline *cl,
2326 __attribute__((unused)) void *data)
2328 struct cmd_set_txpkts_result *res;
2329 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2330 unsigned int nb_segs;
2332 res = parsed_result;
2333 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2334 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2336 set_tx_pkt_segments(seg_lengths, nb_segs);
2339 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2340 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2341 cmd_keyword, "set");
2342 cmdline_parse_token_string_t cmd_set_txpkts_name =
2343 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2345 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2346 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2349 cmdline_parse_inst_t cmd_set_txpkts = {
2350 .f = cmd_set_txpkts_parsed,
2352 .help_str = "set txpkts x[,y]*",
2354 (void *)&cmd_set_txpkts_keyword,
2355 (void *)&cmd_set_txpkts_name,
2356 (void *)&cmd_set_txpkts_lengths,
2361 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2362 struct cmd_rx_vlan_filter_all_result {
2363 cmdline_fixed_string_t rx_vlan;
2364 cmdline_fixed_string_t what;
2365 cmdline_fixed_string_t all;
2370 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2371 __attribute__((unused)) struct cmdline *cl,
2372 __attribute__((unused)) void *data)
2374 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2376 if (!strcmp(res->what, "add"))
2377 rx_vlan_all_filter_set(res->port_id, 1);
2379 rx_vlan_all_filter_set(res->port_id, 0);
2382 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2383 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2384 rx_vlan, "rx_vlan");
2385 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2386 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2388 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2389 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2391 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2392 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2395 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2396 .f = cmd_rx_vlan_filter_all_parsed,
2398 .help_str = "add/remove all identifiers to/from the set of VLAN "
2399 "Identifiers filtered by a port",
2401 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2402 (void *)&cmd_rx_vlan_filter_all_what,
2403 (void *)&cmd_rx_vlan_filter_all_all,
2404 (void *)&cmd_rx_vlan_filter_all_portid,
2409 /* *** VLAN OFFLOAD SET ON A PORT *** */
2410 struct cmd_vlan_offload_result {
2411 cmdline_fixed_string_t vlan;
2412 cmdline_fixed_string_t set;
2413 cmdline_fixed_string_t what;
2414 cmdline_fixed_string_t on;
2415 cmdline_fixed_string_t port_id;
2419 cmd_vlan_offload_parsed(void *parsed_result,
2420 __attribute__((unused)) struct cmdline *cl,
2421 __attribute__((unused)) void *data)
2424 struct cmd_vlan_offload_result *res = parsed_result;
2427 portid_t port_id = 0;
2431 len = strnlen(str, STR_TOKEN_SIZE);
2433 /* Get port_id first */
2441 tmp = strtoul(str, NULL, 0);
2442 /* If port_id greater that what portid_t can represent, return */
2443 if(tmp >= RTE_MAX_ETHPORTS)
2445 port_id = (portid_t)tmp;
2447 if (!strcmp(res->on, "on"))
2452 if (!strcmp(res->what, "strip"))
2453 rx_vlan_strip_set(port_id, on);
2454 else if(!strcmp(res->what, "stripq")){
2455 uint16_t queue_id = 0;
2457 /* No queue_id, return */
2459 printf("must specify (port,queue_id)\n");
2462 tmp = strtoul(str + i + 1, NULL, 0);
2463 /* If queue_id greater that what 16-bits can represent, return */
2467 queue_id = (uint16_t)tmp;
2468 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2470 else if (!strcmp(res->what, "filter"))
2471 rx_vlan_filter_set(port_id, on);
2473 vlan_extend_set(port_id, on);
2478 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2479 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2481 cmdline_parse_token_string_t cmd_vlan_offload_set =
2482 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2484 cmdline_parse_token_string_t cmd_vlan_offload_what =
2485 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2486 what, "strip#filter#qinq#stripq");
2487 cmdline_parse_token_string_t cmd_vlan_offload_on =
2488 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2490 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2491 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2494 cmdline_parse_inst_t cmd_vlan_offload = {
2495 .f = cmd_vlan_offload_parsed,
2497 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2498 " qinq(extended) for both rx/tx sides ",
2500 (void *)&cmd_vlan_offload_vlan,
2501 (void *)&cmd_vlan_offload_set,
2502 (void *)&cmd_vlan_offload_what,
2503 (void *)&cmd_vlan_offload_on,
2504 (void *)&cmd_vlan_offload_portid,
2509 /* *** VLAN TPID SET ON A PORT *** */
2510 struct cmd_vlan_tpid_result {
2511 cmdline_fixed_string_t vlan;
2512 cmdline_fixed_string_t set;
2513 cmdline_fixed_string_t what;
2519 cmd_vlan_tpid_parsed(void *parsed_result,
2520 __attribute__((unused)) struct cmdline *cl,
2521 __attribute__((unused)) void *data)
2523 struct cmd_vlan_tpid_result *res = parsed_result;
2524 vlan_tpid_set(res->port_id, res->tp_id);
2528 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2529 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2531 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2532 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2534 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2535 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2537 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2538 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2540 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2541 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2544 cmdline_parse_inst_t cmd_vlan_tpid = {
2545 .f = cmd_vlan_tpid_parsed,
2547 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2549 (void *)&cmd_vlan_tpid_vlan,
2550 (void *)&cmd_vlan_tpid_set,
2551 (void *)&cmd_vlan_tpid_what,
2552 (void *)&cmd_vlan_tpid_tpid,
2553 (void *)&cmd_vlan_tpid_portid,
2558 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2559 struct cmd_rx_vlan_filter_result {
2560 cmdline_fixed_string_t rx_vlan;
2561 cmdline_fixed_string_t what;
2567 cmd_rx_vlan_filter_parsed(void *parsed_result,
2568 __attribute__((unused)) struct cmdline *cl,
2569 __attribute__((unused)) void *data)
2571 struct cmd_rx_vlan_filter_result *res = parsed_result;
2573 if (!strcmp(res->what, "add"))
2574 rx_vft_set(res->port_id, res->vlan_id, 1);
2576 rx_vft_set(res->port_id, res->vlan_id, 0);
2579 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2580 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2581 rx_vlan, "rx_vlan");
2582 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2583 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2585 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2586 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2588 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2589 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2592 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2593 .f = cmd_rx_vlan_filter_parsed,
2595 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2596 "Identifiers filtered by a port",
2598 (void *)&cmd_rx_vlan_filter_rx_vlan,
2599 (void *)&cmd_rx_vlan_filter_what,
2600 (void *)&cmd_rx_vlan_filter_vlanid,
2601 (void *)&cmd_rx_vlan_filter_portid,
2606 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2607 struct cmd_tx_vlan_set_result {
2608 cmdline_fixed_string_t tx_vlan;
2609 cmdline_fixed_string_t set;
2615 cmd_tx_vlan_set_parsed(void *parsed_result,
2616 __attribute__((unused)) struct cmdline *cl,
2617 __attribute__((unused)) void *data)
2619 struct cmd_tx_vlan_set_result *res = parsed_result;
2620 tx_vlan_set(res->port_id, res->vlan_id);
2623 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2624 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2625 tx_vlan, "tx_vlan");
2626 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2627 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2629 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2630 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2632 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2633 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2636 cmdline_parse_inst_t cmd_tx_vlan_set = {
2637 .f = cmd_tx_vlan_set_parsed,
2639 .help_str = "enable hardware insertion of a VLAN header with a given "
2640 "TAG Identifier in packets sent on a port",
2642 (void *)&cmd_tx_vlan_set_tx_vlan,
2643 (void *)&cmd_tx_vlan_set_set,
2644 (void *)&cmd_tx_vlan_set_vlanid,
2645 (void *)&cmd_tx_vlan_set_portid,
2650 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2651 struct cmd_tx_vlan_set_pvid_result {
2652 cmdline_fixed_string_t tx_vlan;
2653 cmdline_fixed_string_t set;
2654 cmdline_fixed_string_t pvid;
2657 cmdline_fixed_string_t mode;
2661 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2662 __attribute__((unused)) struct cmdline *cl,
2663 __attribute__((unused)) void *data)
2665 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2667 if (strcmp(res->mode, "on") == 0)
2668 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2670 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2673 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2674 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2675 tx_vlan, "tx_vlan");
2676 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2677 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2679 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2680 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2682 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2683 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2685 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2686 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2688 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2689 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2692 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2693 .f = cmd_tx_vlan_set_pvid_parsed,
2695 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2697 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2698 (void *)&cmd_tx_vlan_set_pvid_set,
2699 (void *)&cmd_tx_vlan_set_pvid_pvid,
2700 (void *)&cmd_tx_vlan_set_pvid_port_id,
2701 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2702 (void *)&cmd_tx_vlan_set_pvid_mode,
2707 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2708 struct cmd_tx_vlan_reset_result {
2709 cmdline_fixed_string_t tx_vlan;
2710 cmdline_fixed_string_t reset;
2715 cmd_tx_vlan_reset_parsed(void *parsed_result,
2716 __attribute__((unused)) struct cmdline *cl,
2717 __attribute__((unused)) void *data)
2719 struct cmd_tx_vlan_reset_result *res = parsed_result;
2721 tx_vlan_reset(res->port_id);
2724 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2725 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2726 tx_vlan, "tx_vlan");
2727 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2728 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2730 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2731 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2734 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2735 .f = cmd_tx_vlan_reset_parsed,
2737 .help_str = "disable hardware insertion of a VLAN header in packets "
2740 (void *)&cmd_tx_vlan_reset_tx_vlan,
2741 (void *)&cmd_tx_vlan_reset_reset,
2742 (void *)&cmd_tx_vlan_reset_portid,
2748 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2749 struct cmd_tx_cksum_set_result {
2750 cmdline_fixed_string_t tx_cksum;
2751 cmdline_fixed_string_t set;
2757 cmd_tx_cksum_set_parsed(void *parsed_result,
2758 __attribute__((unused)) struct cmdline *cl,
2759 __attribute__((unused)) void *data)
2761 struct cmd_tx_cksum_set_result *res = parsed_result;
2763 tx_cksum_set(res->port_id, res->cksum_mask);
2766 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2767 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2768 tx_cksum, "tx_checksum");
2769 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2770 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2772 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2773 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2775 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2776 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2779 cmdline_parse_inst_t cmd_tx_cksum_set = {
2780 .f = cmd_tx_cksum_set_parsed,
2782 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2783 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip, "
2784 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip, "
2785 "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
2787 (void *)&cmd_tx_cksum_set_tx_cksum,
2788 (void *)&cmd_tx_cksum_set_set,
2789 (void *)&cmd_tx_cksum_set_cksum_mask,
2790 (void *)&cmd_tx_cksum_set_portid,
2795 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2796 struct cmd_set_flush_rx {
2797 cmdline_fixed_string_t set;
2798 cmdline_fixed_string_t flush_rx;
2799 cmdline_fixed_string_t mode;
2803 cmd_set_flush_rx_parsed(void *parsed_result,
2804 __attribute__((unused)) struct cmdline *cl,
2805 __attribute__((unused)) void *data)
2807 struct cmd_set_flush_rx *res = parsed_result;
2808 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2811 cmdline_parse_token_string_t cmd_setflushrx_set =
2812 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2814 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2815 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2816 flush_rx, "flush_rx");
2817 cmdline_parse_token_string_t cmd_setflushrx_mode =
2818 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2822 cmdline_parse_inst_t cmd_set_flush_rx = {
2823 .f = cmd_set_flush_rx_parsed,
2824 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2827 (void *)&cmd_setflushrx_set,
2828 (void *)&cmd_setflushrx_flush_rx,
2829 (void *)&cmd_setflushrx_mode,
2834 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2835 struct cmd_set_link_check {
2836 cmdline_fixed_string_t set;
2837 cmdline_fixed_string_t link_check;
2838 cmdline_fixed_string_t mode;
2842 cmd_set_link_check_parsed(void *parsed_result,
2843 __attribute__((unused)) struct cmdline *cl,
2844 __attribute__((unused)) void *data)
2846 struct cmd_set_link_check *res = parsed_result;
2847 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2850 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2851 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2853 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2854 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2855 link_check, "link_check");
2856 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2857 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2861 cmdline_parse_inst_t cmd_set_link_check = {
2862 .f = cmd_set_link_check_parsed,
2863 .help_str = "set link_check on|off: enable/disable link status check "
2864 "when starting/stopping a port",
2867 (void *)&cmd_setlinkcheck_set,
2868 (void *)&cmd_setlinkcheck_link_check,
2869 (void *)&cmd_setlinkcheck_mode,
2874 #ifdef RTE_NIC_BYPASS
2875 /* *** SET NIC BYPASS MODE *** */
2876 struct cmd_set_bypass_mode_result {
2877 cmdline_fixed_string_t set;
2878 cmdline_fixed_string_t bypass;
2879 cmdline_fixed_string_t mode;
2880 cmdline_fixed_string_t value;
2885 cmd_set_bypass_mode_parsed(void *parsed_result,
2886 __attribute__((unused)) struct cmdline *cl,
2887 __attribute__((unused)) void *data)
2889 struct cmd_set_bypass_mode_result *res = parsed_result;
2890 portid_t port_id = res->port_id;
2891 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2893 if (!bypass_is_supported(port_id))
2896 if (!strcmp(res->value, "bypass"))
2897 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2898 else if (!strcmp(res->value, "isolate"))
2899 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2901 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2903 /* Set the bypass mode for the relevant port. */
2904 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2905 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2909 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2910 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2912 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2913 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2915 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2916 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2918 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2919 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2920 value, "normal#bypass#isolate");
2921 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2922 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2925 cmdline_parse_inst_t cmd_set_bypass_mode = {
2926 .f = cmd_set_bypass_mode_parsed,
2927 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2928 "Set the NIC bypass mode for port_id",
2931 (void *)&cmd_setbypass_mode_set,
2932 (void *)&cmd_setbypass_mode_bypass,
2933 (void *)&cmd_setbypass_mode_mode,
2934 (void *)&cmd_setbypass_mode_value,
2935 (void *)&cmd_setbypass_mode_port,
2940 /* *** SET NIC BYPASS EVENT *** */
2941 struct cmd_set_bypass_event_result {
2942 cmdline_fixed_string_t set;
2943 cmdline_fixed_string_t bypass;
2944 cmdline_fixed_string_t event;
2945 cmdline_fixed_string_t event_value;
2946 cmdline_fixed_string_t mode;
2947 cmdline_fixed_string_t mode_value;
2952 cmd_set_bypass_event_parsed(void *parsed_result,
2953 __attribute__((unused)) struct cmdline *cl,
2954 __attribute__((unused)) void *data)
2957 struct cmd_set_bypass_event_result *res = parsed_result;
2958 portid_t port_id = res->port_id;
2959 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2960 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2962 if (!bypass_is_supported(port_id))
2965 if (!strcmp(res->event_value, "timeout"))
2966 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2967 else if (!strcmp(res->event_value, "os_on"))
2968 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2969 else if (!strcmp(res->event_value, "os_off"))
2970 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2971 else if (!strcmp(res->event_value, "power_on"))
2972 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2973 else if (!strcmp(res->event_value, "power_off"))
2974 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2976 bypass_event = RTE_BYPASS_EVENT_NONE;
2978 if (!strcmp(res->mode_value, "bypass"))
2979 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2980 else if (!strcmp(res->mode_value, "isolate"))
2981 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2983 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2985 /* Set the watchdog timeout. */
2986 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2989 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2990 (rc = rte_eth_dev_wd_timeout_store(port_id,
2991 bypass_timeout)) != 0) {
2992 printf("Failed to set timeout value %u "
2993 "for port %d, errto code: %d.\n",
2994 bypass_timeout, port_id, rc);
2998 /* Set the bypass event to transition to bypass mode. */
2999 if (0 != rte_eth_dev_bypass_event_store(port_id,
3000 bypass_event, bypass_mode)) {
3001 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3006 cmdline_parse_token_string_t cmd_setbypass_event_set =
3007 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3009 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3010 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3012 cmdline_parse_token_string_t cmd_setbypass_event_event =
3013 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3015 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3016 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3017 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3018 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3019 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3021 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3022 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3023 mode_value, "normal#bypass#isolate");
3024 cmdline_parse_token_num_t cmd_setbypass_event_port =
3025 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3028 cmdline_parse_inst_t cmd_set_bypass_event = {
3029 .f = cmd_set_bypass_event_parsed,
3030 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3031 "mode (normal|bypass|isolate) (port_id): "
3032 "Set the NIC bypass event mode for port_id",
3035 (void *)&cmd_setbypass_event_set,
3036 (void *)&cmd_setbypass_event_bypass,
3037 (void *)&cmd_setbypass_event_event,
3038 (void *)&cmd_setbypass_event_event_value,
3039 (void *)&cmd_setbypass_event_mode,
3040 (void *)&cmd_setbypass_event_mode_value,
3041 (void *)&cmd_setbypass_event_port,
3047 /* *** SET NIC BYPASS TIMEOUT *** */
3048 struct cmd_set_bypass_timeout_result {
3049 cmdline_fixed_string_t set;
3050 cmdline_fixed_string_t bypass;
3051 cmdline_fixed_string_t timeout;
3052 cmdline_fixed_string_t value;
3056 cmd_set_bypass_timeout_parsed(void *parsed_result,
3057 __attribute__((unused)) struct cmdline *cl,
3058 __attribute__((unused)) void *data)
3060 struct cmd_set_bypass_timeout_result *res = parsed_result;
3062 if (!strcmp(res->value, "1.5"))
3063 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3064 else if (!strcmp(res->value, "2"))
3065 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3066 else if (!strcmp(res->value, "3"))
3067 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3068 else if (!strcmp(res->value, "4"))
3069 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3070 else if (!strcmp(res->value, "8"))
3071 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3072 else if (!strcmp(res->value, "16"))
3073 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3074 else if (!strcmp(res->value, "32"))
3075 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3077 bypass_timeout = RTE_BYPASS_TMT_OFF;
3080 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3081 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3083 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3084 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3086 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3087 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3088 timeout, "timeout");
3089 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3090 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3091 value, "0#1.5#2#3#4#8#16#32");
3093 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3094 .f = cmd_set_bypass_timeout_parsed,
3095 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3096 "Set the NIC bypass watchdog timeout",
3099 (void *)&cmd_setbypass_timeout_set,
3100 (void *)&cmd_setbypass_timeout_bypass,
3101 (void *)&cmd_setbypass_timeout_timeout,
3102 (void *)&cmd_setbypass_timeout_value,
3107 /* *** SHOW NIC BYPASS MODE *** */
3108 struct cmd_show_bypass_config_result {
3109 cmdline_fixed_string_t show;
3110 cmdline_fixed_string_t bypass;
3111 cmdline_fixed_string_t config;
3116 cmd_show_bypass_config_parsed(void *parsed_result,
3117 __attribute__((unused)) struct cmdline *cl,
3118 __attribute__((unused)) void *data)
3120 struct cmd_show_bypass_config_result *res = parsed_result;
3121 uint32_t event_mode;
3122 uint32_t bypass_mode;
3123 portid_t port_id = res->port_id;
3124 uint32_t timeout = bypass_timeout;
3127 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3128 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3129 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3130 {"UNKNOWN", "normal", "bypass", "isolate"};
3131 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3138 int num_events = (sizeof events) / (sizeof events[0]);
3140 if (!bypass_is_supported(port_id))
3143 /* Display the bypass mode.*/
3144 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3145 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3149 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3150 bypass_mode = RTE_BYPASS_MODE_NONE;
3152 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3155 /* Display the bypass timeout.*/
3156 if (!RTE_BYPASS_TMT_VALID(timeout))
3157 timeout = RTE_BYPASS_TMT_OFF;
3159 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3161 /* Display the bypass events and associated modes. */
3162 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3164 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3165 printf("\tFailed to get bypass mode for event = %s\n",
3168 if (!RTE_BYPASS_MODE_VALID(event_mode))
3169 event_mode = RTE_BYPASS_MODE_NONE;
3171 printf("\tbypass event: %-16s = %s\n", events[i],
3177 cmdline_parse_token_string_t cmd_showbypass_config_show =
3178 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3180 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3181 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3183 cmdline_parse_token_string_t cmd_showbypass_config_config =
3184 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3186 cmdline_parse_token_num_t cmd_showbypass_config_port =
3187 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3190 cmdline_parse_inst_t cmd_show_bypass_config = {
3191 .f = cmd_show_bypass_config_parsed,
3192 .help_str = "show bypass config (port_id): "
3193 "Show the NIC bypass config for port_id",
3196 (void *)&cmd_showbypass_config_show,
3197 (void *)&cmd_showbypass_config_bypass,
3198 (void *)&cmd_showbypass_config_config,
3199 (void *)&cmd_showbypass_config_port,
3205 #ifdef RTE_LIBRTE_PMD_BOND
3206 /* *** SET BONDING MODE *** */
3207 struct cmd_set_bonding_mode_result {
3208 cmdline_fixed_string_t set;
3209 cmdline_fixed_string_t bonding;
3210 cmdline_fixed_string_t mode;
3215 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3216 __attribute__((unused)) struct cmdline *cl,
3217 __attribute__((unused)) void *data)
3219 struct cmd_set_bonding_mode_result *res = parsed_result;
3220 portid_t port_id = res->port_id;
3222 /* Set the bonding mode for the relevant port. */
3223 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3224 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3227 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3228 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3230 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3231 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3232 bonding, "bonding");
3233 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3234 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3236 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3237 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3239 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3240 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3243 cmdline_parse_inst_t cmd_set_bonding_mode = {
3244 .f = cmd_set_bonding_mode_parsed,
3245 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3248 (void *) &cmd_setbonding_mode_set,
3249 (void *) &cmd_setbonding_mode_bonding,
3250 (void *) &cmd_setbonding_mode_mode,
3251 (void *) &cmd_setbonding_mode_value,
3252 (void *) &cmd_setbonding_mode_port,
3257 /* *** SET BALANCE XMIT POLICY *** */
3258 struct cmd_set_bonding_balance_xmit_policy_result {
3259 cmdline_fixed_string_t set;
3260 cmdline_fixed_string_t bonding;
3261 cmdline_fixed_string_t balance_xmit_policy;
3263 cmdline_fixed_string_t policy;
3266 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3267 __attribute__((unused)) struct cmdline *cl,
3268 __attribute__((unused)) void *data)
3270 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3271 portid_t port_id = res->port_id;
3274 if (!strcmp(res->policy, "l2")) {
3275 policy = BALANCE_XMIT_POLICY_LAYER2;
3276 } else if (!strcmp(res->policy, "l23")) {
3277 policy = BALANCE_XMIT_POLICY_LAYER23;
3278 } else if (!strcmp(res->policy, "l34")) {
3279 policy = BALANCE_XMIT_POLICY_LAYER34;
3281 printf("\t Invalid xmit policy selection");
3285 /* Set the bonding mode for the relevant port. */
3286 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3287 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3292 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3293 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3295 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3296 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3297 bonding, "bonding");
3298 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3299 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3300 balance_xmit_policy, "balance_xmit_policy");
3301 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3302 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3304 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3305 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3306 policy, "l2#l23#l34");
3308 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3309 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3310 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3313 (void *)&cmd_setbonding_balance_xmit_policy_set,
3314 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3315 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3316 (void *)&cmd_setbonding_balance_xmit_policy_port,
3317 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3322 /* *** SHOW NIC BONDING CONFIGURATION *** */
3323 struct cmd_show_bonding_config_result {
3324 cmdline_fixed_string_t show;
3325 cmdline_fixed_string_t bonding;
3326 cmdline_fixed_string_t config;
3330 static void cmd_show_bonding_config_parsed(void *parsed_result,
3331 __attribute__((unused)) struct cmdline *cl,
3332 __attribute__((unused)) void *data)
3334 struct cmd_show_bonding_config_result *res = parsed_result;
3336 uint8_t slaves[RTE_MAX_ETHPORTS];
3337 int num_slaves, num_active_slaves;
3340 portid_t port_id = res->port_id;
3342 /* Display the bonding mode.*/
3343 bonding_mode = rte_eth_bond_mode_get(port_id);
3344 if (bonding_mode < 0) {
3345 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3348 printf("\tBonding mode: %d\n", bonding_mode);
3350 if (bonding_mode == BONDING_MODE_BALANCE) {
3351 int balance_xmit_policy;
3353 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3354 if (balance_xmit_policy < 0) {
3355 printf("\tFailed to get balance xmit policy for port = %d\n",
3359 printf("\tBalance Xmit Policy: ");
3361 switch (balance_xmit_policy) {
3362 case BALANCE_XMIT_POLICY_LAYER2:
3363 printf("BALANCE_XMIT_POLICY_LAYER2");
3365 case BALANCE_XMIT_POLICY_LAYER23:
3366 printf("BALANCE_XMIT_POLICY_LAYER23");
3368 case BALANCE_XMIT_POLICY_LAYER34:
3369 printf("BALANCE_XMIT_POLICY_LAYER34");
3376 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3378 if (num_slaves < 0) {
3379 printf("\tFailed to get slave list for port = %d\n", port_id);
3382 if (num_slaves > 0) {
3383 printf("\tSlaves (%d): [", num_slaves);
3384 for (i = 0; i < num_slaves - 1; i++)
3385 printf("%d ", slaves[i]);
3387 printf("%d]\n", slaves[num_slaves - 1]);
3389 printf("\tSlaves: []\n");
3393 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3396 if (num_active_slaves < 0) {
3397 printf("\tFailed to get active slave list for port = %d\n", port_id);
3400 if (num_active_slaves > 0) {
3401 printf("\tActive Slaves (%d): [", num_active_slaves);
3402 for (i = 0; i < num_active_slaves - 1; i++)
3403 printf("%d ", slaves[i]);
3405 printf("%d]\n", slaves[num_active_slaves - 1]);
3408 printf("\tActive Slaves: []\n");
3412 primary_id = rte_eth_bond_primary_get(port_id);
3413 if (primary_id < 0) {
3414 printf("\tFailed to get primary slave for port = %d\n", port_id);
3417 printf("\tPrimary: [%d]\n", primary_id);
3421 cmdline_parse_token_string_t cmd_showbonding_config_show =
3422 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3424 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3425 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3426 bonding, "bonding");
3427 cmdline_parse_token_string_t cmd_showbonding_config_config =
3428 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3430 cmdline_parse_token_num_t cmd_showbonding_config_port =
3431 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3434 cmdline_parse_inst_t cmd_show_bonding_config = {
3435 .f = cmd_show_bonding_config_parsed,
3436 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3439 (void *)&cmd_showbonding_config_show,
3440 (void *)&cmd_showbonding_config_bonding,
3441 (void *)&cmd_showbonding_config_config,
3442 (void *)&cmd_showbonding_config_port,
3447 /* *** SET BONDING PRIMARY *** */
3448 struct cmd_set_bonding_primary_result {
3449 cmdline_fixed_string_t set;
3450 cmdline_fixed_string_t bonding;
3451 cmdline_fixed_string_t primary;
3456 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3457 __attribute__((unused)) struct cmdline *cl,
3458 __attribute__((unused)) void *data)
3460 struct cmd_set_bonding_primary_result *res = parsed_result;
3461 portid_t master_port_id = res->port_id;
3462 portid_t slave_port_id = res->slave_id;
3464 /* Set the primary slave for a bonded device. */
3465 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3466 printf("\t Failed to set primary slave for port = %d.\n",
3473 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3474 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3476 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3477 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3478 bonding, "bonding");
3479 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3480 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3481 primary, "primary");
3482 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3483 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3485 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3486 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3489 cmdline_parse_inst_t cmd_set_bonding_primary = {
3490 .f = cmd_set_bonding_primary_parsed,
3491 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3494 (void *)&cmd_setbonding_primary_set,
3495 (void *)&cmd_setbonding_primary_bonding,
3496 (void *)&cmd_setbonding_primary_primary,
3497 (void *)&cmd_setbonding_primary_slave,
3498 (void *)&cmd_setbonding_primary_port,
3503 /* *** ADD SLAVE *** */
3504 struct cmd_add_bonding_slave_result {
3505 cmdline_fixed_string_t add;
3506 cmdline_fixed_string_t bonding;
3507 cmdline_fixed_string_t slave;
3512 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3513 __attribute__((unused)) struct cmdline *cl,
3514 __attribute__((unused)) void *data)
3516 struct cmd_add_bonding_slave_result *res = parsed_result;
3517 portid_t master_port_id = res->port_id;
3518 portid_t slave_port_id = res->slave_id;
3520 /* Set the primary slave for a bonded device. */
3521 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3522 printf("\t Failed to add slave %d to master port = %d.\n",
3523 slave_port_id, master_port_id);
3529 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3530 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3532 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3533 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3534 bonding, "bonding");
3535 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3536 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3538 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3539 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3541 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3542 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3545 cmdline_parse_inst_t cmd_add_bonding_slave = {
3546 .f = cmd_add_bonding_slave_parsed,
3547 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3550 (void *)&cmd_addbonding_slave_add,
3551 (void *)&cmd_addbonding_slave_bonding,
3552 (void *)&cmd_addbonding_slave_slave,
3553 (void *)&cmd_addbonding_slave_slaveid,
3554 (void *)&cmd_addbonding_slave_port,
3559 /* *** REMOVE SLAVE *** */
3560 struct cmd_remove_bonding_slave_result {
3561 cmdline_fixed_string_t remove;
3562 cmdline_fixed_string_t bonding;
3563 cmdline_fixed_string_t slave;
3568 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3569 __attribute__((unused)) struct cmdline *cl,
3570 __attribute__((unused)) void *data)
3572 struct cmd_remove_bonding_slave_result *res = parsed_result;
3573 portid_t master_port_id = res->port_id;
3574 portid_t slave_port_id = res->slave_id;
3576 /* Set the primary slave for a bonded device. */
3577 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3578 printf("\t Failed to remove slave %d from master port = %d.\n",
3579 slave_port_id, master_port_id);
3585 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3586 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3588 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3589 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3590 bonding, "bonding");
3591 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3592 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3594 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3595 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3597 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3598 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3601 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3602 .f = cmd_remove_bonding_slave_parsed,
3603 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3606 (void *)&cmd_removebonding_slave_remove,
3607 (void *)&cmd_removebonding_slave_bonding,
3608 (void *)&cmd_removebonding_slave_slave,
3609 (void *)&cmd_removebonding_slave_slaveid,
3610 (void *)&cmd_removebonding_slave_port,
3615 /* *** CREATE BONDED DEVICE *** */
3616 struct cmd_create_bonded_device_result {
3617 cmdline_fixed_string_t create;
3618 cmdline_fixed_string_t bonded;
3619 cmdline_fixed_string_t device;
3624 static int bond_dev_num = 0;
3626 static void cmd_create_bonded_device_parsed(void *parsed_result,
3627 __attribute__((unused)) struct cmdline *cl,
3628 __attribute__((unused)) void *data)
3630 struct cmd_create_bonded_device_result *res = parsed_result;
3631 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3634 if (test_done == 0) {
3635 printf("Please stop forwarding first\n");
3639 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3642 /* Create a new bonded device. */
3643 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3645 printf("\t Failed to create bonded device.\n");
3648 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3651 /* Update number of ports */
3652 nb_ports = rte_eth_dev_count();
3654 rte_eth_promiscuous_enable(port_id);
3659 cmdline_parse_token_string_t cmd_createbonded_device_create =
3660 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3662 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3663 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3665 cmdline_parse_token_string_t cmd_createbonded_device_device =
3666 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3668 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3669 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3671 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3672 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3675 cmdline_parse_inst_t cmd_create_bonded_device = {
3676 .f = cmd_create_bonded_device_parsed,
3677 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3680 (void *)&cmd_createbonded_device_create,
3681 (void *)&cmd_createbonded_device_bonded,
3682 (void *)&cmd_createbonded_device_device,
3683 (void *)&cmd_createbonded_device_mode,
3684 (void *)&cmd_createbonded_device_socket,
3689 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3690 struct cmd_set_bond_mac_addr_result {
3691 cmdline_fixed_string_t set;
3692 cmdline_fixed_string_t bonding;
3693 cmdline_fixed_string_t mac_addr;
3695 struct ether_addr address;
3698 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3699 __attribute__((unused)) struct cmdline *cl,
3700 __attribute__((unused)) void *data)
3702 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3705 if (res->port_num >= nb_ports) {
3706 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3710 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3712 /* check the return value and print it if is < 0 */
3714 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3717 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3718 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3719 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3720 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3722 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3723 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3725 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3726 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3727 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3728 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3730 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3731 .f = cmd_set_bond_mac_addr_parsed,
3733 .help_str = "set bonding mac_addr (port_id) (address): ",
3735 (void *)&cmd_set_bond_mac_addr_set,
3736 (void *)&cmd_set_bond_mac_addr_bonding,
3737 (void *)&cmd_set_bond_mac_addr_mac,
3738 (void *)&cmd_set_bond_mac_addr_portnum,
3739 (void *)&cmd_set_bond_mac_addr_addr,
3745 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
3746 struct cmd_set_bond_mon_period_result {
3747 cmdline_fixed_string_t set;
3748 cmdline_fixed_string_t bonding;
3749 cmdline_fixed_string_t mon_period;
3754 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
3755 __attribute__((unused)) struct cmdline *cl,
3756 __attribute__((unused)) void *data)
3758 struct cmd_set_bond_mon_period_result *res = parsed_result;
3761 if (res->port_num >= nb_ports) {
3762 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3766 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
3768 /* check the return value and print it if is < 0 */
3770 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3773 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
3774 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3776 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
3777 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3778 bonding, "bonding");
3779 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
3780 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3781 mon_period, "mon_period");
3782 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
3783 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3785 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
3786 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3789 cmdline_parse_inst_t cmd_set_bond_mon_period = {
3790 .f = cmd_set_bond_mon_period_parsed,
3792 .help_str = "set bonding mon_period (port_id) (period_ms): ",
3794 (void *)&cmd_set_bond_mon_period_set,
3795 (void *)&cmd_set_bond_mon_period_bonding,
3796 (void *)&cmd_set_bond_mon_period_mon_period,
3797 (void *)&cmd_set_bond_mon_period_portnum,
3798 (void *)&cmd_set_bond_mon_period_period_ms,
3803 #endif /* RTE_LIBRTE_PMD_BOND */
3805 /* *** SET FORWARDING MODE *** */
3806 struct cmd_set_fwd_mode_result {
3807 cmdline_fixed_string_t set;
3808 cmdline_fixed_string_t fwd;
3809 cmdline_fixed_string_t mode;
3812 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3813 __attribute__((unused)) struct cmdline *cl,
3814 __attribute__((unused)) void *data)
3816 struct cmd_set_fwd_mode_result *res = parsed_result;
3818 set_pkt_forwarding_mode(res->mode);
3821 cmdline_parse_token_string_t cmd_setfwd_set =
3822 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3823 cmdline_parse_token_string_t cmd_setfwd_fwd =
3824 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3825 cmdline_parse_token_string_t cmd_setfwd_mode =
3826 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3827 "" /* defined at init */);
3829 cmdline_parse_inst_t cmd_set_fwd_mode = {
3830 .f = cmd_set_fwd_mode_parsed,
3832 .help_str = NULL, /* defined at init */
3834 (void *)&cmd_setfwd_set,
3835 (void *)&cmd_setfwd_fwd,
3836 (void *)&cmd_setfwd_mode,
3841 static void cmd_set_fwd_mode_init(void)
3844 static char token[128];
3845 static char help[256];
3846 cmdline_parse_token_string_t *token_struct;
3848 modes = list_pkt_forwarding_modes();
3849 snprintf(help, sizeof help, "set fwd %s - "
3850 "set packet forwarding mode", modes);
3851 cmd_set_fwd_mode.help_str = help;
3853 /* string token separator is # */
3854 for (c = token; *modes != '\0'; modes++)
3859 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3860 token_struct->string_data.str = token;
3863 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3864 struct cmd_set_burst_tx_retry_result {
3865 cmdline_fixed_string_t set;
3866 cmdline_fixed_string_t burst;
3867 cmdline_fixed_string_t tx;
3868 cmdline_fixed_string_t delay;
3870 cmdline_fixed_string_t retry;
3874 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3875 __attribute__((unused)) struct cmdline *cl,
3876 __attribute__((unused)) void *data)
3878 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3880 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3881 && !strcmp(res->tx, "tx")) {
3882 if (!strcmp(res->delay, "delay"))
3883 burst_tx_delay_time = res->time;
3884 if (!strcmp(res->retry, "retry"))
3885 burst_tx_retry_num = res->retry_num;
3890 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3891 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3892 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3893 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3895 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3896 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3897 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3898 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3899 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3900 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3901 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3902 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3903 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3904 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3906 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3907 .f = cmd_set_burst_tx_retry_parsed,
3908 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3910 (void *)&cmd_set_burst_tx_retry_set,
3911 (void *)&cmd_set_burst_tx_retry_burst,
3912 (void *)&cmd_set_burst_tx_retry_tx,
3913 (void *)&cmd_set_burst_tx_retry_delay,
3914 (void *)&cmd_set_burst_tx_retry_time,
3915 (void *)&cmd_set_burst_tx_retry_retry,
3916 (void *)&cmd_set_burst_tx_retry_retry_num,
3921 /* *** SET PROMISC MODE *** */
3922 struct cmd_set_promisc_mode_result {
3923 cmdline_fixed_string_t set;
3924 cmdline_fixed_string_t promisc;
3925 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3926 uint8_t port_num; /* valid if "allports" argument == 0 */
3927 cmdline_fixed_string_t mode;
3930 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3931 __attribute__((unused)) struct cmdline *cl,
3934 struct cmd_set_promisc_mode_result *res = parsed_result;
3938 if (!strcmp(res->mode, "on"))
3945 for (i = 0; i < nb_ports; i++) {
3947 rte_eth_promiscuous_enable(i);
3949 rte_eth_promiscuous_disable(i);
3954 rte_eth_promiscuous_enable(res->port_num);
3956 rte_eth_promiscuous_disable(res->port_num);
3960 cmdline_parse_token_string_t cmd_setpromisc_set =
3961 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3962 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3963 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3965 cmdline_parse_token_string_t cmd_setpromisc_portall =
3966 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3968 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3969 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3971 cmdline_parse_token_string_t cmd_setpromisc_mode =
3972 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3975 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3976 .f = cmd_set_promisc_mode_parsed,
3978 .help_str = "set promisc all on|off: set promisc mode for all ports",
3980 (void *)&cmd_setpromisc_set,
3981 (void *)&cmd_setpromisc_promisc,
3982 (void *)&cmd_setpromisc_portall,
3983 (void *)&cmd_setpromisc_mode,
3988 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3989 .f = cmd_set_promisc_mode_parsed,
3991 .help_str = "set promisc X on|off: set promisc mode on port X",
3993 (void *)&cmd_setpromisc_set,
3994 (void *)&cmd_setpromisc_promisc,
3995 (void *)&cmd_setpromisc_portnum,
3996 (void *)&cmd_setpromisc_mode,
4001 /* *** SET ALLMULTI MODE *** */
4002 struct cmd_set_allmulti_mode_result {
4003 cmdline_fixed_string_t set;
4004 cmdline_fixed_string_t allmulti;
4005 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4006 uint8_t port_num; /* valid if "allports" argument == 0 */
4007 cmdline_fixed_string_t mode;
4010 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4011 __attribute__((unused)) struct cmdline *cl,
4014 struct cmd_set_allmulti_mode_result *res = parsed_result;
4018 if (!strcmp(res->mode, "on"))
4025 for (i = 0; i < nb_ports; i++) {
4027 rte_eth_allmulticast_enable(i);
4029 rte_eth_allmulticast_disable(i);
4034 rte_eth_allmulticast_enable(res->port_num);
4036 rte_eth_allmulticast_disable(res->port_num);
4040 cmdline_parse_token_string_t cmd_setallmulti_set =
4041 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4042 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4043 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4045 cmdline_parse_token_string_t cmd_setallmulti_portall =
4046 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4048 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4049 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4051 cmdline_parse_token_string_t cmd_setallmulti_mode =
4052 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4055 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4056 .f = cmd_set_allmulti_mode_parsed,
4058 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4060 (void *)&cmd_setallmulti_set,
4061 (void *)&cmd_setallmulti_allmulti,
4062 (void *)&cmd_setallmulti_portall,
4063 (void *)&cmd_setallmulti_mode,
4068 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4069 .f = cmd_set_allmulti_mode_parsed,
4071 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4073 (void *)&cmd_setallmulti_set,
4074 (void *)&cmd_setallmulti_allmulti,
4075 (void *)&cmd_setallmulti_portnum,
4076 (void *)&cmd_setallmulti_mode,
4081 /* *** ADD/REMOVE A PKT FILTER *** */
4082 struct cmd_pkt_filter_result {
4083 cmdline_fixed_string_t pkt_filter;
4085 cmdline_fixed_string_t protocol;
4086 cmdline_fixed_string_t src;
4087 cmdline_ipaddr_t ip_src;
4089 cmdline_fixed_string_t dst;
4090 cmdline_ipaddr_t ip_dst;
4092 cmdline_fixed_string_t flexbytes;
4093 uint16_t flexbytes_value;
4094 cmdline_fixed_string_t vlan;
4096 cmdline_fixed_string_t queue;
4098 cmdline_fixed_string_t soft;
4103 cmd_pkt_filter_parsed(void *parsed_result,
4104 __attribute__((unused)) struct cmdline *cl,
4105 __attribute__((unused)) void *data)
4107 struct rte_fdir_filter fdir_filter;
4108 struct cmd_pkt_filter_result *res = parsed_result;
4110 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4112 if (res->ip_src.family == AF_INET)
4113 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4115 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4116 &(res->ip_src.addr.ipv6),
4117 sizeof(struct in6_addr));
4119 if (res->ip_dst.family == AF_INET)
4120 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4122 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4123 &(res->ip_dst.addr.ipv6),
4124 sizeof(struct in6_addr));
4126 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4127 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4129 if (!strcmp(res->protocol, "udp"))
4130 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4131 else if (!strcmp(res->protocol, "tcp"))
4132 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4133 else if (!strcmp(res->protocol, "sctp"))
4134 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4135 else /* default only IP */
4136 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4138 if (res->ip_dst.family == AF_INET6)
4139 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4141 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4143 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4144 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4146 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4147 fdir_add_signature_filter(res->port_id, res->queue_id,
4149 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4150 fdir_update_signature_filter(res->port_id, res->queue_id,
4152 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4153 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4154 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4155 fdir_add_perfect_filter(res->port_id, res->soft_id,
4157 (uint8_t) (res->queue_id < 0),
4159 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4160 fdir_update_perfect_filter(res->port_id, res->soft_id,
4162 (uint8_t) (res->queue_id < 0),
4164 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4165 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4171 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4172 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4174 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4175 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4176 protocol, "ip#tcp#udp#sctp");
4177 cmdline_parse_token_string_t cmd_pkt_filter_src =
4178 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4180 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4181 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4183 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4184 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4186 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4187 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4189 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4190 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4192 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4193 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4195 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4196 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4197 flexbytes, "flexbytes");
4198 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4199 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4200 flexbytes_value, UINT16);
4201 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4202 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4204 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4205 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4207 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4208 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4210 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4211 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4213 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4214 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4216 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4217 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4221 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4222 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4223 pkt_filter, "add_signature_filter");
4224 cmdline_parse_inst_t cmd_add_signature_filter = {
4225 .f = cmd_pkt_filter_parsed,
4227 .help_str = "add a signature filter",
4229 (void *)&cmd_pkt_filter_add_signature_filter,
4230 (void *)&cmd_pkt_filter_port_id,
4231 (void *)&cmd_pkt_filter_protocol,
4232 (void *)&cmd_pkt_filter_src,
4233 (void *)&cmd_pkt_filter_ip_src,
4234 (void *)&cmd_pkt_filter_port_src,
4235 (void *)&cmd_pkt_filter_dst,
4236 (void *)&cmd_pkt_filter_ip_dst,
4237 (void *)&cmd_pkt_filter_port_dst,
4238 (void *)&cmd_pkt_filter_flexbytes,
4239 (void *)&cmd_pkt_filter_flexbytes_value,
4240 (void *)&cmd_pkt_filter_vlan,
4241 (void *)&cmd_pkt_filter_vlan_id,
4242 (void *)&cmd_pkt_filter_queue,
4243 (void *)&cmd_pkt_filter_queue_id,
4249 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4250 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4251 pkt_filter, "upd_signature_filter");
4252 cmdline_parse_inst_t cmd_upd_signature_filter = {
4253 .f = cmd_pkt_filter_parsed,
4255 .help_str = "update a signature filter",
4257 (void *)&cmd_pkt_filter_upd_signature_filter,
4258 (void *)&cmd_pkt_filter_port_id,
4259 (void *)&cmd_pkt_filter_protocol,
4260 (void *)&cmd_pkt_filter_src,
4261 (void *)&cmd_pkt_filter_ip_src,
4262 (void *)&cmd_pkt_filter_port_src,
4263 (void *)&cmd_pkt_filter_dst,
4264 (void *)&cmd_pkt_filter_ip_dst,
4265 (void *)&cmd_pkt_filter_port_dst,
4266 (void *)&cmd_pkt_filter_flexbytes,
4267 (void *)&cmd_pkt_filter_flexbytes_value,
4268 (void *)&cmd_pkt_filter_vlan,
4269 (void *)&cmd_pkt_filter_vlan_id,
4270 (void *)&cmd_pkt_filter_queue,
4271 (void *)&cmd_pkt_filter_queue_id,
4277 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4278 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4279 pkt_filter, "rm_signature_filter");
4280 cmdline_parse_inst_t cmd_rm_signature_filter = {
4281 .f = cmd_pkt_filter_parsed,
4283 .help_str = "remove a signature filter",
4285 (void *)&cmd_pkt_filter_rm_signature_filter,
4286 (void *)&cmd_pkt_filter_port_id,
4287 (void *)&cmd_pkt_filter_protocol,
4288 (void *)&cmd_pkt_filter_src,
4289 (void *)&cmd_pkt_filter_ip_src,
4290 (void *)&cmd_pkt_filter_port_src,
4291 (void *)&cmd_pkt_filter_dst,
4292 (void *)&cmd_pkt_filter_ip_dst,
4293 (void *)&cmd_pkt_filter_port_dst,
4294 (void *)&cmd_pkt_filter_flexbytes,
4295 (void *)&cmd_pkt_filter_flexbytes_value,
4296 (void *)&cmd_pkt_filter_vlan,
4297 (void *)&cmd_pkt_filter_vlan_id,
4303 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4304 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4305 pkt_filter, "add_perfect_filter");
4306 cmdline_parse_inst_t cmd_add_perfect_filter = {
4307 .f = cmd_pkt_filter_parsed,
4309 .help_str = "add a perfect filter",
4311 (void *)&cmd_pkt_filter_add_perfect_filter,
4312 (void *)&cmd_pkt_filter_port_id,
4313 (void *)&cmd_pkt_filter_protocol,
4314 (void *)&cmd_pkt_filter_src,
4315 (void *)&cmd_pkt_filter_ip_src,
4316 (void *)&cmd_pkt_filter_port_src,
4317 (void *)&cmd_pkt_filter_dst,
4318 (void *)&cmd_pkt_filter_ip_dst,
4319 (void *)&cmd_pkt_filter_port_dst,
4320 (void *)&cmd_pkt_filter_flexbytes,
4321 (void *)&cmd_pkt_filter_flexbytes_value,
4322 (void *)&cmd_pkt_filter_vlan,
4323 (void *)&cmd_pkt_filter_vlan_id,
4324 (void *)&cmd_pkt_filter_queue,
4325 (void *)&cmd_pkt_filter_queue_id,
4326 (void *)&cmd_pkt_filter_soft,
4327 (void *)&cmd_pkt_filter_soft_id,
4333 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4334 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4335 pkt_filter, "upd_perfect_filter");
4336 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4337 .f = cmd_pkt_filter_parsed,
4339 .help_str = "update a perfect filter",
4341 (void *)&cmd_pkt_filter_upd_perfect_filter,
4342 (void *)&cmd_pkt_filter_port_id,
4343 (void *)&cmd_pkt_filter_protocol,
4344 (void *)&cmd_pkt_filter_src,
4345 (void *)&cmd_pkt_filter_ip_src,
4346 (void *)&cmd_pkt_filter_port_src,
4347 (void *)&cmd_pkt_filter_dst,
4348 (void *)&cmd_pkt_filter_ip_dst,
4349 (void *)&cmd_pkt_filter_port_dst,
4350 (void *)&cmd_pkt_filter_flexbytes,
4351 (void *)&cmd_pkt_filter_flexbytes_value,
4352 (void *)&cmd_pkt_filter_vlan,
4353 (void *)&cmd_pkt_filter_vlan_id,
4354 (void *)&cmd_pkt_filter_queue,
4355 (void *)&cmd_pkt_filter_queue_id,
4356 (void *)&cmd_pkt_filter_soft,
4357 (void *)&cmd_pkt_filter_soft_id,
4363 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4364 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4365 pkt_filter, "rm_perfect_filter");
4366 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4367 .f = cmd_pkt_filter_parsed,
4369 .help_str = "remove a perfect filter",
4371 (void *)&cmd_pkt_filter_rm_perfect_filter,
4372 (void *)&cmd_pkt_filter_port_id,
4373 (void *)&cmd_pkt_filter_protocol,
4374 (void *)&cmd_pkt_filter_src,
4375 (void *)&cmd_pkt_filter_ip_src,
4376 (void *)&cmd_pkt_filter_port_src,
4377 (void *)&cmd_pkt_filter_dst,
4378 (void *)&cmd_pkt_filter_ip_dst,
4379 (void *)&cmd_pkt_filter_port_dst,
4380 (void *)&cmd_pkt_filter_flexbytes,
4381 (void *)&cmd_pkt_filter_flexbytes_value,
4382 (void *)&cmd_pkt_filter_vlan,
4383 (void *)&cmd_pkt_filter_vlan_id,
4384 (void *)&cmd_pkt_filter_soft,
4385 (void *)&cmd_pkt_filter_soft_id,
4390 /* *** SETUP MASKS FILTER *** */
4391 struct cmd_pkt_filter_masks_result {
4392 cmdline_fixed_string_t filter_mask;
4394 cmdline_fixed_string_t src_mask;
4395 uint32_t ip_src_mask;
4396 uint16_t ipv6_src_mask;
4397 uint16_t port_src_mask;
4398 cmdline_fixed_string_t dst_mask;
4399 uint32_t ip_dst_mask;
4400 uint16_t ipv6_dst_mask;
4401 uint16_t port_dst_mask;
4402 cmdline_fixed_string_t flexbytes;
4403 uint8_t flexbytes_value;
4404 cmdline_fixed_string_t vlan_id;
4405 uint8_t vlan_id_value;
4406 cmdline_fixed_string_t vlan_prio;
4407 uint8_t vlan_prio_value;
4408 cmdline_fixed_string_t only_ip_flow;
4409 uint8_t only_ip_flow_value;
4410 cmdline_fixed_string_t comp_ipv6_dst;
4411 uint8_t comp_ipv6_dst_value;
4415 cmd_pkt_filter_masks_parsed(void *parsed_result,
4416 __attribute__((unused)) struct cmdline *cl,
4417 __attribute__((unused)) void *data)
4419 struct rte_fdir_masks fdir_masks;
4420 struct cmd_pkt_filter_masks_result *res = parsed_result;
4422 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4424 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4425 fdir_masks.vlan_id = res->vlan_id_value;
4426 fdir_masks.vlan_prio = res->vlan_prio_value;
4427 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4428 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4429 fdir_masks.src_port_mask = res->port_src_mask;
4430 fdir_masks.dst_port_mask = res->port_dst_mask;
4431 fdir_masks.flexbytes = res->flexbytes_value;
4433 fdir_set_masks(res->port_id, &fdir_masks);
4436 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4437 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4438 filter_mask, "set_masks_filter");
4439 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4440 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4442 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4443 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4444 only_ip_flow, "only_ip_flow");
4445 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4446 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4447 only_ip_flow_value, UINT8);
4448 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4449 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4450 src_mask, "src_mask");
4451 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4452 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4453 ip_src_mask, UINT32);
4454 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4455 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4456 port_src_mask, UINT16);
4457 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4458 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4459 dst_mask, "dst_mask");
4460 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4461 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4462 ip_dst_mask, UINT32);
4463 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4464 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4465 port_dst_mask, UINT16);
4466 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4467 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4468 flexbytes, "flexbytes");
4469 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4470 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4471 flexbytes_value, UINT8);
4472 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4473 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4474 vlan_id, "vlan_id");
4475 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4476 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4477 vlan_id_value, UINT8);
4478 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4479 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4480 vlan_prio, "vlan_prio");
4481 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4482 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4483 vlan_prio_value, UINT8);
4485 cmdline_parse_inst_t cmd_set_masks_filter = {
4486 .f = cmd_pkt_filter_masks_parsed,
4488 .help_str = "setup masks filter",
4490 (void *)&cmd_pkt_filter_masks_filter_mask,
4491 (void *)&cmd_pkt_filter_masks_port_id,
4492 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4493 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4494 (void *)&cmd_pkt_filter_masks_src_mask,
4495 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4496 (void *)&cmd_pkt_filter_masks_port_src_mask,
4497 (void *)&cmd_pkt_filter_masks_dst_mask,
4498 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4499 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4500 (void *)&cmd_pkt_filter_masks_flexbytes,
4501 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4502 (void *)&cmd_pkt_filter_masks_vlan_id,
4503 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4504 (void *)&cmd_pkt_filter_masks_vlan_prio,
4505 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4511 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4512 __attribute__((unused)) struct cmdline *cl,
4513 __attribute__((unused)) void *data)
4515 struct rte_fdir_masks fdir_masks;
4516 struct cmd_pkt_filter_masks_result *res = parsed_result;
4518 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4520 fdir_masks.set_ipv6_mask = 1;
4521 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4522 fdir_masks.vlan_id = res->vlan_id_value;
4523 fdir_masks.vlan_prio = res->vlan_prio_value;
4524 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4525 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4526 fdir_masks.src_port_mask = res->port_src_mask;
4527 fdir_masks.dst_port_mask = res->port_dst_mask;
4528 fdir_masks.flexbytes = res->flexbytes_value;
4529 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4531 fdir_set_masks(res->port_id, &fdir_masks);
4534 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4535 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4536 filter_mask, "set_ipv6_masks_filter");
4537 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4538 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4539 ipv6_src_mask, UINT16);
4540 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4541 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4542 ipv6_dst_mask, UINT16);
4544 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4545 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4546 comp_ipv6_dst, "compare_dst");
4547 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4548 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4549 comp_ipv6_dst_value, UINT8);
4551 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4552 .f = cmd_pkt_filter_masks_ipv6_parsed,
4554 .help_str = "setup ipv6 masks filter",
4556 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4557 (void *)&cmd_pkt_filter_masks_port_id,
4558 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4559 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4560 (void *)&cmd_pkt_filter_masks_src_mask,
4561 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4562 (void *)&cmd_pkt_filter_masks_port_src_mask,
4563 (void *)&cmd_pkt_filter_masks_dst_mask,
4564 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4565 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4566 (void *)&cmd_pkt_filter_masks_flexbytes,
4567 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4568 (void *)&cmd_pkt_filter_masks_vlan_id,
4569 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4570 (void *)&cmd_pkt_filter_masks_vlan_prio,
4571 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4572 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4573 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4578 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4579 struct cmd_link_flow_ctrl_set_result {
4580 cmdline_fixed_string_t set;
4581 cmdline_fixed_string_t flow_ctrl;
4582 cmdline_fixed_string_t rx;
4583 cmdline_fixed_string_t rx_lfc_mode;
4584 cmdline_fixed_string_t tx;
4585 cmdline_fixed_string_t tx_lfc_mode;
4586 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4587 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4588 cmdline_fixed_string_t autoneg_str;
4589 cmdline_fixed_string_t autoneg;
4590 cmdline_fixed_string_t hw_str;
4591 uint32_t high_water;
4592 cmdline_fixed_string_t lw_str;
4594 cmdline_fixed_string_t pt_str;
4595 uint16_t pause_time;
4596 cmdline_fixed_string_t xon_str;
4601 cmdline_parse_token_string_t cmd_lfc_set_set =
4602 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4604 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4605 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4606 flow_ctrl, "flow_ctrl");
4607 cmdline_parse_token_string_t cmd_lfc_set_rx =
4608 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4610 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4611 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4612 rx_lfc_mode, "on#off");
4613 cmdline_parse_token_string_t cmd_lfc_set_tx =
4614 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4616 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4617 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4618 tx_lfc_mode, "on#off");
4619 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4620 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4621 hw_str, "high_water");
4622 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4623 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4624 high_water, UINT32);
4625 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4626 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4627 lw_str, "low_water");
4628 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4629 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4631 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4632 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4633 pt_str, "pause_time");
4634 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4635 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4636 pause_time, UINT16);
4637 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4638 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4639 xon_str, "send_xon");
4640 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4641 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4643 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4644 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4645 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4646 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4647 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4648 mac_ctrl_frame_fwd_mode, "on#off");
4649 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4650 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4651 autoneg_str, "autoneg");
4652 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4653 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4655 cmdline_parse_token_num_t cmd_lfc_set_portid =
4656 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4659 /* forward declaration */
4661 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4664 cmdline_parse_inst_t cmd_link_flow_control_set = {
4665 .f = cmd_link_flow_ctrl_set_parsed,
4667 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4668 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4669 autoneg on|off port_id",
4671 (void *)&cmd_lfc_set_set,
4672 (void *)&cmd_lfc_set_flow_ctrl,
4673 (void *)&cmd_lfc_set_rx,
4674 (void *)&cmd_lfc_set_rx_mode,
4675 (void *)&cmd_lfc_set_tx,
4676 (void *)&cmd_lfc_set_tx_mode,
4677 (void *)&cmd_lfc_set_high_water,
4678 (void *)&cmd_lfc_set_low_water,
4679 (void *)&cmd_lfc_set_pause_time,
4680 (void *)&cmd_lfc_set_send_xon,
4681 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4682 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4683 (void *)&cmd_lfc_set_autoneg_str,
4684 (void *)&cmd_lfc_set_autoneg,
4685 (void *)&cmd_lfc_set_portid,
4690 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4691 .f = cmd_link_flow_ctrl_set_parsed,
4692 .data = (void *)&cmd_link_flow_control_set_rx,
4693 .help_str = "Change rx flow control parameter: set flow_ctrl "
4694 "rx on|off port_id",
4696 (void *)&cmd_lfc_set_set,
4697 (void *)&cmd_lfc_set_flow_ctrl,
4698 (void *)&cmd_lfc_set_rx,
4699 (void *)&cmd_lfc_set_rx_mode,
4700 (void *)&cmd_lfc_set_portid,
4705 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4706 .f = cmd_link_flow_ctrl_set_parsed,
4707 .data = (void *)&cmd_link_flow_control_set_tx,
4708 .help_str = "Change tx flow control parameter: set flow_ctrl "
4709 "tx on|off port_id",
4711 (void *)&cmd_lfc_set_set,
4712 (void *)&cmd_lfc_set_flow_ctrl,
4713 (void *)&cmd_lfc_set_tx,
4714 (void *)&cmd_lfc_set_tx_mode,
4715 (void *)&cmd_lfc_set_portid,
4720 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4721 .f = cmd_link_flow_ctrl_set_parsed,
4722 .data = (void *)&cmd_link_flow_control_set_hw,
4723 .help_str = "Change high water flow control parameter: set flow_ctrl "
4724 "high_water value port_id",
4726 (void *)&cmd_lfc_set_set,
4727 (void *)&cmd_lfc_set_flow_ctrl,
4728 (void *)&cmd_lfc_set_high_water_str,
4729 (void *)&cmd_lfc_set_high_water,
4730 (void *)&cmd_lfc_set_portid,
4735 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4736 .f = cmd_link_flow_ctrl_set_parsed,
4737 .data = (void *)&cmd_link_flow_control_set_lw,
4738 .help_str = "Change low water flow control parameter: set flow_ctrl "
4739 "low_water value port_id",
4741 (void *)&cmd_lfc_set_set,
4742 (void *)&cmd_lfc_set_flow_ctrl,
4743 (void *)&cmd_lfc_set_low_water_str,
4744 (void *)&cmd_lfc_set_low_water,
4745 (void *)&cmd_lfc_set_portid,
4750 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4751 .f = cmd_link_flow_ctrl_set_parsed,
4752 .data = (void *)&cmd_link_flow_control_set_pt,
4753 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4754 "pause_time value port_id",
4756 (void *)&cmd_lfc_set_set,
4757 (void *)&cmd_lfc_set_flow_ctrl,
4758 (void *)&cmd_lfc_set_pause_time_str,
4759 (void *)&cmd_lfc_set_pause_time,
4760 (void *)&cmd_lfc_set_portid,
4765 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4766 .f = cmd_link_flow_ctrl_set_parsed,
4767 .data = (void *)&cmd_link_flow_control_set_xon,
4768 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4769 "send_xon value port_id",
4771 (void *)&cmd_lfc_set_set,
4772 (void *)&cmd_lfc_set_flow_ctrl,
4773 (void *)&cmd_lfc_set_send_xon_str,
4774 (void *)&cmd_lfc_set_send_xon,
4775 (void *)&cmd_lfc_set_portid,
4780 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4781 .f = cmd_link_flow_ctrl_set_parsed,
4782 .data = (void *)&cmd_link_flow_control_set_macfwd,
4783 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4784 "mac_ctrl_frame_fwd on|off port_id",
4786 (void *)&cmd_lfc_set_set,
4787 (void *)&cmd_lfc_set_flow_ctrl,
4788 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4789 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4790 (void *)&cmd_lfc_set_portid,
4795 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4796 .f = cmd_link_flow_ctrl_set_parsed,
4797 .data = (void *)&cmd_link_flow_control_set_autoneg,
4798 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4799 "autoneg on|off port_id",
4801 (void *)&cmd_lfc_set_set,
4802 (void *)&cmd_lfc_set_flow_ctrl,
4803 (void *)&cmd_lfc_set_autoneg_str,
4804 (void *)&cmd_lfc_set_autoneg,
4805 (void *)&cmd_lfc_set_portid,
4811 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4812 __attribute__((unused)) struct cmdline *cl,
4815 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4816 cmdline_parse_inst_t *cmd = data;
4817 struct rte_eth_fc_conf fc_conf;
4818 int rx_fc_en, tx_fc_en;
4822 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4823 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4824 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4825 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4827 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4828 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4831 /* Partial command line, retrieve current configuration */
4833 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4835 printf("cannot get current flow ctrl parameters, return"
4836 "code = %d\n", ret);
4840 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4841 (fc_conf.mode == RTE_FC_FULL))
4843 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4844 (fc_conf.mode == RTE_FC_FULL))
4848 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4849 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4851 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4852 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4854 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4856 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4857 fc_conf.high_water = res->high_water;
4859 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4860 fc_conf.low_water = res->low_water;
4862 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4863 fc_conf.pause_time = res->pause_time;
4865 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4866 fc_conf.send_xon = res->send_xon;
4868 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4869 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4870 fc_conf.mac_ctrl_frame_fwd = 1;
4872 fc_conf.mac_ctrl_frame_fwd = 0;
4875 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4876 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4878 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4880 printf("bad flow contrl parameter, return code = %d \n", ret);
4883 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4884 struct cmd_priority_flow_ctrl_set_result {
4885 cmdline_fixed_string_t set;
4886 cmdline_fixed_string_t pfc_ctrl;
4887 cmdline_fixed_string_t rx;
4888 cmdline_fixed_string_t rx_pfc_mode;
4889 cmdline_fixed_string_t tx;
4890 cmdline_fixed_string_t tx_pfc_mode;
4891 uint32_t high_water;
4893 uint16_t pause_time;
4899 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4900 __attribute__((unused)) struct cmdline *cl,
4901 __attribute__((unused)) void *data)
4903 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4904 struct rte_eth_pfc_conf pfc_conf;
4905 int rx_fc_enable, tx_fc_enable;
4909 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4910 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4911 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4912 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4914 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4915 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4918 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4919 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4920 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4921 pfc_conf.fc.high_water = res->high_water;
4922 pfc_conf.fc.low_water = res->low_water;
4923 pfc_conf.fc.pause_time = res->pause_time;
4924 pfc_conf.priority = res->priority;
4926 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4928 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4931 cmdline_parse_token_string_t cmd_pfc_set_set =
4932 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4934 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4935 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4936 pfc_ctrl, "pfc_ctrl");
4937 cmdline_parse_token_string_t cmd_pfc_set_rx =
4938 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4940 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4941 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4942 rx_pfc_mode, "on#off");
4943 cmdline_parse_token_string_t cmd_pfc_set_tx =
4944 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4946 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4947 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4948 tx_pfc_mode, "on#off");
4949 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4950 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4951 high_water, UINT32);
4952 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4953 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4955 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4956 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4957 pause_time, UINT16);
4958 cmdline_parse_token_num_t cmd_pfc_set_priority =
4959 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4961 cmdline_parse_token_num_t cmd_pfc_set_portid =
4962 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4965 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4966 .f = cmd_priority_flow_ctrl_set_parsed,
4968 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4969 tx on|off high_water low_water pause_time priority port_id",
4971 (void *)&cmd_pfc_set_set,
4972 (void *)&cmd_pfc_set_flow_ctrl,
4973 (void *)&cmd_pfc_set_rx,
4974 (void *)&cmd_pfc_set_rx_mode,
4975 (void *)&cmd_pfc_set_tx,
4976 (void *)&cmd_pfc_set_tx_mode,
4977 (void *)&cmd_pfc_set_high_water,
4978 (void *)&cmd_pfc_set_low_water,
4979 (void *)&cmd_pfc_set_pause_time,
4980 (void *)&cmd_pfc_set_priority,
4981 (void *)&cmd_pfc_set_portid,
4986 /* *** RESET CONFIGURATION *** */
4987 struct cmd_reset_result {
4988 cmdline_fixed_string_t reset;
4989 cmdline_fixed_string_t def;
4992 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4994 __attribute__((unused)) void *data)
4996 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4997 set_def_fwd_config();
5000 cmdline_parse_token_string_t cmd_reset_set =
5001 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5002 cmdline_parse_token_string_t cmd_reset_def =
5003 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5006 cmdline_parse_inst_t cmd_reset = {
5007 .f = cmd_reset_parsed,
5009 .help_str = "set default: reset default forwarding configuration",
5011 (void *)&cmd_reset_set,
5012 (void *)&cmd_reset_def,
5017 /* *** START FORWARDING *** */
5018 struct cmd_start_result {
5019 cmdline_fixed_string_t start;
5022 cmdline_parse_token_string_t cmd_start_start =
5023 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5025 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5026 __attribute__((unused)) struct cmdline *cl,
5027 __attribute__((unused)) void *data)
5029 start_packet_forwarding(0);
5032 cmdline_parse_inst_t cmd_start = {
5033 .f = cmd_start_parsed,
5035 .help_str = "start packet forwarding",
5037 (void *)&cmd_start_start,
5042 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5043 struct cmd_start_tx_first_result {
5044 cmdline_fixed_string_t start;
5045 cmdline_fixed_string_t tx_first;
5049 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5050 __attribute__((unused)) struct cmdline *cl,
5051 __attribute__((unused)) void *data)
5053 start_packet_forwarding(1);
5056 cmdline_parse_token_string_t cmd_start_tx_first_start =
5057 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5059 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5060 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5061 tx_first, "tx_first");
5063 cmdline_parse_inst_t cmd_start_tx_first = {
5064 .f = cmd_start_tx_first_parsed,
5066 .help_str = "start packet forwarding, after sending 1 burst of packets",
5068 (void *)&cmd_start_tx_first_start,
5069 (void *)&cmd_start_tx_first_tx_first,
5074 /* *** SET LINK UP *** */
5075 struct cmd_set_link_up_result {
5076 cmdline_fixed_string_t set;
5077 cmdline_fixed_string_t link_up;
5078 cmdline_fixed_string_t port;
5082 cmdline_parse_token_string_t cmd_set_link_up_set =
5083 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5084 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5085 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5087 cmdline_parse_token_string_t cmd_set_link_up_port =
5088 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5089 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5090 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5092 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5093 __attribute__((unused)) struct cmdline *cl,
5094 __attribute__((unused)) void *data)
5096 struct cmd_set_link_up_result *res = parsed_result;
5097 dev_set_link_up(res->port_id);
5100 cmdline_parse_inst_t cmd_set_link_up = {
5101 .f = cmd_set_link_up_parsed,
5103 .help_str = "set link-up port (port id)",
5105 (void *)&cmd_set_link_up_set,
5106 (void *)&cmd_set_link_up_link_up,
5107 (void *)&cmd_set_link_up_port,
5108 (void *)&cmd_set_link_up_port_id,
5113 /* *** SET LINK DOWN *** */
5114 struct cmd_set_link_down_result {
5115 cmdline_fixed_string_t set;
5116 cmdline_fixed_string_t link_down;
5117 cmdline_fixed_string_t port;
5121 cmdline_parse_token_string_t cmd_set_link_down_set =
5122 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5123 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5124 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5126 cmdline_parse_token_string_t cmd_set_link_down_port =
5127 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5128 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5129 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5131 static void cmd_set_link_down_parsed(
5132 __attribute__((unused)) void *parsed_result,
5133 __attribute__((unused)) struct cmdline *cl,
5134 __attribute__((unused)) void *data)
5136 struct cmd_set_link_down_result *res = parsed_result;
5137 dev_set_link_down(res->port_id);
5140 cmdline_parse_inst_t cmd_set_link_down = {
5141 .f = cmd_set_link_down_parsed,
5143 .help_str = "set link-down port (port id)",
5145 (void *)&cmd_set_link_down_set,
5146 (void *)&cmd_set_link_down_link_down,
5147 (void *)&cmd_set_link_down_port,
5148 (void *)&cmd_set_link_down_port_id,
5153 /* *** SHOW CFG *** */
5154 struct cmd_showcfg_result {
5155 cmdline_fixed_string_t show;
5156 cmdline_fixed_string_t cfg;
5157 cmdline_fixed_string_t what;
5160 static void cmd_showcfg_parsed(void *parsed_result,
5161 __attribute__((unused)) struct cmdline *cl,
5162 __attribute__((unused)) void *data)
5164 struct cmd_showcfg_result *res = parsed_result;
5165 if (!strcmp(res->what, "rxtx"))
5166 rxtx_config_display();
5167 else if (!strcmp(res->what, "cores"))
5168 fwd_lcores_config_display();
5169 else if (!strcmp(res->what, "fwd"))
5170 fwd_config_display();
5173 cmdline_parse_token_string_t cmd_showcfg_show =
5174 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5175 cmdline_parse_token_string_t cmd_showcfg_port =
5176 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5177 cmdline_parse_token_string_t cmd_showcfg_what =
5178 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5181 cmdline_parse_inst_t cmd_showcfg = {
5182 .f = cmd_showcfg_parsed,
5184 .help_str = "show config rxtx|cores|fwd",
5186 (void *)&cmd_showcfg_show,
5187 (void *)&cmd_showcfg_port,
5188 (void *)&cmd_showcfg_what,
5193 /* *** SHOW ALL PORT INFO *** */
5194 struct cmd_showportall_result {
5195 cmdline_fixed_string_t show;
5196 cmdline_fixed_string_t port;
5197 cmdline_fixed_string_t what;
5198 cmdline_fixed_string_t all;
5201 static void cmd_showportall_parsed(void *parsed_result,
5202 __attribute__((unused)) struct cmdline *cl,
5203 __attribute__((unused)) void *data)
5207 struct cmd_showportall_result *res = parsed_result;
5208 if (!strcmp(res->show, "clear")) {
5209 if (!strcmp(res->what, "stats"))
5210 for (i = 0; i < nb_ports; i++)
5212 else if (!strcmp(res->what, "xstats"))
5213 for (i = 0; i < nb_ports; i++)
5214 nic_xstats_clear(i);
5215 } else if (!strcmp(res->what, "info"))
5216 for (i = 0; i < nb_ports; i++)
5217 port_infos_display(i);
5218 else if (!strcmp(res->what, "stats"))
5219 for (i = 0; i < nb_ports; i++)
5220 nic_stats_display(i);
5221 else if (!strcmp(res->what, "xstats"))
5222 for (i = 0; i < nb_ports; i++)
5223 nic_xstats_display(i);
5224 else if (!strcmp(res->what, "fdir"))
5225 for (i = 0; i < nb_ports; i++)
5227 else if (!strcmp(res->what, "stat_qmap"))
5228 for (i = 0; i < nb_ports; i++)
5229 nic_stats_mapping_display(i);
5232 cmdline_parse_token_string_t cmd_showportall_show =
5233 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5235 cmdline_parse_token_string_t cmd_showportall_port =
5236 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5237 cmdline_parse_token_string_t cmd_showportall_what =
5238 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5239 "info#stats#xstats#fdir#stat_qmap");
5240 cmdline_parse_token_string_t cmd_showportall_all =
5241 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5242 cmdline_parse_inst_t cmd_showportall = {
5243 .f = cmd_showportall_parsed,
5245 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5247 (void *)&cmd_showportall_show,
5248 (void *)&cmd_showportall_port,
5249 (void *)&cmd_showportall_what,
5250 (void *)&cmd_showportall_all,
5255 /* *** SHOW PORT INFO *** */
5256 struct cmd_showport_result {
5257 cmdline_fixed_string_t show;
5258 cmdline_fixed_string_t port;
5259 cmdline_fixed_string_t what;
5263 static void cmd_showport_parsed(void *parsed_result,
5264 __attribute__((unused)) struct cmdline *cl,
5265 __attribute__((unused)) void *data)
5267 struct cmd_showport_result *res = parsed_result;
5268 if (!strcmp(res->show, "clear")) {
5269 if (!strcmp(res->what, "stats"))
5270 nic_stats_clear(res->portnum);
5271 else if (!strcmp(res->what, "xstats"))
5272 nic_xstats_clear(res->portnum);
5273 } else if (!strcmp(res->what, "info"))
5274 port_infos_display(res->portnum);
5275 else if (!strcmp(res->what, "stats"))
5276 nic_stats_display(res->portnum);
5277 else if (!strcmp(res->what, "xstats"))
5278 nic_xstats_display(res->portnum);
5279 else if (!strcmp(res->what, "fdir"))
5280 fdir_get_infos(res->portnum);
5281 else if (!strcmp(res->what, "stat_qmap"))
5282 nic_stats_mapping_display(res->portnum);
5285 cmdline_parse_token_string_t cmd_showport_show =
5286 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5288 cmdline_parse_token_string_t cmd_showport_port =
5289 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5290 cmdline_parse_token_string_t cmd_showport_what =
5291 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5292 "info#stats#xstats#fdir#stat_qmap");
5293 cmdline_parse_token_num_t cmd_showport_portnum =
5294 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5296 cmdline_parse_inst_t cmd_showport = {
5297 .f = cmd_showport_parsed,
5299 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5301 (void *)&cmd_showport_show,
5302 (void *)&cmd_showport_port,
5303 (void *)&cmd_showport_what,
5304 (void *)&cmd_showport_portnum,
5309 /* *** READ PORT REGISTER *** */
5310 struct cmd_read_reg_result {
5311 cmdline_fixed_string_t read;
5312 cmdline_fixed_string_t reg;
5318 cmd_read_reg_parsed(void *parsed_result,
5319 __attribute__((unused)) struct cmdline *cl,
5320 __attribute__((unused)) void *data)
5322 struct cmd_read_reg_result *res = parsed_result;
5323 port_reg_display(res->port_id, res->reg_off);
5326 cmdline_parse_token_string_t cmd_read_reg_read =
5327 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5328 cmdline_parse_token_string_t cmd_read_reg_reg =
5329 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5330 cmdline_parse_token_num_t cmd_read_reg_port_id =
5331 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5332 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5333 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5335 cmdline_parse_inst_t cmd_read_reg = {
5336 .f = cmd_read_reg_parsed,
5338 .help_str = "read reg port_id reg_off",
5340 (void *)&cmd_read_reg_read,
5341 (void *)&cmd_read_reg_reg,
5342 (void *)&cmd_read_reg_port_id,
5343 (void *)&cmd_read_reg_reg_off,
5348 /* *** READ PORT REGISTER BIT FIELD *** */
5349 struct cmd_read_reg_bit_field_result {
5350 cmdline_fixed_string_t read;
5351 cmdline_fixed_string_t regfield;
5359 cmd_read_reg_bit_field_parsed(void *parsed_result,
5360 __attribute__((unused)) struct cmdline *cl,
5361 __attribute__((unused)) void *data)
5363 struct cmd_read_reg_bit_field_result *res = parsed_result;
5364 port_reg_bit_field_display(res->port_id, res->reg_off,
5365 res->bit1_pos, res->bit2_pos);
5368 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5369 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5371 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5372 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5373 regfield, "regfield");
5374 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5375 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5377 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5378 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5380 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5381 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5383 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5384 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5387 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5388 .f = cmd_read_reg_bit_field_parsed,
5390 .help_str = "read regfield port_id reg_off bit_x bit_y "
5391 "(read register bit field between bit_x and bit_y included)",
5393 (void *)&cmd_read_reg_bit_field_read,
5394 (void *)&cmd_read_reg_bit_field_regfield,
5395 (void *)&cmd_read_reg_bit_field_port_id,
5396 (void *)&cmd_read_reg_bit_field_reg_off,
5397 (void *)&cmd_read_reg_bit_field_bit1_pos,
5398 (void *)&cmd_read_reg_bit_field_bit2_pos,
5403 /* *** READ PORT REGISTER BIT *** */
5404 struct cmd_read_reg_bit_result {
5405 cmdline_fixed_string_t read;
5406 cmdline_fixed_string_t regbit;
5413 cmd_read_reg_bit_parsed(void *parsed_result,
5414 __attribute__((unused)) struct cmdline *cl,
5415 __attribute__((unused)) void *data)
5417 struct cmd_read_reg_bit_result *res = parsed_result;
5418 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5421 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5422 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5423 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5424 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5426 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5427 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5428 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5429 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5430 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5431 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5433 cmdline_parse_inst_t cmd_read_reg_bit = {
5434 .f = cmd_read_reg_bit_parsed,
5436 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5438 (void *)&cmd_read_reg_bit_read,
5439 (void *)&cmd_read_reg_bit_regbit,
5440 (void *)&cmd_read_reg_bit_port_id,
5441 (void *)&cmd_read_reg_bit_reg_off,
5442 (void *)&cmd_read_reg_bit_bit_pos,
5447 /* *** WRITE PORT REGISTER *** */
5448 struct cmd_write_reg_result {
5449 cmdline_fixed_string_t write;
5450 cmdline_fixed_string_t reg;
5457 cmd_write_reg_parsed(void *parsed_result,
5458 __attribute__((unused)) struct cmdline *cl,
5459 __attribute__((unused)) void *data)
5461 struct cmd_write_reg_result *res = parsed_result;
5462 port_reg_set(res->port_id, res->reg_off, res->value);
5465 cmdline_parse_token_string_t cmd_write_reg_write =
5466 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5467 cmdline_parse_token_string_t cmd_write_reg_reg =
5468 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5469 cmdline_parse_token_num_t cmd_write_reg_port_id =
5470 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5471 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5472 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5473 cmdline_parse_token_num_t cmd_write_reg_value =
5474 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5476 cmdline_parse_inst_t cmd_write_reg = {
5477 .f = cmd_write_reg_parsed,
5479 .help_str = "write reg port_id reg_off reg_value",
5481 (void *)&cmd_write_reg_write,
5482 (void *)&cmd_write_reg_reg,
5483 (void *)&cmd_write_reg_port_id,
5484 (void *)&cmd_write_reg_reg_off,
5485 (void *)&cmd_write_reg_value,
5490 /* *** WRITE PORT REGISTER BIT FIELD *** */
5491 struct cmd_write_reg_bit_field_result {
5492 cmdline_fixed_string_t write;
5493 cmdline_fixed_string_t regfield;
5502 cmd_write_reg_bit_field_parsed(void *parsed_result,
5503 __attribute__((unused)) struct cmdline *cl,
5504 __attribute__((unused)) void *data)
5506 struct cmd_write_reg_bit_field_result *res = parsed_result;
5507 port_reg_bit_field_set(res->port_id, res->reg_off,
5508 res->bit1_pos, res->bit2_pos, res->value);
5511 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5512 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5514 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5515 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5516 regfield, "regfield");
5517 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5518 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5520 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5521 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5523 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5524 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5526 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5527 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5529 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5530 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5533 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5534 .f = cmd_write_reg_bit_field_parsed,
5536 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5537 "(set register bit field between bit_x and bit_y included)",
5539 (void *)&cmd_write_reg_bit_field_write,
5540 (void *)&cmd_write_reg_bit_field_regfield,
5541 (void *)&cmd_write_reg_bit_field_port_id,
5542 (void *)&cmd_write_reg_bit_field_reg_off,
5543 (void *)&cmd_write_reg_bit_field_bit1_pos,
5544 (void *)&cmd_write_reg_bit_field_bit2_pos,
5545 (void *)&cmd_write_reg_bit_field_value,
5550 /* *** WRITE PORT REGISTER BIT *** */
5551 struct cmd_write_reg_bit_result {
5552 cmdline_fixed_string_t write;
5553 cmdline_fixed_string_t regbit;
5561 cmd_write_reg_bit_parsed(void *parsed_result,
5562 __attribute__((unused)) struct cmdline *cl,
5563 __attribute__((unused)) void *data)
5565 struct cmd_write_reg_bit_result *res = parsed_result;
5566 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5569 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5570 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5572 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5573 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5575 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5576 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5577 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5578 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5579 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5580 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5581 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5582 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5584 cmdline_parse_inst_t cmd_write_reg_bit = {
5585 .f = cmd_write_reg_bit_parsed,
5587 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5589 (void *)&cmd_write_reg_bit_write,
5590 (void *)&cmd_write_reg_bit_regbit,
5591 (void *)&cmd_write_reg_bit_port_id,
5592 (void *)&cmd_write_reg_bit_reg_off,
5593 (void *)&cmd_write_reg_bit_bit_pos,
5594 (void *)&cmd_write_reg_bit_value,
5599 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5600 struct cmd_read_rxd_txd_result {
5601 cmdline_fixed_string_t read;
5602 cmdline_fixed_string_t rxd_txd;
5609 cmd_read_rxd_txd_parsed(void *parsed_result,
5610 __attribute__((unused)) struct cmdline *cl,
5611 __attribute__((unused)) void *data)
5613 struct cmd_read_rxd_txd_result *res = parsed_result;
5615 if (!strcmp(res->rxd_txd, "rxd"))
5616 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5617 else if (!strcmp(res->rxd_txd, "txd"))
5618 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5621 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5622 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5623 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5624 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5626 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5627 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5628 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5629 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5630 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5631 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5633 cmdline_parse_inst_t cmd_read_rxd_txd = {
5634 .f = cmd_read_rxd_txd_parsed,
5636 .help_str = "read rxd|txd port_id queue_id rxd_id",
5638 (void *)&cmd_read_rxd_txd_read,
5639 (void *)&cmd_read_rxd_txd_rxd_txd,
5640 (void *)&cmd_read_rxd_txd_port_id,
5641 (void *)&cmd_read_rxd_txd_queue_id,
5642 (void *)&cmd_read_rxd_txd_desc_id,
5648 struct cmd_quit_result {
5649 cmdline_fixed_string_t quit;
5652 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5654 __attribute__((unused)) void *data)
5660 cmdline_parse_token_string_t cmd_quit_quit =
5661 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5663 cmdline_parse_inst_t cmd_quit = {
5664 .f = cmd_quit_parsed,
5666 .help_str = "exit application",
5668 (void *)&cmd_quit_quit,
5673 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5674 struct cmd_mac_addr_result {
5675 cmdline_fixed_string_t mac_addr_cmd;
5676 cmdline_fixed_string_t what;
5678 struct ether_addr address;
5681 static void cmd_mac_addr_parsed(void *parsed_result,
5682 __attribute__((unused)) struct cmdline *cl,
5683 __attribute__((unused)) void *data)
5685 struct cmd_mac_addr_result *res = parsed_result;
5688 if (strcmp(res->what, "add") == 0)
5689 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5691 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5693 /* check the return value and print it if is < 0 */
5695 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5699 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5700 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5702 cmdline_parse_token_string_t cmd_mac_addr_what =
5703 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5705 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5706 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5707 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5708 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5710 cmdline_parse_inst_t cmd_mac_addr = {
5711 .f = cmd_mac_addr_parsed,
5713 .help_str = "mac_addr add|remove X <address>: "
5714 "add/remove MAC address on port X",
5716 (void *)&cmd_mac_addr_cmd,
5717 (void *)&cmd_mac_addr_what,
5718 (void *)&cmd_mac_addr_portnum,
5719 (void *)&cmd_mac_addr_addr,
5725 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5726 struct cmd_set_qmap_result {
5727 cmdline_fixed_string_t set;
5728 cmdline_fixed_string_t qmap;
5729 cmdline_fixed_string_t what;
5736 cmd_set_qmap_parsed(void *parsed_result,
5737 __attribute__((unused)) struct cmdline *cl,
5738 __attribute__((unused)) void *data)
5740 struct cmd_set_qmap_result *res = parsed_result;
5741 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5743 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5746 cmdline_parse_token_string_t cmd_setqmap_set =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5749 cmdline_parse_token_string_t cmd_setqmap_qmap =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5752 cmdline_parse_token_string_t cmd_setqmap_what =
5753 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5755 cmdline_parse_token_num_t cmd_setqmap_portid =
5756 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5758 cmdline_parse_token_num_t cmd_setqmap_queueid =
5759 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5761 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5762 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5765 cmdline_parse_inst_t cmd_set_qmap = {
5766 .f = cmd_set_qmap_parsed,
5768 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5770 (void *)&cmd_setqmap_set,
5771 (void *)&cmd_setqmap_qmap,
5772 (void *)&cmd_setqmap_what,
5773 (void *)&cmd_setqmap_portid,
5774 (void *)&cmd_setqmap_queueid,
5775 (void *)&cmd_setqmap_mapvalue,
5780 /* *** CONFIGURE UNICAST HASH TABLE *** */
5781 struct cmd_set_uc_hash_table {
5782 cmdline_fixed_string_t set;
5783 cmdline_fixed_string_t port;
5785 cmdline_fixed_string_t what;
5786 struct ether_addr address;
5787 cmdline_fixed_string_t mode;
5791 cmd_set_uc_hash_parsed(void *parsed_result,
5792 __attribute__((unused)) struct cmdline *cl,
5793 __attribute__((unused)) void *data)
5796 struct cmd_set_uc_hash_table *res = parsed_result;
5798 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5800 if (strcmp(res->what, "uta") == 0)
5801 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5802 &res->address,(uint8_t)is_on);
5804 printf("bad unicast hash table parameter, return code = %d \n", ret);
5808 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5809 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5811 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5812 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5814 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5815 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5817 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5818 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5820 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5821 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5823 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5824 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5827 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5828 .f = cmd_set_uc_hash_parsed,
5830 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5832 (void *)&cmd_set_uc_hash_set,
5833 (void *)&cmd_set_uc_hash_port,
5834 (void *)&cmd_set_uc_hash_portid,
5835 (void *)&cmd_set_uc_hash_what,
5836 (void *)&cmd_set_uc_hash_mac,
5837 (void *)&cmd_set_uc_hash_mode,
5842 struct cmd_set_uc_all_hash_table {
5843 cmdline_fixed_string_t set;
5844 cmdline_fixed_string_t port;
5846 cmdline_fixed_string_t what;
5847 cmdline_fixed_string_t value;
5848 cmdline_fixed_string_t mode;
5852 cmd_set_uc_all_hash_parsed(void *parsed_result,
5853 __attribute__((unused)) struct cmdline *cl,
5854 __attribute__((unused)) void *data)
5857 struct cmd_set_uc_all_hash_table *res = parsed_result;
5859 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5861 if ((strcmp(res->what, "uta") == 0) &&
5862 (strcmp(res->value, "all") == 0))
5863 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5865 printf("bad unicast hash table parameter,"
5866 "return code = %d \n", ret);
5869 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5870 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5872 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5873 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5875 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5876 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5878 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5879 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5881 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5882 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5884 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5885 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5888 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5889 .f = cmd_set_uc_all_hash_parsed,
5891 .help_str = "set port X uta all on|off (X = port number)",
5893 (void *)&cmd_set_uc_all_hash_set,
5894 (void *)&cmd_set_uc_all_hash_port,
5895 (void *)&cmd_set_uc_all_hash_portid,
5896 (void *)&cmd_set_uc_all_hash_what,
5897 (void *)&cmd_set_uc_all_hash_value,
5898 (void *)&cmd_set_uc_all_hash_mode,
5903 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5904 struct cmd_set_vf_macvlan_filter {
5905 cmdline_fixed_string_t set;
5906 cmdline_fixed_string_t port;
5908 cmdline_fixed_string_t vf;
5910 struct ether_addr address;
5911 cmdline_fixed_string_t filter_type;
5912 cmdline_fixed_string_t mode;
5916 cmd_set_vf_macvlan_parsed(void *parsed_result,
5917 __attribute__((unused)) struct cmdline *cl,
5918 __attribute__((unused)) void *data)
5921 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5922 struct rte_eth_mac_filter filter;
5924 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5926 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5928 /* set VF MAC filter */
5932 filter.dst_id = res->vf_id;
5934 if (!strcmp(res->filter_type, "exact-mac"))
5935 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5936 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5937 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5938 else if (!strcmp(res->filter_type, "hashmac"))
5939 filter.filter_type = RTE_MAC_HASH_MATCH;
5940 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5941 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5943 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5946 ret = rte_eth_dev_filter_ctrl(res->port_id,
5947 RTE_ETH_FILTER_MACVLAN,
5951 ret = rte_eth_dev_filter_ctrl(res->port_id,
5952 RTE_ETH_FILTER_MACVLAN,
5953 RTE_ETH_FILTER_DELETE,
5957 printf("bad set MAC hash parameter, return code = %d\n", ret);
5961 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5962 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5964 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5965 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5967 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5968 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5970 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5971 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5973 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5974 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5976 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5977 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5979 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5980 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5981 filter_type, "exact-mac#exact-mac-vlan"
5982 "#hashmac#hashmac-vlan");
5983 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5984 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5987 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5988 .f = cmd_set_vf_macvlan_parsed,
5990 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5991 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5993 "exact match rule:exact match of MAC or MAC and VLAN; "
5994 "hash match rule: hash match of MAC and exact match "
5997 (void *)&cmd_set_vf_macvlan_set,
5998 (void *)&cmd_set_vf_macvlan_port,
5999 (void *)&cmd_set_vf_macvlan_portid,
6000 (void *)&cmd_set_vf_macvlan_vf,
6001 (void *)&cmd_set_vf_macvlan_vf_id,
6002 (void *)&cmd_set_vf_macvlan_mac,
6003 (void *)&cmd_set_vf_macvlan_filter_type,
6004 (void *)&cmd_set_vf_macvlan_mode,
6009 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6010 struct cmd_set_vf_traffic {
6011 cmdline_fixed_string_t set;
6012 cmdline_fixed_string_t port;
6014 cmdline_fixed_string_t vf;
6016 cmdline_fixed_string_t what;
6017 cmdline_fixed_string_t mode;
6021 cmd_set_vf_traffic_parsed(void *parsed_result,
6022 __attribute__((unused)) struct cmdline *cl,
6023 __attribute__((unused)) void *data)
6025 struct cmd_set_vf_traffic *res = parsed_result;
6026 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6027 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6029 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6032 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6033 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6035 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6036 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6038 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6039 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6041 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6042 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6044 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6045 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6047 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6048 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6050 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6051 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6054 cmdline_parse_inst_t cmd_set_vf_traffic = {
6055 .f = cmd_set_vf_traffic_parsed,
6057 .help_str = "set port X vf Y rx|tx on|off"
6058 "(X = port number,Y = vf id)",
6060 (void *)&cmd_setvf_traffic_set,
6061 (void *)&cmd_setvf_traffic_port,
6062 (void *)&cmd_setvf_traffic_portid,
6063 (void *)&cmd_setvf_traffic_vf,
6064 (void *)&cmd_setvf_traffic_vfid,
6065 (void *)&cmd_setvf_traffic_what,
6066 (void *)&cmd_setvf_traffic_mode,
6071 /* *** CONFIGURE VF RECEIVE MODE *** */
6072 struct cmd_set_vf_rxmode {
6073 cmdline_fixed_string_t set;
6074 cmdline_fixed_string_t port;
6076 cmdline_fixed_string_t vf;
6078 cmdline_fixed_string_t what;
6079 cmdline_fixed_string_t mode;
6080 cmdline_fixed_string_t on;
6084 cmd_set_vf_rxmode_parsed(void *parsed_result,
6085 __attribute__((unused)) struct cmdline *cl,
6086 __attribute__((unused)) void *data)
6089 uint16_t rx_mode = 0;
6090 struct cmd_set_vf_rxmode *res = parsed_result;
6092 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6093 if (!strcmp(res->what,"rxmode")) {
6094 if (!strcmp(res->mode, "AUPE"))
6095 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6096 else if (!strcmp(res->mode, "ROPE"))
6097 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6098 else if (!strcmp(res->mode, "BAM"))
6099 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6100 else if (!strncmp(res->mode, "MPE",3))
6101 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6104 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6106 printf("bad VF receive mode parameter, return code = %d \n",
6110 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6111 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6113 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6114 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6116 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6117 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6119 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6120 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6122 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6123 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6125 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6126 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6128 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6129 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6130 mode, "AUPE#ROPE#BAM#MPE");
6131 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6132 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6135 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6136 .f = cmd_set_vf_rxmode_parsed,
6138 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6140 (void *)&cmd_set_vf_rxmode_set,
6141 (void *)&cmd_set_vf_rxmode_port,
6142 (void *)&cmd_set_vf_rxmode_portid,
6143 (void *)&cmd_set_vf_rxmode_vf,
6144 (void *)&cmd_set_vf_rxmode_vfid,
6145 (void *)&cmd_set_vf_rxmode_what,
6146 (void *)&cmd_set_vf_rxmode_mode,
6147 (void *)&cmd_set_vf_rxmode_on,
6152 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6153 struct cmd_vf_mac_addr_result {
6154 cmdline_fixed_string_t mac_addr_cmd;
6155 cmdline_fixed_string_t what;
6156 cmdline_fixed_string_t port;
6158 cmdline_fixed_string_t vf;
6160 struct ether_addr address;
6163 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6164 __attribute__((unused)) struct cmdline *cl,
6165 __attribute__((unused)) void *data)
6167 struct cmd_vf_mac_addr_result *res = parsed_result;
6170 if (strcmp(res->what, "add") == 0)
6171 ret = rte_eth_dev_mac_addr_add(res->port_num,
6172 &res->address, res->vf_num);
6174 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6178 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6179 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6180 mac_addr_cmd,"mac_addr");
6181 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6182 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6184 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6185 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6187 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6188 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6190 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6191 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6193 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6194 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6196 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6197 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6200 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6201 .f = cmd_vf_mac_addr_parsed,
6203 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6204 "Y = VF number)add MAC address filtering for a VF on port X",
6206 (void *)&cmd_vf_mac_addr_cmd,
6207 (void *)&cmd_vf_mac_addr_what,
6208 (void *)&cmd_vf_mac_addr_port,
6209 (void *)&cmd_vf_mac_addr_portnum,
6210 (void *)&cmd_vf_mac_addr_vf,
6211 (void *)&cmd_vf_mac_addr_vfnum,
6212 (void *)&cmd_vf_mac_addr_addr,
6217 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6218 struct cmd_vf_rx_vlan_filter {
6219 cmdline_fixed_string_t rx_vlan;
6220 cmdline_fixed_string_t what;
6222 cmdline_fixed_string_t port;
6224 cmdline_fixed_string_t vf;
6229 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6230 __attribute__((unused)) struct cmdline *cl,
6231 __attribute__((unused)) void *data)
6233 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6235 if (!strcmp(res->what, "add"))
6236 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6238 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6241 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6242 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6243 rx_vlan, "rx_vlan");
6244 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6245 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6247 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6248 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6250 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6251 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6253 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6254 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6256 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6257 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6259 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6260 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6263 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6264 .f = cmd_vf_rx_vlan_filter_parsed,
6266 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6267 "Y = port number,Z = hexadecimal VF mask)",
6269 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6270 (void *)&cmd_vf_rx_vlan_filter_what,
6271 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6272 (void *)&cmd_vf_rx_vlan_filter_port,
6273 (void *)&cmd_vf_rx_vlan_filter_portid,
6274 (void *)&cmd_vf_rx_vlan_filter_vf,
6275 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6280 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6281 struct cmd_queue_rate_limit_result {
6282 cmdline_fixed_string_t set;
6283 cmdline_fixed_string_t port;
6285 cmdline_fixed_string_t queue;
6287 cmdline_fixed_string_t rate;
6291 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6292 __attribute__((unused)) struct cmdline *cl,
6293 __attribute__((unused)) void *data)
6295 struct cmd_queue_rate_limit_result *res = parsed_result;
6298 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6299 && (strcmp(res->queue, "queue") == 0)
6300 && (strcmp(res->rate, "rate") == 0))
6301 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6304 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6308 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6309 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6311 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6312 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6314 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6315 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6317 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6318 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6320 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6321 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6323 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6324 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6326 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6327 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6330 cmdline_parse_inst_t cmd_queue_rate_limit = {
6331 .f = cmd_queue_rate_limit_parsed,
6333 .help_str = "set port X queue Y rate Z:(X = port number,"
6334 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6336 (void *)&cmd_queue_rate_limit_set,
6337 (void *)&cmd_queue_rate_limit_port,
6338 (void *)&cmd_queue_rate_limit_portnum,
6339 (void *)&cmd_queue_rate_limit_queue,
6340 (void *)&cmd_queue_rate_limit_queuenum,
6341 (void *)&cmd_queue_rate_limit_rate,
6342 (void *)&cmd_queue_rate_limit_ratenum,
6347 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6348 struct cmd_vf_rate_limit_result {
6349 cmdline_fixed_string_t set;
6350 cmdline_fixed_string_t port;
6352 cmdline_fixed_string_t vf;
6354 cmdline_fixed_string_t rate;
6356 cmdline_fixed_string_t q_msk;
6360 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6361 __attribute__((unused)) struct cmdline *cl,
6362 __attribute__((unused)) void *data)
6364 struct cmd_vf_rate_limit_result *res = parsed_result;
6367 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6368 && (strcmp(res->vf, "vf") == 0)
6369 && (strcmp(res->rate, "rate") == 0)
6370 && (strcmp(res->q_msk, "queue_mask") == 0))
6371 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6372 res->rate_num, res->q_msk_val);
6374 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6378 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6379 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6381 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6382 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6384 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6385 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6387 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6388 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6390 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6391 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6393 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6394 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6396 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6397 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6399 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6400 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6401 q_msk, "queue_mask");
6402 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6403 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6406 cmdline_parse_inst_t cmd_vf_rate_limit = {
6407 .f = cmd_vf_rate_limit_parsed,
6409 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6410 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6411 "for queues of VF on port X",
6413 (void *)&cmd_vf_rate_limit_set,
6414 (void *)&cmd_vf_rate_limit_port,
6415 (void *)&cmd_vf_rate_limit_portnum,
6416 (void *)&cmd_vf_rate_limit_vf,
6417 (void *)&cmd_vf_rate_limit_vfnum,
6418 (void *)&cmd_vf_rate_limit_rate,
6419 (void *)&cmd_vf_rate_limit_ratenum,
6420 (void *)&cmd_vf_rate_limit_q_msk,
6421 (void *)&cmd_vf_rate_limit_q_msk_val,
6426 /* *** ADD TUNNEL FILTER OF A PORT *** */
6427 struct cmd_tunnel_filter_result {
6428 cmdline_fixed_string_t cmd;
6429 cmdline_fixed_string_t what;
6431 struct ether_addr outer_mac;
6432 struct ether_addr inner_mac;
6433 cmdline_ipaddr_t ip_value;
6434 uint16_t inner_vlan;
6435 cmdline_fixed_string_t tunnel_type;
6436 cmdline_fixed_string_t filter_type;
6442 cmd_tunnel_filter_parsed(void *parsed_result,
6443 __attribute__((unused)) struct cmdline *cl,
6444 __attribute__((unused)) void *data)
6446 struct cmd_tunnel_filter_result *res = parsed_result;
6447 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6450 tunnel_filter_conf.outer_mac = &res->outer_mac;
6451 tunnel_filter_conf.inner_mac = &res->inner_mac;
6452 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6454 if (res->ip_value.family == AF_INET) {
6455 tunnel_filter_conf.ip_addr.ipv4_addr =
6456 res->ip_value.addr.ipv4.s_addr;
6457 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6459 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6460 &(res->ip_value.addr.ipv6),
6461 sizeof(struct in6_addr));
6462 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6465 if (!strcmp(res->filter_type, "imac-ivlan"))
6466 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6467 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6468 tunnel_filter_conf.filter_type =
6469 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6470 else if (!strcmp(res->filter_type, "imac-tenid"))
6471 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6472 else if (!strcmp(res->filter_type, "imac"))
6473 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6474 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6475 tunnel_filter_conf.filter_type =
6476 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6478 printf("The filter type is not supported");
6482 if (!strcmp(res->tunnel_type, "vxlan"))
6483 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6485 printf("Only VXLAN is supported now.\n");
6489 tunnel_filter_conf.tenant_id = res->tenant_id;
6490 tunnel_filter_conf.queue_id = res->queue_num;
6491 if (!strcmp(res->what, "add"))
6492 ret = rte_eth_dev_filter_ctrl(res->port_id,
6493 RTE_ETH_FILTER_TUNNEL,
6495 &tunnel_filter_conf);
6497 ret = rte_eth_dev_filter_ctrl(res->port_id,
6498 RTE_ETH_FILTER_TUNNEL,
6499 RTE_ETH_FILTER_DELETE,
6500 &tunnel_filter_conf);
6502 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6506 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6507 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6508 cmd, "tunnel_filter");
6509 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6510 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6512 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6513 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6515 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6516 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6518 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6519 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6521 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6522 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6523 inner_vlan, UINT16);
6524 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6525 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6527 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6528 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6529 tunnel_type, "vxlan");
6531 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6532 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6533 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6534 "imac#omac-imac-tenid");
6535 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6536 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6538 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6539 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6542 cmdline_parse_inst_t cmd_tunnel_filter = {
6543 .f = cmd_tunnel_filter_parsed,
6545 .help_str = "add/rm tunnel filter of a port: "
6546 "tunnel_filter add port_id outer_mac inner_mac ip "
6547 "inner_vlan tunnel_type(vxlan) filter_type "
6548 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6549 "imac|omac-imac-tenid) "
6550 "tenant_id queue_num",
6552 (void *)&cmd_tunnel_filter_cmd,
6553 (void *)&cmd_tunnel_filter_what,
6554 (void *)&cmd_tunnel_filter_port_id,
6555 (void *)&cmd_tunnel_filter_outer_mac,
6556 (void *)&cmd_tunnel_filter_inner_mac,
6557 (void *)&cmd_tunnel_filter_ip_value,
6558 (void *)&cmd_tunnel_filter_innner_vlan,
6559 (void *)&cmd_tunnel_filter_tunnel_type,
6560 (void *)&cmd_tunnel_filter_filter_type,
6561 (void *)&cmd_tunnel_filter_tenant_id,
6562 (void *)&cmd_tunnel_filter_queue_num,
6567 /* *** CONFIGURE TUNNEL UDP PORT *** */
6568 struct cmd_tunnel_udp_config {
6569 cmdline_fixed_string_t cmd;
6570 cmdline_fixed_string_t what;
6576 cmd_tunnel_udp_config_parsed(void *parsed_result,
6577 __attribute__((unused)) struct cmdline *cl,
6578 __attribute__((unused)) void *data)
6580 struct cmd_tunnel_udp_config *res = parsed_result;
6581 struct rte_eth_udp_tunnel tunnel_udp;
6584 tunnel_udp.udp_port = res->udp_port;
6586 if (!strcmp(res->cmd, "rx_vxlan_port"))
6587 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6589 if (!strcmp(res->what, "add"))
6590 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6592 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6595 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6598 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6599 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6600 cmd, "rx_vxlan_port");
6601 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6602 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6604 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6605 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6607 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6608 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6611 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6612 .f = cmd_tunnel_udp_config_parsed,
6614 .help_str = "add/rm an tunneling UDP port filter: "
6615 "rx_vxlan_port add udp_port port_id",
6617 (void *)&cmd_tunnel_udp_config_cmd,
6618 (void *)&cmd_tunnel_udp_config_what,
6619 (void *)&cmd_tunnel_udp_config_udp_port,
6620 (void *)&cmd_tunnel_udp_config_port_id,
6625 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6626 struct cmd_set_mirror_mask_result {
6627 cmdline_fixed_string_t set;
6628 cmdline_fixed_string_t port;
6630 cmdline_fixed_string_t mirror;
6632 cmdline_fixed_string_t what;
6633 cmdline_fixed_string_t value;
6634 cmdline_fixed_string_t dstpool;
6636 cmdline_fixed_string_t on;
6639 cmdline_parse_token_string_t cmd_mirror_mask_set =
6640 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6642 cmdline_parse_token_string_t cmd_mirror_mask_port =
6643 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6645 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6646 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6648 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6649 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6650 mirror, "mirror-rule");
6651 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6652 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6654 cmdline_parse_token_string_t cmd_mirror_mask_what =
6655 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6656 what, "pool-mirror#vlan-mirror");
6657 cmdline_parse_token_string_t cmd_mirror_mask_value =
6658 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6660 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6661 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6662 dstpool, "dst-pool");
6663 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6664 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6666 cmdline_parse_token_string_t cmd_mirror_mask_on =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6671 cmd_set_mirror_mask_parsed(void *parsed_result,
6672 __attribute__((unused)) struct cmdline *cl,
6673 __attribute__((unused)) void *data)
6676 struct cmd_set_mirror_mask_result *res = parsed_result;
6677 struct rte_eth_vmdq_mirror_conf mr_conf;
6679 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6681 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6683 mr_conf.dst_pool = res->dstpool_id;
6685 if (!strcmp(res->what, "pool-mirror")) {
6686 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6687 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6688 } else if(!strcmp(res->what, "vlan-mirror")) {
6689 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6690 nb_item = parse_item_list(res->value, "core",
6691 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6695 for(i=0; i < nb_item; i++) {
6696 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6697 printf("Invalid vlan_id: must be < 4096\n");
6701 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6702 mr_conf.vlan.vlan_mask |= 1ULL << i;
6706 if(!strcmp(res->on, "on"))
6707 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6710 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6713 printf("mirror rule add error: (%s)\n", strerror(-ret));
6716 cmdline_parse_inst_t cmd_set_mirror_mask = {
6717 .f = cmd_set_mirror_mask_parsed,
6719 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6720 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6722 (void *)&cmd_mirror_mask_set,
6723 (void *)&cmd_mirror_mask_port,
6724 (void *)&cmd_mirror_mask_portid,
6725 (void *)&cmd_mirror_mask_mirror,
6726 (void *)&cmd_mirror_mask_ruleid,
6727 (void *)&cmd_mirror_mask_what,
6728 (void *)&cmd_mirror_mask_value,
6729 (void *)&cmd_mirror_mask_dstpool,
6730 (void *)&cmd_mirror_mask_poolid,
6731 (void *)&cmd_mirror_mask_on,
6736 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6737 struct cmd_set_mirror_link_result {
6738 cmdline_fixed_string_t set;
6739 cmdline_fixed_string_t port;
6741 cmdline_fixed_string_t mirror;
6743 cmdline_fixed_string_t what;
6744 cmdline_fixed_string_t dstpool;
6746 cmdline_fixed_string_t on;
6749 cmdline_parse_token_string_t cmd_mirror_link_set =
6750 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6752 cmdline_parse_token_string_t cmd_mirror_link_port =
6753 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6755 cmdline_parse_token_num_t cmd_mirror_link_portid =
6756 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6758 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6759 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6760 mirror, "mirror-rule");
6761 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6762 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6764 cmdline_parse_token_string_t cmd_mirror_link_what =
6765 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6766 what, "uplink-mirror#downlink-mirror");
6767 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6768 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6769 dstpool, "dst-pool");
6770 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6771 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6773 cmdline_parse_token_string_t cmd_mirror_link_on =
6774 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6778 cmd_set_mirror_link_parsed(void *parsed_result,
6779 __attribute__((unused)) struct cmdline *cl,
6780 __attribute__((unused)) void *data)
6783 struct cmd_set_mirror_link_result *res = parsed_result;
6784 struct rte_eth_vmdq_mirror_conf mr_conf;
6786 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6787 if(!strcmp(res->what, "uplink-mirror")) {
6788 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6789 }else if(!strcmp(res->what, "downlink-mirror"))
6790 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6792 mr_conf.dst_pool = res->dstpool_id;
6794 if(!strcmp(res->on, "on"))
6795 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6798 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6801 /* check the return value and print it if is < 0 */
6803 printf("mirror rule add error: (%s)\n", strerror(-ret));
6807 cmdline_parse_inst_t cmd_set_mirror_link = {
6808 .f = cmd_set_mirror_link_parsed,
6810 .help_str = "set port X mirror-rule Y uplink-mirror|"
6811 "downlink-mirror dst-pool Z on|off",
6813 (void *)&cmd_mirror_link_set,
6814 (void *)&cmd_mirror_link_port,
6815 (void *)&cmd_mirror_link_portid,
6816 (void *)&cmd_mirror_link_mirror,
6817 (void *)&cmd_mirror_link_ruleid,
6818 (void *)&cmd_mirror_link_what,
6819 (void *)&cmd_mirror_link_dstpool,
6820 (void *)&cmd_mirror_link_poolid,
6821 (void *)&cmd_mirror_link_on,
6826 /* *** RESET VM MIRROR RULE *** */
6827 struct cmd_rm_mirror_rule_result {
6828 cmdline_fixed_string_t reset;
6829 cmdline_fixed_string_t port;
6831 cmdline_fixed_string_t mirror;
6835 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6836 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6838 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6839 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6841 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6842 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6844 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6845 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6846 mirror, "mirror-rule");
6847 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6848 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6852 cmd_reset_mirror_rule_parsed(void *parsed_result,
6853 __attribute__((unused)) struct cmdline *cl,
6854 __attribute__((unused)) void *data)
6857 struct cmd_set_mirror_link_result *res = parsed_result;
6859 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6861 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6864 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6865 .f = cmd_reset_mirror_rule_parsed,
6867 .help_str = "reset port X mirror-rule Y",
6869 (void *)&cmd_rm_mirror_rule_reset,
6870 (void *)&cmd_rm_mirror_rule_port,
6871 (void *)&cmd_rm_mirror_rule_portid,
6872 (void *)&cmd_rm_mirror_rule_mirror,
6873 (void *)&cmd_rm_mirror_rule_ruleid,
6878 /* ******************************************************************************** */
6880 struct cmd_dump_result {
6881 cmdline_fixed_string_t dump;
6885 dump_struct_sizes(void)
6887 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6888 DUMP_SIZE(struct rte_mbuf);
6889 DUMP_SIZE(struct rte_mempool);
6890 DUMP_SIZE(struct rte_ring);
6894 static void cmd_dump_parsed(void *parsed_result,
6895 __attribute__((unused)) struct cmdline *cl,
6896 __attribute__((unused)) void *data)
6898 struct cmd_dump_result *res = parsed_result;
6900 if (!strcmp(res->dump, "dump_physmem"))
6901 rte_dump_physmem_layout(stdout);
6902 else if (!strcmp(res->dump, "dump_memzone"))
6903 rte_memzone_dump(stdout);
6904 else if (!strcmp(res->dump, "dump_log_history"))
6905 rte_log_dump_history(stdout);
6906 else if (!strcmp(res->dump, "dump_struct_sizes"))
6907 dump_struct_sizes();
6908 else if (!strcmp(res->dump, "dump_ring"))
6909 rte_ring_list_dump(stdout);
6910 else if (!strcmp(res->dump, "dump_mempool"))
6911 rte_mempool_list_dump(stdout);
6912 else if (!strcmp(res->dump, "dump_devargs"))
6913 rte_eal_devargs_dump(stdout);
6916 cmdline_parse_token_string_t cmd_dump_dump =
6917 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6921 "dump_struct_sizes#"
6926 cmdline_parse_inst_t cmd_dump = {
6927 .f = cmd_dump_parsed, /* function to call */
6928 .data = NULL, /* 2nd arg of func */
6929 .help_str = "dump status",
6930 .tokens = { /* token list, NULL terminated */
6931 (void *)&cmd_dump_dump,
6936 /* ******************************************************************************** */
6938 struct cmd_dump_one_result {
6939 cmdline_fixed_string_t dump;
6940 cmdline_fixed_string_t name;
6943 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6944 __attribute__((unused)) void *data)
6946 struct cmd_dump_one_result *res = parsed_result;
6948 if (!strcmp(res->dump, "dump_ring")) {
6950 r = rte_ring_lookup(res->name);
6952 cmdline_printf(cl, "Cannot find ring\n");
6955 rte_ring_dump(stdout, r);
6956 } else if (!strcmp(res->dump, "dump_mempool")) {
6957 struct rte_mempool *mp;
6958 mp = rte_mempool_lookup(res->name);
6960 cmdline_printf(cl, "Cannot find mempool\n");
6963 rte_mempool_dump(stdout, mp);
6967 cmdline_parse_token_string_t cmd_dump_one_dump =
6968 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6969 "dump_ring#dump_mempool");
6971 cmdline_parse_token_string_t cmd_dump_one_name =
6972 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6974 cmdline_parse_inst_t cmd_dump_one = {
6975 .f = cmd_dump_one_parsed, /* function to call */
6976 .data = NULL, /* 2nd arg of func */
6977 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6978 .tokens = { /* token list, NULL terminated */
6979 (void *)&cmd_dump_one_dump,
6980 (void *)&cmd_dump_one_name,
6985 /* *** ADD/REMOVE an ethertype FILTER *** */
6986 struct cmd_ethertype_filter_result {
6987 cmdline_fixed_string_t filter;
6989 cmdline_fixed_string_t ethertype;
6990 uint16_t ethertype_value;
6991 cmdline_fixed_string_t priority;
6992 cmdline_fixed_string_t priority_en;
6993 uint8_t priority_value;
6994 cmdline_fixed_string_t queue;
6996 cmdline_fixed_string_t index;
6997 uint16_t index_value;
7001 cmd_ethertype_filter_parsed(void *parsed_result,
7002 __attribute__((unused)) struct cmdline *cl,
7003 __attribute__((unused)) void *data)
7006 struct cmd_ethertype_filter_result *res = parsed_result;
7007 struct rte_ethertype_filter filter;
7009 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
7010 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
7011 filter.priority = res->priority_value;
7013 if (!strcmp(res->priority_en, "enable"))
7014 filter.priority_en = 1;
7015 if (!strcmp(res->filter, "add_ethertype_filter"))
7016 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
7018 &filter, res->queue_id);
7019 else if (!strcmp(res->filter, "remove_ethertype_filter"))
7020 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
7022 else if (!strcmp(res->filter, "get_ethertype_filter"))
7023 get_ethertype_filter(res->port_id, res->index_value);
7026 printf("ethertype filter setting error: (%s)\n",
7030 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7031 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7033 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7034 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7035 ethertype, "ethertype");
7036 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
7037 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7038 ethertype_value, UINT16);
7039 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
7040 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7041 priority, "priority");
7042 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
7043 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7044 priority_en, "enable#disable");
7045 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
7046 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7047 priority_value, UINT8);
7048 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7049 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7051 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7052 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7054 cmdline_parse_token_string_t cmd_ethertype_filter_index =
7055 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7057 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
7058 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7059 index_value, UINT16);
7060 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
7061 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7062 filter, "add_ethertype_filter");
7063 cmdline_parse_inst_t cmd_add_ethertype_filter = {
7064 .f = cmd_ethertype_filter_parsed,
7066 .help_str = "add an ethertype filter",
7068 (void *)&cmd_ethertype_filter_add_filter,
7069 (void *)&cmd_ethertype_filter_port_id,
7070 (void *)&cmd_ethertype_filter_ethertype,
7071 (void *)&cmd_ethertype_filter_ethertype_value,
7072 (void *)&cmd_ethertype_filter_priority,
7073 (void *)&cmd_ethertype_filter_priority_en,
7074 (void *)&cmd_ethertype_filter_priority_value,
7075 (void *)&cmd_ethertype_filter_queue,
7076 (void *)&cmd_ethertype_filter_queue_id,
7077 (void *)&cmd_ethertype_filter_index,
7078 (void *)&cmd_ethertype_filter_index_value,
7083 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
7084 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7085 filter, "remove_ethertype_filter");
7086 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
7087 .f = cmd_ethertype_filter_parsed,
7089 .help_str = "remove an ethertype filter",
7091 (void *)&cmd_ethertype_filter_remove_filter,
7092 (void *)&cmd_ethertype_filter_port_id,
7093 (void *)&cmd_ethertype_filter_index,
7094 (void *)&cmd_ethertype_filter_index_value,
7098 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
7099 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7100 filter, "get_ethertype_filter");
7101 cmdline_parse_inst_t cmd_get_ethertype_filter = {
7102 .f = cmd_ethertype_filter_parsed,
7104 .help_str = "get an ethertype filter",
7106 (void *)&cmd_ethertype_filter_get_filter,
7107 (void *)&cmd_ethertype_filter_port_id,
7108 (void *)&cmd_ethertype_filter_index,
7109 (void *)&cmd_ethertype_filter_index_value,
7114 /* *** set SYN filter *** */
7115 struct cmd_set_syn_filter_result {
7116 cmdline_fixed_string_t filter;
7118 cmdline_fixed_string_t priority;
7119 cmdline_fixed_string_t high;
7120 cmdline_fixed_string_t queue;
7125 cmd_set_syn_filter_parsed(void *parsed_result,
7126 __attribute__((unused)) struct cmdline *cl,
7127 __attribute__((unused)) void *data)
7130 struct cmd_set_syn_filter_result *res = parsed_result;
7131 struct rte_syn_filter filter;
7133 if (!strcmp(res->filter, "add_syn_filter")) {
7134 if (!strcmp(res->high, "high"))
7138 ret = rte_eth_dev_add_syn_filter(res->port_id,
7139 &filter, res->queue_id);
7140 } else if (!strcmp(res->filter, "remove_syn_filter"))
7141 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7142 else if (!strcmp(res->filter, "get_syn_filter"))
7143 get_syn_filter(res->port_id);
7145 printf("syn filter setting error: (%s)\n", strerror(-ret));
7148 cmdline_parse_token_num_t cmd_syn_filter_portid =
7149 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7151 cmdline_parse_token_string_t cmd_syn_filter_priority =
7152 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7153 priority, "priority");
7154 cmdline_parse_token_string_t cmd_syn_filter_high =
7155 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7157 cmdline_parse_token_string_t cmd_syn_filter_queue =
7158 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7160 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7161 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7163 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7164 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7165 filter, "add_syn_filter");
7166 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7167 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7168 filter, "remove_syn_filter");
7169 cmdline_parse_inst_t cmd_add_syn_filter = {
7170 .f = cmd_set_syn_filter_parsed,
7172 .help_str = "add syn filter",
7174 (void *)&cmd_syn_filter_add_filter,
7175 (void *)&cmd_syn_filter_portid,
7176 (void *)&cmd_syn_filter_priority,
7177 (void *)&cmd_syn_filter_high,
7178 (void *)&cmd_syn_filter_queue,
7179 (void *)&cmd_syn_filter_queue_id,
7183 cmdline_parse_inst_t cmd_remove_syn_filter = {
7184 .f = cmd_set_syn_filter_parsed,
7186 .help_str = "remove syn filter",
7188 (void *)&cmd_syn_filter_remove_filter,
7189 (void *)&cmd_syn_filter_portid,
7194 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7195 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7196 filter, "get_syn_filter");
7198 cmdline_parse_inst_t cmd_get_syn_filter = {
7199 .f = cmd_set_syn_filter_parsed,
7201 .help_str = "get syn filter",
7203 (void *)&cmd_syn_filter_get_filter,
7204 (void *)&cmd_syn_filter_portid,
7209 /* *** ADD/REMOVE A 2tuple FILTER *** */
7210 struct cmd_2tuple_filter_result {
7211 cmdline_fixed_string_t filter;
7213 cmdline_fixed_string_t protocol;
7214 uint8_t protocol_value;
7215 uint8_t protocol_mask;
7216 cmdline_fixed_string_t dst_port;
7217 uint16_t dst_port_value;
7218 uint16_t dst_port_mask;
7219 cmdline_fixed_string_t flags;
7220 uint8_t flags_value;
7221 cmdline_fixed_string_t priority;
7222 uint8_t priority_value;
7223 cmdline_fixed_string_t queue;
7225 cmdline_fixed_string_t index;
7226 uint16_t index_value;
7230 cmd_2tuple_filter_parsed(void *parsed_result,
7231 __attribute__((unused)) struct cmdline *cl,
7232 __attribute__((unused)) void *data)
7235 struct rte_2tuple_filter filter;
7236 struct cmd_2tuple_filter_result *res = parsed_result;
7238 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7240 if (!strcmp(res->filter, "add_2tuple_filter")) {
7241 /* need convert to big endian. */
7242 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7243 filter.protocol = res->protocol_value;
7244 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7245 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7246 filter.priority = res->priority_value;
7247 filter.tcp_flags = res->flags_value;
7248 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7249 res->index_value, &filter, res->queue_id);
7250 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7251 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7253 else if (!strcmp(res->filter, "get_2tuple_filter"))
7254 get_2tuple_filter(res->port_id, res->index_value);
7257 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7260 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7261 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7263 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7264 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7265 protocol, "protocol");
7266 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7267 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7268 protocol_value, UINT8);
7269 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7270 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7271 protocol_mask, UINT8);
7272 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7273 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7274 dst_port, "dst_port");
7275 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7276 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7277 dst_port_value, UINT16);
7278 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7279 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7280 dst_port_mask, UINT16);
7281 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7282 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7284 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7285 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7286 flags_value, UINT8);
7287 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7288 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7289 priority, "priority");
7290 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7291 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7292 priority_value, UINT8);
7293 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7294 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7296 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7297 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7299 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7300 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7302 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7303 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7304 index_value, UINT16);
7305 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7306 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7307 filter, "add_2tuple_filter");
7308 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7309 .f = cmd_2tuple_filter_parsed,
7311 .help_str = "add a 2tuple filter",
7313 (void *)&cmd_2tuple_filter_add_filter,
7314 (void *)&cmd_2tuple_filter_port_id,
7315 (void *)&cmd_2tuple_filter_protocol,
7316 (void *)&cmd_2tuple_filter_protocol_value,
7317 (void *)&cmd_2tuple_filter_protocol_mask,
7318 (void *)&cmd_2tuple_filter_dst_port,
7319 (void *)&cmd_2tuple_filter_dst_port_value,
7320 (void *)&cmd_2tuple_filter_dst_port_mask,
7321 (void *)&cmd_2tuple_filter_flags,
7322 (void *)&cmd_2tuple_filter_flags_value,
7323 (void *)&cmd_2tuple_filter_priority,
7324 (void *)&cmd_2tuple_filter_priority_value,
7325 (void *)&cmd_2tuple_filter_queue,
7326 (void *)&cmd_2tuple_filter_queue_id,
7327 (void *)&cmd_2tuple_filter_index,
7328 (void *)&cmd_2tuple_filter_index_value,
7333 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7334 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7335 filter, "remove_2tuple_filter");
7336 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7337 .f = cmd_2tuple_filter_parsed,
7339 .help_str = "remove a 2tuple filter",
7341 (void *)&cmd_2tuple_filter_remove_filter,
7342 (void *)&cmd_2tuple_filter_port_id,
7343 (void *)&cmd_2tuple_filter_index,
7344 (void *)&cmd_2tuple_filter_index_value,
7348 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7349 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7350 filter, "get_2tuple_filter");
7351 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7352 .f = cmd_2tuple_filter_parsed,
7354 .help_str = "get a 2tuple filter",
7356 (void *)&cmd_2tuple_filter_get_filter,
7357 (void *)&cmd_2tuple_filter_port_id,
7358 (void *)&cmd_2tuple_filter_index,
7359 (void *)&cmd_2tuple_filter_index_value,
7364 /* *** ADD/REMOVE A 5tuple FILTER *** */
7365 struct cmd_5tuple_filter_result {
7366 cmdline_fixed_string_t filter;
7368 cmdline_fixed_string_t dst_ip;
7369 cmdline_ipaddr_t dst_ip_value;
7370 cmdline_fixed_string_t src_ip;
7371 cmdline_ipaddr_t src_ip_value;
7372 cmdline_fixed_string_t dst_port;
7373 uint16_t dst_port_value;
7374 cmdline_fixed_string_t src_port;
7375 uint16_t src_port_value;
7376 cmdline_fixed_string_t protocol;
7377 uint8_t protocol_value;
7378 cmdline_fixed_string_t mask;
7380 cmdline_fixed_string_t flags;
7381 uint8_t flags_value;
7382 cmdline_fixed_string_t priority;
7383 uint8_t priority_value;
7384 cmdline_fixed_string_t queue;
7386 cmdline_fixed_string_t index;
7387 uint16_t index_value;
7391 cmd_5tuple_filter_parsed(void *parsed_result,
7392 __attribute__((unused)) struct cmdline *cl,
7393 __attribute__((unused)) void *data)
7396 struct rte_5tuple_filter filter;
7397 struct cmd_5tuple_filter_result *res = parsed_result;
7399 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7401 if (!strcmp(res->filter, "add_5tuple_filter")) {
7402 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7403 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7404 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7405 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7406 filter.protocol = res->protocol_value;
7407 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7408 filter.priority = res->priority_value;
7409 filter.tcp_flags = res->flags_value;
7411 if (res->dst_ip_value.family == AF_INET)
7412 /* no need to convert, already big endian. */
7413 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7415 if (filter.dst_ip_mask == 0) {
7416 printf("can not support ipv6 involved compare.\n");
7422 if (res->src_ip_value.family == AF_INET)
7423 /* no need to convert, already big endian. */
7424 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7426 if (filter.src_ip_mask == 0) {
7427 printf("can not support ipv6 involved compare.\n");
7432 /* need convert to big endian. */
7433 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7434 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7436 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7437 res->index_value, &filter, res->queue_id);
7438 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7439 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7441 else if (!strcmp(res->filter, "get_5tuple_filter"))
7442 get_5tuple_filter(res->port_id, res->index_value);
7444 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7448 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7449 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7451 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7452 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7454 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7455 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7457 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7458 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7460 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7461 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7463 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7464 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7465 dst_port, "dst_port");
7466 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7467 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7468 dst_port_value, UINT16);
7469 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7470 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7471 src_port, "src_port");
7472 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7473 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7474 src_port_value, UINT16);
7475 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7476 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7477 protocol, "protocol");
7478 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7479 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7480 protocol_value, UINT8);
7481 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7482 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7484 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7485 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7487 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7488 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7490 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7491 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7492 flags_value, UINT8);
7493 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7494 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7495 priority, "priority");
7496 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7497 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7498 priority_value, UINT8);
7499 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7500 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7502 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7503 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7505 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7506 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7508 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7509 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7510 index_value, UINT16);
7512 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7513 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7514 filter, "add_5tuple_filter");
7515 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7516 .f = cmd_5tuple_filter_parsed,
7518 .help_str = "add a 5tuple filter",
7520 (void *)&cmd_5tuple_filter_add_filter,
7521 (void *)&cmd_5tuple_filter_port_id,
7522 (void *)&cmd_5tuple_filter_dst_ip,
7523 (void *)&cmd_5tuple_filter_dst_ip_value,
7524 (void *)&cmd_5tuple_filter_src_ip,
7525 (void *)&cmd_5tuple_filter_src_ip_value,
7526 (void *)&cmd_5tuple_filter_dst_port,
7527 (void *)&cmd_5tuple_filter_dst_port_value,
7528 (void *)&cmd_5tuple_filter_src_port,
7529 (void *)&cmd_5tuple_filter_src_port_value,
7530 (void *)&cmd_5tuple_filter_protocol,
7531 (void *)&cmd_5tuple_filter_protocol_value,
7532 (void *)&cmd_5tuple_filter_mask,
7533 (void *)&cmd_5tuple_filter_mask_value,
7534 (void *)&cmd_5tuple_filter_flags,
7535 (void *)&cmd_5tuple_filter_flags_value,
7536 (void *)&cmd_5tuple_filter_priority,
7537 (void *)&cmd_5tuple_filter_priority_value,
7538 (void *)&cmd_5tuple_filter_queue,
7539 (void *)&cmd_5tuple_filter_queue_id,
7540 (void *)&cmd_5tuple_filter_index,
7541 (void *)&cmd_5tuple_filter_index_value,
7546 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7547 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7548 filter, "remove_5tuple_filter");
7549 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7550 .f = cmd_5tuple_filter_parsed,
7552 .help_str = "remove a 5tuple filter",
7554 (void *)&cmd_5tuple_filter_remove_filter,
7555 (void *)&cmd_5tuple_filter_port_id,
7556 (void *)&cmd_5tuple_filter_index,
7557 (void *)&cmd_5tuple_filter_index_value,
7562 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7563 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7564 filter, "get_5tuple_filter");
7565 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7566 .f = cmd_5tuple_filter_parsed,
7568 .help_str = "get a 5tuple filter",
7570 (void *)&cmd_5tuple_filter_get_filter,
7571 (void *)&cmd_5tuple_filter_port_id,
7572 (void *)&cmd_5tuple_filter_index,
7573 (void *)&cmd_5tuple_filter_index_value,
7578 /* *** ADD/REMOVE A flex FILTER *** */
7579 struct cmd_flex_filter_result {
7580 cmdline_fixed_string_t filter;
7582 cmdline_fixed_string_t len;
7584 cmdline_fixed_string_t bytes;
7585 cmdline_fixed_string_t bytes_value;
7586 cmdline_fixed_string_t mask;
7587 cmdline_fixed_string_t mask_value;
7588 cmdline_fixed_string_t priority;
7589 uint8_t priority_value;
7590 cmdline_fixed_string_t queue;
7592 cmdline_fixed_string_t index;
7593 uint16_t index_value;
7596 static int xdigit2val(unsigned char c)
7601 else if (isupper(c))
7609 cmd_flex_filter_parsed(void *parsed_result,
7610 __attribute__((unused)) struct cmdline *cl,
7611 __attribute__((unused)) void *data)
7614 struct rte_flex_filter filter;
7615 struct cmd_flex_filter_result *res = parsed_result;
7616 char *bytes_ptr, *mask_ptr;
7624 if (!strcmp(res->filter, "add_flex_filter")) {
7625 if (res->len_value > 128) {
7626 printf("the len exceed the max length 128\n");
7629 memset(&filter, 0, sizeof(struct rte_flex_filter));
7630 filter.len = res->len_value;
7631 filter.priority = res->priority_value;
7632 bytes_ptr = res->bytes_value;
7633 mask_ptr = res->mask_value;
7636 /* translate bytes string to uint_32 array. */
7637 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7638 (bytes_ptr[1] == 'X')))
7640 len = strnlen(bytes_ptr, res->len_value * 2);
7641 if (len == 0 || (len % 8 != 0)) {
7642 printf("please check len and bytes input\n");
7645 for (i = 0; i < len; i++) {
7647 if (isxdigit(c) == 0) {
7648 /* invalid characters. */
7649 printf("invalid input\n");
7652 val = xdigit2val(c);
7656 dword |= byte << (4 * mod - 4);
7661 filter.dwords[j] = dword;
7662 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7668 /* translate mask string to uint8_t array. */
7670 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7671 (mask_ptr[1] == 'X')))
7673 len = strnlen(mask_ptr, (res->len_value+3)/4);
7675 printf("invalid input\n");
7678 for (i = 0; i < len; i++) {
7680 if (isxdigit(c) == 0) {
7681 /* invalid characters. */
7682 printf("invalid input\n");
7685 val = xdigit2val(c);
7686 hex |= (uint8_t)(val & 0x8) >> 3;
7687 hex |= (uint8_t)(val & 0x4) >> 1;
7688 hex |= (uint8_t)(val & 0x2) << 1;
7689 hex |= (uint8_t)(val & 0x1) << 3;
7692 filter.mask[j] = byte;
7693 printf("mask[%d]:%02x ", j, filter.mask[j]);
7701 printf("call function rte_eth_dev_add_flex_filter: "
7702 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7703 res->index_value, res->queue_id,
7704 filter.len, filter.priority);
7705 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7706 &filter, res->queue_id);
7708 } else if (!strcmp(res->filter, "remove_flex_filter"))
7709 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7711 else if (!strcmp(res->filter, "get_flex_filter"))
7712 get_flex_filter(res->port_id, res->index_value);
7715 printf("flex filter setting error: (%s)\n", strerror(-ret));
7718 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7719 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7721 cmdline_parse_token_string_t cmd_flex_filter_len =
7722 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7724 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7725 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7727 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7728 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7730 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7731 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7733 cmdline_parse_token_string_t cmd_flex_filter_mask =
7734 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7736 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7737 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7739 cmdline_parse_token_string_t cmd_flex_filter_priority =
7740 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7741 priority, "priority");
7742 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7743 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7744 priority_value, UINT8);
7745 cmdline_parse_token_string_t cmd_flex_filter_queue =
7746 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7748 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7749 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7751 cmdline_parse_token_string_t cmd_flex_filter_index =
7752 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7754 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7755 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7756 index_value, UINT16);
7757 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7758 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7759 filter, "add_flex_filter");
7760 cmdline_parse_inst_t cmd_add_flex_filter = {
7761 .f = cmd_flex_filter_parsed,
7763 .help_str = "add a flex filter",
7765 (void *)&cmd_flex_filter_add_filter,
7766 (void *)&cmd_flex_filter_port_id,
7767 (void *)&cmd_flex_filter_len,
7768 (void *)&cmd_flex_filter_len_value,
7769 (void *)&cmd_flex_filter_bytes,
7770 (void *)&cmd_flex_filter_bytes_value,
7771 (void *)&cmd_flex_filter_mask,
7772 (void *)&cmd_flex_filter_mask_value,
7773 (void *)&cmd_flex_filter_priority,
7774 (void *)&cmd_flex_filter_priority_value,
7775 (void *)&cmd_flex_filter_queue,
7776 (void *)&cmd_flex_filter_queue_id,
7777 (void *)&cmd_flex_filter_index,
7778 (void *)&cmd_flex_filter_index_value,
7783 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7784 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7785 filter, "remove_flex_filter");
7786 cmdline_parse_inst_t cmd_remove_flex_filter = {
7787 .f = cmd_flex_filter_parsed,
7789 .help_str = "remove a flex filter",
7791 (void *)&cmd_flex_filter_remove_filter,
7792 (void *)&cmd_flex_filter_port_id,
7793 (void *)&cmd_flex_filter_index,
7794 (void *)&cmd_flex_filter_index_value,
7799 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7800 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7801 filter, "get_flex_filter");
7802 cmdline_parse_inst_t cmd_get_flex_filter = {
7803 .f = cmd_flex_filter_parsed,
7805 .help_str = "get a flex filter",
7807 (void *)&cmd_flex_filter_get_filter,
7808 (void *)&cmd_flex_filter_port_id,
7809 (void *)&cmd_flex_filter_index,
7810 (void *)&cmd_flex_filter_index_value,
7815 /* ******************************************************************************** */
7817 /* list of instructions */
7818 cmdline_parse_ctx_t main_ctx[] = {
7819 (cmdline_parse_inst_t *)&cmd_help_brief,
7820 (cmdline_parse_inst_t *)&cmd_help_long,
7821 (cmdline_parse_inst_t *)&cmd_quit,
7822 (cmdline_parse_inst_t *)&cmd_showport,
7823 (cmdline_parse_inst_t *)&cmd_showportall,
7824 (cmdline_parse_inst_t *)&cmd_showcfg,
7825 (cmdline_parse_inst_t *)&cmd_start,
7826 (cmdline_parse_inst_t *)&cmd_start_tx_first,
7827 (cmdline_parse_inst_t *)&cmd_set_link_up,
7828 (cmdline_parse_inst_t *)&cmd_set_link_down,
7829 (cmdline_parse_inst_t *)&cmd_reset,
7830 (cmdline_parse_inst_t *)&cmd_set_numbers,
7831 (cmdline_parse_inst_t *)&cmd_set_txpkts,
7832 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
7833 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
7834 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
7835 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
7836 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
7837 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
7838 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
7839 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
7840 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
7841 (cmdline_parse_inst_t *)&cmd_set_link_check,
7842 #ifdef RTE_NIC_BYPASS
7843 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
7844 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
7845 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
7846 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
7848 #ifdef RTE_LIBRTE_PMD_BOND
7849 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
7850 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
7851 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
7852 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
7853 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
7854 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
7855 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
7856 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
7857 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
7859 (cmdline_parse_inst_t *)&cmd_vlan_offload,
7860 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
7861 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
7862 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
7863 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
7864 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
7865 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
7866 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
7867 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
7868 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
7869 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
7870 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
7871 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
7872 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
7873 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
7874 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
7875 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
7876 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
7877 (cmdline_parse_inst_t *)&cmd_config_dcb,
7878 (cmdline_parse_inst_t *)&cmd_read_reg,
7879 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
7880 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
7881 (cmdline_parse_inst_t *)&cmd_write_reg,
7882 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
7883 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
7884 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
7885 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
7886 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
7887 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
7888 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
7889 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
7890 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
7891 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
7892 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
7893 (cmdline_parse_inst_t *)&cmd_stop,
7894 (cmdline_parse_inst_t *)&cmd_mac_addr,
7895 (cmdline_parse_inst_t *)&cmd_set_qmap,
7896 (cmdline_parse_inst_t *)&cmd_operate_port,
7897 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
7898 (cmdline_parse_inst_t *)&cmd_config_speed_all,
7899 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
7900 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
7901 (cmdline_parse_inst_t *)&cmd_config_mtu,
7902 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
7903 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
7904 (cmdline_parse_inst_t *)&cmd_config_rss,
7905 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
7906 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
7907 (cmdline_parse_inst_t *)&cmd_showport_reta,
7908 (cmdline_parse_inst_t *)&cmd_config_burst,
7909 (cmdline_parse_inst_t *)&cmd_config_thresh,
7910 (cmdline_parse_inst_t *)&cmd_config_threshold,
7911 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
7912 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
7913 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
7914 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
7915 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
7916 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
7917 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
7918 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
7919 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
7920 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
7921 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
7922 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
7923 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
7924 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
7925 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
7926 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
7927 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
7928 (cmdline_parse_inst_t *)&cmd_dump,
7929 (cmdline_parse_inst_t *)&cmd_dump_one,
7930 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
7931 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
7932 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
7933 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
7934 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
7935 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
7936 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
7937 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
7938 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
7939 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
7940 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
7941 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
7942 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
7943 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
7944 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
7948 /* prompt function, called from main on MASTER lcore */
7954 /* initialize non-constant commands */
7955 cmd_set_fwd_mode_init();
7957 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
7961 cmdline_interact(cl);
7962 cmdline_stdin_exit(cl);
7966 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
7968 if (id < nb_ports) {
7969 /* check if need_reconfig has been set to 1 */
7970 if (ports[id].need_reconfig == 0)
7971 ports[id].need_reconfig = dev;
7972 /* check if need_reconfig_queues has been set to 1 */
7973 if (ports[id].need_reconfig_queues == 0)
7974 ports[id].need_reconfig_queues = queue;
7978 for (pid = 0; pid < nb_ports; pid++) {
7979 /* check if need_reconfig has been set to 1 */
7980 if (ports[pid].need_reconfig == 0)
7981 ports[pid].need_reconfig = dev;
7982 /* check if need_reconfig_queues has been set to 1 */
7983 if (ports[pid].need_reconfig_queues == 0)
7984 ports[pid].need_reconfig_queues = queue;
7989 #ifdef RTE_NIC_BYPASS
7991 bypass_is_supported(portid_t port_id)
7993 struct rte_port *port;
7994 struct rte_pci_id *pci_id;
7996 if (port_id >= nb_ports) {
7997 printf("\tPort id must be less than %d.\n", nb_ports);
8001 /* Get the device id. */
8002 port = &ports[port_id];
8003 pci_id = &port->dev_info.pci_dev->id;
8005 /* Check if NIC supports bypass. */
8006 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8010 printf("\tBypass not supported for port_id = %d.\n", port_id);