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 link-up port (port_id)\n"
467 " Set link up for a port.\n\n"
469 "set link-down port (port_id)\n"
470 " Set link down for a port.\n\n"
472 , list_pkt_forwarding_modes()
477 if (show_all || !strcmp(res->section, "flowdir")) {
482 "Flow director mode:\n"
483 "-------------------\n\n"
485 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
486 " src (src_ip_address) (src_port)"
487 " dst (dst_ip_address) (dst_port)"
488 " flexbytes (flexbytes_values) vlan (vlan_id)"
489 " queue (queue_id)\n"
490 " Add a signature filter.\n\n"
492 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
493 " src (src_ip_address) (src_port)"
494 " dst (dst_ip_address) (dst_port)"
495 " flexbytes (flexbytes_values) vlan (vlan_id)"
496 " queue (queue_id)\n"
497 " Update a signature filter.\n\n"
499 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
500 " src (src_ip_address) (src_port)"
501 " dst (dst_ip_address) (dst_port)"
502 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
503 " Remove a signature filter.\n\n"
505 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
506 " src (src_ip_address) (src_port)"
507 " dst (dst_ip_address) (dst_port)"
508 " flexbytes (flexbytes_values) vlan (vlan_id)"
509 " queue (queue_id) soft (soft_id)\n"
510 " Add a perfect filter.\n\n"
512 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
513 " src (src_ip_address) (src_port)"
514 " dst (dst_ip_address) (dst_port)"
515 " flexbytes (flexbytes_values) vlan (vlan_id)"
516 " queue (queue_id)\n"
517 " Update a perfect filter.\n\n"
519 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
520 " src (src_ip_address) (src_port)"
521 " dst (dst_ip_address) (dst_port)"
522 " flexbytes (flexbytes_values) vlan (vlan_id)"
524 " Remove a perfect filter.\n\n"
526 "set_masks_filter (port_id) only_ip_flow (0|1)"
527 " src_mask (ip_src_mask) (src_port_mask)"
528 " dst_mask (ip_dst_mask) (dst_port_mask)"
529 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
530 " Set IPv4 filter masks.\n\n"
532 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
533 " src_mask (ip_src_mask) (src_port_mask)"
534 " dst_mask (ip_dst_mask) (dst_port_mask)"
535 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
536 " compare_dst (0|1)\n"
537 " Set IPv6 filter masks.\n\n"
541 if (show_all || !strcmp(res->section, "ports")) {
547 "----------------\n\n"
549 "port start (port_id|all)\n"
550 " Start all ports or port_id.\n\n"
552 "port stop (port_id|all)\n"
553 " Stop all ports or port_id.\n\n"
555 "port close (port_id|all)\n"
556 " Close all ports or port_id.\n\n"
558 "port config (port_id|all)"
559 " speed (10|100|1000|10000|40000|auto)"
560 " duplex (half|full|auto)\n"
561 " Set speed and duplex for all ports or port_id\n\n"
563 "port config all (rxq|txq|rxd|txd) (value)\n"
564 " Set number for rxq/txq/rxd/txd.\n\n"
566 "port config all max-pkt-len (value)\n"
567 " Set the max packet length.\n\n"
569 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
571 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
574 "port config all rss (ip|udp|none)\n"
575 " Set the RSS mode.\n\n"
577 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
578 " Set the RSS redirection table.\n\n"
580 "port config (port_id) dcb vt (on|off) (traffic_class)"
582 " Set the DCB mode.\n\n"
584 "port config all burst (value)\n"
585 " Set the number of packets per burst.\n\n"
587 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
589 " Set the ring prefetch/host/writeback threshold"
590 " for tx/rx queue.\n\n"
592 "port config all (txfreet|txrst|rxfreet) (value)\n"
593 " Set free threshold for rx/tx, or set"
594 " tx rs bit threshold.\n\n"
595 "port config mtu X value\n"
596 " Set the MTU of port X to a given value\n\n"
598 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
599 " Start/stop a rx/tx queue of port X. Only take effect"
600 " when port X is started\n"
604 if (show_all || !strcmp(res->section, "registers")) {
612 "read reg (port_id) (address)\n"
613 " Display value of a port register.\n\n"
615 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
616 " Display a port register bit field.\n\n"
618 "read regbit (port_id) (address) (bit_x)\n"
619 " Display a single port register bit.\n\n"
621 "write reg (port_id) (address) (value)\n"
622 " Set value of a port register.\n\n"
624 "write regfield (port_id) (address) (bit_x) (bit_y)"
626 " Set bit field of a port register.\n\n"
628 "write regbit (port_id) (address) (bit_x) (value)\n"
629 " Set single bit value of a port register.\n\n"
632 if (show_all || !strcmp(res->section, "filters")) {
640 "add_ethertype_filter (port_id) ethertype (eth_value)"
641 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
642 " add an ethertype filter.\n\n"
644 "remove_ethertype_filter (port_id) index (idx)\n"
645 " remove an ethertype filter.\n\n"
647 "get_ethertype_filter (port_id) index (idx)\n"
648 " get info of a ethertype filter.\n\n"
650 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
651 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
652 " queue (queue_id) index (idx)\n"
653 " add a 2tuple filter.\n\n"
655 "remove_2tuple_filter (port_id) index (idx)\n"
656 " remove a 2tuple filter.\n\n"
658 "get_2tuple_filter (port_id) index (idx)\n"
659 " get info of a 2tuple filter.\n\n"
661 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
662 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
663 " mask (mask_value) flags (flags_value) priority (prio_value)"
664 " queue (queue_id) index (idx)\n"
665 " add a 5tuple filter.\n\n"
667 "remove_5tuple_filter (port_id) index (idx)\n"
668 " remove a 5tuple filter.\n\n"
670 "get_5tuple_filter (port_id) index (idx)\n"
671 " get info of a 5tuple filter.\n\n"
673 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
674 " add syn filter.\n\n"
676 "remove_syn_filter (port_id)"
677 " remove syn filter.\n\n"
679 "get_syn_filter (port_id) "
680 " get syn filter info.\n\n"
682 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
683 " priority (prio_value) queue (queue_id) index (idx)\n"
684 " add a flex filter.\n\n"
686 "remove_flex_filter (port_id) index (idx)\n"
687 " remove a flex filter.\n\n"
689 "get_flex_filter (port_id) index (idx)\n"
690 " get info of a flex filter.\n\n"
695 cmdline_parse_token_string_t cmd_help_long_help =
696 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
698 cmdline_parse_token_string_t cmd_help_long_section =
699 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
700 "all#control#display#config#flowdir#"
701 "ports#registers#filters");
703 cmdline_parse_inst_t cmd_help_long = {
704 .f = cmd_help_long_parsed,
706 .help_str = "show help",
708 (void *)&cmd_help_long_help,
709 (void *)&cmd_help_long_section,
715 /* *** start/stop/close all ports *** */
716 struct cmd_operate_port_result {
717 cmdline_fixed_string_t keyword;
718 cmdline_fixed_string_t name;
719 cmdline_fixed_string_t value;
722 static void cmd_operate_port_parsed(void *parsed_result,
723 __attribute__((unused)) struct cmdline *cl,
724 __attribute__((unused)) void *data)
726 struct cmd_operate_port_result *res = parsed_result;
728 if (!strcmp(res->name, "start"))
729 start_port(RTE_PORT_ALL);
730 else if (!strcmp(res->name, "stop"))
731 stop_port(RTE_PORT_ALL);
732 else if (!strcmp(res->name, "close"))
733 close_port(RTE_PORT_ALL);
735 printf("Unknown parameter\n");
738 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
739 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
741 cmdline_parse_token_string_t cmd_operate_port_all_port =
742 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
744 cmdline_parse_token_string_t cmd_operate_port_all_all =
745 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
747 cmdline_parse_inst_t cmd_operate_port = {
748 .f = cmd_operate_port_parsed,
750 .help_str = "port start|stop|close all: start/stop/close all ports",
752 (void *)&cmd_operate_port_all_cmd,
753 (void *)&cmd_operate_port_all_port,
754 (void *)&cmd_operate_port_all_all,
759 /* *** start/stop/close specific port *** */
760 struct cmd_operate_specific_port_result {
761 cmdline_fixed_string_t keyword;
762 cmdline_fixed_string_t name;
766 static void cmd_operate_specific_port_parsed(void *parsed_result,
767 __attribute__((unused)) struct cmdline *cl,
768 __attribute__((unused)) void *data)
770 struct cmd_operate_specific_port_result *res = parsed_result;
772 if (!strcmp(res->name, "start"))
773 start_port(res->value);
774 else if (!strcmp(res->name, "stop"))
775 stop_port(res->value);
776 else if (!strcmp(res->name, "close"))
777 close_port(res->value);
779 printf("Unknown parameter\n");
782 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
783 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
785 cmdline_parse_token_string_t cmd_operate_specific_port_port =
786 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
787 name, "start#stop#close");
788 cmdline_parse_token_num_t cmd_operate_specific_port_id =
789 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
792 cmdline_parse_inst_t cmd_operate_specific_port = {
793 .f = cmd_operate_specific_port_parsed,
795 .help_str = "port start|stop|close X: start/stop/close port X",
797 (void *)&cmd_operate_specific_port_cmd,
798 (void *)&cmd_operate_specific_port_port,
799 (void *)&cmd_operate_specific_port_id,
804 /* *** configure speed for all ports *** */
805 struct cmd_config_speed_all {
806 cmdline_fixed_string_t port;
807 cmdline_fixed_string_t keyword;
808 cmdline_fixed_string_t all;
809 cmdline_fixed_string_t item1;
810 cmdline_fixed_string_t item2;
811 cmdline_fixed_string_t value1;
812 cmdline_fixed_string_t value2;
816 cmd_config_speed_all_parsed(void *parsed_result,
817 __attribute__((unused)) struct cmdline *cl,
818 __attribute__((unused)) void *data)
820 struct cmd_config_speed_all *res = parsed_result;
821 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
822 uint16_t link_duplex = 0;
825 if (!all_ports_stopped()) {
826 printf("Please stop all ports first\n");
830 if (!strcmp(res->value1, "10"))
831 link_speed = ETH_LINK_SPEED_10;
832 else if (!strcmp(res->value1, "100"))
833 link_speed = ETH_LINK_SPEED_100;
834 else if (!strcmp(res->value1, "1000"))
835 link_speed = ETH_LINK_SPEED_1000;
836 else if (!strcmp(res->value1, "10000"))
837 link_speed = ETH_LINK_SPEED_10G;
838 else if (!strcmp(res->value1, "40000"))
839 link_speed = ETH_LINK_SPEED_40G;
840 else if (!strcmp(res->value1, "auto"))
841 link_speed = ETH_LINK_SPEED_AUTONEG;
843 printf("Unknown parameter\n");
847 if (!strcmp(res->value2, "half"))
848 link_duplex = ETH_LINK_HALF_DUPLEX;
849 else if (!strcmp(res->value2, "full"))
850 link_duplex = ETH_LINK_FULL_DUPLEX;
851 else if (!strcmp(res->value2, "auto"))
852 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
854 printf("Unknown parameter\n");
858 for (pid = 0; pid < nb_ports; pid++) {
859 ports[pid].dev_conf.link_speed = link_speed;
860 ports[pid].dev_conf.link_duplex = link_duplex;
863 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
866 cmdline_parse_token_string_t cmd_config_speed_all_port =
867 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
868 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
869 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
871 cmdline_parse_token_string_t cmd_config_speed_all_all =
872 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
873 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
874 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
875 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
876 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
877 "10#100#1000#10000#40000#auto");
878 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
879 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
880 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
881 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
884 cmdline_parse_inst_t cmd_config_speed_all = {
885 .f = cmd_config_speed_all_parsed,
887 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
890 (void *)&cmd_config_speed_all_port,
891 (void *)&cmd_config_speed_all_keyword,
892 (void *)&cmd_config_speed_all_all,
893 (void *)&cmd_config_speed_all_item1,
894 (void *)&cmd_config_speed_all_value1,
895 (void *)&cmd_config_speed_all_item2,
896 (void *)&cmd_config_speed_all_value2,
901 /* *** configure speed for specific port *** */
902 struct cmd_config_speed_specific {
903 cmdline_fixed_string_t port;
904 cmdline_fixed_string_t keyword;
906 cmdline_fixed_string_t item1;
907 cmdline_fixed_string_t item2;
908 cmdline_fixed_string_t value1;
909 cmdline_fixed_string_t value2;
913 cmd_config_speed_specific_parsed(void *parsed_result,
914 __attribute__((unused)) struct cmdline *cl,
915 __attribute__((unused)) void *data)
917 struct cmd_config_speed_specific *res = parsed_result;
918 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
919 uint16_t link_duplex = 0;
921 if (!all_ports_stopped()) {
922 printf("Please stop all ports first\n");
926 if (res->id >= nb_ports) {
927 printf("Port id %d must be less than %d\n", res->id, nb_ports);
931 if (!strcmp(res->value1, "10"))
932 link_speed = ETH_LINK_SPEED_10;
933 else if (!strcmp(res->value1, "100"))
934 link_speed = ETH_LINK_SPEED_100;
935 else if (!strcmp(res->value1, "1000"))
936 link_speed = ETH_LINK_SPEED_1000;
937 else if (!strcmp(res->value1, "10000"))
938 link_speed = ETH_LINK_SPEED_10000;
939 else if (!strcmp(res->value1, "40000"))
940 link_speed = ETH_LINK_SPEED_40G;
941 else if (!strcmp(res->value1, "auto"))
942 link_speed = ETH_LINK_SPEED_AUTONEG;
944 printf("Unknown parameter\n");
948 if (!strcmp(res->value2, "half"))
949 link_duplex = ETH_LINK_HALF_DUPLEX;
950 else if (!strcmp(res->value2, "full"))
951 link_duplex = ETH_LINK_FULL_DUPLEX;
952 else if (!strcmp(res->value2, "auto"))
953 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
955 printf("Unknown parameter\n");
959 ports[res->id].dev_conf.link_speed = link_speed;
960 ports[res->id].dev_conf.link_duplex = link_duplex;
962 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
966 cmdline_parse_token_string_t cmd_config_speed_specific_port =
967 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
969 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
970 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
972 cmdline_parse_token_num_t cmd_config_speed_specific_id =
973 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
974 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
975 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
977 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
978 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
979 "10#100#1000#10000#40000#auto");
980 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
981 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
983 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
984 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
987 cmdline_parse_inst_t cmd_config_speed_specific = {
988 .f = cmd_config_speed_specific_parsed,
990 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
993 (void *)&cmd_config_speed_specific_port,
994 (void *)&cmd_config_speed_specific_keyword,
995 (void *)&cmd_config_speed_specific_id,
996 (void *)&cmd_config_speed_specific_item1,
997 (void *)&cmd_config_speed_specific_value1,
998 (void *)&cmd_config_speed_specific_item2,
999 (void *)&cmd_config_speed_specific_value2,
1004 /* *** configure txq/rxq, txd/rxd *** */
1005 struct cmd_config_rx_tx {
1006 cmdline_fixed_string_t port;
1007 cmdline_fixed_string_t keyword;
1008 cmdline_fixed_string_t all;
1009 cmdline_fixed_string_t name;
1014 cmd_config_rx_tx_parsed(void *parsed_result,
1015 __attribute__((unused)) struct cmdline *cl,
1016 __attribute__((unused)) void *data)
1018 struct cmd_config_rx_tx *res = parsed_result;
1020 if (!all_ports_stopped()) {
1021 printf("Please stop all ports first\n");
1025 if (!strcmp(res->name, "rxq")) {
1026 if (res->value <= 0) {
1027 printf("rxq %d invalid - must be > 0\n", res->value);
1030 nb_rxq = res->value;
1032 else if (!strcmp(res->name, "txq")) {
1033 if (res->value <= 0) {
1034 printf("txq %d invalid - must be > 0\n", res->value);
1037 nb_txq = res->value;
1039 else if (!strcmp(res->name, "rxd")) {
1040 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1041 printf("rxd %d invalid - must be > 0 && <= %d\n",
1042 res->value, RTE_TEST_RX_DESC_MAX);
1045 nb_rxd = res->value;
1046 } else if (!strcmp(res->name, "txd")) {
1047 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1048 printf("txd %d invalid - must be > 0 && <= %d\n",
1049 res->value, RTE_TEST_TX_DESC_MAX);
1052 nb_txd = res->value;
1054 printf("Unknown parameter\n");
1060 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1063 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1064 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1065 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1066 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1067 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1068 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1069 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1070 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1072 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1073 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1075 cmdline_parse_inst_t cmd_config_rx_tx = {
1076 .f = cmd_config_rx_tx_parsed,
1078 .help_str = "port config all rxq|txq|rxd|txd value",
1080 (void *)&cmd_config_rx_tx_port,
1081 (void *)&cmd_config_rx_tx_keyword,
1082 (void *)&cmd_config_rx_tx_all,
1083 (void *)&cmd_config_rx_tx_name,
1084 (void *)&cmd_config_rx_tx_value,
1089 /* *** config max packet length *** */
1090 struct cmd_config_max_pkt_len_result {
1091 cmdline_fixed_string_t port;
1092 cmdline_fixed_string_t keyword;
1093 cmdline_fixed_string_t all;
1094 cmdline_fixed_string_t name;
1099 cmd_config_max_pkt_len_parsed(void *parsed_result,
1100 __attribute__((unused)) struct cmdline *cl,
1101 __attribute__((unused)) void *data)
1103 struct cmd_config_max_pkt_len_result *res = parsed_result;
1105 if (!all_ports_stopped()) {
1106 printf("Please stop all ports first\n");
1110 if (!strcmp(res->name, "max-pkt-len")) {
1111 if (res->value < ETHER_MIN_LEN) {
1112 printf("max-pkt-len can not be less than %d\n",
1116 if (res->value == rx_mode.max_rx_pkt_len)
1119 rx_mode.max_rx_pkt_len = res->value;
1120 if (res->value > ETHER_MAX_LEN)
1121 rx_mode.jumbo_frame = 1;
1123 rx_mode.jumbo_frame = 0;
1125 printf("Unknown parameter\n");
1131 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1134 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1135 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1137 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1138 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1140 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1141 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1143 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1144 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1146 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1147 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1150 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1151 .f = cmd_config_max_pkt_len_parsed,
1153 .help_str = "port config all max-pkt-len value",
1155 (void *)&cmd_config_max_pkt_len_port,
1156 (void *)&cmd_config_max_pkt_len_keyword,
1157 (void *)&cmd_config_max_pkt_len_all,
1158 (void *)&cmd_config_max_pkt_len_name,
1159 (void *)&cmd_config_max_pkt_len_value,
1164 /* *** configure port MTU *** */
1165 struct cmd_config_mtu_result {
1166 cmdline_fixed_string_t port;
1167 cmdline_fixed_string_t keyword;
1168 cmdline_fixed_string_t mtu;
1174 cmd_config_mtu_parsed(void *parsed_result,
1175 __attribute__((unused)) struct cmdline *cl,
1176 __attribute__((unused)) void *data)
1178 struct cmd_config_mtu_result *res = parsed_result;
1180 if (res->value < ETHER_MIN_LEN) {
1181 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1184 port_mtu_set(res->port_id, res->value);
1187 cmdline_parse_token_string_t cmd_config_mtu_port =
1188 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1190 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1191 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1193 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1194 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1196 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1197 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1198 cmdline_parse_token_num_t cmd_config_mtu_value =
1199 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1201 cmdline_parse_inst_t cmd_config_mtu = {
1202 .f = cmd_config_mtu_parsed,
1204 .help_str = "port config mtu value",
1206 (void *)&cmd_config_mtu_port,
1207 (void *)&cmd_config_mtu_keyword,
1208 (void *)&cmd_config_mtu_mtu,
1209 (void *)&cmd_config_mtu_port_id,
1210 (void *)&cmd_config_mtu_value,
1215 /* *** configure rx mode *** */
1216 struct cmd_config_rx_mode_flag {
1217 cmdline_fixed_string_t port;
1218 cmdline_fixed_string_t keyword;
1219 cmdline_fixed_string_t all;
1220 cmdline_fixed_string_t name;
1221 cmdline_fixed_string_t value;
1225 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1226 __attribute__((unused)) struct cmdline *cl,
1227 __attribute__((unused)) void *data)
1229 struct cmd_config_rx_mode_flag *res = parsed_result;
1231 if (!all_ports_stopped()) {
1232 printf("Please stop all ports first\n");
1236 if (!strcmp(res->name, "crc-strip")) {
1237 if (!strcmp(res->value, "on"))
1238 rx_mode.hw_strip_crc = 1;
1239 else if (!strcmp(res->value, "off"))
1240 rx_mode.hw_strip_crc = 0;
1242 printf("Unknown parameter\n");
1245 } else if (!strcmp(res->name, "rx-cksum")) {
1246 if (!strcmp(res->value, "on"))
1247 rx_mode.hw_ip_checksum = 1;
1248 else if (!strcmp(res->value, "off"))
1249 rx_mode.hw_ip_checksum = 0;
1251 printf("Unknown parameter\n");
1254 } else if (!strcmp(res->name, "hw-vlan")) {
1255 if (!strcmp(res->value, "on")) {
1256 rx_mode.hw_vlan_filter = 1;
1257 rx_mode.hw_vlan_strip = 1;
1259 else if (!strcmp(res->value, "off")) {
1260 rx_mode.hw_vlan_filter = 0;
1261 rx_mode.hw_vlan_strip = 0;
1264 printf("Unknown parameter\n");
1267 } else if (!strcmp(res->name, "drop-en")) {
1268 if (!strcmp(res->value, "on"))
1270 else if (!strcmp(res->value, "off"))
1273 printf("Unknown parameter\n");
1277 printf("Unknown parameter\n");
1283 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1286 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1287 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1288 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1289 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1291 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1292 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1293 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1294 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1295 "crc-strip#rx-cksum#hw-vlan");
1296 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1297 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1300 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1301 .f = cmd_config_rx_mode_flag_parsed,
1303 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1305 (void *)&cmd_config_rx_mode_flag_port,
1306 (void *)&cmd_config_rx_mode_flag_keyword,
1307 (void *)&cmd_config_rx_mode_flag_all,
1308 (void *)&cmd_config_rx_mode_flag_name,
1309 (void *)&cmd_config_rx_mode_flag_value,
1314 /* *** configure rss *** */
1315 struct cmd_config_rss {
1316 cmdline_fixed_string_t port;
1317 cmdline_fixed_string_t keyword;
1318 cmdline_fixed_string_t all;
1319 cmdline_fixed_string_t name;
1320 cmdline_fixed_string_t value;
1324 cmd_config_rss_parsed(void *parsed_result,
1325 __attribute__((unused)) struct cmdline *cl,
1326 __attribute__((unused)) void *data)
1328 struct cmd_config_rss *res = parsed_result;
1329 struct rte_eth_rss_conf rss_conf;
1332 if (!strcmp(res->value, "ip"))
1333 rss_conf.rss_hf = ETH_RSS_IP;
1334 else if (!strcmp(res->value, "udp"))
1335 rss_conf.rss_hf = ETH_RSS_UDP;
1336 else if (!strcmp(res->value, "none"))
1337 rss_conf.rss_hf = 0;
1339 printf("Unknown parameter\n");
1342 rss_conf.rss_key = NULL;
1343 for (i = 0; i < rte_eth_dev_count(); i++)
1344 rte_eth_dev_rss_hash_update(i, &rss_conf);
1347 cmdline_parse_token_string_t cmd_config_rss_port =
1348 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1349 cmdline_parse_token_string_t cmd_config_rss_keyword =
1350 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1351 cmdline_parse_token_string_t cmd_config_rss_all =
1352 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1353 cmdline_parse_token_string_t cmd_config_rss_name =
1354 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1355 cmdline_parse_token_string_t cmd_config_rss_value =
1356 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1358 cmdline_parse_inst_t cmd_config_rss = {
1359 .f = cmd_config_rss_parsed,
1361 .help_str = "port config all rss ip|udp|none",
1363 (void *)&cmd_config_rss_port,
1364 (void *)&cmd_config_rss_keyword,
1365 (void *)&cmd_config_rss_all,
1366 (void *)&cmd_config_rss_name,
1367 (void *)&cmd_config_rss_value,
1372 /* *** configure rss hash key *** */
1373 struct cmd_config_rss_hash_key {
1374 cmdline_fixed_string_t port;
1375 cmdline_fixed_string_t config;
1377 cmdline_fixed_string_t rss_hash_key;
1378 cmdline_fixed_string_t key;
1381 #define RSS_HASH_KEY_LENGTH 40
1383 hexa_digit_to_value(char hexa_digit)
1385 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1386 return (uint8_t) (hexa_digit - '0');
1387 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1388 return (uint8_t) ((hexa_digit - 'a') + 10);
1389 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1390 return (uint8_t) ((hexa_digit - 'A') + 10);
1391 /* Invalid hexa digit */
1396 parse_and_check_key_hexa_digit(char *key, int idx)
1400 hexa_v = hexa_digit_to_value(key[idx]);
1402 printf("invalid key: character %c at position %d is not a "
1403 "valid hexa digit\n", key[idx], idx);
1408 cmd_config_rss_hash_key_parsed(void *parsed_result,
1409 __attribute__((unused)) struct cmdline *cl,
1410 __attribute__((unused)) void *data)
1412 struct cmd_config_rss_hash_key *res = parsed_result;
1413 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1418 /* Check the length of the RSS hash key */
1419 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1420 printf("key length: %d invalid - key must be a string of %d"
1421 "hexa-decimal numbers\n", (int) strlen(res->key),
1422 RSS_HASH_KEY_LENGTH * 2);
1425 /* Translate RSS hash key into binary representation */
1426 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1427 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1430 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1433 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1435 port_rss_hash_key_update(res->port_id, hash_key);
1438 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1439 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1440 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1441 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1443 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1444 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1445 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1446 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1447 rss_hash_key, "rss-hash-key");
1448 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1449 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1451 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1452 .f = cmd_config_rss_hash_key_parsed,
1454 .help_str = "port config X rss-hash-key 80 hexa digits",
1456 (void *)&cmd_config_rss_hash_key_port,
1457 (void *)&cmd_config_rss_hash_key_config,
1458 (void *)&cmd_config_rss_hash_key_port_id,
1459 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1460 (void *)&cmd_config_rss_hash_key_value,
1465 /* *** configure port rxq/txq start/stop *** */
1466 struct cmd_config_rxtx_queue {
1467 cmdline_fixed_string_t port;
1469 cmdline_fixed_string_t rxtxq;
1471 cmdline_fixed_string_t opname;
1475 cmd_config_rxtx_queue_parsed(void *parsed_result,
1476 __attribute__((unused)) struct cmdline *cl,
1477 __attribute__((unused)) void *data)
1479 struct cmd_config_rxtx_queue *res = parsed_result;
1484 if (test_done == 0) {
1485 printf("Please stop forwarding first\n");
1489 if (port_id_is_invalid(res->portid))
1492 if (port_is_started(res->portid) != 1) {
1493 printf("Please start port %u first\n", res->portid);
1497 if (!strcmp(res->rxtxq, "rxq"))
1499 else if (!strcmp(res->rxtxq, "txq"))
1502 printf("Unknown parameter\n");
1506 if (isrx && rx_queue_id_is_invalid(res->qid))
1508 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1511 if (!strcmp(res->opname, "start"))
1513 else if (!strcmp(res->opname, "stop"))
1516 printf("Unknown parameter\n");
1520 if (isstart && isrx)
1521 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1522 else if (!isstart && isrx)
1523 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1524 else if (isstart && !isrx)
1525 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1527 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1529 if (ret == -ENOTSUP)
1530 printf("Function not supported in PMD driver\n");
1533 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1534 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1535 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1536 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1537 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1538 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1539 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1540 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1541 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1542 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1545 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1546 .f = cmd_config_rxtx_queue_parsed,
1548 .help_str = "port X rxq|txq ID start|stop",
1550 (void *)&cmd_config_speed_all_port,
1551 (void *)&cmd_config_rxtx_queue_portid,
1552 (void *)&cmd_config_rxtx_queue_rxtxq,
1553 (void *)&cmd_config_rxtx_queue_qid,
1554 (void *)&cmd_config_rxtx_queue_opname,
1559 /* *** Configure RSS RETA *** */
1560 struct cmd_config_rss_reta {
1561 cmdline_fixed_string_t port;
1562 cmdline_fixed_string_t keyword;
1564 cmdline_fixed_string_t name;
1565 cmdline_fixed_string_t list_name;
1566 cmdline_fixed_string_t list_of_items;
1570 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1577 const char *p, *p0 = str;
1584 unsigned long int_fld[_NUM_FLD];
1585 char *str_fld[_NUM_FLD];
1587 while ((p = strchr(p0,'(')) != NULL) {
1589 if((p0 = strchr(p,')')) == NULL)
1593 if(size >= sizeof(s))
1596 snprintf(s, sizeof(s), "%.*s", size, p);
1597 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1599 for (i = 0; i < _NUM_FLD; i++) {
1601 int_fld[i] = strtoul(str_fld[i], &end, 0);
1602 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1606 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1607 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1609 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1610 printf("Invalid RETA hash index=%d",hash_index);
1614 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1615 reta_conf->mask_lo |= (1ULL << hash_index);
1617 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1619 reta_conf->reta[hash_index] = nb_queue;
1626 cmd_set_rss_reta_parsed(void *parsed_result,
1627 __attribute__((unused)) struct cmdline *cl,
1628 __attribute__((unused)) void *data)
1631 struct rte_eth_rss_reta reta_conf;
1632 struct cmd_config_rss_reta *res = parsed_result;
1634 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1635 if (!strcmp(res->list_name, "reta")) {
1636 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1637 printf("Invalid RSS Redirection Table config entered\n");
1640 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1642 printf("Bad redirection table parameter, return code = %d \n",ret);
1646 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1648 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1650 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1651 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1652 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1654 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1656 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1657 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1659 cmdline_parse_inst_t cmd_config_rss_reta = {
1660 .f = cmd_set_rss_reta_parsed,
1662 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1664 (void *)&cmd_config_rss_reta_port,
1665 (void *)&cmd_config_rss_reta_keyword,
1666 (void *)&cmd_config_rss_reta_port_id,
1667 (void *)&cmd_config_rss_reta_name,
1668 (void *)&cmd_config_rss_reta_list_name,
1669 (void *)&cmd_config_rss_reta_list_of_items,
1674 /* *** SHOW PORT RETA INFO *** */
1675 struct cmd_showport_reta {
1676 cmdline_fixed_string_t show;
1677 cmdline_fixed_string_t port;
1679 cmdline_fixed_string_t rss;
1680 cmdline_fixed_string_t reta;
1685 static void cmd_showport_reta_parsed(void *parsed_result,
1686 __attribute__((unused)) struct cmdline *cl,
1687 __attribute__((unused)) void *data)
1689 struct cmd_showport_reta *res = parsed_result;
1690 struct rte_eth_rss_reta reta_conf;
1692 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1693 printf("Invalid RSS Redirection Table config entered\n");
1697 reta_conf.mask_lo = res->mask_lo;
1698 reta_conf.mask_hi = res->mask_hi;
1700 port_rss_reta_info(res->port_id,&reta_conf);
1703 cmdline_parse_token_string_t cmd_showport_reta_show =
1704 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1705 cmdline_parse_token_string_t cmd_showport_reta_port =
1706 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1707 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1708 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1709 cmdline_parse_token_string_t cmd_showport_reta_rss =
1710 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1711 cmdline_parse_token_string_t cmd_showport_reta_reta =
1712 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1713 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1714 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1715 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1716 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1718 cmdline_parse_inst_t cmd_showport_reta = {
1719 .f = cmd_showport_reta_parsed,
1721 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1722 (mask_lo and mask_hi is UINT64)",
1724 (void *)&cmd_showport_reta_show,
1725 (void *)&cmd_showport_reta_port,
1726 (void *)&cmd_showport_reta_port_id,
1727 (void *)&cmd_showport_reta_rss,
1728 (void *)&cmd_showport_reta_reta,
1729 (void *)&cmd_showport_reta_mask_lo,
1730 (void *)&cmd_showport_reta_mask_hi,
1735 /* *** Show RSS hash configuration *** */
1736 struct cmd_showport_rss_hash {
1737 cmdline_fixed_string_t show;
1738 cmdline_fixed_string_t port;
1740 cmdline_fixed_string_t rss_hash;
1741 cmdline_fixed_string_t key; /* optional argument */
1744 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1745 __attribute__((unused)) struct cmdline *cl,
1748 struct cmd_showport_rss_hash *res = parsed_result;
1750 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1753 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1754 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1755 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1756 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1757 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1758 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1759 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1760 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1762 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1763 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1765 cmdline_parse_inst_t cmd_showport_rss_hash = {
1766 .f = cmd_showport_rss_hash_parsed,
1768 .help_str = "show port X rss-hash (X = port number)\n",
1770 (void *)&cmd_showport_rss_hash_show,
1771 (void *)&cmd_showport_rss_hash_port,
1772 (void *)&cmd_showport_rss_hash_port_id,
1773 (void *)&cmd_showport_rss_hash_rss_hash,
1778 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1779 .f = cmd_showport_rss_hash_parsed,
1781 .help_str = "show port X rss-hash key (X = port number)\n",
1783 (void *)&cmd_showport_rss_hash_show,
1784 (void *)&cmd_showport_rss_hash_port,
1785 (void *)&cmd_showport_rss_hash_port_id,
1786 (void *)&cmd_showport_rss_hash_rss_hash,
1787 (void *)&cmd_showport_rss_hash_rss_key,
1792 /* *** Configure DCB *** */
1793 struct cmd_config_dcb {
1794 cmdline_fixed_string_t port;
1795 cmdline_fixed_string_t config;
1797 cmdline_fixed_string_t dcb;
1798 cmdline_fixed_string_t vt;
1799 cmdline_fixed_string_t vt_en;
1801 cmdline_fixed_string_t pfc;
1802 cmdline_fixed_string_t pfc_en;
1806 cmd_config_dcb_parsed(void *parsed_result,
1807 __attribute__((unused)) struct cmdline *cl,
1808 __attribute__((unused)) void *data)
1810 struct cmd_config_dcb *res = parsed_result;
1811 struct dcb_config dcb_conf;
1812 portid_t port_id = res->port_id;
1813 struct rte_port *port;
1815 port = &ports[port_id];
1816 /** Check if the port is not started **/
1817 if (port->port_status != RTE_PORT_STOPPED) {
1818 printf("Please stop port %d first\n",port_id);
1822 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1823 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1824 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1828 /* DCB in VT mode */
1829 if (!strncmp(res->vt_en, "on",2))
1830 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1832 dcb_conf.dcb_mode = DCB_ENABLED;
1834 if (!strncmp(res->pfc_en, "on",2)) {
1835 dcb_conf.pfc_en = 1;
1838 dcb_conf.pfc_en = 0;
1840 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1841 printf("Cannot initialize network ports\n");
1845 cmd_reconfig_device_queue(port_id, 1, 1);
1848 cmdline_parse_token_string_t cmd_config_dcb_port =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1850 cmdline_parse_token_string_t cmd_config_dcb_config =
1851 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1852 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1853 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1854 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1856 cmdline_parse_token_string_t cmd_config_dcb_vt =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1858 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1859 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1860 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1861 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1862 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1863 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1864 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1865 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1867 cmdline_parse_inst_t cmd_config_dcb = {
1868 .f = cmd_config_dcb_parsed,
1870 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1872 (void *)&cmd_config_dcb_port,
1873 (void *)&cmd_config_dcb_config,
1874 (void *)&cmd_config_dcb_port_id,
1875 (void *)&cmd_config_dcb_dcb,
1876 (void *)&cmd_config_dcb_vt,
1877 (void *)&cmd_config_dcb_vt_en,
1878 (void *)&cmd_config_dcb_num_tcs,
1879 (void *)&cmd_config_dcb_pfc,
1880 (void *)&cmd_config_dcb_pfc_en,
1885 /* *** configure number of packets per burst *** */
1886 struct cmd_config_burst {
1887 cmdline_fixed_string_t port;
1888 cmdline_fixed_string_t keyword;
1889 cmdline_fixed_string_t all;
1890 cmdline_fixed_string_t name;
1895 cmd_config_burst_parsed(void *parsed_result,
1896 __attribute__((unused)) struct cmdline *cl,
1897 __attribute__((unused)) void *data)
1899 struct cmd_config_burst *res = parsed_result;
1901 if (!all_ports_stopped()) {
1902 printf("Please stop all ports first\n");
1906 if (!strcmp(res->name, "burst")) {
1907 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1908 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1911 nb_pkt_per_burst = res->value;
1913 printf("Unknown parameter\n");
1919 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1922 cmdline_parse_token_string_t cmd_config_burst_port =
1923 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1924 cmdline_parse_token_string_t cmd_config_burst_keyword =
1925 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1926 cmdline_parse_token_string_t cmd_config_burst_all =
1927 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1928 cmdline_parse_token_string_t cmd_config_burst_name =
1929 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1930 cmdline_parse_token_num_t cmd_config_burst_value =
1931 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1933 cmdline_parse_inst_t cmd_config_burst = {
1934 .f = cmd_config_burst_parsed,
1936 .help_str = "port config all burst value",
1938 (void *)&cmd_config_burst_port,
1939 (void *)&cmd_config_burst_keyword,
1940 (void *)&cmd_config_burst_all,
1941 (void *)&cmd_config_burst_name,
1942 (void *)&cmd_config_burst_value,
1947 /* *** configure rx/tx queues *** */
1948 struct cmd_config_thresh {
1949 cmdline_fixed_string_t port;
1950 cmdline_fixed_string_t keyword;
1951 cmdline_fixed_string_t all;
1952 cmdline_fixed_string_t name;
1957 cmd_config_thresh_parsed(void *parsed_result,
1958 __attribute__((unused)) struct cmdline *cl,
1959 __attribute__((unused)) void *data)
1961 struct cmd_config_thresh *res = parsed_result;
1963 if (!all_ports_stopped()) {
1964 printf("Please stop all ports first\n");
1968 if (!strcmp(res->name, "txpt"))
1969 tx_thresh.pthresh = res->value;
1970 else if(!strcmp(res->name, "txht"))
1971 tx_thresh.hthresh = res->value;
1972 else if(!strcmp(res->name, "txwt"))
1973 tx_thresh.wthresh = res->value;
1974 else if(!strcmp(res->name, "rxpt"))
1975 rx_thresh.pthresh = res->value;
1976 else if(!strcmp(res->name, "rxht"))
1977 rx_thresh.hthresh = res->value;
1978 else if(!strcmp(res->name, "rxwt"))
1979 rx_thresh.wthresh = res->value;
1981 printf("Unknown parameter\n");
1987 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1990 cmdline_parse_token_string_t cmd_config_thresh_port =
1991 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1992 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1993 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1994 cmdline_parse_token_string_t cmd_config_thresh_all =
1995 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1996 cmdline_parse_token_string_t cmd_config_thresh_name =
1997 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1998 "txpt#txht#txwt#rxpt#rxht#rxwt");
1999 cmdline_parse_token_num_t cmd_config_thresh_value =
2000 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2002 cmdline_parse_inst_t cmd_config_thresh = {
2003 .f = cmd_config_thresh_parsed,
2005 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2007 (void *)&cmd_config_thresh_port,
2008 (void *)&cmd_config_thresh_keyword,
2009 (void *)&cmd_config_thresh_all,
2010 (void *)&cmd_config_thresh_name,
2011 (void *)&cmd_config_thresh_value,
2016 /* *** configure free/rs threshold *** */
2017 struct cmd_config_threshold {
2018 cmdline_fixed_string_t port;
2019 cmdline_fixed_string_t keyword;
2020 cmdline_fixed_string_t all;
2021 cmdline_fixed_string_t name;
2026 cmd_config_threshold_parsed(void *parsed_result,
2027 __attribute__((unused)) struct cmdline *cl,
2028 __attribute__((unused)) void *data)
2030 struct cmd_config_threshold *res = parsed_result;
2032 if (!all_ports_stopped()) {
2033 printf("Please stop all ports first\n");
2037 if (!strcmp(res->name, "txfreet"))
2038 tx_free_thresh = res->value;
2039 else if (!strcmp(res->name, "txrst"))
2040 tx_rs_thresh = res->value;
2041 else if (!strcmp(res->name, "rxfreet"))
2042 rx_free_thresh = res->value;
2044 printf("Unknown parameter\n");
2050 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2053 cmdline_parse_token_string_t cmd_config_threshold_port =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2055 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2056 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2058 cmdline_parse_token_string_t cmd_config_threshold_all =
2059 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2060 cmdline_parse_token_string_t cmd_config_threshold_name =
2061 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2062 "txfreet#txrst#rxfreet");
2063 cmdline_parse_token_num_t cmd_config_threshold_value =
2064 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2066 cmdline_parse_inst_t cmd_config_threshold = {
2067 .f = cmd_config_threshold_parsed,
2069 .help_str = "port config all txfreet|txrst|rxfreet value",
2071 (void *)&cmd_config_threshold_port,
2072 (void *)&cmd_config_threshold_keyword,
2073 (void *)&cmd_config_threshold_all,
2074 (void *)&cmd_config_threshold_name,
2075 (void *)&cmd_config_threshold_value,
2081 struct cmd_stop_result {
2082 cmdline_fixed_string_t stop;
2085 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2086 __attribute__((unused)) struct cmdline *cl,
2087 __attribute__((unused)) void *data)
2089 stop_packet_forwarding();
2092 cmdline_parse_token_string_t cmd_stop_stop =
2093 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2095 cmdline_parse_inst_t cmd_stop = {
2096 .f = cmd_stop_parsed,
2098 .help_str = "stop - stop packet forwarding",
2100 (void *)&cmd_stop_stop,
2105 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2108 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2109 unsigned int *parsed_items, int check_unique_values)
2111 unsigned int nb_item;
2119 * First parse all items in the list and store their value.
2124 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2126 if ((c >= '0') && (c <= '9')) {
2127 value = (unsigned int) (value * 10 + (c - '0'));
2132 printf("character %c is not a decimal digit\n", c);
2136 printf("No valid value before comma\n");
2139 if (nb_item < max_items) {
2140 parsed_items[nb_item] = value;
2146 if (nb_item >= max_items) {
2147 printf("Number of %s = %u > %u (maximum items)\n",
2148 item_name, nb_item + 1, max_items);
2151 parsed_items[nb_item++] = value;
2152 if (! check_unique_values)
2156 * Then, check that all values in the list are differents.
2157 * No optimization here...
2159 for (i = 0; i < nb_item; i++) {
2160 for (j = i + 1; j < nb_item; j++) {
2161 if (parsed_items[j] == parsed_items[i]) {
2162 printf("duplicated %s %u at index %u and %u\n",
2163 item_name, parsed_items[i], i, j);
2171 struct cmd_set_list_result {
2172 cmdline_fixed_string_t cmd_keyword;
2173 cmdline_fixed_string_t list_name;
2174 cmdline_fixed_string_t list_of_items;
2177 static void cmd_set_list_parsed(void *parsed_result,
2178 __attribute__((unused)) struct cmdline *cl,
2179 __attribute__((unused)) void *data)
2181 struct cmd_set_list_result *res;
2183 unsigned int lcorelist[RTE_MAX_LCORE];
2184 unsigned int portlist[RTE_MAX_ETHPORTS];
2186 unsigned int nb_item;
2188 res = parsed_result;
2189 if (!strcmp(res->list_name, "corelist")) {
2190 nb_item = parse_item_list(res->list_of_items, "core",
2192 parsed_items.lcorelist, 1);
2194 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2197 if (!strcmp(res->list_name, "portlist")) {
2198 nb_item = parse_item_list(res->list_of_items, "port",
2200 parsed_items.portlist, 1);
2202 set_fwd_ports_list(parsed_items.portlist, nb_item);
2206 cmdline_parse_token_string_t cmd_set_list_keyword =
2207 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2209 cmdline_parse_token_string_t cmd_set_list_name =
2210 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2211 "corelist#portlist");
2212 cmdline_parse_token_string_t cmd_set_list_of_items =
2213 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2216 cmdline_parse_inst_t cmd_set_fwd_list = {
2217 .f = cmd_set_list_parsed,
2219 .help_str = "set corelist|portlist x[,y]*",
2221 (void *)&cmd_set_list_keyword,
2222 (void *)&cmd_set_list_name,
2223 (void *)&cmd_set_list_of_items,
2228 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2230 struct cmd_setmask_result {
2231 cmdline_fixed_string_t set;
2232 cmdline_fixed_string_t mask;
2236 static void cmd_set_mask_parsed(void *parsed_result,
2237 __attribute__((unused)) struct cmdline *cl,
2238 __attribute__((unused)) void *data)
2240 struct cmd_setmask_result *res = parsed_result;
2242 if (!strcmp(res->mask, "coremask"))
2243 set_fwd_lcores_mask(res->hexavalue);
2244 else if (!strcmp(res->mask, "portmask"))
2245 set_fwd_ports_mask(res->hexavalue);
2248 cmdline_parse_token_string_t cmd_setmask_set =
2249 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2250 cmdline_parse_token_string_t cmd_setmask_mask =
2251 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2252 "coremask#portmask");
2253 cmdline_parse_token_num_t cmd_setmask_value =
2254 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2256 cmdline_parse_inst_t cmd_set_fwd_mask = {
2257 .f = cmd_set_mask_parsed,
2259 .help_str = "set coremask|portmask hexadecimal value",
2261 (void *)&cmd_setmask_set,
2262 (void *)&cmd_setmask_mask,
2263 (void *)&cmd_setmask_value,
2269 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2271 struct cmd_set_result {
2272 cmdline_fixed_string_t set;
2273 cmdline_fixed_string_t what;
2277 static void cmd_set_parsed(void *parsed_result,
2278 __attribute__((unused)) struct cmdline *cl,
2279 __attribute__((unused)) void *data)
2281 struct cmd_set_result *res = parsed_result;
2282 if (!strcmp(res->what, "nbport"))
2283 set_fwd_ports_number(res->value);
2284 else if (!strcmp(res->what, "nbcore"))
2285 set_fwd_lcores_number(res->value);
2286 else if (!strcmp(res->what, "burst"))
2287 set_nb_pkt_per_burst(res->value);
2288 else if (!strcmp(res->what, "verbose"))
2289 set_verbose_level(res->value);
2292 cmdline_parse_token_string_t cmd_set_set =
2293 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2294 cmdline_parse_token_string_t cmd_set_what =
2295 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2296 "nbport#nbcore#burst#verbose");
2297 cmdline_parse_token_num_t cmd_set_value =
2298 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2300 cmdline_parse_inst_t cmd_set_numbers = {
2301 .f = cmd_set_parsed,
2303 .help_str = "set nbport|nbcore|burst|verbose value",
2305 (void *)&cmd_set_set,
2306 (void *)&cmd_set_what,
2307 (void *)&cmd_set_value,
2312 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2314 struct cmd_set_txpkts_result {
2315 cmdline_fixed_string_t cmd_keyword;
2316 cmdline_fixed_string_t txpkts;
2317 cmdline_fixed_string_t seg_lengths;
2321 cmd_set_txpkts_parsed(void *parsed_result,
2322 __attribute__((unused)) struct cmdline *cl,
2323 __attribute__((unused)) void *data)
2325 struct cmd_set_txpkts_result *res;
2326 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2327 unsigned int nb_segs;
2329 res = parsed_result;
2330 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2331 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2333 set_tx_pkt_segments(seg_lengths, nb_segs);
2336 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2337 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2338 cmd_keyword, "set");
2339 cmdline_parse_token_string_t cmd_set_txpkts_name =
2340 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2342 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2343 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2346 cmdline_parse_inst_t cmd_set_txpkts = {
2347 .f = cmd_set_txpkts_parsed,
2349 .help_str = "set txpkts x[,y]*",
2351 (void *)&cmd_set_txpkts_keyword,
2352 (void *)&cmd_set_txpkts_name,
2353 (void *)&cmd_set_txpkts_lengths,
2358 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2359 struct cmd_rx_vlan_filter_all_result {
2360 cmdline_fixed_string_t rx_vlan;
2361 cmdline_fixed_string_t what;
2362 cmdline_fixed_string_t all;
2367 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2368 __attribute__((unused)) struct cmdline *cl,
2369 __attribute__((unused)) void *data)
2371 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2373 if (!strcmp(res->what, "add"))
2374 rx_vlan_all_filter_set(res->port_id, 1);
2376 rx_vlan_all_filter_set(res->port_id, 0);
2379 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2380 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2381 rx_vlan, "rx_vlan");
2382 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2383 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2385 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2386 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2388 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2389 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2392 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2393 .f = cmd_rx_vlan_filter_all_parsed,
2395 .help_str = "add/remove all identifiers to/from the set of VLAN "
2396 "Identifiers filtered by a port",
2398 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2399 (void *)&cmd_rx_vlan_filter_all_what,
2400 (void *)&cmd_rx_vlan_filter_all_all,
2401 (void *)&cmd_rx_vlan_filter_all_portid,
2406 /* *** VLAN OFFLOAD SET ON A PORT *** */
2407 struct cmd_vlan_offload_result {
2408 cmdline_fixed_string_t vlan;
2409 cmdline_fixed_string_t set;
2410 cmdline_fixed_string_t what;
2411 cmdline_fixed_string_t on;
2412 cmdline_fixed_string_t port_id;
2416 cmd_vlan_offload_parsed(void *parsed_result,
2417 __attribute__((unused)) struct cmdline *cl,
2418 __attribute__((unused)) void *data)
2421 struct cmd_vlan_offload_result *res = parsed_result;
2424 portid_t port_id = 0;
2428 len = strnlen(str, STR_TOKEN_SIZE);
2430 /* Get port_id first */
2438 tmp = strtoul(str, NULL, 0);
2439 /* If port_id greater that what portid_t can represent, return */
2440 if(tmp >= RTE_MAX_ETHPORTS)
2442 port_id = (portid_t)tmp;
2444 if (!strcmp(res->on, "on"))
2449 if (!strcmp(res->what, "strip"))
2450 rx_vlan_strip_set(port_id, on);
2451 else if(!strcmp(res->what, "stripq")){
2452 uint16_t queue_id = 0;
2454 /* No queue_id, return */
2456 printf("must specify (port,queue_id)\n");
2459 tmp = strtoul(str + i + 1, NULL, 0);
2460 /* If queue_id greater that what 16-bits can represent, return */
2464 queue_id = (uint16_t)tmp;
2465 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2467 else if (!strcmp(res->what, "filter"))
2468 rx_vlan_filter_set(port_id, on);
2470 vlan_extend_set(port_id, on);
2475 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2476 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2478 cmdline_parse_token_string_t cmd_vlan_offload_set =
2479 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2481 cmdline_parse_token_string_t cmd_vlan_offload_what =
2482 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2483 what, "strip#filter#qinq#stripq");
2484 cmdline_parse_token_string_t cmd_vlan_offload_on =
2485 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2487 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2488 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2491 cmdline_parse_inst_t cmd_vlan_offload = {
2492 .f = cmd_vlan_offload_parsed,
2494 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2495 " qinq(extended) for both rx/tx sides ",
2497 (void *)&cmd_vlan_offload_vlan,
2498 (void *)&cmd_vlan_offload_set,
2499 (void *)&cmd_vlan_offload_what,
2500 (void *)&cmd_vlan_offload_on,
2501 (void *)&cmd_vlan_offload_portid,
2506 /* *** VLAN TPID SET ON A PORT *** */
2507 struct cmd_vlan_tpid_result {
2508 cmdline_fixed_string_t vlan;
2509 cmdline_fixed_string_t set;
2510 cmdline_fixed_string_t what;
2516 cmd_vlan_tpid_parsed(void *parsed_result,
2517 __attribute__((unused)) struct cmdline *cl,
2518 __attribute__((unused)) void *data)
2520 struct cmd_vlan_tpid_result *res = parsed_result;
2521 vlan_tpid_set(res->port_id, res->tp_id);
2525 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2526 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2528 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2529 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2531 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2532 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2534 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2535 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2537 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2538 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2541 cmdline_parse_inst_t cmd_vlan_tpid = {
2542 .f = cmd_vlan_tpid_parsed,
2544 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2546 (void *)&cmd_vlan_tpid_vlan,
2547 (void *)&cmd_vlan_tpid_set,
2548 (void *)&cmd_vlan_tpid_what,
2549 (void *)&cmd_vlan_tpid_tpid,
2550 (void *)&cmd_vlan_tpid_portid,
2555 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2556 struct cmd_rx_vlan_filter_result {
2557 cmdline_fixed_string_t rx_vlan;
2558 cmdline_fixed_string_t what;
2564 cmd_rx_vlan_filter_parsed(void *parsed_result,
2565 __attribute__((unused)) struct cmdline *cl,
2566 __attribute__((unused)) void *data)
2568 struct cmd_rx_vlan_filter_result *res = parsed_result;
2570 if (!strcmp(res->what, "add"))
2571 rx_vft_set(res->port_id, res->vlan_id, 1);
2573 rx_vft_set(res->port_id, res->vlan_id, 0);
2576 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2577 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2578 rx_vlan, "rx_vlan");
2579 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2580 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2582 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2583 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2585 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2586 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2589 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2590 .f = cmd_rx_vlan_filter_parsed,
2592 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2593 "Identifiers filtered by a port",
2595 (void *)&cmd_rx_vlan_filter_rx_vlan,
2596 (void *)&cmd_rx_vlan_filter_what,
2597 (void *)&cmd_rx_vlan_filter_vlanid,
2598 (void *)&cmd_rx_vlan_filter_portid,
2603 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2604 struct cmd_tx_vlan_set_result {
2605 cmdline_fixed_string_t tx_vlan;
2606 cmdline_fixed_string_t set;
2612 cmd_tx_vlan_set_parsed(void *parsed_result,
2613 __attribute__((unused)) struct cmdline *cl,
2614 __attribute__((unused)) void *data)
2616 struct cmd_tx_vlan_set_result *res = parsed_result;
2617 tx_vlan_set(res->port_id, res->vlan_id);
2620 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2621 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2622 tx_vlan, "tx_vlan");
2623 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2624 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2626 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2627 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2629 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2630 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2633 cmdline_parse_inst_t cmd_tx_vlan_set = {
2634 .f = cmd_tx_vlan_set_parsed,
2636 .help_str = "enable hardware insertion of a VLAN header with a given "
2637 "TAG Identifier in packets sent on a port",
2639 (void *)&cmd_tx_vlan_set_tx_vlan,
2640 (void *)&cmd_tx_vlan_set_set,
2641 (void *)&cmd_tx_vlan_set_vlanid,
2642 (void *)&cmd_tx_vlan_set_portid,
2647 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2648 struct cmd_tx_vlan_set_pvid_result {
2649 cmdline_fixed_string_t tx_vlan;
2650 cmdline_fixed_string_t set;
2651 cmdline_fixed_string_t pvid;
2654 cmdline_fixed_string_t mode;
2658 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2659 __attribute__((unused)) struct cmdline *cl,
2660 __attribute__((unused)) void *data)
2662 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2664 if (strcmp(res->mode, "on") == 0)
2665 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2667 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2670 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2671 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2672 tx_vlan, "tx_vlan");
2673 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2674 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2676 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2677 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2679 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2680 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2682 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2683 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2685 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2686 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2689 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2690 .f = cmd_tx_vlan_set_pvid_parsed,
2692 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2694 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2695 (void *)&cmd_tx_vlan_set_pvid_set,
2696 (void *)&cmd_tx_vlan_set_pvid_pvid,
2697 (void *)&cmd_tx_vlan_set_pvid_port_id,
2698 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2699 (void *)&cmd_tx_vlan_set_pvid_mode,
2704 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2705 struct cmd_tx_vlan_reset_result {
2706 cmdline_fixed_string_t tx_vlan;
2707 cmdline_fixed_string_t reset;
2712 cmd_tx_vlan_reset_parsed(void *parsed_result,
2713 __attribute__((unused)) struct cmdline *cl,
2714 __attribute__((unused)) void *data)
2716 struct cmd_tx_vlan_reset_result *res = parsed_result;
2718 tx_vlan_reset(res->port_id);
2721 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2722 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2723 tx_vlan, "tx_vlan");
2724 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2725 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2727 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2728 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2731 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2732 .f = cmd_tx_vlan_reset_parsed,
2734 .help_str = "disable hardware insertion of a VLAN header in packets "
2737 (void *)&cmd_tx_vlan_reset_tx_vlan,
2738 (void *)&cmd_tx_vlan_reset_reset,
2739 (void *)&cmd_tx_vlan_reset_portid,
2745 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2746 struct cmd_tx_cksum_set_result {
2747 cmdline_fixed_string_t tx_cksum;
2748 cmdline_fixed_string_t set;
2754 cmd_tx_cksum_set_parsed(void *parsed_result,
2755 __attribute__((unused)) struct cmdline *cl,
2756 __attribute__((unused)) void *data)
2758 struct cmd_tx_cksum_set_result *res = parsed_result;
2760 tx_cksum_set(res->port_id, res->cksum_mask);
2763 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2764 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2765 tx_cksum, "tx_checksum");
2766 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2767 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2769 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2770 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2772 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2773 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2776 cmdline_parse_inst_t cmd_tx_cksum_set = {
2777 .f = cmd_tx_cksum_set_parsed,
2779 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2780 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip, "
2781 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip, "
2782 "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
2784 (void *)&cmd_tx_cksum_set_tx_cksum,
2785 (void *)&cmd_tx_cksum_set_set,
2786 (void *)&cmd_tx_cksum_set_cksum_mask,
2787 (void *)&cmd_tx_cksum_set_portid,
2792 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2793 struct cmd_set_flush_rx {
2794 cmdline_fixed_string_t set;
2795 cmdline_fixed_string_t flush_rx;
2796 cmdline_fixed_string_t mode;
2800 cmd_set_flush_rx_parsed(void *parsed_result,
2801 __attribute__((unused)) struct cmdline *cl,
2802 __attribute__((unused)) void *data)
2804 struct cmd_set_flush_rx *res = parsed_result;
2805 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2808 cmdline_parse_token_string_t cmd_setflushrx_set =
2809 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2811 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2812 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2813 flush_rx, "flush_rx");
2814 cmdline_parse_token_string_t cmd_setflushrx_mode =
2815 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2819 cmdline_parse_inst_t cmd_set_flush_rx = {
2820 .f = cmd_set_flush_rx_parsed,
2821 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2824 (void *)&cmd_setflushrx_set,
2825 (void *)&cmd_setflushrx_flush_rx,
2826 (void *)&cmd_setflushrx_mode,
2831 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2832 struct cmd_set_link_check {
2833 cmdline_fixed_string_t set;
2834 cmdline_fixed_string_t link_check;
2835 cmdline_fixed_string_t mode;
2839 cmd_set_link_check_parsed(void *parsed_result,
2840 __attribute__((unused)) struct cmdline *cl,
2841 __attribute__((unused)) void *data)
2843 struct cmd_set_link_check *res = parsed_result;
2844 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2847 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2848 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2850 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2851 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2852 link_check, "link_check");
2853 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2854 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2858 cmdline_parse_inst_t cmd_set_link_check = {
2859 .f = cmd_set_link_check_parsed,
2860 .help_str = "set link_check on|off: enable/disable link status check "
2861 "when starting/stopping a port",
2864 (void *)&cmd_setlinkcheck_set,
2865 (void *)&cmd_setlinkcheck_link_check,
2866 (void *)&cmd_setlinkcheck_mode,
2871 #ifdef RTE_NIC_BYPASS
2872 /* *** SET NIC BYPASS MODE *** */
2873 struct cmd_set_bypass_mode_result {
2874 cmdline_fixed_string_t set;
2875 cmdline_fixed_string_t bypass;
2876 cmdline_fixed_string_t mode;
2877 cmdline_fixed_string_t value;
2882 cmd_set_bypass_mode_parsed(void *parsed_result,
2883 __attribute__((unused)) struct cmdline *cl,
2884 __attribute__((unused)) void *data)
2886 struct cmd_set_bypass_mode_result *res = parsed_result;
2887 portid_t port_id = res->port_id;
2888 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2890 if (!bypass_is_supported(port_id))
2893 if (!strcmp(res->value, "bypass"))
2894 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2895 else if (!strcmp(res->value, "isolate"))
2896 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2898 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2900 /* Set the bypass mode for the relevant port. */
2901 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2902 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2906 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2907 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2909 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2910 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2912 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2913 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2915 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2916 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2917 value, "normal#bypass#isolate");
2918 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2919 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2922 cmdline_parse_inst_t cmd_set_bypass_mode = {
2923 .f = cmd_set_bypass_mode_parsed,
2924 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2925 "Set the NIC bypass mode for port_id",
2928 (void *)&cmd_setbypass_mode_set,
2929 (void *)&cmd_setbypass_mode_bypass,
2930 (void *)&cmd_setbypass_mode_mode,
2931 (void *)&cmd_setbypass_mode_value,
2932 (void *)&cmd_setbypass_mode_port,
2937 /* *** SET NIC BYPASS EVENT *** */
2938 struct cmd_set_bypass_event_result {
2939 cmdline_fixed_string_t set;
2940 cmdline_fixed_string_t bypass;
2941 cmdline_fixed_string_t event;
2942 cmdline_fixed_string_t event_value;
2943 cmdline_fixed_string_t mode;
2944 cmdline_fixed_string_t mode_value;
2949 cmd_set_bypass_event_parsed(void *parsed_result,
2950 __attribute__((unused)) struct cmdline *cl,
2951 __attribute__((unused)) void *data)
2954 struct cmd_set_bypass_event_result *res = parsed_result;
2955 portid_t port_id = res->port_id;
2956 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2957 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2959 if (!bypass_is_supported(port_id))
2962 if (!strcmp(res->event_value, "timeout"))
2963 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2964 else if (!strcmp(res->event_value, "os_on"))
2965 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2966 else if (!strcmp(res->event_value, "os_off"))
2967 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2968 else if (!strcmp(res->event_value, "power_on"))
2969 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2970 else if (!strcmp(res->event_value, "power_off"))
2971 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2973 bypass_event = RTE_BYPASS_EVENT_NONE;
2975 if (!strcmp(res->mode_value, "bypass"))
2976 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2977 else if (!strcmp(res->mode_value, "isolate"))
2978 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2980 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2982 /* Set the watchdog timeout. */
2983 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2986 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2987 (rc = rte_eth_dev_wd_timeout_store(port_id,
2988 bypass_timeout)) != 0) {
2989 printf("Failed to set timeout value %u "
2990 "for port %d, errto code: %d.\n",
2991 bypass_timeout, port_id, rc);
2995 /* Set the bypass event to transition to bypass mode. */
2996 if (0 != rte_eth_dev_bypass_event_store(port_id,
2997 bypass_event, bypass_mode)) {
2998 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3003 cmdline_parse_token_string_t cmd_setbypass_event_set =
3004 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3006 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3007 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3009 cmdline_parse_token_string_t cmd_setbypass_event_event =
3010 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3012 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3013 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3014 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3015 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3016 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3018 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3019 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3020 mode_value, "normal#bypass#isolate");
3021 cmdline_parse_token_num_t cmd_setbypass_event_port =
3022 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3025 cmdline_parse_inst_t cmd_set_bypass_event = {
3026 .f = cmd_set_bypass_event_parsed,
3027 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3028 "mode (normal|bypass|isolate) (port_id): "
3029 "Set the NIC bypass event mode for port_id",
3032 (void *)&cmd_setbypass_event_set,
3033 (void *)&cmd_setbypass_event_bypass,
3034 (void *)&cmd_setbypass_event_event,
3035 (void *)&cmd_setbypass_event_event_value,
3036 (void *)&cmd_setbypass_event_mode,
3037 (void *)&cmd_setbypass_event_mode_value,
3038 (void *)&cmd_setbypass_event_port,
3044 /* *** SET NIC BYPASS TIMEOUT *** */
3045 struct cmd_set_bypass_timeout_result {
3046 cmdline_fixed_string_t set;
3047 cmdline_fixed_string_t bypass;
3048 cmdline_fixed_string_t timeout;
3049 cmdline_fixed_string_t value;
3053 cmd_set_bypass_timeout_parsed(void *parsed_result,
3054 __attribute__((unused)) struct cmdline *cl,
3055 __attribute__((unused)) void *data)
3057 struct cmd_set_bypass_timeout_result *res = parsed_result;
3059 if (!strcmp(res->value, "1.5"))
3060 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3061 else if (!strcmp(res->value, "2"))
3062 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3063 else if (!strcmp(res->value, "3"))
3064 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3065 else if (!strcmp(res->value, "4"))
3066 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3067 else if (!strcmp(res->value, "8"))
3068 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3069 else if (!strcmp(res->value, "16"))
3070 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3071 else if (!strcmp(res->value, "32"))
3072 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3074 bypass_timeout = RTE_BYPASS_TMT_OFF;
3077 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3078 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3080 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3081 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3083 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3084 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3085 timeout, "timeout");
3086 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3087 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3088 value, "0#1.5#2#3#4#8#16#32");
3090 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3091 .f = cmd_set_bypass_timeout_parsed,
3092 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3093 "Set the NIC bypass watchdog timeout",
3096 (void *)&cmd_setbypass_timeout_set,
3097 (void *)&cmd_setbypass_timeout_bypass,
3098 (void *)&cmd_setbypass_timeout_timeout,
3099 (void *)&cmd_setbypass_timeout_value,
3104 /* *** SHOW NIC BYPASS MODE *** */
3105 struct cmd_show_bypass_config_result {
3106 cmdline_fixed_string_t show;
3107 cmdline_fixed_string_t bypass;
3108 cmdline_fixed_string_t config;
3113 cmd_show_bypass_config_parsed(void *parsed_result,
3114 __attribute__((unused)) struct cmdline *cl,
3115 __attribute__((unused)) void *data)
3117 struct cmd_show_bypass_config_result *res = parsed_result;
3118 uint32_t event_mode;
3119 uint32_t bypass_mode;
3120 portid_t port_id = res->port_id;
3121 uint32_t timeout = bypass_timeout;
3124 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3125 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3126 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3127 {"UNKNOWN", "normal", "bypass", "isolate"};
3128 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3135 int num_events = (sizeof events) / (sizeof events[0]);
3137 if (!bypass_is_supported(port_id))
3140 /* Display the bypass mode.*/
3141 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3142 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3146 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3147 bypass_mode = RTE_BYPASS_MODE_NONE;
3149 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3152 /* Display the bypass timeout.*/
3153 if (!RTE_BYPASS_TMT_VALID(timeout))
3154 timeout = RTE_BYPASS_TMT_OFF;
3156 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3158 /* Display the bypass events and associated modes. */
3159 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3161 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3162 printf("\tFailed to get bypass mode for event = %s\n",
3165 if (!RTE_BYPASS_MODE_VALID(event_mode))
3166 event_mode = RTE_BYPASS_MODE_NONE;
3168 printf("\tbypass event: %-16s = %s\n", events[i],
3174 cmdline_parse_token_string_t cmd_showbypass_config_show =
3175 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3177 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3178 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3180 cmdline_parse_token_string_t cmd_showbypass_config_config =
3181 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3183 cmdline_parse_token_num_t cmd_showbypass_config_port =
3184 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3187 cmdline_parse_inst_t cmd_show_bypass_config = {
3188 .f = cmd_show_bypass_config_parsed,
3189 .help_str = "show bypass config (port_id): "
3190 "Show the NIC bypass config for port_id",
3193 (void *)&cmd_showbypass_config_show,
3194 (void *)&cmd_showbypass_config_bypass,
3195 (void *)&cmd_showbypass_config_config,
3196 (void *)&cmd_showbypass_config_port,
3202 #ifdef RTE_LIBRTE_PMD_BOND
3203 /* *** SET BONDING MODE *** */
3204 struct cmd_set_bonding_mode_result {
3205 cmdline_fixed_string_t set;
3206 cmdline_fixed_string_t bonding;
3207 cmdline_fixed_string_t mode;
3212 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3213 __attribute__((unused)) struct cmdline *cl,
3214 __attribute__((unused)) void *data)
3216 struct cmd_set_bonding_mode_result *res = parsed_result;
3217 portid_t port_id = res->port_id;
3219 /* Set the bonding mode for the relevant port. */
3220 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3221 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3224 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3225 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3227 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3228 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3229 bonding, "bonding");
3230 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3231 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3233 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3234 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3236 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3237 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3240 cmdline_parse_inst_t cmd_set_bonding_mode = {
3241 .f = cmd_set_bonding_mode_parsed,
3242 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3245 (void *) &cmd_setbonding_mode_set,
3246 (void *) &cmd_setbonding_mode_bonding,
3247 (void *) &cmd_setbonding_mode_mode,
3248 (void *) &cmd_setbonding_mode_value,
3249 (void *) &cmd_setbonding_mode_port,
3254 /* *** SET BALANCE XMIT POLICY *** */
3255 struct cmd_set_bonding_balance_xmit_policy_result {
3256 cmdline_fixed_string_t set;
3257 cmdline_fixed_string_t bonding;
3258 cmdline_fixed_string_t balance_xmit_policy;
3260 cmdline_fixed_string_t policy;
3263 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3264 __attribute__((unused)) struct cmdline *cl,
3265 __attribute__((unused)) void *data)
3267 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3268 portid_t port_id = res->port_id;
3271 if (!strcmp(res->policy, "l2")) {
3272 policy = BALANCE_XMIT_POLICY_LAYER2;
3273 } else if (!strcmp(res->policy, "l23")) {
3274 policy = BALANCE_XMIT_POLICY_LAYER23;
3275 } else if (!strcmp(res->policy, "l34")) {
3276 policy = BALANCE_XMIT_POLICY_LAYER34;
3278 printf("\t Invalid xmit policy selection");
3282 /* Set the bonding mode for the relevant port. */
3283 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3284 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3289 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3290 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3292 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3293 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3294 bonding, "bonding");
3295 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3296 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3297 balance_xmit_policy, "balance_xmit_policy");
3298 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3299 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3301 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3302 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3303 policy, "l2#l23#l34");
3305 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3306 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3307 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3310 (void *)&cmd_setbonding_balance_xmit_policy_set,
3311 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3312 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3313 (void *)&cmd_setbonding_balance_xmit_policy_port,
3314 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3319 /* *** SHOW NIC BONDING CONFIGURATION *** */
3320 struct cmd_show_bonding_config_result {
3321 cmdline_fixed_string_t show;
3322 cmdline_fixed_string_t bonding;
3323 cmdline_fixed_string_t config;
3327 static void cmd_show_bonding_config_parsed(void *parsed_result,
3328 __attribute__((unused)) struct cmdline *cl,
3329 __attribute__((unused)) void *data)
3331 struct cmd_show_bonding_config_result *res = parsed_result;
3333 uint8_t slaves[RTE_MAX_ETHPORTS];
3334 int num_slaves, num_active_slaves;
3337 portid_t port_id = res->port_id;
3339 /* Display the bonding mode.*/
3340 bonding_mode = rte_eth_bond_mode_get(port_id);
3341 if (bonding_mode < 0) {
3342 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3345 printf("\tBonding mode: %d\n", bonding_mode);
3347 if (bonding_mode == BONDING_MODE_BALANCE) {
3348 int balance_xmit_policy;
3350 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3351 if (balance_xmit_policy < 0) {
3352 printf("\tFailed to get balance xmit policy for port = %d\n",
3356 printf("\tBalance Xmit Policy: ");
3358 switch (balance_xmit_policy) {
3359 case BALANCE_XMIT_POLICY_LAYER2:
3360 printf("BALANCE_XMIT_POLICY_LAYER2");
3362 case BALANCE_XMIT_POLICY_LAYER23:
3363 printf("BALANCE_XMIT_POLICY_LAYER23");
3365 case BALANCE_XMIT_POLICY_LAYER34:
3366 printf("BALANCE_XMIT_POLICY_LAYER34");
3373 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3375 if (num_slaves < 0) {
3376 printf("\tFailed to get slave list for port = %d\n", port_id);
3379 if (num_slaves > 0) {
3380 printf("\tSlaves (%d): [", num_slaves);
3381 for (i = 0; i < num_slaves - 1; i++)
3382 printf("%d ", slaves[i]);
3384 printf("%d]\n", slaves[num_slaves - 1]);
3386 printf("\tSlaves: []\n");
3390 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3393 if (num_active_slaves < 0) {
3394 printf("\tFailed to get active slave list for port = %d\n", port_id);
3397 if (num_active_slaves > 0) {
3398 printf("\tActive Slaves (%d): [", num_active_slaves);
3399 for (i = 0; i < num_active_slaves - 1; i++)
3400 printf("%d ", slaves[i]);
3402 printf("%d]\n", slaves[num_active_slaves - 1]);
3405 printf("\tActive Slaves: []\n");
3409 primary_id = rte_eth_bond_primary_get(port_id);
3410 if (primary_id < 0) {
3411 printf("\tFailed to get primary slave for port = %d\n", port_id);
3414 printf("\tPrimary: [%d]\n", primary_id);
3418 cmdline_parse_token_string_t cmd_showbonding_config_show =
3419 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3421 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3422 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3423 bonding, "bonding");
3424 cmdline_parse_token_string_t cmd_showbonding_config_config =
3425 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3427 cmdline_parse_token_num_t cmd_showbonding_config_port =
3428 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3431 cmdline_parse_inst_t cmd_show_bonding_config = {
3432 .f = cmd_show_bonding_config_parsed,
3433 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3436 (void *)&cmd_showbonding_config_show,
3437 (void *)&cmd_showbonding_config_bonding,
3438 (void *)&cmd_showbonding_config_config,
3439 (void *)&cmd_showbonding_config_port,
3444 /* *** SET BONDING PRIMARY *** */
3445 struct cmd_set_bonding_primary_result {
3446 cmdline_fixed_string_t set;
3447 cmdline_fixed_string_t bonding;
3448 cmdline_fixed_string_t primary;
3453 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3454 __attribute__((unused)) struct cmdline *cl,
3455 __attribute__((unused)) void *data)
3457 struct cmd_set_bonding_primary_result *res = parsed_result;
3458 portid_t master_port_id = res->port_id;
3459 portid_t slave_port_id = res->slave_id;
3461 /* Set the primary slave for a bonded device. */
3462 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3463 printf("\t Failed to set primary slave for port = %d.\n",
3470 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3471 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3473 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3474 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3475 bonding, "bonding");
3476 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3477 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3478 primary, "primary");
3479 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3480 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3482 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3483 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3486 cmdline_parse_inst_t cmd_set_bonding_primary = {
3487 .f = cmd_set_bonding_primary_parsed,
3488 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3491 (void *)&cmd_setbonding_primary_set,
3492 (void *)&cmd_setbonding_primary_bonding,
3493 (void *)&cmd_setbonding_primary_primary,
3494 (void *)&cmd_setbonding_primary_slave,
3495 (void *)&cmd_setbonding_primary_port,
3500 /* *** ADD SLAVE *** */
3501 struct cmd_add_bonding_slave_result {
3502 cmdline_fixed_string_t add;
3503 cmdline_fixed_string_t bonding;
3504 cmdline_fixed_string_t slave;
3509 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3510 __attribute__((unused)) struct cmdline *cl,
3511 __attribute__((unused)) void *data)
3513 struct cmd_add_bonding_slave_result *res = parsed_result;
3514 portid_t master_port_id = res->port_id;
3515 portid_t slave_port_id = res->slave_id;
3517 /* Set the primary slave for a bonded device. */
3518 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3519 printf("\t Failed to add slave %d to master port = %d.\n",
3520 slave_port_id, master_port_id);
3526 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3527 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3529 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3530 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3531 bonding, "bonding");
3532 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3533 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3535 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3536 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3538 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3539 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3542 cmdline_parse_inst_t cmd_add_bonding_slave = {
3543 .f = cmd_add_bonding_slave_parsed,
3544 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3547 (void *)&cmd_addbonding_slave_add,
3548 (void *)&cmd_addbonding_slave_bonding,
3549 (void *)&cmd_addbonding_slave_slave,
3550 (void *)&cmd_addbonding_slave_slaveid,
3551 (void *)&cmd_addbonding_slave_port,
3556 /* *** REMOVE SLAVE *** */
3557 struct cmd_remove_bonding_slave_result {
3558 cmdline_fixed_string_t remove;
3559 cmdline_fixed_string_t bonding;
3560 cmdline_fixed_string_t slave;
3565 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3566 __attribute__((unused)) struct cmdline *cl,
3567 __attribute__((unused)) void *data)
3569 struct cmd_remove_bonding_slave_result *res = parsed_result;
3570 portid_t master_port_id = res->port_id;
3571 portid_t slave_port_id = res->slave_id;
3573 /* Set the primary slave for a bonded device. */
3574 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3575 printf("\t Failed to remove slave %d from master port = %d.\n",
3576 slave_port_id, master_port_id);
3582 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3583 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3585 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3586 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3587 bonding, "bonding");
3588 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3589 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3591 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3592 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3594 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3595 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3598 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3599 .f = cmd_remove_bonding_slave_parsed,
3600 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3603 (void *)&cmd_removebonding_slave_remove,
3604 (void *)&cmd_removebonding_slave_bonding,
3605 (void *)&cmd_removebonding_slave_slave,
3606 (void *)&cmd_removebonding_slave_slaveid,
3607 (void *)&cmd_removebonding_slave_port,
3612 /* *** CREATE BONDED DEVICE *** */
3613 struct cmd_create_bonded_device_result {
3614 cmdline_fixed_string_t create;
3615 cmdline_fixed_string_t bonded;
3616 cmdline_fixed_string_t device;
3621 static int bond_dev_num = 0;
3623 static void cmd_create_bonded_device_parsed(void *parsed_result,
3624 __attribute__((unused)) struct cmdline *cl,
3625 __attribute__((unused)) void *data)
3627 struct cmd_create_bonded_device_result *res = parsed_result;
3628 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3631 if (test_done == 0) {
3632 printf("Please stop forwarding first\n");
3636 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3639 /* Create a new bonded device. */
3640 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3642 printf("\t Failed to create bonded device.\n");
3645 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3648 /* Update number of ports */
3649 nb_ports = rte_eth_dev_count();
3651 rte_eth_promiscuous_enable(port_id);
3656 cmdline_parse_token_string_t cmd_createbonded_device_create =
3657 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3659 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3660 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3662 cmdline_parse_token_string_t cmd_createbonded_device_device =
3663 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3665 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3666 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3668 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3669 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3672 cmdline_parse_inst_t cmd_create_bonded_device = {
3673 .f = cmd_create_bonded_device_parsed,
3674 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3677 (void *)&cmd_createbonded_device_create,
3678 (void *)&cmd_createbonded_device_bonded,
3679 (void *)&cmd_createbonded_device_device,
3680 (void *)&cmd_createbonded_device_mode,
3681 (void *)&cmd_createbonded_device_socket,
3686 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3687 struct cmd_set_bond_mac_addr_result {
3688 cmdline_fixed_string_t set;
3689 cmdline_fixed_string_t bonding;
3690 cmdline_fixed_string_t mac_addr;
3692 struct ether_addr address;
3695 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3696 __attribute__((unused)) struct cmdline *cl,
3697 __attribute__((unused)) void *data)
3699 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3702 if (res->port_num >= nb_ports) {
3703 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3707 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3709 /* check the return value and print it if is < 0 */
3711 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3714 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3715 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3716 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3717 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3719 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3720 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3722 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3723 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3724 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3725 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3727 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3728 .f = cmd_set_bond_mac_addr_parsed,
3730 .help_str = "set bonding mac_addr (port_id) (address): ",
3732 (void *)&cmd_set_bond_mac_addr_set,
3733 (void *)&cmd_set_bond_mac_addr_bonding,
3734 (void *)&cmd_set_bond_mac_addr_mac,
3735 (void *)&cmd_set_bond_mac_addr_portnum,
3736 (void *)&cmd_set_bond_mac_addr_addr,
3741 #endif /* RTE_LIBRTE_PMD_BOND */
3743 /* *** SET FORWARDING MODE *** */
3744 struct cmd_set_fwd_mode_result {
3745 cmdline_fixed_string_t set;
3746 cmdline_fixed_string_t fwd;
3747 cmdline_fixed_string_t mode;
3750 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3751 __attribute__((unused)) struct cmdline *cl,
3752 __attribute__((unused)) void *data)
3754 struct cmd_set_fwd_mode_result *res = parsed_result;
3756 set_pkt_forwarding_mode(res->mode);
3759 cmdline_parse_token_string_t cmd_setfwd_set =
3760 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3761 cmdline_parse_token_string_t cmd_setfwd_fwd =
3762 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3763 cmdline_parse_token_string_t cmd_setfwd_mode =
3764 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3765 "" /* defined at init */);
3767 cmdline_parse_inst_t cmd_set_fwd_mode = {
3768 .f = cmd_set_fwd_mode_parsed,
3770 .help_str = NULL, /* defined at init */
3772 (void *)&cmd_setfwd_set,
3773 (void *)&cmd_setfwd_fwd,
3774 (void *)&cmd_setfwd_mode,
3779 static void cmd_set_fwd_mode_init(void)
3782 static char token[128];
3783 static char help[256];
3784 cmdline_parse_token_string_t *token_struct;
3786 modes = list_pkt_forwarding_modes();
3787 snprintf(help, sizeof help, "set fwd %s - "
3788 "set packet forwarding mode", modes);
3789 cmd_set_fwd_mode.help_str = help;
3791 /* string token separator is # */
3792 for (c = token; *modes != '\0'; modes++)
3797 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3798 token_struct->string_data.str = token;
3801 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3802 struct cmd_set_burst_tx_retry_result {
3803 cmdline_fixed_string_t set;
3804 cmdline_fixed_string_t burst;
3805 cmdline_fixed_string_t tx;
3806 cmdline_fixed_string_t delay;
3808 cmdline_fixed_string_t retry;
3812 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3813 __attribute__((unused)) struct cmdline *cl,
3814 __attribute__((unused)) void *data)
3816 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3818 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3819 && !strcmp(res->tx, "tx")) {
3820 if (!strcmp(res->delay, "delay"))
3821 burst_tx_delay_time = res->time;
3822 if (!strcmp(res->retry, "retry"))
3823 burst_tx_retry_num = res->retry_num;
3828 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3829 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3830 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3831 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3833 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3834 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3835 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3836 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3837 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3838 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3839 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3840 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3841 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3842 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3844 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3845 .f = cmd_set_burst_tx_retry_parsed,
3846 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3848 (void *)&cmd_set_burst_tx_retry_set,
3849 (void *)&cmd_set_burst_tx_retry_burst,
3850 (void *)&cmd_set_burst_tx_retry_tx,
3851 (void *)&cmd_set_burst_tx_retry_delay,
3852 (void *)&cmd_set_burst_tx_retry_time,
3853 (void *)&cmd_set_burst_tx_retry_retry,
3854 (void *)&cmd_set_burst_tx_retry_retry_num,
3859 /* *** SET PROMISC MODE *** */
3860 struct cmd_set_promisc_mode_result {
3861 cmdline_fixed_string_t set;
3862 cmdline_fixed_string_t promisc;
3863 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3864 uint8_t port_num; /* valid if "allports" argument == 0 */
3865 cmdline_fixed_string_t mode;
3868 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3869 __attribute__((unused)) struct cmdline *cl,
3872 struct cmd_set_promisc_mode_result *res = parsed_result;
3876 if (!strcmp(res->mode, "on"))
3883 for (i = 0; i < nb_ports; i++) {
3885 rte_eth_promiscuous_enable(i);
3887 rte_eth_promiscuous_disable(i);
3892 rte_eth_promiscuous_enable(res->port_num);
3894 rte_eth_promiscuous_disable(res->port_num);
3898 cmdline_parse_token_string_t cmd_setpromisc_set =
3899 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3900 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3901 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3903 cmdline_parse_token_string_t cmd_setpromisc_portall =
3904 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3906 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3907 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3909 cmdline_parse_token_string_t cmd_setpromisc_mode =
3910 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3913 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3914 .f = cmd_set_promisc_mode_parsed,
3916 .help_str = "set promisc all on|off: set promisc mode for all ports",
3918 (void *)&cmd_setpromisc_set,
3919 (void *)&cmd_setpromisc_promisc,
3920 (void *)&cmd_setpromisc_portall,
3921 (void *)&cmd_setpromisc_mode,
3926 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3927 .f = cmd_set_promisc_mode_parsed,
3929 .help_str = "set promisc X on|off: set promisc mode on port X",
3931 (void *)&cmd_setpromisc_set,
3932 (void *)&cmd_setpromisc_promisc,
3933 (void *)&cmd_setpromisc_portnum,
3934 (void *)&cmd_setpromisc_mode,
3939 /* *** SET ALLMULTI MODE *** */
3940 struct cmd_set_allmulti_mode_result {
3941 cmdline_fixed_string_t set;
3942 cmdline_fixed_string_t allmulti;
3943 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3944 uint8_t port_num; /* valid if "allports" argument == 0 */
3945 cmdline_fixed_string_t mode;
3948 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3949 __attribute__((unused)) struct cmdline *cl,
3952 struct cmd_set_allmulti_mode_result *res = parsed_result;
3956 if (!strcmp(res->mode, "on"))
3963 for (i = 0; i < nb_ports; i++) {
3965 rte_eth_allmulticast_enable(i);
3967 rte_eth_allmulticast_disable(i);
3972 rte_eth_allmulticast_enable(res->port_num);
3974 rte_eth_allmulticast_disable(res->port_num);
3978 cmdline_parse_token_string_t cmd_setallmulti_set =
3979 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3980 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3981 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3983 cmdline_parse_token_string_t cmd_setallmulti_portall =
3984 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3986 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3987 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3989 cmdline_parse_token_string_t cmd_setallmulti_mode =
3990 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3993 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3994 .f = cmd_set_allmulti_mode_parsed,
3996 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3998 (void *)&cmd_setallmulti_set,
3999 (void *)&cmd_setallmulti_allmulti,
4000 (void *)&cmd_setallmulti_portall,
4001 (void *)&cmd_setallmulti_mode,
4006 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4007 .f = cmd_set_allmulti_mode_parsed,
4009 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4011 (void *)&cmd_setallmulti_set,
4012 (void *)&cmd_setallmulti_allmulti,
4013 (void *)&cmd_setallmulti_portnum,
4014 (void *)&cmd_setallmulti_mode,
4019 /* *** ADD/REMOVE A PKT FILTER *** */
4020 struct cmd_pkt_filter_result {
4021 cmdline_fixed_string_t pkt_filter;
4023 cmdline_fixed_string_t protocol;
4024 cmdline_fixed_string_t src;
4025 cmdline_ipaddr_t ip_src;
4027 cmdline_fixed_string_t dst;
4028 cmdline_ipaddr_t ip_dst;
4030 cmdline_fixed_string_t flexbytes;
4031 uint16_t flexbytes_value;
4032 cmdline_fixed_string_t vlan;
4034 cmdline_fixed_string_t queue;
4036 cmdline_fixed_string_t soft;
4041 cmd_pkt_filter_parsed(void *parsed_result,
4042 __attribute__((unused)) struct cmdline *cl,
4043 __attribute__((unused)) void *data)
4045 struct rte_fdir_filter fdir_filter;
4046 struct cmd_pkt_filter_result *res = parsed_result;
4048 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4050 if (res->ip_src.family == AF_INET)
4051 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4053 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4054 &(res->ip_src.addr.ipv6),
4055 sizeof(struct in6_addr));
4057 if (res->ip_dst.family == AF_INET)
4058 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4060 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4061 &(res->ip_dst.addr.ipv6),
4062 sizeof(struct in6_addr));
4064 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4065 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4067 if (!strcmp(res->protocol, "udp"))
4068 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4069 else if (!strcmp(res->protocol, "tcp"))
4070 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4071 else if (!strcmp(res->protocol, "sctp"))
4072 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4073 else /* default only IP */
4074 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4076 if (res->ip_dst.family == AF_INET6)
4077 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4079 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4081 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4082 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4084 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4085 fdir_add_signature_filter(res->port_id, res->queue_id,
4087 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4088 fdir_update_signature_filter(res->port_id, res->queue_id,
4090 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4091 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4092 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4093 fdir_add_perfect_filter(res->port_id, res->soft_id,
4095 (uint8_t) (res->queue_id < 0),
4097 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4098 fdir_update_perfect_filter(res->port_id, res->soft_id,
4100 (uint8_t) (res->queue_id < 0),
4102 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4103 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4109 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4110 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4112 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4113 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4114 protocol, "ip#tcp#udp#sctp");
4115 cmdline_parse_token_string_t cmd_pkt_filter_src =
4116 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4118 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4119 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4121 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4122 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4124 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4125 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4127 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4128 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4130 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4131 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4133 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4134 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4135 flexbytes, "flexbytes");
4136 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4137 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4138 flexbytes_value, UINT16);
4139 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4140 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4142 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4143 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4145 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4146 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4148 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4149 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4151 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4152 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4154 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4155 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4159 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4160 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4161 pkt_filter, "add_signature_filter");
4162 cmdline_parse_inst_t cmd_add_signature_filter = {
4163 .f = cmd_pkt_filter_parsed,
4165 .help_str = "add a signature filter",
4167 (void *)&cmd_pkt_filter_add_signature_filter,
4168 (void *)&cmd_pkt_filter_port_id,
4169 (void *)&cmd_pkt_filter_protocol,
4170 (void *)&cmd_pkt_filter_src,
4171 (void *)&cmd_pkt_filter_ip_src,
4172 (void *)&cmd_pkt_filter_port_src,
4173 (void *)&cmd_pkt_filter_dst,
4174 (void *)&cmd_pkt_filter_ip_dst,
4175 (void *)&cmd_pkt_filter_port_dst,
4176 (void *)&cmd_pkt_filter_flexbytes,
4177 (void *)&cmd_pkt_filter_flexbytes_value,
4178 (void *)&cmd_pkt_filter_vlan,
4179 (void *)&cmd_pkt_filter_vlan_id,
4180 (void *)&cmd_pkt_filter_queue,
4181 (void *)&cmd_pkt_filter_queue_id,
4187 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4188 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4189 pkt_filter, "upd_signature_filter");
4190 cmdline_parse_inst_t cmd_upd_signature_filter = {
4191 .f = cmd_pkt_filter_parsed,
4193 .help_str = "update a signature filter",
4195 (void *)&cmd_pkt_filter_upd_signature_filter,
4196 (void *)&cmd_pkt_filter_port_id,
4197 (void *)&cmd_pkt_filter_protocol,
4198 (void *)&cmd_pkt_filter_src,
4199 (void *)&cmd_pkt_filter_ip_src,
4200 (void *)&cmd_pkt_filter_port_src,
4201 (void *)&cmd_pkt_filter_dst,
4202 (void *)&cmd_pkt_filter_ip_dst,
4203 (void *)&cmd_pkt_filter_port_dst,
4204 (void *)&cmd_pkt_filter_flexbytes,
4205 (void *)&cmd_pkt_filter_flexbytes_value,
4206 (void *)&cmd_pkt_filter_vlan,
4207 (void *)&cmd_pkt_filter_vlan_id,
4208 (void *)&cmd_pkt_filter_queue,
4209 (void *)&cmd_pkt_filter_queue_id,
4215 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4216 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4217 pkt_filter, "rm_signature_filter");
4218 cmdline_parse_inst_t cmd_rm_signature_filter = {
4219 .f = cmd_pkt_filter_parsed,
4221 .help_str = "remove a signature filter",
4223 (void *)&cmd_pkt_filter_rm_signature_filter,
4224 (void *)&cmd_pkt_filter_port_id,
4225 (void *)&cmd_pkt_filter_protocol,
4226 (void *)&cmd_pkt_filter_src,
4227 (void *)&cmd_pkt_filter_ip_src,
4228 (void *)&cmd_pkt_filter_port_src,
4229 (void *)&cmd_pkt_filter_dst,
4230 (void *)&cmd_pkt_filter_ip_dst,
4231 (void *)&cmd_pkt_filter_port_dst,
4232 (void *)&cmd_pkt_filter_flexbytes,
4233 (void *)&cmd_pkt_filter_flexbytes_value,
4234 (void *)&cmd_pkt_filter_vlan,
4235 (void *)&cmd_pkt_filter_vlan_id,
4241 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4242 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4243 pkt_filter, "add_perfect_filter");
4244 cmdline_parse_inst_t cmd_add_perfect_filter = {
4245 .f = cmd_pkt_filter_parsed,
4247 .help_str = "add a perfect filter",
4249 (void *)&cmd_pkt_filter_add_perfect_filter,
4250 (void *)&cmd_pkt_filter_port_id,
4251 (void *)&cmd_pkt_filter_protocol,
4252 (void *)&cmd_pkt_filter_src,
4253 (void *)&cmd_pkt_filter_ip_src,
4254 (void *)&cmd_pkt_filter_port_src,
4255 (void *)&cmd_pkt_filter_dst,
4256 (void *)&cmd_pkt_filter_ip_dst,
4257 (void *)&cmd_pkt_filter_port_dst,
4258 (void *)&cmd_pkt_filter_flexbytes,
4259 (void *)&cmd_pkt_filter_flexbytes_value,
4260 (void *)&cmd_pkt_filter_vlan,
4261 (void *)&cmd_pkt_filter_vlan_id,
4262 (void *)&cmd_pkt_filter_queue,
4263 (void *)&cmd_pkt_filter_queue_id,
4264 (void *)&cmd_pkt_filter_soft,
4265 (void *)&cmd_pkt_filter_soft_id,
4271 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4272 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4273 pkt_filter, "upd_perfect_filter");
4274 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4275 .f = cmd_pkt_filter_parsed,
4277 .help_str = "update a perfect filter",
4279 (void *)&cmd_pkt_filter_upd_perfect_filter,
4280 (void *)&cmd_pkt_filter_port_id,
4281 (void *)&cmd_pkt_filter_protocol,
4282 (void *)&cmd_pkt_filter_src,
4283 (void *)&cmd_pkt_filter_ip_src,
4284 (void *)&cmd_pkt_filter_port_src,
4285 (void *)&cmd_pkt_filter_dst,
4286 (void *)&cmd_pkt_filter_ip_dst,
4287 (void *)&cmd_pkt_filter_port_dst,
4288 (void *)&cmd_pkt_filter_flexbytes,
4289 (void *)&cmd_pkt_filter_flexbytes_value,
4290 (void *)&cmd_pkt_filter_vlan,
4291 (void *)&cmd_pkt_filter_vlan_id,
4292 (void *)&cmd_pkt_filter_queue,
4293 (void *)&cmd_pkt_filter_queue_id,
4294 (void *)&cmd_pkt_filter_soft,
4295 (void *)&cmd_pkt_filter_soft_id,
4301 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4302 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4303 pkt_filter, "rm_perfect_filter");
4304 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4305 .f = cmd_pkt_filter_parsed,
4307 .help_str = "remove a perfect filter",
4309 (void *)&cmd_pkt_filter_rm_perfect_filter,
4310 (void *)&cmd_pkt_filter_port_id,
4311 (void *)&cmd_pkt_filter_protocol,
4312 (void *)&cmd_pkt_filter_src,
4313 (void *)&cmd_pkt_filter_ip_src,
4314 (void *)&cmd_pkt_filter_port_src,
4315 (void *)&cmd_pkt_filter_dst,
4316 (void *)&cmd_pkt_filter_ip_dst,
4317 (void *)&cmd_pkt_filter_port_dst,
4318 (void *)&cmd_pkt_filter_flexbytes,
4319 (void *)&cmd_pkt_filter_flexbytes_value,
4320 (void *)&cmd_pkt_filter_vlan,
4321 (void *)&cmd_pkt_filter_vlan_id,
4322 (void *)&cmd_pkt_filter_soft,
4323 (void *)&cmd_pkt_filter_soft_id,
4328 /* *** SETUP MASKS FILTER *** */
4329 struct cmd_pkt_filter_masks_result {
4330 cmdline_fixed_string_t filter_mask;
4332 cmdline_fixed_string_t src_mask;
4333 uint32_t ip_src_mask;
4334 uint16_t ipv6_src_mask;
4335 uint16_t port_src_mask;
4336 cmdline_fixed_string_t dst_mask;
4337 uint32_t ip_dst_mask;
4338 uint16_t ipv6_dst_mask;
4339 uint16_t port_dst_mask;
4340 cmdline_fixed_string_t flexbytes;
4341 uint8_t flexbytes_value;
4342 cmdline_fixed_string_t vlan_id;
4343 uint8_t vlan_id_value;
4344 cmdline_fixed_string_t vlan_prio;
4345 uint8_t vlan_prio_value;
4346 cmdline_fixed_string_t only_ip_flow;
4347 uint8_t only_ip_flow_value;
4348 cmdline_fixed_string_t comp_ipv6_dst;
4349 uint8_t comp_ipv6_dst_value;
4353 cmd_pkt_filter_masks_parsed(void *parsed_result,
4354 __attribute__((unused)) struct cmdline *cl,
4355 __attribute__((unused)) void *data)
4357 struct rte_fdir_masks fdir_masks;
4358 struct cmd_pkt_filter_masks_result *res = parsed_result;
4360 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4362 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4363 fdir_masks.vlan_id = res->vlan_id_value;
4364 fdir_masks.vlan_prio = res->vlan_prio_value;
4365 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4366 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4367 fdir_masks.src_port_mask = res->port_src_mask;
4368 fdir_masks.dst_port_mask = res->port_dst_mask;
4369 fdir_masks.flexbytes = res->flexbytes_value;
4371 fdir_set_masks(res->port_id, &fdir_masks);
4374 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4375 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4376 filter_mask, "set_masks_filter");
4377 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4378 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4380 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4381 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4382 only_ip_flow, "only_ip_flow");
4383 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4384 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4385 only_ip_flow_value, UINT8);
4386 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4387 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4388 src_mask, "src_mask");
4389 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4390 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4391 ip_src_mask, UINT32);
4392 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4393 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4394 port_src_mask, UINT16);
4395 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4396 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4397 dst_mask, "dst_mask");
4398 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4399 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4400 ip_dst_mask, UINT32);
4401 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4402 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4403 port_dst_mask, UINT16);
4404 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4405 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4406 flexbytes, "flexbytes");
4407 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4408 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4409 flexbytes_value, UINT8);
4410 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4411 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4412 vlan_id, "vlan_id");
4413 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4414 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4415 vlan_id_value, UINT8);
4416 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4417 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4418 vlan_prio, "vlan_prio");
4419 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4420 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4421 vlan_prio_value, UINT8);
4423 cmdline_parse_inst_t cmd_set_masks_filter = {
4424 .f = cmd_pkt_filter_masks_parsed,
4426 .help_str = "setup masks filter",
4428 (void *)&cmd_pkt_filter_masks_filter_mask,
4429 (void *)&cmd_pkt_filter_masks_port_id,
4430 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4431 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4432 (void *)&cmd_pkt_filter_masks_src_mask,
4433 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4434 (void *)&cmd_pkt_filter_masks_port_src_mask,
4435 (void *)&cmd_pkt_filter_masks_dst_mask,
4436 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4437 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4438 (void *)&cmd_pkt_filter_masks_flexbytes,
4439 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4440 (void *)&cmd_pkt_filter_masks_vlan_id,
4441 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4442 (void *)&cmd_pkt_filter_masks_vlan_prio,
4443 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4449 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4450 __attribute__((unused)) struct cmdline *cl,
4451 __attribute__((unused)) void *data)
4453 struct rte_fdir_masks fdir_masks;
4454 struct cmd_pkt_filter_masks_result *res = parsed_result;
4456 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4458 fdir_masks.set_ipv6_mask = 1;
4459 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4460 fdir_masks.vlan_id = res->vlan_id_value;
4461 fdir_masks.vlan_prio = res->vlan_prio_value;
4462 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4463 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4464 fdir_masks.src_port_mask = res->port_src_mask;
4465 fdir_masks.dst_port_mask = res->port_dst_mask;
4466 fdir_masks.flexbytes = res->flexbytes_value;
4467 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4469 fdir_set_masks(res->port_id, &fdir_masks);
4472 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4473 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4474 filter_mask, "set_ipv6_masks_filter");
4475 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4476 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4477 ipv6_src_mask, UINT16);
4478 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4479 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4480 ipv6_dst_mask, UINT16);
4482 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4483 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4484 comp_ipv6_dst, "compare_dst");
4485 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4486 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4487 comp_ipv6_dst_value, UINT8);
4489 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4490 .f = cmd_pkt_filter_masks_ipv6_parsed,
4492 .help_str = "setup ipv6 masks filter",
4494 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4495 (void *)&cmd_pkt_filter_masks_port_id,
4496 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4497 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4498 (void *)&cmd_pkt_filter_masks_src_mask,
4499 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4500 (void *)&cmd_pkt_filter_masks_port_src_mask,
4501 (void *)&cmd_pkt_filter_masks_dst_mask,
4502 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4503 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4504 (void *)&cmd_pkt_filter_masks_flexbytes,
4505 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4506 (void *)&cmd_pkt_filter_masks_vlan_id,
4507 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4508 (void *)&cmd_pkt_filter_masks_vlan_prio,
4509 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4510 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4511 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4516 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4517 struct cmd_link_flow_ctrl_set_result {
4518 cmdline_fixed_string_t set;
4519 cmdline_fixed_string_t flow_ctrl;
4520 cmdline_fixed_string_t rx;
4521 cmdline_fixed_string_t rx_lfc_mode;
4522 cmdline_fixed_string_t tx;
4523 cmdline_fixed_string_t tx_lfc_mode;
4524 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4525 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4526 cmdline_fixed_string_t autoneg_str;
4527 cmdline_fixed_string_t autoneg;
4528 cmdline_fixed_string_t hw_str;
4529 uint32_t high_water;
4530 cmdline_fixed_string_t lw_str;
4532 cmdline_fixed_string_t pt_str;
4533 uint16_t pause_time;
4534 cmdline_fixed_string_t xon_str;
4539 cmdline_parse_token_string_t cmd_lfc_set_set =
4540 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4542 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4543 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4544 flow_ctrl, "flow_ctrl");
4545 cmdline_parse_token_string_t cmd_lfc_set_rx =
4546 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4548 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4549 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4550 rx_lfc_mode, "on#off");
4551 cmdline_parse_token_string_t cmd_lfc_set_tx =
4552 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4554 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4555 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4556 tx_lfc_mode, "on#off");
4557 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4558 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4559 hw_str, "high_water");
4560 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4561 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4562 high_water, UINT32);
4563 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4564 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4565 lw_str, "low_water");
4566 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4567 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4569 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4570 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4571 pt_str, "pause_time");
4572 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4573 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4574 pause_time, UINT16);
4575 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4576 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4577 xon_str, "send_xon");
4578 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4579 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4581 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4582 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4583 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4584 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4585 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4586 mac_ctrl_frame_fwd_mode, "on#off");
4587 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4588 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4589 autoneg_str, "autoneg");
4590 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4591 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4593 cmdline_parse_token_num_t cmd_lfc_set_portid =
4594 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4597 /* forward declaration */
4599 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4602 cmdline_parse_inst_t cmd_link_flow_control_set = {
4603 .f = cmd_link_flow_ctrl_set_parsed,
4605 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4606 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4607 autoneg on|off port_id",
4609 (void *)&cmd_lfc_set_set,
4610 (void *)&cmd_lfc_set_flow_ctrl,
4611 (void *)&cmd_lfc_set_rx,
4612 (void *)&cmd_lfc_set_rx_mode,
4613 (void *)&cmd_lfc_set_tx,
4614 (void *)&cmd_lfc_set_tx_mode,
4615 (void *)&cmd_lfc_set_high_water,
4616 (void *)&cmd_lfc_set_low_water,
4617 (void *)&cmd_lfc_set_pause_time,
4618 (void *)&cmd_lfc_set_send_xon,
4619 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4620 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4621 (void *)&cmd_lfc_set_autoneg_str,
4622 (void *)&cmd_lfc_set_autoneg,
4623 (void *)&cmd_lfc_set_portid,
4628 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4629 .f = cmd_link_flow_ctrl_set_parsed,
4630 .data = (void *)&cmd_link_flow_control_set_rx,
4631 .help_str = "Change rx flow control parameter: set flow_ctrl "
4632 "rx on|off port_id",
4634 (void *)&cmd_lfc_set_set,
4635 (void *)&cmd_lfc_set_flow_ctrl,
4636 (void *)&cmd_lfc_set_rx,
4637 (void *)&cmd_lfc_set_rx_mode,
4638 (void *)&cmd_lfc_set_portid,
4643 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4644 .f = cmd_link_flow_ctrl_set_parsed,
4645 .data = (void *)&cmd_link_flow_control_set_tx,
4646 .help_str = "Change tx flow control parameter: set flow_ctrl "
4647 "tx on|off port_id",
4649 (void *)&cmd_lfc_set_set,
4650 (void *)&cmd_lfc_set_flow_ctrl,
4651 (void *)&cmd_lfc_set_tx,
4652 (void *)&cmd_lfc_set_tx_mode,
4653 (void *)&cmd_lfc_set_portid,
4658 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4659 .f = cmd_link_flow_ctrl_set_parsed,
4660 .data = (void *)&cmd_link_flow_control_set_hw,
4661 .help_str = "Change high water flow control parameter: set flow_ctrl "
4662 "high_water value port_id",
4664 (void *)&cmd_lfc_set_set,
4665 (void *)&cmd_lfc_set_flow_ctrl,
4666 (void *)&cmd_lfc_set_high_water_str,
4667 (void *)&cmd_lfc_set_high_water,
4668 (void *)&cmd_lfc_set_portid,
4673 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4674 .f = cmd_link_flow_ctrl_set_parsed,
4675 .data = (void *)&cmd_link_flow_control_set_lw,
4676 .help_str = "Change low water flow control parameter: set flow_ctrl "
4677 "low_water value port_id",
4679 (void *)&cmd_lfc_set_set,
4680 (void *)&cmd_lfc_set_flow_ctrl,
4681 (void *)&cmd_lfc_set_low_water_str,
4682 (void *)&cmd_lfc_set_low_water,
4683 (void *)&cmd_lfc_set_portid,
4688 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4689 .f = cmd_link_flow_ctrl_set_parsed,
4690 .data = (void *)&cmd_link_flow_control_set_pt,
4691 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4692 "pause_time value port_id",
4694 (void *)&cmd_lfc_set_set,
4695 (void *)&cmd_lfc_set_flow_ctrl,
4696 (void *)&cmd_lfc_set_pause_time_str,
4697 (void *)&cmd_lfc_set_pause_time,
4698 (void *)&cmd_lfc_set_portid,
4703 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4704 .f = cmd_link_flow_ctrl_set_parsed,
4705 .data = (void *)&cmd_link_flow_control_set_xon,
4706 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4707 "send_xon value port_id",
4709 (void *)&cmd_lfc_set_set,
4710 (void *)&cmd_lfc_set_flow_ctrl,
4711 (void *)&cmd_lfc_set_send_xon_str,
4712 (void *)&cmd_lfc_set_send_xon,
4713 (void *)&cmd_lfc_set_portid,
4718 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4719 .f = cmd_link_flow_ctrl_set_parsed,
4720 .data = (void *)&cmd_link_flow_control_set_macfwd,
4721 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4722 "mac_ctrl_frame_fwd on|off port_id",
4724 (void *)&cmd_lfc_set_set,
4725 (void *)&cmd_lfc_set_flow_ctrl,
4726 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4727 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4728 (void *)&cmd_lfc_set_portid,
4733 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4734 .f = cmd_link_flow_ctrl_set_parsed,
4735 .data = (void *)&cmd_link_flow_control_set_autoneg,
4736 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4737 "autoneg on|off port_id",
4739 (void *)&cmd_lfc_set_set,
4740 (void *)&cmd_lfc_set_flow_ctrl,
4741 (void *)&cmd_lfc_set_autoneg_str,
4742 (void *)&cmd_lfc_set_autoneg,
4743 (void *)&cmd_lfc_set_portid,
4749 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4750 __attribute__((unused)) struct cmdline *cl,
4753 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4754 cmdline_parse_inst_t *cmd = data;
4755 struct rte_eth_fc_conf fc_conf;
4756 int rx_fc_en, tx_fc_en;
4760 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4761 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4762 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4763 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4765 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4766 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4769 /* Partial command line, retrieve current configuration */
4771 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4773 printf("cannot get current flow ctrl parameters, return"
4774 "code = %d\n", ret);
4778 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4779 (fc_conf.mode == RTE_FC_FULL))
4781 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4782 (fc_conf.mode == RTE_FC_FULL))
4786 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4787 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4789 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4790 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4792 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4794 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4795 fc_conf.high_water = res->high_water;
4797 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4798 fc_conf.low_water = res->low_water;
4800 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4801 fc_conf.pause_time = res->pause_time;
4803 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4804 fc_conf.send_xon = res->send_xon;
4806 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4807 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4808 fc_conf.mac_ctrl_frame_fwd = 1;
4810 fc_conf.mac_ctrl_frame_fwd = 0;
4813 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4814 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4816 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4818 printf("bad flow contrl parameter, return code = %d \n", ret);
4821 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4822 struct cmd_priority_flow_ctrl_set_result {
4823 cmdline_fixed_string_t set;
4824 cmdline_fixed_string_t pfc_ctrl;
4825 cmdline_fixed_string_t rx;
4826 cmdline_fixed_string_t rx_pfc_mode;
4827 cmdline_fixed_string_t tx;
4828 cmdline_fixed_string_t tx_pfc_mode;
4829 uint32_t high_water;
4831 uint16_t pause_time;
4837 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4838 __attribute__((unused)) struct cmdline *cl,
4839 __attribute__((unused)) void *data)
4841 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4842 struct rte_eth_pfc_conf pfc_conf;
4843 int rx_fc_enable, tx_fc_enable;
4847 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4848 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4849 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4850 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4852 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4853 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4856 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4857 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4858 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4859 pfc_conf.fc.high_water = res->high_water;
4860 pfc_conf.fc.low_water = res->low_water;
4861 pfc_conf.fc.pause_time = res->pause_time;
4862 pfc_conf.priority = res->priority;
4864 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4866 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4869 cmdline_parse_token_string_t cmd_pfc_set_set =
4870 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4872 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4873 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4874 pfc_ctrl, "pfc_ctrl");
4875 cmdline_parse_token_string_t cmd_pfc_set_rx =
4876 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4878 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4879 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4880 rx_pfc_mode, "on#off");
4881 cmdline_parse_token_string_t cmd_pfc_set_tx =
4882 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4884 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4885 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4886 tx_pfc_mode, "on#off");
4887 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4888 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4889 high_water, UINT32);
4890 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4891 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4893 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4894 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4895 pause_time, UINT16);
4896 cmdline_parse_token_num_t cmd_pfc_set_priority =
4897 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4899 cmdline_parse_token_num_t cmd_pfc_set_portid =
4900 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4903 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4904 .f = cmd_priority_flow_ctrl_set_parsed,
4906 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4907 tx on|off high_water low_water pause_time priority port_id",
4909 (void *)&cmd_pfc_set_set,
4910 (void *)&cmd_pfc_set_flow_ctrl,
4911 (void *)&cmd_pfc_set_rx,
4912 (void *)&cmd_pfc_set_rx_mode,
4913 (void *)&cmd_pfc_set_tx,
4914 (void *)&cmd_pfc_set_tx_mode,
4915 (void *)&cmd_pfc_set_high_water,
4916 (void *)&cmd_pfc_set_low_water,
4917 (void *)&cmd_pfc_set_pause_time,
4918 (void *)&cmd_pfc_set_priority,
4919 (void *)&cmd_pfc_set_portid,
4924 /* *** RESET CONFIGURATION *** */
4925 struct cmd_reset_result {
4926 cmdline_fixed_string_t reset;
4927 cmdline_fixed_string_t def;
4930 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4932 __attribute__((unused)) void *data)
4934 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4935 set_def_fwd_config();
4938 cmdline_parse_token_string_t cmd_reset_set =
4939 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4940 cmdline_parse_token_string_t cmd_reset_def =
4941 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4944 cmdline_parse_inst_t cmd_reset = {
4945 .f = cmd_reset_parsed,
4947 .help_str = "set default: reset default forwarding configuration",
4949 (void *)&cmd_reset_set,
4950 (void *)&cmd_reset_def,
4955 /* *** START FORWARDING *** */
4956 struct cmd_start_result {
4957 cmdline_fixed_string_t start;
4960 cmdline_parse_token_string_t cmd_start_start =
4961 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4963 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4964 __attribute__((unused)) struct cmdline *cl,
4965 __attribute__((unused)) void *data)
4967 start_packet_forwarding(0);
4970 cmdline_parse_inst_t cmd_start = {
4971 .f = cmd_start_parsed,
4973 .help_str = "start packet forwarding",
4975 (void *)&cmd_start_start,
4980 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4981 struct cmd_start_tx_first_result {
4982 cmdline_fixed_string_t start;
4983 cmdline_fixed_string_t tx_first;
4987 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4988 __attribute__((unused)) struct cmdline *cl,
4989 __attribute__((unused)) void *data)
4991 start_packet_forwarding(1);
4994 cmdline_parse_token_string_t cmd_start_tx_first_start =
4995 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4997 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4998 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4999 tx_first, "tx_first");
5001 cmdline_parse_inst_t cmd_start_tx_first = {
5002 .f = cmd_start_tx_first_parsed,
5004 .help_str = "start packet forwarding, after sending 1 burst of packets",
5006 (void *)&cmd_start_tx_first_start,
5007 (void *)&cmd_start_tx_first_tx_first,
5012 /* *** SET LINK UP *** */
5013 struct cmd_set_link_up_result {
5014 cmdline_fixed_string_t set;
5015 cmdline_fixed_string_t link_up;
5016 cmdline_fixed_string_t port;
5020 cmdline_parse_token_string_t cmd_set_link_up_set =
5021 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5022 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5023 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5025 cmdline_parse_token_string_t cmd_set_link_up_port =
5026 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5027 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5028 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5030 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5031 __attribute__((unused)) struct cmdline *cl,
5032 __attribute__((unused)) void *data)
5034 struct cmd_set_link_up_result *res = parsed_result;
5035 dev_set_link_up(res->port_id);
5038 cmdline_parse_inst_t cmd_set_link_up = {
5039 .f = cmd_set_link_up_parsed,
5041 .help_str = "set link-up port (port id)",
5043 (void *)&cmd_set_link_up_set,
5044 (void *)&cmd_set_link_up_link_up,
5045 (void *)&cmd_set_link_up_port,
5046 (void *)&cmd_set_link_up_port_id,
5051 /* *** SET LINK DOWN *** */
5052 struct cmd_set_link_down_result {
5053 cmdline_fixed_string_t set;
5054 cmdline_fixed_string_t link_down;
5055 cmdline_fixed_string_t port;
5059 cmdline_parse_token_string_t cmd_set_link_down_set =
5060 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5061 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5062 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5064 cmdline_parse_token_string_t cmd_set_link_down_port =
5065 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5066 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5067 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5069 static void cmd_set_link_down_parsed(
5070 __attribute__((unused)) void *parsed_result,
5071 __attribute__((unused)) struct cmdline *cl,
5072 __attribute__((unused)) void *data)
5074 struct cmd_set_link_down_result *res = parsed_result;
5075 dev_set_link_down(res->port_id);
5078 cmdline_parse_inst_t cmd_set_link_down = {
5079 .f = cmd_set_link_down_parsed,
5081 .help_str = "set link-down port (port id)",
5083 (void *)&cmd_set_link_down_set,
5084 (void *)&cmd_set_link_down_link_down,
5085 (void *)&cmd_set_link_down_port,
5086 (void *)&cmd_set_link_down_port_id,
5091 /* *** SHOW CFG *** */
5092 struct cmd_showcfg_result {
5093 cmdline_fixed_string_t show;
5094 cmdline_fixed_string_t cfg;
5095 cmdline_fixed_string_t what;
5098 static void cmd_showcfg_parsed(void *parsed_result,
5099 __attribute__((unused)) struct cmdline *cl,
5100 __attribute__((unused)) void *data)
5102 struct cmd_showcfg_result *res = parsed_result;
5103 if (!strcmp(res->what, "rxtx"))
5104 rxtx_config_display();
5105 else if (!strcmp(res->what, "cores"))
5106 fwd_lcores_config_display();
5107 else if (!strcmp(res->what, "fwd"))
5108 fwd_config_display();
5111 cmdline_parse_token_string_t cmd_showcfg_show =
5112 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5113 cmdline_parse_token_string_t cmd_showcfg_port =
5114 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5115 cmdline_parse_token_string_t cmd_showcfg_what =
5116 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5119 cmdline_parse_inst_t cmd_showcfg = {
5120 .f = cmd_showcfg_parsed,
5122 .help_str = "show config rxtx|cores|fwd",
5124 (void *)&cmd_showcfg_show,
5125 (void *)&cmd_showcfg_port,
5126 (void *)&cmd_showcfg_what,
5131 /* *** SHOW ALL PORT INFO *** */
5132 struct cmd_showportall_result {
5133 cmdline_fixed_string_t show;
5134 cmdline_fixed_string_t port;
5135 cmdline_fixed_string_t what;
5136 cmdline_fixed_string_t all;
5139 static void cmd_showportall_parsed(void *parsed_result,
5140 __attribute__((unused)) struct cmdline *cl,
5141 __attribute__((unused)) void *data)
5145 struct cmd_showportall_result *res = parsed_result;
5146 if (!strcmp(res->show, "clear")) {
5147 if (!strcmp(res->what, "stats"))
5148 for (i = 0; i < nb_ports; i++)
5150 else if (!strcmp(res->what, "xstats"))
5151 for (i = 0; i < nb_ports; i++)
5152 nic_xstats_clear(i);
5153 } else if (!strcmp(res->what, "info"))
5154 for (i = 0; i < nb_ports; i++)
5155 port_infos_display(i);
5156 else if (!strcmp(res->what, "stats"))
5157 for (i = 0; i < nb_ports; i++)
5158 nic_stats_display(i);
5159 else if (!strcmp(res->what, "xstats"))
5160 for (i = 0; i < nb_ports; i++)
5161 nic_xstats_display(i);
5162 else if (!strcmp(res->what, "fdir"))
5163 for (i = 0; i < nb_ports; i++)
5165 else if (!strcmp(res->what, "stat_qmap"))
5166 for (i = 0; i < nb_ports; i++)
5167 nic_stats_mapping_display(i);
5170 cmdline_parse_token_string_t cmd_showportall_show =
5171 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5173 cmdline_parse_token_string_t cmd_showportall_port =
5174 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5175 cmdline_parse_token_string_t cmd_showportall_what =
5176 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5177 "info#stats#xstats#fdir#stat_qmap");
5178 cmdline_parse_token_string_t cmd_showportall_all =
5179 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5180 cmdline_parse_inst_t cmd_showportall = {
5181 .f = cmd_showportall_parsed,
5183 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5185 (void *)&cmd_showportall_show,
5186 (void *)&cmd_showportall_port,
5187 (void *)&cmd_showportall_what,
5188 (void *)&cmd_showportall_all,
5193 /* *** SHOW PORT INFO *** */
5194 struct cmd_showport_result {
5195 cmdline_fixed_string_t show;
5196 cmdline_fixed_string_t port;
5197 cmdline_fixed_string_t what;
5201 static void cmd_showport_parsed(void *parsed_result,
5202 __attribute__((unused)) struct cmdline *cl,
5203 __attribute__((unused)) void *data)
5205 struct cmd_showport_result *res = parsed_result;
5206 if (!strcmp(res->show, "clear")) {
5207 if (!strcmp(res->what, "stats"))
5208 nic_stats_clear(res->portnum);
5209 else if (!strcmp(res->what, "xstats"))
5210 nic_xstats_clear(res->portnum);
5211 } else if (!strcmp(res->what, "info"))
5212 port_infos_display(res->portnum);
5213 else if (!strcmp(res->what, "stats"))
5214 nic_stats_display(res->portnum);
5215 else if (!strcmp(res->what, "xstats"))
5216 nic_xstats_display(res->portnum);
5217 else if (!strcmp(res->what, "fdir"))
5218 fdir_get_infos(res->portnum);
5219 else if (!strcmp(res->what, "stat_qmap"))
5220 nic_stats_mapping_display(res->portnum);
5223 cmdline_parse_token_string_t cmd_showport_show =
5224 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5226 cmdline_parse_token_string_t cmd_showport_port =
5227 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5228 cmdline_parse_token_string_t cmd_showport_what =
5229 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5230 "info#stats#xstats#fdir#stat_qmap");
5231 cmdline_parse_token_num_t cmd_showport_portnum =
5232 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5234 cmdline_parse_inst_t cmd_showport = {
5235 .f = cmd_showport_parsed,
5237 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5239 (void *)&cmd_showport_show,
5240 (void *)&cmd_showport_port,
5241 (void *)&cmd_showport_what,
5242 (void *)&cmd_showport_portnum,
5247 /* *** READ PORT REGISTER *** */
5248 struct cmd_read_reg_result {
5249 cmdline_fixed_string_t read;
5250 cmdline_fixed_string_t reg;
5256 cmd_read_reg_parsed(void *parsed_result,
5257 __attribute__((unused)) struct cmdline *cl,
5258 __attribute__((unused)) void *data)
5260 struct cmd_read_reg_result *res = parsed_result;
5261 port_reg_display(res->port_id, res->reg_off);
5264 cmdline_parse_token_string_t cmd_read_reg_read =
5265 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5266 cmdline_parse_token_string_t cmd_read_reg_reg =
5267 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5268 cmdline_parse_token_num_t cmd_read_reg_port_id =
5269 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5270 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5271 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5273 cmdline_parse_inst_t cmd_read_reg = {
5274 .f = cmd_read_reg_parsed,
5276 .help_str = "read reg port_id reg_off",
5278 (void *)&cmd_read_reg_read,
5279 (void *)&cmd_read_reg_reg,
5280 (void *)&cmd_read_reg_port_id,
5281 (void *)&cmd_read_reg_reg_off,
5286 /* *** READ PORT REGISTER BIT FIELD *** */
5287 struct cmd_read_reg_bit_field_result {
5288 cmdline_fixed_string_t read;
5289 cmdline_fixed_string_t regfield;
5297 cmd_read_reg_bit_field_parsed(void *parsed_result,
5298 __attribute__((unused)) struct cmdline *cl,
5299 __attribute__((unused)) void *data)
5301 struct cmd_read_reg_bit_field_result *res = parsed_result;
5302 port_reg_bit_field_display(res->port_id, res->reg_off,
5303 res->bit1_pos, res->bit2_pos);
5306 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5307 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5309 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5310 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5311 regfield, "regfield");
5312 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5313 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5315 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5316 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5318 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5319 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5321 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5322 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5325 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5326 .f = cmd_read_reg_bit_field_parsed,
5328 .help_str = "read regfield port_id reg_off bit_x bit_y "
5329 "(read register bit field between bit_x and bit_y included)",
5331 (void *)&cmd_read_reg_bit_field_read,
5332 (void *)&cmd_read_reg_bit_field_regfield,
5333 (void *)&cmd_read_reg_bit_field_port_id,
5334 (void *)&cmd_read_reg_bit_field_reg_off,
5335 (void *)&cmd_read_reg_bit_field_bit1_pos,
5336 (void *)&cmd_read_reg_bit_field_bit2_pos,
5341 /* *** READ PORT REGISTER BIT *** */
5342 struct cmd_read_reg_bit_result {
5343 cmdline_fixed_string_t read;
5344 cmdline_fixed_string_t regbit;
5351 cmd_read_reg_bit_parsed(void *parsed_result,
5352 __attribute__((unused)) struct cmdline *cl,
5353 __attribute__((unused)) void *data)
5355 struct cmd_read_reg_bit_result *res = parsed_result;
5356 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5359 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5360 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5361 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5362 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5364 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5365 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5366 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5367 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5368 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5369 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5371 cmdline_parse_inst_t cmd_read_reg_bit = {
5372 .f = cmd_read_reg_bit_parsed,
5374 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5376 (void *)&cmd_read_reg_bit_read,
5377 (void *)&cmd_read_reg_bit_regbit,
5378 (void *)&cmd_read_reg_bit_port_id,
5379 (void *)&cmd_read_reg_bit_reg_off,
5380 (void *)&cmd_read_reg_bit_bit_pos,
5385 /* *** WRITE PORT REGISTER *** */
5386 struct cmd_write_reg_result {
5387 cmdline_fixed_string_t write;
5388 cmdline_fixed_string_t reg;
5395 cmd_write_reg_parsed(void *parsed_result,
5396 __attribute__((unused)) struct cmdline *cl,
5397 __attribute__((unused)) void *data)
5399 struct cmd_write_reg_result *res = parsed_result;
5400 port_reg_set(res->port_id, res->reg_off, res->value);
5403 cmdline_parse_token_string_t cmd_write_reg_write =
5404 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5405 cmdline_parse_token_string_t cmd_write_reg_reg =
5406 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5407 cmdline_parse_token_num_t cmd_write_reg_port_id =
5408 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5409 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5410 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5411 cmdline_parse_token_num_t cmd_write_reg_value =
5412 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5414 cmdline_parse_inst_t cmd_write_reg = {
5415 .f = cmd_write_reg_parsed,
5417 .help_str = "write reg port_id reg_off reg_value",
5419 (void *)&cmd_write_reg_write,
5420 (void *)&cmd_write_reg_reg,
5421 (void *)&cmd_write_reg_port_id,
5422 (void *)&cmd_write_reg_reg_off,
5423 (void *)&cmd_write_reg_value,
5428 /* *** WRITE PORT REGISTER BIT FIELD *** */
5429 struct cmd_write_reg_bit_field_result {
5430 cmdline_fixed_string_t write;
5431 cmdline_fixed_string_t regfield;
5440 cmd_write_reg_bit_field_parsed(void *parsed_result,
5441 __attribute__((unused)) struct cmdline *cl,
5442 __attribute__((unused)) void *data)
5444 struct cmd_write_reg_bit_field_result *res = parsed_result;
5445 port_reg_bit_field_set(res->port_id, res->reg_off,
5446 res->bit1_pos, res->bit2_pos, res->value);
5449 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5450 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5452 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5453 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5454 regfield, "regfield");
5455 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5456 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5458 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5459 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5461 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5462 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5464 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5465 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5467 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5468 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5471 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5472 .f = cmd_write_reg_bit_field_parsed,
5474 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5475 "(set register bit field between bit_x and bit_y included)",
5477 (void *)&cmd_write_reg_bit_field_write,
5478 (void *)&cmd_write_reg_bit_field_regfield,
5479 (void *)&cmd_write_reg_bit_field_port_id,
5480 (void *)&cmd_write_reg_bit_field_reg_off,
5481 (void *)&cmd_write_reg_bit_field_bit1_pos,
5482 (void *)&cmd_write_reg_bit_field_bit2_pos,
5483 (void *)&cmd_write_reg_bit_field_value,
5488 /* *** WRITE PORT REGISTER BIT *** */
5489 struct cmd_write_reg_bit_result {
5490 cmdline_fixed_string_t write;
5491 cmdline_fixed_string_t regbit;
5499 cmd_write_reg_bit_parsed(void *parsed_result,
5500 __attribute__((unused)) struct cmdline *cl,
5501 __attribute__((unused)) void *data)
5503 struct cmd_write_reg_bit_result *res = parsed_result;
5504 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5507 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5508 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5510 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5511 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5513 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5514 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5515 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5516 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5517 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5518 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5519 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5520 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5522 cmdline_parse_inst_t cmd_write_reg_bit = {
5523 .f = cmd_write_reg_bit_parsed,
5525 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5527 (void *)&cmd_write_reg_bit_write,
5528 (void *)&cmd_write_reg_bit_regbit,
5529 (void *)&cmd_write_reg_bit_port_id,
5530 (void *)&cmd_write_reg_bit_reg_off,
5531 (void *)&cmd_write_reg_bit_bit_pos,
5532 (void *)&cmd_write_reg_bit_value,
5537 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5538 struct cmd_read_rxd_txd_result {
5539 cmdline_fixed_string_t read;
5540 cmdline_fixed_string_t rxd_txd;
5547 cmd_read_rxd_txd_parsed(void *parsed_result,
5548 __attribute__((unused)) struct cmdline *cl,
5549 __attribute__((unused)) void *data)
5551 struct cmd_read_rxd_txd_result *res = parsed_result;
5553 if (!strcmp(res->rxd_txd, "rxd"))
5554 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5555 else if (!strcmp(res->rxd_txd, "txd"))
5556 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5559 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5560 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5561 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5562 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5564 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5565 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5566 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5567 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5568 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5569 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5571 cmdline_parse_inst_t cmd_read_rxd_txd = {
5572 .f = cmd_read_rxd_txd_parsed,
5574 .help_str = "read rxd|txd port_id queue_id rxd_id",
5576 (void *)&cmd_read_rxd_txd_read,
5577 (void *)&cmd_read_rxd_txd_rxd_txd,
5578 (void *)&cmd_read_rxd_txd_port_id,
5579 (void *)&cmd_read_rxd_txd_queue_id,
5580 (void *)&cmd_read_rxd_txd_desc_id,
5586 struct cmd_quit_result {
5587 cmdline_fixed_string_t quit;
5590 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5592 __attribute__((unused)) void *data)
5598 cmdline_parse_token_string_t cmd_quit_quit =
5599 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5601 cmdline_parse_inst_t cmd_quit = {
5602 .f = cmd_quit_parsed,
5604 .help_str = "exit application",
5606 (void *)&cmd_quit_quit,
5611 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5612 struct cmd_mac_addr_result {
5613 cmdline_fixed_string_t mac_addr_cmd;
5614 cmdline_fixed_string_t what;
5616 struct ether_addr address;
5619 static void cmd_mac_addr_parsed(void *parsed_result,
5620 __attribute__((unused)) struct cmdline *cl,
5621 __attribute__((unused)) void *data)
5623 struct cmd_mac_addr_result *res = parsed_result;
5626 if (strcmp(res->what, "add") == 0)
5627 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5629 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5631 /* check the return value and print it if is < 0 */
5633 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5637 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5638 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5640 cmdline_parse_token_string_t cmd_mac_addr_what =
5641 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5643 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5644 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5645 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5646 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5648 cmdline_parse_inst_t cmd_mac_addr = {
5649 .f = cmd_mac_addr_parsed,
5651 .help_str = "mac_addr add|remove X <address>: "
5652 "add/remove MAC address on port X",
5654 (void *)&cmd_mac_addr_cmd,
5655 (void *)&cmd_mac_addr_what,
5656 (void *)&cmd_mac_addr_portnum,
5657 (void *)&cmd_mac_addr_addr,
5663 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5664 struct cmd_set_qmap_result {
5665 cmdline_fixed_string_t set;
5666 cmdline_fixed_string_t qmap;
5667 cmdline_fixed_string_t what;
5674 cmd_set_qmap_parsed(void *parsed_result,
5675 __attribute__((unused)) struct cmdline *cl,
5676 __attribute__((unused)) void *data)
5678 struct cmd_set_qmap_result *res = parsed_result;
5679 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5681 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5684 cmdline_parse_token_string_t cmd_setqmap_set =
5685 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5687 cmdline_parse_token_string_t cmd_setqmap_qmap =
5688 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5690 cmdline_parse_token_string_t cmd_setqmap_what =
5691 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5693 cmdline_parse_token_num_t cmd_setqmap_portid =
5694 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5696 cmdline_parse_token_num_t cmd_setqmap_queueid =
5697 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5699 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5700 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5703 cmdline_parse_inst_t cmd_set_qmap = {
5704 .f = cmd_set_qmap_parsed,
5706 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5708 (void *)&cmd_setqmap_set,
5709 (void *)&cmd_setqmap_qmap,
5710 (void *)&cmd_setqmap_what,
5711 (void *)&cmd_setqmap_portid,
5712 (void *)&cmd_setqmap_queueid,
5713 (void *)&cmd_setqmap_mapvalue,
5718 /* *** CONFIGURE UNICAST HASH TABLE *** */
5719 struct cmd_set_uc_hash_table {
5720 cmdline_fixed_string_t set;
5721 cmdline_fixed_string_t port;
5723 cmdline_fixed_string_t what;
5724 struct ether_addr address;
5725 cmdline_fixed_string_t mode;
5729 cmd_set_uc_hash_parsed(void *parsed_result,
5730 __attribute__((unused)) struct cmdline *cl,
5731 __attribute__((unused)) void *data)
5734 struct cmd_set_uc_hash_table *res = parsed_result;
5736 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5738 if (strcmp(res->what, "uta") == 0)
5739 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5740 &res->address,(uint8_t)is_on);
5742 printf("bad unicast hash table parameter, return code = %d \n", ret);
5746 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5749 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5752 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5753 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5755 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5756 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5758 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5759 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5761 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5762 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5765 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5766 .f = cmd_set_uc_hash_parsed,
5768 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5770 (void *)&cmd_set_uc_hash_set,
5771 (void *)&cmd_set_uc_hash_port,
5772 (void *)&cmd_set_uc_hash_portid,
5773 (void *)&cmd_set_uc_hash_what,
5774 (void *)&cmd_set_uc_hash_mac,
5775 (void *)&cmd_set_uc_hash_mode,
5780 struct cmd_set_uc_all_hash_table {
5781 cmdline_fixed_string_t set;
5782 cmdline_fixed_string_t port;
5784 cmdline_fixed_string_t what;
5785 cmdline_fixed_string_t value;
5786 cmdline_fixed_string_t mode;
5790 cmd_set_uc_all_hash_parsed(void *parsed_result,
5791 __attribute__((unused)) struct cmdline *cl,
5792 __attribute__((unused)) void *data)
5795 struct cmd_set_uc_all_hash_table *res = parsed_result;
5797 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5799 if ((strcmp(res->what, "uta") == 0) &&
5800 (strcmp(res->value, "all") == 0))
5801 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5803 printf("bad unicast hash table parameter,"
5804 "return code = %d \n", ret);
5807 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5808 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5810 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5811 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5813 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5814 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5816 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5817 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5819 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5820 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5822 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5823 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5826 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5827 .f = cmd_set_uc_all_hash_parsed,
5829 .help_str = "set port X uta all on|off (X = port number)",
5831 (void *)&cmd_set_uc_all_hash_set,
5832 (void *)&cmd_set_uc_all_hash_port,
5833 (void *)&cmd_set_uc_all_hash_portid,
5834 (void *)&cmd_set_uc_all_hash_what,
5835 (void *)&cmd_set_uc_all_hash_value,
5836 (void *)&cmd_set_uc_all_hash_mode,
5841 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5842 struct cmd_set_vf_macvlan_filter {
5843 cmdline_fixed_string_t set;
5844 cmdline_fixed_string_t port;
5846 cmdline_fixed_string_t vf;
5848 struct ether_addr address;
5849 cmdline_fixed_string_t filter_type;
5850 cmdline_fixed_string_t mode;
5854 cmd_set_vf_macvlan_parsed(void *parsed_result,
5855 __attribute__((unused)) struct cmdline *cl,
5856 __attribute__((unused)) void *data)
5859 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5860 struct rte_eth_mac_filter filter;
5862 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5864 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5866 /* set VF MAC filter */
5870 filter.dst_id = res->vf_id;
5872 if (!strcmp(res->filter_type, "exact-mac"))
5873 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5874 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5875 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5876 else if (!strcmp(res->filter_type, "hashmac"))
5877 filter.filter_type = RTE_MAC_HASH_MATCH;
5878 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5879 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5881 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5884 ret = rte_eth_dev_filter_ctrl(res->port_id,
5885 RTE_ETH_FILTER_MACVLAN,
5889 ret = rte_eth_dev_filter_ctrl(res->port_id,
5890 RTE_ETH_FILTER_MACVLAN,
5891 RTE_ETH_FILTER_DELETE,
5895 printf("bad set MAC hash parameter, return code = %d\n", ret);
5899 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5900 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5902 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5903 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5905 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5906 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5908 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5911 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5912 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5914 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5915 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5917 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5919 filter_type, "exact-mac#exact-mac-vlan"
5920 "#hashmac#hashmac-vlan");
5921 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5922 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5925 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5926 .f = cmd_set_vf_macvlan_parsed,
5928 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5929 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5931 "exact match rule:exact match of MAC or MAC and VLAN; "
5932 "hash match rule: hash match of MAC and exact match "
5935 (void *)&cmd_set_vf_macvlan_set,
5936 (void *)&cmd_set_vf_macvlan_port,
5937 (void *)&cmd_set_vf_macvlan_portid,
5938 (void *)&cmd_set_vf_macvlan_vf,
5939 (void *)&cmd_set_vf_macvlan_vf_id,
5940 (void *)&cmd_set_vf_macvlan_mac,
5941 (void *)&cmd_set_vf_macvlan_filter_type,
5942 (void *)&cmd_set_vf_macvlan_mode,
5947 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5948 struct cmd_set_vf_traffic {
5949 cmdline_fixed_string_t set;
5950 cmdline_fixed_string_t port;
5952 cmdline_fixed_string_t vf;
5954 cmdline_fixed_string_t what;
5955 cmdline_fixed_string_t mode;
5959 cmd_set_vf_traffic_parsed(void *parsed_result,
5960 __attribute__((unused)) struct cmdline *cl,
5961 __attribute__((unused)) void *data)
5963 struct cmd_set_vf_traffic *res = parsed_result;
5964 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5965 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5967 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5970 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5971 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5973 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5974 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5976 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5977 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5979 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5980 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5982 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5983 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5985 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5986 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5988 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5989 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5992 cmdline_parse_inst_t cmd_set_vf_traffic = {
5993 .f = cmd_set_vf_traffic_parsed,
5995 .help_str = "set port X vf Y rx|tx on|off"
5996 "(X = port number,Y = vf id)",
5998 (void *)&cmd_setvf_traffic_set,
5999 (void *)&cmd_setvf_traffic_port,
6000 (void *)&cmd_setvf_traffic_portid,
6001 (void *)&cmd_setvf_traffic_vf,
6002 (void *)&cmd_setvf_traffic_vfid,
6003 (void *)&cmd_setvf_traffic_what,
6004 (void *)&cmd_setvf_traffic_mode,
6009 /* *** CONFIGURE VF RECEIVE MODE *** */
6010 struct cmd_set_vf_rxmode {
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;
6018 cmdline_fixed_string_t on;
6022 cmd_set_vf_rxmode_parsed(void *parsed_result,
6023 __attribute__((unused)) struct cmdline *cl,
6024 __attribute__((unused)) void *data)
6027 uint16_t rx_mode = 0;
6028 struct cmd_set_vf_rxmode *res = parsed_result;
6030 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6031 if (!strcmp(res->what,"rxmode")) {
6032 if (!strcmp(res->mode, "AUPE"))
6033 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6034 else if (!strcmp(res->mode, "ROPE"))
6035 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6036 else if (!strcmp(res->mode, "BAM"))
6037 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6038 else if (!strncmp(res->mode, "MPE",3))
6039 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6042 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6044 printf("bad VF receive mode parameter, return code = %d \n",
6048 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6049 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6051 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6052 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6054 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6055 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6057 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6058 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6060 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6061 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6063 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6064 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6066 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6067 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6068 mode, "AUPE#ROPE#BAM#MPE");
6069 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6070 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6073 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6074 .f = cmd_set_vf_rxmode_parsed,
6076 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6078 (void *)&cmd_set_vf_rxmode_set,
6079 (void *)&cmd_set_vf_rxmode_port,
6080 (void *)&cmd_set_vf_rxmode_portid,
6081 (void *)&cmd_set_vf_rxmode_vf,
6082 (void *)&cmd_set_vf_rxmode_vfid,
6083 (void *)&cmd_set_vf_rxmode_what,
6084 (void *)&cmd_set_vf_rxmode_mode,
6085 (void *)&cmd_set_vf_rxmode_on,
6090 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6091 struct cmd_vf_mac_addr_result {
6092 cmdline_fixed_string_t mac_addr_cmd;
6093 cmdline_fixed_string_t what;
6094 cmdline_fixed_string_t port;
6096 cmdline_fixed_string_t vf;
6098 struct ether_addr address;
6101 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6102 __attribute__((unused)) struct cmdline *cl,
6103 __attribute__((unused)) void *data)
6105 struct cmd_vf_mac_addr_result *res = parsed_result;
6108 if (strcmp(res->what, "add") == 0)
6109 ret = rte_eth_dev_mac_addr_add(res->port_num,
6110 &res->address, res->vf_num);
6112 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6116 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6117 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6118 mac_addr_cmd,"mac_addr");
6119 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6120 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6122 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6123 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6125 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6126 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6128 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6129 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6131 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6132 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6134 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6135 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6138 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6139 .f = cmd_vf_mac_addr_parsed,
6141 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6142 "Y = VF number)add MAC address filtering for a VF on port X",
6144 (void *)&cmd_vf_mac_addr_cmd,
6145 (void *)&cmd_vf_mac_addr_what,
6146 (void *)&cmd_vf_mac_addr_port,
6147 (void *)&cmd_vf_mac_addr_portnum,
6148 (void *)&cmd_vf_mac_addr_vf,
6149 (void *)&cmd_vf_mac_addr_vfnum,
6150 (void *)&cmd_vf_mac_addr_addr,
6155 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6156 struct cmd_vf_rx_vlan_filter {
6157 cmdline_fixed_string_t rx_vlan;
6158 cmdline_fixed_string_t what;
6160 cmdline_fixed_string_t port;
6162 cmdline_fixed_string_t vf;
6167 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6168 __attribute__((unused)) struct cmdline *cl,
6169 __attribute__((unused)) void *data)
6171 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6173 if (!strcmp(res->what, "add"))
6174 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6176 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6179 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6180 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6181 rx_vlan, "rx_vlan");
6182 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6183 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6185 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6186 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6188 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6189 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6191 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6192 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6194 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6195 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6197 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6198 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6201 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6202 .f = cmd_vf_rx_vlan_filter_parsed,
6204 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6205 "Y = port number,Z = hexadecimal VF mask)",
6207 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6208 (void *)&cmd_vf_rx_vlan_filter_what,
6209 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6210 (void *)&cmd_vf_rx_vlan_filter_port,
6211 (void *)&cmd_vf_rx_vlan_filter_portid,
6212 (void *)&cmd_vf_rx_vlan_filter_vf,
6213 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6218 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6219 struct cmd_queue_rate_limit_result {
6220 cmdline_fixed_string_t set;
6221 cmdline_fixed_string_t port;
6223 cmdline_fixed_string_t queue;
6225 cmdline_fixed_string_t rate;
6229 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6230 __attribute__((unused)) struct cmdline *cl,
6231 __attribute__((unused)) void *data)
6233 struct cmd_queue_rate_limit_result *res = parsed_result;
6236 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6237 && (strcmp(res->queue, "queue") == 0)
6238 && (strcmp(res->rate, "rate") == 0))
6239 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6242 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6246 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6247 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6249 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6250 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6252 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6253 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6255 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6256 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6258 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6259 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6261 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6262 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6264 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6265 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6268 cmdline_parse_inst_t cmd_queue_rate_limit = {
6269 .f = cmd_queue_rate_limit_parsed,
6271 .help_str = "set port X queue Y rate Z:(X = port number,"
6272 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6274 (void *)&cmd_queue_rate_limit_set,
6275 (void *)&cmd_queue_rate_limit_port,
6276 (void *)&cmd_queue_rate_limit_portnum,
6277 (void *)&cmd_queue_rate_limit_queue,
6278 (void *)&cmd_queue_rate_limit_queuenum,
6279 (void *)&cmd_queue_rate_limit_rate,
6280 (void *)&cmd_queue_rate_limit_ratenum,
6285 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6286 struct cmd_vf_rate_limit_result {
6287 cmdline_fixed_string_t set;
6288 cmdline_fixed_string_t port;
6290 cmdline_fixed_string_t vf;
6292 cmdline_fixed_string_t rate;
6294 cmdline_fixed_string_t q_msk;
6298 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6299 __attribute__((unused)) struct cmdline *cl,
6300 __attribute__((unused)) void *data)
6302 struct cmd_vf_rate_limit_result *res = parsed_result;
6305 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6306 && (strcmp(res->vf, "vf") == 0)
6307 && (strcmp(res->rate, "rate") == 0)
6308 && (strcmp(res->q_msk, "queue_mask") == 0))
6309 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6310 res->rate_num, res->q_msk_val);
6312 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6316 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6317 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6319 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6320 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6322 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6323 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6325 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6326 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6328 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6329 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6331 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6332 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6334 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6335 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6337 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6338 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6339 q_msk, "queue_mask");
6340 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6341 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6344 cmdline_parse_inst_t cmd_vf_rate_limit = {
6345 .f = cmd_vf_rate_limit_parsed,
6347 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6348 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6349 "for queues of VF on port X",
6351 (void *)&cmd_vf_rate_limit_set,
6352 (void *)&cmd_vf_rate_limit_port,
6353 (void *)&cmd_vf_rate_limit_portnum,
6354 (void *)&cmd_vf_rate_limit_vf,
6355 (void *)&cmd_vf_rate_limit_vfnum,
6356 (void *)&cmd_vf_rate_limit_rate,
6357 (void *)&cmd_vf_rate_limit_ratenum,
6358 (void *)&cmd_vf_rate_limit_q_msk,
6359 (void *)&cmd_vf_rate_limit_q_msk_val,
6364 /* *** ADD TUNNEL FILTER OF A PORT *** */
6365 struct cmd_tunnel_filter_result {
6366 cmdline_fixed_string_t cmd;
6367 cmdline_fixed_string_t what;
6369 struct ether_addr outer_mac;
6370 struct ether_addr inner_mac;
6371 cmdline_ipaddr_t ip_value;
6372 uint16_t inner_vlan;
6373 cmdline_fixed_string_t tunnel_type;
6374 cmdline_fixed_string_t filter_type;
6380 cmd_tunnel_filter_parsed(void *parsed_result,
6381 __attribute__((unused)) struct cmdline *cl,
6382 __attribute__((unused)) void *data)
6384 struct cmd_tunnel_filter_result *res = parsed_result;
6385 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6388 tunnel_filter_conf.outer_mac = &res->outer_mac;
6389 tunnel_filter_conf.inner_mac = &res->inner_mac;
6390 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6392 if (res->ip_value.family == AF_INET) {
6393 tunnel_filter_conf.ip_addr.ipv4_addr =
6394 res->ip_value.addr.ipv4.s_addr;
6395 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6397 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6398 &(res->ip_value.addr.ipv6),
6399 sizeof(struct in6_addr));
6400 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6403 if (!strcmp(res->filter_type, "imac-ivlan"))
6404 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6405 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6406 tunnel_filter_conf.filter_type =
6407 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6408 else if (!strcmp(res->filter_type, "imac-tenid"))
6409 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6410 else if (!strcmp(res->filter_type, "imac"))
6411 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6412 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6413 tunnel_filter_conf.filter_type =
6414 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6416 printf("The filter type is not supported");
6420 if (!strcmp(res->tunnel_type, "vxlan"))
6421 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6423 printf("Only VXLAN is supported now.\n");
6427 tunnel_filter_conf.tenant_id = res->tenant_id;
6428 tunnel_filter_conf.queue_id = res->queue_num;
6429 if (!strcmp(res->what, "add"))
6430 ret = rte_eth_dev_filter_ctrl(res->port_id,
6431 RTE_ETH_FILTER_TUNNEL,
6433 &tunnel_filter_conf);
6435 ret = rte_eth_dev_filter_ctrl(res->port_id,
6436 RTE_ETH_FILTER_TUNNEL,
6437 RTE_ETH_FILTER_DELETE,
6438 &tunnel_filter_conf);
6440 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6444 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6445 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6446 cmd, "tunnel_filter");
6447 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6448 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6450 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6451 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6453 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6454 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6456 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6457 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6459 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6460 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6461 inner_vlan, UINT16);
6462 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6463 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6465 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6466 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6467 tunnel_type, "vxlan");
6469 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6470 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6471 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6472 "imac#omac-imac-tenid");
6473 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6474 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6476 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6477 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6480 cmdline_parse_inst_t cmd_tunnel_filter = {
6481 .f = cmd_tunnel_filter_parsed,
6483 .help_str = "add/rm tunnel filter of a port: "
6484 "tunnel_filter add port_id outer_mac inner_mac ip "
6485 "inner_vlan tunnel_type(vxlan) filter_type "
6486 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6487 "imac|omac-imac-tenid) "
6488 "tenant_id queue_num",
6490 (void *)&cmd_tunnel_filter_cmd,
6491 (void *)&cmd_tunnel_filter_what,
6492 (void *)&cmd_tunnel_filter_port_id,
6493 (void *)&cmd_tunnel_filter_outer_mac,
6494 (void *)&cmd_tunnel_filter_inner_mac,
6495 (void *)&cmd_tunnel_filter_ip_value,
6496 (void *)&cmd_tunnel_filter_innner_vlan,
6497 (void *)&cmd_tunnel_filter_tunnel_type,
6498 (void *)&cmd_tunnel_filter_filter_type,
6499 (void *)&cmd_tunnel_filter_tenant_id,
6500 (void *)&cmd_tunnel_filter_queue_num,
6505 /* *** CONFIGURE TUNNEL UDP PORT *** */
6506 struct cmd_tunnel_udp_config {
6507 cmdline_fixed_string_t cmd;
6508 cmdline_fixed_string_t what;
6514 cmd_tunnel_udp_config_parsed(void *parsed_result,
6515 __attribute__((unused)) struct cmdline *cl,
6516 __attribute__((unused)) void *data)
6518 struct cmd_tunnel_udp_config *res = parsed_result;
6519 struct rte_eth_udp_tunnel tunnel_udp;
6522 tunnel_udp.udp_port = res->udp_port;
6524 if (!strcmp(res->cmd, "rx_vxlan_port"))
6525 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6527 if (!strcmp(res->what, "add"))
6528 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6530 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6533 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6536 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6537 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6538 cmd, "rx_vxlan_port");
6539 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6540 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6542 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6543 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6545 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6546 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6549 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6550 .f = cmd_tunnel_udp_config_parsed,
6552 .help_str = "add/rm an tunneling UDP port filter: "
6553 "rx_vxlan_port add udp_port port_id",
6555 (void *)&cmd_tunnel_udp_config_cmd,
6556 (void *)&cmd_tunnel_udp_config_what,
6557 (void *)&cmd_tunnel_udp_config_udp_port,
6558 (void *)&cmd_tunnel_udp_config_port_id,
6563 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6564 struct cmd_set_mirror_mask_result {
6565 cmdline_fixed_string_t set;
6566 cmdline_fixed_string_t port;
6568 cmdline_fixed_string_t mirror;
6570 cmdline_fixed_string_t what;
6571 cmdline_fixed_string_t value;
6572 cmdline_fixed_string_t dstpool;
6574 cmdline_fixed_string_t on;
6577 cmdline_parse_token_string_t cmd_mirror_mask_set =
6578 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6580 cmdline_parse_token_string_t cmd_mirror_mask_port =
6581 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6583 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6584 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6586 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6587 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6588 mirror, "mirror-rule");
6589 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6590 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6592 cmdline_parse_token_string_t cmd_mirror_mask_what =
6593 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6594 what, "pool-mirror#vlan-mirror");
6595 cmdline_parse_token_string_t cmd_mirror_mask_value =
6596 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6598 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6599 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6600 dstpool, "dst-pool");
6601 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6602 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6604 cmdline_parse_token_string_t cmd_mirror_mask_on =
6605 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6609 cmd_set_mirror_mask_parsed(void *parsed_result,
6610 __attribute__((unused)) struct cmdline *cl,
6611 __attribute__((unused)) void *data)
6614 struct cmd_set_mirror_mask_result *res = parsed_result;
6615 struct rte_eth_vmdq_mirror_conf mr_conf;
6617 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6619 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6621 mr_conf.dst_pool = res->dstpool_id;
6623 if (!strcmp(res->what, "pool-mirror")) {
6624 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6625 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6626 } else if(!strcmp(res->what, "vlan-mirror")) {
6627 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6628 nb_item = parse_item_list(res->value, "core",
6629 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6633 for(i=0; i < nb_item; i++) {
6634 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6635 printf("Invalid vlan_id: must be < 4096\n");
6639 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6640 mr_conf.vlan.vlan_mask |= 1ULL << i;
6644 if(!strcmp(res->on, "on"))
6645 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6648 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6651 printf("mirror rule add error: (%s)\n", strerror(-ret));
6654 cmdline_parse_inst_t cmd_set_mirror_mask = {
6655 .f = cmd_set_mirror_mask_parsed,
6657 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6658 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6660 (void *)&cmd_mirror_mask_set,
6661 (void *)&cmd_mirror_mask_port,
6662 (void *)&cmd_mirror_mask_portid,
6663 (void *)&cmd_mirror_mask_mirror,
6664 (void *)&cmd_mirror_mask_ruleid,
6665 (void *)&cmd_mirror_mask_what,
6666 (void *)&cmd_mirror_mask_value,
6667 (void *)&cmd_mirror_mask_dstpool,
6668 (void *)&cmd_mirror_mask_poolid,
6669 (void *)&cmd_mirror_mask_on,
6674 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6675 struct cmd_set_mirror_link_result {
6676 cmdline_fixed_string_t set;
6677 cmdline_fixed_string_t port;
6679 cmdline_fixed_string_t mirror;
6681 cmdline_fixed_string_t what;
6682 cmdline_fixed_string_t dstpool;
6684 cmdline_fixed_string_t on;
6687 cmdline_parse_token_string_t cmd_mirror_link_set =
6688 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6690 cmdline_parse_token_string_t cmd_mirror_link_port =
6691 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6693 cmdline_parse_token_num_t cmd_mirror_link_portid =
6694 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6696 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6697 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6698 mirror, "mirror-rule");
6699 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6700 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6702 cmdline_parse_token_string_t cmd_mirror_link_what =
6703 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6704 what, "uplink-mirror#downlink-mirror");
6705 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6706 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6707 dstpool, "dst-pool");
6708 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6709 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6711 cmdline_parse_token_string_t cmd_mirror_link_on =
6712 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6716 cmd_set_mirror_link_parsed(void *parsed_result,
6717 __attribute__((unused)) struct cmdline *cl,
6718 __attribute__((unused)) void *data)
6721 struct cmd_set_mirror_link_result *res = parsed_result;
6722 struct rte_eth_vmdq_mirror_conf mr_conf;
6724 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6725 if(!strcmp(res->what, "uplink-mirror")) {
6726 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6727 }else if(!strcmp(res->what, "downlink-mirror"))
6728 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6730 mr_conf.dst_pool = res->dstpool_id;
6732 if(!strcmp(res->on, "on"))
6733 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6736 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6739 /* check the return value and print it if is < 0 */
6741 printf("mirror rule add error: (%s)\n", strerror(-ret));
6745 cmdline_parse_inst_t cmd_set_mirror_link = {
6746 .f = cmd_set_mirror_link_parsed,
6748 .help_str = "set port X mirror-rule Y uplink-mirror|"
6749 "downlink-mirror dst-pool Z on|off",
6751 (void *)&cmd_mirror_link_set,
6752 (void *)&cmd_mirror_link_port,
6753 (void *)&cmd_mirror_link_portid,
6754 (void *)&cmd_mirror_link_mirror,
6755 (void *)&cmd_mirror_link_ruleid,
6756 (void *)&cmd_mirror_link_what,
6757 (void *)&cmd_mirror_link_dstpool,
6758 (void *)&cmd_mirror_link_poolid,
6759 (void *)&cmd_mirror_link_on,
6764 /* *** RESET VM MIRROR RULE *** */
6765 struct cmd_rm_mirror_rule_result {
6766 cmdline_fixed_string_t reset;
6767 cmdline_fixed_string_t port;
6769 cmdline_fixed_string_t mirror;
6773 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6774 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6776 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6777 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6779 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6780 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6782 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6783 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6784 mirror, "mirror-rule");
6785 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6786 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6790 cmd_reset_mirror_rule_parsed(void *parsed_result,
6791 __attribute__((unused)) struct cmdline *cl,
6792 __attribute__((unused)) void *data)
6795 struct cmd_set_mirror_link_result *res = parsed_result;
6797 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6799 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6802 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6803 .f = cmd_reset_mirror_rule_parsed,
6805 .help_str = "reset port X mirror-rule Y",
6807 (void *)&cmd_rm_mirror_rule_reset,
6808 (void *)&cmd_rm_mirror_rule_port,
6809 (void *)&cmd_rm_mirror_rule_portid,
6810 (void *)&cmd_rm_mirror_rule_mirror,
6811 (void *)&cmd_rm_mirror_rule_ruleid,
6816 /* ******************************************************************************** */
6818 struct cmd_dump_result {
6819 cmdline_fixed_string_t dump;
6823 dump_struct_sizes(void)
6825 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6826 DUMP_SIZE(struct rte_mbuf);
6827 DUMP_SIZE(struct rte_mempool);
6828 DUMP_SIZE(struct rte_ring);
6832 static void cmd_dump_parsed(void *parsed_result,
6833 __attribute__((unused)) struct cmdline *cl,
6834 __attribute__((unused)) void *data)
6836 struct cmd_dump_result *res = parsed_result;
6838 if (!strcmp(res->dump, "dump_physmem"))
6839 rte_dump_physmem_layout(stdout);
6840 else if (!strcmp(res->dump, "dump_memzone"))
6841 rte_memzone_dump(stdout);
6842 else if (!strcmp(res->dump, "dump_log_history"))
6843 rte_log_dump_history(stdout);
6844 else if (!strcmp(res->dump, "dump_struct_sizes"))
6845 dump_struct_sizes();
6846 else if (!strcmp(res->dump, "dump_ring"))
6847 rte_ring_list_dump(stdout);
6848 else if (!strcmp(res->dump, "dump_mempool"))
6849 rte_mempool_list_dump(stdout);
6850 else if (!strcmp(res->dump, "dump_devargs"))
6851 rte_eal_devargs_dump(stdout);
6854 cmdline_parse_token_string_t cmd_dump_dump =
6855 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6859 "dump_struct_sizes#"
6864 cmdline_parse_inst_t cmd_dump = {
6865 .f = cmd_dump_parsed, /* function to call */
6866 .data = NULL, /* 2nd arg of func */
6867 .help_str = "dump status",
6868 .tokens = { /* token list, NULL terminated */
6869 (void *)&cmd_dump_dump,
6874 /* ******************************************************************************** */
6876 struct cmd_dump_one_result {
6877 cmdline_fixed_string_t dump;
6878 cmdline_fixed_string_t name;
6881 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6882 __attribute__((unused)) void *data)
6884 struct cmd_dump_one_result *res = parsed_result;
6886 if (!strcmp(res->dump, "dump_ring")) {
6888 r = rte_ring_lookup(res->name);
6890 cmdline_printf(cl, "Cannot find ring\n");
6893 rte_ring_dump(stdout, r);
6894 } else if (!strcmp(res->dump, "dump_mempool")) {
6895 struct rte_mempool *mp;
6896 mp = rte_mempool_lookup(res->name);
6898 cmdline_printf(cl, "Cannot find mempool\n");
6901 rte_mempool_dump(stdout, mp);
6905 cmdline_parse_token_string_t cmd_dump_one_dump =
6906 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6907 "dump_ring#dump_mempool");
6909 cmdline_parse_token_string_t cmd_dump_one_name =
6910 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6912 cmdline_parse_inst_t cmd_dump_one = {
6913 .f = cmd_dump_one_parsed, /* function to call */
6914 .data = NULL, /* 2nd arg of func */
6915 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6916 .tokens = { /* token list, NULL terminated */
6917 (void *)&cmd_dump_one_dump,
6918 (void *)&cmd_dump_one_name,
6923 /* *** ADD/REMOVE an ethertype FILTER *** */
6924 struct cmd_ethertype_filter_result {
6925 cmdline_fixed_string_t filter;
6927 cmdline_fixed_string_t ethertype;
6928 uint16_t ethertype_value;
6929 cmdline_fixed_string_t priority;
6930 cmdline_fixed_string_t priority_en;
6931 uint8_t priority_value;
6932 cmdline_fixed_string_t queue;
6934 cmdline_fixed_string_t index;
6935 uint16_t index_value;
6939 cmd_ethertype_filter_parsed(void *parsed_result,
6940 __attribute__((unused)) struct cmdline *cl,
6941 __attribute__((unused)) void *data)
6944 struct cmd_ethertype_filter_result *res = parsed_result;
6945 struct rte_ethertype_filter filter;
6947 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
6948 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
6949 filter.priority = res->priority_value;
6951 if (!strcmp(res->priority_en, "enable"))
6952 filter.priority_en = 1;
6953 if (!strcmp(res->filter, "add_ethertype_filter"))
6954 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
6956 &filter, res->queue_id);
6957 else if (!strcmp(res->filter, "remove_ethertype_filter"))
6958 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
6960 else if (!strcmp(res->filter, "get_ethertype_filter"))
6961 get_ethertype_filter(res->port_id, res->index_value);
6964 printf("ethertype filter setting error: (%s)\n",
6968 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
6969 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6971 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
6972 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6973 ethertype, "ethertype");
6974 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
6975 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6976 ethertype_value, UINT16);
6977 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
6978 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6979 priority, "priority");
6980 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
6981 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6982 priority_en, "enable#disable");
6983 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
6984 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6985 priority_value, UINT8);
6986 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
6987 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6989 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
6990 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6992 cmdline_parse_token_string_t cmd_ethertype_filter_index =
6993 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6995 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
6996 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6997 index_value, UINT16);
6998 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
6999 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7000 filter, "add_ethertype_filter");
7001 cmdline_parse_inst_t cmd_add_ethertype_filter = {
7002 .f = cmd_ethertype_filter_parsed,
7004 .help_str = "add an ethertype filter",
7006 (void *)&cmd_ethertype_filter_add_filter,
7007 (void *)&cmd_ethertype_filter_port_id,
7008 (void *)&cmd_ethertype_filter_ethertype,
7009 (void *)&cmd_ethertype_filter_ethertype_value,
7010 (void *)&cmd_ethertype_filter_priority,
7011 (void *)&cmd_ethertype_filter_priority_en,
7012 (void *)&cmd_ethertype_filter_priority_value,
7013 (void *)&cmd_ethertype_filter_queue,
7014 (void *)&cmd_ethertype_filter_queue_id,
7015 (void *)&cmd_ethertype_filter_index,
7016 (void *)&cmd_ethertype_filter_index_value,
7021 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
7022 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7023 filter, "remove_ethertype_filter");
7024 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
7025 .f = cmd_ethertype_filter_parsed,
7027 .help_str = "remove an ethertype filter",
7029 (void *)&cmd_ethertype_filter_remove_filter,
7030 (void *)&cmd_ethertype_filter_port_id,
7031 (void *)&cmd_ethertype_filter_index,
7032 (void *)&cmd_ethertype_filter_index_value,
7036 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
7037 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7038 filter, "get_ethertype_filter");
7039 cmdline_parse_inst_t cmd_get_ethertype_filter = {
7040 .f = cmd_ethertype_filter_parsed,
7042 .help_str = "get an ethertype filter",
7044 (void *)&cmd_ethertype_filter_get_filter,
7045 (void *)&cmd_ethertype_filter_port_id,
7046 (void *)&cmd_ethertype_filter_index,
7047 (void *)&cmd_ethertype_filter_index_value,
7052 /* *** set SYN filter *** */
7053 struct cmd_set_syn_filter_result {
7054 cmdline_fixed_string_t filter;
7056 cmdline_fixed_string_t priority;
7057 cmdline_fixed_string_t high;
7058 cmdline_fixed_string_t queue;
7063 cmd_set_syn_filter_parsed(void *parsed_result,
7064 __attribute__((unused)) struct cmdline *cl,
7065 __attribute__((unused)) void *data)
7068 struct cmd_set_syn_filter_result *res = parsed_result;
7069 struct rte_syn_filter filter;
7071 if (!strcmp(res->filter, "add_syn_filter")) {
7072 if (!strcmp(res->high, "high"))
7076 ret = rte_eth_dev_add_syn_filter(res->port_id,
7077 &filter, res->queue_id);
7078 } else if (!strcmp(res->filter, "remove_syn_filter"))
7079 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7080 else if (!strcmp(res->filter, "get_syn_filter"))
7081 get_syn_filter(res->port_id);
7083 printf("syn filter setting error: (%s)\n", strerror(-ret));
7086 cmdline_parse_token_num_t cmd_syn_filter_portid =
7087 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7089 cmdline_parse_token_string_t cmd_syn_filter_priority =
7090 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7091 priority, "priority");
7092 cmdline_parse_token_string_t cmd_syn_filter_high =
7093 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7095 cmdline_parse_token_string_t cmd_syn_filter_queue =
7096 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7098 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7099 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7101 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7102 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7103 filter, "add_syn_filter");
7104 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7105 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7106 filter, "remove_syn_filter");
7107 cmdline_parse_inst_t cmd_add_syn_filter = {
7108 .f = cmd_set_syn_filter_parsed,
7110 .help_str = "add syn filter",
7112 (void *)&cmd_syn_filter_add_filter,
7113 (void *)&cmd_syn_filter_portid,
7114 (void *)&cmd_syn_filter_priority,
7115 (void *)&cmd_syn_filter_high,
7116 (void *)&cmd_syn_filter_queue,
7117 (void *)&cmd_syn_filter_queue_id,
7121 cmdline_parse_inst_t cmd_remove_syn_filter = {
7122 .f = cmd_set_syn_filter_parsed,
7124 .help_str = "remove syn filter",
7126 (void *)&cmd_syn_filter_remove_filter,
7127 (void *)&cmd_syn_filter_portid,
7132 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7133 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7134 filter, "get_syn_filter");
7136 cmdline_parse_inst_t cmd_get_syn_filter = {
7137 .f = cmd_set_syn_filter_parsed,
7139 .help_str = "get syn filter",
7141 (void *)&cmd_syn_filter_get_filter,
7142 (void *)&cmd_syn_filter_portid,
7147 /* *** ADD/REMOVE A 2tuple FILTER *** */
7148 struct cmd_2tuple_filter_result {
7149 cmdline_fixed_string_t filter;
7151 cmdline_fixed_string_t protocol;
7152 uint8_t protocol_value;
7153 uint8_t protocol_mask;
7154 cmdline_fixed_string_t dst_port;
7155 uint16_t dst_port_value;
7156 uint16_t dst_port_mask;
7157 cmdline_fixed_string_t flags;
7158 uint8_t flags_value;
7159 cmdline_fixed_string_t priority;
7160 uint8_t priority_value;
7161 cmdline_fixed_string_t queue;
7163 cmdline_fixed_string_t index;
7164 uint16_t index_value;
7168 cmd_2tuple_filter_parsed(void *parsed_result,
7169 __attribute__((unused)) struct cmdline *cl,
7170 __attribute__((unused)) void *data)
7173 struct rte_2tuple_filter filter;
7174 struct cmd_2tuple_filter_result *res = parsed_result;
7176 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7178 if (!strcmp(res->filter, "add_2tuple_filter")) {
7179 /* need convert to big endian. */
7180 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7181 filter.protocol = res->protocol_value;
7182 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7183 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7184 filter.priority = res->priority_value;
7185 filter.tcp_flags = res->flags_value;
7186 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7187 res->index_value, &filter, res->queue_id);
7188 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7189 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7191 else if (!strcmp(res->filter, "get_2tuple_filter"))
7192 get_2tuple_filter(res->port_id, res->index_value);
7195 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7198 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7199 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7201 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7202 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7203 protocol, "protocol");
7204 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7205 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7206 protocol_value, UINT8);
7207 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7208 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7209 protocol_mask, UINT8);
7210 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7211 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7212 dst_port, "dst_port");
7213 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7214 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7215 dst_port_value, UINT16);
7216 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7217 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7218 dst_port_mask, UINT16);
7219 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7220 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7222 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7223 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7224 flags_value, UINT8);
7225 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7226 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7227 priority, "priority");
7228 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7229 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7230 priority_value, UINT8);
7231 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7232 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7234 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7235 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7237 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7238 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7240 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7241 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7242 index_value, UINT16);
7243 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7244 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7245 filter, "add_2tuple_filter");
7246 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7247 .f = cmd_2tuple_filter_parsed,
7249 .help_str = "add a 2tuple filter",
7251 (void *)&cmd_2tuple_filter_add_filter,
7252 (void *)&cmd_2tuple_filter_port_id,
7253 (void *)&cmd_2tuple_filter_protocol,
7254 (void *)&cmd_2tuple_filter_protocol_value,
7255 (void *)&cmd_2tuple_filter_protocol_mask,
7256 (void *)&cmd_2tuple_filter_dst_port,
7257 (void *)&cmd_2tuple_filter_dst_port_value,
7258 (void *)&cmd_2tuple_filter_dst_port_mask,
7259 (void *)&cmd_2tuple_filter_flags,
7260 (void *)&cmd_2tuple_filter_flags_value,
7261 (void *)&cmd_2tuple_filter_priority,
7262 (void *)&cmd_2tuple_filter_priority_value,
7263 (void *)&cmd_2tuple_filter_queue,
7264 (void *)&cmd_2tuple_filter_queue_id,
7265 (void *)&cmd_2tuple_filter_index,
7266 (void *)&cmd_2tuple_filter_index_value,
7271 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7272 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7273 filter, "remove_2tuple_filter");
7274 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7275 .f = cmd_2tuple_filter_parsed,
7277 .help_str = "remove a 2tuple filter",
7279 (void *)&cmd_2tuple_filter_remove_filter,
7280 (void *)&cmd_2tuple_filter_port_id,
7281 (void *)&cmd_2tuple_filter_index,
7282 (void *)&cmd_2tuple_filter_index_value,
7286 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7287 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7288 filter, "get_2tuple_filter");
7289 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7290 .f = cmd_2tuple_filter_parsed,
7292 .help_str = "get a 2tuple filter",
7294 (void *)&cmd_2tuple_filter_get_filter,
7295 (void *)&cmd_2tuple_filter_port_id,
7296 (void *)&cmd_2tuple_filter_index,
7297 (void *)&cmd_2tuple_filter_index_value,
7302 /* *** ADD/REMOVE A 5tuple FILTER *** */
7303 struct cmd_5tuple_filter_result {
7304 cmdline_fixed_string_t filter;
7306 cmdline_fixed_string_t dst_ip;
7307 cmdline_ipaddr_t dst_ip_value;
7308 cmdline_fixed_string_t src_ip;
7309 cmdline_ipaddr_t src_ip_value;
7310 cmdline_fixed_string_t dst_port;
7311 uint16_t dst_port_value;
7312 cmdline_fixed_string_t src_port;
7313 uint16_t src_port_value;
7314 cmdline_fixed_string_t protocol;
7315 uint8_t protocol_value;
7316 cmdline_fixed_string_t mask;
7318 cmdline_fixed_string_t flags;
7319 uint8_t flags_value;
7320 cmdline_fixed_string_t priority;
7321 uint8_t priority_value;
7322 cmdline_fixed_string_t queue;
7324 cmdline_fixed_string_t index;
7325 uint16_t index_value;
7329 cmd_5tuple_filter_parsed(void *parsed_result,
7330 __attribute__((unused)) struct cmdline *cl,
7331 __attribute__((unused)) void *data)
7334 struct rte_5tuple_filter filter;
7335 struct cmd_5tuple_filter_result *res = parsed_result;
7337 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7339 if (!strcmp(res->filter, "add_5tuple_filter")) {
7340 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7341 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7342 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7343 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7344 filter.protocol = res->protocol_value;
7345 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7346 filter.priority = res->priority_value;
7347 filter.tcp_flags = res->flags_value;
7349 if (res->dst_ip_value.family == AF_INET)
7350 /* no need to convert, already big endian. */
7351 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7353 if (filter.dst_ip_mask == 0) {
7354 printf("can not support ipv6 involved compare.\n");
7360 if (res->src_ip_value.family == AF_INET)
7361 /* no need to convert, already big endian. */
7362 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7364 if (filter.src_ip_mask == 0) {
7365 printf("can not support ipv6 involved compare.\n");
7370 /* need convert to big endian. */
7371 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7372 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7374 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7375 res->index_value, &filter, res->queue_id);
7376 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7377 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7379 else if (!strcmp(res->filter, "get_5tuple_filter"))
7380 get_5tuple_filter(res->port_id, res->index_value);
7382 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7386 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7387 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7389 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7390 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7392 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7393 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7395 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7396 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7398 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7399 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7401 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7402 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7403 dst_port, "dst_port");
7404 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7405 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7406 dst_port_value, UINT16);
7407 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7408 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7409 src_port, "src_port");
7410 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7411 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7412 src_port_value, UINT16);
7413 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7414 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7415 protocol, "protocol");
7416 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7417 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7418 protocol_value, UINT8);
7419 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7420 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7422 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7423 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7425 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7426 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7428 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7429 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7430 flags_value, UINT8);
7431 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7432 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7433 priority, "priority");
7434 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7435 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7436 priority_value, UINT8);
7437 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7438 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7440 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7441 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7443 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7444 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7446 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7447 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7448 index_value, UINT16);
7450 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7451 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7452 filter, "add_5tuple_filter");
7453 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7454 .f = cmd_5tuple_filter_parsed,
7456 .help_str = "add a 5tuple filter",
7458 (void *)&cmd_5tuple_filter_add_filter,
7459 (void *)&cmd_5tuple_filter_port_id,
7460 (void *)&cmd_5tuple_filter_dst_ip,
7461 (void *)&cmd_5tuple_filter_dst_ip_value,
7462 (void *)&cmd_5tuple_filter_src_ip,
7463 (void *)&cmd_5tuple_filter_src_ip_value,
7464 (void *)&cmd_5tuple_filter_dst_port,
7465 (void *)&cmd_5tuple_filter_dst_port_value,
7466 (void *)&cmd_5tuple_filter_src_port,
7467 (void *)&cmd_5tuple_filter_src_port_value,
7468 (void *)&cmd_5tuple_filter_protocol,
7469 (void *)&cmd_5tuple_filter_protocol_value,
7470 (void *)&cmd_5tuple_filter_mask,
7471 (void *)&cmd_5tuple_filter_mask_value,
7472 (void *)&cmd_5tuple_filter_flags,
7473 (void *)&cmd_5tuple_filter_flags_value,
7474 (void *)&cmd_5tuple_filter_priority,
7475 (void *)&cmd_5tuple_filter_priority_value,
7476 (void *)&cmd_5tuple_filter_queue,
7477 (void *)&cmd_5tuple_filter_queue_id,
7478 (void *)&cmd_5tuple_filter_index,
7479 (void *)&cmd_5tuple_filter_index_value,
7484 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7485 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7486 filter, "remove_5tuple_filter");
7487 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7488 .f = cmd_5tuple_filter_parsed,
7490 .help_str = "remove a 5tuple filter",
7492 (void *)&cmd_5tuple_filter_remove_filter,
7493 (void *)&cmd_5tuple_filter_port_id,
7494 (void *)&cmd_5tuple_filter_index,
7495 (void *)&cmd_5tuple_filter_index_value,
7500 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7501 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7502 filter, "get_5tuple_filter");
7503 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7504 .f = cmd_5tuple_filter_parsed,
7506 .help_str = "get a 5tuple filter",
7508 (void *)&cmd_5tuple_filter_get_filter,
7509 (void *)&cmd_5tuple_filter_port_id,
7510 (void *)&cmd_5tuple_filter_index,
7511 (void *)&cmd_5tuple_filter_index_value,
7516 /* *** ADD/REMOVE A flex FILTER *** */
7517 struct cmd_flex_filter_result {
7518 cmdline_fixed_string_t filter;
7520 cmdline_fixed_string_t len;
7522 cmdline_fixed_string_t bytes;
7523 cmdline_fixed_string_t bytes_value;
7524 cmdline_fixed_string_t mask;
7525 cmdline_fixed_string_t mask_value;
7526 cmdline_fixed_string_t priority;
7527 uint8_t priority_value;
7528 cmdline_fixed_string_t queue;
7530 cmdline_fixed_string_t index;
7531 uint16_t index_value;
7534 static int xdigit2val(unsigned char c)
7539 else if (isupper(c))
7547 cmd_flex_filter_parsed(void *parsed_result,
7548 __attribute__((unused)) struct cmdline *cl,
7549 __attribute__((unused)) void *data)
7552 struct rte_flex_filter filter;
7553 struct cmd_flex_filter_result *res = parsed_result;
7554 char *bytes_ptr, *mask_ptr;
7562 if (!strcmp(res->filter, "add_flex_filter")) {
7563 if (res->len_value > 128) {
7564 printf("the len exceed the max length 128\n");
7567 memset(&filter, 0, sizeof(struct rte_flex_filter));
7568 filter.len = res->len_value;
7569 filter.priority = res->priority_value;
7570 bytes_ptr = res->bytes_value;
7571 mask_ptr = res->mask_value;
7574 /* translate bytes string to uint_32 array. */
7575 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7576 (bytes_ptr[1] == 'X')))
7578 len = strnlen(bytes_ptr, res->len_value * 2);
7579 if (len == 0 || (len % 8 != 0)) {
7580 printf("please check len and bytes input\n");
7583 for (i = 0; i < len; i++) {
7585 if (isxdigit(c) == 0) {
7586 /* invalid characters. */
7587 printf("invalid input\n");
7590 val = xdigit2val(c);
7594 dword |= byte << (4 * mod - 4);
7599 filter.dwords[j] = dword;
7600 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7606 /* translate mask string to uint8_t array. */
7608 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7609 (mask_ptr[1] == 'X')))
7611 len = strnlen(mask_ptr, (res->len_value+3)/4);
7613 printf("invalid input\n");
7616 for (i = 0; i < len; i++) {
7618 if (isxdigit(c) == 0) {
7619 /* invalid characters. */
7620 printf("invalid input\n");
7623 val = xdigit2val(c);
7624 hex |= (uint8_t)(val & 0x8) >> 3;
7625 hex |= (uint8_t)(val & 0x4) >> 1;
7626 hex |= (uint8_t)(val & 0x2) << 1;
7627 hex |= (uint8_t)(val & 0x1) << 3;
7630 filter.mask[j] = byte;
7631 printf("mask[%d]:%02x ", j, filter.mask[j]);
7639 printf("call function rte_eth_dev_add_flex_filter: "
7640 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7641 res->index_value, res->queue_id,
7642 filter.len, filter.priority);
7643 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7644 &filter, res->queue_id);
7646 } else if (!strcmp(res->filter, "remove_flex_filter"))
7647 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7649 else if (!strcmp(res->filter, "get_flex_filter"))
7650 get_flex_filter(res->port_id, res->index_value);
7653 printf("flex filter setting error: (%s)\n", strerror(-ret));
7656 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7657 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7659 cmdline_parse_token_string_t cmd_flex_filter_len =
7660 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7662 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7663 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7665 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7666 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7668 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7669 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7671 cmdline_parse_token_string_t cmd_flex_filter_mask =
7672 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7674 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7675 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7677 cmdline_parse_token_string_t cmd_flex_filter_priority =
7678 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7679 priority, "priority");
7680 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7681 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7682 priority_value, UINT8);
7683 cmdline_parse_token_string_t cmd_flex_filter_queue =
7684 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7686 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7687 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7689 cmdline_parse_token_string_t cmd_flex_filter_index =
7690 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7692 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7693 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7694 index_value, UINT16);
7695 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7696 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7697 filter, "add_flex_filter");
7698 cmdline_parse_inst_t cmd_add_flex_filter = {
7699 .f = cmd_flex_filter_parsed,
7701 .help_str = "add a flex filter",
7703 (void *)&cmd_flex_filter_add_filter,
7704 (void *)&cmd_flex_filter_port_id,
7705 (void *)&cmd_flex_filter_len,
7706 (void *)&cmd_flex_filter_len_value,
7707 (void *)&cmd_flex_filter_bytes,
7708 (void *)&cmd_flex_filter_bytes_value,
7709 (void *)&cmd_flex_filter_mask,
7710 (void *)&cmd_flex_filter_mask_value,
7711 (void *)&cmd_flex_filter_priority,
7712 (void *)&cmd_flex_filter_priority_value,
7713 (void *)&cmd_flex_filter_queue,
7714 (void *)&cmd_flex_filter_queue_id,
7715 (void *)&cmd_flex_filter_index,
7716 (void *)&cmd_flex_filter_index_value,
7721 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7722 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7723 filter, "remove_flex_filter");
7724 cmdline_parse_inst_t cmd_remove_flex_filter = {
7725 .f = cmd_flex_filter_parsed,
7727 .help_str = "remove a flex filter",
7729 (void *)&cmd_flex_filter_remove_filter,
7730 (void *)&cmd_flex_filter_port_id,
7731 (void *)&cmd_flex_filter_index,
7732 (void *)&cmd_flex_filter_index_value,
7737 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7738 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7739 filter, "get_flex_filter");
7740 cmdline_parse_inst_t cmd_get_flex_filter = {
7741 .f = cmd_flex_filter_parsed,
7743 .help_str = "get a flex filter",
7745 (void *)&cmd_flex_filter_get_filter,
7746 (void *)&cmd_flex_filter_port_id,
7747 (void *)&cmd_flex_filter_index,
7748 (void *)&cmd_flex_filter_index_value,
7753 /* ******************************************************************************** */
7755 /* list of instructions */
7756 cmdline_parse_ctx_t main_ctx[] = {
7757 (cmdline_parse_inst_t *)&cmd_help_brief,
7758 (cmdline_parse_inst_t *)&cmd_help_long,
7759 (cmdline_parse_inst_t *)&cmd_quit,
7760 (cmdline_parse_inst_t *)&cmd_showport,
7761 (cmdline_parse_inst_t *)&cmd_showportall,
7762 (cmdline_parse_inst_t *)&cmd_showcfg,
7763 (cmdline_parse_inst_t *)&cmd_start,
7764 (cmdline_parse_inst_t *)&cmd_start_tx_first,
7765 (cmdline_parse_inst_t *)&cmd_set_link_up,
7766 (cmdline_parse_inst_t *)&cmd_set_link_down,
7767 (cmdline_parse_inst_t *)&cmd_reset,
7768 (cmdline_parse_inst_t *)&cmd_set_numbers,
7769 (cmdline_parse_inst_t *)&cmd_set_txpkts,
7770 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
7771 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
7772 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
7773 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
7774 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
7775 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
7776 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
7777 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
7778 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
7779 (cmdline_parse_inst_t *)&cmd_set_link_check,
7780 #ifdef RTE_NIC_BYPASS
7781 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
7782 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
7783 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
7784 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
7786 #ifdef RTE_LIBRTE_PMD_BOND
7787 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
7788 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
7789 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
7790 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
7791 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
7792 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
7793 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
7794 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
7796 (cmdline_parse_inst_t *)&cmd_vlan_offload,
7797 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
7798 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
7799 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
7800 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
7801 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
7802 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
7803 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
7804 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
7805 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
7806 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
7807 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
7808 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
7809 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
7810 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
7811 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
7812 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
7813 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
7814 (cmdline_parse_inst_t *)&cmd_config_dcb,
7815 (cmdline_parse_inst_t *)&cmd_read_reg,
7816 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
7817 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
7818 (cmdline_parse_inst_t *)&cmd_write_reg,
7819 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
7820 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
7821 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
7822 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
7823 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
7824 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
7825 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
7826 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
7827 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
7828 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
7829 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
7830 (cmdline_parse_inst_t *)&cmd_stop,
7831 (cmdline_parse_inst_t *)&cmd_mac_addr,
7832 (cmdline_parse_inst_t *)&cmd_set_qmap,
7833 (cmdline_parse_inst_t *)&cmd_operate_port,
7834 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
7835 (cmdline_parse_inst_t *)&cmd_config_speed_all,
7836 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
7837 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
7838 (cmdline_parse_inst_t *)&cmd_config_mtu,
7839 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
7840 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
7841 (cmdline_parse_inst_t *)&cmd_config_rss,
7842 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
7843 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
7844 (cmdline_parse_inst_t *)&cmd_showport_reta,
7845 (cmdline_parse_inst_t *)&cmd_config_burst,
7846 (cmdline_parse_inst_t *)&cmd_config_thresh,
7847 (cmdline_parse_inst_t *)&cmd_config_threshold,
7848 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
7849 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
7850 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
7851 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
7852 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
7853 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
7854 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
7855 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
7856 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
7857 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
7858 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
7859 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
7860 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
7861 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
7862 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
7863 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
7864 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
7865 (cmdline_parse_inst_t *)&cmd_dump,
7866 (cmdline_parse_inst_t *)&cmd_dump_one,
7867 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
7868 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
7869 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
7870 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
7871 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
7872 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
7873 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
7874 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
7875 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
7876 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
7877 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
7878 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
7879 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
7880 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
7881 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
7885 /* prompt function, called from main on MASTER lcore */
7891 /* initialize non-constant commands */
7892 cmd_set_fwd_mode_init();
7894 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
7898 cmdline_interact(cl);
7899 cmdline_stdin_exit(cl);
7903 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
7905 if (id < nb_ports) {
7906 /* check if need_reconfig has been set to 1 */
7907 if (ports[id].need_reconfig == 0)
7908 ports[id].need_reconfig = dev;
7909 /* check if need_reconfig_queues has been set to 1 */
7910 if (ports[id].need_reconfig_queues == 0)
7911 ports[id].need_reconfig_queues = queue;
7915 for (pid = 0; pid < nb_ports; pid++) {
7916 /* check if need_reconfig has been set to 1 */
7917 if (ports[pid].need_reconfig == 0)
7918 ports[pid].need_reconfig = dev;
7919 /* check if need_reconfig_queues has been set to 1 */
7920 if (ports[pid].need_reconfig_queues == 0)
7921 ports[pid].need_reconfig_queues = queue;
7926 #ifdef RTE_NIC_BYPASS
7928 bypass_is_supported(portid_t port_id)
7930 struct rte_port *port;
7931 struct rte_pci_id *pci_id;
7933 if (port_id >= nb_ports) {
7934 printf("\tPort id must be less than %d.\n", nb_ports);
7938 /* Get the device id. */
7939 port = &ports[port_id];
7940 pci_id = &port->dev_info.pci_dev->id;
7942 /* Check if NIC supports bypass. */
7943 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
7947 printf("\tBypass not supported for port_id = %d.\n", port_id);